Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

class Favorites { protected $remove_list_opt = true; ..

Decoded Output download

<?          class Favorites { 
 
            protected   $remove_list_opt	= true; 
            protected   $allow_module		= ['main', 'cat', 'favorites', 'showfull', 'custom_page', 'favorites_list']; 
            protected	$current_list		= 0; 
            protected	$fastcache			= false; 
            protected   $defaultList		= []; 
            public      $xfields            = []; 
            protected	$favHistory		    = [];             
 
            public function __construct($options = []) { 
                global $db, $member_id, $favorites_config, $FavoritesList; 
 
                if( isset($options['allow_module']) AND count($options['allow_module']) ) { 
 
                    $this->allow_module = array_merge($this->allow_module, $options['allow_module']); 
 
                } 
 
                if ( file_exists( ENGINE_DIR . '/data/favorites_config.php' ) ) { 
 
                    $data 				= @file_get_contents( ENGINE_DIR . '/data/favorites_config.php' ); 
                    $favorites_config 	= json_decode( $data, true ); 
 
                } else $favorites_config = []; 
                 
                if( $_SERVER['REQUEST_METHOD'] == 'POST' AND strpos($_SERVER['QUERY_STRING'], "favorites") !== false ) { 
 
                    if( !favorites_verify($favorites_config['lhash']) ) { 
                        echo json_encode(["error" => true, "content" => 'Key not valid on domain']); 
                        die(); 
                    } 
                }                 
 
                if( isset($favorites_config['remove_list_opt']) ) { 
                    $this->remove_list_opt = $favorites_config['remove_list_opt']; 
                    unset($favorites_config['remove_list_opt']); 
                } 
 
                if( isset($favorites_config['favlist_group_denied']) ) { 
                    $favorites_config['favlist_group_denied'] = explode(',', $favorites_config['favlist_group_denied']); 
                  } else $favorites_config['favlist_group_denied'] = []; 
             
                if ( $favorites_config['fav_cache_type'] ) { 
 
                    if( $favorites_config['fav_cache_type'] == "3" ) { 
 
                        include_once (DLEPlugins::Check(ENGINE_DIR . '/classes/redis.class.php')); 
 
                    } else { 
                         
                        include_once (DLEPlugins::Check(ENGINE_DIR . '/classes/memcache.class.php')); 
 
                    } 
 
                    $this->fastcache = new dle_fastcache($favorites_config); 
 
                }          
 
                $this->loadDefault_list(); 
 
                if( isset($options['disabled_list_init']) AND !$options['disabled_list_init'] OR !isset($options['disabled_list_init']) ) { 
 
                    $this->list = $FavoritesList = new FavoritesList; 
 
                } 
 
            } 
 
            static public function get_uid(){ 
                global $is_logged, $member_id; 
 
                if( $is_logged ) return $member_id['user_id']; 
                else { 
 
                    if( isset($_COOKIE['fuid']) AND is_md5hash($_COOKIE['fuid']) ) return $_COOKIE['fuid']; 
                    else { 
 
                        if(function_exists('openssl_random_pseudo_bytes')) { 
				 
                            $stronghash = md5(openssl_random_pseudo_bytes(15)); 
                             
                        } else $stronghash = md5(uniqid( mt_rand(), TRUE )); 
                             
                        $salt = sha1( str_shuffle("abcdefghjkmnpqrstuvwxyz0123456789") . $stronghash ); 
                        $hash = ''; 
                             
                        for($i = 0; $i < 9; $i ++) { 
                            $hash .= $salt[mt_rand( 0, 39 )]; 
                        } 
                             
                        $hash = md5( $hash ); 
 
                        set_cookie( "fuid", $hash, 365 ); 
                        return $hash; 
 
                    } 
 
                } 
 
            } 
 
            public function get_listCount(){ 
                global $is_logged, $favTypeUser; 
 
                if( !$is_logged ) return -1; 
 
                return count($favTypeUser); 
            }              
 
            static public function get_favCount(){ 
                global $member_id; 
 
                if( !isset($member_id['favorites']) ) return 0; 
 
                return count(explode(',', $member_id['favorites'])); 
            } 
             
            public function get_defaultList(){ 
                 
                return $this->defaultList; 
 
            }             
 
            public function loadData(){ 
                global $db, $member_id, $is_logged, $dle_module, $favType, $favTypeUser, $favorites_config, $mod; 
 
                $_dle_module = $dle_module ? $dle_module : $mod; 
 
                if( !in_array($_dle_module, $this->allow_module) ) { 
 
                    error_log('[Favorites] loadData: Error initialization in dle module'); 
                    return false; 
 
                } 
 
                if( !$favorites_config['enable_guest_favorites'] AND !$is_logged ) { 
 
                    error_log('[Favorites] loadData: Initialization disabled'); 
                    return false; 
 
                } 
 
                $load_data  = false; 
                $uid        = $this->get_uid(); 
                $cache_key  = 'favorites_type_' . $uid; 
  
                if( $is_logged ) { 
                     
                    $favTypeUser	= $this->loadUser_list(); 
                    $favType 		= $this->get_cache($cache_key); 
    
                    if( !is_array( $favType ) ) { 
 
                        $favType_query = $db->query("SELECT type, news_id, note FROM `".PREFIX."_favorites` WHERE name = '" . @$db->safesql( $member_id['name'] ) . "'");	 
 
                        if( $favType_query ) { 
 
                            $favType = []; 
 
                            while ( $data = $db->get_row( $favType_query ) ) { 
 
                                $data['news_id']    = intval($data['news_id']); 
                                $data['type']       = intval($data['type']);                                 
 
                                if( isset($favTypeUser[$data['type']]) ) { 
 
                                    $favType[$data['news_id']][$data['type']] = [ 
                                        'type' => $data['type'], 
                                        'note' => $data['note'] 
                                    ]; 
 
                                } else { 
 
                                    $favType[$data['news_id']] = [ 
                                        'type' => $data['type'], 
                                        'note' => $data['note'] 
                                    ]; 
 
                                } 
 
                            } 
 
                            $db->free( $favType_query );                             
                            $load_data  = true; 
                        } 
 
                    } 
 
                } else { 
                     
                    $favTypeUser	= []; 
                    $favType 		= $this->get_cache($cache_key); 
 
                    if( !is_array( $favType ) ) { 
 
                        $favType_query = $db->query("SELECT type, news_id, note FROM `".PREFIX."_favorites` WHERE hash = '" . $uid . "'");	 
 
                        if( $favType_query ) { 
 
                            $favType = []; 
 
                            while ( $data = $db->get_row( $favType_query ) ) { 
 
                                $data['news_id']    = intval($data['news_id']); 
                                $data['type']       = intval($data['type']); 
 
                                $favType[$data['news_id']] = [ 
                                    'type' => $data['type'],  
                                    'note' => $data['note'] 
                                ]; 
 
                            } 
 
                            $db->free( $favType_query ); 
                            $load_data  = true; 
                        } 
 
                    } 
 
                } 
 
                if( $load_data AND count($favType) ) { 
      
                    $this->set_cache($cache_key, $favType); 
 
                } 
 
                if( count($favType) ) { 
 
                    $member_id['favorites'] = implode(',', array_keys($favType)); 
 
                } 
                 
                return true; 
            } 
 
            public function loadDefault_list() { 
                global $db, $favorites_type; 
 
                $favorites_type = $this->get_vars( "favorites_type" ); 
 
                if ( !is_array( $favorites_type ) ) { 
 
                    $favorites_type = []; 
                    $row_list 		= $db->query( "SELECT id, class_id, name, section, default_list, active, admin_only, posi_id FROM " . PREFIX . "_favorites_list WHERE user_id = '0' ORDER BY posi_id ASC"); 
 
                    while ( $data = $db->get_row( $row_list ) ) { 
 
                        $favorites_type[$data['id']] = [ 
                            'id' 		    => ($data['class_id'] != 'undefined' ? $data['class_id'] : ''), 
                            'name' 		    => $data['name'], 
                            'section' 	    => $data['section'], 
                            'default'       => (int)$data['default_list'], 
                            'active'	    => (int)$data['active'], 
                            'admin_only'	=> (int)$data['admin_only'], 
                            'posi_id'	    => (int)$data['posi_id'] 
                        ]; 
 
                    } 
 
                    $db->free( $row_list ); 
 
                    $this->set_vars ( "favorites_type", $favorites_type ); 
                } 
 
                if( count($favorites_type) ) { 
 
                    $_defaultType_list = array_filter($favorites_type, function($v, $k){ 
                        //if( !$v['default'] ) return false; 
                        return ( $v['default'] ? true : false); 
                    }, ARRAY_FILTER_USE_BOTH); 
 
                    $this->defaultList = array_keys($_defaultType_list); 
 
                } 
 
                return true; 
            } 
 
            public function loadUser_list() { 
                global $db, $member_id; 
 
                $favTypeUser 	= []; 
                $query_list 	= $db->query( "SELECT * FROM " . PREFIX . "_favorites_list WHERE user_id = '{$member_id['user_id']}'"); 
 
                if( $query_list ) { 
 
                    while ( $data = $db->get_row( $query_list ) ) { 
 
                        $favTypeUser[$data['id']] = [ 
                            'id'		=> ($data['class_id'] != 'undefined' ? $data['class_id'] : ''), 
                            'name'		=> $data['name'], 
                            'section'	=> $data['section'] 
                        ];  
 
                    } 
 
                    $db->free( $query_list ); 
 
                } 
 
                return $favTypeUser; 
 
            } 
 
            protected function check_group( $matches ) { 
                global $member_id; 
         
                $regex = '/\[(group|not-group)=(.*?)\]((?>(?R)|.)*?)\[\/\]/is'; 
         
                if (is_array($matches)) { 
         
                    $groups = $matches[2]; 
                    $block  = $matches[3]; 
             
                    if ($matches[1] == "group") $action = true; else $action = false; 
                     
                    $groups = explode( ',', $groups ); 
                     
                    if( $action ) { 
                         
                        if( ! in_array( $member_id['user_group'], $groups ) ) $matches = ''; else $matches = $block; 
                     
                    } else { 
                         
                        if( in_array( $member_id['user_group'], $groups ) ) $matches = ''; else $matches = $block; 
                     
                    } 
                } 
                 
                return preg_replace_callback($regex, [&$this, 'check_group'], $matches); 
             
            }             
 
            public function parseTpl($template) { 
 
                if( $template == '' ) return $template; 
 
                if (stripos ( $template, "[group=" ) !== false OR stripos ( $template, "[not-group=" ) !== false) { 
                    $template = $this->check_group($template); 
                }                
 
                return $template; 
 
            } 
 
            public function clear_cache($key = false) { 
                global $favorites_config; 
 
                if( !$key ) return false; 
 
                if( in_array($favorites_config['fav_cache_type'], [2,3]) ) { 
             
                    if( $this->fastcache->connection > 0 ) { 
         
                        $this->fastcache->clear( $key ); 
         
                    } 
                 
                } elseif( $favorites_config['fav_cache_type'] == 1 ) { 
                 
                    @unlink( ENGINE_DIR . "/cache/system/fav_list/{$key}.php" ); 
                 
                }			 
                error_log($key); 
                return true; 
             
            } 
 
            public function clear_cache_all() { 
                global $favorites_config; 
 
                if( in_array($favorites_config['fav_cache_type'], [2,3]) ) { 
             
                    if( $this->fastcache->connection > 0 ) { 
         
                        $this->fastcache->clear( $key ); 
         
                    } 
                 
                } elseif( $favorites_config['fav_cache_type'] == 1 ) { 
                     
                    $this->listdir( ENGINE_DIR . '/cache/system/fav_list' ); 
                    @unlink( ENGINE_DIR . '/cache/system/favorites_type.php' ); 
                 
                }			 
             
                return true; 
             
            }             
 
            public function set_cache($key = false, $data = []) { 
                global $favorites_config; 
 
                $data = (array)$data; 
 
                if( !$key OR !count($data) OR !$favorites_config['fav_cache_type'] ) return false; 
 
                if( in_array($favorites_config['fav_cache_type'], [2,3]) ) { 
 
                    if( $this->fastcache->connection > 0 ) { 
                        if( is_array($data) ) { 
 
                            $data = json_encode( $data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); 
                            $this->fastcache->set( $key, $data ); 
 
                        } 
                    }	 
 
                } elseif( $favorites_config['fav_cache_type'] == 1 ) { 
                 
                    $this->set_vars( $key, $data, "/cache/system/fav_list/" ); 
 
                } 
                 
                return true; 
                 
            } 
 
            public function get_cache($key = false) { 
                global $favorites_config; 
 
                if( !$key ) return false; 
 
                if( in_array($favorites_config['fav_cache_type'], [2,3]) ) { 
 
                    if( $this->fastcache->connection > 0 ) { 
 
                        $data = $this->fastcache->get($key); 
                        $data = json_decode( $data, true ); 
 
                    }               
 
                } elseif( $favorites_config['fav_cache_type'] == 1 ) { 
 
                    if( !is_dir( ENGINE_DIR . "/cache/system/fav_list/" ) ) { 
 
                        @mkdir( ENGINE_DIR . "/cache/system/fav_list/", 0777 ); 
                        @chmod( ENGINE_DIR . "/cache/system/fav_list/", 0777 ); 
 
                    }			 
 
                    $data = $this->get_vars( $key, "/cache/system/fav_list/" ); 
 
                } 
 
                return $data; 
            }		 
 
            public function set_vars($file, $data, $path = false) { 
 
                $file = totranslit($file, true, false); 
 
                if( !$path ) $path = ENGINE_DIR . '/cache/system/'; 
                else $path = ENGINE_DIR . $path; 
 
                if ( is_array($data) OR is_int($data) OR is_string($data) ) { 
 
                    file_put_contents ($path . $file . '.php', json_encode( $data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ), LOCK_EX); 
                    @chmod( $path . $file . '.php', 0666 ); 
 
                } 
 
            } 
 
            public function get_vars($file, $path = false) { 
                $file = totranslit($file, true, false); 
 
                if( !$path ) $path = ENGINE_DIR . '/cache/system/'; 
                else $path = ENGINE_DIR . $path; 
                 
                $data = @file_get_contents( $path . $file . '.php' ); 
 
                if ( $data !== false ) { 
 
                    $data = json_decode( $data, true ); 
                    if ( is_array($data) OR is_int($data) OR is_string($data) ) return $data; 
 
                } 
 
                return false; 
            } 
 
            private function check_list( $matches = [] ) { 
 
                $id 	= $matches[2]; 
                $block 	= $matches[3]; 
 
                if ($matches[1] == "isset-fav") $action = true; else $action = false; 
 
                $id 			= explode( ',', $id ); 
                $current_list 	= intval($this->current_list); 
 
                if ( $page < 1 ) $page = 1; 
 
                if( $action ) { 
 
                    if( !$this->_in_rangearray( $current_list, $id ) ) return ""; 
 
                } else { 
 
                    if( $this->_in_rangearray( $current_list, $id ) ) return ""; 
 
                } 
 
                return $block; 
 
            } 
 
            private function _in_rangearray($findvalue, $findarray) { 
 
                $findvalue = trim($findvalue); 
 
                foreach ($findarray as $value) { 
 
                    $value = trim($value); 
 
                    if( $value == $findvalue ) { 
 
                        return true; 
 
                    } elseif( count(explode('-', $value)) == 2 ) { 
 
                        list($min, $max) = explode('-', $value); 
 
                        $findvalue = intval($findvalue); 
                        $min = intval($min); 
                        $max = intval($max); 
 
                        if( $findvalue >= $min && $findvalue <= $max ) { 
                            return true; 
                        } 
 
                    } 
                } 
 
                return false; 
 
            } 
 
            private function listdir($dir) { 
	 
                $current_dir = @opendir( $dir ); 
                 
                if($current_dir !== false ) { 
                    while ( $entryname = readdir( $current_dir ) ) { 
                        if( is_dir( $dir."/".$entryname ) AND ($entryname != "." AND $entryname != "..") ) { 
                            $this->listdir( $dir."/".$entryname ); 
                        } elseif( $entryname != "." AND $entryname != ".." ) { 
                            @unlink( $dir."/".$entryname ); 
                        } 
                    } 
                    @closedir( $current_dir ); 
                    @rmdir( $dir ); 
                } 
             
            } 
             
            public function __destruct() {}             
 
        }

Did this file decode correctly?

Original Code

        class Favorites {

            protected   $remove_list_opt	= true;
            protected   $allow_module		= ['main', 'cat', 'favorites', 'showfull', 'custom_page', 'favorites_list'];
            protected	$current_list		= 0;
            protected	$fastcache			= false;
            protected   $defaultList		= [];
            public      $xfields            = [];
            protected	$favHistory		    = [];            

            public function __construct($options = []) {
                global $db, $member_id, $favorites_config, $FavoritesList;

                if( isset($options['allow_module']) AND count($options['allow_module']) ) {

                    $this->allow_module = array_merge($this->allow_module, $options['allow_module']);

                }

                if ( file_exists( ENGINE_DIR . '/data/favorites_config.php' ) ) {

                    $data 				= @file_get_contents( ENGINE_DIR . '/data/favorites_config.php' );
                    $favorites_config 	= json_decode( $data, true );

                } else $favorites_config = [];
                
                if( $_SERVER['REQUEST_METHOD'] == 'POST' AND strpos($_SERVER['QUERY_STRING'], "favorites") !== false ) {

                    if( !favorites_verify($favorites_config['lhash']) ) {
                        echo json_encode(["error" => true, "content" => 'Key not valid on domain']);
                        die();
                    }
                }                

                if( isset($favorites_config['remove_list_opt']) ) {
                    $this->remove_list_opt = $favorites_config['remove_list_opt'];
                    unset($favorites_config['remove_list_opt']);
                }

                if( isset($favorites_config['favlist_group_denied']) ) {
                    $favorites_config['favlist_group_denied'] = explode(',', $favorites_config['favlist_group_denied']);
                  } else $favorites_config['favlist_group_denied'] = [];
            
                if ( $favorites_config['fav_cache_type'] ) {

                    if( $favorites_config['fav_cache_type'] == "3" ) {

                        include_once (DLEPlugins::Check(ENGINE_DIR . '/classes/redis.class.php'));

                    } else {
                        
                        include_once (DLEPlugins::Check(ENGINE_DIR . '/classes/memcache.class.php'));

                    }

                    $this->fastcache = new dle_fastcache($favorites_config);

                }         

                $this->loadDefault_list();

                if( isset($options['disabled_list_init']) AND !$options['disabled_list_init'] OR !isset($options['disabled_list_init']) ) {

                    $this->list = $FavoritesList = new FavoritesList;

                }

            }

            static public function get_uid(){
                global $is_logged, $member_id;

                if( $is_logged ) return $member_id['user_id'];
                else {

                    if( isset($_COOKIE['fuid']) AND is_md5hash($_COOKIE['fuid']) ) return $_COOKIE['fuid'];
                    else {

                        if(function_exists('openssl_random_pseudo_bytes')) {
				
                            $stronghash = md5(openssl_random_pseudo_bytes(15));
                            
                        } else $stronghash = md5(uniqid( mt_rand(), TRUE ));
                            
                        $salt = sha1( str_shuffle("abcdefghjkmnpqrstuvwxyz0123456789") . $stronghash );
                        $hash = '';
                            
                        for($i = 0; $i < 9; $i ++) {
                            $hash .= $salt[mt_rand( 0, 39 )];
                        }
                            
                        $hash = md5( $hash );

                        set_cookie( "fuid", $hash, 365 );
                        return $hash;

                    }

                }

            }

            public function get_listCount(){
                global $is_logged, $favTypeUser;

                if( !$is_logged ) return -1;

                return count($favTypeUser);
            }             

            static public function get_favCount(){
                global $member_id;

                if( !isset($member_id['favorites']) ) return 0;

                return count(explode(',', $member_id['favorites']));
            }
            
            public function get_defaultList(){
                
                return $this->defaultList;

            }            

            public function loadData(){
                global $db, $member_id, $is_logged, $dle_module, $favType, $favTypeUser, $favorites_config, $mod;

                $_dle_module = $dle_module ? $dle_module : $mod;

                if( !in_array($_dle_module, $this->allow_module) ) {

                    error_log('[Favorites] loadData: Error initialization in dle module');
                    return false;

                }

                if( !$favorites_config['enable_guest_favorites'] AND !$is_logged ) {

                    error_log('[Favorites] loadData: Initialization disabled');
                    return false;

                }

                $load_data  = false;
                $uid        = $this->get_uid();
                $cache_key  = 'favorites_type_' . $uid;
 
                if( $is_logged ) {
                    
                    $favTypeUser	= $this->loadUser_list();
                    $favType 		= $this->get_cache($cache_key);
   
                    if( !is_array( $favType ) ) {

                        $favType_query = $db->query("SELECT type, news_id, note FROM `".PREFIX."_favorites` WHERE name = '" . @$db->safesql( $member_id['name'] ) . "'");	

                        if( $favType_query ) {

                            $favType = [];

                            while ( $data = $db->get_row( $favType_query ) ) {

                                $data['news_id']    = intval($data['news_id']);
                                $data['type']       = intval($data['type']);                                

                                if( isset($favTypeUser[$data['type']]) ) {

                                    $favType[$data['news_id']][$data['type']] = [
                                        'type' => $data['type'],
                                        'note' => $data['note']
                                    ];

                                } else {

                                    $favType[$data['news_id']] = [
                                        'type' => $data['type'],
                                        'note' => $data['note']
                                    ];

                                }

                            }

                            $db->free( $favType_query );                            
                            $load_data  = true;
                        }

                    }

                } else {
                    
                    $favTypeUser	= [];
                    $favType 		= $this->get_cache($cache_key);

                    if( !is_array( $favType ) ) {

                        $favType_query = $db->query("SELECT type, news_id, note FROM `".PREFIX."_favorites` WHERE hash = '" . $uid . "'");	

                        if( $favType_query ) {

                            $favType = [];

                            while ( $data = $db->get_row( $favType_query ) ) {

                                $data['news_id']    = intval($data['news_id']);
                                $data['type']       = intval($data['type']);

                                $favType[$data['news_id']] = [
                                    'type' => $data['type'], 
                                    'note' => $data['note']
                                ];

                            }

                            $db->free( $favType_query );
                            $load_data  = true;
                        }

                    }

                }

                if( $load_data AND count($favType) ) {
     
                    $this->set_cache($cache_key, $favType);

                }

                if( count($favType) ) {

                    $member_id['favorites'] = implode(',', array_keys($favType));

                }
                
                return true;
            }

            public function loadDefault_list() {
                global $db, $favorites_type;

                $favorites_type = $this->get_vars( "favorites_type" );

                if ( !is_array( $favorites_type ) ) {

                    $favorites_type = [];
                    $row_list 		= $db->query( "SELECT id, class_id, name, section, default_list, active, admin_only, posi_id FROM " . PREFIX . "_favorites_list WHERE user_id = '0' ORDER BY posi_id ASC");

                    while ( $data = $db->get_row( $row_list ) ) {

                        $favorites_type[$data['id']] = [
                            'id' 		    => ($data['class_id'] != 'undefined' ? $data['class_id'] : ''),
                            'name' 		    => $data['name'],
                            'section' 	    => $data['section'],
                            'default'       => (int)$data['default_list'],
                            'active'	    => (int)$data['active'],
                            'admin_only'	=> (int)$data['admin_only'],
                            'posi_id'	    => (int)$data['posi_id']
                        ];

                    }

                    $db->free( $row_list );

                    $this->set_vars ( "favorites_type", $favorites_type );
                }

                if( count($favorites_type) ) {

                    $_defaultType_list = array_filter($favorites_type, function($v, $k){
                        //if( !$v['default'] ) return false;
                        return ( $v['default'] ? true : false);
                    }, ARRAY_FILTER_USE_BOTH);

                    $this->defaultList = array_keys($_defaultType_list);

                }

                return true;
            }

            public function loadUser_list() {
                global $db, $member_id;

                $favTypeUser 	= [];
                $query_list 	= $db->query( "SELECT * FROM " . PREFIX . "_favorites_list WHERE user_id = '{$member_id['user_id']}'");

                if( $query_list ) {

                    while ( $data = $db->get_row( $query_list ) ) {

                        $favTypeUser[$data['id']] = [
                            'id'		=> ($data['class_id'] != 'undefined' ? $data['class_id'] : ''),
                            'name'		=> $data['name'],
                            'section'	=> $data['section']
                        ]; 

                    }

                    $db->free( $query_list );

                }

                return $favTypeUser;

            }

            protected function check_group( $matches ) {
                global $member_id;
        
                $regex = '/\[(group|not-group)=(.*?)\]((?>(?R)|.)*?)\[\/\1\]/is';
        
                if (is_array($matches)) {
        
                    $groups = $matches[2];
                    $block  = $matches[3];
            
                    if ($matches[1] == "group") $action = true; else $action = false;
                    
                    $groups = explode( ',', $groups );
                    
                    if( $action ) {
                        
                        if( ! in_array( $member_id['user_group'], $groups ) ) $matches = ''; else $matches = $block;
                    
                    } else {
                        
                        if( in_array( $member_id['user_group'], $groups ) ) $matches = ''; else $matches = $block;
                    
                    }
                }
                
                return preg_replace_callback($regex, [&$this, 'check_group'], $matches);
            
            }            

            public function parseTpl($template) {

                if( $template == '' ) return $template;

                if (stripos ( $template, "[group=" ) !== false OR stripos ( $template, "[not-group=" ) !== false) {
                    $template = $this->check_group($template);
                }               

                return $template;

            }

            public function clear_cache($key = false) {
                global $favorites_config;

                if( !$key ) return false;

                if( in_array($favorites_config['fav_cache_type'], [2,3]) ) {
            
                    if( $this->fastcache->connection > 0 ) {
        
                        $this->fastcache->clear( $key );
        
                    }
                
                } elseif( $favorites_config['fav_cache_type'] == 1 ) {
                
                    @unlink( ENGINE_DIR . "/cache/system/fav_list/{$key}.php" );
                
                }			
                error_log($key);
                return true;
            
            }

            public function clear_cache_all() {
                global $favorites_config;

                if( in_array($favorites_config['fav_cache_type'], [2,3]) ) {
            
                    if( $this->fastcache->connection > 0 ) {
        
                        $this->fastcache->clear( $key );
        
                    }
                
                } elseif( $favorites_config['fav_cache_type'] == 1 ) {
                    
                    $this->listdir( ENGINE_DIR . '/cache/system/fav_list' );
                    @unlink( ENGINE_DIR . '/cache/system/favorites_type.php' );
                
                }			
            
                return true;
            
            }            

            public function set_cache($key = false, $data = []) {
                global $favorites_config;

                $data = (array)$data;

                if( !$key OR !count($data) OR !$favorites_config['fav_cache_type'] ) return false;

                if( in_array($favorites_config['fav_cache_type'], [2,3]) ) {

                    if( $this->fastcache->connection > 0 ) {
                        if( is_array($data) ) {

                            $data = json_encode( $data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES );
                            $this->fastcache->set( $key, $data );

                        }
                    }	

                } elseif( $favorites_config['fav_cache_type'] == 1 ) {
                
                    $this->set_vars( $key, $data, "/cache/system/fav_list/" );

                }
                
                return true;
                
            }

            public function get_cache($key = false) {
                global $favorites_config;

                if( !$key ) return false;

                if( in_array($favorites_config['fav_cache_type'], [2,3]) ) {

                    if( $this->fastcache->connection > 0 ) {

                        $data = $this->fastcache->get($key);
                        $data = json_decode( $data, true );

                    }              

                } elseif( $favorites_config['fav_cache_type'] == 1 ) {

                    if( !is_dir( ENGINE_DIR . "/cache/system/fav_list/" ) ) {

                        @mkdir( ENGINE_DIR . "/cache/system/fav_list/", 0777 );
                        @chmod( ENGINE_DIR . "/cache/system/fav_list/", 0777 );

                    }			

                    $data = $this->get_vars( $key, "/cache/system/fav_list/" );

                }

                return $data;
            }		

            public function set_vars($file, $data, $path = false) {

                $file = totranslit($file, true, false);

                if( !$path ) $path = ENGINE_DIR . '/cache/system/';
                else $path = ENGINE_DIR . $path;

                if ( is_array($data) OR is_int($data) OR is_string($data) ) {

                    file_put_contents ($path . $file . '.php', json_encode( $data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ), LOCK_EX);
                    @chmod( $path . $file . '.php', 0666 );

                }

            }

            public function get_vars($file, $path = false) {
                $file = totranslit($file, true, false);

                if( !$path ) $path = ENGINE_DIR . '/cache/system/';
                else $path = ENGINE_DIR . $path;
                
                $data = @file_get_contents( $path . $file . '.php' );

                if ( $data !== false ) {

                    $data = json_decode( $data, true );
                    if ( is_array($data) OR is_int($data) OR is_string($data) ) return $data;

                }

                return false;
            }

            private function check_list( $matches = [] ) {

                $id 	= $matches[2];
                $block 	= $matches[3];

                if ($matches[1] == "isset-fav") $action = true; else $action = false;

                $id 			= explode( ',', $id );
                $current_list 	= intval($this->current_list);

                if ( $page < 1 ) $page = 1;

                if( $action ) {

                    if( !$this->_in_rangearray( $current_list, $id ) ) return "";

                } else {

                    if( $this->_in_rangearray( $current_list, $id ) ) return "";

                }

                return $block;

            }

            private function _in_rangearray($findvalue, $findarray) {

                $findvalue = trim($findvalue);

                foreach ($findarray as $value) {

                    $value = trim($value);

                    if( $value == $findvalue ) {

                        return true;

                    } elseif( count(explode('-', $value)) == 2 ) {

                        list($min, $max) = explode('-', $value);

                        $findvalue = intval($findvalue);
                        $min = intval($min);
                        $max = intval($max);

                        if( $findvalue >= $min && $findvalue <= $max ) {
                            return true;
                        }

                    }
                }

                return false;

            }

            private function listdir($dir) {
	
                $current_dir = @opendir( $dir );
                
                if($current_dir !== false ) {
                    while ( $entryname = readdir( $current_dir ) ) {
                        if( is_dir( $dir."/".$entryname ) AND ($entryname != "." AND $entryname != "..") ) {
                            $this->listdir( $dir."/".$entryname );
                        } elseif( $entryname != "." AND $entryname != ".." ) {
                            @unlink( $dir."/".$entryname );
                        }
                    }
                    @closedir( $current_dir );
                    @rmdir( $dir );
                }
            
            }
            
            public function __destruct() {}            

        }

Function Calls

None

Variables

None

Stats

MD5 6f4ae81b888484cbbe555dcdda660dcb
Eval Count 0
Decode Time 78 ms