hallo!
ich habe ein kleines suchmaschinen script geschrieben (für eine chemie website, also nicht wundern *g*) nur leider treten ein paar fehler auf von denen ich keine ahnung hab weshalb sie fehler sind. auch im restlichen quellcode sind vermutlich noch fehler aber seid nich zu 'streng' bin noch anfänger *g*
ich hoffe das forum 'zerhackstückelt' den quellcode nicht, ich stell ihn sicherheitshalber hier mal mit allen benötigten dateien zum download:
http://www.harald-bartsch.de/suche/script.zip
das script könnt ihr auch hier aktiv sehen:
http://www.harald-bartsch.de/suche
hier der code:
<html>
<head>
<title>ChemSearch</title>
</head>
<body link="#000000" alink="#000000" vlink="#000000">
<?php
if($action == "")
{
$action="search";
}
$where1="#ffffff";
$where2="#ffffff";
if($action == "search")
{
$where1="#fof8ff";
}
else
{
$where2="#fof8ff";
}
if($check == "exakt")
{
$checked="checked";
}
if($search != "")
{
$svalue=$search;
}
$hits="0";
if(($action == "") or ($action == "search") or ($action == "help") or ($action == "formel"))
{
echo "<div align="center"><b>ChemSearch Alpha 1.8</b><br><br>
";
echo "<table cellspacing="4"><tr><td>
";
echo "<div align="center"><table><tr><td><table cellspacing="1"
";
echo "width="100" bgcolor="#000000"><tr><td bgcolor="$where1"><div align="center">
";
echo "<a href="index.php?action=search">Text</a></div></td></tr></table></td><td>
";
echo "<table cellspacing="1" width="100" bgcolor="#000000"><tr><td bgcolor="$where2">
";
echo "<div align="center"><a href="index.php?action=formel">Formel</a></div>
";
echo "</td></tr></table></td></tr></table></div></td></tr><tr><td>
";
echo "<div align="center">
";
if($action == "search")
{
echo "<form method="post" action="index.php?action=search"
";
}
else
{
echo "<form method="post" action="index.php?action=formel"
";
}
echo "name="chemsearch"><input type="text" name="search" value="$svalue">
";
echo "<input type="submit" value="Suche">";
if($action == "search")
{
echo "<table><tr><td>
";
echo "<input type="radio" name="meta" value="web" checked> Das Web</td>
";
echo "<td><input type="radio" name="meta" value="intern"> Intern
";
echo "<td></tr></table><input type="checkbox" name="check" value="exakt" $checked>
";
echo " Exakte Suche
";
}
echo "</form></div></div></td></tr></table>
";
}
if($action == "help")
{
echo "<div align="center"><table width="40%" cellspacing="1"
";
echo "cellpadding="0" bgcolor="#000000"><tr><td bgcolor="#ffffff">
";
echo "<table width="100%" cellspacing="4" cellpadding="0"><tr><td>
";
echo "<div align="justify">
";
include("hilfe.txt");
echo "</div></td></tr>
";
echo "</table></td></tr></table><br>";
include("bottom.txt");
exit;
}
if(($action == "search") and ($meta == "web"))
{
$number=strlen($search);
if($number <= "3")
{
echo "<div align="center"><table width="40%" cellspacing="1"
";
echo "cellpadding="0" bgcolor="#000000"><tr><td bgcolor="#ffffff">
";
echo "<table width="100%" cellspacing="4" cellpadding="0"><tr><td>
";
echo "<div align="center">Der von Ihnen eingegebene Suchbegriff ist
";
echo "zu kurz! Die minimale Länge sind vier Buchstaben.</div></td></tr>
";
echo "</table></td></tr></table><br>";
include("bottom.txt");
exit;
}
else
{
if(file_exists("web.txt"))
{
$entries=file("web.txt");
foreach($entries as $entry)
{
$entrydata=explode("|§|", $entry);
$edata=explode("+", $entrydata[3]);
foreach($edata as $data)
{
if($check == "exakt")
{
////////////////////////////hier steckt ein fehler
if($search == $data)
{
$hits++;
echo "<div align="center">
";
echo "<table cellspacing="1" width="40%" border="0">
";
echo "<tr><td width="2%" valign="top">$hits</td><td width="38%">
";
echo "<a href="$entrydata[0]">$entrydata[1]</a>:<br>
";
echo "<i>$entrydata[2]</i></td></tr></table><br></div>
";
}
}
else
{
if(eregi($search, $data))
{
$bgcolor="";
if($search == $data)
{
$bgcolor="#fof8ff";
}
$hits++;
echo "<div align="center">
";
echo "<table cellspacing="1" width="40%" border="0" bgcolor="$bgcolor">
";
echo "<tr><td width="2%" valign="top">$hits.</td><td width="38%">
";
echo "<a href="$entrydata[0]">$entrydata[1]</a>:<br>
";
echo "<i>$entrydata[2]</i></td></tr></table><br></div>
";
}
}
}
}
$result="Ergebnisse";
if($hits == "1")
{
$result="Ergebnis";
}
echo "<div align="center">" . $hits . " " . $result . " zum
";
echo "Suchbegriff "<b>" . $search . "</b>"</div><br>
";
}
else
{
echo "Fehler beim Lesen der Quelldatei.<br>";
include("bottom.txt");
exit;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
if($action == "formel")
{
$number=strlen($search);
if($number != "")
{
if($number <= "1")
{
echo "<div align="center"><table width="40%" cellspacing="1"
";
echo "cellpadding="0" bgcolor="#000000"><tr><td bgcolor="#ffffff">
";
echo "<table width="100%" cellspacing="4" cellpadding="0"><tr><td>
";
echo "<div align="center">Der von Ihnen eingegebene Suchbegriff ist
";
echo "zu kurz! Die minimale Länge sind zwei Buchstaben.</div></td></tr>
";
echo "</table></td></tr></table><br>";
include("bottom.txt");
exit;
}
}
if(file_exists("formeln.txt"))
{
$entries=file("formeln.txt");
foreach($entries as $entry)
{
$search=strtolower($search);
$entrydata=explode("|§|", $entry);
$edata=explode("+", $entrydata[2]);
foreach($edata as $data)
{
////////////////////////////hier steckt ein fehler
if($search == $data)
{
$hits++;
echo "<div align="center">
";
echo "<table cellspacing="1" width="40%" border="0">
";
echo "<tr><td width="2%" valign="top"></td><td width="38%">
";
echo "$entrydata[0]:<br>
";
echo "<i>$entrydata[1]</i></td></tr></table><br></div>
";
}
}
}
if(($hits == "0") and ($search != ""))
{
echo "Keine Formel für " . $search . " gefunden.<br><br>";
}
}
else
{
echo "Fehler beim Lesen der Quelldatei.<br>";
include("bottom.txt");
exit;
}
}
include("bottom.txt");
?>
die fehler stecken an den beiden gekennzeichneten stellen, ich hoffe ihr könnt mir helfen :)
danke,
Sirius