function getAccesses()
 {
     global $toC_Json, $osC_Language;
     $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/access');
     $osC_DirectoryListing->setIncludeDirectories(false);
     $access_modules_array = array();
     foreach ($osC_DirectoryListing->getFiles() as $file) {
         $module = substr($file['name'], 0, strrpos($file['name'], '.'));
         if (!class_exists('osC_Access_' . ucfirst($module))) {
             $osC_Language->loadIniFile('modules/access/' . $file['name']);
             include $osC_DirectoryListing->getDirectory() . '/' . $file['name'];
         }
         $module = 'osC_Access_' . ucfirst($module);
         $module = new $module();
         $title = osC_Access::getGroupTitle($module->getGroup());
         $access_modules_array[$title][] = array('id' => $module->getModule(), 'text' => $module->getTitle(), 'leaf' => true);
     }
     ksort($access_modules_array);
     $access_options = array();
     $count = 1;
     foreach ($access_modules_array as $group => $modules) {
         $access_option['id'] = $count;
         $access_option['text'] = $group;
         $mod_arrs = array();
         foreach ($modules as $module) {
             $mod_arrs[] = $module;
         }
         $access_option['children'] = $mod_arrs;
         $access_options[] = $access_option;
         $count++;
     }
     echo $toC_Json->encode($access_options);
 }
Exemple #2
0
 function listGeoipModules()
 {
     global $toC_Json, $osC_Language;
     $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/geoip');
     $osC_DirectoryListing->setIncludeDirectories(false);
     $files = $osC_DirectoryListing->getFiles();
     $modules = array();
     foreach ($files as $file) {
         include 'includes/modules/geoip/' . $file['name'];
         $class = substr($file['name'], 0, strrpos($file['name'], '.'));
         if (class_exists('osC_GeoIP_' . $class)) {
             $osC_Language->loadIniFile('modules/geoip/' . $class . '.php');
             $module = 'osC_GeoIP_' . $class;
             $module = new $module();
             $action = array();
             if ($module->isInstalled()) {
                 $action[] = array('class' => 'icon-uninstall-record', 'qtip' => $osC_Language->get('icon_uninstall'));
             } else {
                 $action[] = array('class' => 'icon-install-record', 'qtip' => $osC_Language->get('icon_install'));
             }
             $modules[] = array('code' => $class, 'title' => $module->getTitle(), 'description' => $module->getDescription(), 'author' => $module->getAuthorName(), 'action' => $action);
         }
     }
     $response[EXT_JSON_READER_ROOT] = $modules;
     echo $toC_Json->encode($response);
 }
 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);
 }
Exemple #4
0
 function listTemplates()
 {
     global $toC_Json, $osC_Language;
     $osC_DirectoryListing = new osC_DirectoryListing('../templates');
     $osC_DirectoryListing->setIncludeDirectories(true);
     $osC_DirectoryListing->setIncludeFiles(false);
     $osC_DirectoryListing->setExcludeEntries('system');
     $files = $osC_DirectoryListing->getFiles(true);
     foreach ($files as $file) {
         include '../templates/' . $file['name'] . '/template.php';
         $code = $file['name'];
         $class = 'osC_Template_' . $code;
         if (class_exists($class)) {
             $module = new $class();
             $module_title = $module->getTitle();
             $action = array();
             if ($module->isInstalled()) {
                 if ($module->getCode() == DEFAULT_TEMPLATE) {
                     $module_title .= ' (' . $osC_Language->get('default_entry') . ')';
                     $action[] = array('class' => 'icon-default-record', 'qtip' => $osC_Language->get('field_set_as_default'));
                 } else {
                     $action[] = array('class' => 'icon-default-gray-record', 'qtip' => $osC_Language->get('field_set_as_default'));
                 }
                 $action[] = array('class' => 'icon-uninstall-record', 'qtip' => $osC_Language->get('icon_uninstall'));
             } else {
                 $action[] = array('class' => 'icon-empty-record', 'qtip' => $osC_Language->get('field_set_as_default'));
                 $action[] = array('class' => 'icon-install-record', 'qtip' => $osC_Language->get('icon_install'));
             }
             $modules[] = array('code' => $module->getCode(), 'title' => $module_title, 'author' => $module->getAuthorName(), 'url' => $module->getAuthorAddress(), 'action' => $action);
         }
     }
     $response = array(EXT_JSON_READER_ROOT => $modules);
     echo $toC_Json->encode($response);
 }
 function getGadgets()
 {
     global $toC_Json, $osC_Language;
     $record = array();
     $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/gadgets');
     if ($osC_DirectoryListing->getSize()) {
         foreach ($osC_DirectoryListing->getFiles() as $file) {
             $gadget = substr($file['name'], 0, strrpos($file['name'], '.'));
             $class_path = 'includes/modules/gadgets/' . $gadget . '.php';
             if (!empty($gadget) && file_exists($class_path)) {
                 include $class_path;
                 $osC_Language->loadIniFile('modules/gadgets/' . $gadget . '.php');
                 if (class_exists('toC_Gadget_' . $gadget)) {
                     $module_class = 'toC_Gadget_' . $gadget;
                     $module = new $module_class();
                     $records[] = array('code' => $module->getCode(), 'type' => $module->getType(), 'icon' => $module->getIcon(), 'title' => $module->getTitle(), 'file' => $module->getFile(), 'description' => $module->getDescription());
                 }
             }
         }
         $response = array('success' => true, 'records' => $records);
     } else {
         $response = array('success' => false);
     }
     echo $toC_Json->encode($response);
 }
 function listServices()
 {
     global $toC_Json, $osC_Language;
     $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/services');
     $osC_DirectoryListing->setIncludeDirectories(false);
     $files = $osC_DirectoryListing->getFiles();
     $installed = explode(';', MODULE_SERVICES_INSTALLED);
     $modules = array();
     foreach ($files as $file) {
         include 'includes/modules/services/' . $file['name'];
         $class = substr($file['name'], 0, strrpos($file['name'], '.'));
         $module = 'osC_Services_' . $class . '_Admin';
         $module = new $module();
         $action = array();
         if (in_array($class, $installed) && !osc_empty($module->keys())) {
             $action[] = array('class' => 'icon-edit-record', 'qtip' => $osC_Language->get('icon_edit'));
         } else {
             $action[] = array('class' => 'icon-edit-gray-record', 'qtip' => $osC_Language->get('icon_edit'));
         }
         if (!in_array($class, $installed)) {
             $action[] = array('class' => 'icon-install-record', 'qtip' => $osC_Language->get('icon_install'));
         } else {
             if ($module->uninstallable == false) {
                 $action[] = array('class' => 'icon-uninstall-gray-record', 'qtip' => $osC_Language->get('icon_uninstall'));
             } else {
                 $action[] = array('class' => 'icon-uninstall-record', 'qtip' => $osC_Language->get('icon_uninstall'));
             }
         }
         $modules[] = array('code' => $class, 'title' => $module->title, 'action' => $action);
     }
     $response[EXT_JSON_READER_ROOT] = $modules;
     echo $toC_Json->encode($response);
 }
 function listTemplatesModules()
 {
     global $toC_Json, $osC_Language;
     $osC_Language->load('modules-' . $_REQUEST['set']);
     $osC_DirectoryListing = new osC_DirectoryListing('../includes/modules/' . $_REQUEST['set']);
     $osC_DirectoryListing->setIncludeDirectories(false);
     $files = $osC_DirectoryListing->getFiles();
     $modules = array();
     foreach ($files as $file) {
         include '../includes/modules/' . $_REQUEST['set'] . '/' . $file['name'];
         $code = substr($file['name'], 0, strrpos($file['name'], '.'));
         $class = 'osC_' . ucfirst($_REQUEST['set']) . '_' . $code;
         if (class_exists($class)) {
             if (call_user_func(array($class, 'isInstalled'), $code, $_GET['set']) === false) {
                 $osC_Language->injectDefinitions('modules/' . $_GET['set'] . '/' . $code . '.xml');
             }
             $module = new $class();
             $action = array();
             if ($module->isInstalled() && $module->isActive()) {
                 if ($module->hasKeys()) {
                     $action[] = array('class' => 'icon-edit-record', 'qtip' => $osC_Language->get('icon_edit'));
                 } else {
                     $action[] = array('class' => 'icon-edit-gray-record', 'qtip' => $osC_Language->get('icon_edit'));
                 }
                 $action[] = array('class' => 'icon-uninstall-record', 'qtip' => $osC_Language->get('icon_uninstall'));
             } else {
                 $action[] = array('class' => 'icon-edit-gray-record', 'qtip' => $osC_Language->get('icon_edit'));
                 $action[] = array('class' => 'icon-install-record', 'qtip' => $osC_Language->get('icon_install'));
             }
             $modules[] = array('code' => $code, 'title' => $module->getTitle(), 'author' => $module->getAuthorName(), 'url' => $module->getAuthorAddress(), 'action' => $action);
         }
     }
     $response[EXT_JSON_READER_ROOT] = $modules;
     echo $toC_Json->encode($response);
 }
Exemple #8
0
 function listDirectory()
 {
     global $osC_Language, $toC_Json, $osC_MessageStack;
     $directory = OSC_ADMIN_FILE_MANAGER_ROOT_PATH;
     if (isset($_REQUEST['directory']) && !empty($_REQUEST['directory'])) {
         $directory .= '/' . urldecode($_REQUEST['directory']);
     } elseif (isset($_REQUEST['goto']) && !empty($_REQUEST['goto'])) {
         $directory .= '/' . urldecode($_REQUEST['goto']);
     }
     $osC_DirectoryListing = new osC_DirectoryListing($directory);
     $osC_DirectoryListing->setStats(true);
     $records = array();
     foreach ($osC_DirectoryListing->getFiles() as $file) {
         $file_owner = function_exists('posix_getpwuid') ? posix_getpwuid($file['user_id']) : '-?-';
         $group_owner = function_exists('posix_getgrgid') ? posix_getgrgid($file['group_id']) : '-?-';
         if ($file['is_directory'] === true) {
             $entry_icon = osc_icon('folder_red.png');
             $action = array(array('class' => 'icon-empty-record', 'qtip' => ''), array('class' => 'icon-empty-record', 'qtip' => ''), array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash')));
         } else {
             $entry_icon = osc_icon('file.png');
             $action = array(array('class' => 'icon-edit-record', 'qtip' => $osC_Language->get('icon_edit')), array('class' => 'icon-download-record', 'qtip' => $osC_Language->get('icon_download')), array('class' => 'icon-delete-record', 'qtip' => $osC_Language->get('icon_trash')));
         }
         $records[] = array('icon' => $entry_icon, 'file_name' => $file['name'], 'is_directory' => $file['is_directory'], 'size' => number_format($file['size']), 'permission' => osc_get_file_permissions($file['permissions']), 'file_owner' => $file_owner, 'group_owner' => $group_owner, 'writeable' => osc_icon(is_writable($osC_DirectoryListing->getDirectory() . '/' . $file['name']) ? 'checkbox_ticked.gif' : 'checkbox_crossed.gif'), 'last_modified_date' => osC_DateTime::getShort(osC_DateTime::fromUnixTimestamp($file['last_modified']), true), 'action' => $action);
     }
     $response = array(EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
 function listShippingModules()
 {
     global $toC_Json, $osC_Language;
     $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/shipping');
     $osC_DirectoryListing->setIncludeDirectories(false);
     $files = $osC_DirectoryListing->getFiles();
     $modules = array();
     foreach ($files as $file) {
         include 'includes/modules/shipping/' . $file['name'];
         $class = substr($file['name'], 0, strrpos($file['name'], '.'));
         if (class_exists('osC_Shipping_' . $class)) {
             $osC_Language->injectDefinitions('modules/shipping/' . $class . '.xml');
             $module = 'osC_Shipping_' . $class;
             $module = new $module();
             $action = array();
             if ($module->isInstalled()) {
                 $action[] = array('class' => 'icon-edit-record', 'qtip' => $osC_Language->get('icon_edit'));
                 $action[] = array('class' => 'icon-uninstall-record', 'qtip' => $osC_Language->get('icon_uninstall'));
             } else {
                 $action[] = array('class' => 'icon-edit-gray-record', 'qtip' => $osC_Language->get('icon_edit'));
                 $action[] = array('class' => 'icon-install-record', 'qtip' => $osC_Language->get('icon_install'));
             }
             $modules[] = array('code' => $module->getCode(), 'title' => $module->getTitle(), 'sort_order' => $module->getSortOrder(), 'action' => $action);
         }
     }
     $response[EXT_JSON_READER_ROOT] = $modules;
     echo $toC_Json->encode($response);
 }
 function _getSocialBookmarks()
 {
     $osC_DirectoryListing = new osC_DirectoryListing(TOC_SOCIAL_BOOKMARKS_MODULES);
     $social_bookmarks = array();
     foreach ($osC_DirectoryListing->getFiles() as $social_bookmark) {
         $social_bookmark_class = substr($social_bookmark['name'], 0, strrpos($social_bookmark['name'], '.'));
         if (!class_exists($social_bookmark_class)) {
             include TOC_SOCIAL_BOOKMARKS_MODULES . '/' . $social_bookmark_class . '.php';
         }
         $social_bookmarks[] = new $social_bookmark_class();
     }
     return $social_bookmarks;
 }
Exemple #11
0
 function getOriginalLogo()
 {
     $osC_DirectoryListing = new osC_DirectoryListing('../' . DIR_WS_IMAGES);
     $osC_DirectoryListing->setIncludeDirectories(false);
     $files = $osC_DirectoryListing->getFiles();
     foreach ($files as $file) {
         $filename = explode(".", $file['name']);
         if ($filename[0] == 'logo_originals') {
             return '../' . DIR_WS_IMAGES . 'logo_originals.' . $filename[1];
         }
     }
     return false;
 }
Exemple #12
0
 function listBackup()
 {
     global $toC_Json;
     $osC_DirectoryListing = new osC_DirectoryListing(DIR_FS_BACKUP);
     $osC_DirectoryListing->setIncludeDirectories(false);
     $osC_DirectoryListing->setExcludeEntries('.htaccess');
     $response = array();
     foreach ($osC_DirectoryListing->getFiles() as $file) {
         $response[] = array('file' => $file['name'], 'date' => osC_DateTime::getDate(osC_DateTime::fromUnixTimestamp(filemtime(DIR_FS_BACKUP . $file['name'])), true), 'size' => number_format(filesize(DIR_FS_BACKUP . $file['name'])));
     }
     $response = array(EXT_JSON_READER_ROOT => $response);
     echo $toC_Json->encode($response);
 }
Exemple #13
0
 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 getModules()
 {
     global $toC_Json, $osC_Language;
     $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/newsletters');
     $osC_DirectoryListing->setIncludeDirectories(false);
     $records = array();
     foreach ($osC_DirectoryListing->getFiles() as $file) {
         $module = substr($file['name'], 0, strrpos($file['name'], '.'));
         $osC_Language->loadIniFile('modules/newsletters/' . $file['name']);
         include 'includes/modules/newsletters/' . $file['name'];
         $newsletter_module_class = 'osC_Newsletter_' . $module;
         $osC_NewsletterModule = new $newsletter_module_class();
         $records[] = array('id' => $module, 'text' => $osC_NewsletterModule->getTitle());
     }
     $response = array(EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
 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);
 }
Exemple #16
0
 function getGadgets()
 {
     global $osC_Language;
     $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/gadgets');
     $osC_DirectoryListing->setIncludeDirectories(false);
     $gadgets = array();
     foreach ($osC_DirectoryListing->getFiles() as $file) {
         require_once 'includes/modules/gadgets/' . $file['name'];
         $class = substr($file['name'], 0, strrpos($file['name'], '.'));
         $osC_Language->loadIniFile('modules/gadgets/' . $file['name']);
         if (class_exists('toC_Gadget_' . $class)) {
             $module_class = 'toC_Gadget_' . $class;
             $module = new $module_class();
             $gadgets[] = array('code' => $module->getCode(), 'title' => $module->getTitle());
         }
     }
     return $gadgets;
 }
Exemple #17
0
 /**
  * Return the Administration Tool Application modules the administrator has access to
  *
  * @param int $id The ID of the administrator
  * @access public
  * @return array
  */
 public static function getUserLevels($id)
 {
     global $osC_Database;
     $modules = array();
     $Qaccess = $osC_Database->query('select module from :table_administrators_access where administrators_id = :administrators_id');
     $Qaccess->bindTable(':table_administrators_access', TABLE_ADMINISTRATORS_ACCESS);
     $Qaccess->bindInt(':administrators_id', $id);
     $Qaccess->execute();
     while ($Qaccess->next()) {
         $modules[] = $Qaccess->value('module');
     }
     if (in_array('*', $modules)) {
         $modules = array();
         $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/access');
         $osC_DirectoryListing->setIncludeDirectories(false);
         foreach ($osC_DirectoryListing->getFiles() as $file) {
             $modules[] = substr($file['name'], 0, strrpos($file['name'], '.'));
         }
     }
     return $modules;
 }
Exemple #18
0
 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 _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;
 }
Exemple #20
0
 function deleteAccount($account)
 {
     global $osC_Database;
     $error = false;
     $osC_Database->startTransaction();
     $messages_path = DIR_FS_CACHE_ADMIN . 'emails/' . md5($account['accounts_id'] . $account['accounts_email']) . '/messages';
     if (file_exists($messages_path)) {
         $directory = new osC_DirectoryListing($messages_path);
         foreach ($directory->getFiles() as $file) {
             @unlink($messages_path . '/' . $file['name']);
         }
         rmdir($messages_path);
     }
     $attachments_path = DIR_FS_CACHE_ADMIN . 'emails/' . md5($account['accounts_id'] . $account['accounts_email']) . '/attachments';
     if (file_exists($attachments_path)) {
         $directory = new osC_DirectoryListing($attachments_path);
         foreach ($directory->getFiles() as $file) {
             @unlink($attachments_path . '/' . $file['name']);
         }
         rmdir($attachments_path);
     }
     $account_path = DIR_FS_CACHE_ADMIN . 'emails/' . md5($account['accounts_id'] . $account['accounts_email']);
     if (file_exists($account_path)) {
         rmdir($account_path);
     }
     $Qmessages = $osC_Database->query('delete from :table_email_messages where accounts_id = :accounts_id');
     $Qmessages->bindTable(':table_email_messages', TABLE_EMAIL_MESSAGES);
     $Qmessages->bindInt(':accounts_id', $account['accounts_id']);
     $Qmessages->setLogging($_SESSION['module'], $account['accounts_id']);
     $Qmessages->execute();
     if ($osC_Database->isError()) {
         $error = true;
     }
     if ($error == false) {
         $Qfolders = $osC_Database->query('delete from :table_email_folders where accounts_id = :accounts_id');
         $Qfolders->bindTable(':table_email_folders', TABLE_EMAIL_FOLDERS);
         $Qfolders->bindInt(':accounts_id', $account['accounts_id']);
         $Qfolders->setLogging($_SESSION['module'], $account['accounts_id']);
         $Qfolders->execute();
         if ($osC_Database->isError()) {
             $error = true;
         }
     }
     if ($error == false) {
         $Qaccount = $osC_Database->query('delete from :table_email_accounts where accounts_id = :accounts_id');
         $Qaccount->bindTable(':table_email_accounts', TABLE_EMAIL_ACCOUNTS);
         $Qaccount->bindInt(':accounts_id', $account['accounts_id']);
         $Qaccount->setLogging($_SESSION['module'], $account['accounts_id']);
         $Qaccount->execute();
         if ($osC_Database->isError()) {
             $error = true;
         }
     }
     if ($error === false) {
         $osC_Database->commitTransaction();
         return true;
     }
     $osC_Database->rollbackTransaction();
     return false;
 }
Exemple #21
0
<?php

/*
  $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('includes/modules/payment');
$osC_DirectoryListing->setIncludeDirectories(false);
$files = $osC_DirectoryListing->getFiles();
?>

<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());
}
?>

<table border="0" width="100%" cellspacing="0" cellpadding="2" class="dataTable">
 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;
 }
Exemple #23
0
  it under the terms of the GNU General Public License v2 (1991)
  as published by the Free Software Foundation.
*/
$goto_array = array(array('id' => '', 'text' => $osC_Language->get('top_level')));
if ($_SESSION['fm_directory'] != OSC_ADMIN_FILE_MANAGER_ROOT_PATH) {
    $path_array = explode('/', substr($_SESSION['fm_directory'], strlen(OSC_ADMIN_FILE_MANAGER_ROOT_PATH) + 1));
    foreach ($path_array as $value) {
        if (sizeof($goto_array) < 2) {
            $goto_array[] = array('id' => $value, 'text' => $value);
        } else {
            $parent = end($goto_array);
            $goto_array[] = array('id' => $parent['id'] . '/' . $value, 'text' => $parent['id'] . '/' . $value);
        }
    }
}
$osC_DirectoryListing = new osC_DirectoryListing($_SESSION['fm_directory']);
$osC_DirectoryListing->setStats(true);
?>

<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());
}
?>

<div style="float: right;">
Exemple #24
0
<?php

/*
  $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 
Exemple #25
0
 if ($osC_Database->isError() === false && $db['DB_INSERT_SAMPLE_DATA'] == 'true') {
     $sql_file = $dir_fs_www_root . '/tomatocart_sample_data.sql';
     $osC_Database->importSQL($sql_file, $db['DB_DATABASE'], $db['DB_TABLE_PREFIX']);
 }
 if ($osC_Database->isError() === false) {
     //english
     foreach ($osC_Language->extractDefinitions('fa_IR.xml') as $def) {
         $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)');
         $Qdef->bindTable(':table_languages_definitions', $db['DB_TABLE_PREFIX'] . 'languages_definitions');
         $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();
     }
     $osC_DirectoryListing = new osC_DirectoryListing('../includes/languages/fa_IR');
     $osC_DirectoryListing->setRecursive(true);
     $osC_DirectoryListing->setIncludeDirectories(false);
     $osC_DirectoryListing->setAddDirectoryToFilename(true);
     $osC_DirectoryListing->setCheckExtension('xml');
     foreach ($osC_DirectoryListing->getFiles() as $files) {
         foreach ($osC_Language->extractDefinitions('fa_IR/' . $files['name']) as $def) {
             $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)');
             $Qdef->bindTable(':table_languages_definitions', $db['DB_TABLE_PREFIX'] . 'languages_definitions');
             $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();
         }
     }
Exemple #26
0
 function save($id = null, $data)
 {
     global $osC_Database, $osC_Language, $osC_Image, $osC_Session;
     $error = false;
     $osC_Database->startTransaction();
     //products
     if (is_numeric($id)) {
         $Qproduct = $osC_Database->query('update :table_products set products_type = :products_type, products_sku = :products_sku, products_model = :products_model, products_price = :products_price, products_quantity = :products_quantity, products_moq = :products_moq, products_max_order_quantity = :products_max_order_quantity, order_increment = :order_increment, quantity_unit_class = :quantity_unit_class, products_date_available = :products_date_available, products_weight = :products_weight, products_weight_class = :products_weight_class, products_status = :products_status, products_tax_class_id = :products_tax_class_id, manufacturers_id = :manufacturers_id, quantity_discount_groups_id = :quantity_discount_groups_id, products_last_modified = now(), products_attributes_groups_id = :products_attributes_groups_id where products_id = :products_id');
         $Qproduct->bindInt(':products_id', $id);
     } else {
         $Qproduct = $osC_Database->query('insert into :table_products (products_type, products_sku, products_model, products_price, products_quantity, products_moq, products_max_order_quantity, order_increment, quantity_unit_class, products_date_available, products_weight, products_weight_class, products_status, products_tax_class_id, manufacturers_id, products_date_added, quantity_discount_groups_id, products_attributes_groups_id) values (:products_type, :products_sku, :products_model, :products_price, :products_quantity, :products_moq, :products_max_order_quantity, :order_increment, :quantity_unit_class, :products_date_available, :products_weight, :products_weight_class, :products_status, :products_tax_class_id, :manufacturers_id, :products_date_added, :quantity_discount_groups_id, :products_attributes_groups_id)');
         $Qproduct->bindRaw(':products_date_added', 'now()');
     }
     $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
     $Qproduct->bindInt(':products_type', $data['products_type']);
     $Qproduct->bindValue(':products_sku', $data['products_sku']);
     $Qproduct->bindValue(':products_model', $data['products_model']);
     $Qproduct->bindValue(':products_price', $data['price']);
     $Qproduct->bindInt(':products_quantity', $data['quantity']);
     $Qproduct->bindInt(':products_moq', $data['products_moq']);
     $Qproduct->bindInt(':products_max_order_quantity', $data['products_max_order_quantity']);
     $Qproduct->bindInt(':order_increment', $data['order_increment']);
     $Qproduct->bindInt(':quantity_unit_class', $data['quantity_unit_class']);
     if (date('Y-m-d') < $data['date_available']) {
         $Qproduct->bindValue(':products_date_available', $data['date_available']);
     } else {
         $Qproduct->bindRaw(':products_date_available', 'null');
     }
     $Qproduct->bindValue(':products_weight', $data['weight']);
     $Qproduct->bindInt(':products_weight_class', $data['weight_class']);
     $Qproduct->bindInt(':products_status', $data['status']);
     $Qproduct->bindInt(':products_tax_class_id', $data['tax_class_id']);
     $Qproduct->bindInt(':manufacturers_id', $data['manufacturers_id']);
     $Qproduct->bindInt(':quantity_discount_groups_id', $data['quantity_discount_groups_id']);
     if (empty($data['products_attributes_groups_id'])) {
         $Qproduct->bindRaw(':products_attributes_groups_id', 'null');
     } else {
         $Qproduct->bindInt(':products_attributes_groups_id', $data['products_attributes_groups_id']);
     }
     $Qproduct->setLogging($_SESSION['module'], $id);
     $Qproduct->execute();
     if ($osC_Database->isError()) {
         $error = true;
     } else {
         if (is_numeric($id)) {
             $products_id = $id;
         } else {
             $products_id = $osC_Database->nextID();
         }
         //products_to_categories
         $Qcategories = $osC_Database->query('delete from :table_products_to_categories where products_id = :products_id');
         $Qcategories->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
         $Qcategories->bindInt(':products_id', $products_id);
         $Qcategories->setLogging($_SESSION['module'], $products_id);
         $Qcategories->execute();
         if ($osC_Database->isError()) {
             $error = true;
         } else {
             if (isset($data['categories']) && !empty($data['categories'])) {
                 foreach ($data['categories'] as $category_id) {
                     $Qp2c = $osC_Database->query('insert into :table_products_to_categories (products_id, categories_id) values (:products_id, :categories_id)');
                     $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
                     $Qp2c->bindInt(':products_id', $products_id);
                     $Qp2c->bindInt(':categories_id', $category_id);
                     $Qp2c->setLogging($_SESSION['module'], $products_id);
                     $Qp2c->execute();
                     if ($osC_Database->isError()) {
                         $error = true;
                         break;
                     }
                 }
             }
         }
     }
     if ($error === false && is_numeric($id)) {
         $Qdelete = $osC_Database->query('delete from :table_products_attachments_to_products where products_id = :products_id');
         $Qdelete->bindTable(':table_products_attachments_to_products', TABLE_PRODUCTS_ATTACHMENTS_TO_PRODUCTS);
         $Qdelete->bindInt(':products_id', $products_id);
         $Qdelete->setLogging($_SESSION['module'], $products_id);
         $Qdelete->execute();
         if ($osC_Database->isError()) {
             $error = true;
         }
     }
     if ($error === false && sizeof($data['attachments']) > 0) {
         foreach ($data['attachments'] as $attachments_id) {
             $Qp2a = $osC_Database->query('insert into :table_products_attachments_to_products (products_id, attachments_id) values (:products_id, :attachments_id)');
             $Qp2a->bindTable(':table_products_attachments_to_products', TABLE_PRODUCTS_ATTACHMENTS_TO_PRODUCTS);
             $Qp2a->bindInt(':products_id', $products_id);
             $Qp2a->bindInt(':attachments_id', $attachments_id);
             $Qp2a->setLogging($_SESSION['module'], $products_id);
             $Qp2a->execute();
             if ($osC_Database->isError()) {
                 $error = true;
                 break;
             }
         }
     }
     //accessories
     if ($error === false) {
         if (is_numeric($id)) {
             $Qdelete = $osC_Database->query('delete from :table_products_accessories where products_id = :products_id');
             $Qdelete->bindTable(':table_products_accessories', TABLE_PRODUCTS_ACCESSORIES);
             $Qdelete->bindInt(':products_id', $products_id);
             $Qdelete->setLogging($_SESSION['module'], $products_id);
             $Qdelete->execute();
             if ($osC_Database->isError()) {
                 $error = true;
             }
         }
         if (sizeof($data['accessories_ids']) > 0) {
             foreach ($data['accessories_ids'] as $accessories_id) {
                 $Qinsert = $osC_Database->query('insert into :table_products_accessories (products_id, accessories_id) values (:products_id, :accessories_id)');
                 $Qinsert->bindTable(':table_products_accessories', TABLE_PRODUCTS_ACCESSORIES);
                 $Qinsert->bindInt(':products_id', $products_id);
                 $Qinsert->bindInt(':accessories_id', $accessories_id);
                 $Qinsert->setLogging($_SESSION['module'], $products_id);
                 $Qinsert->execute();
                 if ($osC_Database->isError()) {
                     $error = true;
                     break;
                 }
             }
         }
     }
     //downloadable products & gift certificates
     if ($data['products_type'] == PRODUCT_TYPE_DOWNLOADABLE) {
         if (is_numeric($id)) {
             $Qdownloadables = $osC_Database->query('update :table_products_downloadables set number_of_downloads = :number_of_downloads, number_of_accessible_days = :number_of_accessible_days where products_id = :products_id');
         } else {
             $Qdownloadables = $osC_Database->query('insert into :table_products_downloadables (products_id, number_of_downloads, number_of_accessible_days) values (:products_id, :number_of_downloads, :number_of_accessible_days)');
         }
         $Qdownloadables->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES);
         $Qdownloadables->bindInt(':products_id', $products_id);
         $Qdownloadables->bindInt(':number_of_downloads', $data['number_of_downloads']);
         $Qdownloadables->bindInt(':number_of_accessible_days', $data['number_of_accessible_days']);
         $Qdownloadables->setLogging($_SESSION['module'], $products_id);
         $Qdownloadables->execute();
         if ($osC_Database->isError()) {
             $error = true;
         } else {
             $filename = null;
             $cache_filename = null;
             $file = new upload('downloadable_file');
             if ($file->exists()) {
                 $file->set_destination(realpath('../download'));
                 if ($file->parse() && $file->save()) {
                     $filename = $file->filename;
                     $cache_filename = md5($filename . time());
                     rename(DIR_FS_DOWNLOAD . $filename, DIR_FS_DOWNLOAD . $cache_filename);
                 }
             }
             if (!is_null($filename)) {
                 if (is_numeric($id)) {
                     $Qfile = $osC_Database->query('select cache_filename from :table_products_downloadables where products_id = :products_id');
                     $Qfile->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES);
                     $Qfile->bindInt(':products_id', $products_id);
                     $Qfile->execute();
                     if ($Qfile->numberOfRows() > 0) {
                         $file = $Qfile->value('cache_filename');
                         unlink(DIR_FS_DOWNLOAD . $file);
                     }
                 }
                 $Qupdate = $osC_Database->query('update :table_products_downloadables set filename = :filename, cache_filename = :cache_filename where products_id = :products_id');
                 $Qupdate->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES);
                 $Qupdate->bindInt(':products_id', $products_id);
                 $Qupdate->bindValue(':filename', $filename);
                 $Qupdate->bindValue(':cache_filename', $cache_filename);
                 $Qupdate->setLogging($_SESSION['module'], $products_id);
                 $Qupdate->execute();
                 if ($osC_Database->isError()) {
                     $error = true;
                 }
             }
             if ($error === false) {
                 $sample_filename = null;
                 $cache_sample_filename = null;
                 $sample_file = new upload('sample_downloadable_file');
                 if ($sample_file->exists()) {
                     $sample_file->set_destination(realpath('../download'));
                     if ($sample_file->parse() && $sample_file->save()) {
                         $sample_filename = $sample_file->filename;
                         $cache_sample_filename = md5($sample_filename . time());
                         @rename(DIR_FS_DOWNLOAD . $sample_filename, DIR_FS_DOWNLOAD . $cache_sample_filename);
                     }
                 }
                 if (!is_null($sample_filename) && $error === false) {
                     if (is_numeric($id)) {
                         $Qfile = $osC_Database->query('select cache_sample_filename from :table_products_downloadables where products_id = :products_id');
                         $Qfile->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES);
                         $Qfile->bindInt(':products_id', $products_id);
                         $Qfile->execute();
                         if ($Qfile->numberOfRows() > 0) {
                             $file = $Qfile->value('cache_sample_filename');
                             unlink(DIR_FS_DOWNLOAD . $file);
                         }
                     }
                     $Qfiles = $osC_Database->query('update :table_products_downloadables set sample_filename = :sample_filename, cache_sample_filename = :cache_sample_filename where products_id = :products_id');
                     $Qfiles->bindTable(':table_products_downloadables', TABLE_PRODUCTS_DOWNLOADABLES);
                     $Qfiles->bindInt(':products_id', $products_id);
                     $Qfiles->bindValue(':sample_filename', $sample_filename);
                     $Qfiles->bindValue(':cache_sample_filename', $cache_sample_filename);
                     $Qfiles->setLogging($_SESSION['module'], $products_id);
                     $Qfiles->execute();
                     if ($osC_Database->isError()) {
                         $error = true;
                     }
                 }
             }
         }
     } else {
         if ($data['products_type'] == PRODUCT_TYPE_GIFT_CERTIFICATE) {
             if (is_numeric($id)) {
                 $Qcertificates = $osC_Database->query('update :table_products_gift_certificates set gift_certificates_type = :gift_certificates_type, gift_certificates_amount_type = :gift_certificates_amount_type, open_amount_max_value = :open_amount_max_value, open_amount_min_value = :open_amount_min_value where products_id = :products_id');
             } else {
                 $Qcertificates = $osC_Database->query('insert into :table_products_gift_certificates (products_id, gift_certificates_type, gift_certificates_amount_type, open_amount_max_value, open_amount_min_value) values (:products_id, :gift_certificates_type, :gift_certificates_amount_type, :open_amount_max_value, :open_amount_min_value)');
             }
             $Qcertificates->bindTable(':table_products_gift_certificates', TABLE_PRODUCTS_GIFT_CERTIFICATES);
             $Qcertificates->bindInt(':products_id', $products_id);
             $Qcertificates->bindInt(':gift_certificates_type', $data['gift_certificates_type']);
             $Qcertificates->bindInt(':gift_certificates_amount_type', $data['gift_certificates_amount_type']);
             $Qcertificates->bindValue(':open_amount_max_value', $data['open_amount_max_value']);
             $Qcertificates->bindValue(':open_amount_min_value', $data['open_amount_min_value']);
             $Qcertificates->setLogging($_SESSION['module'], $products_id);
             $Qcertificates->execute();
             if ($osC_Database->isError()) {
                 $error = true;
             }
         }
     }
     //products_description
     if ($error === false) {
         foreach ($osC_Language->getAll() as $l) {
             if (is_numeric($id)) {
                 $Qpd = $osC_Database->query('update :table_products_description set products_name = :products_name, products_short_description = :products_short_description, products_description = :products_description, products_tags = :products_tags, products_url = :products_url, products_friendly_url = :products_friendly_url, products_page_title = :products_page_title, products_meta_keywords = :products_meta_keywords, products_meta_description = :products_meta_description where products_id = :products_id and language_id = :language_id');
             } else {
                 $Qpd = $osC_Database->query('insert into :table_products_description (products_id, language_id, products_name, products_short_description, products_description, products_tags, products_url, products_friendly_url, products_page_title, products_meta_keywords, products_meta_description) values (:products_id, :language_id, :products_name, :products_short_description, :products_description, :products_tags, :products_url, :products_friendly_url, :products_page_title, :products_meta_keywords, :products_meta_description)');
             }
             $Qpd->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
             $Qpd->bindInt(':products_id', $products_id);
             $Qpd->bindInt(':language_id', $l['id']);
             $Qpd->bindValue(':products_name', $data['products_name'][$l['id']]);
             $Qpd->bindValue(':products_short_description', $data['products_short_description'][$l['id']]);
             $Qpd->bindValue(':products_description', $data['products_description'][$l['id']]);
             $Qpd->bindValue(':products_tags', $data['products_tags'][$l['id']]);
             $Qpd->bindValue(':products_url', $data['products_url'][$l['id']]);
             $Qpd->bindValue(':products_friendly_url', $data['products_friendly_url'][$l['id']]);
             $Qpd->bindValue(':products_page_title', $data['products_page_title'][$l['id']]);
             $Qpd->bindValue(':products_meta_keywords', $data['products_meta_keywords'][$l['id']]);
             $Qpd->bindValue(':products_meta_description', $data['products_meta_description'][$l['id']]);
             $Qpd->setLogging($_SESSION['module'], $products_id);
             $Qpd->execute();
             if ($osC_Database->isError()) {
                 $error = true;
                 break;
             }
         }
     }
     //BEGIN: products images
     if ($error === false) {
         $images = array();
         $image_path = '../images/products/_upload/' . $osC_Session->getID() . '/';
         $osC_DirectoryListing = new osC_DirectoryListing($image_path, true);
         $osC_DirectoryListing->setIncludeDirectories(false);
         foreach ($osC_DirectoryListing->getFiles() as $file) {
             @copy($image_path . $file['name'], '../images/products/originals/' . $file['name']);
             @unlink($image_path . $file['name']);
             $images[$file['name']] = -1;
         }
         osc_remove($image_path);
         $default_flag = 1;
         foreach (array_keys($images) as $image) {
             $Qimage = $osC_Database->query('insert into :table_products_images (products_id, default_flag, sort_order, date_added) values (:products_id, :default_flag, :sort_order, :date_added)');
             $Qimage->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
             $Qimage->bindInt(':products_id', $products_id);
             $Qimage->bindInt(':default_flag', $default_flag);
             $Qimage->bindInt(':sort_order', 0);
             $Qimage->bindRaw(':date_added', 'now()');
             $Qimage->execute();
             if ($osC_Database->isError()) {
                 $error = true;
             } else {
                 $image_id = $osC_Database->nextID();
                 $images[$image] = $image_id;
                 $new_image_name = $products_id . '_' . $image_id . '_' . $image;
                 @rename('../images/products/originals/' . $image, '../images/products/originals/' . $new_image_name);
                 $Qupdate = $osC_Database->query('update :table_products_images set image = :image where id = :id');
                 $Qupdate->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
                 $Qupdate->bindValue(':image', $new_image_name);
                 $Qupdate->bindInt(':id', $image_id);
                 $Qupdate->setLogging($_SESSION['module'], $products_id);
                 $Qupdate->execute();
                 foreach ($osC_Image->getGroups() as $group) {
                     if ($group['id'] != '1') {
                         $osC_Image->resize($new_image_name, $group['id'], 'products');
                     }
                 }
             }
             $default_flag = 0;
         }
     }
     //END: products images
     //BEGIN: products variants
     if ($error === false) {
         //if edit product, delete variant first
         if (is_numeric($id)) {
             $Qvariants = $osC_Database->query('select * from :table_products_variants where products_id = :products_id order by products_variants_id');
             $Qvariants->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
             $Qvariants->bindInt(':products_id', $_REQUEST['products_id']);
             $Qvariants->execute();
             $records = array();
             while ($Qvariants->next()) {
                 $Qentries = $osC_Database->query('select products_variants_id, products_variants_groups_id, products_variants_values_id from :table_products_variants_entries where products_variants_id = :products_variants_id order by products_variants_groups_id, products_variants_values_id');
                 $Qentries->bindTable(':table_products_variants_entries', TABLE_PRODUCTS_VARIANTS_ENTRIES);
                 $Qentries->bindInt(':products_variants_id', $Qvariants->valueInt('products_variants_id'));
                 $Qentries->execute();
                 $variants_values = array();
                 while ($Qentries->next()) {
                     $variants_values[] = $Qentries->valueInt('products_variants_groups_id') . '_' . $Qentries->valueInt('products_variants_values_id');
                 }
                 $variant = implode('-', $variants_values);
                 if (!isset($data['products_variants_id'][$variant])) {
                     //remove cache file
                     $cache_filename = $Qvariants->value('cache_filename');
                     if (!empty($cache_filename) && file_exists(DIR_FS_DOWNLOAD . $cache_filename)) {
                         osc_remove(DIR_FS_DOWNLOAD . $cache_filename);
                     }
                     //delete variants
                     $Qdelete = $osC_Database->query('delete from :table_products_variants where products_variants_id = :products_variants_id');
                     $Qdelete->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
                     $Qdelete->bindInt(':products_variants_id', $Qvariants->valueInt('products_variants_id'));
                     $Qdelete->execute();
                     if ($osC_Database->isError()) {
                         $error = true;
                         break;
                     }
                     //delete variants entries
                     if ($error === false) {
                         $Qdelete = $osC_Database->query('delete from :table_products_variants_entries where products_variants_id = :products_variants_id');
                         $Qdelete->bindTable(':table_products_variants_entries', TABLE_PRODUCTS_VARIANTS_ENTRIES);
                         $Qdelete->bindInt(':products_variants_id', $Qvariants->valueInt('products_variants_id'));
                         $Qdelete->execute();
                         if ($osC_Database->isError()) {
                             $error = true;
                             break;
                         }
                     }
                 }
             }
         }
         $products_quantity = 0;
         //insert or update variant
         if (isset($data['products_variants_id']) && is_array($data['products_variants_id'])) {
             foreach ($data['products_variants_id'] as $key => $variants_id) {
                 if ($variants_id > 0) {
                     $Qpv = $osC_Database->query('update :table_products_variants set products_price = :products_price, products_sku = :products_sku, products_model = :products_model, products_quantity = :products_quantity, products_weight = :products_weight, products_status = :products_status, products_images_id = :products_images_id, is_default = :is_default  where products_variants_id = :products_variants_id');
                     $Qpv->bindInt(':products_variants_id', $variants_id);
                 } else {
                     $Qpv = $osC_Database->query('insert into :table_products_variants (products_id, products_price, products_sku, products_model, products_quantity, products_weight, products_status, is_default, products_images_id) values (:products_id, :products_price, :products_sku, :products_model, :products_quantity, :products_weight, :products_status, :is_default, :products_images_id)');
                     $Qpv->bindInt(':products_id', $products_id);
                 }
                 $Qpv->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
                 $Qpv->bindInt(':is_default', $data['variants_default'][$key]);
                 $Qpv->bindValue(':products_price', $data['variants_price'][$key]);
                 $Qpv->bindValue(':products_sku', $data['variants_sku'][$key]);
                 $Qpv->bindValue(':products_model', $data['variants_model'][$key]);
                 $Qpv->bindValue(':products_quantity', $data['variants_quantity'][$key]);
                 $Qpv->bindValue(':products_weight', $data['variants_weight'][$key]);
                 $Qpv->bindValue(':products_status', $data['variants_status'][$key]);
                 $products_images_id = is_numeric($data['variants_image'][$key]) ? $data['variants_image'][$key] : $images[$data['variants_image'][$key]];
                 $Qpv->bindInt(':products_images_id', $products_images_id);
                 $Qpv->execute();
                 if ($osC_Database->isError()) {
                     $error = true;
                     break;
                 } else {
                     if (is_numeric($variants_id) && $variants_id > 0) {
                         $products_variants_id = $variants_id;
                     } else {
                         $products_variants_id = $osC_Database->nextID();
                     }
                     //downloadable file
                     if ($data['products_type'] == PRODUCT_TYPE_DOWNLOADABLE) {
                         $variants_file = new upload('products_variants_download_' . $key);
                         if ($variants_file->exists()) {
                             //remove old file
                             if (is_numeric($variants_id) && $variants_id > 0) {
                                 $Qfile = $osC_Database->query('select cache_filename from :table_products_variants where products_variants_id = :products_variants_id');
                                 $Qfile->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
                                 $Qfile->bindInt(':products_variants_id', $variants_id);
                                 $Qfile->execute();
                                 $cache_filename = $Qfile->value('cache_filename');
                                 if (!empty($cache_filename)) {
                                     osc_remove(DIR_FS_DOWNLOAD . $cache_filename);
                                 }
                             }
                             $variants_file->set_destination(realpath('../download'));
                             if ($variants_file->parse() && $variants_file->save()) {
                                 $variants_filename = $variants_file->filename;
                                 $cache_variants_filename = md5($variants_filename . time());
                                 @rename(DIR_FS_DOWNLOAD . $variants_filename, DIR_FS_DOWNLOAD . $cache_variants_filename);
                                 $Qupdate = $osC_Database->query('update :table_products_variants set filename = :filename, cache_filename = :cache_filename where products_variants_id = :products_variants_id');
                                 $Qupdate->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
                                 $Qupdate->bindInt(':products_variants_id', $products_variants_id);
                                 $Qupdate->bindValue(':filename', $variants_filename);
                                 $Qupdate->bindValue(':cache_filename', $cache_variants_filename);
                                 $Qupdate->execute();
                                 if ($osC_Database->isError()) {
                                     $error = true;
                                     break;
                                 }
                             }
                         }
                     }
                     $products_quantity += $data['variants_quantity'][$key];
                 }
                 //variant entries
                 if ($error === false && $variants_id == '-1') {
                     $assigned_variants = explode('-', $key);
                     for ($i = 0; $i < sizeof($assigned_variants); $i++) {
                         $assigned_variant = explode('_', $assigned_variants[$i]);
                         $Qpve = $osC_Database->query('insert into :table_products_variants_entries (products_variants_id, products_variants_groups_id, products_variants_values_id) values (:products_variants_id, :products_variants_groups_id, :products_variants_values_id)');
                         $Qpve->bindTable(':table_products_variants_entries', TABLE_PRODUCTS_VARIANTS_ENTRIES);
                         $Qpve->bindInt(':products_variants_id', $products_variants_id);
                         $Qpve->bindInt(':products_variants_groups_id', $assigned_variant[0]);
                         $Qpve->bindInt(':products_variants_values_id', $assigned_variant[1]);
                         $Qpve->setLogging($_SESSION['module'], $products_id);
                         $Qpve->execute();
                         if ($osC_Database->isError()) {
                             $error = true;
                             break;
                         }
                     }
                 }
             }
             if ($error === false) {
                 $osC_Database->simpleQuery('update ' . TABLE_PRODUCTS . ' set products_quantity = ' . $products_quantity . ' where products_id =' . $products_id);
                 if ($osC_Database->isError()) {
                     $error = true;
                 }
             }
         }
     }
     //END: products variants
     //BEGIN: xsell products
     if ($error === false) {
         if (is_numeric($id)) {
             $Qdelete = $osC_Database->query('delete from :table_products_xsell where products_id = :products_id');
             $Qdelete->bindTable(':table_products_xsell', TABLE_PRODUCTS_XSELL);
             $Qdelete->bindInt(':products_id', $id);
             $Qdelete->setLogging($_SESSION['module'], $id);
             $Qdelete->execute();
             if ($osC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             if (isset($data['xsell_id_array']) && !empty($data['xsell_id_array'])) {
                 foreach ($data['xsell_id_array'] as $xsell_products_id) {
                     $Qxsell = $osC_Database->query('insert into :table_products_xsell (products_id, xsell_products_id) values (:products_id , :xsell_products_id )');
                     $Qxsell->bindTable(':table_products_xsell', TABLE_PRODUCTS_XSELL);
                     $Qxsell->bindInt(':products_id', $products_id);
                     $Qxsell->bindInt(':xsell_products_id', $xsell_products_id);
                     $Qxsell->setLogging($_SESSION['module'], $products_id);
                     $Qxsell->execute();
                     if ($osC_Database->isError()) {
                         $error = true;
                         break;
                     }
                 }
             }
         }
     }
     //END: xsell products
     //BEGIN: products attributes
     if ($error === false) {
         if (is_numeric($id)) {
             $Qdelete = $osC_Database->query('delete from :table_products_attributes where products_id = :products_id ');
             $Qdelete->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
             $Qdelete->bindInt(':products_id', $id);
             $Qdelete->setLogging($_SESSION['module'], $id);
             $Qdelete->execute();
             if ($osC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             if (!empty($data['products_attributes'])) {
                 foreach ($data['products_attributes'] as $attribute) {
                     $Qef = $osC_Database->query('insert into :table_products_attributes (products_id, products_attributes_values_id, language_id, value) values (:products_id , :products_attributes_values_id, :language_id, :value)');
                     $Qef->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
                     $Qef->bindInt(':products_id', $products_id);
                     $Qef->bindInt(':products_attributes_values_id', $attribute['id']);
                     $Qef->bindInt(':language_id', $attribute['language_id']);
                     $Qef->bindValue(':value', $attribute['value']);
                     $Qef->execute();
                     if ($osC_Database->isError()) {
                         $error = true;
                         break;
                     }
                 }
             }
         }
     }
     //END: products attributes
     //BEGIN: customization fields
     if ($error === false) {
         if (is_numeric($id) && isset($data['customization_fields'])) {
             $ids = array();
             foreach ($data['customization_fields'] as $customization) {
                 if ($customization['customizations_fields_id'] > 0) {
                     $ids[] = $customization['customizations_fields_id'];
                 }
             }
             $Qcheck = $osC_Database->query('select customization_fields_id from :table_customization_fields where products_id = :products_id');
             $Qcheck->bindTable(':table_customization_fields', TABLE_CUSTOMIZATION_FIELDS);
             $Qcheck->bindInt(':products_id', $products_id);
             if (sizeof($ids) > 0) {
                 $Qcheck->appendQuery('and customization_fields_id not in (:customization_fields_id)');
                 $Qcheck->bindRaw(':customization_fields_id', implode(', ', $ids));
             }
             $Qcheck->execute();
             //delete customization fields
             if ($Qcheck->numberOfRows() > 0) {
                 $batch = array();
                 while ($Qcheck->next()) {
                     $batch[] = $Qcheck->valueInt('customization_fields_id');
                 }
                 $Qdelete = $osC_Database->query('delete from :table_customization_fields where customization_fields_id in (:customization_fields_id)');
                 $Qdelete->bindTable(':table_customization_fields', TABLE_CUSTOMIZATION_FIELDS);
                 $Qdelete->bindRaw(':customization_fields_id', implode(', ', $batch));
                 $Qdelete->setLogging($_SESSION['module'], $products_id);
                 $Qdelete->execute();
                 if ($osC_Database->isError()) {
                     $error = true;
                     break;
                 }
                 if ($error === false) {
                     $Qdelete = $osC_Database->query('delete from :table_customization_fields_description where customization_fields_id in (:customization_fields_id)');
                     $Qdelete->bindTable(':table_customization_fields_description', TABLE_CUSTOMIZATION_FIELDS_DESCRIPTION);
                     $Qdelete->bindRaw(':customization_fields_id', implode(', ', $batch));
                     $Qdelete->setLogging($_SESSION['module'], $products_id);
                     $Qdelete->execute();
                     if ($osC_Database->isError()) {
                         $error = true;
                         break;
                     }
                 }
             }
         }
     }
     if ($error === false) {
         if (isset($data['customization_fields']) && !empty($data['customization_fields'])) {
             foreach ($data['customization_fields'] as $field) {
                 if ($field['customizations_fields_id'] > 0) {
                     $Qfield = $osC_Database->query('update :table_customization_fields set type = :type, is_required = :is_required where customization_fields_id = :customization_fields_id');
                     $Qfield->bindInt(':customization_fields_id', $field['customizations_fields_id']);
                 } else {
                     $Qfield = $osC_Database->query('insert into :table_customization_fields (products_id, type, is_required) values (:products_id, :type, :is_required)');
                 }
                 $Qfield->bindTable(':table_customization_fields', TABLE_CUSTOMIZATION_FIELDS);
                 $Qfield->bindInt(':products_id', $products_id);
                 $Qfield->bindInt(':type', $field['customizations_type']);
                 $Qfield->bindInt(':is_required', $field['customizations_is_required']);
                 $Qfield->execute();
                 if ($osC_Database->isError()) {
                     $error = true;
                     break;
                 } else {
                     $fields_id = $field['customizations_fields_id'] > 0 ? $field['customizations_fields_id'] : $osC_Database->nextID();
                     $lan = get_object_vars($field['customizations_name_data']);
                     foreach ($osC_Language->getAll() as $l) {
                         if ($field['customizations_fields_id'] > 0) {
                             $Qdescription = $osC_Database->query('update :table_customization_fields_description set name = :name where customization_fields_id = :customization_fields_id and languages_id = :languages_id');
                         } else {
                             $Qdescription = $osC_Database->query('insert into :table_customization_fields_description (customization_fields_id, languages_id, name) values (:customization_fields_id, :languages_id, :name)');
                         }
                         $Qdescription->bindTable(':table_customization_fields_description', TABLE_CUSTOMIZATION_FIELDS_DESCRIPTION);
                         $Qdescription->bindInt(':customization_fields_id', $fields_id);
                         $Qdescription->bindInt(':languages_id', $l['id']);
                         $Qdescription->bindValue(':name', $lan['name' . $l['id']]);
                         $Qdescription->setLogging($_SESSION['module'], $products_id);
                         $Qdescription->execute();
                         if ($osC_Database->isError()) {
                             $error = true;
                             break;
                         }
                     }
                 }
             }
         }
     }
     //END: customization fields
     if ($error === false) {
         $osC_Database->commitTransaction();
         osC_Cache::clear('categories');
         osC_Cache::clear('category_tree');
         osC_Cache::clear('also_purchased');
         osC_Cache::clear('sefu-products');
         osC_Cache::clear('new_products');
         osC_Cache::clear('feature_products');
         return $products_id;
     }
     $osC_Database->rollbackTransaction();
     return false;
 }
Exemple #27
0
 function uploadLanguage()
 {
     global $toC_Json, $osC_Language, $osC_Currencies;
     $osC_Currencies = new osC_Currencies();
     $error = false;
     $feedback = array();
     $language = $_FILES['upload_file'];
     $tmp_path = DIR_FS_CACHE . 'languages/' . time();
     if (!is_dir(DIR_FS_CACHE . 'languages')) {
         if (!mkdir(DIR_FS_CACHE . 'languages', 0777)) {
             $error = true;
         }
     }
     if ($error === false && mkdir($tmp_path, 0777)) {
         $temp_file = new upload($language, $tmp_path);
         if ($temp_file->exists() && $temp_file->parse() && $temp_file->save()) {
             require_once '../ext/zip/pclzip.lib.php';
             $archive = new PclZip($tmp_path . '/' . $temp_file->filename);
             if ($archive->extract(PCLZIP_OPT_PATH, $tmp_path) == 0) {
                 $error = true;
                 $feedback[] = $osC_Language->get('ms_error_wrong_zip_file_format');
             }
         } else {
             $error = true;
             $feedback[] = $osC_Language->get('ms_error_save_file_failed');
         }
     } else {
         $error = true;
         $feedback[] = sprintf($osC_Language->get('ms_error_creating_directory_failed'), DIR_FS_CACHE);
     }
     if ($error === false) {
         $osC_DirectoryListing = new osC_DirectoryListing($tmp_path);
         $osC_DirectoryListing->setIncludeDirectories(true);
         $osC_DirectoryListing->setIncludeFiles(false);
         $files = $osC_DirectoryListing->getFiles();
         $code = null;
         foreach ($files as $file) {
             if (is_dir($tmp_path . '/' . $file['name'] . '/includes') && is_dir($tmp_path . '/' . $file['name'] . '/' . DIR_FS_ADMIN) && is_dir($tmp_path . '/' . $file['name'] . '/install')) {
                 $code = $file['name'];
                 break;
             }
         }
         if ($code != null) {
             toc_dircopy($tmp_path . '/' . $code . "/includes/languages", DIR_FS_CATALOG . 'includes/languages');
             toc_dircopy($tmp_path . '/' . $code . "/" . DIR_FS_ADMIN . "includes/languages", DIR_FS_CATALOG . DIR_FS_ADMIN . 'includes/languages');
             toc_dircopy($tmp_path . '/' . $code . "/install/includes/languages", DIR_FS_CATALOG . 'install/includes/languages');
             toc_dircopy($tmp_path . '/' . $code . "/install/templates", DIR_FS_CATALOG . 'install/templates');
             osc_remove($tmp_path);
         } else {
             $error = true;
             $feedback[] = $osC_Language->get('ms_error_wrong_language_package');
         }
     }
     if ($error === false) {
         if (osC_Language_Admin::import($code, 'replace')) {
             $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed'));
         } else {
             $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed'));
         }
     } else {
         $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed') . '<br />' . implode('<br />', $feedback));
     }
     header('Content-Type: text/html');
     echo $toC_Json->encode($response);
 }
Exemple #28
0
 function getImages()
 {
     global $toC_Json, $osC_Database, $osC_Session;
     $osC_Image = new osC_Image_Admin();
     $records = array();
     if (isset($_REQUEST['products_id']) && is_numeric($_REQUEST['products_id'])) {
         $Qimages = $osC_Database->query('select id, image, default_flag from :table_products_images where products_id = :products_id order by sort_order');
         $Qimages->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
         $Qimages->bindInt(':products_id', $_REQUEST['products_id']);
         $Qimages->execute();
         while ($Qimages->next()) {
             $records[] = array('id' => $Qimages->valueInt('id'), 'image' => '<img src="' . DIR_WS_HTTP_CATALOG . 'images/products/mini/' . $Qimages->value('image') . '" border="0" />', 'name' => $Qimages->value('image'), 'size' => number_format(@filesize(DIR_FS_CATALOG . DIR_WS_IMAGES . 'products/originals/' . $Qimages->value('image'))) . ' bytes', 'default' => $Qimages->valueInt('default_flag'));
         }
     } else {
         $image_path = '../images/products/_upload/' . $osC_Session->getID() . '/';
         $osC_DirectoryListing = new osC_DirectoryListing($image_path, true);
         $osC_DirectoryListing->setIncludeDirectories('false');
         foreach ($osC_DirectoryListing->getFiles() as $file) {
             $records[] = array('id' => '', 'image' => '<img src="' . $image_path . $file['name'] . '" border="0" width="' . $osC_Image->getWidth('mini') . '" height="' . $osC_Image->getHeight('mini') . '" />', 'name' => $file['name'], 'size' => number_format($file['size']) . ' bytes', 'default' => $_SESSION['default_images'] == $file['name'] ? 1 : 0);
         }
     }
     $response = array(EXT_JSON_READER_TOTAL => sizeof($records), EXT_JSON_READER_ROOT => $records);
     echo $toC_Json->encode($response);
 }
Exemple #29
0
$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 ($_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 . ' --';
 public static function getAccessModules()
 {
     global $osC_Language;
     $osC_DirectoryListing = new osC_DirectoryListing('includes/modules/access');
     $osC_DirectoryListing->setIncludeDirectories(false);
     $modules = array();
     foreach ($osC_DirectoryListing->getFiles() as $file) {
         $module = substr($file['name'], 0, strrpos($file['name'], '.'));
         if (!class_exists('osC_Access_' . ucfirst($module))) {
             $osC_Language->loadIniFile('modules/access/' . $file['name']);
             include $osC_DirectoryListing->getDirectory() . '/' . $file['name'];
         }
         $module = 'osC_Access_' . ucfirst($module);
         $module = new $module();
         $modules[osC_Access::getGroupTitle($module->getGroup())][] = array('id' => $module->getModule(), 'text' => $module->getTitle());
     }
     ksort($modules);
     return $modules;
 }