Exemple #1
0
/* Redefine REQUEST_URI if empty (on some webservers...) */
if (!isset($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] == '') {
    $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
}
if ($tmp = strpos($_SERVER['REQUEST_URI'], '?')) {
    $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 0, $tmp);
}
$_SERVER['REQUEST_URI'] = str_replace('//', '/', $_SERVER['REQUEST_URI']);
define('INSTALL_VERSION', '1.3.2.3');
define('INSTALL_PATH', dirname(__FILE__));
include_once INSTALL_PATH . '/classes/ToolsInstall.php';
define('SETTINGS_FILE', INSTALL_PATH . '/../config/settings.inc.php');
define('DEFINES_FILE', INSTALL_PATH . '/../config/defines.inc.php');
define('INSTALLER__PS_BASE_URI', substr($_SERVER['REQUEST_URI'], 0, -1 * (strlen($_SERVER['REQUEST_URI']) - strrpos($_SERVER['REQUEST_URI'], '/')) - strlen(substr(dirname($_SERVER['REQUEST_URI']), strrpos(dirname($_SERVER['REQUEST_URI']), '/') + 1))));
define('INSTALLER__PS_BASE_URI_ABSOLUTE', 'http://' . ToolsInstall::getHttpHost(false, true) . INSTALLER__PS_BASE_URI);
// XML Header
header('Content-Type: text/xml');
// Switching method
if (isset($_GET['method'])) {
    switch ($_GET['method']) {
        case 'checkConfig':
            include_once 'xml/checkConfig.php';
            break;
        case 'checkDB':
            include_once 'xml/checkDB.php';
            break;
        case 'createDB':
            include_once 'xml/createDB.php';
            break;
        case 'checkMail':
Exemple #2
0
<?php

include INSTALL_PATH . '/classes/ToolsInstall.php';
$resultDB = ToolsInstall::checkDB($_GET['server'], $_GET['login'], $_GET['password'], $_GET['name']);
die("<action result='" . ($resultDB === true ? "ok" : "fail") . "' error='" . ($resultDB === true ? "" : $resultDB) . "'/>\n");
    include_once INSTALL_PATH . '/../config/settings.inc.php';
    $oldversion = _PS_VERSION_;
} else {
    die('<action result="fail" error="30" />' . "\n");
}
$versionCompare = version_compare(INSTALL_VERSION, _PS_VERSION_);
if ($versionCompare == '-1') {
    die('<action result="fail" error="27" />' . "\n");
} elseif ($versionCompare == 0) {
    die('<action result="fail" error="28" />' . "\n");
} elseif ($versionCompare === false) {
    die('<action result="fail" error="29" />' . "\n");
}
//check DB access
include INSTALL_PATH . '/classes/ToolsInstall.php';
$resultDB = ToolsInstall::checkDB(_DB_SERVER_, _DB_USER_, _DB_PASSWD_, _DB_NAME_, false);
if ($resultDB !== true) {
    die("<action result='fail' error='" . $resultDB . "'/>\n");
}
//custom sql file creation
$upgradeFiles = array();
if ($handle = opendir(INSTALL_PATH . '/sql/upgrade')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != '.' and $file != '..') {
            $upgradeFiles[] = str_replace(".sql", "", $file);
        }
    }
    closedir($handle);
}
if (empty($upgradeFiles)) {
    die('<action result="fail" error="31" />' . "\n");
 /**
  * Converts a simpleXML element into an array. Preserves attributes and everything.
  * You can choose to get your elements either flattened, or stored in a custom index that
  * you define.
  * For example, for a given element
  * <field name="someName" type="someType"/>
  * if you choose to flatten attributes, you would get:
  * $array['field']['name'] = 'someName';
  * $array['field']['type'] = 'someType';
  * If you choose not to flatten, you get:
  * $array['field']['@attributes']['name'] = 'someName';
  * _____________________________________
  * Repeating fields are stored in indexed arrays. so for a markup such as:
  * <parent>
  * <child>a</child>
  * <child>b</child>
  * <child>c</child>
  * </parent>
  * you array would be:
  * $array['parent']['child'][0] = 'a';
  * $array['parent']['child'][1] = 'b';
  * ...And so on.
  * _____________________________________
  * @param simpleXMLElement $xml the XML to convert
  * @param bool $flattenValues    Choose wether to flatten values
  *                                    or to set them under a particular index.
  *                                    defaults to true;
  * @param bool $flattenAttributes Choose wether to flatten attributes
  *                                    or to set them under a particular index.
  *                                    Defaults to true;
  * @param bool $flattenChildren    Choose wether to flatten children
  *                                    or to set them under a particular index.
  *                                    Defaults to true;
  * @param string $valueKey            index for values, in case $flattenValues was set to
  *                            false. Defaults to "@value"
  * @param string $attributesKey        index for attributes, in case $flattenAttributes was set to
  *                            false. Defaults to "@attributes"
  * @param string $childrenKey        index for children, in case $flattenChildren was set to
  *                            false. Defaults to "@children"
  * @return array the resulting array.
  */
 public static function simpleXMLToArray($xml, $flattenValues = true, $flattenAttributes = true, $flattenChildren = true, $valueKey = '@value', $attributesKey = '@attributes', $childrenKey = '@children')
 {
     $return = array();
     if (!$xml instanceof SimpleXMLElement) {
         return $return;
     }
     $name = $xml->getName();
     $_value = trim((string) $xml);
     if (strlen($_value) == 0) {
         $_value = null;
     }
     if ($_value !== null) {
         if (!$flattenValues) {
             $return[$valueKey] = $_value;
         } else {
             $return = $_value;
         }
     }
     $children = array();
     $first = true;
     foreach ($xml->children() as $elementName => $child) {
         $value = ToolsInstall::simpleXMLToArray($child, $flattenValues, $flattenAttributes, $flattenChildren, $valueKey, $attributesKey, $childrenKey);
         if (isset($children[$elementName])) {
             if ($first) {
                 $temp = $children[$elementName];
                 unset($children[$elementName]);
                 $children[$elementName][] = $temp;
                 $first = false;
             }
             $children[$elementName][] = $value;
         } else {
             $children[$elementName] = $value;
         }
     }
     if (count($children) > 0) {
         if (!$flattenChildren) {
             $return[$childrenKey] = $children;
         } else {
             $return = array_merge($return, $children);
         }
     }
     $attributes = array();
     foreach ($xml->attributes() as $name => $value) {
         $attributes[$name] = trim($value);
     }
     if (count($attributes) > 0) {
         if (!$flattenAttributes) {
             $return[$attributesKey] = $attributes;
         } else {
             $return = array_merge($return, $attributes);
         }
     }
     return $return;
 }
     if (Configuration::get('PS_LANG_DEFAULT') == 1) {
         $sqlParams[] = 'UPDATE `' . _DB_PREFIX_ . 'configuration` SET `value` = (SELECT id_lang FROM ' . _DB_PREFIX_ . 'lang WHERE iso_code = \'' . pSQL($_GET['isoCode']) . '\') WHERE name = \'PS_LANG_DEFAULT\'';
         // This request is used when _PS_MODE_DEV_ is set to true
         $sqlParams[] = 'UPDATE `' . _DB_PREFIX_ . 'lang` SET `active` = 0 WHERE `iso_code` != \'' . pSQL($_GET['isoCode']) . '\'';
     } else {
         $sqlParams[] = 'UPDATE `' . _DB_PREFIX_ . 'lang` SET `active` = 0 WHERE `id_lang` != ' . Configuration::get('PS_LANG_DEFAULT');
     }
 }
 if (isset($_GET['infosMailMethod']) and $_GET['infosMailMethod'] == "smtp") {
     $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_SERVER', '" . pSQL($_GET['smtpSrv']) . "', NOW(), NOW())";
     $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_USER', '" . pSQL($_GET['smtpLogin']) . "', NOW(), NOW())";
     $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_PASSWD', '" . pSQL($_GET['smtpPassword']) . "', NOW(), NOW())";
     $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_SMTP_ENCRYPTION', '" . pSQL($_GET['smtpEnc']) . "', NOW(), NOW())";
     $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_SMTP_PORT', '" . pSQL($_GET['smtpPort']) . "', NOW(), NOW())";
 }
 $sqlParams[] = 'INSERT INTO ' . _DB_PREFIX_ . 'employee (id_employee, lastname, firstname, email, passwd, last_passwd_gen, bo_theme, active, id_profile, id_lang) VALUES (NULL, \'' . pSQL(ToolsInstall::ucfirst($_GET['infosName'])) . '\', \'' . pSQL(ToolsInstall::ucfirst($_GET['infosFirstname'])) . '\', \'' . pSQL($_GET['infosEmail']) . '\', \'' . md5(pSQL(_COOKIE_KEY_ . $_GET['infosPassword'])) . '\', \'' . date('Y-m-d h:i:s', strtotime('-360 minutes')) . '\', \'oldschool\', 1, 1, (SELECT `value` FROM `' . _DB_PREFIX_ . 'configuration` WHERE `name` = \'PS_LANG_DEFAULT\' LIMIT 1))';
 $sqlParams[] = 'INSERT INTO ' . _DB_PREFIX_ . 'contact (id_contact, email, customer_service) VALUES (NULL, \'' . pSQL($_GET['infosEmail']) . '\', 1), (NULL, \'' . pSQL($_GET['infosEmail']) . '\', 1)';
 if (function_exists('mcrypt_encrypt')) {
     $settings = file_get_contents(dirname(__FILE__) . '/../../config/settings.inc.php');
     if (!strstr($settings, '_RIJNDAEL_KEY_')) {
         $key_size = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
         $key = Tools::passwdGen($key_size);
         $settings = preg_replace('/define\\(\'_COOKIE_KEY_\', \'([a-z0-9=\\/+-_]+)\'\\);/i', 'define(\'_COOKIE_KEY_\', \'\\1\');' . "\n" . 'define(\'_RIJNDAEL_KEY_\', \'' . $key . '\');', $settings);
     }
     if (!strstr($settings, '_RIJNDAEL_IV_')) {
         $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
         $iv = base64_encode(mcrypt_create_iv($iv_size, MCRYPT_RAND));
         $settings = preg_replace('/define\\(\'_COOKIE_IV_\', \'([a-z0-9=\\/+-_]+)\'\\);/i', 'define(\'_COOKIE_IV_\', \'\\1\');' . "\n" . 'define(\'_RIJNDAEL_IV_\', \'' . $iv . '\');', $settings);
     }
     if (file_put_contents(dirname(__FILE__) . '/../../config/settings.inc.php', $settings)) {
         $sqlParams[] = 'UPDATE ' . _DB_PREFIX_ . 'configuration SET value = 1 WHERE name = \'PS_CIPHER_ALGORITHM\'';
Exemple #6
0
			<link rel="stylesheet" type="text/css" media="all" href="view.css"/>
			</head>
			<body>
				<p id="php5_nok">PrestaShop requires <b>PHP5 or later</b>, you are currently running: <b>' . phpversion() . '</b><br />
				' . lang('If you do not know how to enable it, use our turnkey solution PrestaBox at') . ' <a href="http://www.prestabox.com">http://www.prestabox.com</a>.</p>
	</body></html>';
    die;
}
require dirname(__FILE__) . '/../config/autoload.php';
include_once INSTALL_PATH . '/classes/ToolsInstall.php';
include_once INSTALL_PATH . '/classes/GetVersionFromDb.php';
/* Prevent from bad URI parsing when using index.php */
$requestUri = str_replace('index.php', '', $_SERVER['REQUEST_URI']);
$tmpBaseUri = substr($requestUri, 0, -1 * (strlen($requestUri) - strrpos($requestUri, '/')) - strlen(substr(substr($requestUri, 0, -1), strrpos(substr($requestUri, 0, -1), "/") + 1)));
define('PS_BASE_URI', $tmpBaseUri[strlen($tmpBaseUri) - 1] == '/' ? $tmpBaseUri : $tmpBaseUri . '/');
define('PS_BASE_URI_ABSOLUTE', 'http://' . ToolsInstall::getHttpHost(false, true) . PS_BASE_URI);
/* Old version detection */
$oldversion = false;
$sameVersions = false;
$tooOld = true;
$installOfOldVersion = false;
if (file_exists(INSTALL_PATH . '/../config/settings.inc.php')) {
    include INSTALL_PATH . '/../config/settings.inc.php';
    $oldversion = _PS_VERSION_;
    $tooOld = version_compare($oldversion, MINIMUM_VERSION_TO_UPDATE) == -1;
    $sameVersions = version_compare($oldversion, INSTALL_VERSION) == 0;
    $installOfOldVersion = version_compare($oldversion, INSTALL_VERSION) == 1;
}
include INSTALL_PATH . '/classes/LanguagesManager.php';
$lm = new LanguageManager(dirname(__FILE__) . '/langs/list.xml');
$_LANG = array();
    $sqlParams = array();
    $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_SHOP_NAME', '" . pSQL($_GET['infosShop']) . "', NOW(), NOW())";
    $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_SHOP_EMAIL', '" . pSQL($_GET['infosEmail']) . "', NOW(), NOW())";
    $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_METHOD', '" . pSQL($_GET['infosMailMethod'] == "smtp" ? "2" : "1") . "', NOW(), NOW())";
    $sqlParams[] = 'UPDATE ' . _DB_PREFIX_ . 'configuration SET value = (SELECT id_lang FROM ' . _DB_PREFIX_ . 'lang WHERE iso_code = \'' . pSQL($_GET['isoCode']) . '\') WHERE name = \'PS_LANG_DEFAULT\'';
    if (intval($_GET['infosCountry']) != 0) {
        $sqlParams[] = 'UPDATE ' . _DB_PREFIX_ . 'configuration SET value = ' . intval($_GET['infosCountry']) . ' WHERE name = \'PS_COUNTRY_DEFAULT\'';
    }
    if (isset($_GET['infosMailMethod']) and $_GET['infosMailMethod'] == "smtp") {
        $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_SERVER', '" . pSQL($_GET['smtpSrv']) . "', NOW(), NOW())";
        $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_USER', '" . pSQL($_GET['smtpLogin']) . "', NOW(), NOW())";
        $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_PASSWD', '" . pSQL($_GET['smtpPassword']) . "', NOW(), NOW())";
        $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_SMTP_ENCRYPTION', '" . pSQL($_GET['smtpEnc']) . "', NOW(), NOW())";
        $sqlParams[] = "INSERT INTO " . _DB_PREFIX_ . "configuration (name, value, date_add, date_upd) VALUES ('PS_MAIL_SMTP_PORT', '" . pSQL($_GET['smtpPort']) . "', NOW(), NOW())";
    }
    $sqlParams[] = 'INSERT INTO ' . _DB_PREFIX_ . 'employee (id_employee, lastname, firstname, email, passwd, last_passwd_gen, active, id_profile) VALUES (NULL, \'' . pSQL(ToolsInstall::strtoupper($_GET['infosName'])) . '\', \'' . pSQL(ToolsInstall::ucfirst($_GET['infosFirstname'])) . '\', \'' . pSQL($_GET['infosEmail']) . '\', \'' . md5(pSQL(_COOKIE_KEY_ . $_GET['infosPassword'])) . '\', \'' . date('Y-m-d h:i:s', strtotime('-360 minutes')) . '\', 1, 1)';
    $sqlParams[] = 'INSERT INTO ' . _DB_PREFIX_ . 'contact (id_contact, email) VALUES (NULL, \'' . pSQL($_GET['infosEmail']) . '\'), (NULL, \'' . pSQL($_GET['infosEmail']) . '\')';
    $dbInstance = Db::getInstance();
    foreach ($sqlParams as $query) {
        if (!$dbInstance->Execute($query)) {
            $error['infosInsertSQL'] = '11';
        }
    }
    unset($dbInstance);
}
//////////////////////////
// Building XML Response//
//////////////////////////
echo '<shopConfig>' . "\n";
foreach ($error as $key => $line) {
    echo '<field id="' . $key . '" result="' . ($line != "" ? 'fail' : 'ok') . '" error="' . $line . '" />' . "\n";
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
include_once INSTALL_PATH . '/classes/ToolsInstall.php';
$smtpChecked = trim($_GET['mailMethod']) == 'smtp';
$smtpServer = $_GET['smtpSrv'];
$content = $_GET['testMsg'];
$subject = $_GET['testSubject'];
$type = 'text/html';
$to = $_GET['testEmail'];
$from = 'no-reply@' . ToolsInstall::getHttpHost(false, true, true);
$smtpLogin = $_GET['smtpLogin'];
$smtpPassword = $_GET['smtpPassword'];
$smtpPort = $_GET['smtpPort'];
$smtpEncryption = $_GET['smtpEnc'];
$result = ToolsInstall::sendMail($smtpChecked, $smtpServer, $content, $subject, $type, $to, $from, $smtpLogin, $smtpPassword, $smtpPort, $smtpEncryption);
die($result ? '<action result="ok"/>' : '<action result="fail"/>');
Exemple #9
0
// - include : variable $result available after inclusion
// 3) file_get_contents()
// - eval : $res = eval(file_get_contents());
if (empty($return_type) || $return_type == 'xml') {
    header('Content-Type: text/xml');
    echo $result;
} else {
    // result in xml to array
    $result = simplexml_load_string($result);
    if (!class_exists('ToolsInstall', false)) {
        if (file_exists(_PS_INSTALL_PATH_ . '/upgrade/classes/ToolsInstall.php')) {
            include_once _PS_INSTALL_PATH_ . '/upgrade/classes/ToolsInstall.php';
        }
    }
    if (class_exists('ToolsInstall', false)) {
        $result = ToolsInstall::simpleXMLToArray($result);
        switch ($return_type) {
            case 'json':
                header('Content-Type: application/json');
                if (function_exists('json_encode')) {
                    $result = json_encode($result);
                } else {
                    include_once INSTALL_PATH . '/../tools/json/json.php';
                    $pearJson = new Services_JSON();
                    $result = $pearJson->encode($result);
                }
                echo $result;
                break;
            case 'eval':
                return $result;
            case 'include':
 public function _modelDo($method)
 {
     @set_time_limit(0);
     @ini_set('max_execution_time', '0');
     // setting the memory limit to 128M only if current is lower
     $memory_limit = ini_get('memory_limit');
     if (substr($memory_limit, -1) != 'G' and (substr($memory_limit, -1) == 'M' and substr($memory_limit, 0, -1) < 128 or is_numeric($memory_limit) and intval($memory_limit) < 131072)) {
         @ini_set('memory_limit', '128M');
     }
     require_once $this->prodRootDir . '/config/autoload.php';
     /* Redefine REQUEST_URI if empty (on some webservers...) */
     if (!isset($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] == '') {
         $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
     }
     if ($tmp = strpos($_SERVER['REQUEST_URI'], '?')) {
         $_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 0, $tmp);
     }
     $_SERVER['REQUEST_URI'] = str_replace('//', '/', $_SERVER['REQUEST_URI']);
     define('INSTALL_VERSION', $this->currentParams['install_version']);
     define('INSTALL_PATH', realpath($this->latestRootDir . DIRECTORY_SEPARATOR . 'install'));
     define('PS_INSTALLATION_IN_PROGRESS', true);
     require_once INSTALL_PATH . '/classes/ToolsInstall.php';
     define('SETTINGS_FILE', $this->prodRootDir . '/config/settings.inc.php');
     define('DEFINES_FILE', $this->prodRootDir . '/config/defines.inc.php');
     define('INSTALLER__PS_BASE_URI', substr($_SERVER['REQUEST_URI'], 0, -1 * (strlen($_SERVER['REQUEST_URI']) - strrpos($_SERVER['REQUEST_URI'], '/')) - strlen(substr(dirname($_SERVER['REQUEST_URI']), strrpos(dirname($_SERVER['REQUEST_URI']), '/') + 1))));
     define('INSTALLER__PS_BASE_URI_ABSOLUTE', 'http://' . ToolsInstall::getHttpHost(false, true) . INSTALLER__PS_BASE_URI);
     // XML Header
     header('Content-Type: text/xml');
     // Switching method
     if (in_array($method, array('doUpgrade', 'createDB', 'checkShopInfos'))) {
         global $logger;
         $logger = new FileLogger();
         $logger->setFilename($this->prodRootDir . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR . @date('Ymd') . '_installation.log');
     }
     switch ($method) {
         case 'checkConfig':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'checkConfig.php';
             die;
             break;
         case 'checkDB':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'checkDB.php';
             break;
         case 'createDB':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'createDB.php';
             break;
         case 'checkMail':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'checkMail.php';
             break;
         case 'checkShopInfos':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'checkShopInfos.php';
             break;
         case 'doUpgrade':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'doUpgrade.php';
             break;
         case 'getVersionFromDb':
             require_once INSTALL_PATH . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'getVersionFromDb.php';
             break;
     }
 }
Exemple #11
0
}
//delete settings file if it exist
if (file_exists(SETTINGS_FILE)) {
    if (!unlink(SETTINGS_FILE)) {
        die('<action result="fail" error="17" />' . "\n");
    }
}
include INSTALL_PATH . '/classes/AddConfToFile.php';
//check db access
include_once INSTALL_PATH . '/classes/ToolsInstall.php';
$resultDB = ToolsInstall::checkDB($_GET['server'], $_GET['login'], $_GET['password'], $_GET['name'], true, $_GET['engine']);
if ($resultDB !== true) {
    die("<action result='fail' error='" . $resultDB . "'/>\n");
}
// Check POST data...
$data_check = array(!isset($_GET['tablePrefix']) or !ToolsInstall::isMailName($_GET['tablePrefix']) or !preg_match('/^[a-z0-9_]*$/i', $_GET['tablePrefix']));
foreach ($data_check as $data) {
    if ($data) {
        die('<action result="fail" error="8"/>' . "\n");
    }
}
// Writing data in settings file
$oldLevel = error_reporting(E_ALL);
$_BASE_URI_ = str_replace(' ', '%20', INSTALLER_BASE_URI);
$datas = array(array('_DB_SERVER_', trim($_GET['server'])), array('_DB_TYPE_', trim($_GET['type'])), array('_DB_NAME_', trim($_GET['name'])), array('_DB_USER_', trim($_GET['login'])), array('_DB_PASSWD_', trim($_GET['password'])), array('_DB_PREFIX_', trim($_GET['tablePrefix'])), array('_MYSQL_ENGINE_', $_GET['engine']), array('_BASE_URI_', $_BASE_URI_), array('_CREATION_DATE_', date('Y-m-d')), array('_VERSION_', INSTALL_VERSION), array('_SALT_', 'm4d3!N|2U$$!4bYg!o7$4|2'));
error_reporting($oldLevel);
$confFile = new AddConfToFile(SETTINGS_FILE, 'w');
if ($confFile->error) {
    die('<action result="fail" error="' . $confFile->error . '" />' . "\n");
}
foreach ($datas as $data) {