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-24 08:47:01.563114000 -0500 +++ yasuck-0.0.4/docs/ChangeLog 2004-09-24 11:47:59.139512208 -0500 @@ -2,9 +2,23 @@ # Copyright (c)2004 badpenguins.com; Distributed under the GPL v2 # +*yasuck-0.0.5 (24 Sep 2004) + *yasuck-0.0.4 (19 Sep 2004) 24 Sep 2004: Mike Green docs/ChangeLog, + includes/app.functions.php, includes/globals.php, yasuck, patch-0.0.4-03: + + Added versioning information and arguement to check version (--version). + Turned off the automatic initialization of boards when calling queryBoardInfo + from arguments that shouldn't initialize boards. Reordered processing of + arguments. Added --unlock argument to override a lock on a board. Added + --listgaps argument to query messages and display gaps in message ids, to + find missing message ranges. Changed default FETCHSLEEP to 1 to see if + it will pass the yahoo filters without looking like a DoS attack. + Created patch-0.0.4-03. Bumped version level to 0.0.5. + + 24 Sep 2004: Mike Green docs/ChangeLog, includes/app.functions.php, yasuck, patch-0.0.4-02: Fixed typo that was causing updates to fail, added call to sanityCheck() 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-24 08:47:01.564114000 -0500 +++ yasuck-0.0.4/includes/app.functions.php 2004-09-24 11:30:52.832534584 -0500 @@ -25,9 +25,10 @@ } else { define(SKIPMSGS,false); } -if (in_array("--sanity",$args)) { die(sanityCheck()); } -if (in_array("--help",$args)) { die(helpMessage()); } -if (in_array("--init",$args)) { die(initializeDatabase()); } +if (in_array("--help",$args)) { die(helpMessage()); } +if (in_array("--version",$args)) { die(displayVersion()); } +if (in_array("--sanity",$args)) { die(sanityCheck()); } +if (in_array("--init",$args)) { die(initializeDatabase()); } global $board, $start, $end; @@ -59,6 +60,13 @@ if (empty($board)) { die(helpMessage()); } if (substr($board,0,2) == "--") { die(helpMessage()); } break; + case "--listgaps": + $j++; + $board = $args[$j]; + if (empty($board)) { die(helpMessage()); } + if (substr($board,0,2) == "--") { die(helpMessage()); } + die(listGaps($board)); + break; case "--poster": $j++; $text = $args[$j]; @@ -108,6 +116,13 @@ define(SUBJECT_SEARCH,true); define(SUBJECT_TEXT,$text); break; + case "--unlock": + $j++; + $board = $args[$j]; + if (empty($board)) { die(helpMessage()); } + if (substr($board,0,2) == "--") { die(helpMessage()); } + die(lockOverride($board)); + break; default: die(helpMessage()); break; @@ -199,7 +214,7 @@ checkDatabase(); $msg = ''; -$info_ar = queryBoardInfo($board); +$info_ar = queryBoardInfo($board,false); if ($info_ar === false or !is_array($info_ar)) { $msg .= "ERROR: queryBoardInfo($board) failed.\n"; $board_id = "n/a"; @@ -269,6 +284,25 @@ /***************************************************************************** * * *****************************************************************************/ +function displayVersion() { + +defined('VERSION') ? $version = VERSION : $version = "unknown"; +defined('PATCHLEVEL') ? $patchlevel = PATCHLEVEL : $patchlevel = "unknown"; + +$msg = basename($_SERVER['SCRIPT_FILENAME']) . " version "; +if ($patchlevel) { + $msg .= "$version" . "pl" . "$patchlevel"; + } else { + $msg .= "$version"; + } + +echo "$msg\n"; + +} + +/***************************************************************************** + * * + *****************************************************************************/ function getUa() { $randomize = false; @@ -365,14 +399,17 @@ --get BOARD Retrieve messages from board BOARD --help Display this help message --init Initialize database (destructive) + --listgaps BOARD List possible missing messages --poster POSTER Only retrieve messages posted by POSTER --quiet No non-error messages displayed while running + --recs BOARD [all] Update recommendation counters only --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 - --recs BOARD [all] Update recommendation counters only\n"; + --unlock BOARD Unlock BOARD and exit + --version Display version and exit\n"; die($msg); @@ -501,6 +538,76 @@ /***************************************************************************** * * *****************************************************************************/ +function listGaps($board_name='') { + +$info_ar = queryBoardInfo($board_name,false); +if ($info_ar === false or !is_array($info_ar)) { + die("ABORT: could not look up board: $board_name\n"); + } +$board_id = addslashes($info_ar['board_id']); + +$sql = "select message_id from " . DBN . ".message_ids "; +$sql .= "where board_id=$board_id order by message_id"; +if (!$qid = db_query($sql)) { + die("ABORT: could not query message ids\n"); + } +$num = db_num_rows($qid); +if ($num < 1) { + die("ABORT: no rows returned by query\n"); + } + +defined('GAPMAX') ? $gapmax = GAPMAX : $gapmax = 10; +if (!is_numeric($gapmax)) { $gapmax = 10; } + +$lowest = db_result($qid,0,0); +$highest = db_result($qid,$num - 1,0); +$last = $lowest; +$gaps = array(); + +for($j=0; $j < $num; $j++) { + $mid = db_result($qid,$j,0); + + $gap = $mid - $last; + if ( $gap > $gapmax ) { + $gaps[] = "$last - $mid ($gap)"; + } + $last = $mid; + } + +echo "lowest: $lowest\n"; +if (count($gaps) > 0) { + foreach($gaps as $gap) { + echo "gap: $gap\n"; + } + } +echo "highest: $highest\n"; +exit(); + +} + +/***************************************************************************** + * * + *****************************************************************************/ +function lockOverride($board_name='') { + +$info_ar = queryBoardInfo($board_name,false); +if ($info_ar === false or !is_array($info_ar)) { + die("ABORT: can't unlock non-existent board: $board_name\n"); + } + +if (toggleLock($info_ar['board_id'],0)) { + die("INFO: lock overridden for board: $board_name\n"); + } else { + $msg = "ERROR: could not override lock on board: $board_name "; + $msg .= "(not locked?)\n"; + die($msg); + } + +} + +/***************************************************************************** + * * + *****************************************************************************/ function messageIdExists($board_id='',$message_id='') { $board_id = addslashes($board_id); 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-24 08:46:58.543573000 -0500 +++ yasuck-0.0.4/includes/globals.php 2004-09-24 11:45:16.203282280 -0500 @@ -21,14 +21,17 @@ define(USER_AGENT,'Mozilla/5.0 (compatible; Konqueror/3.3; phpcli)'); define(YAHOOHOST,'finance.messages.yahoo.com'); define(SOCKTIMEOUT,10); -define(FETCHSLEEP,"1,4"); -//define(FETCHSLEEP,1); +//define(FETCHSLEEP,"1,4"); +define(FETCHSLEEP,1); define(RETRIES,5); // misc settings define(RANDOM_UA,INCDIR . "/agents.txt"); define(RANDOMIZE_UA,false); define(MAXMISSES,50); +define(VERSION,"0.0.5"); +define(PATCHLEVEL,""); +define(GAPMAX,15); // debug settings define(DEBUGUA,false); diff -u -r -N yasuck-0.0.4.orig/yasuck yasuck-0.0.4/yasuck --- yasuck-0.0.4.orig/yasuck 2004-09-24 08:47:01.564114000 -0500 +++ yasuck-0.0.4/yasuck 2004-09-24 10:45:38.873119128 -0500 @@ -12,7 +12,7 @@ CheckDatabase(); // query the sid -$info_ar = queryBoardInfo($board); +$info_ar = queryBoardInfo($board,true); if ($info_ar === false or !is_array($info_ar)) { die("ABORT: cannot retrieve information for board: $board\n"); }