Overview

Packages

  • None
  • PHPShopArray
  • PHPShopClass
    • Helper
  • PHPShopCore
  • PHPShopElements
  • PHPShopGUI
  • PHPShopInc
  • PHPShopObj
  • PHPShopParser
  • PHPShopTest

Classes

  • fase4_rdf
  • PHPShopAdminRule
  • PHPShopArray
  • PHPShopBannerElement
  • PHPShopBase
  • PHPShopBaseXml
  • PHPShopCatalogElement
  • PHPShopCategory
  • PHPShopCategoryArray
  • PHPShopCloudElement
  • PHPShopCore
  • PHPShopCoretest
  • PHPShopCssParser
  • PHPShopDate
  • PHPShopDebug
  • PHPShopDoc
  • PHPShopElements
  • PHPShopFile
  • PHPShopForma
  • PHPShopFrontInterface
  • PHPShopGbook
  • PHPShopGbookElement
  • PHPShopGUI
  • PHPShopIndex
  • PHPShopInterface
  • PHPShopLang
  • PHPShopLinks
  • PHPShopMail
  • PHPShopMailFile
  • PHPShopMap
  • PHPShopModules
  • PHPShopNav
  • PHPShopNews
  • PHPShopNewsElement
  • PHPShopObj
  • PHPShopOpros
  • PHPShopOprosElement
  • PHPShopOrm
  • PHPShopPage
  • PHPShopPageCategory
  • PHPShopPageCategoryArray
  • PHPShopPages
  • PHPShopParser
  • PHPShopPhoto
  • PHPShopPhotoCategory
  • PHPShopPhotoCategoryArray
  • PHPShopPhotoElement
  • PHPShopReadCsv
  • PHPShopReadCsvNative
  • PHPShopReadCsvPro
  • PHPShopRestore
  • PHPShopRssParser
  • PHPShopSearch
  • PHPShopSecurity
  • PHPShopSkinElement
  • PHPShopSkinmarket
  • PHPShopSliderElement
  • PHPShopString
  • PHPShopSystem
  • PHPShopText
  • PHPShopTextElement
  • PHPShopUpdate
  • XMLparser

Functions

  • __
  • allowedFunctions
  • array2iconv
  • CheckCanGzip
  • debug
  • evalstr
  • GzDocOut
  • Open
  • output_handler
  • parseDatabase
  • Parser
  • ParseTemplate
  • ParseTemplateReturn
  • PHPShopAutoLoadClass
  • phpshopparserevalstr
  • preExtractCallBack
  • readDatabase
  • stripslashes_deep
  • SysValueReturn
  • timer
  • tmpGetFile
  • utf8_win1251
  • writeLangFile
  • xml2array
  • Overview
  • Package
  • Class
  1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 
<?php

/**

 * @author PHPShop Software
 * @version 1.7
 * @package PHPShopClass



 */
class PHPShopBase {

    /**

     * @var string 
     */
    var $iniPath;

    /**

     * @var array 
     */
    var $SysValue;

    /**

     * @var string
     */
    var $codBase = "cp1251";

    /**

     * @var string 
     */
    var $locale = 'ru_RU.cp1251';

    /**

     * @var string 
     */
    var $timezone = 'Europe/Moscow';

    /**

     * @var bool 
     */
    var $debug = true;

    /**




     */
    function __construct($iniPath, $connectdb = true, $error = true) {

        //
        $this->setTimeZone();

        // UTF-8 Fix
        $this->fixUTF();

        //
        $this->setPHPCoreReporting($error);

        $this->iniPath = $iniPath;
        $this->SysValue = parse_ini_file($this->iniPath, 1);

        define('parser_function_allowed', $this->SysValue['function']['allowed']);
        define('parser_function_deny', $this->SysValue['function']['deny']);
        define('parser_function_guard', $this->SysValue['function']['guard']);

        $GLOBALS['SysValue'] = &$this->SysValue;

        if (!empty($connectdb))
            $this->link_db = $this->connect();
    }

    /**

     * @return array
     */
    function getSysValue() {
        return $this->SysValue;
    }

    /**

     * <code>
     * // example
     * $PHPShopBase= new PHPShopBase('./inc/config.ini');
     * $PHPShopBase->getParam('base.table_name');
     * </code>

     * @return string
     */
    function getParam($param) {
        $param = explode(".", $param);
        if (count($param) > 2)
            return $this->SysValue[$param[0]][$param[1]][$param[2]];
        return $this->SysValue[$param[0]][$param[1]];
    }

    /**

     * <code>
     * // example
     * $PHPShopBase= new PHPShopBase('./inc/config.ini');
     * $PHPShopBase->setParam('base.table_name','mybase');
     * </code>


     */
    function setParam($param, $value) {
        $param = explode(".", $param);
        if ($param[0] == "var")
            $param[0] = "other";
        $GLOBALS['SysValue'][$param[0]][$param[1]] = $value;
    }

    /**




     */
    function errorConnect($e = false, $message = "", $error = false) {
        global $link_db;

        if (is_dir($_SERVER['DOCUMENT_ROOT'] . '/install/') and $e != 105)
            header('Location: /install/');
        else {
            $message = '<strong>' . $message . '' . $error . @mysqli_error($link_db) . '</em>';
        }

        if (function_exists('ParseTemplateReturn')) {
            $GLOBALS['SysValue']['other']['message'] = $message;
            $GLOBALS['SysValue']['other']['title'] = $e;
            exit(ParseTemplateReturn('phpshop/lib/templates/error/error.tpl', true));
        } elseif (class_exists('PHPShopObj')) {
            PHPShopObj::loadClass('parser');
            PHPShopParser::set('message', $message);
            PHPShopParser::set('title', $e);
            exit(PHPShopParser::file($_SERVER['DOCUMENT_ROOT'] . '/phpshop/lib/templates/error/error.tpl'));
        }
        else
            exit($message);
    }

    /**

     */
    function connect() {
        global $link_db;
        $link_db = @mysqli_connect($this->getParam("connect.host"), $this->getParam("connect.user_db"), $this->getParam("connect.pass_db")) or die($this->errorConnect(101));
        mysqli_select_db($link_db, $this->getParam("connect.dbase")) or die($this->errorConnect(101));
        mysqli_query($link_db, "SET NAMES '" . $this->codBase . "'");
        mysqli_query($link_db, "SET SESSION sql_mode=''");

        return $link_db;
    }

    /**

     */
    function chekAdmin() {

        // Portable PHP password hashing framework.
        require_once dirname(__FILE__) . '/../lib/phpass/passwordhash.php';

        PHPShopObj::loadClass('admrule');
        $this->Rule = new PHPShopAdminRule();
    }

    /**



     * @return int
     */
    function getNumRows($from_base, $query) {
        $sql = "select COUNT('id') as count from " . $this->SysValue['base'][$from_base] . " " . $query;
        $result = mysqli_query($this->link_db, $sql);
        $row = @mysqli_fetch_array($result);
        $num = $row['count'];
        return intval($num);
    }

    /**

     */
    function setLocale() {
        if (function_exists('setlocale') and !empty($this->locale))
            setlocale(LC_ALL, $this->locale);
    }

    /**

     */
    function setTimeZone() {
        if (function_exists('date_default_timezone_set') and !empty($this->timezone))
            date_default_timezone_set($this->timezone);
    }

    /**
     * UTF-8 Fix
     */
    function fixUTF() {

        //  UTF-8 Default Charset Fix
        if (stristr(ini_get("default_charset"), "utf") and function_exists('ini_set')) {
            ini_set("default_charset", "cp1251");
        }

        // UTF-8 Env Fix
        if (ini_get("mbstring.func_overload") > 0 and function_exists('ini_set')) {
            ini_set("mbstring.internal_encoding", null);
        }
    }

    /**

     */
    function setPHPCoreReporting($error) {
        if (function_exists('error_reporting')) {
            if (empty($error)) {
                error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT);
                if ($this->phpversion() and function_exists('ini_set')) {
                    ini_set('allow_call_time_pass_reference', 1);
                }
            }
            else
                error_reporting(0);

            // Short Open Tag 
            if (ini_get("short_open_tag") == 0) {
                ini_set('short_open_tag', 1);
            }
        }
    }

    /**


     * @return boolean 
     */
    function phpversion($version = '5.3') {
        if ((phpversion() * 1) >= $version)
            return true;
    }

}
?>
API documentation generated by ApiGen