[ 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/modules/pages/database_setup/ -> header_php.php (source)

   1  <?php
   2  /**

   3   * @package Installer

   4   * @access private

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

   6   * @copyright Portions Copyright 2003 osCommerce

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

   8   * @version $Id: header_php.php 5454 2006-12-29 20:10:17Z drbyte $

   9   * @todo -- test with Mac and Fedora Core 2 ... to see why sometimes fields with just '' are written with only one single-quote instead of two

  10   *

  11   */
  12  
  13  if (!isset($_GET['debug'])  && !zen_not_null($_POST['debug']))  define('ZC_UPG_DEBUG',false);
  14  if (!isset($_GET['debug2']) && !zen_not_null($_POST['debug2'])) define('ZC_UPG_DEBUG2',false);
  15  if (!isset($_GET['debug3']) && !zen_not_null($_POST['debug3'])) define('ZC_UPG_DEBUG3',false);
  16  $write_config_files_only = ((isset($_POST['submit']) && $_POST['submit']==ONLY_UPDATE_CONFIG_FILES) || (isset($_POST['configfile']) && zen_not_null($_POST['configfile'])) || (isset($_GET['configfile']) && zen_not_null($_GET['configfile'])) || ZC_UPG_DEBUG3 != false) ? true : false;
  17  
  18  // Turn on progress meter

  19  $zc_show_progress='yes';
  20  if (defined('DO_NOT_USE_PROGRESS_METER') && DO_NOT_USE_PROGRESS_METER == 'do_not_use') $zc_show_progress='no';
  21  
  22  // check to see if we're upgrading

  23  $is_upgrade = $_GET['is_upgrade'];
  24  
  25    $zc_install->error = false;
  26    $zc_install->fatal_error = false;
  27    $zc_install->error_list = array();
  28  
  29    if (isset($_POST['submit'])) {
  30      if ($_POST['db_type'] != 'mysql') $_POST['db_prefix'] = '';  // if not using mysql, don't support prefixes because we don't trap for them

  31      if ($_POST['db_sess'] != 'true' || $_POST['cache_type'] == 'file') {  //if not storing sessions in database, or if caching to file, check folder
  32        $zc_install->isEmpty($_POST['sql_cache_dir'],  ERROR_TEXT_CACHE_DIR_ISEMPTY, ERROR_CODE_CACHE_DIR_ISEMPTY);
  33        $zc_install->isDir($_POST['sql_cache_dir'],  ERROR_TEXT_CACHE_DIR_ISDIR, ERROR_CODE_CACHE_DIR_ISDIR);
  34        $zc_install->isWriteable($_POST['sql_cache_dir'],  ERROR_TEXT_CACHE_DIR_ISWRITEABLE, ERROR_CODE_CACHE_DIR_ISWRITEABLE);
  35      }
  36      $zc_install->noDots($_POST['db_prefix'], ERROR_TEXT_DB_PREFIX_NODOTS, ERROR_CODE_DB_PREFIX_NODOTS);
  37      $zc_install->isEmpty($_POST['db_host'], ERROR_TEXT_DB_HOST_ISEMPTY, ERROR_CODE_DB_HOST_ISEMPTY);
  38      $zc_install->isEmpty($_POST['db_username'], ERROR_TEXT_DB_USERNAME_ISEMPTY, ERROR_CODE_DB_USERNAME_ISEMPTY);
  39      $zc_install->isEmpty($_POST['db_name'], ERROR_TEXT_DB_NAME_ISEMPTY, ERROR_CODE_DB_NAME_ISEMPTY);
  40      $zc_install->fileExists('sql/' . $_POST['db_type'] . '_zencart.sql', ERROR_TEXT_DB_SQL_NOTEXIST, ERROR_CODE_DB_SQL_NOTEXIST);
  41      $zc_install->functionExists($_POST['db_type'], ERROR_TEXT_DB_NOTSUPPORTED, ERROR_CODE_DB_NOTSUPPORTED);
  42      $zc_install->dbConnect($_POST['db_type'], $_POST['db_host'], $_POST['db_name'], $_POST['db_username'], $_POST['db_pass'], ERROR_TEXT_DB_CONNECTION_FAILED, ERROR_CODE_DB_CONNECTION_FAILED,ERROR_TEXT_DB_NOTEXIST, ERROR_CODE_DB_NOTEXIST);
  43      $zc_install->dbExists(false, $_POST['db_type'], $_POST['db_host'], $_POST['db_username'], $_POST['db_pass'], $_POST['db_name'], ERROR_TEXT_DB_NOTEXIST, ERROR_CODE_DB_NOTEXIST);
  44  
  45      if (!$zc_install->fatal_error) {
  46        include('../includes/classes/db/' . $_POST['db_type'] . '/query_factory.php');
  47        if ($_POST['db_sess'] == 'true') {
  48          $_POST['db_sess'] = 'db';
  49        } else {
  50          $_POST['db_sess'] = '';
  51        }
  52        $virtual_http_path = parse_url($_GET['virtual_http_path']);
  53        $http_server = $virtual_http_path['scheme'] . '://' . $virtual_http_path['host'];
  54        $http_catalog = $virtual_http_path['path'];
  55        if (isset($virtual_http_path['port']) && !empty($virtual_http_path['port'])) {
  56          $http_server .= ':' . $virtual_http_path['port'];
  57        }
  58        if (substr($http_catalog, -1) != '/') {
  59          $http_catalog .= '/';
  60        }
  61        $_POST['db_prefix'] == str_replace('-', '_', $_POST['db_prefix']);
  62        $sql_cache_dir = $_GET['sql_cache_dir'];
  63        $cache_type = $_GET['cache_type'];
  64        $https_server = $_GET['virtual_https_server'];
  65        $https_catalog = $_GET['virtual_https_path'];
  66        //if the https:// entries were left blank, use catalog versions

  67        if ($https_server=='' || $https_server=='https://') {$https_server=$http_server;}
  68        if ($https_catalog=='') {$https_catalog=$http_catalog;}
  69        $https_catalog_path = ereg_replace($https_server,'',$https_catalog) . '/';
  70        $https_catalog = $https_catalog_path;
  71  
  72        //now let's write the files

  73        // Catalog version first:

  74        require('includes/store_configure.php');
  75        $config_file_contents_catalog = $file_contents;
  76        $fp = @fopen($_GET['physical_path'] . '/includes/configure.php', 'w');
  77        if ($fp) {
  78          fputs($fp, $file_contents);
  79          fclose($fp);
  80          @chmod($_GET['physical_path'] . '/includes/configure.php', 0644);
  81        }
  82        // now Admin version:

  83        require('includes/admin_configure.php');
  84        $config_file_contents_admin = $file_contents;
  85        $fp = @fopen($_GET['physical_path'] . '/admin/includes/configure.php', 'w');
  86        if ($fp) {
  87          fputs($fp, $file_contents);
  88          fclose($fp);
  89          @chmod($_GET['physical_path'] . '/admin/includes/configure.php', 0644);
  90        }
  91  
  92        // test whether the files were written successfully

  93        $ztst_http_server = zen_read_config_value('HTTP_SERVER');
  94        $ztst_db_server = zen_read_config_value('DB_SERVER');
  95        $ztst_sqlcachedir = zen_read_config_value('DIR_FS_SQL_CACHE');
  96        if ($ztst_http_server != $http_server || $ztst_db_server != $_POST['db_host'] || $ztst_sqlcachedir != $_POST['sql_cache_dir']) {
  97          $zc_install->setError(ERROR_TEXT_COULD_NOT_WRITE_CONFIGURE_FILES, ERROR_CODE_COULD_NOT_WRITE_CONFIGURE_FILES, true);
  98        }
  99  
 100        //OK, files written -- now let's connect to the database and load the tables:

 101        if ($is_upgrade && !$zc_install->fatal_error) { //if upgrading, move on to the upgrade page
 102           //update the cache folder setting:

 103           $db = new queryFactory;
 104           $db->Connect($_POST['db_host'], $_POST['db_username'], $_POST['db_pass'], $_POST['db_name'], true);
 105           $sql = "update ".$_POST['db_prefix']."configuration set configuration_value='".$_POST['sql_cache_dir']."' where configuration_key='SESSION_WRITE_DIRECTORY'";
 106           $db->Execute($sql);
 107           //update the logging_folder setting:

 108           $sql = "update ".$_POST['db_prefix']."configuration set configuration_value='".$_POST['sql_cache_dir']."/page_parse_time.log' where configuration_key='STORE_PAGE_PARSE_TIME_LOG'";
 109           $db->Execute($sql);
 110           //update the phpbb setting:

 111           $sql = "update ".$_POST['db_prefix']."configuration set configuration_value='".$_GET['use_phpbb']."' where configuration_key='PHPBB_LINKS_ENABLED'";
 112           $db->Execute($sql);
 113  
 114           header('location: index.php?main_page=database_upgrade&language=' . $language);
 115           exit;
 116        } elseif (!$zc_install->fatal_error && $_POST['submit']==SAVE_DATABASE_SETTINGS) {
 117               // not upgrading - load the fresh database

 118           $db = new queryFactory;
 119           $db->Connect($_POST['db_host'], $_POST['db_username'], $_POST['db_pass'], $_POST['db_name'], true);
 120  
 121           if ($zc_show_progress == 'yes') {
 122  ?>
 123  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 124  <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
 125  <head>
 126  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 127  <title>Zen Cart&trade; Installer</title>
 128  <link rel="stylesheet" type="text/css" href="includes/templates/template_default/css/stylesheet.css">
 129  </head>
 130  <div id="wrap">
 131    <div id="header">
 132    <img src="includes/templates/template_default/images/zen_header_bg.jpg">
 133    </div>
 134  <div class="progress" align="center"><?php echo INSTALLATION_IN_PROGRESS; ?><br /><br />
 135  <?php
 136           }
 137           executeSql('sql/' . $_POST['db_type'] . '_zencart.sql', $_POST['db_name'], $_POST['db_prefix']);
 138  
 139           //update the cache folder setting:

 140           $sql = "update ".$_POST['db_prefix']."configuration set configuration_value='".$_POST['sql_cache_dir']."' where configuration_key='SESSION_WRITE_DIRECTORY'";
 141           $db->Execute($sql);
 142           //update the phpbb setting:

 143           $sql = "update ".$_POST['db_prefix']."configuration set configuration_value='".$_GET['use_phpbb']."' where configuration_key='PHPBB_LINKS_ENABLED'";
 144           $db->Execute($sql);
 145           if (file_exists('includes/local/developers_' . $_POST['db_type'] . '.sql')) {
 146             executeSql('includes/local/developers_' . $_POST['db_type'] . '.sql', $_POST['db_name'], $_POST['db_prefix']);
 147           }
 148  
 149           /**

 150            * Support for SQL Plugins in installer 

 151            */
 152           $sqlpluginsdir = 'sql/plugins/';
 153           if ($dir = @dir($sqlpluginsdir)) {
 154             while ($file = $dir->read()) {
 155               if (!is_dir($sqlpluginsdir . $file)) {
 156                 if (ZC_UPG_DEBUG3) echo '<br />checking file: ' . $sqlpluginsdir . $file;
 157                 if (preg_match('/^' . $_POST['db_type'] . '.*\.sql$/', $file) > 0) {
 158  
 159                   $directory_array[] = $file;
 160                 }
 161               }
 162             }
 163             if (sizeof($directory_array)) {
 164               sort($directory_array);
 165             }
 166             $dir->close();
 167           }
 168           for ($i = 0, $n = sizeof($directory_array); $i < $n; $i++) {
 169             $file = $directory_array[$i];
 170             if (file_exists($sqlpluginsdir . $file)) {
 171               echo '<br />Processing Plugin: ' . $sqlpluginsdir . $file . '<br />';
 172               executeSql($sqlpluginsdir . $file, $_POST['db_name'], $_POST['db_prefix']);
 173             }
 174           }
 175           // Close the database connection

 176           $db->Close();
 177           if (ZC_UPG_DEBUG3) die('ready to continue');
 178           // done - now on to next page for Store Setup (entries into database)

 179  
 180           if ($zc_show_progress == 'yes') {
 181             $linkto = 'index.php?main_page=store_setup&language=' . $language;
 182             $link = '<a href="' . $linkto . '">' . '<br /><br />Done!<br />Click Here To Continue<br /><br />' . '</a>';
 183             echo "\n<script type=\"text/javascript\">\nwindow.location=\"$linkto\";\n</script>\n";
 184             echo '<noscript>'.$link.'</noscript><br /><br />';
 185             echo '<div id="footer"><p>Copyright &copy; 2003-' . date('Y') . ' <a href="http://www.zen-cart.com" target="_blank">Zen Cart</a></p></div></div></body></html>';
 186           } else {
 187             header('location: index.php?main_page=store_setup&language=' . $language);
 188           }
 189           exit;
 190        } elseif ($write_config_files_only && !$zc_install->fatal_error) {
 191           header('location: index.php?main_page=database_upgrade&language=' . $language);
 192           exit;
 193        } //endif $is_upgrade

 194      }
 195    }
 196  
 197  if ($is_upgrade) { // read previous settings from configure.php
 198     $zdb_type       = zen_read_config_value('DB_TYPE');
 199     $zdb_prefix     = zen_read_config_value('DB_PREFIX');
 200     $zdb_server     = zen_read_config_value('DB_SERVER');
 201     $zdb_user       = zen_read_config_value('DB_SERVER_USERNAME');
 202     $zdb_pwd        = zen_read_config_value('DB_SERVER_PASSWORD');
 203     $zdb_name       = zen_read_config_value('DB_DATABASE');
 204     $zdb_sql_cache  = ($_GET['sql_cache']=='') ? zen_read_config_value('DIR_FS_SQL_CACHE') : $_GET['sql_cache'];
 205     $zdb_cache_type = zen_read_config_value('SQL_CACHE_METHOD');
 206     $zdb_persistent = zen_read_config_value('USE_PCONNECT');
 207     $zdb_sessions   = (zen_read_config_value('STORE_SESSIONS')) ? 'true' : 'false';
 208  
 209    } else { // set defaults:
 210     $zdb_type       = 'MySQL';
 211     $zdb_prefix     = '';
 212     $zdb_server     = 'localhost';
 213     $zdb_user       = 'root';
 214     $zdb_name       = 'zencart';
 215     $zdb_sql_cache  = $_GET['sql_cache'];
 216     $zdb_cache_type = 'none';
 217     $zdb_persistent = 'false';
 218     $zdb_sessions   = 'true';
 219   } //endif $is_upgrade

 220  
 221    if (!isset($_POST['db_host']))     $_POST['db_host']    = $zdb_server;
 222    if (!isset($_POST['db_username'])) $_POST['db_username']= $zdb_user;
 223    if (!isset($_POST['db_name']))     $_POST['db_name']    = $zdb_name;
 224    if (!isset($_POST['sql_cache']))   $_POST['sql_cache']  = $zdb_sql_cache;
 225    if (!isset($_POST['db_conn']))     $_POST['db_conn']    = $zdb_persistent;
 226    if (!isset($_POST['db_sess']))     $_POST['db_sess']    = $zdb_sessions;
 227    if (!isset($_POST['db_prefix']))   $_POST['db_prefix']  = $zdb_prefix;
 228    if (!isset($_POST['db_type']))     $_POST['db_type']    = $zdb_type;
 229    if (!isset($_POST['cache_type']))  $_POST['cache_type'] = $zdb_cache_type;
 230  
 231    setInputValue($_POST['db_host'],    'DATABASE_HOST_VALUE', $zdb_server);
 232    setInputValue($_POST['db_username'],'DATABASE_USERNAME_VALUE', $zdb_user);
 233    setInputValue($_POST['db_name'],    'DATABASE_NAME_VALUE', $zdb_name);
 234    setInputValue($_POST['sql_cache'],  'SQL_CACHE_VALUE', $zdb_sql_cache);
 235    setInputValue($_POST['db_prefix'],  'DATABASE_NAME_PREFIX', $zdb_prefix );
 236    setRadioChecked($_POST['db_conn'],  'DB_CONN', $zdb_persistent);
 237    setRadioChecked($_POST['db_sess'],  'DB_SESS', $zdb_sessions);
 238  ?>


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