Parse error...
Hejsa.. den sigerParse error: parse error in search.php on line 139
Hvorfor? Hvis jeg retter på }, så poster den bare hele koden.. Hvad er der galt her?
Scriptet kommer fra http://www.eksperten.dk/spm/143567
Her er Scriptet:
<html>
<head>
<title>sitename - Søgeresultater</title>
</head>
<body>
<table align=center><tr><td>
// Variables
// Set your username and password. Leave blank if you don\'t want any protection.
$user = \"admin\";
$pass = \"password\";
// The full system path to the files you wish to index. DO NOT include trailing slash.
$file_root = \"http://localhost/Navision.dk\";
// The URL equivilent of the above. DO NOT include trailing slash.
$http_root = \"http://localhost/Navision.dk\";
// The full system path to the index file.
$index_file = \"http://localhost/Navision.dk/search_index.dat\";
// The full system path to the file of words to exclude.
$exclude_words = \"http://localhost/Navision.dk/exclude_words.txt\";
// The full system path to the file of files to exclude.
$exclude_files = \"http://localhost/Navision.dk/exclude_files.txt\";
// Set to true if you wish the time taken to be displayed when searching, false otherwise:
$show_time_search = true;
// Displays time taken when indexing if true:
$show_time_index = true;
// The array file file extentions to index. The extentions must be readable (no exe, jpg, gif)
$include_extentions = array(\'html\',\'htm\',\'shtml\',\'shtm\', \'php\', \'php3\', \'phtml\', \'php4\');
// Message variables:
$err_no_results = \"Ingen søgeresultater fundet - Prøv venligst igen...\";
$err_no_search_db = \"Could not find search database<br>Contact the administrator of this site.\";
$err_index = \"The index file could not be opened.<br><i>Check the path and permissions and try again.</i>\";
$index_complete = \"Your site has been indexed.\";
$index_cleared = \"Your site index has been cleared.<br>No search results will be found until you re-index your site.\";
$no_files = \"No files in the specified directory were available for indexing.\";
$no_dir = \"The directory you specified cannot be found.\";
// Sets the version.
$version = \"1.7.4\";
// Sets start time.
$timeparts = explode(\" \",microtime());
$starttime = $timeparts[1].substr($timeparts[0],1);
if (isset($query)) s_control($query);
elseif (substr($QUERY_STRING,0,5) == \"admin\") i_control();
else s_print_search_form(\"\");
c_print_footer();
function s_control($q) {
$orig = $q;
$result_arr = s_search($q);
$result_count = sizeof($result_arr);
if ($result_count < 1) {
echo \" <a href=\\\"../content.phtml?id=1\\\" class=\\\"lightbluelink\\\"><< Til indexsiden</a><br><br> <font class=\\\"txtbolddarkblue\\\">$GLOBALS[err_no_results]</font>\";
s_print_search_form($q);
}
else {
echo \"
<a href=\\\"../content.phtml?id=1\\\" class=\\\"lightbluelink\\\">>> Til indexsiden</a><br><br> <font class=\\\"txtbolddarkblue\\\">Hits: 1 - $result_count for søgning: \\\"$orig\\\"<br></font>
<ol class=\\\"txt\\\">\";
foreach ($result_arr as $result)
s_print_title_desc($result);
echo \"</ol>\";
s_print_search_form($orig);
}
}
function s_search($query) {
// Searches for query in the index file.
// Multiple word search originally contributed by Matthew Furister <matt@agtown.com>
$query = trim(strtolower(c_strip_chars($query)));
$search_data = @file($GLOBALS[index_file]) or die(\"<font class=\\\"txtdarkboldblue\\\" align=\\\"center\\\">$GLOBALS[err_no_search_db]</font>\");
$pages_found = \" \";
foreach ($search_data as $search_page) {
$page_arr = explode(\"|\", $search_page);
$found_count = 0;
$qry_array = split(\'[, ]+\',trim(strtolower($query)));
foreach ($qry_array as $qry) {
if (in_array($qry, $page_arr)) {
++$found_count;
$pages_found .= $page_arr[0] . \" \";
}
}
if ($found_count == count($qry_array)) $result_arr[] = $page_arr[0];
}
return $result_arr;
}
function s_print_title_desc($file_n) {
$file = @file($file_n);
if ($file) {
$line_complete = implode(\'\', $file);
// eregi(\"<title>(.*)</title>\", $line_complete, $out);
// $title = trim($out[1]);
if($title) $line_complete = str_replace($title, \"\", $line_complete);
$line_complete = strip_tags($line_complete);
$line_complete = trim($line_complete);
$line_complete = trim(substr($line_complete, 0, 400));
$file_n = str_replace(\".inc.phtml\", \"\", $file_n);
$file_n = str_replace(\"http://\", \"hest&&&\", $file_n);
$file_n = str_replace(\"/\", \"/content.phtml?id=\", $file_n);
$file_n = str_replace(\"hest&&&\", \"http://\", $file_n);
echo \"<li><b><a href=\\\"$file_n\\\" class=\\\"lightbluelink\\\">\";
if (isset($title))
echo \"$title</a></b> <font size=\\\"-1\\\">- <i>$file_n</i></font>\";
else
echo \"$file_n</a></b>\";
echo \"<br><font class=\\\"txt\\\">$line_complete...\\n</font><br> \";
}
else {
echo \"<li><a href=\\\"$file_n\\\" class=\\\"lightbluelink\\\"><b>$file_n</b></a><br>...\";
}
}
function s_print_search_form($query) {
// Function to print the search form.
?>
<div align=\"center\"><form method=\"post\">
<font class=\"txtbolddarkblue\">Søg efter:</font><br><br>
<input type=\"text\" name=\"query\" value=\"<?php echo $query ?>\" class=\"field\"> <input type=\"submit\" value=\"Søg!\" class=\"button\">
</form></div>
<?php
}
function i_control() {
global $action, $username, $password, $user, $pass;
if (($user == $username) && ($pass == $password)) {
if ($action == \"clear_index\") i_clear_index();
elseif ($action == \"view_index\") i_view_index();
elseif ($action == \"index_site\") i_index_site();
i_print_options();
}
else {
if (($username == \"\") && ($password == \"\")) i_print_logon(\"\");
else i_print_logon(\"<font class=\\\"txtdarkboldblue\\\">Invalid username and/or password.</font>\");
}
}
function i_index_site() {
// Indexes the site & writes it to file.
if (!isset($GLOBALS[s])) {
echo \"
<br><div align=\\\"center\\\">
<font class=\\\"txt\\\">You have selected to index you site.</font>
<font class=\\\"txt\\\">You can index you site by it meta tag \\\"keyword\\\" or you can perform a \\\"full\\\" index.
<br>Which action do you wish to perform?</font>
<br><br><table border=\\\"0\\\"><tr>
<td align=\\\"center\\\"><form method=\\\"post\\\"><input type=\\\"hidden\\\" name=\\\"index\\\"><input type=\\\"hidden\\\" name=\\\"action\\\" value=\\\"index_site\\\"><input type=\\\"hidden\\\" name=\\\"s\\\" value=\\\"submit_meta\\\"><input type=\\\"hidden\\\" name=\\\"username\\\" value=\\\"$GLOBALS[username]\\\"><input type=\\\"hidden\\\" name=\\\"password\\\" value=\\\"$GLOBALS[password]\\\"><input type=\\\"submit\\\" value=\\\"Meta Tag Index\\\" class=\\\"button\\\"></form></td>
<td align=\\\"center\\\"><form method=\\\"post\\\"><input type=\\\"hidden\\\" name=\\\"index\\\"><input type=\\\"hidden\\\" name=\\\"action\\\" value=\\\"index_site\\\"><input type=\\\"hidden\\\" name=\\\"s\\\" value=\\\"submit_full\\\"><input type=\\\"hidden\\\" name=\\\"username\\\" value=\\\"$GLOBALS[username]\\\"><input type=\\\"hidden\\\" name=\\\"password\\\" value=\\\"$GLOBALS[password]\\\"><input type=\\\"submit\\\" value=\\\" Full Index \\\" class=\\\"button\\\"></form></td>
</tr></table></div>\";
}
else {
if (is_dir($GLOBALS[file_root])) {
$file_array = i_get_files($GLOBALS[file_root]);
$file_array = i_strip_extentions($file_array);
$file_array = i_strip_files($file_array);
if(is_array($file_array)) {
set_time_limit(0);
$fd = @fopen($GLOBALS[index_file], \"w\") or die(\"<font class=\\\"txtdarkboldblue\\\" align=\\\"center\\\">$GLOBALS[err_index]</font>\");
foreach ($file_array as $file) {
if (($GLOBALS[s] == \"submit_full\") || (substr($file, -3) == \"txt\")) $line = i_full_index_file($file);
elseif ($GLOBALS[s] == \"submit_meta\")$line = i_meta_index_file($file);
if (substr_count($line, \"|\") > 1) fputs($fd, \"$line\\n\");
}
fclose($fd);
echo \"<font class=\\\"txtdarkboldblue\\\" align=\\\"center\\\">$GLOBALS[index_complete]</font>\";
}
else {
echo \"<font class=\\\"txtdarkboldblue\\\" align=\\\"center\\\">$GLOBALS[no_files]</font>\";
}
}
else {
echo \"<font class=\\\"txtdarkboldblue\\\" align=\\\"center\\\">$GLOBALS[no_dir]</font>\";
}
}
}
function i_full_index_file($file_name) {
// Retrieves a list of keywords from a file.
global $http_root, $file_root;
$file_contents = @file($file_name);
if ($file_contents) {
$SURL = str_replace($file_root, $http_root , $file_name);
$keywords = \"$SURL|\";
$file_contents = implode(\" \", $file_contents);
$file_contents = strip_tags($file_contents);
$file_contents = strtolower($file_contents);
$file_contents = str_replace(\"\\n\", \"\", $file_contents);
$file_contents = c_strip_chars($file_contents);
$file_contents = str_replace(\",\", \"\", $file_contents);
$file_contents = explode(\" \", $file_contents);
foreach($file_contents as $word) {
$word = trim($word);
if ($word != \"\") {
$keywords .= \"$word|\";
}
}
}
$complete = str_replace(\"|||\", \"|\", $keywords);
$complete = str_replace(\"||\", \"|\", $complete);
$complete = i_strip_words($complete);
return $complete;
}
function i_meta_index_file($file) {
// Indexes a page by it\'s meta tags.
global $index_file, $http_root, $file_root;
$SURL = str_replace($file_root, $http_root , $file);
$mt = @get_meta_tags($file);
$line = $mt[keywords];
if ($line) {
$line = explode(\",\", $line);
foreach ($line as $word) {
$word = trim($word);
if ($word != \"\") {
$keywords .= \"$word|\";
}
}
$keyword = str_replace(\",\", \"\", $keywords);
$keywords = c_strip_chars($keywords);
$keywords = i_strip_words($keywords);
$keywords = \"$SURL|$keywords\";
return $keywords;
}
else {
return \"$SURL|\";
}
}
function i_get_files($dirname) {
// Navigates through the directories recurrsively and retrieves a listing in an array.
// File permission bit by Abhay Jain <vigya@yahoo.com>
if($dirname[strlen($dirname)-1] != \"/\") $dirname.=\"/\";
static $result_array = array();
$mode = fileperms($dirname);
if(($mode & 0x4000) == 0x4000 && ($mode & 0x00004) == 0x00004) {
chdir($dirname);
$handle = @opendir($dirname);
}
if($handle) {
while ($file = readdir($handle)) {
if($file==\'.\'||$file==\'..\') continue;
if(is_dir($dirname.$file)) i_get_files($dirname.$file.\'/\');
else $result_array[] = $dirname.$file;
}
closedir($handle);
}
return $result_array;
}
function i_strip_extentions($array) {
// Runs through the extention array and
// returns all files with the selected extentions.
global $include_extentions;
if(is_array($array)) {
foreach ($include_extentions as $ext) {
$str_len = strlen($ext);
foreach ($array as $file) {
if (substr($file, -$str_len) == $ext) $result_array[] = $file;
}
}
return $result_array;
}
else return $array;
}
function i_strip_files($array) {
// Removes unwanted files from an array.
global $file_root, $exclude_files;
if(is_array($array)) {
$exclude = @file($exclude_files);
if ($exclude) {
foreach($exclude as $exc_file) {
$exc_file = trim($exc_file);
$file[] = $exc_file;
}
foreach ($array as $act_file) {
$act_file = str_replace($file_root, \"\", $act_file);
if (!in_array($act_file, $file)) $result_array[] = \"$file_root$act_file\";
}
return $result_array;
}
else return $array;
}
else return $array;
}
function i_strip_words($line) {
$file = @file($GLOBALS[\'exclude_words\']);
if ($file) {
foreach ($file as $word) {
$word = trim($word);
$word = \"|$word|\";
$line = str_replace(\"$word\", \"|\", $line);
}
}
return $line;
}
function i_clear_index() {
// Checks for a confirmation and then clears the index file.
global $username, $password;
if ($GLOBALS[\'s\'] == \"submit\") {
$fd = @fopen($GLOBALS[index_file], \"w\") or die(\"<font class=\\\"txtdarkboldblue\\\" align=\\\"center\\\">$GLOBALS[err_index]</font>\");
fclose($fd);
echo \"<font class=\\\"txtdarkboldblue\\\" align=\\\"center\\\">$GLOBALS[index_cleared]</font>\";
}
else {
echo \"
<br><center><font class=\\\"txt\\\">
<b>You have selected to clear your site index.</b>
<br>No search results will be found until you re-index your site.
<br>Are you sure?
<br><form method=\\\"post\\\">
<input type=\\\"hidden\\\" name=\\\"action\\\" value=\\\"clear_index\\\">
<input type=\\\"hidden\\\" name=\\\"s\\\" value=\\\"submit\\\">
<input type=\\\"hidden\\\" name=\\\"username\\\" value=\\\"$username\\\">
<input type=\\\"hidden\\\" name=\\\"password\\\" value=\\\"$password\\\">
<input type=\\\"hidden\\\" name=\\\"index\\\">
<input type=\\\"submit\\\" value=\\\" Yes \\\" class=\\\"button\\\"></form>
</font></center>\";
}
}
function i_view_index() {
// Displays the index file in a table.
$file = @file($GLOBALS[index_file]);
if ($file) {
echo \"
<br><br><font class=\\\"txtdarkboldblue\\\" align=\\\"center\\\">Your index file:</font>
<table style=\\\"font-size:11; font-face:verdana\\\" border=\\\"1\\\" bordercolor=\\\"black\\\" cellpadding=\\\"2\\\" cellspacing=\\\"0\\\" bgcolor=\\\"#DDDDDD\\\">
<tr>
<td nowrap align=\\\"center\\\" valign=\\\"top\\\"><b>#</b></td>
<td nowrap align=\\\"center\\\" valign=\\\"top\\\"><b>URL</b></td>
<td nowrap align=\\\"center\\\" valign=\\\"top\\\"><b>Keywords</b></td></tr>\";
foreach ($file as $key => $line) {
$exp_line = explode(\"|\", $line);
$key = $key + 1;
echo \" <td>$key</td>\\n\";
foreach ($exp_line as $key => $word) {
if ($key == 0) { echo \" <td bgcolor=\\\"#FFFFFF\\\" nowrap><a href=\\\"$word\\\" class=\\\"lightbluelink\\\">$word</a></td>\\n \"; }
else { echo \"<td nowrap bgcolor=\\\"#FFFFFF\\\">$word</td>\"; }
}
echo \" \\n</tr>\\n\";
}
echo \"</table>\";
}
else { echo \"<font class=\\\"txtdarkboldblue\\\" align=\\\"center\\\">$GLOBALS[err_index]</font>\"; }
}
function i_print_options() {
// Prints the indexer options.
global $username, $password;
echo \"
<br><br><form method=\\\"post\\\"><table border=\\\"0\\\" align=\\\"center\\\"><tr><td colspan=\\\"2\\\" align=\\\"left\\\" valign=\\\"top\\\"><font class=\\\"txtbolddarkblue\\\"><b>Indexer Options:</b></font></td></tr>
<tr><td valign=\\\"top\\\"><input type=\\\"radio\\\" name=\\\"action\\\" value=\\\"index_site\\\"><font class=\\\"txt\\\" size=\\\"-1\\\">Create Site Index</font></td></tr>
<tr><td valign=\\\"top\\\"><input type=\\\"radio\\\" name=\\\"action\\\" value=\\\"view_index\\\"><font class=\\\"txt\\\" size=\\\"-1\\\">View Site Index</font></td></tr>
<tr><td valign=\\\"top\\\"><input type=\\\"radio\\\" name=\\\"action\\\" value=\\\"clear_index\\\"><font class=\\\"txt\\\" size=\\\"-1\\\">Clear Site Index</font></td></tr>
<tr><td colspan=\\\"2\\\" align=\\\"left\\\" valign=\\\"top\\\"><input type=\\\"hidden\\\" name=\\\"username\\\" value=\\\"$username\\\"><input type=\\\"hidden\\\" name=\\\"password\\\" value=\\\"$password\\\"><input type=\\\"hidden\\\" name=\\\"index\\\"><input type=\\\"submit\\\" value=\\\"Submit\\\" class=\\\"button\\\"></td></tr></table></form>\";
}
function i_print_logon($msg) {
// Prints the indexer logon.
echo \"
<form method=\\\"post\\\"><center><font class=\\\"txtbolddarkblue\\\"><b>$msg</b><br><br></font></center>
<table border=\\\"0\\\" align=\\\"center\\\"><tr><td colspan=\\\"2\\\" align=\\\"center\\\"><font class=\\\"txt\\\"><b>Logon:</b></font></td></tr><tr><td><font class=\\\"txt\\\">Username:</font></td><td><input type=\\\"text\\\" class=\\\"field\\\" name=\\\"username\\\"></td></tr>
<tr><td><font class=\\\"txt\\\">Password:</font></td><td><input type=\\\"password\\\" name=\\\"password\\\" class=\\\"field\\\"></td></tr>
<tr><td></td><td><input type=\\\"hidden\\\" name=\\\"index\\\"><input type=\\\"submit\\\" value=\\\"Logon\\\" class=\\\"button\\\"></td></tr></table></form>\";
}
function c_strip_chars($line) {
// Strips various characters from $line.
$line = str_replace(\".\", \" \", $line);
$line = str_replace(\"\\\"\", \" \", $line);
$line = str_replace(\"\'\", \"\", $line);
$line = str_replace(\"+\", \" \", $line);
$line = str_replace(\"-\", \" \", $line);
$line = str_replace(\"*\", \" \", $line);
$line = str_replace(\"/\", \" \", $line);
$line = str_replace(\"!\", \" \", $line);
$line = str_replace(\"%\", \" \", $line);
$line = str_replace(\">\", \" \", $line);
$line = str_replace(\"<\", \" \", $line);
$line = str_replace(\"^\", \" \", $line);
$line = str_replace(\"(\", \" \", $line);
$line = str_replace(\")\", \" \", $line);
$line = str_replace(\"[\", \" \", $line);
$line = str_replace(\"]\", \" \", $line);
$line = str_replace(\"{\", \" \", $line);
$line = str_replace(\"}\", \" \", $line);
$line = str_replace(\"\\\\\", \" \", $line);
$line = str_replace(\"=\", \" \", $line);
$line = str_replace(\"$\", \" \", $line);
$line = str_replace(\"#\", \" \", $line);
$line = str_replace(\"?\", \" \", $line);
$line = str_replace(\"~\", \" \", $line);
$line = str_replace(\":\", \" \", $line);
$line = str_replace(\";\", \" \", $line);
$line = str_replace(\"_\", \" \", $line);
$line = str_replace(\" \", \" \", $line);
$line = str_replace(\"&\", \" \", $line);
$line = str_replace(\"©\", \" \", $line);
$line = str_replace(\" \", \" \", $line);
$line = str_replace(\""\", \" \", $line);
$line = str_replace(\"&\", \" \", $line);
$line = str_replace(\"\\n\", \" \", $line);
return $line;
}
function c_print_footer() {
// Prints the footer of the page.
echo \"
<div align=\\\"center\\\">
<font class=\\\"txt\\\"><b>Powered by <a href=\\\"http://php.warpedweb.net/\\\" class=\\\"lightbluelink\\\">PHPSiteSearch</a></b>
<br>Version $GLOBALS[version]</font></div>\";
}
// Display time taken.
if(isset($query)) {
if($show_time_search) {
$timeparts = explode(\" \",microtime());
$total_time = ($timeparts[1].substr($timeparts[0],1)) - $starttime;
echo \"<br><center><font class=\\\"txt\\\">(Søgningen tog: \".substr($total_time,0,4).\" sekunder)</font><br><br></center>\";
}
}
elseif (substr($QUERY_STRING,0,5) == \"admin\") {
if($show_time_index) {
$timeparts = explode(\" \",microtime());
$total_time = ($timeparts[1].substr($timeparts[0],1)) - $starttime;
echo \"<br><center><font class=\\\"txt\\\">(Handlingen tog: \".substr($total_time,0,4).\" sekunder)</font><br></center>\";
}
}
?>
</td></tr></table>
</body>
</html>
