diff -u -r -N yasuck-0.0.1.orig/docs/ChangeLog yasuck-0.0.1/docs/ChangeLog --- yasuck-0.0.1.orig/docs/ChangeLog 2004-09-17 23:25:11.000000000 -0500 +++ yasuck-0.0.1/docs/ChangeLog 2004-09-18 22:54:37.019174112 -0500 @@ -4,6 +4,12 @@ *yasuck-0.0.1 (17 Sep 2004) + 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, includes/app.functions.php, includes/globals.php, yasuck, patch-0.0.1-01: diff -u -r -N yasuck-0.0.1.orig/includes/app.functions.php yasuck-0.0.1/includes/app.functions.php --- yasuck-0.0.1.orig/includes/app.functions.php 2004-09-17 23:15:56.000000000 -0500 +++ yasuck-0.0.1/includes/app.functions.php 2004-09-18 13:09:50.332161304 -0500 @@ -38,7 +38,9 @@ switch($arg) { case "--debug": case "--skipmsgs": - continue; + break; + case "--dryrun": + define(DRYRUN,true); break; case "--end": $j++; @@ -46,7 +48,6 @@ if (empty($end)) { die(helpMessage()); } if (substr($end,0,2) == "--") { die(helpMessage()); } if (!is_numeric($end)) { die(helpMessage()); } - continue; break; case "--get": $j++; @@ -54,7 +55,6 @@ $board = $args[$j]; if (empty($board)) { die(helpMessage()); } if (substr($board,0,2) == "--") { die(helpMessage()); } - continue; break; case "--poster": $j++; @@ -70,7 +70,6 @@ if (empty($start)) { die(helpMessage()); } if (substr($start,0,2) == "--") { die(helpMessage()); } if (!is_numeric($start)) { die(helpMessage()); } - continue; break; case "--status": $j++; @@ -78,7 +77,6 @@ $board = $args[$j]; if (empty($board)) { die(helpMessage()); } if (substr($board,0,2) == "--") { die(helpMessage()); } - continue; break; case "--subject": $j++; @@ -336,6 +334,7 @@ $msg = "Usage: $fname action args [--start msg] [--end msg] --debug Turn on verbose debug messages + --dryrun Fetch only, NO database message insert/updates --end MSG End with message number MSG (optional) --get BOARD Retrieve messages from board BOARD --help Display this help message @@ -628,6 +627,48 @@ /***************************************************************************** * * *****************************************************************************/ +function parseMsgNext($page='') { + +if ($page == '' or !is_array($page)) { return false; } + +foreach($page as $line) { + $line = strtolower($line); + $posend = strpos($line,"\">Next >"); + if ($posend === false ) { continue; } + $line = substr($line,0,$posend); + $posbeg = strpos($line,"mid="); + if ($posbeg === false) { return false; } + return str_replace('"','',substr($line,$posbeg+4)); + } + +return 0; + +} + +/***************************************************************************** + * * + *****************************************************************************/ +function parseMsgPrev($page='') { + +if ($page == '' or !is_array($page)) { return false; } + +foreach($page as $line) { + $line = strtolower($line); + $posend = strpos($line,"\">< Previous"); + if ($posend === false ) { continue; } + $line = substr($line,0,$posend); + $posbeg = strpos($line,"mid="); + if ($posbeg === false) { return false; } + return str_replace('"','',substr($line,$posbeg+4)); + } + +return 0; + +} + +/***************************************************************************** + * * + *****************************************************************************/ function parseMsgReplyTo($page='') { if ($page == '' or !is_array($page)) { return false; } @@ -895,38 +936,41 @@ echo "$message_id(msgdate) "; } -$message_id = addslashes($message_id); -$board_id = addslashes($board_id); -$poster_id = addslashes($poster_id); -$parent_id = addslashes($parent_id); -$thread_id = addslashes($thread_id); -$ds = addslashes($ds); -$subject = addslashes($subject); -$msgtext = addslashes($msgtext); -if ($insert_msg) { - $fl = "message_id,board_id,poster_id,parent_id,thread_id,message_date,"; - $fl .= "message_subject,message_text"; - $vl = "$message_id,$board_id,$poster_id,$parent_id,$thread_id,"; - $vl .= "'$ds','$subject','$msgtext'"; - $sql = "insert into " . DBN . ".message_ids($fl)\nvalues($vl)"; - if (!db_query($sql)) { - echo "$message_id(insert) "; - return false; +if (! DRYRUN === true) { + $message_id = addslashes($message_id); + $board_id = addslashes($board_id); + $poster_id = addslashes($poster_id); + $parent_id = addslashes($parent_id); + $thread_id = addslashes($thread_id); + $ds = addslashes($ds); + $subject = addslashes($subject); + $msgtext = addslashes($msgtext); + if ($insert_msg) { + $fl = "message_id,board_id,poster_id,parent_id,thread_id,"; + $fl .= "message_date,message_subject,message_text"; + $vl = "$message_id,$board_id,$poster_id,$parent_id,$thread_id,"; + $vl .= "'$ds','$subject','$msgtext'"; + $sql = "insert into " . DBN . ".message_ids($fl)\nvalues($vl)"; + if (!db_query($sql)) { + echo "$message_id(insert) "; + return false; + } + } else { + $sql = "update " . DBN . ".message_ids set board_id=$board_id"; + $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 .= "where board_id=$board_id and message_id=$message_id "; + $sql .= "limit 1"; + if (!db_query($sql)) { + echo "$message_id(update) "; + return false; + } } - } else { - $sql = "update " . DBN . ".message_ids set board_id=$board_id, "; - $sql .= "poster_id=$poster_id,parent_id=$parent_id,thread_id=$thread_id,"; - $sql .= "message_date='$ds',message_text='$msgtext',"; - $sql .= "message_subject='$subject' "; - $sql .= "where board_id=$board_id and message_id=$message_id limit 1"; - if (!db_query($sql)) { - echo "$message_id(update) "; - return false; + if (!updateCounters($board_id,$message_id)) { + echo "$message_id(updateCounters()) "; } } -if (!updateCounters($board_id,$message_id)) { - echo "$message_id(updateCounters()) "; - } return true;