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: 
<?php

/**

 * @author PHPShop Software
 * @version 1.2
 * @package PHPShopClass
 */
class PHPShopRestore extends PHPShopUpdate {

    var $_restore_path = '../../';
    var $_restore_version;

    function __construct() {
        parent::__construct();
    }

    /*

     */

    function checkRestore($version) {
        if (file_exists($this->_backup_path . 'backups/' . intval($version) . '/files.zip')) {
            $this->_restore_version = $version;
            return true;
        }
    }

    /**

     */
    function restoreBD() {
        global $PHPShopGUI;

        if (file_exists($this->_backup_path . 'backups/' . $this->_restore_version . '/restore.sql', 'dumper/backup/restore.sql')) {

            if (!copy($this->_backup_path . 'backups/' . $this->_restore_version . '/restore.sql', 'dumper/backup/restore.sql')) {
                $this->log("" . $this->_restore_version . '/restore.sql', 'warning', 'remove');
                return false;
            }

            $this->_log.=$PHPShopGUI->setProgress(__(''), 'install-restore-bd');
            $this->log("", 'success hide install-restore-bd');
            $this->log("", 'danger hide install-restore-bd-danger');
        }
    }

    /**

     */
    function restoreFiles() {

        //
        $this->chmod("phpshop/inc/config.ini", $this->_user_ftp_chmod);

        $this->installFiles('backups/' . $this->_restore_version . '/files.zip', $status = '', $this->_restore_path);

        //
        $this->chmod("phpshop/inc/config.ini", $this->_user_ftp_re_chmod);
    }

    /**

     */
    function restoreConfig() {
        $config['upload']['version'] = $this->_restore_version;
        $this->installConfig($config);
    }

}

/**

 * @author PHPShop Software
 * @version 1.0
 * @package PHPShopClass
 */
class PHPShopUpdate {

    /**

     * @var bool 
     */
    var $local_update = true;
    var $_endPoint;
    var $_log;
    var $_timeLimit = 600;
    var $_backup_path = '../../backup/';
    var $_test_file = 'index.php';
    var $base_update_enabled = false;
    var $_user_ftp_dir;
    var $_user_ftp_chmod;
    var $_user_ftp_re_chmod;

    function __construct() {

        include_once('../lib/zip/pclzip.lib.php');

        $this->path = $_SERVER['DOCUMENT_ROOT'] . $GLOBALS['SysValue']['dir']['dir'] . '/';

        $this->_user_ftp_host = $GLOBALS['SysValue']['user_ftp']['host'];
        $this->_user_ftp_login = $GLOBALS['SysValue']['user_ftp']['login'];
        $this->_user_ftp_password = $GLOBALS['SysValue']['user_ftp']['password'];
        $this->_user_ftp_chmod = $GLOBALS['SysValue']['user_ftp']['chmod'];
        $this->_user_ftp_re_chmod = $GLOBALS['SysValue']['user_ftp']['re_chmod'];

        $this->_endPoint = $_SERVER['SERVER_NAME'];
        $this->_user_ftp_chmod = $GLOBALS['SysValue']['user_ftp']['chmod'];

        if ($this->islocal())
            $this->_user_ftp_dir = $_SERVER['DOCUMENT_ROOT'] . $GLOBALS['dir']['dir'];
        else
            $this->_user_ftp_dir = $GLOBALS['SysValue']['user_ftp']['dir'];


        //
        if (function_exists('error_reporting')) {
            error_reporting('E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT');
        }

        set_time_limit($this->_timeLimit);
    }

    /**

     */
    function islocal() {
        if ($this->local_update or ($_SERVER["SERVER_ADDR"] == "127.0.0.1" and getenv("COMSPEC")))
            return true;
    }

    /**

     */
    function chmod($path, $chmod) {

        if ($this->islocal()) {
            return true;
        } else {

            if (ftp_site($this->user_ftp_stream, "CHMOD " . $chmod . " " . $this->_user_ftp_dir . '/' . $path))
                return true;
            else
                return false;
        }
    }

    /**

     */
    function mkdir($path) {

        if ($this->islocal()) {
            if (mkdir($this->path . $path))
                return true;
            else
                return false;
        } else {

            if (ftp_mkdir($this->user_ftp_stream, $this->_user_ftp_dir . '/' . $path)) {
                return true;
            }
            else
                return false;
        }
    }

    /**

     */
    function delete($path = null) {

        if (!$path)
            return false;

        if ($this->islocal()) {
            if (@unlink($this->path . $path))
                return true;
            else
                return false;
        } else {

            if (ftp_delete($this->user_ftp_stream, $this->_user_ftp_dir . '/' . $path))
                return true;
            else
                return false;
        }
    }

    /**

     */
    function isReady() {

        if (!$this->islocal()) {

            if (!$this->user_ftp_stream = ftp_connect($this->_user_ftp_host)) {
                $this->log('' . $this->_user_ftp_host, 'warning', 'remove');
                return false;
            }

            if (!ftp_login($this->user_ftp_stream, $this->_user_ftp_login, $this->_user_ftp_password)) {
                $this->log("" . $this->_user_ftp_host, 'warning', 'remove');
                return false;
            }

            if (!ftp_pasv($this->user_ftp_stream, true)) {
                $this->log("" . $this->_user_ftp_host, 'warning', 'remove');
                return false;
            }

            if (!empty($this->_user_ftp_dir) and !ftp_chdir($this->user_ftp_stream, $this->_user_ftp_dir)) {
                $this->log("" . $this->_user_ftp_dir, 'warning', 'remove');
                return false;
            }

            //
            //$this->chmod(null, $this->_user_ftp_chmod);

            $archive = new PclZip($this->path . 'test_update.zip');
            $v_list = $archive->add($this->path . $this->_test_file, PCLZIP_OPT_REMOVE_PATH, $this->path);

            if ($v_list == 0) {
                $this->log('', 'warning', 'remove');
                return false;
            }

            if (!$this->delete('test_update.zip')) {
                $this->log("", 'danger', 'remove');
                return false;
            }
            else
                return true;
        }
        else
            return true;
    }

    /**

     */
    function installFiles($file = 'temp/update.zip', $status = '', $path = '../../') {

        $archive = new PclZip($this->_backup_path . $file);
        if ($archive->extract(PCLZIP_OPT_PATH, $path, PCLZIP_CB_PRE_EXTRACT, 'preExtractCallBack')) {
            $this->log("" . $status . "");
            return true;
        } else {
            $this->log("" . $status, 'warning', 'remove');
            return false;
        }

        //
        //$this->chmod(null, $this->_user_ftp_re_chmod);
    }

    /**

     */
    function cleanTemp() {

        $this->delete('backup/temp/config_update.txt');
        $this->delete('backup/temp/upd_conf.txt');
        $this->delete('backup/temp/update.sql');
        $this->delete('backup/temp/restore.sql');
        $this->delete('backup/temp/upload_backup.sql.gz');

        if ($this->delete('backup/temp/update.zip'))
            $this->log("");
        else
            $this->log("", 'warning', 'remove');
    }

    /**

     */
    function installBD() {
        global $PHPShopGUI;

        if (file_exists("dumper/backup/update.sql")) {
            $this->_log.=$PHPShopGUI->setProgress(__(''), 'install-update-bd');
            $this->log("", 'success hide install-update-bd');
            $this->log("", 'danger hide install-update-bd-danger');
            @unlink("dumper/backup/update.sql");
            return false;
        }
    }

    /**

     */
    function installConfig($config = false) {
        global $PHPShopBase;

        //
        $this->chmod("phpshop/inc/config.ini", $this->_user_ftp_chmod);

        if (!is_array($config))
            $config = parse_ini_file($this->_backup_path . "temp/config_update.txt", 1);

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

        //
        if (is_array($config)) {
            foreach ($config as $k => $v) {
                if (is_array($config[$k])) {
                    foreach ($config[$k] as $key => $value) {
                        $SysValue[$k][$key] = $value;
                    }
                }
            }
        }


        $s = null;

        if (is_array($SysValue))
            foreach ($SysValue as $k => $v) {

                $s .="[$k]\n";
                foreach ($v as $key => $val) {
                    if (!is_array($val))
                        $s .= "$key = \"$val\";\n";
                }

                $s .= "\n";
            }

        if (!empty($s)) {
            if ($f = fopen($this->path . "phpshop/inc/config.ini", "w")) {

                if (!empty($s) and strstr($s, 'phpshop')) {
                    fwrite($f, $s);
                    $this->log("");
                }

                fclose($f);
            }
            else
                $this->log("", 'warning', 'remove');
        }
        else
            $this->log("", 'warning', 'remove');


        //
        $this->chmod("phpshop/inc/config.ini", $this->_user_ftp_re_chmod);
    }

    /**

     */
    function backupFiles() {

        //
        $this->mkdir('backup/backups/' . $GLOBALS['SysValue']['upload']['version']);

        //
        $this->chmod($this->_user_ftp_dir . '/backup/backups/' . $GLOBALS['SysValue']['upload']['version'], $this->_user_ftp_chmod);

        if ($this->base_update_enabled and !copy($this->_backup_path . "temp/upload_backup.sql.gz", $this->_backup_path . 'backups/' . $GLOBALS['SysValue']['upload']['version'] . '/base.sql.gz')) {
            copy($this->_backup_path . "temp/restore.sql", $this->_backup_path . 'backups/' . $GLOBALS['SysValue']['upload']['version'] . '/restore.sql');
            $this->log("" . $GLOBALS['SysValue']['upload']['version'], 'warning', 'remove');
        }

        if ($this->base_update_enabled)
            copy($this->_backup_path . "temp/restore.sql", $this->_backup_path . 'backups/' . $GLOBALS['SysValue']['upload']['version'] . '/restore.sql');


        $archive = new PclZip($this->_backup_path . 'backups/' . $GLOBALS['SysValue']['upload']['version'] . '/files.zip');
        $map = parse_ini_file($this->_backup_path . "temp/upd_conf.txt", 1);
        $zip_files = null;

        if (is_array($map)) {
            foreach ($map as $k => $v) {

                if (!empty($v['files'])) {

                    if (strstr($v['files'], ';')) {
                        $files = explode(";", $v['files']);

                        if (is_array($files)) {
                            foreach ($files as $file) {
                                if (file_exists($_SERVER['DOCUMENT_ROOT'] . $GLOBALS['SysValue']['dir']['dir'] . '/' . $k . '/' . $file))
                                    $zip_files.= $_SERVER['DOCUMENT_ROOT'] . $GLOBALS['SysValue']['dir']['dir'] . '/' . $k . '/' . $file . ',';
                            }
                        }
                    }
                    elseif (file_exists($_SERVER['DOCUMENT_ROOT'] . $GLOBALS['SysValue']['dir']['dir'] . '/' . $k . '/' . $v['files']))
                        $zip_files.= $_SERVER['DOCUMENT_ROOT'] . $GLOBALS['SysValue']['dir']['dir'] . '/' . $k . '/' . $v['files'] . ',';
                }
            }
        }

        if (!empty($zip_files)) {
            $v_list = $archive->create($zip_files, PCLZIP_OPT_REMOVE_PATH, $_SERVER['DOCUMENT_ROOT'] . $GLOBALS['SysValue']['dir']['dir'] . '/');
            if ($v_list == 0) {
                $this->log("" . $archive->errorInfo(true), 'warning', 'remove');
                return false;
            }

            $this->log("");

            //
            $this->chmod($this->_user_ftp_dir . '/backup/backups/' . $GLOBALS['SysValue']['upload']['version'], $this->_user_ftp_re_chmod);
        }
    }

    /**

     */
    function map() {

        //
        if ($this->base_update_enabled) {

            /*
              if (!file_exists("dumper/backup/upload_dump.sql.gz")) {

              return false;
              }

              if (!copy("dumper/backup/upload_dump.sql.gz", $this->_backup_path . "temp/upload_backup.sql.gz")) {

              return false;
              }

              if (!unlink("dumper/backup/upload_dump.sql.gz")) {

              }
             */

            if (!copy($this->_backup_path . "temp/update.sql", "dumper/backup/update.sql")) {
                $this->log("", 'warning', 'remove');
                return false;
            }
        }


        //
        if (!$this->map = parse_ini_file($this->_backup_path . "temp/upd_conf.txt", 1)) {
            $this->log("");
            return false;
        }
    }

    /**

     */
    function ftpConnect() {

        if (!$this->ftp_stream = ftp_connect($this->ftp_host)) {
            $this->log('', 'warning', 'remove');
            return false;
        }

        if (!ftp_login($this->ftp_stream, $this->ftp_login, $this->ftp_password)) {
            $this->log("", 'warning', 'remove');
            return false;
        }

        if (!ftp_pasv($this->ftp_stream, true)) {
            $this->log("", 'warning', 'remove');
            return false;
        }

        if (!ftp_chdir($this->ftp_stream, $this->ftp_folder)) {
            $this->log("" . intval($this->ftp_folder), 'warning', 'remove');
            return false;
        }

        if (!ftp_get($this->ftp_stream, $this->path . '/backup/temp/upd_conf.txt', 'upd_conf.txt', FTP_BINARY)) {
            $this->log("", 'warning', 'remove');
            return false;
        }

        if (@ftp_get($this->ftp_stream, $this->path . '/backup/temp/update.sql', 'update.sql', FTP_BINARY)) {
            $this->log("");
            ftp_get($this->ftp_stream, $this->path . '/backup/temp/restore.sql', 'restore.sql', FTP_BINARY);
            $this->base_update_enabled = true;
        }


        if (ftp_get($this->ftp_stream, $this->path . '/backup/temp/config_update.txt', 'config_update.txt', FTP_BINARY)) {
            $this->log("");
        }

        if (ftp_get($this->ftp_stream, $this->path . '/backup/temp/update.zip', 'update.zip', FTP_BINARY)) {
            $this->log("");
        }

        $this->log("");
    }

    /**

     */
    function checkUpdate() {

        $update_enable = xml2array(UPDATE_PATH, "update", true);
        if ($update_enable) {
            $this->update_status = $update_enable['status'];
            $this->version = $update_enable['name'];
            if ($this->update_status != 'no_update') {

                $this->ftp_host = $update_enable['ftp_host'];
                $this->ftp_login = $update_enable['ftp_login'];
                $this->ftp_password = $update_enable['ftp_password'];
                $this->ftp_folder = $update_enable['os'] . "/" . $update_enable['num'];

                $this->content = $update_enable['content']['item'];

                $this->btn_class = 'btn btn-primary btn-sm navbar-btn update-start';
            } elseif ($update_enable['status'] == 'passive') {
                $this->btn_class = 'btn btn-default btn-sm navbar-btn disabled';
            } elseif ($update_enable['status'] == 'no_update') {
                $this->btn_class = 'btn btn-default btn-sm navbar-btn disabled';
            }
        }
        else
            $this->btn_class = 'hide';
    }

    /**

     */
    function checkBD() {

        if (file_exists("dumper/backup/upload_dump.sql.gz")) {
            $this->log('');
        }
        else
            $this->log('', 'warning', 'remove');
    }

    function log($text, $class = 'success', $icon = 'ok') {
        $this->_log.='<div class="alert alert-' . $class . '" role="alert"><span class="glyphicon glyphicon-' . $icon . '-sign"></span> ' . $text . '</div>';
    }

    function fulllog($text) {
        $this->_fulllog.=$text . '<br>';
    }

    function getLog() {
        return $this->_log;
    }

}

/**

 */
function preExtractCallBack($p_event, $p_header) {
    if ($p_header['folder'] != 1 and $_SERVER["SERVER_ADDR"] != "127.0.0.1" and !getenv("COMSPEC")) {
        unlink($p_header['filename']);
    }
    return 1;
}

?>
API documentation generated by ApiGen