mirror of
https://github.com/Xkeeper0/jul.git
synced 2025-05-19 08:40:21 -07:00
i don't know how to update this fork to match the main one so this will do I guess
This commit is contained in:
commit
2c33a35d5a
@ -57,7 +57,7 @@
|
||||
</tr>
|
||||
";
|
||||
|
||||
$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 = "<font color=\"#ff8080\">First post missing or otherwise broken</font>";
|
||||
// $data['offset'] = " ";
|
||||
}
|
||||
|
||||
if (!$status) {
|
||||
if ($data['replies'] === null) {
|
||||
$status = "<font color=\"#ff8080\">Invalid thread</font>";
|
||||
} else {
|
||||
$status = mysql_query("UPDATE `threads` SET `replies` = '". ($data['real'] - 1) ."' WHERE `id` = '". $data['thread'] ."'") or "<font color=#ff0000>Error</font>: ". mysql_error();
|
||||
if ($status == 1) $status = "<font color=#80ff80>Updated</font>";
|
||||
// $status = "Not updated";
|
||||
$count++;
|
||||
}
|
||||
|
||||
print "
|
||||
<tr>
|
||||
$tccell1>". $data['thread'] ."</td>
|
||||
$tccell2l><a href=\"thread.php?id=". $data['thread'] ."\">". $data['threadname'] ."</a></td>
|
||||
$tccell1r>". $data['replies'] ."</td>
|
||||
$tccell1r>". $data['real'] ."</td>
|
||||
$tccell2r><b>". $data['offset'] ."</b></td>
|
||||
$tccell1l>$status</td>
|
||||
$tccell1><a href=\"thread.php?id=". $data['thread'] ."\">". $data['thread'] ."</a></td>
|
||||
$tccell2l><a href=\"thread.php?id=". $data['thread'] ."\">". ($data['threadname'] !== null ? $data['threadname'] : "<em>(Deleted thread)</em>") ."</a></td>
|
||||
$tccell1>". ($data['replies'] !== null ? $data['replies'] + 1 : "—") ."</td>
|
||||
$tccell1>". ($data['real']) ."</td>
|
||||
$tccell2><b>". ($data['offset'] !== null ? $data['offset'] : "—") ."</b></td>
|
||||
$tccell1>$status</td>
|
||||
</tr>";
|
||||
|
||||
} else {
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,4 +106,3 @@
|
||||
$footer
|
||||
";
|
||||
printtimedif($startingtime);
|
||||
?>
|
||||
|
@ -58,7 +58,7 @@
|
||||
|
||||
|
||||
|
||||
$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 = "<font color=#ff8888>Broken thread</font>";
|
||||
} else {
|
||||
|
||||
@ -105,4 +105,3 @@
|
||||
$footer
|
||||
";
|
||||
printtimedif($startingtime);
|
||||
?>
|
||||
|
73
css/base.css
73
css/base.css
@ -1,33 +1,56 @@
|
||||
textarea,input,select {
|
||||
border: 1px solid #000;
|
||||
background: #000;
|
||||
color: #EEE;
|
||||
font: 10pt monospace;
|
||||
/* Global CSS styles across every theme */
|
||||
|
||||
/* 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;
|
||||
}
|
||||
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; }
|
||||
|
||||
/* Make all links bold and not underlined by default */
|
||||
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; }
|
||||
/* Mostly legacy thing from when IE had a blue border around link images */
|
||||
img { border:none; }
|
||||
.center {text-align:center}
|
||||
.right {text-align:right}
|
||||
|
||||
code { overflow: auto; width: 100%; white-space: pre; display: block; }
|
||||
code br { display: none; }
|
||||
/* Make code blocks scroll instead of stretching the page */
|
||||
code {
|
||||
overflow: auto;
|
||||
width: 100%;
|
||||
white-space: pre;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* "Fix" for auto-generated <br> tags in <code> and <pre> 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%;
|
||||
}
|
||||
|
33
css/basics.css
Normal file
33
css/basics.css
Normal file
@ -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;}
|
BIN
images/photobucket.png
Normal file
BIN
images/photobucket.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
@ -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";
|
||||
}
|
||||
|
||||
@ -328,7 +328,8 @@ function timeunits($sec){
|
||||
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<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("'<script(.*?)</script>'si",'',$p);
|
||||
$p=preg_replace("'<script'si",'',$p);
|
||||
$p=preg_replace("'\b\s(on[^=]*?=.*)\b'si",'',$p);
|
||||
if ($temp != $p) {
|
||||
nuke_js($temp, $p);
|
||||
}
|
||||
} else {
|
||||
|
||||
$p=preg_replace("'onload'si",'onl<z>oad',$p);
|
||||
@ -1227,10 +1217,6 @@ function dofilters($p){
|
||||
$p=preg_replace("'onmouseout'si",'onmou<z>seout',$p);
|
||||
$p=preg_replace("'onmouseover'si",'onmo<z>useover',$p);
|
||||
$p=preg_replace("'onmouseup'si",'onmou<z>seup',$p);
|
||||
|
||||
if ($temp != $p) {
|
||||
nuke_js($temp, $p);
|
||||
}
|
||||
}
|
||||
|
||||
//$p=preg_replace("'<object(.*?)</object>'si","",$p);
|
||||
@ -1277,6 +1263,9 @@ function dofilters($p){
|
||||
$p=str_replace("-->", '--></font>', $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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,7 +73,7 @@
|
||||
// special "null" scheme.
|
||||
$css = "";
|
||||
} elseif (isset($schemetype) && $schemetype == 1) {
|
||||
$css = "<link rel='stylesheet' href='/css/base.css' type='text/css'><link rel='stylesheet' type='text/css' href='/css/$schemefile.css'>";
|
||||
$css = "<link rel='stylesheet' href='/css/basics.css' type='text/css'><link rel='stylesheet' type='text/css' href='/css/$schemefile.css'>";
|
||||
// possibly causes issue #19 - not sure why this was here
|
||||
// likely irrelevant after addition of custom date formats
|
||||
// (remove this later)
|
||||
@ -86,30 +86,12 @@
|
||||
$linkcolor = "FFF";
|
||||
} else {
|
||||
$css="
|
||||
<link rel='stylesheet' href='/css/base.css' type='text/css'>
|
||||
<style type='text/css'>
|
||||
html, img { image-rendering: -moz-crisp-edges; }
|
||||
/*
|
||||
body {
|
||||
cursor: url('images/ikachanpointer.png'), default;
|
||||
}
|
||||
a:link {
|
||||
cursor: url('images/ikachanpointer2.png'), pointer;
|
||||
}
|
||||
*/ a:link,a:visited,a:active,a:hover{text-decoration:none;font-weight:bold;}
|
||||
a {
|
||||
color: #$linkcolor;
|
||||
}
|
||||
a:visited {
|
||||
color: #$linkcolor2;
|
||||
}
|
||||
a:active {
|
||||
color: #$linkcolor3;
|
||||
}
|
||||
a:hover {
|
||||
color: #$linkcolor4;
|
||||
}
|
||||
img { border:none; }
|
||||
pre br { display: none; }
|
||||
a { color: #$linkcolor; }
|
||||
a:visited { color: #$linkcolor2; }
|
||||
a:active { color: #$linkcolor3; }
|
||||
a:hover { color: #$linkcolor4; }
|
||||
body {
|
||||
scrollbar-face-color: #$scr3;
|
||||
scrollbar-track-color: #$scr7;
|
||||
@ -132,26 +114,12 @@
|
||||
.tdbg1 {background:#$tablebg1}
|
||||
.tdbg2 {background:#$tablebg2}
|
||||
.tdbgc {background:#$categorybg}
|
||||
.tdbgh {background:#$tableheadbg;}
|
||||
.center {text-align:center}
|
||||
.right {text-align:right}
|
||||
.tdbgh {background:#$tableheadbg; color:$tableheadtext}
|
||||
.table {empty-cells: show; width: $tablewidth;
|
||||
border-top: #$tableborder 1px solid;
|
||||
border-left: #$tableborder 1px solid;}
|
||||
td.tbl {border-right: #$tableborder 1px solid;
|
||||
border-bottom: #$tableborder 1px solid}
|
||||
code {
|
||||
overflow: auto;
|
||||
width: 100%;
|
||||
white-space: pre;
|
||||
display: block;
|
||||
}
|
||||
code br { display: none; }
|
||||
input[type=radio] { color: black; background: white; }
|
||||
|
||||
.pstspl1 {opacity:0;}
|
||||
.pstspl1:hover {opacity:1;}
|
||||
.pstspl2 {background:#000;color:#FFF;display:block;}
|
||||
";
|
||||
}
|
||||
|
||||
@ -376,15 +344,14 @@
|
||||
if (filter_bool($meta['noindex']))
|
||||
$metatag .= "<meta name=\"robots\" content=\"noindex,follow\" />";
|
||||
|
||||
if (filter_bool($meta['description']))
|
||||
if (isset($meta['description']))
|
||||
$metatag .= "<meta name=\"description\" content=\"{$meta['description']}\" />";
|
||||
|
||||
if (filter_bool($x_hacks['smallbrowse']) and false) {
|
||||
$css = "";
|
||||
$css = "<link rel='stylesheet' href='/mobile.css'>";
|
||||
if (isset($meta['canonical'])) {
|
||||
$metatag .= "<link rel='canonical' href='{$meta['canonical']}'>";
|
||||
}
|
||||
|
||||
$header1="<html><head><meta http-equiv='Content-type' content='text/html; charset=utf-8'><title>$windowtitle</title>
|
||||
$header1="<html><head><meta http-equiv='Content-type' content='text/html; charset=utf-8'><meta name='viewport' content='width=device-width, initial-scale=1'><title>$windowtitle</title>
|
||||
$metatag
|
||||
<link rel=\"shortcut icon\" href=\"/favicon". (!$x_hacks['host'] ? rand(1,8) ."" : "" ) .".ico\" type=\"image/x-icon\">
|
||||
$css
|
||||
@ -540,6 +507,3 @@ piwikTracker.enableLinkTracking();
|
||||
<br>
|
||||
<br>E-mail: xkeeper@gmail.com
|
||||
$tblend$footer");
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
<?php
|
||||
// mobile layout stuff
|
||||
|
||||
print $body;
|
||||
?>
|
@ -1,4 +1,10 @@
|
||||
<?php
|
||||
|
||||
if (!function_exists("mysql_connect")) {
|
||||
// probably php 7, load shim for it
|
||||
require_once("lib/mysql_compat.php");
|
||||
}
|
||||
|
||||
class mysql {
|
||||
// a 'backport' of my 'static' class in not-as-static form
|
||||
// the statistics remain static so they're global just in case this gets used for >1 connection
|
||||
@ -22,7 +28,7 @@
|
||||
$this->connection = (($persist) ? mysql_pconnect($host,$user,$pass) : mysql_connect($host,$user,$pass));
|
||||
$t = microtime(true)-$start;
|
||||
$this->id = ++self::$connection_count;
|
||||
$this->set_character_encoding("utf8");
|
||||
$this->set_character_encoding("utf8mb4");
|
||||
|
||||
if (self::$debug_on) {
|
||||
$b = self::getbacktrace();
|
||||
|
834
lib/mysql_compat.php
Normal file
834
lib/mysql_compat.php
Normal file
@ -0,0 +1,834 @@
|
||||
<?php
|
||||
/**
|
||||
* php7-mysql-shim
|
||||
*
|
||||
* @author Davey Shafik <me@daveyshafik.com>
|
||||
* @copyright Copyright (c) 2017 Davey Shafik
|
||||
* @license MIT License
|
||||
* @link https://github.com/dshafik/php7-mysql-shim
|
||||
*/
|
||||
|
||||
/**
|
||||
* A drop-in replacement for ext/mysql in PHP 7+ using ext/mysqli instead
|
||||
*
|
||||
* This library is meant to be a _stop-gap_. It will be slower than using
|
||||
* the native functions directly.
|
||||
*
|
||||
* You should switch to ext/pdo_mysql or ext/mysqli, and migrate to prepared
|
||||
* queries (@see http://php.net/manual/en/pdo.prepared-statements.php) to
|
||||
* ensure you are securely interacting with your database.
|
||||
*/
|
||||
namespace {
|
||||
|
||||
if (!extension_loaded('mysql')) {
|
||||
if (!extension_loaded('mysqli')) {
|
||||
trigger_error('php7-mysql-shim: ext/mysqli is required', E_USER_ERROR);
|
||||
}
|
||||
|
||||
define('MYSQL_ASSOC', 1);
|
||||
define('MYSQL_NUM', 2);
|
||||
define('MYSQL_BOTH', 3);
|
||||
define('MYSQL_CLIENT_COMPRESS', 32);
|
||||
define('MYSQL_CLIENT_SSL', 2048);
|
||||
define('MYSQL_CLIENT_INTERACTIVE', 1024);
|
||||
define('MYSQL_CLIENT_IGNORE_SPACE', 256);
|
||||
|
||||
function mysql_connect(
|
||||
$hostname = null,
|
||||
$username = null,
|
||||
$password = null,
|
||||
$new = false,
|
||||
$flags = 0
|
||||
) {
|
||||
if ($new !== false) {
|
||||
trigger_error('Argument $new is no longer supported in PHP > 7', E_USER_WARNING);
|
||||
}
|
||||
if (null === $hostname) {
|
||||
$hostname = ini_get('mysqli.default_host') ?: null;
|
||||
}
|
||||
if (null === $username) {
|
||||
$username = ini_get('mysqli.default_user') ?: null;
|
||||
}
|
||||
if (null === $password) {
|
||||
$password = ini_get('mysqli.default_pw') ?: null;
|
||||
}
|
||||
|
||||
$hash = sha1($hostname . $username . $flags);
|
||||
/* persistent connections start with p: */
|
||||
if ($hostname{1} !== ':' && isset(\Dshafik\MySQL::$connections[$hash])) {
|
||||
\Dshafik\MySQL::$last_connection = \Dshafik\MySQL::$connections[$hash]['conn'];
|
||||
\Dshafik\MySQL::$connections[$hash]['refcount'] += 1;
|
||||
return \Dshafik\MySQL::$connections[$hash]['conn'];
|
||||
}
|
||||
|
||||
/* No flags, means we can use mysqli_connect() */
|
||||
if ($flags === 0) {
|
||||
$conn = mysqli_connect($hostname, $username, $password);
|
||||
if (!$conn instanceof mysqli) {
|
||||
return false;
|
||||
}
|
||||
\Dshafik\MySQL::$last_connection = $conn;
|
||||
$conn->hash = $hash;
|
||||
\Dshafik\MySQL::$connections[$hash] = array('refcount' => 1, 'conn' => $conn);
|
||||
|
||||
return $conn;
|
||||
}
|
||||
|
||||
/* Flags means we need to use mysqli_real_connect() instead, and handle exceptions */
|
||||
try {
|
||||
\Dshafik\MySQL::$last_connection = $conn = mysqli_init();
|
||||
|
||||
mysqli_real_connect(
|
||||
$conn,
|
||||
$hostname,
|
||||
$username,
|
||||
$password,
|
||||
'',
|
||||
null,
|
||||
'',
|
||||
$flags
|
||||
);
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
// PHPUnit turns the warning from mysqli_real_connect into an exception, so this never runs
|
||||
if ($conn === false) {
|
||||
return false;
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
$conn->hash = $hash;
|
||||
\Dshafik\MySQL::$connections[$hash] = array('refcount' => 1, 'conn' => $conn);
|
||||
|
||||
return $conn;
|
||||
} catch (\Throwable $e) {
|
||||
trigger_error($e->getMessage(), E_USER_WARNING);
|
||||
// @codeCoverageIgnoreStart
|
||||
// PHPUnit turns the warning into an exception, so this never runs
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
}
|
||||
|
||||
function mysql_pconnect(
|
||||
$hostname = null,
|
||||
$username = null,
|
||||
$password = null,
|
||||
$flags = 0
|
||||
) {
|
||||
$hostname = 'p:' . $hostname;
|
||||
return mysql_connect($hostname, $username, $password, false, $flags);
|
||||
}
|
||||
|
||||
function mysql_close(\mysqli $link = null)
|
||||
{
|
||||
$isDefault = ($link === null);
|
||||
|
||||
$link = \Dshafik\MySQL::getConnection($link, __FUNCTION__);
|
||||
if ($link === null) {
|
||||
// @codeCoverageIgnoreStart
|
||||
// PHPUnit Warning -> Exception
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
if (isset(\Dshafik\MySQL::$connections[$link->hash])) {
|
||||
\Dshafik\MySQL::$connections[$link->hash]['refcount'] -= 1;
|
||||
}
|
||||
|
||||
$return = true;
|
||||
if (\Dshafik\MySQL::$connections[$link->hash]['refcount'] === 0) {
|
||||
$return = mysqli_close($link);
|
||||
unset(\Dshafik\MySQL::$connections[$link->hash]);
|
||||
}
|
||||
|
||||
if ($isDefault) {
|
||||
Dshafik\MySQL::$last_connection = null;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
function mysql_select_db($databaseName, \mysqli $link = null)
|
||||
{
|
||||
$link = \Dshafik\MySQL::getConnection($link);
|
||||
|
||||
return mysqli_query(
|
||||
$link,
|
||||
'USE `' . mysqli_real_escape_string($link, $databaseName) . '`'
|
||||
) !== false;
|
||||
}
|
||||
|
||||
function mysql_query($query, \mysqli $link = null)
|
||||
{
|
||||
return mysqli_query(\Dshafik\MySQL::getConnection($link), $query);
|
||||
}
|
||||
|
||||
function mysql_unbuffered_query($query, \mysqli $link = null)
|
||||
{
|
||||
$link = \Dshafik\MySQL::getConnection($link);
|
||||
if (mysqli_real_query($link, $query)) {
|
||||
return mysqli_use_result($link);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function mysql_db_query($databaseName, $query, \mysqli $link = null)
|
||||
{
|
||||
if (mysql_select_db($databaseName, $link)) {
|
||||
return mysql_query($query, $link);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function mysql_list_dbs(\mysqli $link = null)
|
||||
{
|
||||
return mysql_query('SHOW DATABASES', $link);
|
||||
}
|
||||
|
||||
function mysql_list_tables($databaseName, \mysqli $link = null)
|
||||
{
|
||||
$link = \Dshafik\MySQL::getConnection($link);
|
||||
$query = sprintf(
|
||||
'SHOW TABLES FROM `%s`',
|
||||
mysql_real_escape_string($databaseName, $link)
|
||||
);
|
||||
return mysql_query($query, $link);
|
||||
}
|
||||
|
||||
function mysql_list_fields($databaseName, $tableName, \mysqli $link = null)
|
||||
{
|
||||
$link = \Dshafik\MySQL::getConnection($link);
|
||||
|
||||
$query = sprintf(
|
||||
'SHOW COLUMNS FROM `%s`.`%s`',
|
||||
mysqli_real_escape_string($link, $databaseName),
|
||||
mysqli_real_escape_string($link, $tableName)
|
||||
);
|
||||
|
||||
$result = mysql_query($query, $link);
|
||||
|
||||
if ($result instanceof \mysqli_result) {
|
||||
$result->table = $tableName;
|
||||
return $result;
|
||||
}
|
||||
|
||||
trigger_error('mysql_list_fields(): Unable to save MySQL query result', E_USER_WARNING);
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
function mysql_list_processes(\mysqli $link = null)
|
||||
{
|
||||
return mysql_query('SHOW PROCESSLIST', $link);
|
||||
}
|
||||
|
||||
function mysql_error(\mysqli $link = null)
|
||||
{
|
||||
return mysqli_error(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_errno(\mysqli $link = null)
|
||||
{
|
||||
return mysqli_errno(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_affected_rows(\mysqli $link = null)
|
||||
{
|
||||
return mysqli_affected_rows(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_insert_id($link = null) /*|*/
|
||||
{
|
||||
return mysqli_insert_id(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_result($result, $row, $field = 0)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
if (!mysqli_data_seek($result, $row)) {
|
||||
trigger_error(
|
||||
sprintf(
|
||||
'mysql_result(): Unable to jump to row %d on MySQL result index %s',
|
||||
$row,
|
||||
spl_object_hash($result)
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
$found = true;
|
||||
if (strpos($field, '.') !== false) {
|
||||
list($table, $name) = explode('.', $field);
|
||||
$i = 0;
|
||||
$found = false;
|
||||
mysqli_field_seek($result, 0);
|
||||
while ($column = mysqli_fetch_field($result)) {
|
||||
if ($column->table === $table && $column->name === $name) {
|
||||
$field = $i;
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$row = mysql_fetch_array($result);
|
||||
if ($found && array_key_exists($field, $row)) {
|
||||
return $row[$field];
|
||||
}
|
||||
|
||||
trigger_error(
|
||||
sprintf(
|
||||
'%s(): %s not found in MySQL result index %s',
|
||||
__FUNCTION__,
|
||||
$field,
|
||||
spl_object_hash($result)
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
function mysql_num_rows($result)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
$previous = error_reporting(0);
|
||||
$rows = mysqli_num_rows($result);
|
||||
error_reporting($previous);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function mysql_num_fields($result)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return mysqli_num_fields($result);
|
||||
}
|
||||
|
||||
function mysql_fetch_row($result)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return mysqli_fetch_row($result) ?: false;
|
||||
}
|
||||
|
||||
function mysql_fetch_array($result, $resultType = MYSQL_BOTH)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return mysqli_fetch_array($result, $resultType) ?: false;
|
||||
}
|
||||
|
||||
function mysql_fetch_assoc($result) /* : array|null */
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
return mysqli_fetch_assoc($result) ?: false;
|
||||
}
|
||||
|
||||
function mysql_fetch_object($result, $class = null, array $params = array()) /* : object|null */
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
if ($class === null) {
|
||||
$object = mysqli_fetch_object($result);
|
||||
} else {
|
||||
$object = mysqli_fetch_object($result, $class, $params);
|
||||
}
|
||||
|
||||
return $object ?: false;
|
||||
}
|
||||
|
||||
function mysql_data_seek($result, $offset)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return mysqli_data_seek($result, $offset);
|
||||
}
|
||||
|
||||
function mysql_fetch_lengths($result) /* : array|*/
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return mysqli_fetch_lengths($result);
|
||||
}
|
||||
|
||||
function mysql_fetch_field($result) /* : object|*/
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return mysqli_fetch_field($result);
|
||||
}
|
||||
|
||||
function mysql_field_seek($result, $field)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return mysqli_field_seek($result, $field);
|
||||
}
|
||||
|
||||
function mysql_free_result($result)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return mysqli_free_result($result);
|
||||
}
|
||||
|
||||
function mysql_field_name($result, $field)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return \Dshafik\MySQL::mysqlFieldInfo($result, $field, 'name');
|
||||
}
|
||||
|
||||
function mysql_field_table($result, $field)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return \Dshafik\MySQL::mysqlFieldInfo($result, $field, 'table');
|
||||
}
|
||||
|
||||
function mysql_field_len($result, $field)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return \Dshafik\MySQL::mysqlFieldInfo($result, $field, 'length');
|
||||
}
|
||||
|
||||
function mysql_field_type($result, $field)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return \Dshafik\MySQL::mysqlFieldInfo($result, $field, 'type');
|
||||
}
|
||||
|
||||
function mysql_field_flags($result, $field)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
return \Dshafik\MySQL::mysqlFieldInfo($result, $field, 'flags');
|
||||
}
|
||||
|
||||
function mysql_escape_string($unescapedString)
|
||||
{
|
||||
if (\Dshafik\MySQL::$last_connection === null) {
|
||||
trigger_error(
|
||||
sprintf(
|
||||
'%s() is insecure; use mysql_real_escape_string() instead!',
|
||||
__FUNCTION__
|
||||
),
|
||||
E_USER_NOTICE
|
||||
);
|
||||
|
||||
return \Dshafik\MySQL::escapeString($unescapedString);
|
||||
}
|
||||
return mysql_real_escape_string($unescapedString, null);
|
||||
}
|
||||
|
||||
function mysql_real_escape_string($unescapedString, \mysqli $link = null)
|
||||
{
|
||||
return mysqli_escape_string(\Dshafik\MySQL::getConnection($link), $unescapedString);
|
||||
}
|
||||
|
||||
function mysql_stat(\mysqli $link = null)
|
||||
{
|
||||
return mysqli_stat(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_thread_id(\mysqli $link = null)
|
||||
{
|
||||
return mysqli_thread_id(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_client_encoding(\mysqli $link = null)
|
||||
{
|
||||
return mysqli_character_set_name(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_ping(\mysqli $link = null)
|
||||
{
|
||||
return mysqli_ping(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_get_client_info(\mysqli $link = null)
|
||||
{
|
||||
return mysqli_get_client_info(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_get_host_info(\mysqli $link = null)
|
||||
{
|
||||
return mysqli_get_host_info(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_get_proto_info(\mysqli $link = null)
|
||||
{
|
||||
return mysqli_get_proto_info(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_get_server_info(\mysqli $link = null)
|
||||
{
|
||||
return mysqli_get_server_info(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_info(\mysqli $link = null)
|
||||
{
|
||||
return mysqli_info(\Dshafik\MySQL::getConnection($link));
|
||||
}
|
||||
|
||||
function mysql_set_charset($charset, \mysqli $link = null)
|
||||
{
|
||||
return mysqli_set_charset(\Dshafik\MySQL::getConnection($link), $charset);
|
||||
}
|
||||
|
||||
function mysql_db_name($result, $row, $field = 0)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
// Alias as per https://github.com/php/php-src/blob/PHP-5.6/ext/mysql/php_mysql.c#L319
|
||||
return mysql_result($result, $row, $field);
|
||||
}
|
||||
|
||||
function mysql_tablename($result, $row)
|
||||
{
|
||||
if (!\Dshafik\MySQL::checkValidResult($result, __FUNCTION__)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
// Alias as per http://lxr.php.net/xref/PHP_5_6/ext/mysql/php_mysql.c#321
|
||||
return mysql_result($result, $row, 'Table');
|
||||
}
|
||||
|
||||
/* Aliases */
|
||||
|
||||
function mysql_fieldname($result, $field)
|
||||
{
|
||||
return mysql_field_name($result, $field);
|
||||
}
|
||||
|
||||
function mysql_fieldtable($result, $field)
|
||||
{
|
||||
return mysql_field_table($result, $field);
|
||||
}
|
||||
|
||||
function mysql_fieldlen($result, $field)
|
||||
{
|
||||
return mysql_field_len($result, $field);
|
||||
}
|
||||
|
||||
function mysql_fieldtype($result, $field)
|
||||
{
|
||||
return mysql_field_type($result, $field);
|
||||
}
|
||||
|
||||
function mysql_fieldflags($result, $field)
|
||||
{
|
||||
return mysql_field_flags($result, $field);
|
||||
}
|
||||
|
||||
function mysql_selectdb($databaseName, $link = null)
|
||||
{
|
||||
return mysql_select_db($databaseName, $link);
|
||||
}
|
||||
|
||||
function mysql_freeresult($result)
|
||||
{
|
||||
return mysql_free_result($result);
|
||||
}
|
||||
|
||||
function mysql_numfields($result)
|
||||
{
|
||||
return mysql_num_fields($result);
|
||||
}
|
||||
|
||||
function mysql_numrows($result)
|
||||
{
|
||||
return mysql_num_rows($result);
|
||||
}
|
||||
|
||||
function mysql_listdbs($link)
|
||||
{
|
||||
return mysql_list_dbs($link);
|
||||
}
|
||||
|
||||
function mysql_listtables($databaseName, $link = null)
|
||||
{
|
||||
return mysql_list_tables($databaseName, $link);
|
||||
}
|
||||
|
||||
function mysql_listfields($databaseName, $tableName, $link = null)
|
||||
{
|
||||
return mysql_list_fields($databaseName, $tableName, $link);
|
||||
}
|
||||
|
||||
function mysql_dbname($result, $row, $field = 0)
|
||||
{
|
||||
return mysql_db_name($result, $row, $field);
|
||||
}
|
||||
|
||||
function mysql_table_name($result, $row)
|
||||
{
|
||||
return mysql_tablename($result, $row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Dshafik {
|
||||
|
||||
class MySQL
|
||||
{
|
||||
public static $last_connection = null;
|
||||
public static $connections = array();
|
||||
|
||||
public static function getConnection($link = null, $func = null)
|
||||
{
|
||||
if ($link !== null) {
|
||||
return $link;
|
||||
}
|
||||
|
||||
if (static::$last_connection === null) {
|
||||
$err = 'A link to the server could not be established';
|
||||
if ($func !== null) {
|
||||
$err = $func . '(): no MySQL-Link resource supplied';
|
||||
}
|
||||
trigger_error($err, E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
return static::$last_connection;
|
||||
}
|
||||
|
||||
public static function mysqlFieldInfo(\mysqli_result $result, $field, $what)
|
||||
{
|
||||
try {
|
||||
$field = mysqli_fetch_field_direct($result, $field);
|
||||
} catch (\Exception $e) {
|
||||
trigger_error(
|
||||
sprintf(
|
||||
'mysql_field_%s(): Field %d is invalid for MySQL result index %s',
|
||||
($what !== 'length') ? $what : 'len',
|
||||
$field,
|
||||
spl_object_hash($result)
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
// @codeCoverageIgnoreStart
|
||||
// PHPUnit turns the warning into an exception, so this never runs
|
||||
return false;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
if ($what === 'type') {
|
||||
return static::getFieldType($field->type);
|
||||
}
|
||||
|
||||
if ($what === 'flags') {
|
||||
return static::getFieldFlags($field->flags);
|
||||
}
|
||||
|
||||
if (isset($field->{$what})) {
|
||||
return $field->{$what};
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function checkValidResult($result, $function)
|
||||
{
|
||||
if (!($result instanceof \mysqli_result)) {
|
||||
if ($function !== 'mysql_fetch_object') {
|
||||
trigger_error(
|
||||
$function . '() expects parameter 1 to be resource, ' . strtolower(gettype($result)) . ' given',
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
if ($function === 'mysql_fetch_object') {
|
||||
trigger_error(
|
||||
$function . '(): supplied argument is not a valid MySQL result resource',
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function escapeString($unescapedString)
|
||||
{
|
||||
$escapedString = '';
|
||||
for ($i = 0, $max = strlen($unescapedString); $i < $max; $i++) {
|
||||
$escapedString .= self::escapeChar($unescapedString{$i});
|
||||
}
|
||||
|
||||
return $escapedString;
|
||||
}
|
||||
|
||||
protected static function getFieldFlags($what)
|
||||
{
|
||||
// Order of flags taken from http://lxr.php.net/xref/PHP_5_6/ext/mysql/php_mysql.c#2507
|
||||
$flags = array(
|
||||
MYSQLI_NOT_NULL_FLAG => 'not_null',
|
||||
MYSQLI_PRI_KEY_FLAG => 'primary_key',
|
||||
MYSQLI_UNIQUE_KEY_FLAG => 'unique_key',
|
||||
MYSQLI_MULTIPLE_KEY_FLAG => 'multiple_key',
|
||||
MYSQLI_BLOB_FLAG => 'blob',
|
||||
MYSQLI_UNSIGNED_FLAG => 'unsigned',
|
||||
MYSQLI_ZEROFILL_FLAG => 'zerofill',
|
||||
MYSQLI_BINARY_FLAG => 'binary',
|
||||
MYSQLI_ENUM_FLAG => 'enum',
|
||||
MYSQLI_SET_FLAG => 'set',
|
||||
MYSQLI_AUTO_INCREMENT_FLAG => 'auto_increment',
|
||||
MYSQLI_TIMESTAMP_FLAG => 'timestamp',
|
||||
);
|
||||
|
||||
$fieldFlags = array();
|
||||
foreach ($flags as $flag => $value) {
|
||||
if ($what & $flag) {
|
||||
$fieldFlags[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return implode(' ', $fieldFlags);
|
||||
}
|
||||
|
||||
protected static function getFieldType($what)
|
||||
{
|
||||
$types = array(
|
||||
MYSQLI_TYPE_STRING => 'string',
|
||||
MYSQLI_TYPE_VAR_STRING => 'string',
|
||||
MYSQLI_TYPE_ENUM => 'string',
|
||||
MYSQLI_TYPE_SET => 'string',
|
||||
|
||||
MYSQLI_TYPE_LONG => 'int',
|
||||
MYSQLI_TYPE_TINY => 'int',
|
||||
MYSQLI_TYPE_SHORT => 'int',
|
||||
MYSQLI_TYPE_INT24 => 'int',
|
||||
MYSQLI_TYPE_CHAR => 'int',
|
||||
MYSQLI_TYPE_LONGLONG => 'int',
|
||||
|
||||
MYSQLI_TYPE_DECIMAL => 'real',
|
||||
MYSQLI_TYPE_FLOAT => 'real',
|
||||
MYSQLI_TYPE_DOUBLE => 'real',
|
||||
MYSQLI_TYPE_NEWDECIMAL => 'real',
|
||||
|
||||
MYSQLI_TYPE_TINY_BLOB => 'blob',
|
||||
MYSQLI_TYPE_MEDIUM_BLOB => 'blob',
|
||||
MYSQLI_TYPE_LONG_BLOB => 'blob',
|
||||
MYSQLI_TYPE_BLOB => 'blob',
|
||||
|
||||
MYSQLI_TYPE_NEWDATE => 'date',
|
||||
MYSQLI_TYPE_DATE => 'date',
|
||||
MYSQLI_TYPE_TIME => 'time',
|
||||
MYSQLI_TYPE_YEAR => 'year',
|
||||
MYSQLI_TYPE_DATETIME => 'datetime',
|
||||
MYSQLI_TYPE_TIMESTAMP => 'timestamp',
|
||||
|
||||
MYSQLI_TYPE_NULL => 'null',
|
||||
|
||||
MYSQLI_TYPE_GEOMETRY => 'geometry',
|
||||
);
|
||||
|
||||
return isset($types[$what]) ? $types[$what] : 'unknown';
|
||||
}
|
||||
|
||||
protected static function escapeChar($char)
|
||||
{
|
||||
switch ($char) {
|
||||
case "\0":
|
||||
$esc = "\\0";
|
||||
break;
|
||||
case "\n":
|
||||
$esc = "\\n";
|
||||
break;
|
||||
case "\r":
|
||||
$esc = "\\r";
|
||||
break;
|
||||
case '\\':
|
||||
case '\'':
|
||||
case '"':
|
||||
$esc = "\\{$char}";
|
||||
break;
|
||||
case "\032":
|
||||
$esc = "\\Z";
|
||||
break;
|
||||
default:
|
||||
$esc = $char;
|
||||
break;
|
||||
}
|
||||
|
||||
return $esc;
|
||||
}
|
||||
}
|
||||
}
|
@ -19,14 +19,13 @@
|
||||
|
||||
if($post['picture'] || ($post['moodid'] && $post['moodurl'])){
|
||||
$post['picture'] = str_replace('>','%3E',$post['picture']);
|
||||
$set['userpic'] = "<img src=\"{$post['picture']}\">";
|
||||
$set['userpic'] = "<img class='avatar' src=\"{$post['picture']}\">";
|
||||
$set['picture'] = $post['picture'];
|
||||
|
||||
if ($post['moodid'] && $post['moodurl']) {
|
||||
$set['userpic'] = "<img src=\"". str_replace(array('$', '>'), array($post['moodid'], '%3E'), $post['moodurl']) ."\">";
|
||||
$set['picture'] = str_replace(array('$', '>'), array($post['moodid'], '%3E'), $post['moodurl']);
|
||||
$set['userpic'] = "<img class='avatar' src=\"". str_replace(array('$', '>', '"'), array($post['moodid'], '%3E', '%22'), $post['moodurl']) ."\">";
|
||||
$set['picture'] = str_replace(array('$', '>', '"'), array($post['moodid'], '%3E', '%22'), $post['moodurl']);
|
||||
}
|
||||
// $userpicture="<img src=\"$user['picture']\" name=pic$p onload=sizelimit(pic$p,60,100)>";
|
||||
}
|
||||
|
||||
if($post['signtext']) {
|
||||
@ -38,7 +37,6 @@
|
||||
}
|
||||
|
||||
$post['text']=doreplace2($post['text'], $post['options']);
|
||||
// if (strpos($post['text'], "http://hyperhacker.no-ip.org/b/smilies/lolface.png") || strpos($post['text'], "images/smilies/roflx.gif")) $post['text'] = "<img src=images/smilies/roflx.gif><br><br><small>(Excessive post content hidden)</small>";
|
||||
|
||||
if (filter_int($post['editdate'])) {
|
||||
$post['edited'] = " (last edited by {$post['edited']} at ".date($dateformat,$post['editdate']+$tzoff).")";
|
||||
|
@ -1,4 +0,0 @@
|
||||
a:link,a:visited,a:active,a:hover{text-decoration:none;font-weight:bold}
|
||||
html { width: 480px; }
|
||||
body { background: #079; color: #fff;}
|
||||
|
43
schemes/spec-unfiction.php
Normal file
43
schemes/spec-unfiction.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
$boardtitle='<img src="http://i.imgur.com/gVDZW7x.png">';
|
||||
|
||||
$formcss=0;
|
||||
$inputborder='000000';
|
||||
|
||||
$bgimage='';
|
||||
$bgcolor='bbbbbb';
|
||||
$textcolor='000000';
|
||||
|
||||
$linkcolor ='660000';
|
||||
$linkcolor2='553333';
|
||||
$linkcolor3='990033';
|
||||
$linkcolor4='990033';
|
||||
|
||||
$tablebg1='aaaaaa';
|
||||
$tablebg2='999999';
|
||||
$categorybg='005020';
|
||||
$tableheadtext='ece6da;';
|
||||
$tableheadbg='4b3617';
|
||||
//$tableheadbg='b07f36';
|
||||
$tableborder='000000';
|
||||
|
||||
# Extra CSS included at the bottom of a page
|
||||
$css_extra = "
|
||||
textarea,input,select{
|
||||
border: 1px solid #a89;
|
||||
background: #fff;
|
||||
color: #000;
|
||||
font: 10pt $font;
|
||||
}
|
||||
input[type=\"radio\"], .radio {
|
||||
border: none;
|
||||
background: #fff0f8;
|
||||
color: #ffffff;
|
||||
font: 10pt $font;}
|
||||
.submit{
|
||||
border: #000 solid 2px;
|
||||
font: 10pt $font;}
|
||||
a {
|
||||
/* text-shadow: 0px 0px 3px #fff;
|
||||
*/ }
|
||||
";
|
@ -56,6 +56,9 @@
|
||||
}
|
||||
$numposts = $sql->resultq("SELECT COUNT(*) FROM `posts` WHERE `thread` = '{$id}' AND `id` < '{$pid}'");
|
||||
$page = floor($numposts / $ppp);
|
||||
|
||||
// Canonical page w/o ppp link (for bots)
|
||||
$meta['canonical'] = "thread.php?id=$id&page=$page";
|
||||
}
|
||||
|
||||
define('E_BADPOSTS', -1);
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
function userfields(){return 'posts,sex,powerlevel,birthday,aka';}
|
||||
// function userfields(){return 'posts,sex,powerlevel,birthday,aka';}
|
||||
function userfields(){
|
||||
return 'posts,sex,powerlevel,picture,aka';
|
||||
}
|
||||
|
||||
function postcode($post,$set){
|
||||
global $smallfont,$ip,$quote,$edit, $tblstart;
|
||||
@ -7,14 +10,15 @@
|
||||
$postnum=($post[num]?"$post[num]/":'').$post[posts];
|
||||
if($set[threadlink]) $threadlink=", in $set[threadlink]";
|
||||
return "$tblstart
|
||||
$set[tdbg]>
|
||||
$set[tdbg]><div class='mobile-avatar'>$set[userpic]</div>
|
||||
$set[userlink]<br>
|
||||
$smallfont Posts: $postnum</td>
|
||||
$set[tdbg] width=50% align=right>
|
||||
$smallfont Posted on $set[date]$threadlink
|
||||
<br>$quote$edit$ip
|
||||
<br>$quote$edit
|
||||
<br>$ip
|
||||
<tr>
|
||||
$set[tdbg] height=60 colspan=2 id=\"post". $post['id'] ."\">$post[headtext]$post[text]$post[signtext]$set[edited]</td></table>
|
||||
$set[tdbg] height=60 colspan=2 id=\"post". $post['id'] ."\">$post[headtext]$post[text]$post[signtext]$set[edited]</td></table><br>
|
||||
";
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user