|
init.php
<?php /** * This file is included in header.php, and holds all * the library functions required for forums */
// undo stupid magic quotes function undomq(&$m) { if (get_magic_quotes_gpc()) { // undo the damage $m = str_replace('\"','"',$m); $m = str_replace('\\\'','\'',$m); } return $m; }
/* * Generates the forum top caption ($lens->lang->topCaption) */ function forumheader($db,$forumid,$forumname,$topicid=false) { if ($topicid) { $a1 = '<a href=topics.php?id='.$forumid.'><font color=lightblue>'; $a2 = '</font></a>'; }else { $a1 = ''; $a2 = ''; } return "<a href=forums.php><font color=lightblue>Forums</font></a>: " .$a1.$forumname.$a2; }
/* * Generates the forum bottom caption ($lens->lang->bottomCaption) */ function forumfooter($lens) {
if ($lens->curState == 'NEW') if (ALLOWHTML) print '<div align=center>You can enter HTML tags in the body such as ' . '<b><b>bold</b></b>, <i><i>italic</i></i>, ' . '<code><code>code</code></code></div>'; else print '<p align=center>You can enter the following UBB tags: ' . '[b]<b>bold</b>[/b], [i]<i>italic</i>[/i], [red]<font color=#800000>red</font>[/red] and [pre] [/pre] </p>'; }
/* * Support [b] and [i] */ function ubbcode($s) { $s = phplens_str2url($s); // convert http:// to urls -- part of phplens internal library $arr1 = array('/\[pre\]/i','/\[\/pre\]/i','/\[red\]/i','/\[\/red\]/i','/\[h[1-9]\]/i','/\[\\/h[1-9]\]/i','/\[b\]/i','/\[\\/b\]/i','/\[i\]/i','/\[\\/i\]/i'); $arr2 = array('<div class=pre><pre>','</pre></div>','<font color="#800000">','</font>','<h3>','</h3>','<b>','</b>','<i>','</i>'); return preg_replace($arr1,$arr2,$s); }
/* * Check whether administrator exists: that is if $gAdmin global variable is set. */ function checkadmin() { global $gAdmin,$_SESSION; session_register('gAdmin'); $gAdmin=!empty($_SESSION['gAdmin']); }
function CheckGoogle() { global $_SERVER;
if (strpos(strtoupper($_SERVER["HTTP_USER_AGENT"]),'GOOGLE') !== false) { session_destroy(); } }
/* Disables http from non-admin. Also now checks to see that http string is not repeated more than 10 times, and http string is not more than 1% of all text. */
function antispam($s) { global $gAdmin;
#return $s; $spam = "Message banned as potential spammer."; $cnt = substr_count(strtolower($s),'http'); if ($cnt > 10) return die(); $strlen = strlen($s); if ($cnt >= 4 && $cnt/$strlen >= 0.010) return die(); // if http is 1% of all text, then ban // echo round($cnt/$strlen * 100,2); if ($gAdmin) return $s; $su = strtoupper($s); if (strpos(array('JERSEY','PRADA','GUCCI','CHANEL', 'HANDBAG', 'NIKE AIR', 'JERSEY'),$su)) die();
return preg_replace('/http:/i', 'http :',$s); }
//================================================================ INCLUDES
include_once(PHPLENS_DIR.'/phplens.inc.php'); //================================================================ DEFINITIONS define(NOSPAM,true); define(ALLOWHTML,false);
## fix for the auto-spammers if (isset($_POST['phplens_forumtpc'])) { if ($_POST['phplens_forumtpc'] == 'postedit' || $_POST['phplens_forumtpc'] == 'postnew') if (empty($_POST['bypass'])) $_POST['phplens_forumtpc'] = ''; if (@strpos($_POST['lens_FX_BODY'],'[url') !== false) { $_POST['phplens_forumtpc'] = ''; } #var_dump($_POST); #die(); }
function _session_register($var) { global $$var; # session_register($var); $_GLOBALS[$var] =& $_SESSION[$var]; }
$gDB=&ADONewConnection('mysql'); //$gDB->debug = true;
$gDB->Connect($gDB_Server,$gDB_User,$gDB_Pwd,$gDB_DB); ini_set('session.use_trans_sid',0);
# hold the username and email until we can access the headers and set these cookie variables _session_register('SESS_name'); _session_register('SESS_email');
_session_register('gTopicID'); _session_register('gForumID'); _session_register('gForumName'); _session_register('gTopicSubject');
$gForumID =& $_SESSION['gForumID']; $gTopicID =& $_SESSION['gTopicID']; $gForumName =& $_SESSION['gForumName']; $gTopicSubject =& $_SESSION['gTopicSubject'];
$SESS_name =& $_SESSION['SESS_name']; $SESS_email =& $_SESSION['SESS_email'];
if (!empty($SESS_name) and $_COOKIE['cookie_name'] != $SESS_name) setcookie('cookie_name',$SESS_name,time()+3600*24*30); if (!empty($SESS_email) and $_COOKIE['cookie_email'] != $SESS_email) setcookie('cookie_email',$SESS_email,time()+3600*24*30);
checkadmin(); #var_dump($_SESSION);
?>
|
|