View Single Post
  #52  
Old 03-16-2003, 03:21 AM
Slynderdale Slynderdale is offline
 
Join Date: Mar 2002
Location: New York State
Posts: 576
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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']==or $postinfo['usergroupid']==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);

Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01232 seconds
  • Memory Usage 1,824KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete