Subversion Repositories cheapmusic

Rev

Rev 134 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
function clean_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
}

include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/hosting.php");
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/tools.php");
include_once ($_SERVER['DOCUMENT_ROOT'] . "/php/htmlTools.php");
$_SESSION["htmlIndent"] = 2;
$_SESSION["nonce"] = "";
$_SESSION["gtag"] = "";

error_reporting(E_ALL);

$startDate = date_create();
date_add($startDate,date_interval_create_from_date_string("-14 days"));    
$endDate = date_create();
$width = 1024;
$height = 600;
$uniqueIP = false;
$chartType = "bars";


if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (!empty($_POST['startDate'])) {
        $startDate = date_create(clean_input($_POST['startDate']));
    }
    if (!empty($_POST['endDate'])) {
        $endDate = date_create(clean_input($_POST['endDate']));
    }
    if (!empty($_POST['width'])) {
        $width = clean_input($_POST['width']);
    }
    if (!empty($_POST['height'])) {
        $height = clean_input($_POST['height']);
    }
    if (isset($_POST['unique'])) {
        $uniqueIP = true;
    }
    if (!empty($_POST['type'])) {
        $chartType = clean_input($_POST['type']);
    }
}
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Find Cheap Music: Searches and Transfers</title>
    <?php echo htmlHeader(); ?>
</head>
<body>

    <form method="post" action="/report.php">
        <nav class="navbar navbar-expand-sm bg-black navbar-dark fixed-top">
            <div class="navbar-header">
                <button type="submit" name="submitBtn" value="Search" class="btn text-white">Find Cheap Music</button>
            </div>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
                <span class="navbar-toggler-icon"></span>
            </button>
        </nav>
    </form>

    <form method="post" action="/report.php">
<div class="mt-2">        
<label class="mr-2" for="startDate">Start Date: </label><input name="startDate" type="date" value="<?php echo date_format($startDate,"Y-m-d"); ?>" /> 
<label class="mx-2" for="endDate">End Date: </label><input name="endDate" type="date" value="<?php echo  date_format($endDate,"Y-m-d"); ?>" /> 
</div>
 <div class="mt-2">
  <label class="mr-2" for="type">Select Chart Type:</label>
  <select name="type">
    <option <?php if ($chartType == "bars") echo "selected";?>>bars</option>
    <option <?php if ($chartType == "area") echo "selected";?>>area</option>
    <option <?php if ($chartType == "linepoints") echo "selected";?>>linepoints</option>
    <option <?php if ($chartType == "liones") echo "selected";?>>lines</option>
    <option <?php if ($chartType == "pie") echo "selected";?>>pie</option>
    <option <?php if ($chartType == "points") echo "selected";?>>points</option>
    <option <?php if ($chartType == "squared") echo "selected";?>>squared</option>
    <option <?php if ($chartType == "squaredarea") echo "selected";?>>squaredarea</option>
    <option <?php if ($chartType == "stackedarea") echo "selected";?>>stackedarea</option>
    <option <?php if ($chartType == "stackedbars") echo "selected";?>>stackedbars</option>
    <option <?php if ($chartType == "stackedsquaredarea") echo "selected";?>>stackedsquaredarea</option>
    <option <?php if ($chartType == "thinbarline") echo "selected";?>>thinbarline</option>
  </select>
</div> 
<div class="form-check mt-2"">
  <label class="form-check-label">
    <input type="checkbox" name="unique" class="form-check-input" value="" <?php if ($uniqueIP) echo 'checked';?> />Unique IP
  </label>
</div>

<div class="mt-2">
<label class="mr-2" for="width">Width: </label><input name="width" type="number" value="<?php echo $width;?>" /> 
<label class="mx-2" for="height">Height: </label><input name="height" type="number" value="<?php echo $height;?>" /> 
</div>
<div class="mt-2">
<input type="submit" name="submitBtn" value="Submit" />
</div>
    </form>
    
<hr>

<?php 
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        //echo "<pre>"; print_r($_POST); echo "</pre>";
        $params = "start=" . date_format($startDate,"Ymd");
        $params .= "&end=" . date_format($endDate,"Ymd");
        $params .= "&width=" . $width;
        $params .= "&height=" . $height;
        $params .= "&type=" . $chartType;
        $params .= "&unique=" . ($uniqueIP ? "1" : "0");
        echo '<img  class="mx-auto d-block img-fluid" src="/plotimage.php?' . $params . '" alt="Searches and Transfers Image" />';
    }
?>
    <footer class="container-fluid text-center bg-primary py-5">
        <p>Copyright &#169; <?php echo @date("Y"); ?> FindCheapMusic.com. All rights reserved.</p>
    </footer>

    <?php echo downloadAtOnload(); ?>

</body>
</html>