Close
0 <? 1 include("./mysql.php3"); 2 3 4 $db = new MySQL; 5 if(!$db->init()) { 6 echo "Well this sucks<BR>\n"; 7 exit; 8 } 9 10 function breadcrumbs($CatID="") 11 { 12 global $db; 13 global $PHP_SELF; 14 15 if(empty($CatID)) { return; } 16 $db->get_ParentsInt($CatID); 17 $path = $db->TRAIL; 18 if(!empty($path)) 19 { 20 while ( list ( $key,$val ) = each ($path)) 21 { 22 $CatID = stripslashes($val["CatID"]); 23 $CatName = stripslashes($val["CatName"]); 24 $trail = "|<A HREF=\"$PHP_SELF?viewCat=$CatID\"><B>$CatName</B></A>$trail"; 25 } 26 } else { 27 $trail = ""; 28 } 29 return $trail; 30 } 31 32 function start_page($CatID="",$title="",$msg="") 33 { 34 global $PHP_SELF; 35 36 print "<HTML>\n"; 37 print "<HEAD><TITLE>phpHoo - $title</TITLE></HEAD>\n"; 38 print '<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0033FF" VLINK="#660099">'; 39 print "\n<CENTER><H1>phpHoo</H1></CENTER>\n"; 40 if(!empty($msg)) 41 { 42 print "\n<CENTER><B>$msg</B></CENTER>\n"; 43 } 44 45 print "<CENTER><FORM ACTION=\"$PHP_SELF\" METHOD=\"POST\">\n"; 46 print "<INPUT TYPE=\"TEXT\" NAME=\"KeyWords\" SIZE=20>\n"; 47 print "<INPUT TYPE=\"SUBMIT\" NAME=\"Search\" VALUE=\"Search\"></FORM></CENTER>"; 48 print "<P><H3><A HREF=\"$PHP_SELF\">Top</A>"; 49 50 $trail = breadcrumbs($CatID); 51 print "$trail</H3></P><HR>\n"; 52 53 return; 54 } 55 56 function start_browse($CatID = "") 57 { 58 global $PHP_SELF; 59 global $db; 60 61 $data = $db->get_Cats($CatID); 62 $links = $db->get_Links($CatID); 63 64 if(!empty($CatID)) 65 { 66 $currentID = $CatID; 67 $currentName = $db->get_CatNames($CatID); 68 69 } else { 70 $currentID = "top"; 71 $currentName = "top"; 72 } 73 74 if(!empty($data)) 75 { 76 while ( list ( $key,$val ) = each ($data)) 77 { 78 $CatID = stripslashes($val["CatID"]); 79 $CatName = stripslashes($val["CatName"]); 80 print "<LI><A HREF=\"$PHP_SELF?viewCat=$CatID\"><B>$CatName</B></A></LI>\n"; 81 } 82 } 83 print "<HR>\n"; 84 if(!empty($links)) 85 { 86 while ( list ( $key,$val ) = each ($links)) 87 { 88 $Url = stripslashes($val["Url"]); 89 $LinkName = stripslashes($val["LinkName"]); 90 $Desc = stripslashes($val["Description"]); 91 print "<LI><A HREF=\"$Url\"><B>$LinkName</B></A> - $Desc</LI>\n"; 92 } 93 } 94 print "<P><CENTER><A HREF=\"$PHP_SELF?add=$currentID\">Suggest new link</A></CENTER>\n"; 95 print "</BODY></HTML>\n"; 96 return; 97 } 98 99 // ***************************************************************** 100 101 $query = getenv("QUERY_STRING"); 102 103 if( ($viewCat) or ( (!$HTTP_POST_VARS) and (!$query) ) ) 104 { 105 start_page($viewCat); 106 start_browse($viewCat); 107 exit; 108 109 } elseif($add) 110 { 111 if("$add" == "top") { $add = 0; } 112 $CatName = stripslashes($db->get_CatNames($add)); 113 if(empty($CatName)) { $CatName = "Top"; } 114 print "<HTML> 115 <head><title>phpHoo - Add a Resource</title></head> 116 <body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#0033FF\" VLINK=\"#660099\"> 117 <center><H1>phpHoo</H1></center> 118 <p><H3>Add a Resource to: <B>$CatName</B></H3><HR noshade> 119 <form action=\"$PHP_SELF\" method=\"POST\"> 120 <input type=\"hidden\" name=\"CatID\" value=\"$add\"> 121 <table border=\"0\" cellpadding=\"2\" cellspacing=\"2\"> 122 <tr><td align=\"right\"><B>URL:</B></td><td><input name=\"Url\" size=\"40\" VALUE=\"https://\"></td></tr> 123 <tr><td align=\"right\"><B>Title:</B></td><td><input name=\"LinkName\" size=\"40\"></td></tr> 124 <tr><td align=\"right\"><B>Description:</B></td><td><textarea name=\"Description\" rows=\"3\" cols=\"40\"></textarea></td></tr> 125 <tr><td align=\"right\"><B>Your Name:</B></td><td><input name=\"SubmitName\" size=\"40\"></td></tr> 126 <tr><td align=\"right\"><B>Your Email:</B></td><td><input name=\"SubmitEmail\" size=\"40\"></td></tr> 127 <tr><td></td><td><input type=\"submit\" name=\"suggest\" value=\"Submit Resource\"> 128 <input type=\"reset\" value=\" Reset \"></td></tr> 129 </table> 130 <HR noshade> 131 </form></p> 132 </html>\n"; 133 } elseif ($suggest) 134 { 135 $junk = ""; 136 if(!$db->suggest($HTTP_POST_VARS)) 137 { 138 $title = "Suggestion Error"; 139 $msg = "Suggestion failed! Required data missing, invalid, or you duplicated an existing entry.\n"; 140 } else { 141 $title = "Suggestion Submitted"; 142 $msg = "Suggestion submitted for approval\n"; 143 } 144 start_page($junk,$title,$msg); 145 start_browse(); 146 exit; 147 } elseif ($KeyWords) 148 { 149 //start_page(); 150 $hits = $db->search($KeyWords); 151 if( (!$hits) or (empty($hits)) ) 152 { 153 $junk = ""; 154 $title = "Search Results"; 155 $msg = "No Matches"; 156 start_page($junk,$title,$msg); 157 } else { 158 $total = count($hits); 159 $title = "Search Results"; 160 $msg = "Search returned [$total] matches"; 161 $junk = ""; 162 start_page($junk,$title,$msg); 163 while ( list ($key,$hit) = each ($hits)) 164 { 165 if(!empty($hit)) 166 { 167 $LinkID = $hit["LinkID"]; 168 $LinkName = stripslashes($hit["LinkName"]); 169 $LinkDesc = stripslashes($hit["Description"]); 170 $LinkURL = stripslashes($hit["Url"]); 171 $CatID = $hit["CatID"]; 172 $CatName = stripslashes($db->get_CatNames($CatID)); 173 print "<DL>\n"; 174 print "<DT><A HREF=\"$LinkURL\" TARGET=\"_NEW\">$LinkName</A>\n"; 175 print "<DD>$LinkDesc\n"; 176 print "<DD><B>Found In:</B> <A HREF=\"$PHP_SELF?viewCat=$CatID\">$CatName</A>\n"; 177 print "</DL>\n"; 178 } 179 } 180 } 181 print "<P><HR>\n"; 182 start_browse(); 183 exit; 184 } else { 185 // Something terribly bad happened - start fresh 186 start_page(); 187 start_browse(); 188 exit; 189 } 190 ?>