Overige software > Web Station
Hoe kan ik een php html script dat bij een index html hoort zien
(1/1)
spidy601:
DSM7.2.....
Ik heb een nieuwe nas en ik heb een stukje website dat gebruik maakt van een index html die verwijst weer door naar een index php file
Het is een website dat verzoekplaatjes door stuurt naar de radio
Nu kan ik met mijn url wel de index file te voorschijn halen door domijnnaamsynologyserver/test/request-index.html dit gaat goed
Maar als deze index webpagina dan door wil verwijzen naar domijnnaamsynology/test/song-request-resultaten.php
Dan krijg ik code 500 te zien.
Ik weet niet wat ik fout doe.
Of hoe ik dit instellen moet op de synology suport website wordt ik ook niet veel wijzer van veel te technisch.
Op mijn vorige ds 112j lade de song-request-resultaten.php wel maar kon ik de buttons niet gebruiken omdat de ds112j geen java scripts ondersteund
Ik heb nu maar de verzoekserver draaien op Windows desktop computer via xamp
Maar het zou mooi zijn als ik het op de synology webserver kan laten draaien
Maar hoe doe ik dat
Wyodor:
De domeinnamen zijn verschillend:
https://domijnnaamsynologyserver/test/request-index.html
en
https://domijnnaamsynology/test/song-request-resultaten.php
En Javascript wordt door de browser uitgevoerd. Niet door de server.
En error 500 is meestal een configuratiefout.
Wellicht is het tonen van echte code een goed idee.
spidy601:
ik probeer het script te plaatsen in dit forum maar het forum ziet het als spam
ik heb het bestand nu gedeelt vanaf mijn server.
php javascript geeft fout weet niet hoe dit komt [mod edit: script staat in de volgende posting]
dit is het stukje website wat nu gehost wordt vanaf mijn computer via xamp
de werkende verzoek server als de computer aanstaat
dit is de website die ik heel simpel gemaakt heb waar ook de verzoek server op staat via iframe
de verzoek server in een iframe
mocht het toch iets wezen in de synology dan kan ik mijn teamvieuwer gegevesn van de synology server wel geven
Briolet:
Ik heb het bestand gedownload, maar ik krijg geen spammelding bij plaatsen.
--- Code: ---<?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>';
?>
--- Einde van code ---
jr212:
Ik krijg al zeker 2 fouten
Warning: Undefined array key "search" in song-request-results.php on line 17
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in song-request-results.php on line 18
Het is trouwens een héééééél oud script. php 5 is al jaren dood.
Zoek eens iets recenter of schrijf zelf.
Hoewel voor nas vragen deze site 1 van de beste is, de beste in het NL, voor php vragen kan je misschien beter terecht op phphulp.nl
Verder zou je op zijn minst de log moeten aanstellen. Dan zie je dan wat het probleem is.
Ga naar webstation
kies voor scripttaalinstellingen
bewerk gebruikersprofiel (of een ander als je zelf iets anders heb gesteld als standaard)
kies tab core
zoek naar error_log
vul een correct en volledig pad naar een logbestand in. Bij mij is dit /volume7/web2/logs/ds2_error.log
zorg er voor dat deze log NIET onder web valt en dat http schrijfrechten heeft op deze share
kijk naar de inhoud van het bestand zodra je een foutmelding krijgt uit de 500 groep dus ook 501, 502,...
Begin altijd bovenaan omdat 1 lijn oplossen 10-tallen fouten kan oplossen. zie ook uw code. Als 17 ok is is 18 ook opgelost:)
terug naar uw code.
schrijven op dezelfde plaats als de via internettoegankelijke plaatsen. Dit moet buiten de root staan. Veiligheid!
Geen controle of er wel iets gepost is
het gebruik van globals ipv return
Jan
Navigatie
[0] Berichtenindex
Naar de volledige versie