public static function getLocalImages() { $osC_DirectoryListing = new osC_DirectoryListing('../images/products/_upload', true); $osC_DirectoryListing->setCheckExtension('gif'); $osC_DirectoryListing->setCheckExtension('jpg'); $osC_DirectoryListing->setCheckExtension('png'); $osC_DirectoryListing->setIncludeDirectories(false); $result = array('entries' => array()); foreach ($osC_DirectoryListing->getFiles() as $file) { $result['entries'][] = $file['name']; } $result['rpcStatus'] = RPC_STATUS_SUCCESS; echo json_encode($result); }
function listCache() { global $toC_Json; $osC_DirectoryListing = new osC_DirectoryListing(DIR_FS_WORK); $osC_DirectoryListing->setIncludeDirectories(false); $osC_DirectoryListing->setCheckExtension('cache'); $response = array(); foreach ($osC_DirectoryListing->getFiles() as $file) { $last_modified = filemtime(DIR_FS_WORK . '/' . $file['name']); if (strpos($file['name'], '-') !== false) { $code = substr($file['name'], 0, strpos($file['name'], '-')); } else { $code = substr($file['name'], 0, strpos($file['name'], '.')); } if (isset($cached_files[$code])) { $cached_files[$code]['total']++; if ($last_modified > $cached_files[$code]['last_modified']) { $cached_files[$code]['last_modified'] = $last_modified; } } else { $cached_files[$code] = array('total' => 1, 'last_modified' => $last_modified); } $response[] = array('code' => $code, 'total' => $cached_files[$code]['total'], 'last_modified' => osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($cached_files[$code]['last_modified']), true)); } $response = array(EXT_JSON_READER_ROOT => $response); echo $toC_Json->encode($response); }
function getLanguages() { global $toC_Json; $osC_DirectoryListing = new osC_DirectoryListing('../includes/languages'); $osC_DirectoryListing->setIncludeDirectories(false); $osC_DirectoryListing->setCheckExtension('xml'); $records = array(); foreach ($osC_DirectoryListing->getFiles() as $file) { $records[] = array('id' => substr($file['name'], 0, strrpos($file['name'], '.')), 'text' => substr($file['name'], 0, strrpos($file['name'], '.'))); } $response = array(EXT_JSON_READER_ROOT => $records); echo $toC_Json->encode($response); }
function osC_LanguageInstall() { $osC_DirectoryListing = new osC_DirectoryListing('../includes/languages'); $osC_DirectoryListing->setIncludeDirectories(false); $osC_DirectoryListing->setCheckExtension('xml'); foreach ($osC_DirectoryListing->getFiles() as $file) { $osC_XML = new osC_XML(file_get_contents('../includes/languages/' . $file['name'])); $lang = $osC_XML->toArray(); $this->_languages[$lang['language']['data']['code']] = array('name' => $lang['language']['data']['title'], 'code' => $lang['language']['data']['code'], 'charset' => $lang['language']['data']['character_set']); } unset($lang); $language = isset($_GET['language']) && !empty($_GET['language']) ? $_GET['language'] : ''; $this->set($language); $this->loadIniFile(); $this->loadIniFile(basename($_SERVER['SCRIPT_FILENAME'])); }
function listImages() { global $toC_Json; $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/image'); $osC_DirectoryListing->setIncludeDirectories(false); $osC_DirectoryListing->setCheckExtension('php'); $record = array(); foreach ($osC_DirectoryListing->getFiles() as $file) { $class = 'osC_Image_Admin_' . substr($file['name'], 0, strrpos($file['name'], '.')); if (class_exists($class)) { $module = new $class(); $record[] = array('module' => $module->getTitle(), 'run' => substr($file['name'], 0, strrpos($file['name'], '.'))); } } $response = array(EXT_JSON_READER_ROOT => $record); echo $toC_Json->encode($response); }
function _createIndexSitemap() { global $osC_Language; $handle = fopen($this->_save_path . 'sitemapsIndex.xml', 'w'); $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $xml .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n"; fwrite($handle, $xml); $directory_listing = new osC_DirectoryListing($this->_save_path); $directory_listing->setIncludeDirectories(false); $directory_listing->setIncludeFiles(true); $directory_listing->setCheckExtension('xml'); $xmls = $directory_listing->getFiles(); if (!empty($xmls)) { foreach ($xmls as $xml) { if ($xml['name'] !== $this->_file_name . 'Index.xml' && preg_match('/^sitemaps[A-Za-z_]+\\.xml$/', $xml['name'])) { $content = "\t" . '<sitemap>' . "\n"; $content .= "\t\t" . '<loc>' . $this->_base_url . basename($xml['name']) . '</loc>' . "\n"; $content .= "\t\t" . '<lastmod>' . date("Y-m-d", filemtime($this->_save_path . basename($xml['name']))) . '</lastmod>' . "\n"; $content .= "\t" . '</sitemap>' . "\n"; fwrite($handle, $content); } } } fwrite($handle, '</sitemapindex>'); fclose($handle); $osC_Language->set($this->_original_language_code); return true; }
function import($file, $type) { global $osC_Database, $osC_Currencies; if (file_exists('../includes/languages/' . $file . '.xml')) { $osC_XML = new osC_XML(file_get_contents('../includes/languages/' . $file . '.xml')); $source = $osC_XML->toArray(); $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' => $source['language']['data']['parent_language_code'], 'parent_id' => 0); if (!$osC_Currencies->exists($language['currency'])) { $language['currency'] = DEFAULT_CURRENCY; } if (!empty($language['parent_language_code'])) { $Qlanguage = $osC_Database->query('select languages_id from :table_languages where code = :code'); $Qlanguage->bindTable(':table_languages', TABLE_LANGUAGES); $Qlanguage->bindValue(':code', $language['parent_language_code']); $Qlanguage->execute(); if ($Qlanguage->numberOfRows() === 1) { $language['parent_id'] = $Qlanguage->valueInt('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'])); } } $tables = array(); if (isset($source['language']['tables']['table'])) { $tables = $source['language']['tables']['table']; } unset($source); $error = false; $add_category_and_product_placeholders = true; $osC_Database->startTransaction(); $Qcheck = $osC_Database->query('select languages_id from :table_languages where code = :code'); $Qcheck->bindTable(':table_languages', TABLE_LANGUAGES); $Qcheck->bindValue(':code', $language['code']); $Qcheck->execute(); if ($Qcheck->numberOfRows() === 1) { $add_category_and_product_placeholders = false; $language_id = $Qcheck->valueInt('languages_id'); $Qlanguage = $osC_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 = $osC_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->bindTable(':table_languages', TABLE_LANGUAGES); $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', $osC_Currencies->getID($language['currency'])); $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($_SESSION['module'], $Qcheck->numberOfRows() === 1 ? $language_id : null); $Qlanguage->execute(); if ($osC_Database->isError()) { $error = true; } else { if ($Qcheck->numberOfRows() !== 1) { $language_id = $osC_Database->nextID(); } $default_language_id = osC_Language_Admin::getData(osC_Language_Admin::getID(DEFAULT_LANGUAGE), 'languages_id'); if ($type == 'replace') { $Qdel = $osC_Database->query('delete from :table_languages_definitions where languages_id = :languages_id'); $Qdel->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS); $Qdel->bindInt(':languages_id', $language_id); $Qdel->execute(); if ($osC_Database->isError()) { $error = true; } } } if ($error === false) { $osC_DirectoryListing = new osC_DirectoryListing('../includes/languages/' . $file); $osC_DirectoryListing->setRecursive(true); $osC_DirectoryListing->setIncludeDirectories(false); $osC_DirectoryListing->setAddDirectoryToFilename(true); $osC_DirectoryListing->setCheckExtension('xml'); foreach ($osC_DirectoryListing->getFiles() as $files) { $definitions = array_merge($definitions, osC_Language_Admin::extractDefinitions($file . '/' . $files['name'])); } foreach ($definitions as $def) { $insert = false; $update = false; if ($type == 'replace') { $insert = true; } else { $Qcheck = $osC_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->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS); $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 = $osC_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 = $osC_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->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS); $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 ($osC_Database->isError()) { $error = true; break; } } } } if ($add_category_and_product_placeholders === true) { if (!empty($tables)) { foreach ($tables as $table) { $table_name = str_replace('toc_', DB_TABLE_PREFIX, $table['meta']['name']); $key_field = $table['meta']['key_field']; $language_field = $table['meta']['language_field']; $Qcheck = $osC_Database->query('select * from :table_name where ' . $language_field . ' = :language_id'); $Qcheck->bindTable(':table_name', $table_name); $Qcheck->bindInt(':language_id', $default_language_id); $Qcheck->execute(); while ($Qcheck->next()) { $data = $Qcheck->toArray(); $data[$language_field] = $language_id; $insert = false; foreach ($table['definition'] as $definition) { if ($data[$key_field] == $definition['key']) { $insert = true; foreach ($definition as $key => $value) { if ($key != 'key' && array_key_exists($key, $data)) { $data[$key] = $osC_Database->escapeString($value); } } } } if ($insert === true) { $fields = array_keys($data); $values = array(); foreach ($fields as $field) { $values[] = "'" . $data[$field] . "'"; } $Qinsert = $osC_Database->query('insert into :table_name (' . implode(', ', $fields) . ') values (' . implode(', ', $values) . ')'); $Qinsert->bindTable(':table_name', $table_name); $Qinsert->execute(); } } } } if ($error === false) { $Qcategories = $osC_Database->query('select categories_id, categories_name, categories_url, categories_page_title, categories_meta_keywords, categories_meta_description from :table_categories_description where language_id = :language_id'); $Qcategories->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); $Qcategories->bindInt(':language_id', $default_language_id); $Qcategories->execute(); while ($Qcategories->next()) { $Qinsert = $osC_Database->query('insert into :table_categories_description (categories_id, language_id, categories_name, categories_url, categories_page_title, categories_meta_keywords, categories_meta_description) values (:categories_id, :language_id, :categories_name, :categories_url, :categories_page_title, :categories_meta_keywords, :categories_meta_description)'); $Qinsert->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); $Qinsert->bindInt(':categories_id', $Qcategories->valueInt('categories_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':categories_name', $Qcategories->value('categories_name')); $Qinsert->bindValue(':categories_url', $Qcategories->value('categories_url')); $Qinsert->bindValue(':categories_page_title', $Qcategories->value('categories_page_title')); $Qinsert->bindValue(':categories_meta_keywords', $Qcategories->value('categories_meta_keywords')); $Qinsert->bindValue(':categories_meta_description', $Qcategories->value('categories_meta_description')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qproducts = $osC_Database->query('select products_id, products_name, products_description, products_keyword, products_tags, products_url, products_friendly_url, products_page_title, products_meta_keywords, products_meta_description, products_viewed from :table_products_description where language_id = :language_id'); $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); $Qproducts->bindInt(':language_id', $default_language_id); $Qproducts->execute(); while ($Qproducts->next()) { $Qinsert = $osC_Database->query('insert into :table_products_description (products_id, language_id, products_name, products_description, products_keyword, products_tags, products_url, products_friendly_url, products_page_title, products_meta_keywords, products_meta_description, products_viewed) values (:products_id, :language_id, :products_name, :products_description, :products_keyword, :products_tags, :products_url, :products_friendly_url, :products_page_title, :products_meta_keywords, :products_meta_description, :products_viewed)'); $Qinsert->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); $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->bindValue(':products_friendly_url', $Qproducts->value('products_friendly_url')); $Qinsert->bindValue(':products_page_title', $Qproducts->value('products_page_title')); $Qinsert->bindValue(':products_meta_keywords', $Qproducts->value('products_meta_keywords')); $Qinsert->bindValue(':products_meta_description', $Qproducts->value('products_meta_description')); $Qinsert->bindInt(':products_viewed', $Qproducts->valueInt('products_viewed')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $QcustomizationFields = $osC_Database->query('select customization_fields_id, languages_id, name from :table_customization_fields_description where languages_id = :languages_id'); $QcustomizationFields->bindTable(':table_customization_fields_description', TABLE_CUSTOMIZATION_FIELDS_DESCRIPTION); $QcustomizationFields->bindInt(':languages_id', $default_language_id); $QcustomizationFields->execute(); while ($QcustomizationFields->next()) { $Qinsert = $osC_Database->query('insert into :table_customization_fields_description (customization_fields_id, languages_id, name) values (:customization_fields_id, :languages_id, :name)'); $Qinsert->bindTable(':table_customization_fields_description', TABLE_CUSTOMIZATION_FIELDS_DESCRIPTION); $Qinsert->bindInt(':customization_fields_id', $QcustomizationFields->valueInt('customization_fields_id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindValue(':name', $QcustomizationFields->value('name')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qvariants = $osC_Database->query('select products_variants_groups_id, products_variants_groups_name from :table_products_variants_groups where language_id = :language_id'); $Qvariants->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS); $Qvariants->bindInt(':language_id', $default_language_id); $Qvariants->execute(); while ($Qvariants->next()) { $Qinsert = $osC_Database->query('insert into :table_products_variants_groups (products_variants_groups_id, language_id, products_variants_groups_name) values (:products_variants_groups_id, :language_id, :products_variants_groups_name)'); $Qinsert->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS); $Qinsert->bindInt(':products_variants_groups_id', $Qvariants->valueInt('products_variants_groups_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':products_variants_groups_name', $Qvariants->value('products_variants_groups_name')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qvalues = $osC_Database->query('select products_variants_values_id, products_variants_values_name from :table_products_variants_values where language_id = :language_id'); $Qvalues->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES); $Qvalues->bindInt(':language_id', $default_language_id); $Qvalues->execute(); while ($Qvalues->next()) { $Qinsert = $osC_Database->query('insert into :table_products_variants_values (products_variants_values_id, language_id, products_variants_values_name) values (:products_variants_values_id, :language_id, :products_variants_values_name)'); $Qinsert->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES); $Qinsert->bindInt(':products_variants_values_id', $Qvalues->valueInt('products_variants_values_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':products_variants_values_name', $Qvalues->value('products_variants_values_name')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qmanufacturers = $osC_Database->query('select manufacturers_id, manufacturers_url, manufacturers_friendly_url from :table_manufacturers_info where languages_id = :languages_id'); $Qmanufacturers->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO); $Qmanufacturers->bindInt(':languages_id', $default_language_id); $Qmanufacturers->execute(); while ($Qmanufacturers->next()) { $Qinsert = $osC_Database->query('insert into :table_manufacturers_info (manufacturers_id, languages_id, manufacturers_url, manufacturers_friendly_url) values (:manufacturers_id, :languages_id, :manufacturers_url, :manufacturers_friendly_url)'); $Qinsert->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO); $Qinsert->bindInt(':manufacturers_id', $Qmanufacturers->valueInt('manufacturers_id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindValue(':manufacturers_url', $Qmanufacturers->value('manufacturers_url')); $Qinsert->bindValue(':manufacturers_friendly_url', $Qmanufacturers->value('manufacturers_friendly_url')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qimages = $osC_Database->query('select image_id, description, image, image_url, sort_order, status from :table_slide_images where language_id = :language_id'); $Qimages->bindTable(':table_slide_images', TABLE_SLIDE_IMAGES); $Qimages->bindInt(':language_id', $default_language_id); $Qimages->execute(); while ($Qimages->next()) { $Qinsert = $osC_Database->query('insert into :table_slide_images (image_id, language_id, description, image, image_url, sort_order, status) values (:image_id, :language_id, :description, :image, :image_url, :sort_order, :status)'); $Qinsert->bindTable(':table_slide_images', TABLE_SLIDE_IMAGES); $Qinsert->bindInt(':image_id', $Qimages->valueInt('image_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':description', $Qimages->value('description')); $Qinsert->bindValue(':image', $Qimages->value('image')); $Qinsert->bindValue(':image_url', $Qimages->value('image_url')); $Qinsert->bindInt(':sort_order', $Qimages->valueInt('sort_order')); $Qinsert->bindInt(':status', $Qimages->valueInt('status')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qattributes = $osC_Database->query('select products_attributes_values_id, products_attributes_groups_id, name, module, value, status, sort_order from :table_products_attributes_values where language_id = :language_id'); $Qattributes->bindTable(':table_products_attributes_values', TABLE_PRODUCTS_ATTRIBUTES_VALUES); $Qattributes->bindInt(':language_id', $default_language_id); $Qattributes->execute(); while ($Qattributes->next()) { $Qinsert = $osC_Database->query('insert into :table_products_attributes_values (products_attributes_values_id, products_attributes_groups_id, language_id, name, module, value, status, sort_order) values (:products_attributes_values_id, :products_attributes_groups_id, :language_id, :name, :module, :value, :status, :sort_order)'); $Qinsert->bindTable(':table_products_attributes_values', TABLE_PRODUCTS_ATTRIBUTES_VALUES); $Qinsert->bindInt(':products_attributes_values_id', $Qattributes->valueInt('products_attributes_values_id')); $Qinsert->bindInt(':products_attributes_groups_id', $Qattributes->valueInt('products_attributes_groups_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':name', $Qattributes->value('name')); $Qinsert->bindValue(':module', $Qattributes->value('module')); $Qinsert->bindValue(':value', $Qattributes->value('value')); $Qinsert->bindInt(':status', $Qattributes->valueInt('status')); $Qinsert->bindInt(':sort_order', $Qattributes->valueInt('sort_order')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qattributes = $osC_Database->query('select products_id, products_attributes_values_id, value from :table_products_attributes where language_id = :language_id'); $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); $Qattributes->bindInt(':language_id', $default_language_id); $Qattributes->execute(); while ($Qattributes->next()) { $Qinsert = $osC_Database->query('insert into :table_products_attributes (products_id, products_attributes_values_id, value, language_id) values (:products_id, :products_attributes_values_id, :value, :language_id)'); $Qinsert->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES); $Qinsert->bindInt(':products_id', $Qattributes->valueInt('products_id')); $Qinsert->bindInt(':products_attributes_values_id', $Qattributes->valueInt('products_attributes_values_id')); $Qinsert->bindValue(':value', $Qattributes->value('value')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qfaqs = $osC_Database->query('select faqs_id, faqs_question, faqs_url, faqs_answer from :table_faqs_description where language_id = :language_id'); $Qfaqs->bindTable(':table_faqs_description', TABLE_FAQS_DESCRIPTION); $Qfaqs->bindInt(':language_id', $default_language_id); $Qfaqs->execute(); while ($Qfaqs->next()) { $Qinsert = $osC_Database->query('insert into :table_faqs_description (faqs_id, language_id, faqs_question, faqs_answer, faqs_url) values (:faqs_id, :language_id, :faqs_question, :faqs_answer, :faqs_url)'); $Qinsert->bindTable(':table_faqs_description', TABLE_FAQS_DESCRIPTION); $Qinsert->bindInt(':faqs_id', $Qfaqs->valueInt('faqs_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':faqs_question', $Qfaqs->value('faqs_question')); $Qinsert->bindValue(':faqs_answer', $Qfaqs->value('faqs_answer')); $Qinsert->bindValue(':faqs_url', $Qfaqs->value('faqs_url')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qcoupons = $osC_Database->query('select coupons_id, coupons_name, coupons_description from :table_coupons_description where language_id = :language_id'); $Qcoupons->bindTable(':table_coupons_description', TABLE_COUPONS_DESCRIPTION); $Qcoupons->bindInt(':language_id', $default_language_id); $Qcoupons->execute(); while ($Qcoupons->next()) { $Qinsert = $osC_Database->query('insert into :table_coupons_description (coupons_id, language_id, coupons_name, coupons_description) values (:coupons_id, :language_id, :coupons_name, :coupons_description)'); $Qinsert->bindTable(':table_coupons_description', TABLE_COUPONS_DESCRIPTION); $Qinsert->bindInt(':coupons_id', $Qcoupons->valueInt('coupons_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':coupons_name', $Qcoupons->value('coupons_name')); $Qinsert->bindValue(':coupons_description', $Qcoupons->value('coupons_description')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qarticles = $osC_Database->query('select articles_id, articles_name, articles_description, articles_url, articles_page_title, articles_meta_keywords, articles_meta_description from :table_articles_description where language_id = :language_id'); $Qarticles->bindTable(':table_articles_description', TABLE_ARTICLES_DESCRIPTION); $Qarticles->bindInt(':language_id', $default_language_id); $Qarticles->execute(); while ($Qarticles->next()) { $Qcheck = $osC_Database->query('select * from :table_articles_description where articles_id = :articles_id and language_id = :language_id'); $Qcheck->bindTable(':table_articles_description', TABLE_ARTICLES_DESCRIPTION); $Qcheck->bindInt(':articles_id', $Qarticles->valueInt('articles_id')); $Qcheck->bindInt(':language_id', $language_id); $Qcheck->execute(); if ($Qcheck->numberOfRows() === 0) { $Qinsert = $osC_Database->query('insert into :table_articles_description (articles_id, language_id, articles_name, articles_description, articles_url, articles_page_title, articles_meta_keywords, articles_meta_description) values (:articles_id, :language_id, :articles_name, :articles_description, :articles_url, :articles_page_title, :articles_meta_keywords, :articles_meta_description)'); $Qinsert->bindTable(':table_articles_description', TABLE_ARTICLES_DESCRIPTION); $Qinsert->bindInt(':articles_id', $Qarticles->valueInt('articles_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':articles_name', $Qarticles->value('articles_name')); $Qinsert->bindValue(':articles_description', $Qarticles->value('articles_description')); $Qinsert->bindValue(':articles_url', $Qarticles->value('articles_url')); $Qinsert->bindValue(':articles_page_title', $Qarticles->value('articles_page_title')); $Qinsert->bindValue(':articles_meta_keywords', $Qarticles->value('articles_meta_keywords')); $Qinsert->bindValue(':articles_meta_description', $Qarticles->value('articles_meta_description')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } } if ($error === false) { $Qcategories = $osC_Database->query('select articles_categories_id, articles_categories_name, articles_categories_url, articles_categories_page_title, articles_categories_meta_keywords, articles_categories_meta_description from :table_articles_categories_description where language_id = :language_id'); $Qcategories->bindTable(':table_articles_categories_description', TABLE_ARTICLES_CATEGORIES_DESCRIPTION); $Qcategories->bindInt(':language_id', $default_language_id); $Qcategories->execute(); while ($Qcategories->next()) { $Qinsert = $osC_Database->query('insert into :table_articles_categories_description (articles_categories_id, language_id, articles_categories_name, articles_categories_url, articles_categories_page_title, articles_categories_meta_keywords, articles_categories_meta_description) values (:articles_categories_id, :language_id, :articles_categories_name, :articles_categories_url, :articles_categories_page_title, :articles_categories_meta_keywords, :articles_categories_meta_description )'); $Qinsert->bindTable(':table_articles_categories_description', TABLE_ARTICLES_CATEGORIES_DESCRIPTION); $Qinsert->bindInt(':articles_categories_id', $Qcategories->valueInt('articles_categories_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':articles_categories_name', $Qcategories->value('articles_categories_name')); $Qinsert->bindValue(':articles_categories_url', $Qcategories->value('articles_categories_url')); $Qinsert->bindValue(':articles_categories_page_title', $Qcategories->value('articles_categories_page_title')); $Qinsert->bindValue(':articles_categories_meta_keywords', $Qcategories->value('articles_categories_meta_keywords')); $Qinsert->bindValue(':articles_categories_meta_description', $Qcategories->value('articles_categories_meta_description')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qgroups = $osC_Database->query('select customers_groups_id, customers_groups_name from :table_customers_groups_description where language_id = :language_id'); $Qgroups->bindTable(':table_customers_groups_description', TABLE_CUSTOMERS_GROUPS_DESCRIPTION); $Qgroups->bindInt(':language_id', $default_language_id); $Qgroups->execute(); while ($Qgroups->next()) { $Qinsert = $osC_Database->query('insert into :table_customers_groups_description (customers_groups_id, language_id, customers_groups_name) values (:customers_groups_id, :language_id, :customers_groups_name)'); $Qinsert->bindTable(':table_customers_groups_description', TABLE_CUSTOMERS_GROUPS_DESCRIPTION); $Qinsert->bindInt(':customers_groups_id', $Qgroups->valueInt('customers_groups_id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':customers_groups_name', $Qgroups->value('customers_groups_name')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qratings = $osC_Database->query('select ratings_id, ratings_text from :table_ratings_description where languages_id = :languages_id'); $Qratings->bindTable(':table_ratings_description', TABLE_RATINGS_DESCRIPTION); $Qratings->bindInt(':languages_id', $default_language_id); $Qratings->execute(); while ($Qratings->next()) { $Qinsert = $osC_Database->query('insert into :table_ratings_description (ratings_id, languages_id, ratings_text) values (:ratings_id, :languages_id, :ratings_text)'); $Qinsert->bindTable(':table_ratings_description', TABLE_RATINGS_DESCRIPTION); $Qinsert->bindInt(':ratings_id', $Qratings->valueInt('ratings_id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindValue(':ratings_text', $Qratings->value('ratings_text')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qpolls = $osC_Database->query('select polls_id, polls_title from :table_polls_description where languages_id = :languages_id'); $Qpolls->bindTable(':table_polls_description', TABLE_POLLS_DESCRIPTION); $Qpolls->bindInt(':languages_id', $default_language_id); $Qpolls->execute(); while ($Qpolls->next()) { $Qinsert = $osC_Database->query('insert into :table_polls_description (polls_id, languages_id, polls_title) values (:polls_id, :languages_id, :polls_title)'); $Qinsert->bindTable(':table_polls_description', TABLE_POLLS_DESCRIPTION); $Qinsert->bindInt(':polls_id', $Qpolls->valueInt('polls_id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindValue(':polls_title', $Qpolls->value('polls_title')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qanswers = $osC_Database->query('select polls_answers_id, answers_title from :table_polls_answers_description where languages_id = :languages_id'); $Qanswers->bindTable(':table_polls_answers_description', TABLE_POLLS_ANSWERS_DESCRIPTION); $Qanswers->bindInt(':languages_id', $default_language_id); $Qanswers->execute(); while ($Qanswers->next()) { $Qinsert = $osC_Database->query('insert into :table_polls_answers_description (polls_answers_id, languages_id, answers_title) values (:polls_answers_id, :languages_id, :answers_title)'); $Qinsert->bindTable(':table_polls_answers_description', TABLE_POLLS_ANSWERS_DESCRIPTION); $Qinsert->bindInt(':polls_answers_id', $Qanswers->valueInt('polls_answers_id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindValue(':answers_title', $Qanswers->value('answers_title')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qattachments = $osC_Database->query('select attachments_id, attachments_name, attachments_description from :table_products_attachments_description where languages_id = :language_id'); $Qattachments->bindTable(':table_products_attachments_description', TABLE_PRODUCTS_ATTACHMENTS_DESCRIPTION); $Qattachments->bindInt(':language_id', $default_language_id); $Qattachments->execute(); while ($Qattachments->next()) { $Qinsert = $osC_Database->query('insert into :table_products_attachments_description (attachments_id, languages_id, attachments_name, attachments_description) values (:attachments_id, :languages_id, :attachments_name, :attachments_description)'); $Qinsert->bindTable(':table_products_attachments_description', TABLE_PRODUCTS_ATTACHMENTS_DESCRIPTION); $Qinsert->bindInt(':attachments_id', $Qattachments->valueInt('attachments_id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindValue(':attachments_name', $Qattachments->value('attachments_name')); $Qinsert->bindValue(':attachments_description', $Qattachments->value('attachments_description')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qdepart = $osC_Database->query('select departments_id, departments_title, departments_description from :table_departments_description where languages_id = :language_id'); $Qdepart->bindTable(':table_departments_description', TABLE_DEPARTMENTS_DESCRIPTION); $Qdepart->bindInt(':language_id', $default_language_id); $Qdepart->execute(); while ($Qdepart->next()) { $Qinsert = $osC_Database->query('insert into :table_departments_description (departments_id, languages_id, departments_title, departments_description) values (:departments_id, :languages_id, :departments_title, :departments_description)'); $Qinsert->bindTable(':table_departments_description', TABLE_DEPARTMENTS_DESCRIPTION); $Qinsert->bindInt(':departments_id', $Qdepart->valueInt('departments_id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindValue(':departments_title', $Qdepart->value('departments_title')); $Qinsert->bindValue(':departments_description', $Qdepart->value('departments_description')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } } } if ($error === false) { $osC_Database->commitTransaction(); osC_Cache::clear('languages'); return true; } else { $osC_Database->rollbackTransaction(); } return false; }
if ($box['is_directory'] === true) { $entry = array('id' => $filter_id . '/' . $box['name'] . '/*', 'text' => $box['name'] . '/*'); } else { $page_filename = substr($box['name'], 0, strrpos($box['name'], '.')); $entry = array('id' => $filter_id . '/' . $page_filename, 'text' => $page_filename); } if ($_GET['filter'] != DEFAULT_TEMPLATE && $d_boxes->getSize() > 0) { $entry['group'] = '-- ' . $_GET['filter'] . ' --'; } $pages_array[] = $entry; } if ($_GET['filter'] != DEFAULT_TEMPLATE) { $d_boxes = new osC_DirectoryListing('../templates/' . DEFAULT_TEMPLATE . '/content'); $d_boxes->setRecursive(true); $d_boxes->setAddDirectoryToFilename(true); $d_boxes->setCheckExtension('php'); $d_boxes->setExcludeEntries('.svn'); foreach ($d_boxes->getFiles(false) as $box) { if ($box['is_directory'] === true) { $entry = array('id' => $filter_id . '/' . $box['name'] . '/*', 'text' => $box['name'] . '/*'); } else { $page_filename = substr($box['name'], 0, strrpos($box['name'], '.')); $entry = array('id' => $filter_id . '/' . $page_filename, 'text' => $page_filename); } $check_entry = $entry; $check_entry['group'] = '-- ' . $_GET['filter'] . ' --'; if (!in_array($check_entry, $pages_array)) { $entry['group'] = '-- ' . DEFAULT_TEMPLATE . ' --'; $pages_array[] = $entry; } }
function getLocalImages() { global $toC_Json; $osC_DirectoryListing = new osC_DirectoryListing('../images/products/_upload', true); $osC_DirectoryListing->setCheckExtension('gif'); $osC_DirectoryListing->setCheckExtension('jpg'); $osC_DirectoryListing->setCheckExtension('png'); $osC_DirectoryListing->setIncludeDirectories(false); $records = array(); foreach ($osC_DirectoryListing->getFiles() as $file) { $records[] = array('id' => $file['name'], 'text' => $file['name']); } $response = array(EXT_JSON_READER_TOTAL => sizeof($records), EXT_JSON_READER_ROOT => $records); echo $toC_Json->encode($response); }
/* $Id: $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2007 osCommerce 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. */ $modules_array = array(); $osC_DirectoryListing = new osC_DirectoryListing('../includes/modules/variants'); $osC_DirectoryListing->setIncludeDirectories(false); $osC_DirectoryListing->setCheckExtension('php'); foreach ($osC_DirectoryListing->getFiles() as $file) { $module = substr($file['name'], 0, strrpos($file['name'], '.')); $modules_array[] = array('id' => $module, 'text' => $module); } $osC_ObjectInfo = new osC_ObjectInfo(osC_ProductVariants_Admin::getData($_GET['paID'])); ?> <h1><?php echo osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule()), $osC_Template->getPageTitle()); ?> </h1> <?php if ($osC_MessageStack->size($osC_Template->getModule()) > 0) { echo $osC_MessageStack->get($osC_Template->getModule());
/* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2007 osCommerce 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. */ $osC_DirectoryListing = new osC_DirectoryListing(DIR_FS_WORK); $osC_DirectoryListing->setIncludeDirectories(false); $osC_DirectoryListing->setCheckExtension('cache'); $cached_files = array(); foreach ($osC_DirectoryListing->getFiles() as $file) { $last_modified = filemtime(DIR_FS_WORK . '/' . $file['name']); if (strpos($file['name'], '-') !== false) { $code = substr($file['name'], 0, strpos($file['name'], '-')); } else { $code = substr($file['name'], 0, strpos($file['name'], '.')); } if (isset($cached_files[$code])) { $cached_files[$code]['total']++; if ($last_modified > $cached_files[$code]['last_modified']) { $cached_files[$code]['last_modified'] = $last_modified; } } else { $cached_files[$code] = array('total' => 1, 'last_modified' => $last_modified);
function getPages() { global $toC_Json, $osC_Database, $osC_Language; $Qtemplate = $osC_Database->query('select code from :table_templates where id = :id'); $Qtemplate->bindTable(':table_templates', TABLE_TEMPLATES); $Qtemplate->bindValue(':id', $_REQUEST['filter']); $Qtemplate->execute(); $filter_id = $_REQUEST['filter']; $_REQUEST['filter'] = $Qtemplate->Value('code'); $pages_array = array(array('id' => $filter_id . '/*', 'text' => '*')); $d_boxes = new osC_DirectoryListing('../templates/' . $_REQUEST['filter'] . '/content'); $d_boxes->setRecursive(true); $d_boxes->setAddDirectoryToFilename(true); $d_boxes->setCheckExtension('php'); $d_boxes->setExcludeEntries('.svn'); foreach ($d_boxes->getFiles(false) as $box) { if ($box['is_directory'] === true) { $entry = array('id' => $filter_id . '/' . $box['name'] . '/*', 'text' => $box['name'] . '/*'); } else { $page_filename = substr($box['name'], 0, strrpos($box['name'], '.')); $entry = array('id' => $filter_id . '/' . $page_filename, 'text' => $page_filename); } if ($_REQUEST['filter'] != DEFAULT_TEMPLATE && $d_boxes->getSize() > 0) { $entry['group'] = '-- ' . $_REQUEST['filter'] . ' --'; } $pages_array[] = $entry; } if ($_REQUEST['filter'] != DEFAULT_TEMPLATE) { $d_boxes = new osC_DirectoryListing('../templates/' . DEFAULT_TEMPLATE . '/content'); $d_boxes->setRecursive(true); $d_boxes->setAddDirectoryToFilename(true); $d_boxes->setCheckExtension('php'); $d_boxes->setExcludeEntries('.svn'); foreach ($d_boxes->getFiles(false) as $box) { if ($box['is_directory'] === true) { $entry = array('id' => $filter_id . '/' . $box['name'] . '/*', 'text' => $box['name'] . '/*'); } else { $page_filename = substr($box['name'], 0, strrpos($box['name'], '.')); $entry = array('id' => $filter_id . '/' . $page_filename, 'text' => $page_filename); } $check_entry = $entry; $check_entry['group'] = '-- ' . $_REQUEST['filter'] . ' --'; if (!in_array($check_entry, $pages_array)) { $entry['group'] = '-- ' . DEFAULT_TEMPLATE . ' --'; $pages_array[] = $entry; } } } $response = array(EXT_JSON_READER_ROOT => $pages_array); echo $toC_Json->encode($response); }
public static function import($file, $type) { global $osC_Database; if (file_exists('../includes/languages/' . $file . '.xml')) { $osC_XML = new osC_XML(file_get_contents('../includes/languages/' . $file . '.xml')); $source = $osC_XML->toArray(); $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 (osC_Currencies_Admin::exists($language['currency']) === false) { $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; $osC_Database->startTransaction(); $language_id = self::get($language['code'], 'languages_id'); if ($language_id !== false) { $add_category_and_product_placeholders = false; $Qlanguage = $osC_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 = $osC_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->bindTable(':table_languages', TABLE_LANGUAGES); $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', osC_Currencies_Admin::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($_SESSION['module'], $language_id !== false ? $language_id : null); $Qlanguage->execute(); if ($osC_Database->isError()) { $error = true; } else { if ($language_id === false) { $language_id = $osC_Database->nextID(); } $default_language_id = osC_Languages_Admin::get(DEFAULT_LANGUAGE, 'languages_id'); if ($type == 'replace') { $Qdel = $osC_Database->query('delete from :table_languages_definitions where languages_id = :languages_id'); $Qdel->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS); $Qdel->bindInt(':languages_id', $language_id); $Qdel->execute(); if ($osC_Database->isError()) { $error = true; } } } if ($error === false) { $osC_DirectoryListing = new osC_DirectoryListing('../includes/languages/' . $file); $osC_DirectoryListing->setRecursive(true); $osC_DirectoryListing->setIncludeDirectories(false); $osC_DirectoryListing->setAddDirectoryToFilename(true); $osC_DirectoryListing->setCheckExtension('xml'); foreach ($osC_DirectoryListing->getFiles() as $files) { $definitions = array_merge($definitions, osC_Language_Admin::extractDefinitions($file . '/' . $files['name'])); } foreach ($definitions as $def) { $insert = false; $update = false; if ($type == 'replace') { $insert = true; } else { $Qcheck = $osC_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->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS); $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 = $osC_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 = $osC_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->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS); $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 ($osC_Database->isError()) { $error = true; break; } } } } if ($add_category_and_product_placeholders === true) { if ($error === false) { $Qcategories = $osC_Database->query('select categories_id, categories_name from :table_categories_description where language_id = :language_id'); $Qcategories->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); $Qcategories->bindInt(':language_id', $default_language_id); $Qcategories->execute(); while ($Qcategories->next()) { $Qinsert = $osC_Database->query('insert into :table_categories_description (categories_id, language_id, categories_name) values (:categories_id, :language_id, :categories_name)'); $Qinsert->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION); $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 ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qproducts = $osC_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->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); $Qproducts->bindInt(':language_id', $default_language_id); $Qproducts->execute(); while ($Qproducts->next()) { $Qinsert = $osC_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->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION); $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 ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qattributes = $osC_Database->query('select products_id, value from :table_product_attributes where languages_id = :languages_id'); $Qattributes->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES); $Qattributes->bindInt(':languages_id', $default_language_id); $Qattributes->execute(); while ($Qattributes->next()) { $Qinsert = $osC_Database->query('insert into :table_product_attributes (products_id, languages_id, value) values (:products_id, :languages_id, :value)'); $Qinsert->bindTable(':table_product_attributes', TABLE_PRODUCT_ATTRIBUTES); $Qinsert->bindInt(':products_id', $Qattributes->valueInt('products_id')); $Qinsert->bindInt(':languages_id', $language_id); $Qinsert->bindValue(':value', $Qattributes->value('value')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qgroups = $osC_Database->query('select id, title, sort_order, module from :table_products_variants_groups where languages_id = :languages_id'); $Qgroups->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS); $Qgroups->bindInt(':languages_id', $default_language_id); $Qgroups->execute(); while ($Qgroups->next()) { $Qinsert = $osC_Database->query('insert into :table_products_variants_groups (id, languages_id, title, sort_order, module) values (:id, :languages_id, :title, :sort_order, :module)'); $Qinsert->bindTable(':table_products_variants_groups', TABLE_PRODUCTS_VARIANTS_GROUPS); $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 ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qvalues = $osC_Database->query('select id, products_variants_groups_id, title, sort_order from :table_products_variants_values where languages_id = :languages_id'); $Qvalues->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES); $Qvalues->bindInt(':languages_id', $default_language_id); $Qvalues->execute(); while ($Qvalues->next()) { $Qinsert = $osC_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->bindTable(':table_products_variants_values', TABLE_PRODUCTS_VARIANTS_VALUES); $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 ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qmanufacturers = $osC_Database->query('select manufacturers_id, manufacturers_url from :table_manufacturers_info where languages_id = :languages_id'); $Qmanufacturers->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO); $Qmanufacturers->bindInt(':languages_id', $default_language_id); $Qmanufacturers->execute(); while ($Qmanufacturers->next()) { $Qinsert = $osC_Database->query('insert into :table_manufacturers_info (manufacturers_id, languages_id, manufacturers_url) values (:manufacturers_id, :languages_id, :manufacturers_url)'); $Qinsert->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO); $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 ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qstatus = $osC_Database->query('select orders_status_id, orders_status_name from :table_orders_status where language_id = :language_id'); $Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS); $Qstatus->bindInt(':language_id', $default_language_id); $Qstatus->execute(); while ($Qstatus->next()) { $Qinsert = $osC_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->bindTable(':table_orders_status', TABLE_ORDERS_STATUS); $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 ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qstatus = $osC_Database->query('select id, status_name from :table_orders_transactions_status where language_id = :language_id'); $Qstatus->bindTable(':table_orders_transactions_status', TABLE_ORDERS_TRANSACTIONS_STATUS); $Qstatus->bindInt(':language_id', $default_language_id); $Qstatus->execute(); while ($Qstatus->next()) { $Qinsert = $osC_Database->query('insert into :table_orders_transactions_status (id, language_id, status_name) values (:id, :language_id, :status_name)'); $Qinsert->bindTable(':table_orders_transactions_status', TABLE_ORDERS_TRANSACTIONS_STATUS); $Qinsert->bindInt(':id', $Qstatus->valueInt('id')); $Qinsert->bindInt(':language_id', $language_id); $Qinsert->bindValue(':status_name', $Qstatus->value('status_name')); $Qinsert->execute(); if ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qstatus = $osC_Database->query('select id, title, css_key from :table_shipping_availability where languages_id = :languages_id'); $Qstatus->bindTable(':table_shipping_availability', TABLE_SHIPPING_AVAILABILITY); $Qstatus->bindInt(':languages_id', $default_language_id); $Qstatus->execute(); while ($Qstatus->next()) { $Qinsert = $osC_Database->query('insert into :table_shipping_availability (id, languages_id, title, css_key) values (:id, :languages_id, :title, :css_key)'); $Qinsert->bindTable(':table_shipping_availability', TABLE_SHIPPING_AVAILABILITY); $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 ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qstatus = $osC_Database->query('select weight_class_id, weight_class_key, weight_class_title from :table_weight_classes where language_id = :language_id'); $Qstatus->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS); $Qstatus->bindInt(':language_id', $default_language_id); $Qstatus->execute(); while ($Qstatus->next()) { $Qinsert = $osC_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->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS); $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 ($osC_Database->isError()) { $error = true; break; } } } if ($error === false) { $Qgroup = $osC_Database->query('select id, title, code, size_width, size_height, force_size from :table_products_images_groups where language_id = :language_id'); $Qgroup->bindTable(':table_products_images_groups', TABLE_PRODUCTS_IMAGES_GROUPS); $Qgroup->bindInt(':language_id', $default_language_id); $Qgroup->execute(); while ($Qgroup->next()) { $Qinsert = $osC_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->bindTable(':table_products_images_groups', TABLE_PRODUCTS_IMAGES_GROUPS); $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 ($osC_Database->isError()) { $error = true; break; } } } } } if ($error === false) { $osC_Database->commitTransaction(); osC_Cache::clear('languages'); return true; } else { $osC_Database->rollbackTransaction(); } return false; }
/* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2007 osCommerce 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. */ $osC_DirectoryListing = new osC_DirectoryListing(DIR_FS_BACKUP); $osC_DirectoryListing->setIncludeDirectories(false); $osC_DirectoryListing->setCheckExtension('zip'); $osC_DirectoryListing->setCheckExtension('sql'); $osC_DirectoryListing->setCheckExtension('gz'); ?> <h1><?php echo osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule()), $osC_Template->getPageTitle()); ?> </h1> <?php if ($osC_MessageStack->size($osC_Template->getModule()) > 0) { echo $osC_MessageStack->get($osC_Template->getModule()); } ?>