<?php
// Copyright 2010-2016 by Jeff Harris - Jeff@HookedOnThe.Net
// Do not modify PHP code below this line.
error_reporting(E_ALL ^ E_NOTICE);
$version = "version 3.3 - 2016-07-01";
require_once ("config.php");
require_once ("function.php");
// Check banlist
if (!empty ($banfile)) {
$banlist = @file ($banfile);
if (is_array ($banlist))
if (in_array ($_SERVER["REMOTE_ADDR"]."\r\n", $banlist)) {
echo "
Sorry, you are not allowed to use this request form.
\r\n";
exit;
}
}
// Get current count from cookie
if (!isset ($_COOKIE["SPS1"])) {
$day = time ()+86400;
$value = $requestsperday.":".$day;
$daycount = $requestsperday;
setcookie ("SPS1", $value, $day);
$errormsg = "Cookies must be enabled in your browser in order to use this request feature. \r\n";
} else {
list ($daycount, $day) = explode (":", $_COOKIE["SPS1"]);
}
if (!isset ($_COOKIE["SPS2"])) {
$hour = time ()+3600;
$value = $requestsperhour.":".$hour;
$hourcount = $requestsperhour;
setcookie ("SPS2", $value, $hour);
} else {
list ($hourcount, $hour) = explode (":", $_COOKIE["SPS2"]);
}
$script = $_SERVER["SCRIPT_NAME"];
if (!empty ($libdir)) $path = $libdir."/";
$func = $_REQUEST["func"];
if ($func == "Send Your Request") { // Insert request
// Validate request
if (empty ($_POST["rq"])) {
$errormsg .= "No request was selected. Please try again. \r\n";
$func = "Search";
} else if (($namefield == 2) && empty ($_POST["name"])) {
$errormsg .= "Your name is required. Please try again. \r\n";
$func = "Search";
} else if (($locationfield == 2) && empty ($_POST["location"])) {
$errormsg .= "Your location is required. Please try again. \r\n";
$func = "Search";
} else if (($daycount > 0) && ($hourcount > 0)) {
$rq = rawurldecode ($_POST["rq"]);
if (get_magic_quotes_gpc ())
$rq = stripslashes ($rq);
$name = rawurldecode ($_POST["name"]);
if (get_magic_quotes_gpc ())
$name = stripslashes ($name);
$location = rawurldecode ($_POST["location"]);
if (get_magic_quotes_gpc ())
$location = stripslashes ($location);
if ($expire > 0) $exp = time()+($expire*86400);
else $exp = 0;
setcookie ("SPS3", "$name|$location", $exp);
// Insert request
$command = "Insert Request=".$rq."|".$_SERVER["REMOTE_ADDR"];
if ($namefield || $locationfield)
$command .= "|".$name."|".$location;
$command .= "\r\n";
$fp = @fsockopen("$studiohost", $studioport, $errno, $errstr, 10); //open connection
if ($fp !== false) {
fwrite ($fp, $command);
$errormsg = fgets ($fp);
fclose ($fp);
if (stripos ($errormsg, "has been submitted") !== false) {
$daycount -= 1;
setcookie ("SPS1", "$daycount:$day", $day);
$hourcount -= 1;
setcookie ("SPS2", "$hourcount:$hour", $hour);
}
} else {
$errormsg .= "$errno: $errstr\r\n";
}
} else { // Request limit reached
$errormsg = "Sorry, you've reached your request limit. Please try again ";
if ($daycount == 0)
$errormsg .= timediff ($day, 1, 2);
else
$errormsg .= timediff ($hour, 1, 2);
$errormsg .= ".\r\n";
}
}
if ($func == "Search") { // Lookup request
if (isset ($_COOKIE["SPS3"])) {
list ($name, $location) = explode ("|", $_COOKIE["SPS3"]);
}
if (!empty ($_REQUEST["searchtext"])) {
$searchtext = rawurldecode ($_REQUEST["searchtext"]);
if (get_magic_quotes_gpc ())
$searchtext = stripslashes ($searchtext);
// Send search command
$command = "Search=*".$searchtext."*\r\n";
if (strpos ($searchtext, "*|") !== false) {
$command = "Search=".$searchtext."*\r\n";
if ($buildlib != 0) {
$f = $path.str_replace ("*|", "", $searchtext).".sdb";
$line = @file ($f, FILE_IGNORE_NEW_LINES);
}
}
if (!is_array ($line)) {
$fp = @fsockopen("$studiohost", $studioport, $errno, $errstr, 10); //open connection
if ($fp !== false) {
fwrite ($fp, $command);
$buffer = trim (fgets ($fp));
while (!empty ($buffer) && ($buffer != "Not Found")) {
$line[] = $buffer;
$buffer = trim (fgets ($fp));
}
fclose ($fp);
} else {
$errormsg .= "$errno: $errstr\r\n";
}
}
if (is_array ($line)) {
$results_page =
"\r\n".
"\r\n".
"Select | \r\n".
"Artist | \r\n".
"Title | \r\n".
"
\r\n";
for ($i=0; $i $artist | $title | \r\n";
}
}
$body .= "Searching for: ".str_replace ("*|", "", $searchtext)."
\r\n";
if (!empty ($results_page)) {
$results_page .= "
\r\n";
$body .= "Select the song you want to hear by clicking its radio button then click the submit button.
\r\n";
$body .= "\r\n";
} else { // No matches found
$errormsg = "Sorry, no matches were found. \r\n";
}
}
}
?>
<?php echo $sitename; ?> Requests
<?php
if (!empty ($css))
echo "\r\n";
?>