diff --git a/admin-threads.php b/admin-threads.php index 326ac60..34f6a12 100644 --- a/admin-threads.php +++ b/admin-threads.php @@ -6,10 +6,10 @@ require 'lib/layout.php'; print "$header
"; - + if (!$isadmin) { - print " + print " $tblstart $tccell1>This feature is restricted. $tblend @@ -24,7 +24,7 @@ print adminlinkbar("admin-threads.php"); if (!$_POST['run']) { - print "
+ print " $tblstart $tccellh>Thread Repair System $tccell1>  @@ -57,7 +57,7 @@ "; - $q = "SELECT `posts`.`thread`, (COUNT(`posts`.`id`)) AS 'real', ((COUNT(`posts`.`id`) - 1) - `threads`.`replies`) AS 'offset', `threads`.`replies`, `threads`.`title` AS `threadname` FROM `posts` LEFT JOIN `threads` ON `posts`.`thread` = `threads`.`id` GROUP BY `thread` ORDER BY `offset` DESC"; + $q = "SELECT `posts`.`thread`, (COUNT(`posts`.`id`)) AS 'real', ((CAST(COUNT(`posts`.`id`) AS SIGNED) - 1) - CAST(`threads`.`replies` AS SIGNED)) AS 'offset', `threads`.`replies`, `threads`.`title` AS `threadname` FROM `posts` LEFT JOIN `threads` ON `posts`.`thread` = `threads`.`id` GROUP BY `thread` HAVING `offset` <> 0 OR `offset` IS NULL ORDER BY ISNULL(`threadname`) ASC, `thread` DESC"; $sql = mysql_query($q) or die(mysql_error()); $count = ""; @@ -65,33 +65,28 @@ $status = ""; - if ($data['offset'] != 0) { + if ($data['offset'] != 0 || $data['offset'] === null) { - if ($data['offset'] >= 10000000) { - $data['offset'] = ($data['real'] - 1) - $data['replies']; -// $status = "First post missing or otherwise broken"; -// $data['offset'] = " "; - } - - if (!$status) { + if ($data['replies'] === null) { + $status = "Invalid thread"; + } else { $status = mysql_query("UPDATE `threads` SET `replies` = '". ($data['real'] - 1) ."' WHERE `id` = '". $data['thread'] ."'") or "Error: ". mysql_error(); if ($status == 1) $status = "Updated"; -// $status = "Not updated"; $count++; } print " - $tccell1>". $data['thread'] ." - $tccell2l>". $data['threadname'] ." - $tccell1r>". $data['replies'] ." - $tccell1r>". $data['real'] ." - $tccell2r>". $data['offset'] ." - $tccell1l>$status - "; + $tccell1>". $data['thread'] ." + $tccell2l>". ($data['threadname'] !== null ? $data['threadname'] : "(Deleted thread)") ." + $tccell1>". ($data['replies'] !== null ? $data['replies'] + 1 : "—") ." + $tccell1>". ($data['real']) ." + $tccell2>". ($data['offset'] !== null ? $data['offset'] : "—") ." + $tccell1>$status + "; } else { - break; + continue; } } @@ -106,9 +101,8 @@ } } - + print "$tblend $footer "; printtimedif($startingtime); -?> diff --git a/admin-threads2.php b/admin-threads2.php index 8b9a2f6..b089a51 100644 --- a/admin-threads2.php +++ b/admin-threads2.php @@ -6,10 +6,10 @@ require 'lib/layout.php'; print "$header
"; - + if (!$isadmin) { - print " + print " $tblstart $tccell1>This feature is restricted. $tblend @@ -23,7 +23,7 @@ print adminlinkbar("admin-threads2.php"); if (!$_POST['run']) { - print " + print " $tblstart $tccellh>Thread Repair System II $tccell1>  @@ -57,8 +57,8 @@ "; - - $q = "SELECT `threads`.`id`, `threads`.`title` , `threads`.`lastpostdate` , `posts`.`date` as realdate, (`posts`.`date` - `threads`.`lastpostdate`) AS `diff` FROM `threads` LEFT JOIN (SELECT MAX(`date`) as `date`, `thread` FROM `posts` GROUP BY `thread`) as `posts` ON `posts`.`thread` = `threads`.`id` ORDER BY `diff` DESC"; + + $q = "SELECT `threads`.`id`, `threads`.`title` , `threads`.`lastpostdate` , `posts`.`date` as realdate FROM `threads` LEFT JOIN (SELECT MAX(`date`) as `date`, `thread` FROM `posts` GROUP BY `thread`) as `posts` ON `posts`.`thread` = `threads`.`id` ORDER BY `threads`.`id` DESC"; $sql = mysql_query($q) or die(mysql_error()); $count = ""; @@ -68,7 +68,7 @@ if ($data['lastpostdate'] != $data['realdate']) { - if ($data['lastpostdate'] == "0" && $data['realdate'] == NULL) { + if ($data['lastpostdate'] == "0" && $data['realdate'] === null) { $status = "Broken thread"; } else { @@ -89,7 +89,7 @@ $tccell1>". ($data['realdate'] ? date($dateformat, $data['realdate'] + $tzoff) : "-") ." $tccell1>". timeunits2($data['lastpostdate'] - $data['realdate']) ." $tccell2l>$status - "; + "; } } @@ -100,9 +100,8 @@ } } - + print "$tblend $footer "; printtimedif($startingtime); -?> diff --git a/css/base.css b/css/base.css index 4688976..0d7adc7 100644 --- a/css/base.css +++ b/css/base.css @@ -1,33 +1,56 @@ -textarea,input,select { - border: 1px solid #000; - background: #000; - color: #EEE; - font: 10pt monospace; -} -input[type=radio] { - border: none; -} -input[type=submit] { - border: #000 solid 2px; - font: 10pt 'verdana', sans-serif; -} -body, table, thead, tbody, span, td, tr, th, a, img, br { padding: 0; margin: 0; border: 0; font-size: 100%; } -center { text-align: center; } -.tdbgh, .tbl, .tdbgc, .tdbg1, .tdbg2 { line-height: 1; padding: 1px;} -table { border-spacing: 0; border-collapse: collapse; } -a:link,a:visited,a:active,a:hover { text-decoration:none; font-weight: bold; } -table { padding: 0.5em; } -span.lastpost { font-size: 90%; padding: 0; margin: 0; } -div.lastpost { font-size: 90%; text-align: right !important; } +/* Global CSS styles across every theme */ -.table { width: 100%; empty-cells: show;} -.sparkline { display: none; } -.center, center { text-align: center; } -.right { text-align: right; } +/* Make images upscale crispy */ +* { + image-rendering: -moz-crisp-edges; + image-rendering: -o-crisp-edges; + image-rendering: -webkit-optimize-contrast; + image-rendering: crisp-edges; + image-rendering: pixelated; + -ms-interpolation-mode:nearest-neighbor; + } -code { overflow: auto; width: 100%; white-space: pre; display: block; } -code br { display: none; } +/* Make all links bold and not underlined by default */ +a:link,a:visited,a:active,a:hover{text-decoration:none;font-weight:bold;} +/* Mostly legacy thing from when IE had a blue border around link images */ +img { border:none; } +.center {text-align:center} +.right {text-align:right} + +/* Make code blocks scroll instead of stretching the page */ +code { + overflow: auto; + width: 100%; + white-space: pre; + display: block; +} + +/* "Fix" for auto-generated
tags in and
 blocks */
+code br, pre br { display: none; }
+
+/* Make radio buttons look not terrible */
+input[type=radio] { color: black; background: white; }
+
+/* Spoiler tag code */
 .pstspl1 {opacity:0;}
 .pstspl1:hover {opacity:1;}
 .pstspl2 {background:#000;color:#FFF;display:block;}
+
+/* Stop avatars from being huge */
+.avatar	{
+	max-width:	200px;
+	}
+
+/* On mobile, make avatars smaller */
+.mobile-avatar {
+	float:	left;
+	height:	50px;
+	width:	50px;
+	padding: 2px;
+	text-align:	center;
+}
+.mobile-avatar > .avatar {
+	max-height:	100%;
+	max-width:	100%;
+}
diff --git a/css/basics.css b/css/basics.css
new file mode 100644
index 0000000..4688976
--- /dev/null
+++ b/css/basics.css
@@ -0,0 +1,33 @@
+textarea,input,select {
+	border: 1px solid #000;
+	background: #000;
+	color: #EEE;
+	font: 10pt monospace;
+}
+input[type=radio] {
+	border: none;
+}
+input[type=submit] {
+	border: #000 solid 2px;
+	font: 10pt 'verdana', sans-serif;
+}
+body, table, thead, tbody, span, td, tr, th, a, img, br { padding: 0; margin: 0; border: 0; font-size: 100%; }
+center { text-align: center; }
+.tdbgh, .tbl, .tdbgc, .tdbg1, .tdbg2 { line-height: 1; padding: 1px;}
+table { border-spacing: 0; border-collapse: collapse; }
+a:link,a:visited,a:active,a:hover { text-decoration:none; font-weight: bold; }
+table { padding: 0.5em; }
+span.lastpost { font-size: 90%; padding: 0; margin: 0; }
+div.lastpost { font-size: 90%; text-align: right !important; }
+
+.table { width: 100%; empty-cells: show;}
+.sparkline { display: none; }
+.center, center { text-align: center; }
+.right { text-align: right; }
+
+code { overflow: auto; width: 100%; white-space: pre; display: block; }
+code br { display: none; }
+
+.pstspl1 {opacity:0;}
+.pstspl1:hover {opacity:1;}
+.pstspl2 {background:#000;color:#FFF;display:block;}
diff --git a/images/photobucket.png b/images/photobucket.png
new file mode 100644
index 0000000..b761da7
Binary files /dev/null and b/images/photobucket.png differ
diff --git a/lib/function.php b/lib/function.php
index e9af9bc..87f7451 100644
--- a/lib/function.php
+++ b/lib/function.php
@@ -14,7 +14,7 @@
 		$id = 0;
 
 	// Wait for the midnight backup to finish...
-	if ((int)date("Gi") < 5) {
+	if ((int)date("Gi") < 1) {
 		require "lib/downtime.php";
 	}
 
@@ -323,12 +323,13 @@ function readpostread($userid){
 }
 
 function timeunits($sec){
-	if($sec<60)	return "$sec sec.";
-	if($sec<3600)	return floor($sec/60).' min.';
-	if($sec<7200)	return '1 hour';
-	if($sec<86400)	return floor($sec/3600).' hours';
-	if($sec<172800)	return '1 day';
-	return floor($sec/86400).' days';
+	if($sec<60)			return "$sec sec.";
+	if($sec<3600)		return floor($sec/60).' min.';
+	if($sec<7200)		return '1 hour';
+	if($sec<86400)		return floor($sec/3600).' hours';
+	if($sec<172800)		return '1 day';
+	if($sec<31556926)	return floor($sec/86400).' days';
+	return sprintf("%.1f years", floor($sec/31556926));
 }
 
 function timeunits2($sec){
@@ -1177,14 +1178,6 @@ function adminlinkbar($sel = 'admin.php') {
 	return $r;
 }
 
-function nuke_js($before, $after) {
-
-	global $sql, $loguser;
-	$page	= addslashes($_SERVER['REQUEST_URI']);
-	$time	= ctime();
-	$sql -> query("INSERT INTO `jstrap` SET `loguser` = '". $loguser['id'] ."', `ip` = '". $_SERVER['REMOTE_ADDR'] ."', `text` = '". addslashes($before) ."', `url` = '$page', `time` = '$time', `filtered` = '". addslashes($after) ."'");
-
-}
 function include_js($fn, $as_tag = false) {
 	// HANDY JAVASCRIPT INCLUSION FUNCTION
 	if ($as_tag) {
@@ -1206,9 +1199,6 @@ function dofilters($p){
 		$p=preg_replace("''si",'',$p);
 		$p=preg_replace("'oad',$p);
@@ -1227,10 +1217,6 @@ function dofilters($p){
 		$p=preg_replace("'onmouseout'si",'onmouseout',$p);
 		$p=preg_replace("'onmouseover'si",'onmouseover',$p);
 		$p=preg_replace("'onmouseup'si",'onmouseup',$p);
-
-		if ($temp != $p) {
-			nuke_js($temp, $p);
-		}
 	}
 
 	//$p=preg_replace("''si","",$p);
@@ -1277,6 +1263,9 @@ function dofilters($p){
 		$p=str_replace("-->", '-->', $p);
 	}
 
+	$p=preg_replace("'(https?://.*?photobucket.com/)'si",'images/photobucket.png#\\1',$p);
+
+
 	$p=str_replace("http://insectduel.proboards82.com","http://jul.rustedlogic.net/idiotredir.php?",$p);
 //	$p=str_replace("http://imageshack.us", "imageshit", $p);
 	$p=preg_replace("'http://.{0,3}\.?tinypic\.com'si",'tinyshit',$p);
@@ -1614,5 +1603,3 @@ function ircerrors($type, $msg, $file, $line, $context) {
 	           " $typetext: ".xk()."($errorlocation) $msg");
 	return true;
 }
-
-
diff --git a/lib/layout.php b/lib/layout.php
index d038615..b640109 100644
--- a/lib/layout.php
+++ b/lib/layout.php
@@ -10,7 +10,7 @@
 	header('Pragma: no-cache');
 
 	$userip = $_SERVER['REMOTE_ADDR'];
-	
+
 	if (!($clientip    = filter_var(getenv("HTTP_CLIENT_IP"),       FILTER_VALIDATE_IP))) $clientip =    "XXXXXXXXXXXXXXXXX";
 	if (!($forwardedip = filter_var(getenv("HTTP_X_FORWARDED_FOR"), FILTER_VALIDATE_IP))) $forwardedip = "XXXXXXXXXXXXXXXXX";
 //	$clientip=(getenv("HTTP_CLIENT_IP") == "" ? "XXXXXXXXXXXXXXXXX" : getenv("HTTP_CLIENT_IP"));
@@ -73,43 +73,25 @@
 		// special "null" scheme.
 		$css = "";
 	} elseif (isset($schemetype) && $schemetype == 1) {
-		$css = "";
+		$css = "";
 		// possibly causes issue #19 - not sure why this was here
 		// likely irrelevant after addition of custom date formats
 		// (remove this later)
 		//$dateformat = "m/d/y h:i";
 		//$dateshort  = "m/d/y";
-		
+
 		// backwards compat
 		global $bgcolor, $linkcolor;
 		$bgcolor = "000";
 		$linkcolor = "FFF";
 	} else {
 		$css="
+