[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/zc_install/includes/classes/ -> installer.php (source)

   1  <?php
   2  /**

   3   * installer Class.

   4   * This class is used during the installation and upgrade processes *

   5   * @package Installer

   6   * @access private

   7   * @copyright Copyright 2003-2006 Zen Cart Development Team

   8   * @copyright Portions Copyright 2003 osCommerce

   9   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

  10   * @version $Id: installer.php 4849 2006-10-27 19:09:22Z drbyte $

  11   */
  12  
  13  
  14    class installer {
  15  
  16      function installer() {
  17        $this->php_version = PHP_VERSION;
  18        $this->user_agent = $_SERVER['HTTP_USER_AGENT'];
  19      }
  20  
  21      function test_admin_configure($zp_error_text, $zp_error_code, $fatal = false) {
  22        if (!file_exists('../admin/includes/configure.php')) {
  23          @chmod('../admin/includes', 0777);
  24          @touch('../admin/includes/configure.php');
  25          @chmod('../admin/includes', 0755);
  26          if (!file_exists('../admin/includes/configure.php')) {
  27            $this->setError($zp_error_text, $zp_error_code, $fatal);
  28            return false;
  29          }
  30        } else {
  31          return true;
  32        }
  33      }
  34  
  35  
  36      function test_admin_configure_write($zp_error_text, $zp_error_code) {
  37        $fp = @fopen('../admin/includes/configure.php', 'a');
  38        if (!is_writeable('../admin/includes/configure.php') || (!$fp) ) {
  39          $this->setError($zp_error_text, $zp_error_code, true);
  40          $this->admin_config_writable=false;
  41        } else {
  42          $this->admin_config_writable=true;
  43        }
  44      }
  45  
  46      function test_store_configure_write($zp_error_text, $zp_error_code) {
  47        $fp = @fopen('../includes/configure.php', 'a');
  48        if (!is_writeable('../includes/configure.php') || (!$fp) ) {
  49          $this->setError($zp_error_text, $zp_error_code, true);
  50          $this->store_config_writable=false;
  51        } else {
  52          $this->store_config_writable=true;
  53        }
  54      }
  55  
  56      function test_store_configure($zp_error_text, $zp_error_code) {
  57        if (!file_exists('../includes/configure.php')) {
  58          @chmod('../includes', 0777);
  59          @touch('../includes/configure.php');
  60          @chmod('../includes', 0755);
  61          if (!file_exists('../includes/configure.php')) {
  62            $this->setError($zp_error_text, $zp_error_code, true);
  63            return false;
  64          }
  65        } else {
  66          return true;
  67        }
  68      }
  69  
  70      function test_php_version ($zp_test, $test_version, $zp_error_text='', $zp_error_code='', $zp_fatal=false) {
  71        if (isset($_GET['ignorephpver']) && $_GET['ignorephpver']=='1') return false;
  72        $string = explode('.',substr($this->php_version,0,6));
  73        foreach ($string as $key=>$value) {
  74          $string[$key] = str_pad((int)$value, 2, '0', STR_PAD_LEFT);
  75        }
  76        $myver_string = implode('',$string);
  77  
  78        $string = explode('.',$test_version);
  79        foreach ($string as $key=>$value) {
  80          $string[$key] = str_pad($value, 2, '0', STR_PAD_LEFT);
  81        }
  82        $test_version = implode('',$string);
  83  
  84        $zp_error_text = $this->php_version . ' ' . $zp_error_text;
  85  //echo '<br />$myver='.$myver_string . '  $test_ver = ' . $test_version . ' &nbsp;&nbsp;&nbsp;TEST: ' . $zp_test . '&nbsp;&nbsp;error-text: ' . $zp_error_text;

  86  
  87        switch ($zp_test) {
  88          case '=':
  89            if ($myver_string == $test_version) {
  90                        $this->setError($zp_error_text, $zp_error_code, $zp_fatal);
  91              return true;
  92            }
  93            break;
  94          case '<':
  95            if ($myver_string < $test_version) {
  96                        $this->setError($zp_error_text, $zp_error_code, $zp_fatal);
  97              return true;
  98            }
  99          break;
 100        }
 101        return false;
 102    }
 103  
 104      function isEmpty($zp_test, $zp_error_text, $zp_error_code) {
 105        if (!$zp_test || $zp_test=='http://' || $zp_test=='https://' ) {
 106          $this->setError($zp_error_text, $zp_error_code, true);
 107        }
 108      }
 109  
 110      function noDots($zp_test, $zp_error_text, $zp_error_code) {
 111        if (str_replace(array('.','/',"\\"),'',$zp_test) != $zp_test) {
 112          $this->setError($zp_error_text, $zp_error_code, true);
 113        }
 114      }
 115  
 116      function fileExists($zp_file, $zp_error_text, $zp_error_code) {
 117        if (!file_exists($zp_file)) {
 118          $this->setError($zp_error_text, $zp_error_code, true);
 119        }
 120      }
 121  
 122      function isDir($zp_file, $zp_error_text, $zp_error_code) {
 123        if (!is_dir($zp_file)) {
 124          $this->setError($zp_error_text, $zp_error_code, true);
 125        }
 126      }
 127  
 128      function isWriteable($zp_file, $zp_error_text='', $zp_error_code='') {
 129        $retVal = true;
 130        if (is_dir($zp_file)) $zp_file .= '/test_writable.txt';
 131        $fp = @fopen($zp_file, 'a');
 132        if (!is_writeable($zp_file) || (!$fp) ) {
 133          if ($zp_error_code !='') $this->setError($zp_error_text, $zp_error_code, true);
 134          $retVal = false;
 135        }
 136        @fclose($fp);
 137        if (file_exists($zp_file) && !strstr($zp_file, 'configure.php')) @unlink($zp_file);
 138        return $retVal;
 139      }
 140  
 141      function functionExists($zp_type, $zp_error_text, $zp_error_code) {
 142        if ($zp_type == 'mysql') {
 143          $function = 'mysql_connect';
 144        }
 145        if (!function_exists($function)) {
 146          $this->setError($zp_error_text, $zp_error_code, true);
 147        }
 148      }
 149  
 150      function dbConnect($zp_type, $zp_host, $zp_database, $zp_username, $zp_pass, $zp_error_text, $zp_error_code, $zp_error_text2=ERROR_TEXT_DB_NOTEXIST, $zp_error_code2=ERROR_CODE_DB_NOTEXIST) {
 151        if ($this->error == false) {
 152          if ($zp_type == 'mysql') {
 153            if (@mysql_connect($zp_host, $zp_username, $zp_pass) == false ) {
 154              $this->setError($zp_error_text.'<br />'.@mysql_error(), $zp_error_code, true);
 155            } else {
 156              if (!@mysql_select_db($zp_database)) {
 157                $this->setError($zp_error_text2.'<br />'.@mysql_error(), $zp_error_code2, true);
 158              } else {
 159                @mysql_close();
 160              }
 161            }
 162          }
 163        }
 164      }
 165  
 166      function dbCreate($zp_create, $zp_type, $zp_name, $zp_error_text, $zp_error_code) {
 167        if ($zp_create == 'true' && $this->error == false) {
 168          if ($zp_type == 'mysql' && (@mysql_query('CREATE DATABASE ' . $zp_name) == false)) {
 169            $this->setError($zp_error_text, $zp_error_code, true);
 170          }
 171        }
 172      }
 173  
 174      function dbExists($zp_create, $zp_type, $zp_host, $zp_username, $zp_pass, $zp_name, $zp_error_text, $zp_error_code) {
 175        //    echo $zp_create;

 176        if ($zp_create != 'true' && $this->error == false) {
 177          if ($zp_type == 'mysql') {
 178            @mysql_connect($zp_host, $zp_username, $zp_pass);
 179            if (@mysql_select_db($zp_name) == false) {
 180              $this->setError($zp_error_text.'<br />'.@mysql_error(), $zp_error_code, true);
 181            }
 182          }
 183        }
 184      }
 185  
 186      function isEmail($zp_param, $zp_error_text, $zp_error_code) {
 187        if (zen_validate_email($zp_param) == false) {
 188          $this->setError($zp_error_text, $zp_error_code, true);
 189        }
 190      }
 191  
 192      function isEqual($zp_param1, $zp_param2, $zp_error_text, $zp_error_code) {
 193        if ($zp_param1 != $zp_param2) {
 194          $this->setError($zp_error_text, $zp_error_code, true);
 195        }
 196      }
 197  
 198      function setError($zp_error_text, $zp_error_code, $zp_fatal = false) {
 199        $this->error = true;
 200        $this->fatal_error = $zp_fatal;
 201        $this->error_array[] = array('text'=>$zp_error_text, 'code'=>$zp_error_code);
 202      }
 203    }
 204  
 205  ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics