Example #1
0
 function compact_info()
 {
     main()->NO_GRAPHICS = true;
     conf('no_ajax_here', true);
     // Check user id
     $USER_ID = $_REQUEST["id"];
     if (empty($USER_ID)) {
         $error_message = "No id";
     }
     if (empty($error_message)) {
         // Try to get user info
         $this->_user_info = db()->query_fetch("SELECT * FROM " . db('user') . " WHERE id=" . intval($USER_ID) . " AND active='1'");
         if (empty($this->_user_info)) {
             $error_message = "No info";
         }
     }
     if (empty($error_message)) {
         // Get live quick user stats
         $totals = _class_safe("user_stats")->_get_live_stats(["user_id" => $this->_user_info["id"]]);
         // Check if this user is in favorites (also check if this is own profile)
         $DISPLAY_CONTACT_ITEMS = 0;
         if (main()->USER_ID && $this->_user_info["id"] != main()->USER_ID) {
             if ($totals["favorite_users"]) {
                 $is_in_favorites = db()->query_num_rows("SELECT 1 FROM " . db('favorites') . " WHERE user_id=" . intval(main()->USER_ID) . " AND target_user_id=" . intval($this->_user_info["id"]));
             }
             if ($totals["ignored_users"]) {
                 $is_ignored = db()->query_num_rows("SELECT 1 FROM " . db('ignore_list') . " WHERE user_id=" . intval(main()->USER_ID) . " AND target_user_id=" . intval($this->_user_info["id"]));
             }
             // Check friendship
             $FRIENDS_OBJ = module("friends");
             $is_a_friend = is_object($FRIENDS_OBJ) ? $FRIENDS_OBJ->_is_a_friend(main()->USER_ID, $this->_user_info["id"]) : -1;
             if (!empty($totals["try_friends"])) {
                 $is_friend_of = $FRIENDS_OBJ->_is_a_friend($this->_user_info["id"], main()->USER_ID);
             }
             $is_mutual_friends = $is_a_friend && $is_friend_of;
             // Switch for contact items
             $DISPLAY_CONTACT_ITEMS = 1;
         }
         // Interests
         $totals["interests"] = 0;
         if (!empty($totals["try_interests"])) {
             $INTERESTS_OBJ = module("interests");
             if (is_object($INTERESTS_OBJ)) {
                 $user_interests = $INTERESTS_OBJ->_get_for_user_id($user_id);
                 if (!empty($user_interests) && is_array($user_interests)) {
                     $totals["interests"] = count($user_interests);
                 }
             }
         }
         // Process user reputation
         $reput_text = "";
         $REPUT_OBJ = module("reputation");
         if (is_object($REPUT_OBJ)) {
             $reput_info = ["points" => $totals["reput_points"]];
             $reput_text = $REPUT_OBJ->_show_for_user($this->_user_info["id"], $reput_info);
         }
         // Array of $_GET vars to skip
         $skip_get = ["page", "escort_id", "q", "show"];
         if (empty($this->_user_info["last_login"])) {
             $this->_user_info["last_login"] = $this->_user_info["add_date"];
         }
         // Process template
         $replace = ["user_id" => intval($USER_ID), "user_avatar" => _show_avatar($USER_ID), "user_name" => _prepare_html(_display_name($this->_user_info)), "user_group" => t($this->_account_types[$this->_user_info["group"]]), "user_profile_link" => process_url(_profile_link($USER_ID)), "user_level" => intval($this->_user_info["level"]), "user_level_name" => _prepare_html($this->_user_levels[$this->_user_info["level"]]), "emails_received" => intval($this->_user_info["emails"]), "emails_sent" => intval($this->_user_info["emailssent"]), "reg_date" => _format_date($this->_user_info["add_date"]), "last_update" => _format_date($this->_user_info["last_update"], "long"), "last_login" => _format_date($this->_user_info["last_login"], "long"), "num_logins" => intval($this->_user_info["num_logins"]), "site_visits" => intval($this->_user_info["sitevisits"]), "gallery_link" => $totals["gallery_photos"] ? process_url("./?object=gallery&action=show_gallery&id=" . $this->_user_info["id"] . _add_get($skip_get)) : "", "blog_link" => $totals["blog_posts"] ? process_url("./?object=blog&action=show_posts&id=" . $this->_user_info["id"] . _add_get($skip_get)) : "", "articles_link" => $totals["articles"] ? process_url("./?object=articles&action=view_by_user&id=" . $this->_user_info["id"] . _add_get($skip_get)) : "", "interests_link" => $totals["interests"] ? process_url("./?object=interests&action=view&id=" . $this->_user_info["id"] . _add_get($skip_get)) : "", "contact_link" => main()->USER_ID && main()->USER_ID != $this->_user_info["id"] ? process_url(main()->USER_ID ? "./?object=email&action=send_form&id=" . $this->_user_info["id"] : "./?object=login_form&go_url=email;send_form;id=" . $this->_user_info["id"]) : "", "favorites_link" => !empty($is_in_favorites) ? process_url("./?object=account&action=favorite_delete&id=" . $this->_user_info["id"]) : process_url("./?object=account&action=favorite_add&id=" . $this->_user_info["id"]), "is_in_favorites" => isset($is_in_favorites) ? intval((bool) $is_in_favorites) : "", "ignore_link" => !empty($is_ignored) ? process_url("./?object=account&action=unignore_user&id=" . $this->_user_info["id"]) : process_url("./?object=account&action=ignore_user&id=" . $this->_user_info["id"]), "is_ignored" => isset($is_ignored) ? intval((bool) $is_ignored) : "", "make_friend_link" => empty($is_a_friend) ? process_url("./?object=friends&action=add&id=" . $this->_user_info["id"]) : "", "is_a_friend" => isset($is_a_friend) ? intval($is_a_friend) : "", "is_friend_of" => isset($is_friend_of) ? intval($is_friend_of) : "", "is_mutual_friends" => isset($is_mutual_friends) ? intval($is_mutual_friends) : "", "display_contact_items" => intval($DISPLAY_CONTACT_ITEMS), "sex" => _prepare_html($this->_user_info["sex"]), "country" => _prepare_html($this->_user_info["country"]), "state" => _prepare_html($this->_user_info["state"]), "city" => _prepare_html($this->_user_info["city"]), "country_code_lower" => strtolower($this->_user_info["country"]), "reput_text" => $reput_text, "reput_points" => MAIN_TYPE_ADMIN ? intval($totals["reput_points"]) : "", "alt_power" => MAIN_TYPE_ADMIN ? intval($REPUT_INFO["alt_power"]) : "", "activity_points" => intval($totals["activity_points"]), "is_admin" => MAIN_TYPE_ADMIN ? 1 : 0];
         // Admin-only methods
         if (MAIN_TYPE_ADMIN) {
             $replace = array_merge($replace, ["login_stats" => process_url("./?object=log_auth_view&action=save_filter&user_id=" . $this->_user_info["id"]), "multi_accounts_link" => process_url("./?object=check_multi_accounts&action=show_by_user&id=" . $this->_user_info["id"]), "user_errors" => process_url("./?object=log_user_errors_viewer&action=save_filter&user_id=" . $this->_user_info["id"]), "ban_popup_link" => _class("manage_auto_ban", "admin_modules/")->_popup_link(["user_id" => intval($this->_user_info["id"])]), "verify_link" => !$this->_user_info["photo_verified"] ? "./?object=manage_photo_verify&action=add&id=" . intval($this->_user_info["id"]) : ""]);
         }
         $body = tpl()->parse($_GET["object"] . "/compact_info", $replace);
     }
     if (!empty($error_message)) {
         $body = $error_message;
     }
     if (DEBUG_MODE) {
         $body .= "<hr class='clearfloat'>DEBUG INFO:\r\n";
         $body .= common()->_show_execution_time();
         //			$body .= common()->show_debug_info();
     }
     echo $body;
 }
 protected function _firewall($class = null, $class_path = null, $method = null, $options = [])
 {
     if ($class && $class_path) {
         $_class = _class_safe($class, $class_path);
     } else {
         $_class = $this;
     }
     empty($method) && ($method = $_GET['api']);
     $_method = '_api_' . $method;
     $_status = method_exists($_class, $_method);
     if (!$_status) {
         $this->_reject();
     }
     return $_class->{$_method}($options);
 }
Example #3
0
 /**
  * Process text to show
  */
 function _process_text($body = '', $no_smilies = false, $smilies_as_image = false)
 {
     if (empty($body)) {
         return '';
     }
     $this->_preload_data();
     $body = str_replace(['<', '>'], ['&lt;', '&gt;'], $body);
     if ($this->FILTER_BAD_WORDS) {
         if (!isset($GLOBALS['BAD_WORDS_ARRAY'])) {
             $Q = db()->query('SELECT word FROM ' . db('badwords') . '');
             while ($A = db()->fetch_assoc($Q)) {
                 $GLOBALS['BAD_WORDS_ARRAY'] = $A['word'];
             }
         }
         $body = str_replace($GLOBALS['BAD_WORDS_ARRAY'], '', $body);
     }
     if ($this->CHECK_WORDS_LENGTH) {
         $body = _check_words_length($body);
     }
     if ($this->ENABLE_BB_CODES) {
         if (false !== strpos($body, '[')) {
             if ($this->CHECK_CODES_IF_CLOSED) {
                 $body = $this->_force_close_bb_codes($body);
             }
             $body = preg_replace(array_keys($this->_preg_bb_codes), array_values($this->_preg_bb_codes), $body);
             if ($this->USE_HIGHLIGHT) {
                 $body = preg_replace_callback('/\\[sql\\](.*?)\\[\\/sql\\]/ims', function ($m) {
                     return _class_safe('text_highlight', 'classes/common/')->_regex_sql_tag(stripslashes($m[1]));
                 }, $body);
                 $body = preg_replace_callback('/\\[html\\](.*?)\\[\\/html\\]/ims', function ($m) {
                     return _class_safe('text_highlight', 'classes/common/')->_regex_html_tag(stripslashes($m[1]));
                 }, $body);
             }
             $_this = $this;
             $body = preg_replace_callback('/\\[csv\\](.*?)\\[\\/csv\\]/ims', function ($m) use($_this) {
                 return $_this->_parse_csv_bb_code($m[1]);
             }, $body);
         }
         if ($this->ENABLE_SMILIES && is_array($GLOBALS['_smiles_array']) && empty($no_smilies)) {
             if (!empty($GLOBALS['_SMILIES_CACHE'])) {
                 $this->_smilies_replace =& $GLOBALS['_SMILIES_CACHE'];
             } else {
                 $smilies_as_image = 0;
                 if ($this->SMILIES_AS_IMAGES) {
                     $smilies_as_image = true;
                 }
                 foreach ((array) $GLOBALS['_smiles_array'] as $smile_info) {
                     $replace = ['img_src' => WEB_PATH . $this->SMILIES_DIR . $smile_info['url'], 'img_alt' => _prepare_html($smile_info['emoticon']), 'css_class' => $this->CSS_CLASSES['smile'], 'text' => _prepare_html($smile_info['code']), 'as_image' => intval($smilies_as_image)];
                     $this->_smilies_replace[$smile_info['code']] = tpl()->parse('system/smile_item', $replace);
                 }
                 $GLOBALS['_SMILIES_CACHE'] = $this->_smilies_replace;
             }
         }
         if (!empty($this->_smilies_replace)) {
             $body = str_replace(array_keys($this->_smilies_replace), array_values($this->_smilies_replace), $body);
         }
     }
     $body = nl2br($body);
     return $body;
 }
Example #4
0
    /**
     * Form to add comments
     */
    function _add($params = [])
    {
        if (empty(main()->USER_ID) && MAIN_TYPE_USER && !$params['allow_guests_posts']) {
            return '';
        }
        $_GET['id'] = intval($_GET['id']);
        $OBJECT_NAME = !empty($params['object_name']) ? $params['object_name'] : $_GET['object'];
        $OBJECT_ID = !empty($params['object_id']) ? intval($params['object_id']) : intval($_GET['id']);
        $FORM_ACTION = !empty($params['add_form_action']) ? $params['add_form_action'] : './?object=' . $_GET['object'] . '&action=add_comment&id=' . $OBJECT_ID;
        $STPL_NAME_ADD = !empty($params['stpl_add']) ? $params['stpl_add'] : 'comments/add_form';
        $RETURN_PATH = $_SERVER['HTTP_REFERER'];
        if (!empty($params['return_path'])) {
            $RETURN_PATH = process_url($params['return_path']);
        } elseif (!empty($params['return_action'])) {
            $RETURN_PATH = process_url('./?object=' . $_GET['object'] . '&action=' . $params['return_action'] . '&id=' . $OBJECT_ID);
        }
        if (empty($OBJECT_NAME) || empty($OBJECT_ID)) {
            return '';
        }
        $COMMENT_IS_ALLOWED = true;
        if (is_object(module($_GET['object']))) {
            $m = module('comments')->_add_allowed_method;
            $COMMENT_IS_ALLOWED = module($_GET['object'])->{$m}($params);
        }
        if (!$COMMENT_IS_ALLOWED && common()->_error_exists()) {
            return _e();
        }
        if (!$COMMENT_IS_ALLOWED) {
            return false;
        }
        if (count($_POST) > 0 && !isset($_POST['_not_for_comments'])) {
            if (isset($_POST['text2']) && !isset($_POST['text'])) {
                $_POST['text'] = $_POST['text2'];
                unset($_POST['text2']);
            }
            if (!common()->_error_exists()) {
                $_POST['text'] = substr($_POST['text'], 0, module('comments')->MAX_POST_TEXT_LENGTH);
                if (empty($_POST['text'])) {
                    _re('Comment text required');
                }
            }
            if (module($_GET['object'])->USE_CAPTCHA) {
                if (module('comments')->USE_TREE_MODE && isset($_POST['parent_id'])) {
                    if (empty(main()->USER_ID)) {
                        module($_GET['object'])->_captcha_check();
                    }
                } else {
                    module($_GET['object'])->_captcha_check();
                }
            }
            if (!common()->_error_exists() && MAIN_TYPE_USER) {
                $info_for_check = ['comment_text' => $_POST['text'], 'user_id' => main()->USER_ID];
                $USER_BANNED = _check_user_ban($info_for_check, module('comments')->_user_info);
                if ($USER_BANNED) {
                    module('comments')->_user_info = user(main()->USER_ID);
                }
                if (module('comments')->_user_info['ban_comments']) {
                    return _e('Sorry, you are not allowed to post comments!' . PHP_EOL . 'Perhaps, you broke some of our rules and moderator has banned you from using this feature. Please, enjoy our site in some other way!' . 'For more details <a href=\'./?object=faq&action=view&id=16\'>click here</a>');
                }
            }
            if (!common()->_error_exists() && module('comments')->ANTI_FLOOD_TIME && MAIN_TYPE_USER) {
                $FLOOD_DETECTED = db()->query_fetch('SELECT id,add_date FROM ' . db('comments') . ' 
					WHERE ' . (main()->USER_ID ? 'user_id=' . intval(main()->USER_ID) : 'ip="' . _es(common()->get_ip()) . '"') . ' AND add_date > ' . (time() - module('comments')->ANTI_FLOOD_TIME) . ' 
					ORDER BY add_date DESC LIMIT 1');
                if (!empty($FLOOD_DETECTED)) {
                    _re('Please wait %num seconds before post comment.', ['%num' => intval(module('comments')->ANTI_FLOOD_TIME - (time() - $FLOOD_DETECTED['add_date']))]);
                }
            }
            if (!common()->_error_exists()) {
                if (module('comments')->ANTI_SPAM_DETECT) {
                    $this->_spam_check($_POST['text']);
                }
            }
            if (!empty($_POST['user_email'])) {
                if (!preg_match('#^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$#i', $_POST['user_email'])) {
                    _re('Invalid e-mail, please check your spelling');
                }
            }
            if (!common()->_error_exists()) {
                if (module('comments')->AUTO_FILTER_INPUT_TEXT) {
                    $_POST['text'] = _filter_text($_POST['text']);
                }
                // Do close BB Codes (if needed)
                if (module('comments')->USE_BB_CODES) {
                    $BB_CODES_OBJ = _class('bb_codes');
                    if (is_object($BB_CODES_OBJ)) {
                        $_POST['text'] = $BB_CODES_OBJ->_force_close_bb_codes($_POST['text']);
                    }
                }
                db()->INSERT('comments', ['object_name' => _es($OBJECT_NAME), 'object_id' => intval($OBJECT_ID), 'parent_id' => intval(isset($_POST['parent_id']) ? $_POST['parent_id'] : 0), 'user_id' => intval(main()->USER_ID), 'user_name' => !main()->USER_ID ? _es($_POST['user_name']) : '', 'user_email' => !main()->USER_ID ? _es($_POST['user_email']) : '', 'text' => _es($_POST['text']), 'add_date' => time(), 'active' => 1, 'ip' => _es(common()->get_ip())]);
                $RECORD_ID = db()->INSERT_ID();
                $try_trigger_callback = [module($_GET['object']), module('comments')->_on_update_trigger];
                if (is_callable($try_trigger_callback)) {
                    call_user_func($try_trigger_callback, $params);
                }
                common()->_add_activity_points(main()->USER_ID, $OBJECT_NAME . '_comment', strlen($_POST['text']), $RECORD_ID);
                return js_redirect($RETURN_PATH, false);
            }
        }
        $error_message = _e();
        if (empty($_POST['go']) || !empty($error_message)) {
            if (module('comments')->VIEW_EMAIL_FIELD == true and empty(main()->USER_ID)) {
                $view_user_email = '1';
            } else {
                $view_user_email = '0';
            }
            $replace = ['form_action' => $FORM_ACTION, 'error_message' => $error_message, 'user_name' => $_POST['user_name'], 'view_user_email' => $view_user_email, 'user_email' => $_POST['user_email'], 'text' => _prepare_html($_POST['text']), 'object_name' => _prepare_html($OBJECT_NAME), 'object_id' => intval($OBJECT_ID), 'use_captcha' => intval((bool) module($_GET['object'])->USE_CAPTCHA), 'captcha_block' => module($_GET['object'])->_captcha_block(), 'bb_codes_block' => module('comments')->USE_BB_CODES ? _class('bb_codes')->_display_buttons(['unique_id' => 'text']) : '', 'submit_buttons' => _class_safe('preview')->_display_buttons(), 'js_check' => intval((bool) module('comments')->JS_TEXT_CHECKING), 'parent_id' => intval($_POST['parent_id'])];
            $body = tpl()->parse($STPL_NAME_ADD, $replace);
        }
        return $body;
    }
Example #5
0
 public function _class($class, $method = null, $options = null)
 {
     $_path = $this->_class_path;
     $_class_name = __CLASS__ . '__' . $class;
     $_class = _class_safe($_class_name, $_path);
     $status = $_class instanceof $_class_name;
     if (!$status) {
         return null;
     }
     $status = method_exists($_class, $method);
     if (!$status) {
         return $_class;
     }
     $result = $_class->{$method}($options);
     return $result;
 }
Example #6
0
 protected function _firewall($class = null, $class_path = null, $method = null, $options = [])
 {
     $_method = '_api_' . $method;
     // try module
     $_class = module_safe($class);
     $_status = method_exists($_class, $_method);
     if (!$_status) {
         // try class
         $_class = _class_safe($class, $class_path);
         $_status = method_exists($_class, $_method);
     }
     if (!$_status) {
         $this->_reject();
     }
     $request = $this->_parse_request();
     return $_class->{$_method}($request, $options);
 }
Example #7
0
 /**
  */
 function _display_submit_buttons($params = [], $template = '')
 {
     return $this->USE_PREVIEW ? _class_safe('preview')->_display_buttons() : '';
 }
Example #8
0
 /**
  * Main $_GET tasks handler
  */
 function tasks($allowed_check = false)
 {
     $main = main();
     if ($main->is_console() || $main->is_ajax()) {
         $main->no_graphics(true);
     }
     // Singleton
     $_center_result = tpl()->_CENTER_RESULT;
     if (isset($_center_result)) {
         return $_center_result;
     }
     $not_found = false;
     $access_denied = false;
     $custom_handler_exists = false;
     $OBJECT =& $_GET['object'];
     $ACTION =& $_GET['action'];
     _class('router')->_route_request();
     // Check if called class method is 'private' - then do not use it
     // Also we protect here core classes that can be instantinated before this method and can be allowed by mistake
     // Use other module names, think about this list as "reserved" words
     if (substr($ACTION, 0, 1) == '_' || !strlen($OBJECT) || substr($OBJECT, 0, strlen(YF_PREFIX)) === YF_PREFIX || in_array($OBJECT, $this->_get_denied_tasks_names())) {
         $access_denied = true;
     }
     if (!$access_denied) {
         $obj = module($OBJECT);
         if (!is_object($obj)) {
             $not_found = true;
         }
         if (!$not_found && !method_exists($obj, $ACTION)) {
             $not_found = true;
         }
         // Check if we have custom action handler in module (catch all requests to module methods)
         if (method_exists($obj, $main->MODULE_ACTION_HANDLER)) {
             $custom_handler_exists = true;
         }
         if (!$not_found || $custom_handler_exists) {
             if ($custom_handler_exists) {
                 $not_found = false;
                 $body = $obj->{$main->MODULE_ACTION_HANDLER}($ACTION, $main->_ARGS_DIRTY);
             } else {
                 $is_banned = false;
                 if (MAIN_TYPE_USER && $main->AUTO_BAN_CHECKING) {
                     $is_banned = _class('ban_status')->_auto_check([]);
                 }
                 if ($is_banned) {
                     $body = _e();
                 } else {
                     $body = $obj->{$ACTION}();
                 }
             }
         }
     }
     $redirect_func = function ($url) {
         $redir_params = ['%%object%%' => $OBJECT, '%%action%%' => $ACTION, '%%add_get_vars%%' => str_replace('&', ';', _add_get(['object', 'action']))];
         $redir_url = str_replace(array_keys($redir_params), array_values($redir_params), $url);
         if (!empty($redir_url)) {
             redirect($redir_url, 1, tpl()->parse('system/error_not_found'));
         }
     };
     if ($not_found) {
         $main->BLOCKS_TASK_404 = true;
         if ($this->TASK_NOT_FOUND_404_HEADER) {
             header(($_SERVER['SERVER_PROTOCOL'] ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1') . ' 404 Not Found');
             $main->IS_404 = true;
         }
         if (_class('graphics')->NOT_FOUND_RAISE_WARNING) {
             trigger_error(__CLASS__ . ': Task not found: ' . $OBJECT . '.' . $ACTION, E_USER_WARNING);
         }
         if (MAIN_TYPE_USER) {
             $u = $main->REDIR_URL_NOT_FOUND;
             if (is_array($u) && !empty($u)) {
                 // Prefill GET keys from redirect url
                 foreach (['object', 'action', 'id', 'page'] as $k) {
                     $_GET[$k] = $u[$k];
                 }
                 if (!empty($u['object'])) {
                     $action = $u['action'] ?: 'show';
                     $body = _class_safe($u['object'], $u['path'])->{$action}();
                 } elseif (isset($u['stpl'])) {
                     $main->no_graphics(true);
                     print tpl()->parse($u['stpl']);
                 }
             } else {
                 $redir_func = $this->REDIRECT_CALLBACK_404 ?: $redirect_func;
                 $redir_func($u);
             }
         }
     } elseif ($allowed_check && $access_denied) {
         $main->BLOCKS_TASK_403 = true;
         if ($this->TASK_DENIED_403_HEADER) {
             header(($_SERVER['SERVER_PROTOCOL'] ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1') . ' 403 Forbidden');
             $main->IS_403 = true;
         }
         trigger_error(__CLASS__ . ': Access denied: ' . $OBJECT . '.' . $ACTION, E_USER_WARNING);
         if (MAIN_TYPE_USER) {
             $redir_func = $this->REDIRECT_CALLBACK_403 ?: $redirect_func;
             $redir_func($main->REDIR_URL_DENIED);
         }
     }
     $block_name = 'center_area';
     $events = _class('core_events');
     $prepend = $events->fire('block.prepend[' . $block_name . ']');
     $append = $events->fire('block.append[' . $block_name . ']', [&$body]);
     $body = ($prepend ? implode(PHP_EOL, $prepend) : '') . $body . ($append ? implode(PHP_EOL, $append) : '');
     // Singleton
     tpl()->_CENTER_RESULT = (string) $body;
     // Output only center content, when we are inside AJAX_MODE
     if ($main->is_ajax()) {
         print $body;
     }
     return $body;
 }
Example #9
0
 /**
  * Replace standard patterns
  */
 function _replace_std_patterns($string, $name = '', array &$replace, $params = [])
 {
     $_this = $this;
     $tpl = tpl();
     $patterns = ['/\\{const\\(\\s*["\']{0,1}([a-z_][a-z0-9_]+?)["\']{0,1}\\s*\\)\\}/i' => function ($m) {
         return defined($m[1]) ? constant($m[1]) : '';
     }, '/\\{conf\\(\\s*["\']{0,1}([a-z_][a-z0-9_:]+?)["\']{0,1}\\s*\\)\\}/i' => function ($m) {
         return conf($m[1]);
     }, '/\\{module_conf\\(\\s*["\']{0,1}([a-z_@][a-z0-9_:]+?)["\']{0,1}\\s*,\\s*["\']{0,1}([a-z_][a-z0-9_:]+?)["\']{0,1}\\s*\\)\\}/i' => function ($m) {
         return module_conf($m[1], $m[2]);
     }, '/\\{(t|translate|i18n)\\(\\s*["\']{0,1}(.*?)["\']{0,1}\\s*\\)\\}/ims' => function ($m) use($replace, $name, $tpl) {
         return $tpl->_i18n_wrapper($m[2], $replace);
     }, '/\\{cleanup\\(\\s*\\)\\}(.*?)\\{\\/cleanup\\}/ims' => function ($m) {
         return trim(str_replace(["\r", "\n", "\t"], '', stripslashes($m[1])));
     }, '/\\{(tip|itip)\\(\\s*["\']{0,1}(?P<raw>[^"\'\\)\\}]*)["\']{0,1}\\s*\\)\\}/ims' => function ($m) use($replace, $name) {
         return _class_safe('graphics')->tip(['raw' => $m['raw'], 'replace' => $replace, 'tpl_name' => $name]);
     }, '/\\{(e|user_error)\\(\\s*["\']{0,1}([\\w\\-\\.]+)["\']{0,1}\\s*\\)\\}/ims' => function ($m) {
         return common()->_show_error_inline($m[2]);
     }, '/\\{ad\\(\\s*["\']{0,1}([^"\'\\)\\}]*)["\']{0,1}\\s*\\)\\}/ims' => function ($m) {
         return module_safe('advertising')->_show(['ad' => $m[1]]);
     }, '/\\{url\\(\\s*["\']{0,1}([^"\'\\)\\}]*)["\']{0,1}\\s*\\)\\}/ims' => function ($m) use($tpl) {
         return $tpl->_url_wrapper($m[1]);
     }, '/\\{form_row\\(\\s*["\']{0,1}[\\s\\t]*([a-z0-9\\-_]+)[\\s\\t]*["\']{0,1}([\\s\\t]*,[\\s\\t]*["\']{1}([^"\']*)["\']{1})?([\\s\\t]*,' . '[\\s\\t]*["\']{1}([^"\']*)["\']{1})?([\\s\\t]*,[\\s\\t]*["\']{1}([^"\']*)["\']{1})?\\s*\\)\\}/ims' => function ($m) use($replace, $name) {
         return _class('form2')->tpl_row($m[1], $replace, $m[3], $m[5], $m[7]);
     }, '/\\{([a-z0-9\\-\\_]+)\\|([a-z0-9\\-\\_\\|]+)\\}/ims' => function ($m) use($replace, $name, $tpl) {
         return $tpl->_process_var_filters($replace[$m[1]], $m[2]);
     }, '/\\{([a-z0-9\\-\\_]+)\\.([a-z0-9\\-\\_]+)\\|([a-z0-9\\-\\_\\|]+)\\}/ims' => function ($m) use($replace, $name, $tpl) {
         $val = $replace[$m[1]][$m[2]];
         return $tpl->_process_var_filters($val ?: $class_prop, $m[3]);
     }];
     // Evaluate custom PHP code pattern. Examples: {eval_code(print_r(_class('forum')))}
     if ($tpl->ALLOW_EVAL_PHP_CODE) {
         $patterns['/(\\{eval_code\\()([^\\}]+?)(\\)\\})/i'] = function ($m) {
             return eval('return ' . $m[2] . ' ;');
         };
     }
     // Custom patterns support (intended to be used inside modules/plugins)
     foreach ((array) $tpl->_custom_patterns_funcs as $pattern => $func) {
         $patterns[$pattern] = function ($m) use($replace, $name, $_this, $func) {
             return $func($m, $replace, $name, $_this);
         };
     }
     if (DEBUG_MODE) {
         // Evaluate custom PHP code pattern special for the DEBUG_MODE. Examples: {_debug_get_replace()}
         $patterns['/(\\{_debug_get_replace\\(\\)\\})/i'] = function ($m) use($replace, $name) {
             return is_array($replace) ? '<pre>' . print_r(array_keys($replace), 1) . '</pre>' : '';
         };
         // Evaluate custom PHP code pattern special for the DEBUG_MODE. Examples: {_debug_stpl_vars()}
         $patterns['/(\\{_debug_get_vars\\(\\)\\})/i'] = function ($m) use($string, $tpl) {
             return $tpl->_debug_get_vars($string);
         };
     }
     foreach ((array) $patterns as $pattern => $callback) {
         $string = preg_replace_callback($pattern, $callback, $string);
     }
     return $string;
 }
Example #10
0
 private function _class($class, $method, $options)
 {
     $_path = $this->_class_path;
     $_class = __CLASS__ . '__' . $class;
     $result = _class_safe($_class, $_path)->{$method}($options);
     return $result;
 }
Example #11
0
 /**
  * Do Log
  */
 function _log_queries()
 {
     // Restore startup working directory
     @chdir(main()->_CWD);
     if (!isset($this->_queries_logged)) {
         $this->_queries_logged = true;
     } else {
         return false;
     }
     _class_safe('logs')->store_db_queries_log();
 }
Example #12
0
 public function _hook_side_column()
 {
     $custom_class_name = 'sample_' . $_GET['action'];
     $custom_obj = _class_safe($custom_class_name);
     $hook_name = __FUNCTION__;
     // Try to load side column hook from subclass
     if ($_GET['action'] && is_object($custom_obj) && method_exists($custom_obj, $hook_name)) {
         // class should be instantinated with full path before this
         $custom = $custom_obj->{$hook_name}();
         if ($custom) {
             return $custom;
         }
     }
     $url = url('/@object');
     $names = [];
     $ext = '.class.php';
     $ext_len = strlen($ext);
     $globs = ['yf_dev_classes' => YF_PATH . '.dev/samples/classes/*' . $ext, 'yf_dev_form2' => YF_PATH . '.dev/samples/form2/*' . $ext, 'yf_dev_table2' => YF_PATH . '.dev/samples/table2/*' . $ext];
     $names = [];
     foreach ($globs as $glob) {
         foreach (glob($glob) as $cls) {
             $cls = basename($cls);
             if ($cls == __CLASS__) {
                 continue;
             }
             $name = substr($cls, 0, -$ext_len);
             $names[$name] = $name;
         }
     }
     $links = [];
     foreach ($names as $name) {
         if (substr($name, 0, strlen('sample_')) === 'sample_') {
             $name = substr($name, strlen('sample_'));
         }
         $url = '/';
         if (substr($name, 0, strlen('table2_')) === 'table2_') {
             $url = '/@object/table/' . $name;
         } elseif (substr($name, 0, strlen('form2_')) === 'form2_') {
             $url = '/@object/form/' . $name;
         } else {
             $url = '/@object/' . $name;
         }
         $links[url($url)] = t($name) . (in_array($name, $this->whats_new) ? ' <sup class="text-success"><small>NEW</small></sup>' : '');
     }
     return html()->navlist($links);
 }