Ik heb het bestand gedownload, maar ik krijg geen spammelding bij plaatsen.
<?php
$files = glob("./request.*.txt");
$out = fopen("request-playlist.txt", "w");
foreach ($files as $file) {
fwrite($out, file_get_contents($file));
}
fclose($out);
/*
MAKE SURE YOU HAVE THE FIRST PAGE OF HTML TOO.
THE FORM ON IT CALLS THIS 2ND PAGE.
WITHOUT IT THE DEMO WON'T WORK!
*/
$search = $_POST['search'];
$search = str_replace('|','',$search); //remove pipe delimiter as database uses it
$search = str_replace('\"','"',$search); //fix difference between PHP4 and 5!
$search = strip_tags($search); //remove HTML tags
//remove spaces before or after a word:
$search = rtrim($search);
$search = ltrim($search);
//remove multiple spaces:
while ((substr_count($search,' ') >= 1)) {
//echo substr_count($search,' ');
//echo '<pre>'.$search.'</pre>';
$search = str_replace(' ',' ',$search);
}
//remove multiple speech marks:
while ((substr_count($search,'""') >= 1)) {
$search = str_replace('""','"',$search);
}
//define globals so they can be returned by functions
$GLOBALS['highlight1'] = '';
$GLOBALS['highlight2'] = '';
$GLOBALS['result'] = '';
function debug($lineno) {
echo '<em>PHP line no: '.$lineno.'</em>';
}
function test($variable,$lineno) {
echo '
<p><em>PHP line no: '.$lineno.'</em> TEST VARIABLE = '.$variable.'</p>
';
}
function highlight($colloop,$thefield,$thesearch) {
$fieldlength = strlen($thefield);
$searchlength = strlen($thesearch);
$pos = strpos($thefield, $thesearch);
$stringend = $searchlength + $pos;
$slice1 = substr($colloop, 0, $pos);
$slice2 = substr($colloop, $pos, $searchlength);
$slice3 = substr($colloop, $stringend);
$GLOBALS['result'] = $slice1.$GLOBALS['highlight1'].$slice2.$GLOBALS['highlight2'].$slice3; //rebuild text with highlight
// echo '<br />'.$GLOBALS['result'];
}
$title = 'Hier zijn uw zoekresultaten!';
$title2 = 'Indien beschikbaar, gebruik dan de knop (Aanvragen) hieronder om uw nummer op ons station aan te vragen!';
echo <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>$title</title>
<script language=JavaScript>
<!--
//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com
var message="Function Not Available";
///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
// -->
</script>
<script type="text/javascript" src="/js/common.js"></script>
<!-- Javascript for request and songinfo actions -->
<script type="text/javascript">
/**
* Open a popup window to send a song request to SAM
*/
function request(songID)
{
var samhost = "94.211.174.100";
var samport = "1221";
requestAudioRealm(songID, samhost, samport);
}
</script>
<script>
function goBack() {
window.history.back()
}
</script>
<style type="text/css">
html,body {color:#000; background-color:#eee}
body {padding-left:10px}
body, th, td, p, small {
font-family:'Times New Roman',Times,serif;
font-size:100%;
color:#444
}
fieldset {border:1px solid #eee; padding:0}
pre {font-size:90%} /* for non-Firefox browsers */
table {
background-color:#fff;
border:1px solid #ccf;
padding:3px;
margin-top:10px;
margin-bottom:10px
}
table#database {margin-top:32px}
td, th {
background-color:#def;
padding:7px 20px 7px 20px
}
th {background-color:#dee; color:#677}
.top-th {background-color:#eee}
h1, h2 {font-size:140%; color:#558}
h2 {margin-top:32px; font-size:120%}
h1 .sortby {color:#855}
form {margin-top:16px}
legend {font-weight:bold; color:#666; padding:0}
.found {font-weight:bold; background-color:#ff9}
#found {color:#666}
.count {background-color:#dee; color:#677; font-weight:bold; color:#666}
em {color:#c00} /* for PHP debugging */
</style>
</head>
<body>
<h1>$title</h1>
<h2>$title2</h2>
HTML;
if (($search == '') or ($search == '"')) {exit('Geen bruikbare zoekreeks gevonden!<FORM METHOD="LINK" ACTION="request-index.html"><INPUT TYPE="submit" VALUE="Klik om opnieuw te zoeken"></FORM>');}
$fp = fopen('request-playlist.txt','r');
if (!$fp) {exit('<p><b>ERROR: Unable to open database file!</b></p></body></html>');}
$row = 0;
while (!feof($fp)) {
$line = fgets($fp,1024); //use 2048 if very long lines
$col[$row] = ($row + 1).'|'.$line;
$row++;
}
fclose($fp);
// Avoid sort below if you have numbers at the start of each line!
//It puts all the lines beginning with 1 first, eg: 1, 10, 11, 12 etc.
//sort($col);
reset($col);
$arrays = count($col) - 1;
$tablecells = '';
$loop = -1;
$and = $once = $found = $found1 = $found2 = $bothfound = $search2also = 'no';
$count = 0;
$speechmarks = '';
//test for AND but not two words that must be together (""):
if ((strstr($search,' AND ')) and ($search[0] <> '"')) {
$and = 'yes';
list ($word1, $word2, $word3) = explode (' ', $search); //remove AND
$word1 = strtolower($word1);
$word3 = strtolower($word3);
if ($word1 == $word3) {
$search = $word1;
$and = 'no';
} else {
$search1 = $word1;
$search2 = $word3;
while ($loop < $arrays) {
$loop++;
$field = strtolower($col[$loop]);
if ((strstr($field,$search1)) and (strstr($field,$search2))) {
$found = $found1 = $found2 = $bothfound = 'yes';
//word1
highlight($col[$loop],$field,$search1);
$col[$loop] = $GLOBALS['result'];
//word2
$field = strtolower($col[$loop]); //update field to include highlighted version from above
highlight($col[$loop],$field,$search2);
//add rows
$col[$loop] = explode('|',$GLOBALS['result']);
$tablecells.='
<tr>
<td>'.$col[$loop][1].'</td>
<td>'.$col[$loop][2].'</td>
<td>'.$col[$loop][3].'</td>
<td>'.$col[$loop][4].'</td>
<td>'.$col[$loop][5].'</td>
<td>'.$col[$loop][6].'</td>
</tr>
';
$count++;
}
}
}
}
if (($and == 'no') and ($bothfound == 'no')) {
$search = strtolower($search);
$search1 = $search2 = '';
if (strstr($search,' ')) {
list ($search1, $search2) = explode (' ', $search);
if ($search2 == $search1) {//when both words are the same
$search = $search1; //make search just first word
$search1 = $search2 = ''; //destroy both words from split
}
}
//test for space in search but not two words that must be together (""):
if ((strstr($search,' ')) and ($search[0] <> '"')) {
list ($search1, $search2) = explode (' ', $search);
//search for two separate words
while ($loop < $arrays) {
$loop++;
$search2also = 'no';
$field = strtolower($col[$loop]);
$fieldkept = $field; //preserve text without web code
if (strstr($field,$search1)) {
if (strstr($field,$search2)) {$search2also = $bothfound = 'yes';}
$found = $found1 = 'yes';
highlight($col[$loop],$field,$search1);
$col[$loop] = $GLOBALS['result'];
if ($search2also <> 'yes') { //only output once when both words on same row
//add rows
$col[$loop] = explode('|',$GLOBALS['result']);
$tablecells.='
<tr>
<td>'.$col[$loop][1].'</td>
<td>'.$col[$loop][2].'</td>
<td>'.$col[$loop][3].'</td>
<td>'.$col[$loop][4].'</td>
<td>'.$col[$loop][5].'</td>
<td>'.$col[$loop][6].'</td>
</tr>
';
$count++;
}
}
$field = strtolower($col[$loop]); //update field to include highlighted version from above
if (strstr($fieldkept,$search2)) { //search on line without highlighting added
$found = $found2 = 'yes';
highlight($col[$loop],$field,$search2);
if (($search2also == 'yes') or ($found2 == 'yes')) {
//add rows
$col[$loop] = explode('|',$GLOBALS['result']);
$tablecells.='
<tr>
<td>'.$col[$loop][1].'</td>
<td>'.$col[$loop][2].'</td>
<td>'.$col[$loop][3].'</td>
<td>'.$col[$loop][4].'</td>
<td>'.$col[$loop][5].'</td>
<td>'.$col[$loop][6].'</td>
</tr>
';
$count++;
}
}
}
} else {
//check if speech marks and remove them:
if ($search[0] == '"') {
$search = str_replace('"','',$search);
$speechmarks = '\''; //for output later
}
if ($search <> '') {
//do normal search
while ($loop < $arrays) {
$loop++;
$field = strtolower($col[$loop]);
if (strstr($field,$search)) {
$found = $found1 = 'yes';
highlight($col[$loop],$field,$search);
//add rows
$col[$loop] = explode('|',$GLOBALS['result']);
$tablecells.='
<tr>
<td>'.$col[$loop][1].'</td>
<td>'.$col[$loop][2].'</td>
<td>'.$col[$loop][3].'</td>
<td>'.$col[$loop][4].'</td>
<td>'.$col[$loop][5].'</td>
<td>'.$col[$loop][6].'</td>
</tr>
';
$count++;
}
}
} else {exit('No usable search string found! <FORM METHOD="LINK" ACTION="request-index.html"><INPUT TYPE="submit" VALUE="Klik om opnieuw te zoeken"></FORM>');}
}
} //if ($and == 'no')
if ($found == 'yes') {
echo '<p>jouw zoek opdracht for <b>\''.$speechmarks.$search.$speechmarks.'\'</b> werd gevonden in het volgende '.$count.' resultaten van onze mediabibliotheek voor radiostations:</p>
<table summary="List of database fields matching the search">
<tr><td colspan="7"><center><FORM METHOD="LINK" ACTION="request-index.html"><INPUT TYPE="submit" VALUE="Klik om opnieuw te zoeken">
</FORM></center></td></tr>
<tr>
<th colspan="7" class="top-th">Zoekresultaten van de muziekbibliotheek van radiostations</th>
</tr>
<tr>
<th>Cd-cover</th>
<th>Artiest</th>
<th>Nummer</th>
<th>Album</th>
<th>Verzoek</th>
<th>Koop</th>
</tr>
'.$tablecells.'
<tr><td colspan="7"><center><FORM METHOD="LINK" ACTION="request-index.html"><INPUT TYPE="submit" VALUE="Klik om opnieuw te zoeken">
</FORM></center></td></tr>
</table>';
} else {
echo '<p>Uw zoektopdracht naar <b>\''.$speechmarks.$search.$speechmarks.'\'</b> was niet gevonden.</p><br><p><center><FORM METHOD="LINK" ACTION="request-index.html"><INPUT TYPE="submit" VALUE="Klik om opnieuw te zoeken"></FORM></center></p>';
}
echo '
<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=7937148;
var sc_invisible=1;
var sc_security="a5e51c3d";
</script>
<script type="text/javascript"
src="http://www.statcounter.com/counter/counter.js"></script>
<noscript><div class="statcounter"><a title="web analytics"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="http://c.statcounter.com/7937148/0/a5e51c3d/1/"
alt="web analytics"></a></div></noscript>
<!-- End of StatCounter Code for Default Guide -->
</body>
</html>';
?>