public static function execute() { $db = array('DB_SERVER' => trim(urldecode($_POST['server'])), 'DB_SERVER_USERNAME' => trim(urldecode($_POST['username'])), 'DB_SERVER_PASSWORD' => trim(urldecode($_POST['password'])), 'DB_DATABASE' => trim(urldecode($_POST['name'])), 'DB_SERVER_PORT' => trim(urldecode($_POST['port'])), 'DB_DATABASE_CLASS' => trim(urldecode(str_replace('_', '\\', $_POST['class'])))); Registry::set('Database', Database::initialize($db['DB_SERVER'], $db['DB_SERVER_USERNAME'], $db['DB_SERVER_PASSWORD'], $db['DB_DATABASE'], $db['DB_SERVER_PORT'], $db['DB_DATABASE_CLASS'])); $OSCOM_Database = Registry::get('Database'); if (!$OSCOM_Database->isError()) { $OSCOM_Database->selectDatabase($db['DB_DATABASE']); } if (!$OSCOM_Database->isError()) { echo '[[1]]'; } else { echo '[[0|' . $OSCOM_Database->getError() . ']]'; } }
public static function execute() { $db = array('DB_SERVER' => trim(urldecode($_POST['server'])), 'DB_SERVER_USERNAME' => trim(urldecode($_POST['username'])), 'DB_SERVER_PASSWORD' => trim(urldecode($_POST['password'])), 'DB_DATABASE' => trim(urldecode($_POST['name'])), 'DB_SERVER_PORT' => trim(urldecode($_POST['port'])), 'DB_DATABASE_CLASS' => trim(urldecode(str_replace('_', '\\', $_POST['class'])))); Registry::set('Database', Database::initialize($db['DB_SERVER'], $db['DB_SERVER_USERNAME'], $db['DB_SERVER_PASSWORD'], $db['DB_DATABASE'], $db['DB_SERVER_PORT'], $db['DB_DATABASE_CLASS'])); $OSCOM_Database = Registry::get('Database'); if (!$OSCOM_Database->isError()) { $OSCOM_Database->selectDatabase($db['DB_DATABASE']); } if (!$OSCOM_Database->isError()) { $result = array('result' => true); } else { $result = array('result' => false, 'error_message' => $OSCOM_Database->getError()); } echo json_encode($result); }
public static function execute() { $db = array('DB_SERVER' => trim(urldecode($_POST['server'])), 'DB_SERVER_USERNAME' => trim(urldecode($_POST['username'])), 'DB_SERVER_PASSWORD' => trim(urldecode($_POST['password'])), 'DB_DATABASE' => trim(urldecode($_POST['name'])), 'DB_SERVER_PORT' => trim(urldecode($_POST['port'])), 'DB_DATABASE_CLASS' => trim(urldecode(str_replace('_', '\\', $_POST['class']))), 'DB_TABLE_PREFIX' => trim(urldecode($_POST['prefix']))); Registry::set('Database', Database::initialize($db['DB_SERVER'], $db['DB_SERVER_USERNAME'], $db['DB_SERVER_PASSWORD'], $db['DB_DATABASE'], $db['DB_SERVER_PORT'], $db['DB_DATABASE_CLASS'])); $OSCOM_Database = Registry::get('Database'); if (!$OSCOM_Database->isError()) { $sql_file = OSCOM::BASE_DIRECTORY . 'Core/Site/Setup/sql/oscommerce_sample_data.sql'; $OSCOM_Database->importSQL($sql_file, $db['DB_DATABASE'], $db['DB_TABLE_PREFIX']); } if (!$OSCOM_Database->isError()) { echo '[[1]]'; } else { echo '[[0|' . $OSCOM_Database->getError() . ']]'; } }
public static function initialize() { OSCOM::loadConfig(); if (strlen(DB_SERVER) < 1) { osc_redirect(OSCOM::getLink('Setup')); } Registry::set('MessageStack', new MessageStack()); Registry::set('Cache', new Cache()); Registry::set('Database', Database::initialize()); $Qcfg = Registry::get('Database')->query('select configuration_key as cfgKey, configuration_value as cfgValue from :table_configuration'); $Qcfg->setCache('configuration'); $Qcfg->execute(); while ($Qcfg->next()) { define($Qcfg->value('cfgKey'), $Qcfg->value('cfgValue')); } $Qcfg->freeResult(); Registry::set('Session', Session::load('adminSid')); Registry::get('Session')->start(); Registry::get('MessageStack')->loadFromSession(); Registry::set('Language', new Language()); if (!self::hasAccess(OSCOM::getSiteApplication())) { Registry::get('MessageStack')->add('header', 'No access.', 'error'); osc_redirect_admin(OSCOM::getLink(null, 'Index')); } $application = 'osCommerce\\OM\\Core\\Site\\Admin\\Application\\' . OSCOM::getSiteApplication() . '\\Controller'; Registry::set('Application', new $application()); Registry::set('Template', new Template()); Registry::get('Template')->setApplication(Registry::get('Application')); // HPDL move following checks elsewhere // check if a default currency is set if (!defined('DEFAULT_CURRENCY')) { Registry::get('MessageStack')->add('header', OSCOM::getDef('ms_error_no_default_currency'), 'error'); } // check if a default language is set if (!defined('DEFAULT_LANGUAGE')) { Registry::get('MessageStack')->add('header', ERROR_NO_DEFAULT_LANGUAGE_DEFINED, 'error'); } if (function_exists('ini_get') && (bool) ini_get('file_uploads') == false) { Registry::get('MessageStack')->add('header', OSCOM::getDef('ms_warning_uploads_disabled'), 'warning'); } }
public static function initialize() { if (strlen(DB_SERVER) < 1) { osc_redirect(OSCOM::getLink('Setup')); } Registry::set('MessageStack', new MessageStack()); Registry::set('Cache', new Cache()); Registry::set('Database', Database::initialize()); Registry::set('PDO', DatabasePDO::initialize()); $Qcfg = Registry::get('Database')->query('select configuration_key as cfgKey, configuration_value as cfgValue from :table_configuration'); $Qcfg->setCache('configuration'); $Qcfg->execute(); while ($Qcfg->next()) { define($Qcfg->value('cfgKey'), $Qcfg->value('cfgValue')); } $Qcfg->freeResult(); Registry::set('Service', new Service()); Registry::get('Service')->start(); Registry::set('Template', new Template()); $application = 'osCommerce\\OM\\Core\\Site\\Shop\\Application\\' . OSCOM::getSiteApplication() . '\\Controller'; Registry::set('Application', new $application()); Registry::get('Template')->setApplication(Registry::get('Application')); }
public static function initialize() { if (strlen(DB_SERVER) < 1) { osc_redirect(OSCOM::getLink('Setup')); } Registry::set('MessageStack', new MessageStack()); Registry::set('Cache', new Cache()); Registry::set('Database', Database::initialize()); Registry::set('PDO', DatabasePDO::initialize()); foreach (OSCOM::callDB('Admin\\GetConfiguration', null, 'Site') as $param) { define($param['cfgKey'], $param['cfgValue']); } Registry::set('Session', Session::load('adminSid')); Registry::get('Session')->start(); Registry::get('MessageStack')->loadFromSession(); Registry::set('Language', new Language()); if (!self::hasAccess(OSCOM::getSiteApplication())) { Registry::get('MessageStack')->add('header', 'No access.', 'error'); osc_redirect_admin(OSCOM::getLink(null, OSCOM::getDefaultSiteApplication())); } $application = 'osCommerce\\OM\\Core\\Site\\Admin\\Application\\' . OSCOM::getSiteApplication() . '\\Controller'; Registry::set('Application', new $application()); Registry::set('Template', new Template()); Registry::get('Template')->setApplication(Registry::get('Application')); // HPDL move following checks elsewhere // check if a default currency is set if (!defined('DEFAULT_CURRENCY')) { Registry::get('MessageStack')->add('header', OSCOM::getDef('ms_error_no_default_currency'), 'error'); } // check if a default language is set if (!defined('DEFAULT_LANGUAGE')) { Registry::get('MessageStack')->add('header', ERROR_NO_DEFAULT_LANGUAGE_DEFINED, 'error'); } if (function_exists('ini_get') && (bool) ini_get('file_uploads') == false) { Registry::get('MessageStack')->add('header', OSCOM::getDef('ms_warning_uploads_disabled'), 'warning'); } }
<?php /* osCommerce Online Merchant $osCommerce-SIG$ Copyright (c) 2010 osCommerce (http://www.oscommerce.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 (1991) as published by the Free Software Foundation. */ use osCommerce\OM\Core\Registry; use osCommerce\OM\Core\Database; use osCommerce\OM\Core\OSCOM; use osCommerce\OM\Core\DirectoryListing; define('DB_TABLE_PREFIX', $_POST['DB_TABLE_PREFIX']); Registry::set('Database', Database::initialize($_POST['DB_SERVER'], $_POST['DB_SERVER_USERNAME'], $_POST['DB_SERVER_PASSWORD'], $_POST['DB_DATABASE'], $_POST['DB_SERVER_PORT'], str_replace('_', '\\', $_POST['DB_DATABASE_CLASS']))); // Registry::set('osC_Database', Registry::get('Database')); // HPDL to delete $OSCOM_Database = Registry::get('Database'); $Qupdate = $OSCOM_Database->query('update :table_configuration set configuration_value = :configuration_value where configuration_key = :configuration_key'); $Qupdate->bindValue(':configuration_value', $_POST['CFG_STORE_NAME']); $Qupdate->bindValue(':configuration_key', 'STORE_NAME'); $Qupdate->execute(); $Qupdate = $OSCOM_Database->query('update :table_configuration set configuration_value = :configuration_value where configuration_key = :configuration_key'); $Qupdate->bindValue(':configuration_value', $_POST['CFG_STORE_OWNER_NAME']); $Qupdate->bindValue(':configuration_key', 'STORE_OWNER'); $Qupdate->execute(); $Qupdate = $OSCOM_Database->query('update :table_configuration set configuration_value = :configuration_value where configuration_key = :configuration_key'); $Qupdate->bindValue(':configuration_value', $_POST['CFG_STORE_OWNER_EMAIL_ADDRESS']); $Qupdate->bindValue(':configuration_key', 'STORE_OWNER_EMAIL_ADDRESS'); $Qupdate->execute(); if (!empty($_POST['CFG_STORE_OWNER_NAME']) && !empty($_POST['CFG_STORE_OWNER_EMAIL_ADDRESS'])) {
public static function execute() { $db = array('DB_SERVER' => trim(urldecode($_POST['server'])), 'DB_SERVER_USERNAME' => trim(urldecode($_POST['username'])), 'DB_SERVER_PASSWORD' => trim(urldecode($_POST['password'])), 'DB_DATABASE' => trim(urldecode($_POST['name'])), 'DB_SERVER_PORT' => trim(urldecode($_POST['port'])), 'DB_DATABASE_CLASS' => trim(urldecode(str_replace('_', '\\', $_POST['class']))), 'DB_INSERT_SAMPLE_DATA' => trim(urldecode($_POST['import'])) == '1' ? 'true' : 'false', 'DB_TABLE_PREFIX' => trim(urldecode($_POST['prefix']))); Registry::set('Database', Database::initialize($db['DB_SERVER'], $db['DB_SERVER_USERNAME'], $db['DB_SERVER_PASSWORD'], $db['DB_DATABASE'], $db['DB_SERVER_PORT'], $db['DB_DATABASE_CLASS'])); $OSCOM_Database = Registry::get('Database'); if (!$OSCOM_Database->isError()) { $sql_file = OSCOM::BASE_DIRECTORY . 'Core/Site/Setup/sql/oscommerce.sql'; $OSCOM_Database->importSQL($sql_file, $db['DB_DATABASE'], $db['DB_TABLE_PREFIX']); } if (!$OSCOM_Database->isError()) { define('DB_TABLE_PREFIX', $db['DB_TABLE_PREFIX']); // HPDL to remove foreach (Registry::get('Language')->extractDefinitions('en_US.xml') as $def) { $Qdef = $OSCOM_Database->query('insert into :table_languages_definitions (languages_id, content_group, definition_key, definition_value) values (:languages_id, :content_group, :definition_key, :definition_value)'); $Qdef->bindInt(':languages_id', 1); $Qdef->bindValue(':content_group', $def['group']); $Qdef->bindValue(':definition_key', $def['key']); $Qdef->bindValue(':definition_value', $def['value']); $Qdef->execute(); } $OSCOM_DirectoryListing = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/Shop/Languages/en_US'); $OSCOM_DirectoryListing->setRecursive(true); $OSCOM_DirectoryListing->setIncludeDirectories(false); $OSCOM_DirectoryListing->setAddDirectoryToFilename(true); $OSCOM_DirectoryListing->setCheckExtension('xml'); foreach ($OSCOM_DirectoryListing->getFiles() as $files) { foreach (Registry::get('Language')->extractDefinitions('en_US/' . $files['name']) as $def) { $Qdef = $OSCOM_Database->query('insert into :table_languages_definitions (languages_id, content_group, definition_key, definition_value) values (:languages_id, :content_group, :definition_key, :definition_value)'); $Qdef->bindInt(':languages_id', 1); $Qdef->bindValue(':content_group', $def['group']); $Qdef->bindValue(':definition_key', $def['key']); $Qdef->bindValue(':definition_value', $def['value']); $Qdef->execute(); } } } if (!$OSCOM_Database->isError()) { $services = array('OutputCompression', 'Session', 'Language', 'Debug', 'Currencies', 'Core', 'SimpleCounter', 'CategoryPath', 'Breadcrumb', 'WhosOnline', 'Specials', 'Reviews', 'RecentlyVisited'); $installed = array(); foreach ($services as $service) { $class = 'osCommerce\\OM\\Core\\Site\\Admin\\Module\\Service\\' . $service; $module = new $class(); $module->install(); if (isset($module->depends)) { if (is_string($module->depends) && ($key = array_search($module->depends, $installed)) !== false) { if (isset($installed[$key + 1])) { array_splice($installed, $key + 1, 0, $service); } else { $installed[] = $service; } } elseif (is_array($module->depends)) { foreach ($module->depends as $depends_module) { if (($key = array_search($depends_module, $installed)) !== false) { if (!isset($array_position) || $key > $array_position) { $array_position = $key; } } } if (isset($array_position)) { array_splice($installed, $array_position + 1, 0, $service); } else { $installed[] = $service; } } } elseif (isset($module->precedes)) { if (is_string($module->precedes)) { if (($key = array_search($module->precedes, $installed)) !== false) { array_splice($installed, $key, 0, $service); } else { $installed[] = $service; } } elseif (is_array($module->precedes)) { foreach ($module->precedes as $precedes_module) { if (($key = array_search($precedes_module, $installed)) !== false) { if (!isset($array_position) || $key < $array_position) { $array_position = $key; } } } if (isset($array_position)) { array_splice($installed, $array_position, 0, $service); } else { $installed[] = $service; } } } else { $installed[] = $service; } unset($array_position); } $Qs = $OSCOM_Database->query('insert into :table_configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ("Service Modules", "MODULE_SERVICES_INSTALLED", :configuration_value, "Installed services modules", "6", "0", now())'); $Qs->bindValue(':configuration_value', implode(';', $installed)); $Qs->execute(); define('DEFAULT_ORDERS_STATUS_ID', 1); // HPDL to remove $module = new \osCommerce\OM\Core\Site\Admin\Module\Payment\COD(); $module->install(); $Qupdate = $OSCOM_Database->query('update :table_configuration set configuration_value = 1 where configuration_key = :configuration_key'); $Qupdate->bindValue(':configuration_key', 'MODULE_PAYMENT_COD_STATUS'); $Qupdate->execute(); $module = new \osCommerce\OM\Core\Site\Admin\Module\Shipping\Flat(); $module->install(); $module = new \osCommerce\OM\Core\Site\Admin\Module\OrderTotal\SubTotal(); $module->install(); $module = new \osCommerce\OM\Core\Site\Admin\Module\OrderTotal\Shipping(); $module->install(); $module = new \osCommerce\OM\Core\Site\Admin\Module\OrderTotal\Tax(); $module->install(); $module = new \osCommerce\OM\Core\Site\Admin\Module\OrderTotal\Total(); $module->install(); } if (!$OSCOM_Database->isError() && $db['DB_DATABASE_CLASS'] == 'mysql_innodb') { $Qinno = $OSCOM_Database->query('show variables like "have_innodb"'); if ($Qinno->numberOfRows() === 1 && strtolower($Qinno->value('Value')) == 'yes') { $innodb_sql_file = OSCOM::BASE_DIRECTORY . 'Core/Site/Setup/sql/oscommerce_innodb.sql'; $OSCOM_Database->importSQL($innodb_sql_file, $db['DB_DATABASE'], $db['DB_TABLE_PREFIX']); } } if (!$OSCOM_Database->isError()) { echo '[[1]]'; } else { echo '[[0|' . $OSCOM_Database->getError() . ']]'; } }