Permalink
Browse files

Fix runtime errors

  • Loading branch information...
1 parent 33af929 commit f2d4c0fc58cd19f8363540af07af0d1fe44645f4 @pmyteh pmyteh committed Jul 9, 2012
Showing with 14 additions and 11 deletions.
  1. +10 −8 LIB_db_functions.php
  2. +4 −3 spider.php
View
@@ -5,16 +5,17 @@
include("CONFIG_db.php");
# Above file defines the following variables:
#
-# $db_host = "localhost"
-# $db_username = "jrandom"
-# $db_password = "ASDF!!1!one1"
-# $db_name = "somedb"
-# $operator_email is used to mail the user on script completion
-# $operator_email = "j.random@example.com"
+# $db_host = "localhost";
+# $db_username = "jrandom";
+# $db_password = "ASDF!!1!one1";
+# $db_name = "somedb";
+## $operator_email is used to mail the user on script completion
+# $operator_email = "j.random@example.com";
#
function /*public*/ db_connect() {
- $GLOBALS["db"] = mysql_connect($db_host, $db_username, $db_password or
+ global $db_host, $db_username, $db_password, $db_name;
+ $GLOBALS["db"] = mysql_connect($db_host, $db_username, $db_password) or
die("Could not connect: " . mysql_error());
mysql_select_db($db_name,$GLOBALS["db"]);
}
@@ -24,10 +25,11 @@ function /*public*/ db_connect() {
#db_store_link($seed,$resolved_address;
function /*private*/ db_run_select($strSQL,$returnVal=false) {
+ global $db_name;
mysql_select_db($db_name);
#echo $strSQL . "\n";
try {
- $result = mysql_query($strSQL,$GLOBALS["db"]); #or die('Query failed: ' . mysql_error());
+ $result = mysql_query($strSQL,$GLOBALS["db"]) or die('Query failed: ' . mysql_error());
}
catch(Exception $e)
{
View
@@ -10,6 +10,7 @@
include("LIB_simple_spider.php"); // spider routines used by this app.
include("LIB_db_functions.php");
include("LIB_encoding.php");
+include("CONFIG_db.php");
set_time_limit(0); // Don't let PHP timeout
@@ -48,8 +49,8 @@
if (exclude_link($seed["strURL"])) throw new Exception("Page in excluded list: $strURL\n");
$downloaded_page = http_get_withheader($seed["strURL"], "");
$content_type=$downloaded_page['STATUS']['content_type'];
- $code=$strStatus["http_code"];
$strStatus=$downloaded_page['STATUS'];
+ $code=$strStatus["http_code"];
if ($code!=200 || strpos(strtolower($content_type),"text")===false) {
print "Skipping....http_code is $code content_type is $content_type\n";
db_marked_processed($seed);
@@ -116,9 +117,9 @@
$seed = db_get_next_to_process();
}
db_close();
-echo "Done";
+echo "Done.\n";
-#link_array now has all off-site links from SEED page
+#link_array now has all off-site links from SEED pagehttps://www.facebook.com/pages/Clapham-Adventure/407825022594984
#insert into database
#for ($xx=0; $xx<length($link_array); $xx++) {
#store new page returns unique id for url

0 comments on commit f2d4c0f

Please sign in to comment.