diff --git a/archive.php b/archive.php index 4b8c72b..7c6eb67 100644 --- a/archive.php +++ b/archive.php @@ -28,7 +28,7 @@ if(isset($_REQUEST['list_by']) && $_REQUEST['list_by'] == "date") $comics = mysqli_query($link,"SELECT distinct id, title, DATE_FORMAT(published, '%M %D, %Y') AS pubdate FROM strip WHERE published < NOW() ORDER BY id") or die(mysqli_error($link)); - + echo '

Comics by Date

diff --git a/external.php b/external.php index fa6b318..4148fe6 100644 --- a/external.php +++ b/external.php @@ -4,20 +4,20 @@ require_once 'frontend.inc.php'; class MTAPIi { - + private static $db_conn; - + static function construct($db) { $db_conn = $db; return mysqli_ping($db_conn); } - + static function destruct() { $db_conn = NULL; } - + #This just returns the current maximum comic static function getNumStrips() { @@ -36,7 +36,7 @@ class MTAPIi die("Invalid args: $comic $panel\n"); return false; } - + $script = build_panel_transcript($comic, $panel); if(!$xml) { @@ -88,9 +88,9 @@ class MTAPIi { return false; } - + $panels = MTAPIi::getNumPanels($comic); - + $query = 'SELECT DISTINCT speaker FROM transcript WHERE strip = '.(int)$comic; $query .= ' AND panel = '.(int)$panel; $query .= ' AND speaker NOT LIKE "#%" '; @@ -99,7 +99,7 @@ class MTAPIi $query .= " AND search != '' "; } $query .= 'ORDER BY speaker'; - + return query_to_array($query); } @@ -109,7 +109,7 @@ class MTAPIi { return false; } - + $query = 'SELECT DISTINCT speaker FROM transcript WHERE strip = '.(int)$comic; $query .= ' AND speaker NOT LIKE "#%" '; if($speakersOnly) @@ -117,7 +117,7 @@ class MTAPIi $query .= " AND search != '' "; } $query .= 'ORDER BY speaker'; - + return query_to_array($query); } @@ -161,7 +161,7 @@ class MTAPIi $query = 'SELECT description FROM strip_t JOIN strip ON strip.type = strip_t.id WHERE strip.id = '.(int)$comic; - + $qr = query_to_array($query); return $qr[0]; } @@ -178,11 +178,11 @@ class MTAPIi JOIN strip_t ON meta.type = strip_t.id JOIN strip ON strip.type = strip_t.id WHERE strip.id = '.(int)$comic.' ORDER BY meta_t.id'; - + $qr = query_to_array($query); return $qr; } - + static function getStrip($comic) { if(!validate_comic_id($comic)) @@ -192,26 +192,26 @@ class MTAPIi $strip = load_strip($comic); $strip['type'] = self::getStripTypeName($strip['type']); $strip['number'] = self::getStripNumberInType($comic); - + unset($strip['udate']); - + return $strip; } - + static function getStripNumberInType($comic) { if(!validate_comic_id($comic)) { return false; } - + $type = self::getStripType($comic); - + $query = "SELECT count(*) FROM strip_t JOIN strip ON strip_t.id = strip.type WHERE strip.id < {$comic}+1 AND strip.type = {$type}"; - + $qr = query_to_array($query); return $qr[0]; } @@ -227,7 +227,7 @@ class MTAPIi JOIN strip_t ON meta.type = strip_t.id JOIN strip ON strip.type = strip_t.id WHERE strip.id = '.(int)$comic.' ORDER BY meta_t.name'; - + $qr = query_to_array($query); return $qr; } @@ -238,12 +238,12 @@ class MTAPIi { return false; } - + $query = 'SELECT meta_t.id FROM meta_t JOIN meta ON meta_t.id = meta.meta JOIN strip_t ON meta.type = strip_t.id WHERE strip_t.id = '.(int)$type.' ORDER BY meta_t.id'; - + $qr = query_to_array($query); return $qr; } @@ -254,12 +254,12 @@ class MTAPIi { return false; } - + $query = 'SELECT meta_t.name FROM meta_t JOIN meta ON meta_t.id = meta.meta JOIN strip_t ON meta.type = strip_t.id WHERE strip_t.id = '.(int)$type.' ORDER BY meta_t.name'; - + $qr = query_to_array($query); return $qr; } @@ -270,7 +270,7 @@ class MTAPIi { return false; } - + $query = 'SELECT strip.id FROM strip WHERE strip.type = '.(int)$type.' ORDER BY strip.id'; $qr = query_to_array($query); return $qr; @@ -283,7 +283,7 @@ class MTAPIi { return false; } - + $query = 'SELECT strip.id FROM strip JOIN strip_t ON strip.type = strip_t.id JOIN meta ON strip_t.id = meta.type diff --git a/frontend.inc.php b/frontend.inc.php index c27acc1..fff3c61 100644 --- a/frontend.inc.php +++ b/frontend.inc.php @@ -40,7 +40,7 @@ function get_num_panels($comic) { return false; } - + $rs = mysqli_query($link,'SELECT MAX(panel) FROM transcript WHERE strip = '.(int)$comic); return current(mysqli_fetch_row($rs)); } @@ -48,9 +48,9 @@ function get_num_panels($comic) function build_panel_transcript($comic, $panel) { $query = 'SELECT speaker, speech FROM transcript - WHERE strip = '.(int)$comic.' AND panel = '.(int)$panel.' + WHERE strip = '.(int)$comic.' AND panel = '.(int)$panel.' AND speaker NOT LIKE "#%" ORDER BY line'; - + $qr = query_to_nested($query); return $qr; } @@ -65,7 +65,7 @@ function query_to_nested($query) $ret[]= $row; } mysqli_free_result($rs); - + return $ret; } @@ -81,7 +81,7 @@ function query_to_array($query, $col=0) $ret[]= $row[0]; } mysqli_free_result($rs); - + return $ret; } @@ -141,7 +141,7 @@ function conditional_exit($mtime) { if(!PERFORM_CONDITIONAL_CACHE) return; - + $f_date = gmdate( 'D, d M Y H:i:s T', $mtime ); header("Last-Modified: $f_date"); @@ -183,17 +183,17 @@ function mtdie($errno, $errstr, $errfile, $errline, $errcontext) { } error_log( $message, 0 ); // Log to Syslog - + $message .= "\r\n\r\nBacktrace:"; $backtrace = array_reverse(debug_backtrace()); $i=2; $message .= "\r\n1: " . $err_context . " at $errfile:$errline"; foreach($backtrace as $k=>$call) { - $message .= "\r\n" . str_pad("$i:", $i+4 ) . $call['function'] . '( ' . implode(', ', $call['args']) . ' ) at ' . $call['file'] . ':' . $call['line']; + $message .= "\r\n" . str_pad("$i:", $i+4 ) . $call['function'] . '( ' . implode(', ', $call['args']) . ' ) at ' . $call['file'] . ':' . $call['line']; $i++; } $message .= "\r\n"; - + $message .= "\r\nRequest Details:" . "\r\nscript_url: " . $_SERVER["SCRIPT_URL"] . "\r\nquery_string: " . $_SERVER["QUERY_STRING"] @@ -300,7 +300,7 @@ function pagehead($caller, $title = 'relax, we understand j00', $style='') - + - + - + /www/delivery/spcjs.php?id=1'> */ ?> @@ -361,7 +361,7 @@ function pagefoot() all rights reserved.

'megatokyo' is a registered trademark of fredart studios llc.

- endElement(); return $xml->outputMemory(true); } @@ -35,7 +35,7 @@ $API = new ReflectionClass('MTAPIi'); if( $API->hasMethod($_GET['method']) ) { $method = $API->getMethod($_GET['method']); $parameters = $method->getParameters(); - + $method_parameters = Array(); foreach($parameters as $parameter) { $param = (Array) $parameter; @@ -51,9 +51,9 @@ if( $API->hasMethod($_GET['method']) ) { printf( 'Parameter %s is required but not supplied', $parameter_name ); } } - + $result = $method->invokeArgs($API, $method_parameters); - + switch($_GET['output-type']) { case 'json': $result = json_encode($result); diff --git a/navswitch.js b/navswitch.js index 2960569..135c520 100644 --- a/navswitch.js +++ b/navswitch.js @@ -17,13 +17,13 @@ function navinit() { f = document.getElementById('searchprevnext'); f.style.display="none"; - b = document.getElementById('q'); + b = document.getElementById('q'); for( i=0; i

Rants by Date

    '; - + while($rant = mysqli_fetch_assoc($rants)) { printf('
  1. %s - %s
  2. ', $rant['pubdate'], $rant['id'], $rant['id'], $rant['author'], utfentities($rant['title'])); } - + echo '
'; } else @@ -55,7 +55,7 @@ else ?>

', utfentities($author['name']), '

    '; - + while($rant = mysqli_fetch_assoc($rants)) { printf('
  1. %s
  2. ', $rant['pubdate'], $rant['id'], $rant['id'], diff --git a/rewrite_searchbox.js b/rewrite_searchbox.js index c78f988..5c19fe3 100644 --- a/rewrite_searchbox.js +++ b/rewrite_searchbox.js @@ -10,7 +10,7 @@ while(match = metarx.exec(textbox.value)) { var t = checks[4].checked; checks[4].checked = true; checks[4].checked = false; - checks[4].checked = t; + checks[4].checked = t; for(i=0; i
    - \ No newline at end of file + diff --git a/search.php b/search.php index 7066a96..024a29b 100644 --- a/search.php +++ b/search.php @@ -55,19 +55,19 @@ if($date_f && $date) if(isset($_REQUEST['q'])) { - if( isset($_GET['method-fp_x']) || isset($_GET['method-fp_y']) + if( isset($_GET['method-fp_x']) || isset($_GET['method-fp_y']) || isset($_GET['method-fp.x']) || isset($_GET['method-fp.y']) ) { array_push($magic, 'max'); array_push($value, $_GET['current'] - 1); - + array_push($magic, 'method'); - array_push($value, 'Find Previous'); + array_push($value, 'Find Previous'); } - if( isset($_GET['method-fn_x']) || isset($_GET['method-fn_y']) + if( isset($_GET['method-fn_x']) || isset($_GET['method-fn_y']) || isset($_GET['method-fn.x']) || isset($_GET['method-fn.y']) ) { array_push($magic, 'min'); array_push($value, $_GET['current'] + 1); - + array_push($magic, 'method'); array_push($value, 'Find Next'); } @@ -85,15 +85,15 @@ if(isset($_REQUEST['q'])) $_REQUEST['q'] = trim("$_REQUEST[q] $k:\"$v\""); } } - + if(get_magic_quotes_gpc()) $_REQUEST['q'] = stripslashes($_REQUEST['q']); - + $tokens = tpw_parse_line('\s+', $_REQUEST['q']); # Protect against SQL injection in the event of Register Globals being on. $SEARCH_MIN = $SEARCH_MAX = null; - + foreach($tokens as $token) { $token = strtolower($token); @@ -108,17 +108,17 @@ if(isset($_REQUEST['q'])) } $subtokens = preg_match('/(?:\w+|[#*]):/', $token) ? preg_split('/:/', $token, 2) : Array( false, $token ); - + # Magic values are easy, just throw them on the list array_push($loop_magic, $subtokens[0]); - + # Values, however, need a bit more cleaning up first if('""' == $subtokens[1]) array_push($loop_value, '""'); else array_push($loop_value, preg_replace('/[[:punct:]]|(?<=\s)\s+/', '', $subtokens[1])); } - + #DEBUG #print_r($magic); #echo "
    "; @@ -139,9 +139,9 @@ if(isset($_REQUEST['q'])) WHERE (strip.published < NOW()) AND (transcript.speaker NOT LIKE \"#%\" OR transcript.speaker IS NULL) "; - + $flag = false; - + if($m) #attempt to short-circuit on no magic { # well, we have magic @@ -177,7 +177,7 @@ if(isset($_REQUEST['q'])) $flag = true; } } - + #now, handle the $value portion of the string # first, handle for "" switch($sub_value[$i]) { @@ -199,21 +199,21 @@ if(isset($_REQUEST['q'])) } $query.=") "; } - + array_push($sub_queries, $query); } - + foreach($sub_queries as $q) { #DEBUG: run the search #echo $q; $result = mysqli_query($link,$q); - + if(!$result) { continue; } - + while($row = mysqli_fetch_row($result)) { #and put all the hits onto an array @@ -232,9 +232,9 @@ if(isset($_REQUEST['q'])) WHERE (strip.published < NOW()) AND (transcript.speaker NOT LIKE \"#%\" OR transcript.speaker IS NULL) "; - + $flag = false; - + if($m) #attempt to short-circuit on no magic { # well, we have magic @@ -319,7 +319,7 @@ if(isset($_REQUEST['q'])) $flag = true; } } - + #now, handle the $value portion of the string # first, handle for "" switch($value[$i]) { @@ -341,10 +341,10 @@ if(isset($_REQUEST['q'])) } $query.=") "; } - + array_push($queries, $query); } - + if(count($queries) == 0) { array_push($queries, $query); @@ -364,7 +364,7 @@ if(isset($_REQUEST['q'])) #second, collapse them into one clause $modifier .= " AND (" . implode(" OR ", $SEARCH_TEMP) . ") "; } - + #now the metatypes, just like the types if(count($META_TYPES) > 0) { @@ -377,7 +377,7 @@ if(isset($_REQUEST['q'])) #second, collapse them into one clause $modifier .= " AND (" . implode(" OR ", $META_TEMP) . ") "; } - + #now do min and max if(isset($SEARCH_MIN)) { @@ -387,7 +387,7 @@ if(isset($_REQUEST['q'])) { $modifier .= "AND (strip.id <= $SEARCH_MAX) "; } - + #and now book and page if(isset($BOOK)) { @@ -397,7 +397,7 @@ if(isset($_REQUEST['q'])) { $modifier .= $PAGE; } - + foreach($queries as $q) { #apply modifiers @@ -408,12 +408,12 @@ if(isset($_REQUEST['q'])) continue; } $result = mysqli_query($link,$q); - + if(!$result) { continue; } - + while($row = mysqli_fetch_row($result)) { #and put all the hits onto an array @@ -423,7 +423,7 @@ if(isset($_REQUEST['q'])) #so, now all the raw hits are in the same spot #now comes The Magic - + # if book and page are used, break out if(isset($BOOK) && isset($PAGE) && count($rhits) != 0) { @@ -431,16 +431,16 @@ if(isset($_REQUEST['q'])) header('Location: ' . SITE_HOST . SITE_PATH . "/strip/$rhits[0]"); exit(0); } - + #first, reverse sort and uniquify a copy rsort($rhits); $uhits = array_unique($rhits); #do the same for the subtraction hits $sub_uhits = array_unique($sub_rhits); - + #now... the subtraction! $uhits = array_diff($uhits, $sub_uhits); - + #if we're redirecting, break out of the normal search logic here if(isset($METHOD) && count($uhits) > 0) { @@ -453,26 +453,26 @@ if(isset($_REQUEST['q'])) { $target = $rhits[0]; } - + //die($METHOD); - + header('HTTP/1.0 301 Moved Permanently'); header('Location: ' . SITE_HOST . SITE_PATH . "/index.php?strip_id=$target" . "&q=" . urlencode($_REQUEST['q'])); exit(0); } - + $revhits = array_reverse($rhits); #now create a count for each unique hit foreach($uhits as $key => $value) { $first = array_search($value, $rhits); $last = array_search($value, $revhits); - + $numhits = count($rhits) - $first - $last; - + array_push($hcount, $numhits); } - + if(count($uhits) > 0) { if($random) { @@ -486,7 +486,7 @@ if(isset($_REQUEST['q'])) $entry.= " - ". htmlentities($result[1]) . ""; array_push($strings, $entry); } - + #now, a clever multisort... array_multisort($hcount, SORT_DESC, SORT_NUMERIC, $uhits, SORT_DESC, SORT_NUMERIC, @@ -502,7 +502,7 @@ pagehead('search', 'Search');
- 0) { + 0) { echo '
    '; /*$qsearch = mysqli_query($link,'SELECT id, title FROM strip WHERE id IN(' . implode(', ', $uhits) . ')'); while($result = mysqli_fetch_array($qsearch)) @@ -514,12 +514,12 @@ pagehead('search', 'Search'); } echo '
'; echo '

Learn to direct search ninjas!

'; - + ?> + 0)) { echo '

So sorry. Search ninjas obey without fail, yet find nothing.

'; @@ -529,7 +529,7 @@ pagehead('search', 'Search'); echo ''; } #search_help(); - + ?>