Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../var/softacul.../fud
File: pdf.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* copyright : (C) 2001-2022 Advanced Internet Designs Inc.
[2] Fix | Delete
* email : forum@prohost.org
[3] Fix | Delete
* $Id$
[4] Fix | Delete
*
[5] Fix | Delete
* This program is free software; you can redistribute it and/or modify it
[6] Fix | Delete
* under the terms of the GNU General Public License as published by the
[7] Fix | Delete
* Free Software Foundation; version 2 of the License.
[8] Fix | Delete
**/
[9] Fix | Delete
[10] Fix | Delete
require('./GLOBALS.php');
[11] Fix | Delete
fud_use('err.inc');
[12] Fix | Delete
fud_use('fpdf.inc', true);
[13] Fix | Delete
[14] Fix | Delete
class fud_pdf extends FPDF
[15] Fix | Delete
{
[16] Fix | Delete
var $outlines = array();
[17] Fix | Delete
var $OutlineRoot;
[18] Fix | Delete
[19] Fix | Delete
/** Override Cell() function to render special characters (FPDF doesn't support UTF-8).
[20] Fix | Delete
* Details at http://fudforum.org/forum/index.php?t=msg&goto=167344
[21] Fix | Delete
*/
[22] Fix | Delete
function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
[23] Fix | Delete
{
[24] Fix | Delete
if (extension_loaded('iconv')) {
[25] Fix | Delete
$txt = iconv('utf-8', 'cp1252', $txt);
[26] Fix | Delete
}
[27] Fix | Delete
parent::Cell($w, $h, $txt, $border, $ln, $align, $fill, $link);
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
function begin_page($title)
[31] Fix | Delete
{
[32] Fix | Delete
$this->AddPage();
[33] Fix | Delete
$this->Bookmark($title);
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
function input_text($text)
[37] Fix | Delete
{
[38] Fix | Delete
$this->SetFont('helvetica', '', 12);
[39] Fix | Delete
$this->Write(5, $text);
[40] Fix | Delete
$this->Ln(5);
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
function draw_line()
[44] Fix | Delete
{
[45] Fix | Delete
$this->Line($this->lMargin, $this->y, ($this->w - $this->rMargin), $this->y);
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
function add_link($url, $caption=0)
[49] Fix | Delete
{
[50] Fix | Delete
$this->SetTextColor(0,0,255);
[51] Fix | Delete
$this->Write(5, $caption ? $caption : $url, $url);
[52] Fix | Delete
$this->SetTextColor(0);
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
function add_attacments($attch, $private=0)
[56] Fix | Delete
{
[57] Fix | Delete
$this->Ln(5);
[58] Fix | Delete
$this->SetFont('courier', '', 16);
[59] Fix | Delete
$this->Write(5, 'File Attachments');
[60] Fix | Delete
$this->Ln(5);
[61] Fix | Delete
[62] Fix | Delete
$this->draw_line();
[63] Fix | Delete
[64] Fix | Delete
$this->SetFont('', '', 14);
[65] Fix | Delete
[66] Fix | Delete
$i = 0;
[67] Fix | Delete
foreach ($attch as $a) {
[68] Fix | Delete
$this->Write(5, ++$i .') ');
[69] Fix | Delete
$this->add_link($GLOBALS['WWW_ROOT'] .'index.php?t=getfile&id='. $a['id'] . ($private ? '&private=1' : ''), $a['name']);
[70] Fix | Delete
$this->Write(5, ', downloaded '. $a['nd'] .' times');
[71] Fix | Delete
[72] Fix | Delete
// GIF, PNG and JPG images can be embedded.
[73] Fix | Delete
if (extension_loaded('gd') && preg_match('/\.gif$/i', $a['name'])) {
[74] Fix | Delete
$this->Ln(5);
[75] Fix | Delete
$this->Image($GLOBALS['WWW_ROOT'] .'index.php?t=getfile&id='. $a['id'] . ($private ? '&private=1' : ''), null, null, 0, 0, 'GIF');
[76] Fix | Delete
} elseif (preg_match('/\.png$/i', $a['name'])) {
[77] Fix | Delete
$this->Ln(5);
[78] Fix | Delete
$this->Image($GLOBALS['WWW_ROOT'] .'index.php?t=getfile&id='. $a['id'] . ($private ? '&private=1' : ''), null, null, 0, 0, 'PNG');
[79] Fix | Delete
} elseif (preg_match('/\.(jpg|jpeg)$/i', $a['name'])) {
[80] Fix | Delete
$this->Ln(5);
[81] Fix | Delete
$this->Image($GLOBALS['WWW_ROOT'] .'index.php?t=getfile&id='. $a['id'] . ($private ? '&private=1' : ''), null, null, 0, 0, 'JPEG');
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
$this->Ln(5);
[85] Fix | Delete
}
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
function add_poll($name, $opts, $ttl_votes)
[89] Fix | Delete
{
[90] Fix | Delete
$this->Ln(6);
[91] Fix | Delete
$this->SetFont('courier', '', 16);
[92] Fix | Delete
$this->Write(5, $name);
[93] Fix | Delete
$this->SetFont('', '', 14);
[94] Fix | Delete
$this->Write(5, '(total votes: '. $ttl_votes .')');
[95] Fix | Delete
$this->Ln(6);
[96] Fix | Delete
$this->draw_line();
[97] Fix | Delete
$this->Ln(5);
[98] Fix | Delete
[99] Fix | Delete
$p1 = ($this->w - $this->rMargin - $this->lMargin) * 0.6 / 100;
[100] Fix | Delete
[101] Fix | Delete
// Avoid /0 warnings and safe to do, since we'd be multiplying 0 since there are no votes,
[102] Fix | Delete
if (!$ttl_votes) {
[103] Fix | Delete
$ttl_votes = 1;
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
$this->SetFont('helvetica', '', 14);
[107] Fix | Delete
[108] Fix | Delete
foreach ($opts as $o) {
[109] Fix | Delete
$this->SetFillColor(52, 146, 40);
[110] Fix | Delete
$this->Cell((!$o['votes'] ? 1 : $p1 * (($o['votes'] / $ttl_votes) * 100)), 5, $o['name'] ."\t\t". $o['votes'] .'/('.round(($o['votes'] / $ttl_votes) * 100).'%)', 1, 0, '', 1);
[111] Fix | Delete
$this->Ln(5);
[112] Fix | Delete
}
[113] Fix | Delete
$this->SetFillColor();
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
function message_header($subject, $author, $date, $id, $th)
[117] Fix | Delete
{
[118] Fix | Delete
$this->Rect($this->lMargin, $this->y, (int)($this->w - $this->lMargin - $this->lMargin), 1, 'F');
[119] Fix | Delete
$this->Ln(2);
[120] Fix | Delete
[121] Fix | Delete
$this->SetFont('helvetica', '', 14);
[122] Fix | Delete
$this->Bookmark($subject, 1);
[123] Fix | Delete
$this->Write(5, 'Subject: '. $subject);
[124] Fix | Delete
$this->Ln(5);
[125] Fix | Delete
[126] Fix | Delete
$this->Write(5, 'Posted by ');
[127] Fix | Delete
$this->add_link($GLOBALS['WWW_ROOT'] .'index.php?t=usrinfo&id='. $author[0], $author[1]);
[128] Fix | Delete
$this->Write(5, ' on '. gmdate('D, d M Y H:i:s \G\M\T', $date));
[129] Fix | Delete
if ($th) {
[130] Fix | Delete
$this->SetFont('helvetica', '', 10);
[131] Fix | Delete
$this->Ln(5);
[132] Fix | Delete
$this->add_link($GLOBALS['WWW_ROOT'] .'index.php?t=rview&th='. $th .'&goto='. $id .'#msg_'. $id, 'View Forum Message');
[133] Fix | Delete
$this->Write(5, ' <> ');
[134] Fix | Delete
$this->add_link($GLOBALS['WWW_ROOT'] .'index.php?t=post&reply_to='. $id, 'Reply to Message');
[135] Fix | Delete
}
[136] Fix | Delete
$this->Ln(5);
[137] Fix | Delete
$this->draw_line();
[138] Fix | Delete
$this->Ln(3);
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
function end_message()
[142] Fix | Delete
{
[143] Fix | Delete
$this->Ln(3);
[144] Fix | Delete
$this->Rect($this->lMargin, $this->y, (int)($this->w - $this->lMargin - $this->lMargin), 1, 'F');
[145] Fix | Delete
$this->Ln(10);
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
function header()
[149] Fix | Delete
{
[150] Fix | Delete
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
function footer()
[154] Fix | Delete
{
[155] Fix | Delete
$this->SetFont('courier', '', 8);
[156] Fix | Delete
$this->Ln(10);
[157] Fix | Delete
$this->draw_line();
[158] Fix | Delete
$this->Write(5, 'Page '. $this->page .' of {fnb} ---- Generated from ');
[159] Fix | Delete
$this->add_link($GLOBALS['WWW_ROOT'] .'index.php', $GLOBALS['FORUM_TITLE']);
[160] Fix | Delete
// $this->Write(5, ' by FUDforum '. $GLOBALS['FORUM_VERSION']);
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
function Bookmark($txt, $level=0)
[164] Fix | Delete
{
[165] Fix | Delete
$this->outlines[] = array('t' => $txt, 'l' => $level, 'y' => $this->y, 'p' => $this->page);
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
function _putbookmarks()
[169] Fix | Delete
{
[170] Fix | Delete
if (empty($this->outlines)) {
[171] Fix | Delete
return;
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
$nb = count($this->outlines);
[175] Fix | Delete
[176] Fix | Delete
$lru = array();
[177] Fix | Delete
$level = 0;
[178] Fix | Delete
foreach ($this->outlines as $i => $o) {
[179] Fix | Delete
if($o['l'] > 0) {
[180] Fix | Delete
$parent = $lru[$o['l']-1];
[181] Fix | Delete
// Set parent and last pointers.
[182] Fix | Delete
$this->outlines[$i]['parent'] = $parent;
[183] Fix | Delete
$this->outlines[$parent]['last'] = $i;
[184] Fix | Delete
if ($o['l'] > $level) {
[185] Fix | Delete
// Level increasing: set first pointer.
[186] Fix | Delete
$this->outlines[$parent]['first'] = $i;
[187] Fix | Delete
}
[188] Fix | Delete
} else {
[189] Fix | Delete
$this->outlines[$i]['parent'] = $nb;
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
if($o['l'] <= $level && $i > 0) {
[193] Fix | Delete
// Set prev and next pointers.
[194] Fix | Delete
$prev = $lru[$o['l']];
[195] Fix | Delete
$this->outlines[$prev]['next'] = $i;
[196] Fix | Delete
$this->outlines[$i]['prev'] = $prev;
[197] Fix | Delete
}
[198] Fix | Delete
$lru[$o['l']] = $i;
[199] Fix | Delete
$level = $o['l'];
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
// Outline items.
[203] Fix | Delete
$n = $this->n + 1;
[204] Fix | Delete
foreach($this->outlines as $i => $o) {
[205] Fix | Delete
$this->_newobj();
[206] Fix | Delete
$this->_out('<</Title '. $this->_textstring($o['t']));
[207] Fix | Delete
$this->_out('/Parent '. ($n+$o['parent']).' 0 R');
[208] Fix | Delete
if(isset($o['prev']))
[209] Fix | Delete
$this->_out('/Prev '. ($n+$o['prev']).' 0 R');
[210] Fix | Delete
if(isset($o['next']))
[211] Fix | Delete
$this->_out('/Next '. ($n+$o['next']).' 0 R');
[212] Fix | Delete
if(isset($o['first']))
[213] Fix | Delete
$this->_out('/First '. ($n+$o['first']).' 0 R');
[214] Fix | Delete
if(isset($o['last']))
[215] Fix | Delete
$this->_out('/Last '. ($n+$o['last']).' 0 R');
[216] Fix | Delete
$this->_out(sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]', 1+2*$o['p'], ($this->h-$o['y'])*$this->k));
[217] Fix | Delete
$this->_out('/Count 0>>');
[218] Fix | Delete
$this->_out('endobj');
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
// Outline root.
[222] Fix | Delete
$this->_newobj();
[223] Fix | Delete
$this->OutlineRoot = $this->n;
[224] Fix | Delete
$this->_out('<</Type /Outlines /First '. $n .' 0 R');
[225] Fix | Delete
$this->_out('/Last '. ($n+$lru[0]) .' 0 R>>');
[226] Fix | Delete
$this->_out('endobj');
[227] Fix | Delete
}
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
/* main */
[231] Fix | Delete
/* Before we go on, we need to do some very basic activation checks. */
[232] Fix | Delete
if (!($FUD_OPT_1 & 1)) { // FORUM_ENABLED
[233] Fix | Delete
fud_use('errmsg.inc');
[234] Fix | Delete
exit_forum_disabled();
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
/* This potentially can be a longer form to generate. */
[238] Fix | Delete
@set_time_limit($PDF_MAX_CPU);
[239] Fix | Delete
[240] Fix | Delete
# define('fud_query_stats', 1);
[241] Fix | Delete
[242] Fix | Delete
class db { public static $db, $slave; }
[243] Fix | Delete
[244] Fix | Delete
if (empty(db::$db)) {
[245] Fix | Delete
[246] Fix | Delete
// Use MYSQLI_REPORT_OFF so we can check error codes manually.
[247] Fix | Delete
$driver = new mysqli_driver();
[248] Fix | Delete
$driver->report_mode = MYSQLI_REPORT_OFF;
[249] Fix | Delete
[250] Fix | Delete
if (substr($GLOBALS['DBHOST'], 0, 1) == ':') { // Socket connection.
[251] Fix | Delete
$socket = substr($GLOBALS['DBHOST'], 1);
[252] Fix | Delete
$GLOBALS['DBHOST'] = 'localhost';
[253] Fix | Delete
} else {
[254] Fix | Delete
$socket = NULL;
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
if ($GLOBALS['FUD_OPT_1'] & 256 && $socket == NULL && version_compare(PHP_VERSION, '5.3.0', '>=')) { // Enable pconnect for PHP 5.3+.
[258] Fix | Delete
$GLOBALS['DBHOST'] = 'p:'. $GLOBALS['DBHOST'];
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
db::$db = new mysqli($GLOBALS['DBHOST'], $GLOBALS['DBHOST_USER'], $GLOBALS['DBHOST_PASSWORD'], $GLOBALS['DBHOST_DBNAME'], NULL, $socket);
[262] Fix | Delete
if (mysqli_connect_errno()) {
[263] Fix | Delete
fud_sql_error_handler('Failed to establish database connection', 'MySQLi says: '. mysqli_connect_error(), mysqli_connect_errno(), '');
[264] Fix | Delete
}
[265] Fix | Delete
db::$db->set_charset('utf8');
[266] Fix | Delete
[267] Fix | Delete
/* Connect to slave, if specified. */
[268] Fix | Delete
if (!empty($GLOBALS['DBHOST_SLAVE_HOST']) && !$GLOBALS['is_post']) {
[269] Fix | Delete
db::$slave = new mysqli($GLOBALS['DBHOST'], $GLOBALS['DBHOST_USER'], $GLOBALS['DBHOST_PASSWORD'], $GLOBALS['DBHOST_DBNAME'], NULL, $socket);
[270] Fix | Delete
if (mysqli_connect_errno()) {
[271] Fix | Delete
fud_logerror('Unable to init SlaveDB, fallback to MasterDB: '. mysqli_connect_error(), 'sql_errors');
[272] Fix | Delete
} else {
[273] Fix | Delete
db::$db->set_charset('utf8');
[274] Fix | Delete
}
[275] Fix | Delete
}
[276] Fix | Delete
[277] Fix | Delete
define('__dbtype__', 'mysql');
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
function db_close()
[281] Fix | Delete
{
[282] Fix | Delete
db::$db->close();
[283] Fix | Delete
}
[284] Fix | Delete
[285] Fix | Delete
function db_version()
[286] Fix | Delete
{
[287] Fix | Delete
if (!defined('__FUD_SQL_VERSION__')) {
[288] Fix | Delete
$ver = q_singleval('SELECT VERSION()');
[289] Fix | Delete
define('__FUD_SQL_VERSION__', $ver);
[290] Fix | Delete
}
[291] Fix | Delete
return __FUD_SQL_VERSION__;
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
function db_lock($tables)
[295] Fix | Delete
{
[296] Fix | Delete
if (!empty($GLOBALS['__DB_INC_INTERNALS__']['db_locked'])) {
[297] Fix | Delete
fud_sql_error_handler('Recursive Lock', 'internal', 'internal', db_version());
[298] Fix | Delete
} else {
[299] Fix | Delete
q('LOCK TABLES '. $tables);
[300] Fix | Delete
$GLOBALS['__DB_INC_INTERNALS__']['db_locked'] = 1;
[301] Fix | Delete
}
[302] Fix | Delete
}
[303] Fix | Delete
[304] Fix | Delete
function db_unlock()
[305] Fix | Delete
{
[306] Fix | Delete
if (empty($GLOBALS['__DB_INC_INTERNALS__']['db_locked'])) {
[307] Fix | Delete
unset($GLOBALS['__DB_INC_INTERNALS__']['db_locked']);
[308] Fix | Delete
fud_sql_error_handler('DB_UNLOCK: no previous lock established', 'internal', 'internal', db_version());
[309] Fix | Delete
}
[310] Fix | Delete
[311] Fix | Delete
if (--$GLOBALS['__DB_INC_INTERNALS__']['db_locked'] < 0) {
[312] Fix | Delete
unset($GLOBALS['__DB_INC_INTERNALS__']['db_locked']);
[313] Fix | Delete
fud_sql_error_handler('DB_UNLOCK: unlock overcalled', 'internal', 'internal', db_version());
[314] Fix | Delete
}
[315] Fix | Delete
unset($GLOBALS['__DB_INC_INTERNALS__']['db_locked']);
[316] Fix | Delete
q('UNLOCK TABLES');
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
function db_locked()
[320] Fix | Delete
{
[321] Fix | Delete
return isset($GLOBALS['__DB_INC_INTERNALS__']['db_locked']);
[322] Fix | Delete
}
[323] Fix | Delete
[324] Fix | Delete
function db_affected()
[325] Fix | Delete
{
[326] Fix | Delete
return db::$db->affected_rows;
[327] Fix | Delete
}
[328] Fix | Delete
[329] Fix | Delete
function uq($query)
[330] Fix | Delete
{
[331] Fix | Delete
return q($query);
[332] Fix | Delete
}
[333] Fix | Delete
[334] Fix | Delete
if (!defined('fud_query_stats')) {
[335] Fix | Delete
function q($query)
[336] Fix | Delete
{
[337] Fix | Delete
// Assume master DB, route SELECT's to slave DB.
[338] Fix | Delete
// Force master if DB is locked (in transaction) or 'SELECT /* USE MASTER */'.
[339] Fix | Delete
$db = db::$db;
[340] Fix | Delete
if (!empty(db::$slave) && !db_locked() && !strncasecmp($query, 'SELECT', 6) && strncasecmp($query, 'SELECT /* USE MASTER */', 23)) {
[341] Fix | Delete
$db = db::$slave;
[342] Fix | Delete
}
[343] Fix | Delete
[344] Fix | Delete
$r = $db->query($query);
[345] Fix | Delete
if ($db->error) {
[346] Fix | Delete
fud_sql_error_handler($query, $db->error, $db->errno, db_version());
[347] Fix | Delete
}
[348] Fix | Delete
return $r;
[349] Fix | Delete
}
[350] Fix | Delete
} else {
[351] Fix | Delete
function q($query)
[352] Fix | Delete
{
[353] Fix | Delete
if (!isset($GLOBALS['__DB_INC_INTERNALS__']['query_count'])) {
[354] Fix | Delete
$GLOBALS['__DB_INC_INTERNALS__']['query_count'] = 1;
[355] Fix | Delete
} else {
[356] Fix | Delete
++$GLOBALS['__DB_INC_INTERNALS__']['query_count'];
[357] Fix | Delete
}
[358] Fix | Delete
[359] Fix | Delete
if (!isset($GLOBALS['__DB_INC_INTERNALS__']['total_sql_time'])) {
[360] Fix | Delete
$GLOBALS['__DB_INC_INTERNALS__']['total_sql_time'] = 0;
[361] Fix | Delete
}
[362] Fix | Delete
[363] Fix | Delete
// Assume master DB, route SELECT's to slave DB.
[364] Fix | Delete
// Force master if DB is locked (in transaction) or 'SELECT /* USE MASTER */'.
[365] Fix | Delete
$db = db::$db;
[366] Fix | Delete
if (!empty(db::$slave) && !db_locked() && !strncasecmp($query, 'SELECT', 6) && strncasecmp($query, 'SELECT /* USE MASTER */', 23)) {
[367] Fix | Delete
$db = db::$slave;
[368] Fix | Delete
}
[369] Fix | Delete
[370] Fix | Delete
$s = microtime(true);
[371] Fix | Delete
$result = $db->query($query);
[372] Fix | Delete
if ($db->error) {
[373] Fix | Delete
fud_sql_error_handler($query, $db->error, $db->errno, db_version());
[374] Fix | Delete
}
[375] Fix | Delete
$e = microtime(true);
[376] Fix | Delete
[377] Fix | Delete
$GLOBALS['__DB_INC_INTERNALS__']['last_time'] = ($e - $s);
[378] Fix | Delete
$GLOBALS['__DB_INC_INTERNALS__']['total_sql_time'] += $GLOBALS['__DB_INC_INTERNALS__']['last_time'];
[379] Fix | Delete
[380] Fix | Delete
echo '<hr><b>Query #'. $GLOBALS['__DB_INC_INTERNALS__']['query_count'] .'</b><small>';
[381] Fix | Delete
echo ': time taken: <i>'. number_format($GLOBALS['__DB_INC_INTERNALS__']['last_time'], 4) .'</i>';
[382] Fix | Delete
echo ', affected rows: <i>'. db_affected() .'</i>';
[383] Fix | Delete
echo ', total sql time: <i>'. number_format($GLOBALS['__DB_INC_INTERNALS__']['total_sql_time'], 4) .'</i>';
[384] Fix | Delete
echo '<pre>'. preg_replace('!\s+!', ' ', htmlspecialchars($query)) .'</pre></small>';
[385] Fix | Delete
[386] Fix | Delete
return $result;
[387] Fix | Delete
}
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
function db_rowobj($result)
[391] Fix | Delete
{
[392] Fix | Delete
return $result->fetch_object();
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
function db_rowarr($result)
[396] Fix | Delete
{
[397] Fix | Delete
return $result->fetch_row();
[398] Fix | Delete
}
[399] Fix | Delete
[400] Fix | Delete
function q_singleval($query)
[401] Fix | Delete
{
[402] Fix | Delete
$r = q($query);
[403] Fix | Delete
if (($result = $r->fetch_row()) !== false && isset($result)) {
[404] Fix | Delete
return isset($result) ? $result[0] : '';
[405] Fix | Delete
}
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
function q_limit($query, $limit, $off=0)
[409] Fix | Delete
{
[410] Fix | Delete
return $query .' LIMIT '. $limit .' OFFSET '. $off;
[411] Fix | Delete
}
[412] Fix | Delete
[413] Fix | Delete
function q_concat($arg)
[414] Fix | Delete
{
[415] Fix | Delete
// MySQL badly breaks the SQL standard by redefining || to mean OR.
[416] Fix | Delete
$tmp = func_get_args();
[417] Fix | Delete
return 'CONCAT('. implode(',', $tmp) .')';
[418] Fix | Delete
}
[419] Fix | Delete
[420] Fix | Delete
function q_rownum() {
[421] Fix | Delete
q('SET @seq=0'); // For simulating rownum.
[422] Fix | Delete
return '(@seq:=@seq+1)';
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
function q_bitand($fieldLeft, $fieldRight) {
[426] Fix | Delete
return $fieldLeft .' & '. $fieldRight;
[427] Fix | Delete
}
[428] Fix | Delete
[429] Fix | Delete
function q_bitor($fieldLeft, $fieldRight) {
[430] Fix | Delete
return '('. $fieldLeft .' | '. $fieldRight .')';
[431] Fix | Delete
}
[432] Fix | Delete
[433] Fix | Delete
function q_bitnot($bitField) {
[434] Fix | Delete
return '~'. $bitField;
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
function db_saq($q)
[438] Fix | Delete
{
[439] Fix | Delete
$r = q($q);
[440] Fix | Delete
return $r->fetch_row() ;
[441] Fix | Delete
}
[442] Fix | Delete
[443] Fix | Delete
function db_sab($q)
[444] Fix | Delete
{
[445] Fix | Delete
$r = q($q);
[446] Fix | Delete
return $r->fetch_object();
[447] Fix | Delete
}
[448] Fix | Delete
[449] Fix | Delete
function db_qid($q)
[450] Fix | Delete
{
[451] Fix | Delete
q($q);
[452] Fix | Delete
return db::$db->insert_id;
[453] Fix | Delete
}
[454] Fix | Delete
[455] Fix | Delete
function db_arr_assoc($q)
[456] Fix | Delete
{
[457] Fix | Delete
$r = q($q);
[458] Fix | Delete
return $r->fetch_array(MYSQLI_ASSOC);
[459] Fix | Delete
}
[460] Fix | Delete
[461] Fix | Delete
function db_fetch_array($r)
[462] Fix | Delete
{
[463] Fix | Delete
return is_object($r) ? $r->fetch_array(MYSQLI_ASSOC) : null;
[464] Fix | Delete
}
[465] Fix | Delete
[466] Fix | Delete
function db_li($q, &$ef, $li=0)
[467] Fix | Delete
{
[468] Fix | Delete
$r = db::$db->query($q);
[469] Fix | Delete
if ($r) {
[470] Fix | Delete
return ($li ? db::$db->insert_id : $r);
[471] Fix | Delete
}
[472] Fix | Delete
[473] Fix | Delete
/* Duplicate key. */
[474] Fix | Delete
if (db::$db->errno == 1062) {
[475] Fix | Delete
$ef = ltrim(strrchr(db::$db->error, ' '));
[476] Fix | Delete
return null;
[477] Fix | Delete
} else {
[478] Fix | Delete
fud_sql_error_handler($q, db::$db->error, db::$db->errno, db_version());
[479] Fix | Delete
}
[480] Fix | Delete
}
[481] Fix | Delete
[482] Fix | Delete
function ins_m($tbl, $flds, $types, $vals)
[483] Fix | Delete
{
[484] Fix | Delete
q('INSERT IGNORE INTO '. $tbl .' ('. $flds .') VALUES ('. implode('),(', $vals) .')');
[485] Fix | Delete
}
[486] Fix | Delete
[487] Fix | Delete
function db_all($q)
[488] Fix | Delete
{
[489] Fix | Delete
$f = array();
[490] Fix | Delete
$c = uq($q);
[491] Fix | Delete
while ($r = $c->fetch_row()) {
[492] Fix | Delete
$f[] = $r[0];
[493] Fix | Delete
}
[494] Fix | Delete
return $f;
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
function _esc($s)
[498] Fix | Delete
{
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function