public static function execute() { $installed_modules = ProductAttributes::getInstalled(); $installed = array(); foreach ( $installed_modules['entries'] as $module ) { $installed[] = $module['code']; } $result = array('entries' => array()); $DLpa = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/Admin/Module/ProductAttribute'); $DLpa->setIncludeDirectories(false); foreach ( $DLpa->getFiles() as $file ) { $module = substr($file['name'], 0, strrpos($file['name'], '.')); if ( !in_array($module, $installed) ) { $class = 'osCommerce\\OM\\Core\\Site\\Admin\\Module\\ProductAttribute\\' . $module; $OSCOM_PA = new $class(); $result['entries'][] = array('code' => $OSCOM_PA->getCode(), 'title' => $OSCOM_PA->getTitle()); } } $result['total'] = count($result['entries']); return $result; }
public static function getUninstalled() { $OSCOM_Database = Registry::get('Database'); $OSCOM_Language = Registry::get('Language'); $installed = array(); $Qpm = $OSCOM_Database->query('select code from :table_templates_boxes where modules_group = :modules_group'); $Qpm->bindValue(':modules_group', 'Payment'); $Qpm->execute(); while ($Qpm->next()) { $installed[] = $Qpm->value('code'); } $result = array('entries' => array()); $DLpm = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/Admin/Module/Payment'); $DLpm->setIncludeDirectories(false); foreach ($DLpm->getFiles() as $file) { $module = substr($file['name'], 0, strrpos($file['name'], '.')); if (!in_array($module, $installed)) { $class = 'osCommerce\\OM\\Core\\Site\\Admin\\Module\\Payment\\' . $module; if (class_exists($class)) { $OSCOM_Language->injectDefinitions('modules/payment/' . $module . '.xml'); $OSCOM_PM = new $class(); $result['entries'][] = array('code' => $OSCOM_PM->getCode(), 'title' => $OSCOM_PM->getTitle(), 'sort_order' => $OSCOM_PM->getSortOrder(), 'status' => $OSCOM_PM->isEnabled()); } } } $result['total'] = count($result['entries']); return $result; }
public static function execute() { $result = array(); $OSCOM_DirectoryListing = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/Shop/Languages'); $OSCOM_DirectoryListing->setIncludeDirectories(false); $OSCOM_DirectoryListing->setCheckExtension('xml'); foreach ($OSCOM_DirectoryListing->getFiles() as $file) { $result[] = substr($file['name'], 0, strrpos($file['name'], '.')); } return $result; }
public static function execute() { $result = array('images' => array()); $OSCOM_DL = new DirectoryListing(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'upload'); $OSCOM_DL->setIncludeDirectories(false); $OSCOM_DL->setCheckExtension('gif'); $OSCOM_DL->setCheckExtension('jpg'); $OSCOM_DL->setCheckExtension('png'); foreach ($OSCOM_DL->getFiles() as $f) { $result['images'][] = $f['name']; } $result['rpcStatus'] = RPC::STATUS_SUCCESS; echo json_encode($result); }
public static function execute() { $OSCOM_DirectoryListing = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/Admin/Module/Dashboard'); $OSCOM_DirectoryListing->setIncludeDirectories(false); $result = array(); foreach ($OSCOM_DirectoryListing->getFiles() as $file) { $module = substr($file['name'], 0, strrpos($file['name'], '.')); $module_class = 'osCommerce\\OM\\Core\\Site\\Admin\\Module\\Dashboard\\' . $module; $OSCOM_Admin_DB_Module = new $module_class(); if ($OSCOM_Admin_DB_Module->hasData()) { $result[] = array('module' => $module, 'title' => $OSCOM_Admin_DB_Module->getTitle(), 'link' => $OSCOM_Admin_DB_Module->hasTitleLink() ? $OSCOM_Admin_DB_Module->getTitleLink() : null, 'data' => $OSCOM_Admin_DB_Module->getData()); } } return $result; }
public function __construct() { $DLlang = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/Shop/Languages'); $DLlang->setIncludeDirectories(false); $DLlang->setCheckExtension('xml'); foreach ($DLlang->getFiles() as $file) { $lang = XML::toArray(simplexml_load_file(OSCOM::BASE_DIRECTORY . 'Core/Site/Shop/Languages/' . $file['name'])); if (!isset($lang['language'])) { // create root element (simpleXML does not use root element) $lang = array('language' => $lang); } $this->_languages[$lang['language']['data']['code']] = array('id' => 1, 'code' => $lang['language']['data']['code'], 'name' => $lang['language']['data']['title'], 'locale' => $lang['language']['data']['locale'], 'charset' => $lang['language']['data']['character_set'], 'date_format_short' => $lang['language']['data']['date_format_short'], 'date_format_long' => $lang['language']['data']['date_format_long'], 'time_format' => $lang['language']['data']['time_format'], 'text_direction' => $lang['language']['data']['text_direction'], 'parent_id' => 0); } unset($lang); $language = isset($_GET['language']) && !empty($_GET['language']) ? $_GET['language'] : ''; $this->set($language); header('Content-Type: text/html; charset=' . $this->getCharacterSet()); setlocale(LC_TIME, explode(',', $this->getLocale())); $this->loadIniFile(); $this->loadIniFile(OSCOM::getSiteApplication() . '.php'); }
public static function execute() { $OSCOM_Language = Registry::get('Language'); $installed_modules = PaymentModules::getInstalled(); $installed = array(); foreach ($installed_modules['entries'] as $module) { $installed[] = $module['code']; } $result = array('entries' => array()); $DLpm = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/Admin/Module/Payment'); $DLpm->setIncludeDirectories(false); foreach ($DLpm->getFiles() as $file) { $module = substr($file['name'], 0, strrpos($file['name'], '.')); if (!in_array($module, $installed)) { $class = 'osCommerce\\OM\\Core\\Site\\Admin\\Module\\Payment\\' . $module; $OSCOM_Language->injectDefinitions('modules/payment/' . $module . '.xml'); $OSCOM_PM = new $class(); $result['entries'][] = array('code' => $OSCOM_PM->getCode(), 'title' => $OSCOM_PM->getTitle(), 'sort_order' => $OSCOM_PM->getSortOrder(), 'status' => $OSCOM_PM->isEnabled()); } } $result['total'] = count($result['entries']); return $result; }
public static function execute($data) { $source = array('language' => XML::toArray(simplexml_load_file(OSCOM::BASE_DIRECTORY . 'Core/Site/Shop/Languages/' . $data['code'] . '.xml'))); $language = array('name' => $source['language']['data']['title'], 'code' => $source['language']['data']['code'], 'locale' => $source['language']['data']['locale'], 'charset' => $source['language']['data']['character_set'], 'date_format_short' => $source['language']['data']['date_format_short'], 'date_format_long' => $source['language']['data']['date_format_long'], 'time_format' => $source['language']['data']['time_format'], 'text_direction' => $source['language']['data']['text_direction'], 'currency' => $source['language']['data']['default_currency'], 'numeric_separator_decimal' => $source['language']['data']['numerical_decimal_separator'], 'numeric_separator_thousands' => $source['language']['data']['numerical_thousands_separator'], 'parent_language_code' => isset($source['language']['data']['parent_language_code']) ? $source['language']['data']['parent_language_code'] : '', 'parent_id' => 0); if (!Currencies::exists($language['currency'])) { $language['currency'] = DEFAULT_CURRENCY; } $language['currencies_id'] = Currencies::get($language['currency'], 'currencies_id'); if (!empty($language['parent_language_code']) && Languages::exists($language['parent_language_code'])) { $language['parent_id'] = Languages::get($language['parent_language_code'], 'languages_id'); } $language['id'] = Languages::get($language['code'], 'languages_id'); $language['default_language_id'] = Languages::get(DEFAULT_LANGUAGE, 'languages_id'); $language['import_type'] = $data['type']; $definitions = array(); if (isset($source['language']['definitions']['definition'])) { $definitions = $source['language']['definitions']['definition']; if (isset($definitions['key']) && isset($definitions['value']) && isset($definitions['group'])) { $definitions = array(array('key' => $definitions['key'], 'value' => $definitions['value'], 'group' => $definitions['group'])); } } unset($source); $OSCOM_DirectoryListing = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/Shop/Languages/' . $data['code']); $OSCOM_DirectoryListing->setRecursive(true); $OSCOM_DirectoryListing->setIncludeDirectories(false); $OSCOM_DirectoryListing->setAddDirectoryToFilename(true); $OSCOM_DirectoryListing->setCheckExtension('xml'); foreach ($OSCOM_DirectoryListing->getFiles() as $files) { $definitions = array_merge($definitions, Language::extractDefinitions($data['code'] . '/' . $files['name'])); } $language['definitions'] = $definitions; if (OSCOM::callDB('Admin\\Languages\\Import', $language)) { Cache::clear('languages'); return true; } return false; }
public static function import($file, $type) { $OSCOM_Database = Registry::get('Database'); if (file_exists(OSCOM::BASE_DIRECTORY . 'Core/Site/Shop/Languages/' . $file . '.xml')) { $source = array('language' => XML::toArray(simplexml_load_file(OSCOM::BASE_DIRECTORY . 'Core/Site/Shop/Languages/' . $file . '.xml'))); $language = array('name' => $source['language']['data']['title'], 'code' => $source['language']['data']['code'], 'locale' => $source['language']['data']['locale'], 'charset' => $source['language']['data']['character_set'], 'date_format_short' => $source['language']['data']['date_format_short'], 'date_format_long' => $source['language']['data']['date_format_long'], 'time_format' => $source['language']['data']['time_format'], 'text_direction' => $source['language']['data']['text_direction'], 'currency' => $source['language']['data']['default_currency'], 'numeric_separator_decimal' => $source['language']['data']['numerical_decimal_separator'], 'numeric_separator_thousands' => $source['language']['data']['numerical_thousands_separator'], 'parent_language_code' => isset($source['language']['data']['parent_language_code']) ? $source['language']['data']['parent_language_code'] : '', 'parent_id' => 0); if (!Currencies::exists($language['currency'])) { $language['currency'] = DEFAULT_CURRENCY; } if (!empty($language['parent_language_code']) && self::exists($language['parent_language_code'])) { $language['parent_id'] = self::get($language['parent_language_code'], 'languages_id'); } $definitions = array(); if (isset($source['language']['definitions']['definition'])) { $definitions = $source['language']['definitions']['definition']; if (isset($definitions['key']) && isset($definitions['value']) && isset($definitions['group'])) { $definitions = array(array('key' => $definitions['key'], 'value' => $definitions['value'], 'group' => $definitions['group'])); } } unset($source); $error = false; $add_category_and_product_placeholders = true; $OSCOM_Database->startTransaction(); $language_id = self::get($language['code'], 'languages_id'); if ($language_id !== false) { $add_category_and_product_placeholders = false; $Qlanguage = $OSCOM_Database->query('update :table_languages set name = :name, code = :code, locale = :locale, charset = :charset, date_format_short = :date_format_short, date_format_long = :date_format_long, time_format = :time_format, text_direction = :text_direction, currencies_id = :currencies_id, numeric_separator_decimal = :numeric_separator_decimal, numeric_separator_thousands = :numeric_separator_thousands, parent_id = :parent_id where languages_id = :languages_id'); $Qlanguage->bindInt(':languages_id', $language_id); } else { $Qlanguage = $OSCOM_Database->query('insert into :table_languages (name, code, locale, charset, date_format_short, date_format_long, time_format, text_direction, currencies_id, numeric_separator_decimal, numeric_separator_thousands, parent_id) values (:name, :code, :locale, :charset, :date_format_short, :date_format_long, :time_format, :text_direction, :currencies_id, :numeric_separator_decimal, :numeric_separator_thousands, :parent_id)'); } $Qlanguage->bindValue(':name', $language['name']); $Qlanguage->bindValue(':code', $language['code']); $Qlanguage->bindValue(':locale', $language['locale']); $Qlanguage->bindValue(':charset', $language['charset']); $Qlanguage->bindValue(':date_format_short', $language['date_format_short']); $Qlanguage->bindValue(':date_format_long', $language['date_format_long']); $Qlanguage->bindValue(':time_format', $language['time_format']); $Qlanguage->bindValue(':text_direction', $language['text_direction']); $Qlanguage->bindInt(':currencies_id', Currencies::get($language['currency'], 'currencies_id')); $Qlanguage->bindValue(':numeric_separator_decimal', $language['numeric_separator_decimal']); $Qlanguage->bindValue(':numeric_separator_thousands', $language['numeric_separator_thousands']); $Qlanguage->bindInt(':parent_id', $language['parent_id']); $Qlanguage->setLogging(null, $language_id !== false ? $language_id : null); $Qlanguage->execute(); if ($OSCOM_Database->isError()) { $error = true; } else { if ($language_id === false) { $language_id = $OSCOM_Database->nextID(); } $default_language_id = self::get(DEFAULT_LANGUAGE, 'languages_id'); if ($type == 'replace') { $Qdel = $OSCOM_Database->query('delete from :table_languages_definitions where languages_id = :languages_id'); $Qdel->bindInt(':languages_id', $language_id); $Qdel->execute(); if ($OSCOM_Database->isError()) { $error = true; } } } if ($error === false) { $OSCOM_DirectoryListing = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/Shop/Languages/' . $file); $OSCOM_DirectoryListing->setRecursive(true); $OSCOM_DirectoryListing->setIncludeDirectories(false); $OSCOM_DirectoryListing->setAddDirectoryToFilename(true); $OSCOM_DirectoryListing->setCheckExtension('xml'); foreach ($OSCOM_DirectoryListing->getFiles() as $files) { $definitions = array_merge($definitions, Language::extractDefinitions($file . '/' . $files['name'])); } foreach ($definitions as $def) { $insert = false; $update = false; if ($type == 'replace') { $insert = true; } else { $Qcheck = $OSCOM_Database->query('select definition_key, content_group from :table_languages_definitions where definition_key = :definition_key and languages_id = :languages_id and content_group = :content_group'); $Qcheck->bindValue(':definition_key', $def['key']); $Qcheck->bindInt(':languages_id', $language_id); $Qcheck->bindValue(':content_group', $def['group']); $Qcheck->execute(); if ($Qcheck->numberOfRows() > 0) { if ($type == 'update') { $update = true; } } elseif ($type == 'add') { $insert = true; } } if ($insert === true || $update === true) { if ($insert === true) { $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)'); } else { $Qdef = $OSCOM_Database->query('update :table_languages_definitions set content_group = :content_group, definition_key = :definition_key, definition_value = :definition_value where definition_key = :definition_key and languages_id = :languages_id and content_group = :content_group'); $Qdef->bindValue(':definition_key', $def['key']); $Qdef->bindValue(':content_group', $def['group']); } $Qdef->bindInt(':languages_id', $language_id); $Qdef->bindValue(':content_group', $def['group']); $Qdef->bindValue(':definition_key', $def['key']); $Qdef->bindValue(':definition_value', $def['value']); $Qdef->execute(); if ($OSCOM_Database->isError()) { $error = true; break; } } } } if ($add_category_and_product_placeholders === true) { if ($error === false) { $Qcategories = $OSCOM_Database->query('select categories_id, categories_name from :table_categories_description where language_id = :language_id'); $Qcategories->bindInt(':language_id', $default_language_id); $Qcategories->execute(); while ($Qcategories->next()) { $Qinsert = $OSCOM_Database->query('insert into :table_categories_description (categories_id, language_id, categories_name) values (:categories_id, :language_id, :categories_name)'); $Qinsert->bindInt(':categories_id', $Qcategories->valueInt('categories_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':categories_name', $Qcategories->value('categories_name')); $Qinsert->execute(); if ($OSCOM_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qproducts = $OSCOM_Database->query('select products_id, products_name, products_description, products_keyword, products_tags, products_url from :table_products_description where language_id = :language_id'); $Qproducts->bindInt(':language_id', $default_language_id); $Qproducts->execute(); while ($Qproducts->next()) { $Qinsert = $OSCOM_Database->query('insert into :table_products_description (products_id, language_id, products_name, products_description, products_keyword, products_tags, products_url) values (:products_id, :language_id, :products_name, :products_description, :products_keyword, :products_tags, :products_url)'); $Qinsert->bindInt(':products_id', $Qproducts->valueInt('products_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':products_name', $Qproducts->value('products_name')); $Qinsert->bindValue(':products_description', $Qproducts->value('products_description')); $Qinsert->bindValue(':products_keyword', $Qproducts->value('products_keyword')); $Qinsert->bindValue(':products_tags', $Qproducts->value('products_tags')); $Qinsert->bindValue(':products_url', $Qproducts->value('products_url')); $Qinsert->execute(); if ($OSCOM_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qattributes = $OSCOM_Database->query('select products_id, value from :table_product_attributes where languages_id = :languages_id'); $Qattributes->bindInt(':languages_id', $default_language_id); $Qattributes->execute(); while ($Qattributes->next()) { $Qinsert = $OSCOM_Database->query('insert into :table_product_attributes (products_id, languages_id, value) values (:products_id, :languages_id, :value)'); $Qinsert->bindInt(':products_id', $Qattributes->valueInt('products_id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindValue(':value', $Qattributes->value('value')); $Qinsert->execute(); if ($OSCOM_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qgroups = $OSCOM_Database->query('select id, title, sort_order, module from :table_products_variants_groups where languages_id = :languages_id'); $Qgroups->bindInt(':languages_id', $default_language_id); $Qgroups->execute(); while ($Qgroups->next()) { $Qinsert = $OSCOM_Database->query('insert into :table_products_variants_groups (id, languages_id, title, sort_order, module) values (:id, :languages_id, :title, :sort_order, :module)'); $Qinsert->bindInt(':id', $Qgroups->valueInt('id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindValue(':title', $Qgroups->value('title')); $Qinsert->bindInt(':sort_order', $Qgroups->valueInt('sort_order')); $Qinsert->bindValue(':module', $Qgroups->value('module')); $Qinsert->execute(); if ($OSCOM_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qvalues = $OSCOM_Database->query('select id, products_variants_groups_id, title, sort_order from :table_products_variants_values where languages_id = :languages_id'); $Qvalues->bindInt(':languages_id', $default_language_id); $Qvalues->execute(); while ($Qvalues->next()) { $Qinsert = $OSCOM_Database->query('insert into :table_products_variants_values (id, languages_id, products_variants_groups_id, title, sort_order) values (:id, :languages_id, :products_variants_groups_id, :title, :sort_order)'); $Qinsert->bindInt(':id', $Qvalues->valueInt('id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindInt(':products_variants_groups_id', $Qvalues->valueInt('products_variants_groups_id')); $Qinsert->bindValue(':title', $Qvalues->value('title')); $Qinsert->bindInt(':sort_order', $Qvalues->valueInt('sort_order')); $Qinsert->execute(); if ($OSCOM_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qmanufacturers = $OSCOM_Database->query('select manufacturers_id, manufacturers_url from :table_manufacturers_info where languages_id = :languages_id'); $Qmanufacturers->bindInt(':languages_id', $default_language_id); $Qmanufacturers->execute(); while ($Qmanufacturers->next()) { $Qinsert = $OSCOM_Database->query('insert into :table_manufacturers_info (manufacturers_id, languages_id, manufacturers_url) values (:manufacturers_id, :languages_id, :manufacturers_url)'); $Qinsert->bindInt(':manufacturers_id', $Qmanufacturers->valueInt('manufacturers_id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindValue(':manufacturers_url', $Qmanufacturers->value('manufacturers_url')); $Qinsert->execute(); if ($OSCOM_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qstatus = $OSCOM_Database->query('select orders_status_id, orders_status_name from :table_orders_status where language_id = :language_id'); $Qstatus->bindInt(':language_id', $default_language_id); $Qstatus->execute(); while ($Qstatus->next()) { $Qinsert = $OSCOM_Database->query('insert into :table_orders_status (orders_status_id, language_id, orders_status_name) values (:orders_status_id, :language_id, :orders_status_name)'); $Qinsert->bindInt(':orders_status_id', $Qstatus->valueInt('orders_status_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':orders_status_name', $Qstatus->value('orders_status_name')); $Qinsert->execute(); if ($OSCOM_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qstatus = $OSCOM_Database->query('select id, status_name from :table_orders_transactions_status where language_id = :language_id'); $Qstatus->bindInt(':language_id', $default_language_id); $Qstatus->execute(); while ($Qstatus->next()) { $Qinsert = $OSCOM_Database->query('insert into :table_orders_transactions_status (id, language_id, status_name) values (:id, :language_id, :status_name)'); $Qinsert->bindInt(':id', $Qstatus->valueInt('id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':status_name', $Qstatus->value('status_name')); $Qinsert->execute(); if ($OSCOM_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qstatus = $OSCOM_Database->query('select id, title, css_key from :table_shipping_availability where languages_id = :languages_id'); $Qstatus->bindInt(':languages_id', $default_language_id); $Qstatus->execute(); while ($Qstatus->next()) { $Qinsert = $OSCOM_Database->query('insert into :table_shipping_availability (id, languages_id, title, css_key) values (:id, :languages_id, :title, :css_key)'); $Qinsert->bindInt(':id', $Qstatus->valueInt('id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindValue(':title', $Qstatus->value('title')); $Qinsert->bindValue(':css_key', $Qstatus->value('css_key')); $Qinsert->execute(); if ($OSCOM_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qstatus = $OSCOM_Database->query('select weight_class_id, weight_class_key, weight_class_title from :table_weight_classes where language_id = :language_id'); $Qstatus->bindInt(':language_id', $default_language_id); $Qstatus->execute(); while ($Qstatus->next()) { $Qinsert = $OSCOM_Database->query('insert into :table_weight_classes (weight_class_id, weight_class_key, language_id, weight_class_title) values (:weight_class_id, :weight_class_key, :language_id, :weight_class_title)'); $Qinsert->bindInt(':weight_class_id', $Qstatus->valueInt('weight_class_id')); $Qinsert->bindValue(':weight_class_key', $Qstatus->value('weight_class_key')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':weight_class_title', $Qstatus->value('weight_class_title')); $Qinsert->execute(); if ($OSCOM_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qgroup = $OSCOM_Database->query('select id, title, code, size_width, size_height, force_size from :table_products_images_groups where language_id = :language_id'); $Qgroup->bindInt(':language_id', $default_language_id); $Qgroup->execute(); while ($Qgroup->next()) { $Qinsert = $OSCOM_Database->query('insert into :table_products_images_groups (id, language_id, title, code, size_width, size_height, force_size) values (:id, :language_id, :title, :code, :size_width, :size_height, :force_size)'); $Qinsert->bindInt(':id', $Qgroup->valueInt('id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':title', $Qgroup->value('title')); $Qinsert->bindValue(':code', $Qgroup->value('code')); $Qinsert->bindInt(':size_width', $Qgroup->value('size_width')); $Qinsert->bindInt(':size_height', $Qgroup->value('size_height')); $Qinsert->bindInt(':force_size', $Qgroup->value('force_size')); $Qinsert->execute(); if ($OSCOM_Database->isError()) { $error = true; break; } } } } } if ($error === false) { $OSCOM_Database->commitTransaction(); Cache::clear('languages'); return true; } else { $OSCOM_Database->rollbackTransaction(); } return false; }
?> </h2> <?php $http_url = parse_url($_POST['HTTP_WWW_ADDRESS']); $http_server = $http_url['scheme'] . '://' . $http_url['host']; $http_catalog = $http_url['path']; if (isset($http_url['port']) && !empty($http_url['port'])) { $http_server .= ':' . $http_url['port']; } if (substr($http_catalog, -1) != '/') { $http_catalog .= '/'; } $dir_fs_document_root = realpath(OSCOM::BASE_DIRECTORY . '../../') . '/'; $OSCOM_DirectoryListing = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Work/Cache'); $OSCOM_DirectoryListing->setIncludeDirectories(false); $OSCOM_DirectoryListing->setCheckExtension('cache'); foreach ($OSCOM_DirectoryListing->getFiles() as $files) { @unlink($OSCOM_DirectoryListing->getDirectory() . '/' . $files['name']); } $file_contents = 'OSCOM_BOOTSTRAP_FILE = "index.php"' . "\n" . 'OSCOM_DEFAULT_SITE = "Shop"' . "\n" . 'HTTP_SERVER = "' . $http_server . '"' . "\n" . 'HTTPS_SERVER = "' . $http_server . '"' . "\n" . 'ENABLE_SSL = "false"' . "\n" . 'HTTP_COOKIE_DOMAIN = ""' . "\n" . 'HTTPS_COOKIE_DOMAIN = ""' . "\n" . 'HTTP_COOKIE_PATH = "' . $http_catalog . '"' . "\n" . 'HTTPS_COOKIE_PATH = "' . $http_catalog . '"' . "\n" . 'DIR_WS_HTTP_CATALOG = "' . $http_catalog . '"' . "\n" . 'DIR_WS_HTTPS_CATALOG = "' . $http_catalog . '"' . "\n" . 'DIR_WS_IMAGES = "images/"' . "\n" . 'DIR_WS_DOWNLOAD_PUBLIC = "pub/"' . "\n" . 'DIR_FS_CATALOG = "' . $dir_fs_document_root . '"' . "\n" . 'DIR_FS_WORK = "' . OSCOM::BASE_DIRECTORY . 'work/' . '"' . "\n" . 'DIR_FS_DOWNLOAD = "' . $dir_fs_document_root . 'download/"' . "\n" . 'DIR_FS_DOWNLOAD_PUBLIC = "' . $dir_fs_document_root . 'pub/"' . "\n" . 'DIR_FS_BACKUP = "' . OSCOM::BASE_DIRECTORY . 'Core/Site/Admin/backups/"' . "\n" . 'DB_SERVER = "' . $_POST['DB_SERVER'] . '"' . "\n" . 'DB_SERVER_USERNAME = "******"' . "\n" . 'DB_SERVER_PASSWORD = "******"' . "\n" . 'DB_SERVER_PORT = "' . $_POST['DB_SERVER_PORT'] . '"' . "\n" . 'DB_DATABASE = "' . $_POST['DB_DATABASE'] . '"' . "\n" . 'DB_DATABASE_CLASS = "' . str_replace('_', '\\', $_POST['DB_DATABASE_CLASS']) . '"' . "\n" . 'DB_TABLE_PREFIX = "' . $_POST['DB_TABLE_PREFIX'] . '"' . "\n" . 'DB_SERVER_PERSISTENT_CONNECTIONS = "false"' . "\n" . 'STORE_SESSIONS = "Database"' . "\n"; if (is_writable(OSCOM::BASE_DIRECTORY . 'Config/settings.ini')) { file_put_contents(OSCOM::BASE_DIRECTORY . 'Config/settings.ini', $file_contents); ?> <p><?php echo OSCOM::getDef('text_successful_installation'); ?> </p> <?php
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() . ']]'; } }
public static function execute($data) { Registry::set('PDO', PDO::initialize($data['server'], $data['username'], $data['password'], $data['database'], $data['port'], $data['class'])); // Import SQL queries OSCOM::callDB('Setup\\Install\\ImportSQL', array('table_prefix' => $data['table_prefix'])); // Import language definitions OSCOM::setConfig('db_table_prefix', $data['table_prefix'], 'Admin'); OSCOM::setConfig('db_table_prefix', $data['table_prefix'], 'Shop'); OSCOM::setConfig('db_table_prefix', $data['table_prefix'], 'Setup'); foreach (Language::extractDefinitions('en_US.xml') as $def) { $def['id'] = 1; OSCOM::callDB('Admin\\InsertLanguageDefinition', $def, 'Site'); } $DL_lang = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/Shop/Languages/en_US'); $DL_lang->setRecursive(true); $DL_lang->setIncludeDirectories(false); $DL_lang->setAddDirectoryToFilename(true); $DL_lang->setCheckExtension('xml'); foreach ($DL_lang->getFiles() as $files) { foreach (Language::extractDefinitions('en_US/' . $files['name']) as $def) { $def['id'] = 1; OSCOM::callDB('Admin\\InsertLanguageDefinition', $def, 'Site'); } } // Import Service modules $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); } $cfg_data = array('title' => 'Service Modules', 'key' => 'MODULE_SERVICES_INSTALLED', 'value' => implode(';', $installed), 'description' => 'Installed services modules', 'group_id' => '6'); OSCOM::callDB('Admin\\InsertConfigurationParameters', $cfg_data, 'Site'); // Import Payment modules define('DEFAULT_ORDERS_STATUS_ID', 1); $module = new \osCommerce\OM\Core\Site\Admin\Module\Payment\COD(); $module->install(); $pm_data = array('key' => 'MODULE_PAYMENT_COD_STATUS', 'value' => '1'); OSCOM::callDB('Admin\\UpdateConfigurationParameters', $pm_data, 'Site'); // Import Shipping modules $module = new \osCommerce\OM\Core\Site\Admin\Module\Shipping\Flat(); $module->install(); // Import Order Total modules $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(); // Import Foreign Keys OSCOM::callDB('Setup\\Install\\ImportFK', array('table_prefix' => $data['table_prefix'])); }
$http_url = parse_url($_POST['HTTP_WWW_ADDRESS']); $http_server = $http_url['scheme'] . '://' . $http_url['host']; $http_dir_ws = $http_url['path']; if (isset($http_url['port']) && !empty($http_url['port'])) { $http_server .= ':' . $http_url['port']; } if (substr($http_dir_ws, -1) != '/') { $http_dir_ws .= '/'; } $http_cookie_domain = ''; if (substr_count($http_url['host'], '.') > 1 && !filter_var($http_url['host'], FILTER_VALIDATE_IP)) { $http_cookie_domain = $http_url['host']; } $dir_fs_document_root = OSCOM_PUBLIC_BASE_DIRECTORY; $DL_Cache = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Work/Cache'); $DL_Cache->setIncludeDirectories(false); $DL_Cache->setCheckExtension('cache'); foreach ($DL_Cache->getFiles() as $files) { @unlink($DL_Cache->getDirectory() . '/' . $files['name']); } $db_class = str_replace('_', '\\', $_POST['DB_DATABASE_CLASS']); $file_contents = <<<EOT [OSCOM] bootstrap_file = "index.php" default_site = "Shop" time_zone = "{$_POST['CFG_TIME_ZONE']}" dir_fs_public = "{$dir_fs_document_root}public/" [Admin] enable_ssl = "false" http_server = "{$http_server}"
public static function execute() { $result = array('entries' => array()); $phar_can_open = true; try { $phar = new Phar(OSCOM::BASE_DIRECTORY . 'Work/CoreUpdate/update.phar'); } catch (\Exception $e) { $phar_can_open = false; trigger_error($e->getMessage()); } if ($phar_can_open === true) { $update_pkg = array(); foreach (new RecursiveIteratorIterator($phar) as $iteration) { if (($pos = strpos($iteration->getPathName(), 'update.phar')) !== false) { $update_pkg[] = substr($iteration->getPathName(), $pos + 12); } } natcasesort($update_pkg); $counter = 0; foreach ($update_pkg as $file) { if (substr($file, 0, 14) == 'osCommerce/OM/') { $custom = false; if (substr($file, 14, 5) == 'Core/') { $custom = file_exists(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/osCommerce/OM/Custom/' . substr($file, 19)); } $result['entries'][] = array('key' => $counter, 'name' => $file, 'exists' => file_exists(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . $file), 'writable' => self::isWritable(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . $file) && self::isWritable(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . dirname($file)), 'custom' => $custom, 'to_delete' => false); $counter++; } elseif (substr($file, 0, 7) == 'public/') { $result['entries'][] = array('key' => $counter, 'name' => $file, 'exists' => file_exists(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $file), 'writable' => self::isWritable(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $file) && self::isWritable(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . dirname($file)), 'custom' => false, 'to_delete' => false); $counter++; } } } $meta = $phar->getMetadata(); if (isset($meta['delete'])) { $files = array(); foreach ($meta['delete'] as $file) { if (substr($file, 0, 14) == 'osCommerce/OM/') { if (file_exists(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . $file)) { if (is_dir(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . $file)) { $DL = new DirectoryListing(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . $file); $DL->setRecursive(true); $DL->setAddDirectoryToFilename(true); $DL->setIncludeDirectories(false); foreach ($DL->getFiles() as $f) { $files[] = $file . '/' . $f['name']; } } else { $files[] = $file; } } } elseif (substr($file, 0, 7) == 'public/') { if (file_exists(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $file)) { if (is_dir(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $file)) { $DL = new DirectoryListing(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $file); $DL->setRecursive(true); $DL->setAddDirectoryToFilename(true); $DL->setIncludeDirectories(false); foreach ($DL->getFiles() as $f) { $files[] = $file . '/' . $f['name']; } } else { $files[] = $file; } } } } natcasesort($files); foreach ($files as $d) { $writable = false; $custom = false; if (substr($d, 0, 14) == 'osCommerce/OM/') { $writable = self::isWritable(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . $d) && self::isWritable(realpath(OSCOM::BASE_DIRECTORY . '../../') . '/' . dirname($d)); } elseif (substr($d, 0, 7) == 'public/') { $writable = self::isWritable(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . $d) && self::isWritable(realpath(OSCOM::getConfig('dir_fs_public', 'OSCOM') . '../') . '/' . dirname($d)); } $result['entries'][] = array('key' => $counter, 'name' => $d, 'exists' => true, 'writable' => $writable, 'custom' => $custom, 'to_delete' => true); $counter++; } } $result['total'] = count($result['entries']); return $result; }