diff -u -r -N yasuck-0.0.4.orig/docs/AUTHORS yasuck-0.0.4/docs/AUTHORS --- yasuck-0.0.4.orig/docs/AUTHORS 2004-09-11 15:14:11.000000000 -0500 +++ yasuck-0.0.4/docs/AUTHORS 2004-09-24 00:43:53.546712080 -0500 @@ -1,2 +1,2 @@ -Mike Green +Mike Green Created first iteration 2004-09-09 diff -u -r -N yasuck-0.0.4.orig/docs/ChangeLog yasuck-0.0.4/docs/ChangeLog --- yasuck-0.0.4.orig/docs/ChangeLog 2004-09-20 01:26:07.000000000 -0500 +++ yasuck-0.0.4/docs/ChangeLog 2004-09-24 00:51:31.110151864 -0500 @@ -4,9 +4,23 @@ *yasuck-0.0.4 (19 Sep 2004) + 24 Sep 2004: Mike Green docs/AUTHORS, + docs/ChangeLog, docs/README, includes/app.functions.php, + includes/globals.php, yasuck, patch-0.0.4-01: + + Spam-obscured email addresses. Added new arguments: --quiet to quelch + non error messages and --recs to update recommendations only. Sanitized + text output. Added code to retrieve recommendations and created function + to only deal with recommendations. Fixed a problem with the ini_set call + when setting the user agent. Added to sanityCheck() a call to runUpgrades(), + which will check for upgrade tasks like adding table columns etc... + Changed default values of FETCHSLEEP to 1,4, testing for yahoo lockout + on those numbers. Created patch for all of this and updated ChangeLog. + + *yasuck-0.0.3 (19 Sep 2004) - 20 Sep 2004: Mike Green docs/ChangeLog, + 20 Sep 2004: Mike Green docs/ChangeLog, includes/app.functions.php, patch-0.0.3-01: Oops, fixed bug that was hardcoding DRYRUN. Nothing was being saved @@ -14,7 +28,7 @@ *yasuck-0.0.2 (18 Sep 2004) - 19 Sep 2004; Mike Green docs/ChangeLog, + 19 Sep 2004; Mike Green docs/ChangeLog, includes/app.functions.php, includes/globals.php, yasuck, patch-0.0.2-01: @@ -28,13 +42,13 @@ *yasuck-0.0.1 (17 Sep 2004) - 18 Sep 2004; Mike Green docs/ChangeLog, + 18 Sep 2004; Mike Green docs/ChangeLog, includes/app.functions.php, patch-0.0.1-02: Added --dryrun and beginning of code to add previous/next message link information. Bumped version to 0.0.2. - 17 Sep 2004; Mike Green docs/ChangeLog, + 17 Sep 2004; Mike Green docs/ChangeLog, includes/app.functions.php, includes/globals.php, yasuck, patch-0.0.1-01: @@ -43,7 +57,7 @@ on the poster or subject. Added MAXMISSES to abort if it is determined that the network may be down. Updated ChangeLog and created patch. - 17 Sep 2004; Mike Green docs/ChangeLog: + 17 Sep 2004; Mike Green docs/ChangeLog: First rough cut release. \ No newline at end of file diff -u -r -N yasuck-0.0.4.orig/docs/README yasuck-0.0.4/docs/README --- yasuck-0.0.4.orig/docs/README 2004-09-17 17:05:43.000000000 -0500 +++ yasuck-0.0.4/docs/README 2004-09-24 00:44:20.256651552 -0500 @@ -1,7 +1,7 @@ /***************************************************************************** * Copyright (c)2004 badpenguins.com * * Distributed under the terms of the GNU General Public License v2 * - * Created 2004-09-09 Mike Green * + * Created 2004-09-09 Mike Green * *****************************************************************************/ Welcome to yasuck, please see the files AUTHORS and COPYING for diff -u -r -N yasuck-0.0.4.orig/includes/app.functions.php yasuck-0.0.4/includes/app.functions.php --- yasuck-0.0.4.orig/includes/app.functions.php 2004-09-20 01:23:17.000000000 -0500 +++ yasuck-0.0.4/includes/app.functions.php 2004-09-24 00:45:58.797671040 -0500 @@ -2,7 +2,7 @@ /***************************************************************************** * Copyright (c)2004 badpenguins.com * * Distributed under the terms of the GNU General Public License v2 * - * Created 2004-09-09 Mike Green * + * Created 2004-09-09 Mike Green * *****************************************************************************/ if (basename($PHP_SELF) == basename(__FILE__)) { die("Access Denied\n"); } @@ -67,6 +67,25 @@ define(AUTHOR_SEARCH,true); define(AUTHOR_TEXT,$text); break; + case "--quiet": + define(QUIET,true); + break; + case "--recs": + $action = "refresh"; + define(RECSONLY,true); + $j++; + $board = $args[$j]; + if (empty($board)) { die(helpMessage()); } + if (substr($board,0,2) == "--") { die(helpMessage()); } + $j++; + $text = $args[$j]; + if ("$text" == "all") { + define(RECSALL,true); + } else { + define(RECSALL,false); + $j--; + } + break; case "--start": $j++; $start = $args[$j]; @@ -101,6 +120,8 @@ if ($end < $start) { die(helpMessage()); } } break; + case "refresh": + break; case "status": die(checkStatus($board)); break; @@ -119,18 +140,18 @@ function checkLock($board_id='') { if ($board_id == '' or !is_numeric($board_id)) { - die("Invalid board_id: $board_id, cannot check for lock.\n"); + die("ABORT: invalid board_id: checkLock($board_id).\n"); } $board_id = addslashes($board_id); $sql = "select locked from " . DBN . ".board_ids where board_id=$board_id limit 1"; if (!$qid = db_query($sql)) { - die("SQL Error when checking for lock.\n"); + die("ABORT: SQL failure during checkLock().\n"); } $num = db_num_rows($qid); if ($num !== 1) { - die("Checked for lock on non-existant board_id.\n"); + die("ABORT: checkLock($board_id) nonexistant board_id.\n"); } $lock = db_result($qid,0,0); @@ -138,7 +159,7 @@ case 0: return false; break; case 1: return true; break; default: - die("Invalid lock value for board.\n"); + die("ABORT: invalid lock detected.\n"); break; } } @@ -150,11 +171,12 @@ $msg = ''; $file = basename($_SERVER['argv'][0]); if (!db_connect(DBH,DBN,DBU,DBP)) { - $msg = " Cannot connect to the database. Either the server is down, \n"; - $msg .= " the database has not been initialized, or incorrect database\n"; - $msg .= " settings have been specified in globals.php. Run:\n"; - $msg .= " $file --init to initialize the database (which will wipe any\n"; - $msg .= " existing data).\n"; + $msg = "ABORT:\n"; + $msg .= "Cannot connect to the database. Either the server is down, \n"; + $msg .= "the database has not been initialized, or incorrect database\n"; + $msg .= "settings have been specified in globals.php. Run:\n"; + $msg .= "$file --init to initialize the database (which will wipe any\n"; + $msg .= "existing data).\n"; } if (! $msg == '') { if (DEBUG) { @@ -172,14 +194,14 @@ *****************************************************************************/ function checkStatus($board='') { -if ($board == '') { die("No board specified for status check.\n"); } +if ($board == '') { die("ABORT: invalid board: checkStatus($board).\n"); } checkDatabase(); $msg = ''; $info_ar = queryBoardInfo($board); if ($info_ar === false or !is_array($info_ar)) { - $msg .= "Cannot retrieve database information for board: $board\n"; + $msg .= "ERROR: queryBoardInfo($board) failed.\n"; $board_id = "n/a"; $ticker_id = "n/a"; $low_msg = "n/a"; @@ -271,7 +293,7 @@ if ($randomize === false) { $ua = USER_AGENT; } -if (DEBUGUA) { echo "UA($ua) "; } +if (DEBUGUA) { echo "DEBUG: user agent is: $ua\n"; } return $ua; @@ -303,15 +325,15 @@ } sleep($sleep); $page = array(); - if (DEBUG) { echo "fsockopen(\"$host\",80)\n"; } + if (DEBUG) { echo "DEBUG: fsockopen(\"$host\",80)\n"; } if (! $fp = fsockopen("$host",80,$errno,$errstr,SOCKTIMEOUT)) { if (DEBUG) { echo "ERROR: $errno - $errstr\n"; } continue; } foreach($headers as $header) { - if (DEBUG) { echo "$header"; } + if (DEBUG) { echo "DEBUG: $header\n"; } if (!fwrite($fp,$header)) { - if (DEBUG) { echo "failed to write to stream\n"; } + if (DEBUG) { echo "ERROR: failed to write to stream\n"; } fclose($fp); continue; } @@ -344,11 +366,13 @@ --help Display this help message --init Initialize database (destructive) --poster POSTER Only retrieve messages posted by POSTER + --quiet No non-error messages displayed while running --sanity Run sanity check and display results --skipmsgs Don't import messages (subject/poster only) --start MSG Start with message number MSG (optional) --status BOARD Display status of board BOARD database - --subject SUBJECT Only retrieve messages with subject SUBJECT\n"; + --subject SUBJECT Only retrieve messages with subject SUBJECT + --recs BOARD [all] Update recommendation counters only\n"; die($msg); @@ -363,7 +387,7 @@ // Don't initialize if it already exists, make the admin wipe it. if (! queryBoardInfo($board_name,false) === false) { - echo "Cannot initialize existing board: $board_name\n"; + echo "ERROR: queryBoardInfo($board_name).\n"; return false; } @@ -391,8 +415,8 @@ $vl = "$board_id,'$board_name','$ticker_id',$start,$end,$start"; $sql = "insert into " . DBN . ".board_ids($fl) values($vl)"; if (!db_query($sql)) { - $msg = "initializeBoard() failed. The failed query is "; - $msg .= "listed below:\n\n"; + $msg = "ABORT: initializeBoard() failed. The failed query is "; + $msg .= "listed below:\n"; $msg .= wordwrap($sql) . "\n"; die($msg); } @@ -406,10 +430,10 @@ *****************************************************************************/ function initializeDatabase() { -$msg = "Initializing database:\n"; +$msg = "INFO: Initializing database:\n"; if (!@db_connect(DBH,"",DBU,DBP)) { - $msg .= " Cannot connect to database host\n"; + $msg .= "ABORT: Cannot connect to database host\n"; die($msg); } @@ -445,6 +469,7 @@ thread_id int(10) unsigned NOT NULL default '0', message_date datetime NOT NULL default '0000-00-00 00:00:00', message_subject varchar(100) default NULL, +message_recs int(5) unsigned default '0', message_text text, PRIMARY KEY (message_id,board_id), KEY poster_id (poster_id), @@ -462,8 +487,8 @@ foreach($sql as $query) { if (!db_query($query)) { - $msg = "initializeDatabase() failed. The failed query is "; - $msg .= "listed below:\n\n"; + $msg = "ABORT: initializeDatabase() failed. The failed query is "; + $msg .= "listed below:\n"; $msg .= wordwrap($query) . "\n"; die($msg); } @@ -673,6 +698,39 @@ /***************************************************************************** * * *****************************************************************************/ +function parseMsgRecs($page='') { + +if ($page == '' or !is_array($page)) { return false; } + +$text = strtolower(">Recommend this Post"); + +for($j=0; $j < count($page); $j++) { + $line = trim(strtolower($page[$j])); + $pos = strpos($line,$text); + if ($pos === false) { continue; } + $ptr = $j + 1; + if ($ptr > count($page)) { return false; } + $recsline = trim(strtolower($page[$ptr])); + if ("$recsline" == "") { return 0; } + $posbeg = strpos($recsline,"this post has "); + if ($posbeg === false) { return false; } + $line = substr($recsline,$posbeg); + $tmp_ar = explode(" ",$line); + $recs = trim($tmp_ar[3]); + if (is_numeric($recs)) { + return $recs; + } else { + return false; + } + } + +return 0; + +} + +/***************************************************************************** + * * + *****************************************************************************/ function parseMsgReplyTo($page='') { if ($page == '' or !is_array($page)) { return false; } @@ -886,15 +944,15 @@ function processMessage($board_id='',$message_id='',$page='') { if (!is_numeric($board_id)) { - echo "$message_id(board_id) "; + echo "ERROR: ID: $message_id: board_id\n"; return false; } if ($message_id == '' or !is_array($page)) { - echo "$message_id(no page) "; + echo "ERROR: ID: $message_id: no page\n"; return false; } if (!$subject = parseMsgSubject($page)) { - echo "$message_id(subject) "; + echo "ERROR: ID: $message_id: subject\n"; return false; } if (SUBJECT_SEARCH and defined('SUBJECT_TEXT')) { @@ -902,7 +960,7 @@ if ($pos === false) { return true; } } if (!$author = parseMsgAuthor($page)) { - echo "$message_id(author) "; + echo "ERROR: ID: $message_id: author\n"; return false; } if (AUTHOR_SEARCH and defined('AUTHOR_TEXT')) { @@ -910,23 +968,28 @@ if ($pos === false) { return true; } } if (!$msgdate = parseMsgDate($page)) { - echo "$message_id(msgdate) "; + echo "ERROR: ID: $message_id: msgdate\n"; return false; } $parent_id = parseMsgReplyTo($page); if ($parent_id === false) { - echo "$message_id(parent_id) "; + echo "ERROR: ID: $message_id parent_id\n"; return false; } $thread_id = parseMsgThread($page); if ($thread_id === false) { - echo "$message_id(thread_id) "; + echo "ERROR: ID: $message_id: thread_id\n"; + return false; + } +$msg_recs = parseMsgRecs($page); +if ($msg_recs === false) { + echo "ERROR: ID: $message_id: recs\n"; return false; } if (!SKIPMSGS) { $msgtext = parseMsgText($page); if ($msgtext === false) { - echo "$message_id(msgtext) "; + echo "ERROR: ID: $message_id: msgtext\n"; return false; } } else { @@ -942,18 +1005,18 @@ if (posterNameExists($author)) { $poster_id = queryPosterId($author); if ($poster_id === false) { - echo "$message_id(queryPosterId()) "; + echo "ERROR: ID: $message_id: queryPosterId())\n"; return false; } } else { $poster_id = createPosterId($author); if ($poster_id === false or !is_numeric($poster_id)) { - echo "$message_id(createPosterId()) "; + echo "ERROR: ID: $message_id: createPosterId()\n"; return false; } } if (! $ds = date('Y-m-d H:i:s',strtotime($msgdate))) { - echo "$message_id(msgdate) "; + echo "ERROR: ID: $message_id: msgdate\n"; } if (DRYRUN !== true) { @@ -967,12 +1030,12 @@ $msgtext = addslashes($msgtext); if ($insert_msg) { $fl = "message_id,board_id,poster_id,parent_id,thread_id,"; - $fl .= "message_date,message_subject,message_text"; + $fl .= "message_date,message_subject,message_recs,message_text"; $vl = "$message_id,$board_id,$poster_id,$parent_id,$thread_id,"; - $vl .= "'$ds','$subject','$msgtext'"; + $vl .= "'$ds','$subject',$msg_recs,'$msgtext'"; $sql = "insert into " . DBN . ".message_ids($fl)\nvalues($vl)"; if (!db_query($sql)) { - echo "$message_id(insert) "; + echo "ERROR: ID: $message_id: insert\n"; return false; } } else { @@ -980,15 +1043,19 @@ $sql .= ",poster_id=$poster_id,parent_id=$parent_id,"; $sql .= "thread_id=$thread_id,message_date='$ds',"; $sql .= "message_text='$msgtext',message_subject='$subject' "; + $sql .= "message_recs=$msg_recs "; $sql .= "where board_id=$board_id and message_id=$message_id "; $sql .= "limit 1"; if (!db_query($sql)) { - echo "$message_id(update) "; + echo "ERROR: ID: $message_id: update\n"; return false; } } if (!updateCounters($board_id,$message_id)) { - echo "$message_id(updateCounters()) "; + echo "WARNING: ID: $message_id: updateCounters()\n"; + } + if (QUIET !== true) { + echo "ID: $message_id P:$author S:$subject R:$msg_recs\n"; } } @@ -999,6 +1066,134 @@ /***************************************************************************** * * *****************************************************************************/ +function processRecommendations($board_id,$ticker_id,$start='',$end='') { + +global $board, $info_ar; + +// Until we can figure out how long recommendations are allowed to +// be updated on yahoo boards, go back 500 messages as an arbitrary +// number. +if (!is_numeric($start) and !is_numeric($end)) { + $end = $info_ar['last_msg']; + if ($end <= 500) { + $start = 1; + } else { + $start = $end - 500; + } + } +if (!is_numeric($start)) { + $start = $info_ar['last_msg'] - 500; + if ($start < 1) { $start = 1; } + } +if (!is_numeric($end)) { + $end = $info_ar['last_msg']; + } + +if (($start > $end) or ($end > $info_ar['last_msg'])) { + toggleLock($board_id,0); + die("ABORT: invalid start($start)/end($end)\n"); + } + +// get list of existing message ids +$board_id = addslashes($board_id); +$start = addslashes($start); +$end = addslashes($end); +$sql = "select message_id from " . DBN . ".message_ids "; +$sql .= "where board_id=$board_id and message_id "; +$sql .= "between $start and $end order by message_id"; +if (!$qid = db_query($sql)) { + echo "ERROR: sql failure:\n$sql\n"; + return false; + } +$num = db_num_rows($qid); +if ($num < 1) { return false; } +$msg_ar = array(); +for($j=0; $j < $num; $j++) { + $msg_ar[] = db_result($qid,$j,0); + } +db_free_result($qid); + +echo "Updating recommendations: Board($board) Start($start) End($end)\n"; +foreach($msg_ar as $j) { + if (!$page = retrieveMsg($board_id,$ticker_id,$j)) { + echo "WARNING: ID: $j retrieval failure\n"; + continue; + } + if (DUMPHTML === true) { + if (!$fd = fopen("$j.html","w")) { + echo "WARNING: cannot open file: $j.html\n"; + } else { + foreach($page as $line) { + if (!fwrite($fd,$line . "\n")) { + echo "WARNING: could not write to file: $j.html\n"; + fclose($fd); + break; + } + } + fclose($fd); + if (QUIET !== true) { + echo "INFO: wrote $j.html\n"; + } + } + } + // account for yahoo outages + $maxunavail = 0; + $sleepmax = 3600; + $sleep = 10; + while (parseMsgUnavailable($page) === true) { + echo "WARNING: ID: $j unavailable\n"; + $maxunavail++; + if ($maxunavail > MAXMISSES) { + toggleLock($board_id,0); + die("ABORT: Hit MAXMISSES " . MAXMISSES . "\n"); + } + if ($sleep > $sleepmax) { + $sleep = 10; + } else { + $sleep = $sleep * 2; + } + if (QUIET !== true) { echo "INFO: Sleeping $sleep\n"; } + sleep($sleep); + } + if (!parseMsgExists($page)) { + echo "WARNING: ID: $j missing\n"; + $maxmisses++; + if ($maxmisses > MAXMISSES) { + toggleLock($board_id,0); + die("ABORT: Hit MAXMISSES " . MAXMISSES . ".\n"); + } + continue; + } else { + $maxmisses = 0; + } + + $msg_recs = parseMsgRecs($page); + if ($msg_recs === false) { + echo "ERROR: ID: $message_id: recs\n"; + continue; + } + + if (DRYRUN !== true) { + $msg_recs = addslashes($msg_recs); + $sql = "update " . DBN . ".message_ids "; + $sql .= "set message_recs=$msg_recs "; + $sql .= "where board_id=$board_id and message_id=$j limit 1"; + if (!db_query($sql)) { + echo "ERROR: ID: $j: update rec\n"; + } + } + if (QUIET !== true) { + echo "ID: $j R: $msg_recs\n"; + } + } + +return true; + +} + +/***************************************************************************** + * * + *****************************************************************************/ function queryBoardInfo($board_name='',$initialize=true) { if ($board_name == '') { return false; } @@ -1079,7 +1274,37 @@ } +/***************************************************************************** + * * + *****************************************************************************/ +function runUpgrades() { +// verify message_recs column exists when upgrading from +// 0.0.4 +checkDatabase(); +$has_recs = false; +$fields = db_list_fields(DBN,"message_ids"); +$columns = db_num_fields($fields); +for($j=0; $j < $columns; $j++) { + if (db_field_name($fields,$j) == "message_recs") { + $has_recs = true; + break; + } + } +if (!$has_recs) { + echo "INFO: Upgrading message_ids: adding message_recs column\n"; + $sql = "alter table " . DBN . ".message_ids add message_recs "; + $sql .= "int(5) unsigned default '0' after message_subject"; + if (!db_query($sql)) { + echo "ERROR: Upgrade failure:\n$sql\n"; + return false; + } + } + +return true; + +} + /***************************************************************************** * * *****************************************************************************/ @@ -1097,68 +1322,78 @@ defined('YAHOOHOST') ? $yhh = true : $yhh = false; defined('FETCHSLEEP') ? $fs = true : $fs = false; defined('RETRIES') ? $rt = true : $rt = false; -defined('USER_AGENT') ? $ua = true : $ua = false; +defined('USER_AGENT') ? $ua = true : $ua = false; defined('SOCKTIMEOUT') ? $to = true : $to = false; defined('MAXMISSES') ? $mm = true : $mm = false; if (!$dbh or DBH == '') { - $msg .= " Database host not defined (DBH).\n"; + $msg .= "ERROR: Database host not defined (DBH).\n"; } if (!$dbn or DBN == '') { - $msg .= " Database name not defined (DBN).\n"; + $msg .= "ERROR: Database name not defined (DBN).\n"; } if (!$dbu or DBU == '') { - $msg .= " Database user not defined (DBU).\n"; + $msg .= "ERROR: Database user not defined (DBU).\n"; } if (!$dbp or DBP == '') { - $msg .= " Database password not defined (DBP).\n"; + $msg .= "ERROR: Database password not defined (DBP).\n"; } if (!$rd or ROOTDIR == '' or !is_dir(ROOTDIR)) { - $msg .= " Invalid or undefined directory (ROOTDIR)\n"; + $msg .= "ERROR: Invalid or undefined directory (ROOTDIR)\n"; } if (!$id or INCDIR == '' or !is_dir(INCDIR)) { - $msg .= " Invalid or undefined directory (INCDIR)\n"; + $msg .= "ERROR: Invalid or undefined directory (INCDIR)\n"; } $dbinc = INCDIR . "/" . DBINCLUDE; if (!$dbi or DBINCLUDE == '' or !is_file($dbinc)) { - $msg .= " Invalid or undefined db include ($dbinc)\n"; + $msg .= "ERROR: Invalid or undefined db include ($dbinc)\n"; } if (!$yhh or YAHOOHOST == '') { - $msg .= " Invalid or undefined yahoo host (YAHOOHOST)\n"; + $msg .= "ERROR: Invalid or undefined yahoo host (YAHOOHOST)\n"; } -if (!$fs or FETCHSLEEP == '' or !is_numeric(FETCHSLEEP)) { - $msg .= " Invalid or undefined fetch sleep timeout (FETCHSLEEPO)\n"; +if (!$fs or FETCHSLEEP == '') { + $msg .= "ERROR: Invalid or undefined fetch sleep timeout (FETCHSLEEP)\n"; } if (!$rt or RETRIES == '' or !is_numeric(RETRIES)) { - $msg .= " Invalid or undefined retries value (RETRIES)\n"; + $msg .= "ERROR: Invalid or undefined retries value (RETRIES)\n"; } if (!$to or SOCKTIMEOUT == '' or !is_numeric(SOCKTIMEOUT)) { - $msg .= " Invalid or undefined socket timeout value (SOCKTIMEOUT)\n"; + $msg .= "ERROR: Invalid or undefined socket timeout value "; + $msg .= "(SOCKTIMEOUT)\n"; } if (!$mm or MAXMISSES == '' or !is_numeric(MAXMISSES)) { - $msg .= " Invalid or undefined maximum misses value (MAXMISSES)\n"; + $msg .= "ERROR: Invalid or undefined maximum misses value (MAXMISSES)\n"; } if (!$ua or USER_AGENT == '') { - $msg .= " Invalid or undefined user agent (USER_AGENT)\n"; + $msg .= "ERROR: Invalid or undefined user agent (USER_AGENT)\n"; } $cfg = get_cfg_var('cfg_file_path'); if (!ini_get('allow_url_fopen') == 1) { - $msg .= " Cannot retrieve urls without enabling allow_url_fopen.\n"; - $msg .= " Enable allow_url_fopen in php.ini ($cfg)\n"; + $msg .= "ERROR: Cannot retrieve urls without enabling allow_url_fopen.\n"; + $msg .= " Enable allow_url_fopen in php.ini ($cfg)\n"; } if (!ini_get('max_execution_time') == 0) { - $msg .= " Cannot retrieve urls without enabling allow_url_fopen.\n"; - $msg .= " Enable allow_url_fopen in php.ini ($cfg)\n"; + $msg .= "ERROR: Max execution time is not set to 0.\n"; + $msg .= " Set max_execution_time to 0 in php.ini ($cfg)\n"; } -if (!ini_set('user_agent',USER_AGENT)) { - $msg .= " Cannot set user_agent.\n"; +@ini_set('user_agent',USER_AGENT); +if (ini_get('user_agent') !== USER_AGENT) { + $msg .= "ERROR: Cannot set user_agent: " . USER_AGENT . ".\n"; + $msg .= "ERROR: Currently it is " . ini_get('user_agent') . ".\n"; + } +if (function_exists(runUpgrades)) { + if (!runUpgrades()) { + $msg .= "ERROR: Upgrade attempt failed.\n"; + } } if (! $msg == '') { - $text = "sanityCheck() failed:\n"; + $text = "ABORT: sanityCheck() failed:\n"; $text .= $msg; die($text); } else { - echo "sanityCheck() passed\n"; + if (QUIET !== true) { + echo "INFO: sanityCheck() passed\n"; + } } } @@ -1209,8 +1444,7 @@ $sql .= " where board_id=$board_id limit 1"; if (!db_query($sql)) { - $msg = "\n" . mysql_error() . "\n"; - $msg .= "$sql\n"; + $msg = "ABORT: SQL Error:\n" . mysql_error() . "\n"; die($msg); return false; } diff -u -r -N yasuck-0.0.4.orig/includes/globals.php yasuck-0.0.4/includes/globals.php --- yasuck-0.0.4.orig/includes/globals.php 2004-09-19 14:24:24.000000000 -0500 +++ yasuck-0.0.4/includes/globals.php 2004-09-24 00:46:13.302465976 -0500 @@ -2,7 +2,7 @@ /***************************************************************************** * Copyright (c)2004 badpenguins.com * * Distributed under the terms of the GNU General Public License v2 * - * Created 2004-09-09 Mike Green * + * Created 2004-09-09 Mike Green * *****************************************************************************/ if (basename($PHP_SELF) == basename(__FILE__)) { die("Access Denied\n"); } @@ -18,10 +18,10 @@ define(DBINCLUDE,"mysql.functions.php"); // board settings -define(USER_AGENT,'Mozilla/5.0 (compatible; Konqueror/3.3)'); +define(USER_AGENT,'Mozilla/5.0 (compatible; Konqueror/3.3; phpcli)'); define(YAHOOHOST,'finance.messages.yahoo.com'); define(SOCKTIMEOUT,10); -define(FETCHSLEEP,"2,5"); +define(FETCHSLEEP,"1,4"); //define(FETCHSLEEP,1); define(RETRIES,5); diff -u -r -N yasuck-0.0.4.orig/includes/mysql.functions.php yasuck-0.0.4/includes/mysql.functions.php --- yasuck-0.0.4.orig/includes/mysql.functions.php 2004-09-15 18:32:31.000000000 -0500 +++ yasuck-0.0.4/includes/mysql.functions.php 2004-09-24 00:46:26.358481160 -0500 @@ -2,7 +2,7 @@ /***************************************************************************** * Copyright (c)2004 badpenguins.com * * Distributed under the terms of the GNU General Public License v2 * - * Created 2004-09-09 Mike Green * + * Created 2004-09-09 Mike Green * *****************************************************************************/ if (basename($PHP_SELF) == basename(__FILE__)) { die("Access Denied"); } diff -u -r -N yasuck-0.0.4.orig/yasuck yasuck-0.0.4/yasuck --- yasuck-0.0.4.orig/yasuck 2004-09-19 14:22:04.000000000 -0500 +++ yasuck-0.0.4/yasuck 2004-09-24 00:45:39.044673952 -0500 @@ -3,7 +3,7 @@ /***************************************************************************** * yasuck - Copyright (c)2004 badpenguins.com * * Distributed under the terms of the GNU General Public License v2 * - * Created 2004-09-09 Mike Green * + * Created 2004-09-09 Mike Green * *****************************************************************************/ require_once("includes/globals.php"); // process command line arguments @@ -13,14 +13,26 @@ // query the sid $info_ar = queryBoardInfo($board); if ($info_ar === false or !is_array($info_ar)) { - die("Cannot retrieve information for board: $board\n"); + die("ABORT: cannot retrieve information for board: $board\n"); } $board_id = $info_ar['board_id']; $ticker_id = $info_ar['ticker_id']; // locking -if (checkLock($board_id)) { die("Board $board is locked\n"); } -if (!toggleLock($board_id,1)) { die("Cannot put lock on board.\n"); } +if (checkLock($board_id)) { die("ABORT: board $board is locked\n"); } +if (!toggleLock($board_id,1)) { die("ABORT: cannot lock board $board.\n"); } + +// take care of rec refresh updates +if (RECSONLY === true) { + if (RECSALL === true) { + $start = 1; + $end = $info_ar['high_msg']; + } + processRecommendations($board_id,$ticker_id,$start,$end); + toggleLock($board_id,0); + echo "\n"; + exit(); + } // figure out where to start/end if (!is_numeric($start)) { @@ -29,39 +41,42 @@ if (!is_numeric($end)) { if (!$page = retrieveList($board)) { toggleLock($board_id,0); - die("Cannot retrieve page list.\n"); + die("ABORT: cannot retrieve page list.\n"); } $end = parseHighMessage($page); if (!is_numeric($end)) { toggleLock($board_id,0); - die("Cannot determine high message number.\n"); + die("ABORT: cannot determine high message number.\n"); } } if ($start > $end) { toggleLock($board_id,0); - die("Invalid start($start)/end($end)\n"); + die("ABORT: invalid start($start)/end($end)\n"); } // start sucking echo "Retrieving messages: Board($board) Start($start) End($end)\n"; for($j = $start; $j <= $end; $j++) { if (!$page = retrieveMsg($board_id,$ticker_id,$j)) { - echo "$j(retrieval failure) "; + echo "WARNING: ID: $j retrieval failure\n"; continue; } if (DUMPHTML === true) { if (!$fd = fopen("$j.html","w")) { - echo "cannot open file for html dump "; + echo "WARNING: cannot open file: $j.html\n"; } else { foreach($page as $line) { if (!fwrite($fd,$line . "\n")) { - echo "could not write to $j.html "; + echo "WARNING: could not write to file: $j.html\n"; fclose($fd); break; } } fclose($fd); + if (QUIET !== true) { + echo "INFO: wrote $j.html\n"; + } } } // account for yahoo outages @@ -69,37 +84,33 @@ $sleepmax = 3600; $sleep = 10; while (parseMsgUnavailable($page) === true) { - echo "$j(unavailable) "; + echo "WARNING: ID: $j unavailable\n"; $maxunavail++; if ($maxunavail > MAXMISSES) { toggleLock($board_id,0); - die("Hit MAXMISSES (" . MAXMISSES . ") - aborting\n"); + die("ABORT: Hit MAXMISSES: " . MAXMISSES . "\n"); } if ($sleep > $sleepmax) { $sleep = 10; } else { $sleep = $sleep * 2; } + if (QUIET !== true) { echo "INFO: Sleeping $sleep\n"; } sleep($sleep); } if (!parseMsgExists($page)) { - echo "$j(missing) "; + echo "WARNING: ID: $j missing\n"; $maxmisses++; if ($maxmisses > MAXMISSES) { toggleLock($board_id,0); - die("Hit MAXMISSES (" . MAXMISSES . ") - aborting.\n"); + die("ABORT: Hit MAXMISSES " . MAXMISSES . ".\n"); } continue; } else { $maxmisses = 0; } processMessage($board_id,$j,$page); - //if (processMessage($board_id,$j,$page)) { - // echo "$j "; - // } } -echo "\n"; - toggleLock($board_id,0); - -?> \ No newline at end of file +if (QUIET !== true) { echo "Done\n"; } +?>