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: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 
<?php

/**


 * @author PHPShop Software
 * @version 1.6
 * @package PHPShopClass
 */
class PHPShopCore {

    /**

     */
    var $objBase;

    /**

     */
    var $debug = false;

    /**

     */
    var $Disp, $ListInfoItems;

    /**

     */
    var $action = array("nav" => "index");

    /**

     */
    var $title, $description, $keywords, $lastmodified;

    /**

     */
    var $navigation_link = '';

    /**

     */
    var $template = 'templates.shop';

    /**

     */
    var $navigationArray = 'CatalogPage';

    /**

     */
    var $navigationBase = 'base.table_name';

    /**

     */
    var $navigationFileType = '.html';

    /**

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

    /**

     * @global array $PHPShopSystem
     * @global array $PHPShopNav
     * @global array $PHPShopModules
     */
    function __construct() {
        global $PHPShopSystem, $PHPShopNav, $PHPShopModules;

        if ($this->objBase) {
            $this->PHPShopOrm = new PHPShopOrm($this->objBase);
            $this->PHPShopOrm->debug = $this->debug;
        }

        $this->SysValue = &$GLOBALS['SysValue'];
        $this->LoadItems = &$GLOBALS['LoadItems'];
        $this->PHPShopSystem = &$PHPShopSystem;
        $this->num_row = $this->PHPShopSystem->getParam('num_row');
        $this->PHPShopNav = &$PHPShopNav;
        $this->PHPShopModules = &$PHPShopModules;
        $this->page = $this->PHPShopNav->getId();
        if (strlen($this->page) == 0)
            $this->page = 1;

        //
        $this->set('pageReg', "PHPShop CMS Free");
        $this->set('pageDomen', "No");
        $this->set('pageProduct', $this->SysValue['license']['product_name']);
    }

    function getNavigationPath($id) {
        global $array;
        $PHPShopOrm = new PHPShopOrm($this->getValue($this->navigationBase));
        $PHPShopOrm->debug = $this->debug;

        if ($id)
            if (empty($this->LoadItems[$this->navigationArray][$id]['name'])) {
                $PHPShopOrm->comment = "";
                $v = $PHPShopOrm->select(array('name', 'id', 'parent_to'), array('id' => '=' . $id), false, array('limit' => 1));

                if (is_array($v)) {
                    $array[] = array('id' => $v['id'], 'name' => $v['name'], 'parent_to' => $v['parent_to']);
                    $this->getNavigationPath($v['parent_to']);
                }
            } else {
                foreach ($this->LoadItems[$this->navigationArray] as $k => $v)
                    if ($k == $id) {
                        $array[] = array('id' => $id, 'name' => $v['name'], 'parent_to' => $v['parent_to']);
                        $this->getNavigationPath($v['parent_to']);
                    }
            }
        return $array;
    }

    /**




     */
    function navigation($id, $name, $title = false) {
        $dis = null;
        $spliter = ParseTemplateReturn($this->getValue('templates.breadcrumbs_splitter'));
        $home = ParseTemplateReturn($this->getValue('templates.breadcrumbs_home'));

        $arrayPath = $this->getNavigationPath($id);

        if (is_array($arrayPath)) {
            $arrayPath = array_reverse($arrayPath);

            //
            if ($this->PHPShopNav->getNav() == "CID")
                array_pop($arrayPath);

            foreach ($arrayPath as $v) {
                $dis.= $spliter . '<A href="/' . $this->PHPShopNav->getPath() . '/CID_' . $v['id'] . '.html">' . $v['name'] . '</a>';
            }
        }

        //
        if (empty($dis) and is_array($title))
            $dis = $spliter . PHPShopText::a($title['url'], $title['name']);

        $dis = $home . $dis . $spliter . '<b>' . $name . '</b>';
        $this->set('breadCrumbs', $dis);

        //
        $this->set('pageNameId', $id);
    }

    /**

     */
    function header() {
        if ($this->getValue("my.last_modified") == "true") {
            @header("Cache-Control: no-cache, must-revalidate");
            @header("Pragma: no-cache");

            if (!empty($this->lastmodified)) {
                $updateDate = @gmdate("D, d M Y H:i:s", $this->lastmodified);
            } else {
                $updateDate = gmdate("D, d M Y H:i:s", (date("U") - 21600));
            }

            @header("Last-Modified: " . $updateDate . " GMT");
        }

        @header("X-Powered-By: PHPShop");
    }

    /**

     */
    function meta() {

        if (!empty($this->title))
            $this->set('pageTitl', $this->title);
        else
            $this->set('pageTitl', $this->PHPShopSystem->getValue("title"));

        if (!empty($this->description))
            $this->set('pageDesc', $this->description);
        else
            $this->set('pageDesc', $this->PHPShopSystem->getValue("meta"));

        if (!empty($this->keywords))
            $this->set('pageKeyw', $this->keywords);
        else
            $this->set('pageKeyw', $this->PHPShopSystem->getValue("keywords"));


        //
        if ($this->get('breadCrumbs') == '') {
            if (strstr($this->title, '-'))
                $title = explode("-", $this->title);
            else
                $title[0] = $this->title;
            $this->navigation(false, $title[0]);
        }
    }

    /**

     */
    function loadActions() {

        $core_file = "./pages/" . $this->PHPShopNav->getPath() . ".php";

        if (!is_file($core_file)) {
            $this->setAction();
            $this->Compile();
        } else {

            //
            include_once($core_file);
        }
    }

    /**




     * @return array
     */
    function getListInfoItem($select = false, $where = false, $order = false) {
        $this->ListInfoItems = '';
        $this->where = $where;

        //
        if (!PHPShopSecurity::true_num($this->page))
            return $this->setError404();

        if (empty($this->page)) {
            $num_ot = 0;
            $num_do = $this->num_row;
        } else {
            $num_ot = $this->num_row * ($this->page - 1);
            $num_do = $this->num_row;
        }

        $option = array('limit' => $num_ot . ',' . $num_do);

        $this->set('productFound', $this->getValue('lang.found_of_products'));
        $this->set('productNumOnPage', $this->getValue('lang.row_on_page'));
        $this->set('productPage', $this->getValue('lang.page_now'));

        return $this->PHPShopOrm->select($select, $where, $order, $option);
    }

    /**

     */
    function setPaginator($nav_len = 3) {
        $SQL = null;

        //
        $nWhere = 1;
        if (is_array($this->where)) {
            $SQL.=' where ';
            foreach ($this->where as $pole => $value) {
                $SQL.=$pole . $value;
                if ($nWhere < count($this->where))
                    $SQL.=$this->PHPShopOrm->Option['where'];
                $nWhere++;
            }
        }

        //
        $result = $this->PHPShopOrm->query("select COUNT('id') as count from " . $this->objBase . $SQL);
        $row = mysqli_fetch_array($result);
        $this->num_page = $row['count'];

        $i = 1;
        //$pageDo=null;
        $navigat = null;
        $num = ceil($this->num_page / $this->num_row);

        while ($i <= $num) {

            if ($i == 1)
                $pageOt = 0 + $pageDo;
            else
                $pageOt = $i + $pageDo - $i;

            $pageDo = $i * $this->num_row;

            if ($i != $this->page) {

                if ($i > ($this->page - $nav_len) and $i < ($this->page + $nav_len))
                    $navigat.=" <a href=\"" . $this->objPath . $i . $this->navigationFileType . "\">" . ($pageOt + 1) . "-" . $pageDo . "</a> | ";
                else if ($i - ($this->page + $nav_len) < 3 and (($this->page - $nav_len) - $i) < 3)
                    $navigat.=".";
            }
            else
                $navigat.=" <b>" . ($pageOt + 1) . "-" . $pageDo . "</b> | ";
            $i++;
        }

        if ($num > 1) {
            if ($this->page >= $num) {
                $p_to = $i - 1;
                $p_do = $this->page - 1;
            } else {
                $p_to = $this->page + 1;

                if ($this->page > 1)
                    $p_do = $this->page - 1;
                else
                    $p_do = 1;
            }
            $this->set('productPageNav', $this->getValue('lang.page_now') . ":
<a href=\"" . $this->objPath . ($p_do) . $this->navigationFileType . "\">&laquo;&laquo;&nbsp;</a>&nbsp;
                    $navigat&nbsp<a href=\"" . $this->objPath . $p_to . $this->navigationFileType . "\">&nbsp;&raquo;&raquo;</a>");
        }
    }

    /**




     * @return array
     */
    function getFullInfoItem($select, $where, $order = false) {
        return $this->PHPShopOrm->select($select, $where, $order, array('limit' => '1'));
    }

    /**




     */
    function addToTemplate($template, $mod = false, $replace = null) {
        if ($mod)
            $template_file = $template;
        else
            $template_file = $this->getValue('dir.templates') . chr(47) . $_SESSION['skin'] . chr(47) . $template;
        if (is_file($template_file)) {
            $dis = ParseTemplateReturn($template, $mod);

            //
            if (is_array($replace)) {
                foreach ($replace as $key => $val)
                    $dis = str_replace($key, $val, $dis);
            }

            $this->ListInfoItems.=$dis;

            $this->set('pageContent', $this->ListInfoItems);
        }
        else
            $this->setError("addToTemplate", $template_file);
    }

    /**



     */
    function add($content, $list = false) {
        if ($list)
            $this->ListInfoItems.=$content;
        else
            $this->Disp.=$content;
    }

    /**




     */
    function parseTemplate($template, $mod = false, $replace = null) {
        $this->set('productPageDis', $this->ListInfoItems);
        $dis = ParseTemplateReturn($template, $mod);

        //
        if (is_array($replace)) {
            foreach ($replace as $key => $val)
                $dis = str_replace($key, $val, $dis);
        }

        $this->Disp = $dis;
    }

    /**



     */
    function setError($name, $action) {
        echo '<p style="BORDER: #000000 1px dashed;padding-top:10px;padding-bottom:10px;background-color:#FFFFFF;color:000000;font-size:12px">
<img hspace="10" style="padding-left:10px" align="left" src="../phpshop/admpanel/img/i_domainmanager_med[1].gif"
' . $name . '()
     <br><em>' . $action . '</em></p>';
    }

    /**

     */
    function Compile() {
        $this->set('DispShop', $this->Disp);

        //
        $this->meta();

        //
        $this->header();

        //
        writeLangFile();

        ParseTemplate($this->getValue($this->template));
    }

    /**




     */
    function set($name, $value, $flag = false) {
        if ($flag)
            $this->SysValue['other'][$name].=$value;
        else
            $this->SysValue['other'][$name] = $value;
    }

    /**

     * @param string $name
     * @return string
     */
    function get($name) {
        return $this->SysValue['other'][$name];
    }

    /**


     * @return mixed
     */
    function getValue($param) {
        $param = explode(".", $param);
        return $this->SysValue[$param[0]][$param[1]];
    }

    /**

     */
    function setAction() {
        global $SysValue;

        if (is_array($this->action)) {
            foreach ($this->action as $k => $v) {

                switch ($k) {

                    case("post"):

                        //
                        if (is_array($v)) {
                            foreach ($v as $function)
                                if (!empty($_POST[$function]) and $this->isAction($function))
                                    call_user_func(array(&$this, $function));
                        } else {
                            //
                            if (!empty($_POST[$v]) and $this->isAction($v))
                                call_user_func(array(&$this, $v));
                        }
                        break;

                    case("get"):


                        //
                        if (is_array($v)) {
                            foreach ($v as $function)
                                if (!empty($_GET[$function]) and $this->isAction($function))
                                    call_user_func(array(&$this, $function));
                        } else {
                            //
                            if (!empty($_GET[$v]) and $this->isAction($v))
                                call_user_func(array(&$this, $v));
                        }

                        break;

                    //
                    case("name"):

                        //
                        if (is_array($v)) {
                            foreach ($v as $function)
                                if ($this->PHPShopNav->getName(0) == $function and $this->isAction($function))
                                    return call_user_func(array(&$this, $this->action_prefix . $function));
                        } else {
                            //
                            if ($this->PHPShopNav->getName(0) == $v and $this->isAction($v))
                                return call_user_func(array(&$this, $this->action_prefix . $v));
                        }

                        break;

                    //
                    case("nav"):

                        //
                        if (is_array($v)) {
                            foreach ($v as $function) {
                                if ($this->PHPShopNav->getNav() == $function and $this->isAction($function)) {
                                    return call_user_func(array(&$this, $this->action_prefix . $function));
                                    $call_user_func = true;
                                }
                            }
                            if (empty($call_user_func)) {

                                if ($this->isAction('index')) {

                                    //
                                    if ($this->PHPShopNav->getNav() and !$this->empty_index_action)
                                        $this->setError404();
                                    else
                                        call_user_func(array(&$this, $this->action_prefix . 'index'));
                                }
                                else
                                    $this->setError($this->action_prefix . "index", "");
                            }
                        } else {
                            //

                            if ($this->PHPShopNav->getNav() == $v and $this->isAction($v))
                                return call_user_func(array(&$this, $this->action_prefix . $v));
                            elseif ($this->isAction('index')) {
                                //
                                if ($this->PHPShopNav->getNav() and !$this->empty_index_action)
                                    $this->setError404();
                                else
                                    call_user_func(array(&$this, $this->action_prefix . 'index'));
                            }
                            else
                                $this->setError($this->action_prefix . "phpshop" . $this->PHPShopNav->getPath() . "->index", "");
                        }

                        break;
                }
            }
        }
        else
            $this->setError("action", "");
    }

    /**


     * @return bool
     */
    function isAction($method_name) {
        if (method_exists($this, $method_name))
            return true;
    }

    /**

     */
    function setError404() {

        //
        $this->title = __("") . " - " . $this->PHPShopSystem->getValue("name");

        //
        header("HTTP/1.0 404 Not Found");
        header("Status: 404 Not Found");

        //
        $this->parseTemplate($this->getValue('templates.error_page_forma'));
    }

    /**





     * @return bool
     */
    function setHook($class_name, $function_name, $data = false, $rout = false) {
        return $this->PHPShopModules->setHookHandler($class_name, $function_name, array(&$this), $data, $rout);
    }

    /**

     */
    function __call($name, $arguments) {
        if ($name == __CLASS__) {
            self::__construct();
        }
    }

}

?>
API documentation generated by ApiGen