function add_quote_do_inner() { global $CONFIG, $TEMPLATE, $db; $flag = isset($CONFIG['auto_flagged_quotes']) && $CONFIG['auto_flagged_quotes'] == 1 ? 2 : 0; $spamre = isset($CONFIG['spam_regex']) && $CONFIG['spam_regex'] != '' ? $CONFIG['spam_regex'] : NULL; $quotxt = htmlspecialchars(trim($_POST["rash_quote"])); $innerhtml = $TEMPLATE->add_quote_outputmsg(mangle_quote_text($quotxt)); $t = time(); $ip = $_SERVER['REMOTE_ADDR']; if ($spamre && preg_match('/' . $spamre . '/', $quotxt)) { $table = 'spamlog'; if (isset($CONFIG['spam_expire_time']) && $CONFIG['spam_expire_time'] > 0) { $sql = 'DELETE FROM ' . db_tablename('spamlog') . ' WHERE date<' . $db->quote($t + $CONFIG['spam_expire_time']); db_query($sql); } } elseif ($CONFIG['moderated_quotes']) { $table = 'queue'; } else { $table = 'quotes'; } if (isset($CONFIG['auto_block_spam_ip']) && $CONFIG['auto_block_spam_ip'] > 0) { $sql = 'SELECT COUNT(*) FROM ' . db_tablename('spamlog') . ' WHERE submitip=' . $db->quote($ip); $cnt = db_query_singlevalue($sql); if ($cnt >= $CONFIG['auto_block_spam_ip']) { return $innerhtml; } } $db->query("INSERT INTO " . db_tablename($table) . " (quote, submitip, date) VALUES(" . $db->quote($quotxt) . ", " . $db->quote($ip) . ", " . $t . ")"); return $innerhtml; }
function do_random($db, $params) { $qt = db_tablename('quotes', $params); $count = db_query_singlevalue('SELECT COUNT(id) FROM ' . $qt . ' where queue=0'); $index = rand(0, $count - 1); return make_query_one($db, 'SELECT * FROM ' . $qt . ' where queue=0', $index); }