Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../var/softacul.../fud
File: index.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* copyright : (C) 2001-2019 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
if (function_exists('mb_internal_encoding')) {
[11] Fix | Delete
mb_internal_encoding('utf-8');
[12] Fix | Delete
}
[13] Fix | Delete
require('./GLOBALS.php');
[14] Fix | Delete
[15] Fix | Delete
/* Activation check. */
[16] Fix | Delete
if (!($FUD_OPT_1 & 1)) { // FORUM_ENABLED
[17] Fix | Delete
fud_use('errmsg.inc');
[18] Fix | Delete
exit_forum_disabled();
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
# define('fud_query_stats', 1);
[22] Fix | Delete
[23] Fix | Delete
class db { public static $db, $slave; }
[24] Fix | Delete
[25] Fix | Delete
if (empty(db::$db)) {
[26] Fix | Delete
[27] Fix | Delete
// Use MYSQLI_REPORT_OFF so we can check error codes manually.
[28] Fix | Delete
$driver = new mysqli_driver();
[29] Fix | Delete
$driver->report_mode = MYSQLI_REPORT_OFF;
[30] Fix | Delete
[31] Fix | Delete
if (substr($GLOBALS['DBHOST'], 0, 1) == ':') { // Socket connection.
[32] Fix | Delete
$socket = substr($GLOBALS['DBHOST'], 1);
[33] Fix | Delete
$GLOBALS['DBHOST'] = 'localhost';
[34] Fix | Delete
} else {
[35] Fix | Delete
$socket = NULL;
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
if ($GLOBALS['FUD_OPT_1'] & 256 && $socket == NULL && version_compare(PHP_VERSION, '5.3.0', '>=')) { // Enable pconnect for PHP 5.3+.
[39] Fix | Delete
$GLOBALS['DBHOST'] = 'p:'. $GLOBALS['DBHOST'];
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
db::$db = new mysqli($GLOBALS['DBHOST'], $GLOBALS['DBHOST_USER'], $GLOBALS['DBHOST_PASSWORD'], $GLOBALS['DBHOST_DBNAME'], NULL, $socket);
[43] Fix | Delete
if (mysqli_connect_errno()) {
[44] Fix | Delete
fud_sql_error_handler('Failed to establish database connection', 'MySQLi says: '. mysqli_connect_error(), mysqli_connect_errno(), '');
[45] Fix | Delete
}
[46] Fix | Delete
db::$db->set_charset('utf8');
[47] Fix | Delete
[48] Fix | Delete
/* Connect to slave, if specified. */
[49] Fix | Delete
if (!empty($GLOBALS['DBHOST_SLAVE_HOST']) && !$GLOBALS['is_post']) {
[50] Fix | Delete
db::$slave = new mysqli($GLOBALS['DBHOST'], $GLOBALS['DBHOST_USER'], $GLOBALS['DBHOST_PASSWORD'], $GLOBALS['DBHOST_DBNAME'], NULL, $socket);
[51] Fix | Delete
if (mysqli_connect_errno()) {
[52] Fix | Delete
fud_logerror('Unable to init SlaveDB, fallback to MasterDB: '. mysqli_connect_error(), 'sql_errors');
[53] Fix | Delete
} else {
[54] Fix | Delete
db::$db->set_charset('utf8');
[55] Fix | Delete
}
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
define('__dbtype__', 'mysql');
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
function db_close()
[62] Fix | Delete
{
[63] Fix | Delete
db::$db->close();
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
function db_version()
[67] Fix | Delete
{
[68] Fix | Delete
if (!defined('__FUD_SQL_VERSION__')) {
[69] Fix | Delete
$ver = q_singleval('SELECT VERSION()');
[70] Fix | Delete
define('__FUD_SQL_VERSION__', $ver);
[71] Fix | Delete
}
[72] Fix | Delete
return __FUD_SQL_VERSION__;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
function db_lock($tables)
[76] Fix | Delete
{
[77] Fix | Delete
if (!empty($GLOBALS['__DB_INC_INTERNALS__']['db_locked'])) {
[78] Fix | Delete
fud_sql_error_handler('Recursive Lock', 'internal', 'internal', db_version());
[79] Fix | Delete
} else {
[80] Fix | Delete
q('LOCK TABLES '. $tables);
[81] Fix | Delete
$GLOBALS['__DB_INC_INTERNALS__']['db_locked'] = 1;
[82] Fix | Delete
}
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
function db_unlock()
[86] Fix | Delete
{
[87] Fix | Delete
if (empty($GLOBALS['__DB_INC_INTERNALS__']['db_locked'])) {
[88] Fix | Delete
unset($GLOBALS['__DB_INC_INTERNALS__']['db_locked']);
[89] Fix | Delete
fud_sql_error_handler('DB_UNLOCK: no previous lock established', 'internal', 'internal', db_version());
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
if (--$GLOBALS['__DB_INC_INTERNALS__']['db_locked'] < 0) {
[93] Fix | Delete
unset($GLOBALS['__DB_INC_INTERNALS__']['db_locked']);
[94] Fix | Delete
fud_sql_error_handler('DB_UNLOCK: unlock overcalled', 'internal', 'internal', db_version());
[95] Fix | Delete
}
[96] Fix | Delete
unset($GLOBALS['__DB_INC_INTERNALS__']['db_locked']);
[97] Fix | Delete
q('UNLOCK TABLES');
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
function db_locked()
[101] Fix | Delete
{
[102] Fix | Delete
return isset($GLOBALS['__DB_INC_INTERNALS__']['db_locked']);
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
function db_affected()
[106] Fix | Delete
{
[107] Fix | Delete
return db::$db->affected_rows;
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
function uq($query)
[111] Fix | Delete
{
[112] Fix | Delete
return q($query);
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
if (!defined('fud_query_stats')) {
[116] Fix | Delete
function q($query)
[117] Fix | Delete
{
[118] Fix | Delete
// Assume master DB, route SELECT's to slave DB.
[119] Fix | Delete
// Force master if DB is locked (in transaction) or 'SELECT /* USE MASTER */'.
[120] Fix | Delete
$db = db::$db;
[121] Fix | Delete
if (!empty(db::$slave) && !db_locked() && !strncasecmp($query, 'SELECT', 6) && strncasecmp($query, 'SELECT /* USE MASTER */', 23)) {
[122] Fix | Delete
$db = db::$slave;
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
$r = $db->query($query);
[126] Fix | Delete
if ($db->error) {
[127] Fix | Delete
fud_sql_error_handler($query, $db->error, $db->errno, db_version());
[128] Fix | Delete
}
[129] Fix | Delete
return $r;
[130] Fix | Delete
}
[131] Fix | Delete
} else {
[132] Fix | Delete
function q($query)
[133] Fix | Delete
{
[134] Fix | Delete
if (!isset($GLOBALS['__DB_INC_INTERNALS__']['query_count'])) {
[135] Fix | Delete
$GLOBALS['__DB_INC_INTERNALS__']['query_count'] = 1;
[136] Fix | Delete
} else {
[137] Fix | Delete
++$GLOBALS['__DB_INC_INTERNALS__']['query_count'];
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
if (!isset($GLOBALS['__DB_INC_INTERNALS__']['total_sql_time'])) {
[141] Fix | Delete
$GLOBALS['__DB_INC_INTERNALS__']['total_sql_time'] = 0;
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
// Assume master DB, route SELECT's to slave DB.
[145] Fix | Delete
// Force master if DB is locked (in transaction) or 'SELECT /* USE MASTER */'.
[146] Fix | Delete
$db = db::$db;
[147] Fix | Delete
if (!empty(db::$slave) && !db_locked() && !strncasecmp($query, 'SELECT', 6) && strncasecmp($query, 'SELECT /* USE MASTER */', 23)) {
[148] Fix | Delete
$db = db::$slave;
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
$s = microtime(true);
[152] Fix | Delete
$result = $db->query($query);
[153] Fix | Delete
if ($db->error) {
[154] Fix | Delete
fud_sql_error_handler($query, $db->error, $db->errno, db_version());
[155] Fix | Delete
}
[156] Fix | Delete
$e = microtime(true);
[157] Fix | Delete
[158] Fix | Delete
$GLOBALS['__DB_INC_INTERNALS__']['last_time'] = ($e - $s);
[159] Fix | Delete
$GLOBALS['__DB_INC_INTERNALS__']['total_sql_time'] += $GLOBALS['__DB_INC_INTERNALS__']['last_time'];
[160] Fix | Delete
[161] Fix | Delete
echo '<hr><b>Query #'. $GLOBALS['__DB_INC_INTERNALS__']['query_count'] .'</b><small>';
[162] Fix | Delete
echo ': time taken: <i>'. number_format($GLOBALS['__DB_INC_INTERNALS__']['last_time'], 4) .'</i>';
[163] Fix | Delete
echo ', affected rows: <i>'. db_affected() .'</i>';
[164] Fix | Delete
echo ', total sql time: <i>'. number_format($GLOBALS['__DB_INC_INTERNALS__']['total_sql_time'], 4) .'</i>';
[165] Fix | Delete
echo '<pre>'. preg_replace('!\s+!', ' ', htmlspecialchars($query)) .'</pre></small>';
[166] Fix | Delete
[167] Fix | Delete
return $result;
[168] Fix | Delete
}
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
function db_rowobj($result)
[172] Fix | Delete
{
[173] Fix | Delete
return $result->fetch_object();
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
function db_rowarr($result)
[177] Fix | Delete
{
[178] Fix | Delete
return $result->fetch_row();
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
function q_singleval($query)
[182] Fix | Delete
{
[183] Fix | Delete
$r = q($query);
[184] Fix | Delete
if (($result = $r->fetch_row()) !== false && isset($result)) {
[185] Fix | Delete
return isset($result) ? $result[0] : '';
[186] Fix | Delete
}
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
function q_limit($query, $limit, $off=0)
[190] Fix | Delete
{
[191] Fix | Delete
return $query .' LIMIT '. $limit .' OFFSET '. $off;
[192] Fix | Delete
}
[193] Fix | Delete
[194] Fix | Delete
function q_concat($arg)
[195] Fix | Delete
{
[196] Fix | Delete
// MySQL badly breaks the SQL standard by redefining || to mean OR.
[197] Fix | Delete
$tmp = func_get_args();
[198] Fix | Delete
return 'CONCAT('. implode(',', $tmp) .')';
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
function q_rownum() {
[202] Fix | Delete
q('SET @seq=0'); // For simulating rownum.
[203] Fix | Delete
return '(@seq:=@seq+1)';
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
function q_bitand($fieldLeft, $fieldRight) {
[207] Fix | Delete
return $fieldLeft .' & '. $fieldRight;
[208] Fix | Delete
}
[209] Fix | Delete
[210] Fix | Delete
function q_bitor($fieldLeft, $fieldRight) {
[211] Fix | Delete
return '('. $fieldLeft .' | '. $fieldRight .')';
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
function q_bitnot($bitField) {
[215] Fix | Delete
return '~'. $bitField;
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
function db_saq($q)
[219] Fix | Delete
{
[220] Fix | Delete
$r = q($q);
[221] Fix | Delete
return $r->fetch_row() ;
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
function db_sab($q)
[225] Fix | Delete
{
[226] Fix | Delete
$r = q($q);
[227] Fix | Delete
return $r->fetch_object();
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
function db_qid($q)
[231] Fix | Delete
{
[232] Fix | Delete
q($q);
[233] Fix | Delete
return db::$db->insert_id;
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
function db_arr_assoc($q)
[237] Fix | Delete
{
[238] Fix | Delete
$r = q($q);
[239] Fix | Delete
return $r->fetch_array(MYSQLI_ASSOC);
[240] Fix | Delete
}
[241] Fix | Delete
[242] Fix | Delete
function db_fetch_array($r)
[243] Fix | Delete
{
[244] Fix | Delete
return is_object($r) ? $r->fetch_array(MYSQLI_ASSOC) : null;
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
function db_li($q, &$ef, $li=0)
[248] Fix | Delete
{
[249] Fix | Delete
$r = db::$db->query($q);
[250] Fix | Delete
if ($r) {
[251] Fix | Delete
return ($li ? db::$db->insert_id : $r);
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
/* Duplicate key. */
[255] Fix | Delete
if (db::$db->errno == 1062) {
[256] Fix | Delete
$ef = ltrim(strrchr(db::$db->error, ' '));
[257] Fix | Delete
return null;
[258] Fix | Delete
} else {
[259] Fix | Delete
fud_sql_error_handler($q, db::$db->error, db::$db->errno, db_version());
[260] Fix | Delete
}
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
function ins_m($tbl, $flds, $types, $vals)
[264] Fix | Delete
{
[265] Fix | Delete
q('INSERT IGNORE INTO '. $tbl .' ('. $flds .') VALUES ('. implode('),(', $vals) .')');
[266] Fix | Delete
}
[267] Fix | Delete
[268] Fix | Delete
function db_all($q)
[269] Fix | Delete
{
[270] Fix | Delete
$f = array();
[271] Fix | Delete
$c = uq($q);
[272] Fix | Delete
while ($r = $c->fetch_row()) {
[273] Fix | Delete
$f[] = $r[0];
[274] Fix | Delete
}
[275] Fix | Delete
return $f;
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
function _esc($s)
[279] Fix | Delete
{
[280] Fix | Delete
return '\''. db::$db->real_escape_string($s) .'\'';
[281] Fix | Delete
}function ses_make_sysid()
[282] Fix | Delete
{
[283] Fix | Delete
if ($GLOBALS['FUD_OPT_2'] & 256) { // MULTI_HOST_LOGIN
[284] Fix | Delete
return;
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
$keys = array('REMOTE_USER', 'HTTP_USER_AGENT', 'SERVER_PROTOCOL', 'HTTP_ACCEPT_CHARSET', 'HTTP_ACCEPT_LANGUAGE');
[288] Fix | Delete
if ($GLOBALS['FUD_OPT_3'] & 16) { // SESSION_IP_CHECK
[289] Fix | Delete
$keys[] = 'HTTP_X_FORWARDED_FOR';
[290] Fix | Delete
$keys[] = 'REMOTE_ADDR';
[291] Fix | Delete
}
[292] Fix | Delete
$pfx = '';
[293] Fix | Delete
foreach ($keys as $v) {
[294] Fix | Delete
if (isset($_SERVER[$v])) {
[295] Fix | Delete
$pfx .= $_SERVER[$v];
[296] Fix | Delete
}
[297] Fix | Delete
}
[298] Fix | Delete
return md5($pfx);
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
function ses_get($id=0)
[302] Fix | Delete
{
[303] Fix | Delete
if (!$id) {
[304] Fix | Delete
/* Cookie or URL session? If not, check for known bots. */
[305] Fix | Delete
if (!empty($_COOKIE[$GLOBALS['COOKIE_NAME']])) {
[306] Fix | Delete
/* Have cookie */
[307] Fix | Delete
$q_opt = 's.ses_id='. _esc($_COOKIE[$GLOBALS['COOKIE_NAME']]);
[308] Fix | Delete
} else if ((isset($_GET['S']) || isset($_POST['S'])) && $GLOBALS['FUD_OPT_1'] & 128) {
[309] Fix | Delete
/* Have session string */
[310] Fix | Delete
$url_session = 1;
[311] Fix | Delete
$q_opt = 's.ses_id='. _esc((isset($_GET['S']) ? (string) $_GET['S'] : (string) $_POST['S']));
[312] Fix | Delete
/* Do not validate against expired URL sessions. */
[313] Fix | Delete
$q_opt .= ' AND s.time_sec > '. (__request_timestamp__ - $GLOBALS['SESSION_TIMEOUT']);
[314] Fix | Delete
} else {
[315] Fix | Delete
/* Unknown user, maybe bot? */
[316] Fix | Delete
// Auto login authorized bots.
[317] Fix | Delete
// To test: wget --user-agent="Googlebot 1.2" http://127.0.0.1:8080/forum
[318] Fix | Delete
$spider_session = 0;
[319] Fix | Delete
$my_ip = get_ip();
[320] Fix | Delete
[321] Fix | Delete
include $GLOBALS['FORUM_SETTINGS_PATH'] .'spider_cache';
[322] Fix | Delete
foreach ($spider_cache as $spider_id => $spider) {
[323] Fix | Delete
if (preg_match('/'. $spider['useragent'] .'/i', $_SERVER['HTTP_USER_AGENT'])) {
[324] Fix | Delete
if (empty($spider['bot_ip'])) {
[325] Fix | Delete
$spider_session = 1; // Agent matched, no IPs to check.
[326] Fix | Delete
break;
[327] Fix | Delete
} else {
[328] Fix | Delete
foreach (explode(',', $spider['bot_ip']) as $bot_ip) {
[329] Fix | Delete
if (!($bot_ip = trim($bot_ip))) {
[330] Fix | Delete
continue;
[331] Fix | Delete
}
[332] Fix | Delete
if (strpos($bot_ip, $my_ip) === 0) {
[333] Fix | Delete
$spider_session = 1; // Agent and an IP matched.
[334] Fix | Delete
break;
[335] Fix | Delete
}
[336] Fix | Delete
}
[337] Fix | Delete
}
[338] Fix | Delete
}
[339] Fix | Delete
}
[340] Fix | Delete
if ($spider_session) {
[341] Fix | Delete
if ($spider['bot_opts'] & 2) { // Access blocked.
[342] Fix | Delete
die('Go away!');
[343] Fix | Delete
}
[344] Fix | Delete
if ($id = db_li('INSERT INTO fud30_ses (ses_id, time_sec, sys_id, ip_addr, useragent, user_id) VALUES (\''. $spider['botname'] .'\', '. __request_timestamp__ .', '. _esc(ses_make_sysid()) .', '. _esc($my_ip) .', '. _esc(substr($_SERVER['HTTP_USER_AGENT'], 0, 64)) .', '. $spider['user_id'] .')', $ef, 1)) {
[345] Fix | Delete
$q_opt = 's.id='. $id;
[346] Fix | Delete
} else {
[347] Fix | Delete
$q_opt = 's.ses_id='. _esc($spider['botname']);
[348] Fix | Delete
}
[349] Fix | Delete
$GLOBALS['FUD_OPT_1'] ^= 128; // Disable URL sessions for user.
[350] Fix | Delete
} else {
[351] Fix | Delete
/* NeXuS: What is this? Return if user unknown? Function should
[352] Fix | Delete
return only after the query is run. */
[353] Fix | Delete
//return;
[354] Fix | Delete
[355] Fix | Delete
// Check sys_id, ip_addr and useragent for a possible match
[356] Fix | Delete
$q_opt = 's.sys_id= '._esc(ses_make_sysid()).
[357] Fix | Delete
' AND s.ip_addr='._esc(get_ip()).
[358] Fix | Delete
' AND s.useragent='._esc(substr($_SERVER['HTTP_USER_AGENT'], 0, 64));
[359] Fix | Delete
}
[360] Fix | Delete
}
[361] Fix | Delete
[362] Fix | Delete
/* ENABLE_REFERRER_CHECK */
[363] Fix | Delete
if ($GLOBALS['FUD_OPT_3'] & 4 && isset($_SERVER['HTTP_REFERER']) && strncmp($_SERVER['HTTP_REFERER'], $GLOBALS['WWW_ROOT'], strlen($GLOBALS['WWW_ROOT']))) {
[364] Fix | Delete
/* More checks, we need those because some proxies mangle referer field. */
[365] Fix | Delete
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
[366] Fix | Delete
/* $p > 8 https:// or http:// */
[367] Fix | Delete
if (($p = strpos($_SERVER['HTTP_REFERER'], $host)) === false || $p > 8) {
[368] Fix | Delete
$q_opt .= ' AND s.user_id > 2000000000 '; // Different referrer, force anonymous.
[369] Fix | Delete
}
[370] Fix | Delete
}
[371] Fix | Delete
} else {
[372] Fix | Delete
$q_opt = 's.id='. $id;
[373] Fix | Delete
}
[374] Fix | Delete
[375] Fix | Delete
$u = db_sab('SELECT
[376] Fix | Delete
s.id AS sid, s.ses_id, s.data, s.returnto, s.sys_id,
[377] Fix | Delete
t.id AS theme_id, t.lang, t.name AS theme_name, t.locale, t.theme, t.pspell_lang, t.theme_opt,
[378] Fix | Delete
u.alias, u.posts_ppg, u.time_zone, u.sig, u.last_visit, u.last_read, u.cat_collapse_status, u.users_opt, u.posted_msg_count, u.topics_per_page,
[379] Fix | Delete
u.ignore_list, u.ignore_list, u.buddy_list, u.id, u.group_leader_list, u.email, u.login, u.sq, u.ban_expiry, u.ban_reason, u.flag_cc
[380] Fix | Delete
FROM fud30_ses s
[381] Fix | Delete
INNER JOIN fud30_users u ON u.id=(CASE WHEN s.user_id>2000000000 THEN 1 ELSE s.user_id END)
[382] Fix | Delete
LEFT OUTER JOIN fud30_themes t ON t.id=u.theme
[383] Fix | Delete
WHERE '. $q_opt);
[384] Fix | Delete
[385] Fix | Delete
/* Anon user, no session or login. */
[386] Fix | Delete
if (!$u || $u->id == 1 || $id) {
[387] Fix | Delete
return $u;
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
if ($u->sys_id == ses_make_sysid()) {
[391] Fix | Delete
return $u;
[392] Fix | Delete
} else if ($GLOBALS['FUD_OPT_3'] & 16 || isset($url_session)) {
[393] Fix | Delete
/* URL sessions must validate sys_id check and SESSION_IP_CHECK must be disabled */
[394] Fix | Delete
return;
[395] Fix | Delete
}
[396] Fix | Delete
[397] Fix | Delete
/* Try doing a strict SQ match in last-ditch effort to make things 'work'. */
[398] Fix | Delete
if (isset($_POST['SQ']) && $_POST['SQ'] == $u->sq) {
[399] Fix | Delete
return $u;
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
return;
[403] Fix | Delete
}
[404] Fix | Delete
[405] Fix | Delete
/** Create an anonymous session. */
[406] Fix | Delete
function ses_anon_make()
[407] Fix | Delete
{
[408] Fix | Delete
do {
[409] Fix | Delete
$uid = 2000000000 + mt_rand(1, 147483647);
[410] Fix | Delete
$ses_id = md5($uid . __request_timestamp__ . getmypid());
[411] Fix | Delete
} while (!($id = db_li('INSERT INTO fud30_ses (ses_id, time_sec, sys_id, ip_addr, useragent, user_id) VALUES (\''. $ses_id .'\', '. __request_timestamp__ .', '. _esc(ses_make_sysid()) .', '. _esc(get_ip()) .', '. _esc(substr($_SERVER['HTTP_USER_AGENT'], 0, 64)) .', '. $uid .')', $ef, 1)));
[412] Fix | Delete
[413] Fix | Delete
/* When we have an anon user, we set a special cookie allowing us to see who referred this user. */
[414] Fix | Delete
if (isset($_GET['rid']) && !isset($_COOKIE['frm_referer_id']) && $GLOBALS['FUD_OPT_2'] & 8192) {
[415] Fix | Delete
setcookie($GLOBALS['COOKIE_NAME'] .'_referer_id', $_GET['rid'], __request_timestamp__+31536000, $GLOBALS['COOKIE_PATH'], $GLOBALS['COOKIE_DOMAIN']);
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
if ($GLOBALS['FUD_OPT_3'] & 1) { // SESSION_COOKIES
[419] Fix | Delete
setcookie($GLOBALS['COOKIE_NAME'], $ses_id, 0, $GLOBALS['COOKIE_PATH'], $GLOBALS['COOKIE_DOMAIN']);
[420] Fix | Delete
} else {
[421] Fix | Delete
setcookie($GLOBALS['COOKIE_NAME'], $ses_id, __request_timestamp__+$GLOBALS['COOKIE_TIMEOUT'], $GLOBALS['COOKIE_PATH'], $GLOBALS['COOKIE_DOMAIN']);
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
[425] Fix | Delete
return ses_get($id);
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
/** Update session status to indicate last known action. */
[429] Fix | Delete
function ses_update_status($ses_id, $str=null, $forum_id=0, $ret='')
[430] Fix | Delete
{
[431] Fix | Delete
if (empty($ses_id)) {
[432] Fix | Delete
die('FATAL ERROR: No session, check your forum\'s URL and COOKIE settings.');
[433] Fix | Delete
}
[434] Fix | Delete
q('UPDATE fud30_ses SET sys_id=\''. ses_make_sysid() .'\', forum_id='. $forum_id .', time_sec='. __request_timestamp__ .', action='. ($str ? _esc($str) : 'NULL') .', returnto='. (!is_int($ret) ? (isset($_SERVER['QUERY_STRING']) ? _esc($_SERVER['QUERY_STRING']) : 'NULL') : 'returnto') .' WHERE id='. $ses_id);
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
/** Save/ clear a session variable. */
[438] Fix | Delete
function ses_putvar($ses_id, $data)
[439] Fix | Delete
{
[440] Fix | Delete
$cond = is_int($ses_id) ? 'id='. (int)$ses_id : 'ses_id=\''. $ses_id .'\'';
[441] Fix | Delete
[442] Fix | Delete
if (empty($data)) {
[443] Fix | Delete
q('UPDATE fud30_ses SET data=NULL WHERE '. $cond);
[444] Fix | Delete
} else {
[445] Fix | Delete
q('UPDATE fud30_ses SET data='. _esc(serialize($data)) .' WHERE '. $cond);
[446] Fix | Delete
}
[447] Fix | Delete
}
[448] Fix | Delete
[449] Fix | Delete
/** Destroy a session. */
[450] Fix | Delete
function ses_delete($ses_id)
[451] Fix | Delete
{
[452] Fix | Delete
// Delete all forum sessions.
[453] Fix | Delete
// Regardless of MULTI_HOST_LOGIN, all sessions will be terminated.
[454] Fix | Delete
q('DELETE FROM fud30_ses WHERE id='. $ses_id);
[455] Fix | Delete
setcookie($GLOBALS['COOKIE_NAME'], '', __request_timestamp__-100000, $GLOBALS['COOKIE_PATH'], $GLOBALS['COOKIE_DOMAIN']);
[456] Fix | Delete
[457] Fix | Delete
return 1;
[458] Fix | Delete
}
[459] Fix | Delete
[460] Fix | Delete
function ses_anonuser_auth($id, $error)
[461] Fix | Delete
{
[462] Fix | Delete
if (!empty($_POST)) {
[463] Fix | Delete
$_SERVER['QUERY_STRING'] = '';
[464] Fix | Delete
}
[465] Fix | Delete
q('UPDATE fud30_ses SET data='. _esc(serialize($error)) .', returnto='. ssn($_SERVER['QUERY_STRING']) .' WHERE id='. $id);
[466] Fix | Delete
if ($GLOBALS['FUD_OPT_2'] & 32768) { // USE_PATH_INFO
[467] Fix | Delete
header('Location: [[relativeurl]]/index.php/l/'. _rsidl);
[468] Fix | Delete
} else {
[469] Fix | Delete
header('Location: [[relativeurl]]/index.php?t=login&'. _rsidl);
[470] Fix | Delete
}
[471] Fix | Delete
exit;
[472] Fix | Delete
}function &init_user()
[473] Fix | Delete
{
[474] Fix | Delete
$o1 =& $GLOBALS['FUD_OPT_1'];
[475] Fix | Delete
$o2 =& $GLOBALS['FUD_OPT_2'];
[476] Fix | Delete
[477] Fix | Delete
if ($o2 & 32768 && empty($_SERVER['PATH_INFO']) && !empty($_SERVER['ORIG_PATH_INFO'])) {
[478] Fix | Delete
$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
[479] Fix | Delete
}
[480] Fix | Delete
[481] Fix | Delete
/* We need to parse S & rid right away since they are used during user init. */
[482] Fix | Delete
if ($o2 & 32768 && !empty($_SERVER['PATH_INFO']) && empty($_GET['t'])) { // USE_PATH_INFO
[483] Fix | Delete
$pb = $p = explode('/', trim($_SERVER['PATH_INFO'], '/'));
[484] Fix | Delete
if ($o1 & 128) { // SESSION_USE_URL
[485] Fix | Delete
$_GET['S'] = array_pop($p);
[486] Fix | Delete
}
[487] Fix | Delete
if ($o2 & 8192) { // TRACK_REFERRALS
[488] Fix | Delete
$_GET['rid'] = array_pop($p);
[489] Fix | Delete
}
[490] Fix | Delete
$_SERVER['QUERY_STRING'] = htmlspecialchars($_SERVER['PATH_INFO']) .'?'. $_SERVER['QUERY_STRING'];
[491] Fix | Delete
[492] Fix | Delete
/* Default to index page. */
[493] Fix | Delete
if (!isset($p[0])) {
[494] Fix | Delete
$p[0] = 'i';
[495] Fix | Delete
}
[496] Fix | Delete
/* Notice prevention code. */
[497] Fix | Delete
for ($i = 1; $i < 5; $i++) {
[498] Fix | Delete
if (!isset($p[$i])) {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function