Its been a while, but I fixed the bug that Nuclion had and also added a few more options to it, I also updated the text file with the fix, Ill also post the code below so you dont have to redownload the text. Just replace your old doif function with:
PHP Code:
// ###################### Do IF #######################
function doif($code,$text,$output=0) {
extract ($GLOBALS);
//Editable Options Below
$allowed_functions = array('trim','strtolower','strtoupper'); //Array of allowable functions
$admin_only = false; //Set to true if you want only admins to use this.
$admin_allowed_functions = false; //Set to true if you want only admins to be able to use all the functions.
$admin_view_all = false; //Set to true if you want to allow admins to view all text.
$users_view_all = array('1'); //Users that can view all the text
//Editable Options Above
$postadmin = false;
if ($post['usergroupid']==6 or $postinfo['usergroupid']==6 or $searchresult['usergroupid']==6) $postadmin = true;
$isadmin = false;
if ($bbuserinfo['usergroupid']==6) $isadmin = true;
if ($code and ($admin_only!=true or $admin_only==true and $postadmin==true)) {
unset($codestuff);
while (list($key,$val)=each($bbuserinfo)) {
$codestuff .= '$bb'.strtolower($key).' = "'.$val.'";';
@define("bb".strtolower($key),$val,true);
}
@eval($codestuff);
$allfuncs = get_defined_functions();
$search_array = array();
$replace_array = array();
if ($admin_allowed_functions!=true or $admin_allowed_functions==true and $postadmin!=true) {
foreach ($allfuncs['internal'] as $name) {
if (!in_array($name,$allowed_functions)) {
$search_array[] = "/($name)(.*)(\()(.*)(\))/siU";
$replace_array[] = "\\4";
}
}
foreach ($allfuncs['user'] as $name) {
if (!in_array($name,$allowed_functions)) {
$search_array[] = "/($name)(.*)(\()(.*)(\))/siU";
$replace_array[] = "\\4";
}
}
}
$code = preg_replace($search_array,$replace_array,$code);
//$code = str_replace("(","",$code);
//$code = str_replace(")","",$code);
$eval_code=false;
@eval ('if ('.stripslashes($code).') { $eval_code=true; } else { $eval_code=false; }');
if (($eval_code==true) or ($bbuserinfo['userid'] == $post['userid'] and intval($post['userid'])>0) or ($bbuserinfo['userid'] == $postinfo['userid'] and intval($postinfo['userid'])>0) or ($bbuserinfo['userid'] == $searchresult['userid'] and intval($searchresult['userid'])>0) or ($isadmin==true and $admin_view_all==true) or (is_array($users_view_all) and @in_array($bbuserinfo['userid'],$users_view_all))) {
if (!$output) {
return "<table border=\"0\" align=\"center\" width=\"90%\" cellpadding=\"3\" cellspacing=\"1\"><tr><td><smallfont><b>Private Text: ".iif($isadmin,"(".stripslashes($code).")","")."</b></smallfont></td></tr><tr><td class=\"privatetext_style\">".bbcodeparse($text)."</td></tr></table>";
} else return "[if(".stripslashes($code).")]".$text."[/if]";
} else {
return "";
}
}
if ($admin_only==true and $postadmin!=true) return "[if(".stripslashes($code).")]".$text."[/if]";
else return bbcodeparse($text);
}