예제 #1
0
 public static function updateInstallID($id)
 {
     global $lC_Database;
     $Qchk = $lC_Database->query('select * from :table_configuration where configuration_key = :configuration_key');
     $Qchk->bindTable(':table_configuration', TABLE_CONFIGURATION);
     $Qchk->bindValue(':configuration_key', 'INSTALLATION_ID');
     $Qchk->execute();
     if ($Qchk->numberOfRows() > 0) {
         $Qupdate = $lC_Database->query('update :table_configuration set configuration_title = :configuration_title, configuration_key = :configuration_key, configuration_value = :configuration_value, configuration_description = :configuration_description, configuration_group_id = :configuration_group_id, date_added = :date_added where configuration_key = :configuration_key');
         $Qupdate->bindValue(':date_added', date("Y-m-d H:m:s"));
         $Qupdate->bindValue(':configuration_key', 'INSTALLATION_ID');
     } else {
         $Qupdate = $lC_Database->query('insert into :table_configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, last_modified) values (:configuration_title, :configuration_key, :configuration_value, :configuration_description, :configuration_group_id, :last_modified)');
         $Qupdate->bindValue(':last_modified', date("Y-m-d H:m:s"));
     }
     $Qupdate->bindTable(':table_configuration', TABLE_CONFIGURATION);
     $Qupdate->bindValue(':configuration_title', 'Installation ID');
     $Qupdate->bindValue(':configuration_key', 'INSTALLATION_ID');
     $Qupdate->bindValue(':configuration_value', $id);
     $Qupdate->bindValue(':configuration_description', 'Installation ID');
     $Qupdate->bindValue(':configuration_group_id', '6');
     $Qupdate->execute();
     $Qchk->freeResult();
     lC_Cache::clear('configuration');
     if ($lC_Database->isError()) {
         return false;
     }
     return true;
 }
예제 #2
0
 public function remove()
 {
     global $lC_Database, $lC_Language;
     $Qdel = $lC_Database->query('delete from :table_templates_boxes where code = :code and modules_group = :modules_group');
     $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
     $Qdel->bindValue(':code', $this->_code);
     $Qdel->bindValue(':modules_group', $this->_group);
     $Qdel->execute();
     if ($this->hasKeys()) {
         $Qdel = $lC_Database->query('delete from :table_configuration where configuration_key in (":configuration_key")');
         $Qdel->bindTable(':table_configuration', TABLE_CONFIGURATION);
         $Qdel->bindRaw(':configuration_key', implode('", "', $this->getKeys()));
         $Qdel->execute();
     }
     if (file_exists('../includes/languages/' . $lC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) {
         foreach ($lC_Language->extractDefinitions($lC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) {
             $Qdel = $lC_Database->query('delete from :table_languages_definitions where definition_key = :definition_key and content_group = :content_group');
             $Qdel->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
             $Qdel->bindValue(':definition_key', $def['key']);
             $Qdel->bindValue(':content_group', $def['group']);
             $Qdel->execute();
         }
         lC_Cache::clear('languages');
     }
 }
예제 #3
0
 protected function _process()
 {
     global $lC_Database, $lC_Session, $lC_Language, $lC_ShoppingCart, $lC_MessageStack, $lC_Customer, $lC_NavigationHistory, $lC_Vqmod;
     require $lC_Vqmod->modCheck('includes/classes/account.php');
     if (lC_Account::checkEntry($_POST['email_address'])) {
         if (lC_Account::checkPassword($_POST['password'], $_POST['email_address'])) {
             if (SERVICE_SESSION_REGENERATE_ID == '1') {
                 $lC_Session->recreate();
             }
             $lC_Customer->setCustomerData(lC_Account::getID($_POST['email_address']));
             $Qupdate = $lC_Database->query('update :table_customers set date_last_logon = :date_last_logon, number_of_logons = number_of_logons+1 where customers_id = :customers_id');
             $Qupdate->bindTable(':table_customers', TABLE_CUSTOMERS);
             $Qupdate->bindRaw(':date_last_logon', 'now()');
             $Qupdate->bindInt(':customers_id', $lC_Customer->getID());
             $Qupdate->execute();
             if ($lC_ShoppingCart->hasContents() === true) {
                 $lC_ShoppingCart->synchronizeWithDatabase();
             }
             $lC_NavigationHistory->removeCurrentPage();
             lC_Cache::clearAll();
             if ($lC_NavigationHistory->hasSnapshot()) {
                 $lC_NavigationHistory->redirectToSnapshot();
             } else {
                 lc_redirect(lc_href_link(FILENAME_DEFAULT, null, 'AUTO'));
             }
         } else {
             $lC_MessageStack->add('login', $lC_Language->get('error_login_no_match'));
         }
     } else {
         $lC_MessageStack->add('login', $lC_Language->get('error_login_no_match'));
     }
 }
예제 #4
0
 protected function _process()
 {
     global $lC_ShoppingCart, $lC_Customer, $lC_Coupons;
     $lC_ShoppingCart->reset();
     $lC_Coupons->reset();
     $lC_Customer->reset();
     lC_Cache::clearAll();
     if (isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === TRUE) {
         unset($_SESSION['admin_login']);
     }
 }
예제 #5
0
 public function __construct()
 {
     global $lC_Language;
     $this->_page_title = $lC_Language->get('heading_title');
     if (!isset($_GET['action'])) {
         $_GET['action'] = '';
     }
     $action = isset($_GET['action']) && $_GET['action'] != NULL ? $_GET['action'] : NULL;
     switch ($action) {
         case 'clear':
             lC_Cache::clear('*');
             break;
     }
 }
예제 #6
0
 public function __construct()
 {
     global $lC_Language;
     $this->_page_title = $lC_Language->get('heading_title');
     if (isset($_SESSION['deleteAddon']) && empty($_SESSION['deleteAddon']) === false) {
         $this->_rmdir_r(DIR_FS_CATALOG . 'addons/' . $_SESSION['deleteAddon'] . '/');
         unset($_SESSION['deleteAddon']);
         lC_Cache::clear('modules-addons');
         lC_Cache::clear('configuration');
         lC_Cache::clear('templates');
         lC_Cache::clear('addons');
         lC_Cache::clear('vqmoda');
         lC_Cache::clear('vqmods');
     }
 }
예제 #7
0
 public function remove()
 {
     global $lC_Database;
     if ($handle = opendir(DIR_FS_CATALOG)) {
         while (false !== ($entry = readdir($handle))) {
             if ($entry == '.htaccess') {
                 if (rename(DIR_FS_CATALOG . '.htaccess', DIR_FS_CATALOG . 'dot.htaccess')) {
                 } else {
                     return false;
                 }
             }
         }
         closedir($handle);
     }
     $lC_Database->simpleQuery("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
     lC_Cache::clear('category_tree');
     lC_Cache::clear('templates');
 }
예제 #8
0
 public static function deleteCatImage($_image, $_id = null)
 {
     global $lC_Database;
     // added to check for other categories using same image and do not delete
     $Qci = $lC_Database->query('select id from :table_categories where categories_image = :categories_image');
     $Qci->bindTable(':table_categories', TABLE_CATEGORIES);
     $Qci->bindInt(':categories_image', $_image);
     $Qci->execute();
     if ($Qci->numberOfRows() < 2) {
         if (file_exists('../images/categories/' . $_image)) {
             unlink('../images/categories/' . $_image);
         }
     }
     $Qci->freeResult();
     if (is_numeric($_id)) {
         $Qcategoriesimage = $lC_Database->query('update :table_categories set categories_image = "" where categories_id = :categories_id');
         $Qcategoriesimage->bindTable(':table_categories', TABLE_CATEGORIES);
         $Qcategoriesimage->bindInt(':categories_id', $_id);
         $Qcategoriesimage->execute();
     }
     if (!$lC_Database->isError()) {
         lC_Cache::clear('categories');
         lC_Cache::clear('category_tree');
         lC_Cache::clear('template');
         lC_Cache::clear('also_purchased');
     }
     return true;
 }
 public static function uninstall($key)
 {
     global $lC_Database, $lC_Language, $lC_Vqmod;
     if (file_exists('includes/modules/order_total/' . $key . '.php')) {
         $lC_Language->injectDefinitions('modules/order_total/' . $key . '.xml');
         include $lC_Vqmod->modCheck('includes/modules/order_total/' . $key . '.php');
         $module = 'lC_OrderTotal_' . $key;
         $module = new $module();
         $module->remove();
         lC_Cache::clear('modules-order_total');
         lC_Cache::clear('configuration');
         return true;
     }
     return false;
 }
예제 #10
0
 public static function delete($id)
 {
     lC_Cache::clear($id);
     return true;
 }
예제 #11
0
 public static function save($id = null, $data, $default = false)
 {
     global $lC_Database, $lC_Language;
     $error = false;
     $lC_Database->startTransaction();
     if (isset($id) && $id != null) {
         $orders_status_id = $id;
         // ISSUE: if we add a new language, editing values does not save the new language.
         // To cure this, we delete the old records first, then re-insert instead of update.
         lC_Orders_status_Admin::delete($orders_status_id);
     } else {
         $Qstatus = $lC_Database->query('select max(orders_status_id) as orders_status_id from :table_orders_status');
         $Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
         $Qstatus->execute();
         $orders_status_id = $Qstatus->valueInt('orders_status_id') + 1;
     }
     foreach ($lC_Language->getAll() as $l) {
         $Qstatus = $lC_Database->query('insert into :table_orders_status (orders_status_id, language_id, orders_status_name, orders_status_type) values (:orders_status_id, :language_id, :orders_status_name, :orders_status_type)');
         $Qstatus->bindTable(':table_orders_status', TABLE_ORDERS_STATUS);
         $Qstatus->bindInt(':orders_status_id', $orders_status_id);
         $Qstatus->bindValue(':orders_status_name', $data['name'][$l['id']]);
         $Qstatus->bindValue(':orders_status_type', $data['type']);
         $Qstatus->bindInt(':language_id', $l['id']);
         $Qstatus->setLogging($_SESSION['module'], $orders_status_id);
         $Qstatus->execute();
         if ($lC_Database->isError()) {
             $error = true;
             break;
         }
     }
     if ($error === false) {
         if ($default === true) {
             $Qupdate = $lC_Database->query('update :table_configuration set configuration_value = :configuration_value where configuration_key = :configuration_key');
             $Qupdate->bindTable(':table_configuration', TABLE_CONFIGURATION);
             $Qupdate->bindInt(':configuration_value', $orders_status_id);
             $Qupdate->bindValue(':configuration_key', 'DEFAULT_ORDERS_STATUS_ID');
             $Qupdate->setLogging($_SESSION['module'], $orders_status_id);
             $Qupdate->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
     }
     if ($error === false) {
         $lC_Database->commitTransaction();
         if ($default === true) {
             lC_Cache::clear('configuration');
         }
         return true;
     }
     $lC_Database->rollbackTransaction();
     return false;
 }
예제 #12
0
 public static function save($data)
 {
     global $lC_Database, $lC_Language;
     $error = false;
     if (empty($language_id)) {
         $language_id = $lC_Language->getID();
     }
     $Qdelete = $lC_Database->query('delete from :table_branding_data');
     $Qdelete->bindTable(':table_branding_data', TABLE_BRANDING_DATA);
     $Qdelete->execute();
     foreach ($lC_Language->getAll() as $l) {
         // delete data first
         $Qdelete = $lC_Database->query('delete from :table_branding where language_id = :language_id');
         $Qdelete->bindTable(':table_branding', TABLE_BRANDING);
         $Qdelete->bindInt(':language_id', $l['id']);
         $Qdelete->execute();
         //save new data
         $QBrand = $lC_Database->query('insert into :table_branding (language_id, homepage_text, slogan, meta_description, meta_keywords, meta_title, meta_title_prefix, meta_title_suffix, footer_text) values (:language_id, :homepage_text, :slogan, :meta_description, :meta_keywords, :meta_title, :meta_title_prefix, :meta_title_suffix, :footer_text)');
         $QBrand->bindTable(':table_branding', TABLE_BRANDING);
         $QBrand->bindValue(':homepage_text', $data['home_page_text'][$l['id']]);
         $QBrand->bindValue(':slogan', $data['slogan'][$l['id']]);
         $QBrand->bindValue(':meta_description', $data['meta_description'][$l['id']]);
         $QBrand->bindValue(':meta_keywords', $data['meta_keywords'][$l['id']]);
         $QBrand->bindValue(':meta_title', $data['meta_title'][$l['id']]);
         $QBrand->bindValue(':meta_title_prefix', $data['meta_title_prefix'][$l['id']]);
         $QBrand->bindValue(':meta_title_suffix', $data['meta_title_suffix'][$l['id']]);
         $QBrand->bindValue(':footer_text', $data['footer_text'][$l['id']]);
         $QBrand->bindValue(':language_id', $l['id']);
         $QBrand->setLogging($_SESSION['module']);
         $QBrand->execute();
     }
     //save non language specific data
     $QbrandingData = $lC_Database->query('insert into :table_branding_data (site_image, chat_code, support_phone, support_email, sales_phone, sales_email, og_image, meta_delimeter, social_facebook_page, social_twitter, social_pinterest, social_google_plus, social_youtube, social_linkedin, custom_css) values ( :site_image, :chat_code, :support_phone, :support_email, :sales_phone, :sales_email, :og_image, :meta_delimeter, :social_facebook_page, :social_twitter, :social_pinterest, :social_google_plus, :social_youtube, :social_linkedin, :custom_css)');
     $QbrandingData->bindTable(':table_branding_data', TABLE_BRANDING_DATA);
     $QbrandingData->bindValue(':site_image', $data['site_image']);
     $QbrandingData->bindValue(':chat_code', $data['chat_code']);
     $QbrandingData->bindValue(':address', $data['address']);
     $QbrandingData->bindValue(':support_phone', $data['support_phone']);
     $QbrandingData->bindValue(':support_email', $data['support_email']);
     $QbrandingData->bindValue(':sales_phone', $data['sales_phone']);
     $QbrandingData->bindValue(':sales_email', $data['sales_email']);
     $QbrandingData->bindValue(':og_image', $data['og_image']);
     $QbrandingData->bindValue(':meta_delimeter', $data['meta_delimeter']);
     $QbrandingData->bindValue(':social_facebook_page', $data['social_facebook_page']);
     $QbrandingData->bindValue(':social_twitter', $data['social_twitter']);
     $QbrandingData->bindValue(':social_pinterest', $data['social_pinterest']);
     $QbrandingData->bindValue(':social_google_plus', $data['social_google_plus']);
     $QbrandingData->bindValue(':social_youtube', $data['social_youtube']);
     $QbrandingData->bindValue(':social_linkedin', $data['social_linkedin']);
     $QbrandingData->bindValue(':custom_css', $data['custom_css']);
     $QbrandingData->bindValue(':language_id', $language_id);
     $QbrandingData->execute();
     $QbrandingName = $lC_Database->query('update :table_configuration set configuration_value = :name where configuration_key = "STORE_NAME"');
     $QbrandingName->bindTable(':table_configuration', TABLE_CONFIGURATION);
     $QbrandingName->bindValue(':name', $data['name']);
     $QbrandingName->execute();
     $QbrandingAddress = $lC_Database->query('update :table_configuration set configuration_value = :address where configuration_key = "STORE_NAME_ADDRESS"');
     $QbrandingAddress->bindTable(':table_configuration', TABLE_CONFIGURATION);
     $QbrandingAddress->bindValue(':address', $data['address']);
     $QbrandingAddress->execute();
     lC_Cache::clear('configuration');
     return true;
 }
예제 #13
0
 public static function delete($id, $categories = null)
 {
     global $lC_Database;
     $lC_Image = new lC_Image_Admin();
     $delete_product = true;
     $error = false;
     $lC_Database->startTransaction();
     if (is_array($categories) && !empty($categories)) {
         $Qpc = $lC_Database->query('delete from :table_products_to_categories where products_id = :products_id and categories_id in :categories_id');
         $Qpc->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
         $Qpc->bindInt(':products_id', $id);
         $Qpc->bindRaw(':categories_id', '("' . implode('", "', $categories) . '")');
         $Qpc->setLogging($_SESSION['module'], $id);
         $Qpc->execute();
         if (!$lC_Database->isError()) {
             $Qcheck = $lC_Database->query('select products_id from :table_products_to_categories where products_id = :products_id limit 1');
             $Qcheck->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
             $Qcheck->bindInt(':products_id', $id);
             $Qcheck->execute();
             if ($Qcheck->numberOfRows() > 0) {
                 $delete_product = false;
             }
         } else {
             $error = true;
         }
     }
     if ($error === false && $delete_product === true) {
         $Qvariants = $lC_Database->query('select products_id from :table_products where parent_id = :parent_id');
         $Qvariants->bindTable(':table_products', TABLE_PRODUCTS);
         $Qvariants->bindInt(':parent_id', $id);
         $Qvariants->execute();
         while ($Qvariants->next()) {
             $Qsc = $lC_Database->query('delete from :table_shopping_carts where products_id = :products_id');
             $Qsc->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS);
             $Qsc->bindInt(':products_id', $Qvariants->valueInt('products_id'));
             $Qsc->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
             if ($error === false) {
                 $Qsccvv = $lC_Database->query('delete from :table_shopping_carts_custom_variants_values where products_id = :products_id');
                 $Qsccvv->bindTable(':table_shopping_carts_custom_variants_values', TABLE_SHOPPING_CARTS_CUSTOM_VARIANTS_VALUES);
                 $Qsccvv->bindInt(':products_id', $Qvariants->valueInt('products_id'));
                 $Qsccvv->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                 }
             }
             if ($error === false) {
                 $Qpa = $lC_Database->query('delete from :table_products_variants where products_id = :products_id');
                 $Qpa->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
                 $Qpa->bindInt(':products_id', $Qvariants->valueInt('products_id'));
                 $Qpa->setLogging($_SESSION['module'], $id);
                 $Qpa->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                 }
             }
             if ($error === false) {
                 $Qp = $lC_Database->query('delete from :table_products where products_id = :products_id');
                 $Qp->bindTable(':table_products', TABLE_PRODUCTS);
                 $Qp->bindInt(':products_id', $Qvariants->valueInt('products_id'));
                 $Qp->setLogging($_SESSION['module'], $id);
                 $Qp->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                 }
             }
             // QPB
             if ($error === false) {
                 $Qpb = $lC_Database->query('delete from :table_products_pricing where products_id = :products_id');
                 $Qpb->bindTable(':table_products_pricing', TABLE_PRODUCTS_PRICING);
                 $Qpb->bindInt(':products_id', $Qvariants->valueInt('products_id'));
                 $Qpb->setLogging($_SESSION['module'], $id);
                 $Qpb->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                 }
             }
         }
         if ($error === false) {
             $Qr = $lC_Database->query('delete from :table_reviews where products_id = :products_id');
             $Qr->bindTable(':table_reviews', TABLE_REVIEWS);
             $Qr->bindInt(':products_id', $id);
             $Qr->setLogging($_SESSION['module'], $id);
             $Qr->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qsc = $lC_Database->query('delete from :table_shopping_carts where products_id = :products_id');
             $Qsc->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS);
             $Qsc->bindInt(':products_id', $id);
             $Qsc->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qsccvv = $lC_Database->query('delete from :table_shopping_carts_custom_variants_values where products_id = :products_id');
             $Qsccvv->bindTable(':table_shopping_carts_custom_variants_values', TABLE_SHOPPING_CARTS_CUSTOM_VARIANTS_VALUES);
             $Qsccvv->bindInt(':products_id', $id);
             $Qsccvv->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qp2c = $lC_Database->query('delete from :table_products_to_categories where products_id = :products_id');
             $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
             $Qp2c->bindInt(':products_id', $id);
             $Qp2c->setLogging($_SESSION['module'], $id);
             $Qp2c->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qs = $lC_Database->query('delete from :table_specials where products_id = :products_id');
             $Qs->bindTable(':table_specials', TABLE_SPECIALS);
             $Qs->bindInt(':products_id', $id);
             $Qs->setLogging($_SESSION['module'], $id);
             $Qs->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qpa = $lC_Database->query('delete from :table_products_variants where products_id = :products_id');
             $Qpa->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
             $Qpa->bindInt(':products_id', $id);
             $Qpa->setLogging($_SESSION['module'], $id);
             $Qpa->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qpd = $lC_Database->query('delete from :table_products_description where products_id = :products_id');
             $Qpd->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
             $Qpd->bindInt(':products_id', $id);
             $Qpd->setLogging($_SESSION['module'], $id);
             $Qpd->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qp = $lC_Database->query('delete from :table_products where products_id = :products_id');
             $Qp->bindTable(':table_products', TABLE_PRODUCTS);
             $Qp->bindInt(':products_id', $id);
             $Qp->setLogging($_SESSION['module'], $id);
             $Qp->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qim = $lC_Database->query('select id, image from :table_products_images where products_id = :products_id');
             $Qim->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
             $Qim->bindInt(':products_id', $id);
             $Qim->execute();
             // added to check for other products using same image and do not delete
             $Qop = $lC_Database->query('select id from :table_products_images where image = :image');
             $Qop->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
             $Qop->bindInt(':image', $Qim->value('image'));
             $Qop->execute();
             if ($Qop->numberOfRows() < 2) {
                 while ($Qim->next()) {
                     $lC_Image->delete($Qim->valueInt('id'));
                 }
             }
         }
         // featured products
         if ($error === false) {
             $Qfp = $lC_Database->query('delete from :table_featured_products where products_id = :products_id');
             $Qfp->bindTable(':table_featured_products', TABLE_FEATURED_PRODUCTS);
             $Qfp->bindInt(':products_id', $id);
             $Qfp->setLogging($_SESSION['module'], $id);
             $Qfp->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         // QPB
         if ($error === false) {
             $Qpb = $lC_Database->query('delete from :table_products_pricing where products_id = :products_id');
             $Qpb->bindTable(':table_products_pricing', TABLE_PRODUCTS_PRICING);
             $Qpb->bindInt(':products_id', $id);
             $Qpb->setLogging($_SESSION['module'], $id);
             $Qpb->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         // permalink
         if ($error === false) {
             $Qpb = $lC_Database->query('delete from :table_permalinks where item_id = :item_id');
             $Qpb->bindTable(':table_permalinks', TABLE_PERMALINKS);
             $Qpb->bindInt(':item_id', $id);
             $Qpb->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
     }
     // delete subproducts
     if ($error === false && $delete_product === true) {
         $Qcheck = $lC_Database->query('select products_id from :table_products where parent_id = :parent_id');
         $Qcheck->bindTable(':table_products', TABLE_PRODUCTS);
         $Qcheck->bindInt(':parent_id', $id);
         $Qcheck->execute();
         while ($Qcheck->next()) {
             // delete the description data
             $Qdel = $lC_Database->query('delete from :table_products_description where products_id = :products_id');
             $Qdel->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
             $Qdel->bindInt(':products_id', $Qcheck->valueInt('products_id'));
             $Qdel->setLogging($_SESSION['module'], $id);
             $Qdel->execute();
             // delete the image data
             $Qdel = $lC_Database->query('delete from :table_products_images where products_id = :products_id');
             $Qdel->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
             $Qdel->bindInt(':products_id', $Qcheck->valueInt('products_id'));
             $Qdel->setLogging($_SESSION['module'], $id);
             $Qdel->execute();
         }
         // delete the subproduct
         $Qdel = $lC_Database->query('delete from :table_products where products_id = :products_id');
         $Qdel->bindTable(':table_products', TABLE_PRODUCTS);
         $Qdel->bindInt(':products_id', $Qcheck->valueInt('products_id'));
         $Qdel->setLogging($_SESSION['module'], $id);
         $Qdel->execute();
         if ($lC_Database->isError()) {
             $error = true;
         }
     }
     // delete simple options
     if ($error === false && $delete_product === true) {
         $Qcheck = $lC_Database->query('select options_id from :table_products_simple_options where products_id = :products_id');
         $Qcheck->bindTable(':table_products_simple_options', TABLE_PRODUCTS_SIMPLE_OPTIONS);
         $Qcheck->bindInt(':products_id', $id);
         $Qcheck->execute();
         // delete the simple options values
         while ($Qcheck->next()) {
             $Qdel = $lC_Database->query('delete from :table_products_simple_options_values where options_id = :options_id AND products_id = :products_id');
             $Qdel->bindTable(':table_products_simple_options_values', TABLE_PRODUCTS_SIMPLE_OPTIONS_VALUES);
             $Qdel->bindInt(':options_id', $Qcheck->valueInt('options_id'));
             $Qdel->bindInt(':products_id', $id);
             $Qdel->setLogging($_SESSION['module'], $id);
             $Qdel->execute();
         }
         // delete the simple option
         $Qdel = $lC_Database->query('delete from :table_products_simple_options where products_id = :products_id');
         $Qdel->bindTable(':table_products_simple_options', TABLE_PRODUCTS_SIMPLE_OPTIONS);
         $Qdel->bindInt(':products_id', $id);
         $Qdel->setLogging($_SESSION['module'], $id);
         $Qdel->execute();
         $Qcheck->freeResult();
         if ($lC_Database->isError()) {
             $error = true;
         }
     }
     if ($error === false) {
         $lC_Database->commitTransaction();
         lC_Cache::clear('categories');
         lC_Cache::clear('category_tree');
         lC_Cache::clear('also_purchased');
         lC_Cache::clear('box-whats_new');
         return true;
     }
     $lC_Database->rollbackTransaction();
     return false;
 }
예제 #14
0
 public static function save($id = null, $data, $default = false)
 {
     global $lC_Database, $lC_Language;
     if (is_numeric($id)) {
         $group_id = $id;
     } else {
         $Qgroup = $lC_Database->query('select max(id) as id from :table_products_images_groups');
         $Qgroup->bindTable(':table_products_images_groups', TABLE_PRODUCTS_IMAGES_GROUPS);
         $Qgroup->execute();
         $group_id = $Qgroup->valueInt('id') + 1;
     }
     $error = false;
     $lC_Database->startTransaction();
     foreach ($lC_Language->getAll() as $l) {
         // check to see if the DB entry exists for the selected language
         $Qchk1 = $lC_Database->query('select title from :table_products_images_groups where code = :code and language_id = :language_id limit 1');
         $Qchk1->bindTable(':table_products_images_groups', TABLE_PRODUCTS_IMAGES_GROUPS);
         $Qchk1->bindValue(':code', $data['code']);
         $Qchk1->bindInt(':language_id', $l['id']);
         $Qchk1->execute();
         if (is_numeric($id) && $Qchk1->numberOfRows() == 1) {
             $Qgroup = $lC_Database->query('update :table_products_images_groups set title = :title, code = :code, size_width = :size_width, size_height = :size_height, force_size = :force_size where id = :id and language_id = :language_id');
         } else {
             $Qgroup = $lC_Database->query('insert into :table_products_images_groups (id, language_id, title, code, size_width, size_height, force_size) values (:id, :language_id, :title, :code, :size_width, :size_height, :force_size)');
         }
         $Qchk1->freeResult();
         $Qgroup->bindTable(':table_products_images_groups', TABLE_PRODUCTS_IMAGES_GROUPS);
         $Qgroup->bindInt(':id', $group_id);
         $Qgroup->bindValue(':title', $data['title'][$l['id']]);
         $Qgroup->bindValue(':code', $data['code']);
         $Qgroup->bindInt(':size_width', $data['width']);
         $Qgroup->bindInt(':size_height', $data['height']);
         $Qgroup->bindInt(':force_size', $data['force_size'] == 'on' ? 1 : 0);
         $Qgroup->bindInt(':language_id', $l['id']);
         $Qgroup->setLogging($_SESSION['module'], $group_id);
         $Qgroup->execute();
         if ($lC_Database->isError()) {
             $error = true;
             break;
         }
     }
     if ($error === false) {
         if ($default === true) {
             $Qupdate = $lC_Database->query('update :table_configuration set configuration_value = :configuration_value where configuration_key = :configuration_key');
             $Qupdate->bindTable(':table_configuration', TABLE_CONFIGURATION);
             $Qupdate->bindInt(':configuration_value', $group_id);
             $Qupdate->bindValue(':configuration_key', 'DEFAULT_IMAGE_GROUP_ID');
             $Qupdate->setLogging($_SESSION['module'], $group_id);
             $Qupdate->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
     }
     if ($error === false) {
         $lC_Database->commitTransaction();
         lC_Cache::clear('images_groups');
         if ($default === true) {
             lC_Cache::clear('configuration');
         }
         return true;
     }
     $lC_Database->rollbackTransaction();
     return false;
 }
예제 #15
0
 /**
  * Save the coupons information
  *
  * @param integer $id The coupons id used on update, null on insert
  * @param array $data An array containing the coupons information
  * @access public
  * @return array
  */
 public static function save($id = null, $data)
 {
     global $lC_Database, $lC_Language;
     $error = false;
     $lC_Database->startTransaction();
     if (is_numeric($id)) {
         $Qfeatured = $lC_Database->query('update :table_featured_products set expires_date = :expires_date, status = :status, last_modified = now() where id = :id');
         $Qfeatured->bindInt(':id', $id);
     } else {
         $Qfeatured = $lC_Database->query('insert into :table_featured_products (products_id, date_added, last_modified, expires_date, status) values (:products_id, now(), now(), :expires_date, :status)');
         $Qfeatured->bindInt(':products_id', $data['products_id']);
     }
     // insert/update the featured products table
     $Qfeatured->bindTable(':table_featured_products', TABLE_FEATURED_PRODUCTS);
     //$Qfeatured->bindDate(':expires_date', (($data['expires_date'] != '0000-00-00 00:00:00') ? ((strstr($data['expires_date'], '/')) ? lC_DateTime::toDateTime($data['expires_date']) : $data['expires_date']) : '0000-00-00 00:00:00'));
     $Qfeatured->bindDate(':expires_date', $data['expires_date'] != '0000-00-00 00:00:00' ? lC_DateTime::toDateTime($data['expires_date']) : $data['expires_date']);
     $Qfeatured->bindInt(':status', $data['status']);
     $Qfeatured->setLogging($_SESSION['module'], $id);
     $Qfeatured->execute();
     if ($lC_Database->isError()) {
         $error = true;
     }
     if ($error === false) {
         $lC_Database->commitTransaction();
         lC_Cache::clear('featured_products');
         if (is_numeric($id)) {
             return $id;
         } else {
             return $lC_Database->nextID();
         }
     }
     $lC_Database->rollbackTransaction();
     return false;
 }
 public static function delete($id)
 {
     global $lC_Database;
     $Qdel = $lC_Database->query('delete from :table_templates_boxes_to_pages where id = :id');
     $Qdel->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES);
     $Qdel->bindInt(':id', $id);
     $Qdel->setLogging($_SESSION['module'], $id);
     $Qdel->execute();
     if (!$lC_Database->isError()) {
         lC_Cache::clear('templates_' . $_GET['set'] . '_layout');
         return true;
     }
     return false;
 }
예제 #17
0
 public static function updateStatus()
 {
     $status = lC_Products_Admin::updateStatus($_GET['pid'], $_GET['val']);
     if ($status) {
         lC_Cache::clear('category_tree');
         $result['rpcStatus'] = RPC_STATUS_SUCCESS;
     }
     echo json_encode($result);
 }
 public static function importProducts($filename, $pwizard, $ptype, $pbackup, $pmapdata = NULL)
 {
     global $lC_Database, $lC_Datetime, $lC_Language, $lC_Image;
     $lC_Products = new lC_Products_Admin();
     $error = "";
     $msg = "";
     $other = "";
     $uploaddir = DIR_FS_WORK . 'products_import_export/imports/';
     $uploadfile = $uploaddir . basename($filename);
     if (is_null($pmapdata)) {
         $columns = array('id', 'parent_id', 'quantity', 'price', 'cost', 'msrp', 'model', 'sku', 'date_added', 'weight', 'weight_class', 'status', 'tax_class_id', 'manufacturer', 'ordered', 'has_children', 'language_id', 'name', 'description', 'permalink', 'tags', 'meta_title', 'meta_keywords', 'meta_description', 'url', 'products_viewed', 'categories', 'parent_categories', 'base_image');
     } else {
         // do the mapping of columns here with the mapdata
     }
     $ext = end(explode(".", $filename));
     $delim = $ext == 'txt' ? "\t" : ($ext == 'csv' ? "," : "\t");
     $row = 0;
     if (($handle = fopen($uploadfile, "r")) !== FALSE) {
         while (($data = fgetcsv($handle, null, $delim)) !== FALSE) {
             $num = count($data);
             for ($c = 0; $c < $num; $c++) {
                 if ($row != 0) {
                     $import_array[$row][$columns[$c]] = $data[$c];
                 }
             }
             $row++;
         }
         fclose($handle);
     }
     // Need to find and remove blank rows
     $match_count = 0;
     $insert_count = 0;
     if ($pwizard != 'false') {
         // p wizard stuff like return columns and etc.
         // $other = 'pwizard ' . $pwizard;
     } else {
         // do the import as usual
         // utilize import array to go through each column and run on each to check for product id and if not matched import and remove from arrray
         foreach ($import_array as $product) {
             // Get the products ID for control
             $products_id = $product['id'];
             // need to get the weight class since Im outputting lb and kg instead of the ids
             if ($product['weight_class'] != '') {
                 $QweightClass = $lC_Database->query("select * from :table_weight_classes wc where wc.weight_class_key = :weight_class_key");
                 $QweightClass->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS);
                 $QweightClass->bindValue(':weight_class_key', $product['weight_class']);
                 $QweightClass->execute();
                 if ($lC_Database->isError()) {
                     $errormsg .= 'weight class err ' . $lC_Database->getError();
                 } else {
                     $product_weight_class_id = $QweightClass->value('weight_class_id');
                 }
             }
             // convert the permalink to a safe output
             if (!empty($product['permalink'])) {
                 $product['permalink'] = lC_Products_import_export_Admin::generate_clean_permalink($product['permalink']);
             } else {
                 $product['permalink'] = lC_Products_import_export_Admin::generate_clean_permalink($product['name']);
             }
             // need to get ids for these categories if they dont exist we need to make them and return that id
             if ($product['categories'] != '') {
                 $product['categories'] = explode(",", $product['categories']);
                 $ifParent = '';
                 foreach ($product['categories'] as $catName) {
                     if ($catName != '') {
                         $catCheck = $lC_Database->query("select cd.* from :table_categories_description cd left join :table_categories c on (cd.categories_id = c.categories_id) where cd.categories_name = :categories_name" . $ifParent);
                         $catCheck->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
                         $catCheck->bindTable(':table_categories', TABLE_CATEGORIES);
                         $catCheck->bindValue(':categories_name', $catName);
                         if ($product['parent_categories'] != '') {
                             $parentCheck = $lC_Database->query("select categories_id from :table_categories_description where categories_name = :categories_name and language_id = :language_id");
                             $parentCheck->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
                             $parentCheck->bindValue(':categories_name', end(explode(",", $product['parent_categories'])));
                             $parentCheck->bindInt(':language_id', $product['language_id']);
                             $parentCheck->execute();
                             $ifParent = ' and c.parent_id = :parent_id';
                             $catCheck->bindInt(':parent_id', $parentCheck->valueInt('categories_id'));
                         }
                         $catCheck->execute();
                         if ($lC_Database->isError()) {
                             die($lC_Database->getError());
                         }
                         if ($catCheck->numberOfRows() > 0) {
                             $category_ids[] = $catCheck->valueInt('categories_id');
                         } else {
                             // insert a category that doesnt exist
                             $QcatInsert = $lC_Database->query("insert into :table_categories (parent_id, categories_status, categories_mode) values (:parent_id, :categories_status, :categories_mode)");
                             $QcatInsert->bindTable(':table_categories', TABLE_CATEGORIES);
                             $QcatInsert->bindInt(':parent_id', 0);
                             $QcatInsert->bindInt(':categories_status', 1);
                             $QcatInsert->bindValue(':categories_mode', 'category');
                             $QcatInsert->execute();
                             if ($lC_Database->isError()) {
                                 $errormsg .= $lC_Database->getError();
                             } else {
                                 // if we did ok inserting to the main cat table lets do the description
                                 $currentCatId = $lC_Database->nextID();
                                 $QcatDescInsert = $lC_Database->query("insert into :table_categories_description (categories_id, language_id, categories_name) VALUES (:categories_id, :language_id, :categories_name)");
                                 $QcatDescInsert->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
                                 $QcatDescInsert->bindInt(':categories_id', $currentCatId);
                                 $QcatDescInsert->bindInt(':language_id', $product['language_id']);
                                 $QcatDescInsert->bindValue(':categories_name', $catName);
                                 $QcatDescInsert->execute();
                                 if ($lC_Database->isError()) {
                                     $errormsg .= 'descerr: ' . $lC_Database->getError();
                                 } else {
                                     // if were successful add the inserted id to the category ids
                                     $category_ids[] = $currentCatId;
                                     // get existing cat permalinks
                                     $Qquery = $lC_Database->query("select permalink from :table_permalinks where type = :type and language_id = :language_id");
                                     $Qquery->bindTable(':table_permalinks', TABLE_PERMALINKS);
                                     $Qquery->bindInt(':type', 1);
                                     $Qquery->bindInt(':language_id', $product['language_id']);
                                     $Qquery->execute();
                                     // make the array of existing permalinks
                                     while ($Qquery->next()) {
                                         $cat_pl_arr[] = $Qquery->value('permalink');
                                     }
                                     // what the new permalink is to be
                                     $cat_permalink = lC_Products_import_export_Admin::generate_clean_permalink($catName);
                                     // compare to existing cat permalinks and add random string to avoid duplicates if needed
                                     if (in_array($cat_permalink, $cat_pl_arr)) {
                                         $cat_permalink = $cat_permalink . '-' . self::randomString();
                                     }
                                     // lets get the query
                                     $parents = self::getParentsPath($currentCatId);
                                     if (empty($parents)) {
                                         $query = "cPath=" . $currentCatId;
                                     } else {
                                         $query = "cPath=" . implode("_", array_reverse(explode("_", str_replace("_0", "", self::getParentsPath($currentCatId))))) . "_" . $currentCatId;
                                     }
                                     $query = str_replace("cPath=0_", "cPath=", $query);
                                     // insert the new permalink
                                     $Qupdate = $lC_Database->query("insert into :table_permalinks (item_id, language_id, type, query, permalink) values (:item_id, :language_id, :type, :query, :permalink)");
                                     $Qupdate->bindTable(':table_permalinks', TABLE_PERMALINKS);
                                     $Qupdate->bindInt(':item_id', $currentCatId);
                                     $Qupdate->bindInt(':language_id', $product['language_id']);
                                     $Qupdate->bindInt(':type', 1);
                                     $Qupdate->bindValue(':query', $query);
                                     $Qupdate->bindValue(':permalink', $cat_permalink);
                                     $Qupdate->execute();
                                     $Qquery->freeResult();
                                     if ($lC_Database->isError()) {
                                         $error = true;
                                         break;
                                     }
                                 }
                             }
                             $catCheck->freeResult();
                         }
                     }
                 }
                 $product['categories'] = $category_ids;
                 $currentCatId = null;
                 $category_ids = null;
             }
             // build a cPath for later use
             $parents = self::getParentsPath($product['categories'][0]);
             if (empty($parents)) {
                 $query = "cPath=" . $product['categories'][0];
             } else {
                 $query = "cPath=" . implode("_", array_reverse(explode("_", str_replace("_0", "", self::getParentsPath($product['categories'][0]))))) . "_" . $product['categories'][0];
             }
             $query = str_replace("cPath=0_", "cPath=", $query);
             // need to get the id for the manufacturer
             if ($product['manufacturer'] != '') {
                 $Qman = $lC_Database->query("SELECT * FROM :table_manufacturers WHERE manufacturers_name = :manufacturers_name");
                 $Qman->bindTable(':table_manufacturers', TABLE_MANUFACTURERS);
                 $Qman->bindValue(':manufacturers_name', $product['manufacturer']);
                 $Qman->execute();
                 if ($Qman->numberOfRows()) {
                     $product['manufacturers_id'] = $Qman->value('manufacturers_id');
                 } else {
                     // insert a manufacture that doesn't exist
                     $QmanInsert = $lC_Database->query("INSERT INTO :table_manufacturers (manufacturers_name) VALUES (:manufacturers_name)");
                     $QmanInsert->bindTable(':table_manufacturers', TABLE_MANUFACTURERS);
                     $QmanInsert->bindValue(':manufacturers_name', $product['manufacturer']);
                     $QmanInsert->execute();
                     if ($lC_Database->isError()) {
                         $errormsg .= 'man insert err ' . $lC_Database->getError();
                     } else {
                         $product['manufacturers_id'] = $lC_Database->nextID();
                     }
                 }
             }
             // check for a match in the database
             $Qcheck = $lC_Database->query("SELECT * FROM :table_products WHERE products_id = :products_id");
             $Qcheck->bindTable(':table_products', TABLE_PRODUCTS);
             $Qcheck->bindInt(':products_id', $products_id);
             $Qcheck->execute();
             if ($Qcheck->numberOfRows()) {
                 // the product exists in the database so were just going to update the product with the new data
                 $match_count++;
                 $error = false;
                 $pdaParts = explode("/", $product['date_added']);
                 $products_date_added = date("Y-m-d H:i:s", mktime(0, 0, 0, $pdaParts[0], $pdaParts[1], $pdaParts[2]));
                 $lC_Database->startTransaction();
                 $Qproduct = $lC_Database->query('update :table_products set products_quantity = :products_quantity, products_cost = :products_cost, products_price = :products_price, products_msrp = :products_msrp, products_model = :products_model, products_sku = :products_sku, 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, products_date_added = :products_date_added WHERE products_id = :products_id');
                 $Qproduct->bindInt(':products_id', $products_id);
                 $Qproduct->bindValue(':products_date_added', $products_date_added);
                 $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
                 $Qproduct->bindValue(':products_quantity', $product['quantity']);
                 $Qproduct->bindValue(':products_cost', $product['cost']);
                 $Qproduct->bindValue(':products_price', $product['price']);
                 $Qproduct->bindValue(':products_msrp', $product['msrp']);
                 $Qproduct->bindValue(':products_model', $product['model']);
                 $Qproduct->bindValue(':products_sku', $product['sku']);
                 $Qproduct->bindValue(':products_weight', $product['weight']);
                 $Qproduct->bindInt(':products_weight_class', $product_weight_class_id);
                 $Qproduct->bindInt(':products_status', $product['status']);
                 $Qproduct->bindInt(':products_tax_class_id', $product['tax_class_id']);
                 $Qproduct->bindInt(':manufacturers_id', $product['manufacturers_id']);
                 $Qproduct->setLogging($_SESSION['module'], $products_id);
                 $Qproduct->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                     $errormsg .= '   initial: ' . $products_id . ' ' . $lC_Database->getError();
                 } else {
                     $Qcategories = $lC_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 ($lC_Database->isError()) {
                         $error = true;
                     } else {
                         $categories = $product['categories'];
                         if (isset($categories) && !empty($categories)) {
                             foreach ($categories as $category_id) {
                                 $Qp2c = $lC_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 ($lC_Database->isError()) {
                                     $error = true;
                                     break;
                                 }
                             }
                         }
                     }
                 }
                 if ($error === false) {
                     $Qpd = $lC_Database->query('update :table_products_description set products_name = :products_name, products_description = :products_description, products_keyword = :products_keyword, products_tags = :products_tags, products_url = :products_url WHERE products_id = :products_id AND language_id = :language_id');
                     $Qpd->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
                     $Qpd->bindInt(':products_id', $products_id);
                     $Qpd->bindInt(':language_id', $product['language_id']);
                     $Qpd->bindValue(':products_name', $product['name']);
                     $Qpd->bindValue(':products_description', $product['description']);
                     $Qpd->bindValue(':products_keyword', $product['permalink']);
                     $Qpd->bindValue(':products_tags', $product['tags']);
                     $Qpd->bindValue(':products_url', $product['url']);
                     $Qpd->setLogging($_SESSION['module'], $products_id);
                     $Qpd->execute();
                     if ($lC_Database->isError()) {
                         $error = true;
                         break;
                     }
                 }
                 if ($error === false) {
                     $Qquery = $lC_Database->query("select query from :table_permalinks where item_id = :item_id and type = :type and language_id = :language_id");
                     $Qquery->bindTable(':table_permalinks', TABLE_PERMALINKS);
                     $Qquery->bindInt(':item_id', $products_id);
                     $Qquery->bindInt(':language_id', $product['language_id']);
                     $Qquery->bindInt(':type', 2);
                     $Qquery->execute();
                     if ($Qquery->numberOfRows()) {
                         if ($query != $Qquery->value('query')) {
                             $Qupdate = $lC_Database->query("update :table_permalinks set query = :query where item_id = :item_id and type = :type and language_id = :language_id");
                             $Qupdate->bindTable(':table_permalinks', TABLE_PERMALINKS);
                             $Qupdate->bindInt(':item_id', $products_id);
                             $Qupdate->bindInt(':language_id', $product['language_id']);
                             $Qupdate->bindInt(':type', 2);
                             $Qupdate->bindValue(':query', $query);
                             $Qupdate->execute();
                             if ($lC_Database->isError()) {
                                 $error = true;
                                 break;
                             }
                         }
                     }
                     $Qquery->freeResult();
                 }
                 if ($error === false) {
                     $lC_Database->commitTransaction();
                     lC_Cache::clear('categories');
                     lC_Cache::clear('category_tree');
                     lC_Cache::clear('also_purchased');
                 } else {
                     $lC_Database->rollbackTransaction();
                     $errormsg .= '    Error on product id: ' . $products_id . '  ';
                 }
             } else {
                 // the product doesnt exist so lets write it into the database
                 $insert_count++;
                 $error = false;
                 $pdaParts = explode("/", $product['date_added']);
                 $products_date_added = '"' . date("Y-m-d H:i:s", mktime(0, 0, 0, $pdaParts[0], $pdaParts[1], $pdaParts[2])) . '"';
                 $lC_Database->startTransaction();
                 $Qproduct = $lC_Database->query('insert into :table_products (products_id, products_quantity, products_cost, products_price, products_msrp, products_model, products_sku, products_date_added, products_last_modified, products_weight, products_weight_class, products_status, products_tax_class_id, manufacturers_id, has_children) values (:products_id, :products_quantity, :products_cost, :products_price, :products_msrp, :products_model, :products_sku, :products_date_added, :products_last_modified, :products_weight, :products_weight_class, :products_status, :products_tax_class_id, :manufacturers_id, 0)');
                 $Qproduct->bindInt(':products_id', $products_id);
                 $Qproduct->bindRaw(':products_date_added', $products_date_added != '' ? $products_date_added : 'now()');
                 $Qproduct->bindRaw(':products_last_modified', 'now()');
                 $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
                 $Qproduct->bindInt(':products_quantity', $product['quantity']);
                 $Qproduct->bindFloat(':products_cost', $product['cost']);
                 $Qproduct->bindFloat(':products_price', $product['price']);
                 $Qproduct->bindFloat(':products_msrp', $product['msrp']);
                 $Qproduct->bindValue(':products_model', $product['model']);
                 $Qproduct->bindValue(':products_sku', $product['sku']);
                 $Qproduct->bindFloat(':products_weight', $product['weight']);
                 $Qproduct->bindInt(':products_weight_class', $product_weight_class_id);
                 $Qproduct->bindInt(':products_status', $product['status']);
                 $Qproduct->bindInt(':products_tax_class_id', $product['tax_class_id']);
                 $Qproduct->bindInt(':manufacturers_id', $product['manufacturers_id']);
                 $Qproduct->setLogging($_SESSION['module'], $products_id);
                 $Qproduct->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                 } else {
                     $Qcategories = $lC_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 ($lC_Database->isError()) {
                         $error = true;
                     } else {
                         $categories = $product['categories'];
                         if (isset($categories) && !empty($categories)) {
                             foreach ($categories as $category_id) {
                                 $Qp2c = $lC_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 ($lC_Database->isError()) {
                                     $error = true;
                                     break;
                                 }
                             }
                         }
                     }
                 }
                 if ($error === false) {
                     $Qimage = $lC_Database->query('insert into :table_products_images (products_id, image, default_flag, sort_order, date_added) values (:products_id, :image, :default_flag, :sort_order, :date_added)');
                     $Qimage->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
                     $Qimage->bindInt(':products_id', $products_id);
                     $Qimage->bindValue(':image', $product['base_image']);
                     $Qimage->bindInt(':default_flag', '1');
                     $Qimage->bindInt(':sort_order', 0);
                     $Qimage->bindRaw(':date_added', 'now()');
                     $Qimage->setLogging($_SESSION['module'], $products_id);
                     $Qimage->execute();
                     if ($lC_Database->isError()) {
                         $error = true;
                     }
                 }
                 if ($error === false) {
                     $Qpd = $lC_Database->query('insert into :table_products_description (products_id, language_id, products_name, products_description, products_keyword, products_tags, products_url) values (:products_id, :language_id, :products_name, :products_description, :products_keyword, :products_tags, :products_url)');
                     $Qpd->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
                     $Qpd->bindInt(':products_id', $products_id);
                     $Qpd->bindInt(':language_id', $product['language_id']);
                     $Qpd->bindValue(':products_name', $product['name']);
                     $Qpd->bindValue(':products_description', $product['description']);
                     $Qpd->bindValue(':products_keyword', $product['permalink']);
                     $Qpd->bindValue(':products_tags', $product['tags']);
                     $Qpd->bindValue(':products_url', $product['url']);
                     $Qpd->setLogging($_SESSION['module'], $products_id);
                     $Qpd->execute();
                     if ($lC_Database->isError()) {
                         $error = true;
                         break;
                     }
                 }
                 if ($error === false) {
                     $Qupdate = $lC_Database->query("insert into :table_permalinks (item_id, language_id, type, query, permalink) values (:item_id, :language_id, :type, :query, :permalink)");
                     $Qupdate->bindTable(':table_permalinks', TABLE_PERMALINKS);
                     $Qupdate->bindInt(':item_id', $products_id);
                     $Qupdate->bindInt(':language_id', $product['language_id']);
                     $Qupdate->bindInt(':type', 2);
                     $Qupdate->bindValue(':query', $query);
                     $Qupdate->bindValue(':permalink', $product['permalink']);
                     $Qupdate->execute();
                     if ($lC_Database->isError()) {
                         $error = true;
                         break;
                     }
                 }
                 if ($error === false) {
                     $lC_Database->commitTransaction();
                     lC_Cache::clear('categories');
                     lC_Cache::clear('category_tree');
                     lC_Cache::clear('also_purchased');
                 } else {
                     $lC_Database->rollbackTransaction();
                 }
             }
         }
     }
     // end if $do
     // for all left in array match and update the records
     // use columns from import to figure out what columns are what
     if ($errormsg) {
         $ipreturn['error'] = $errormsg;
     }
     if ($msg) {
         $ipreturn['msg'] = $msg;
     }
     if ($other) {
         $ipreturn['other'] = $other;
     }
     $ipreturn['matched'] = $match_count;
     $ipreturn['inserted'] = $insert_count;
     $ipreturn['total'] = $match_count + $insert_count;
     return $ipreturn;
 }
예제 #19
0
 public static function save($id = null, $data, $default = false)
 {
     global $lC_Database, $lC_Language;
     $error = false;
     $lC_Database->startTransaction();
     if (isset($id) && $id != null) {
         $customers_group_id = $id;
         // ISSUE: if we add a new language, editing values does not save the new language.
         // To cure this, we delete the old records first, then re-insert instead of update.
         lC_Customer_groups_Admin::delete($customers_group_id);
     } else {
         $Qgroups = $lC_Database->query('select max(customers_group_id) as customers_group_id from :table_customers_groups');
         $Qgroups->bindTable(':table_customers_groups', TABLE_CUSTOMERS_GROUPS);
         $Qgroups->execute();
         $customers_group_id = $Qgroups->valueInt('customers_group_id') + 1;
     }
     foreach ($lC_Language->getAll() as $l) {
         $group_name = str_replace('&#37;', '%', $data['name'][$l['id']]);
         $group_name = str_replace('&#64;', '@', $group_name);
         $Qgroups = $lC_Database->query('insert into :table_customers_groups (customers_group_id, language_id, customers_group_name) values (:customers_group_id, :language_id, :customers_group_name)');
         $Qgroups->bindTable(':table_customers_groups', TABLE_CUSTOMERS_GROUPS);
         $Qgroups->bindInt(':customers_group_id', $customers_group_id);
         $Qgroups->bindValue(':customers_group_name', $group_name);
         $Qgroups->bindInt(':language_id', $l['id']);
         $Qgroups->setLogging($_SESSION['module'], $customers_group_id);
         $Qgroups->execute();
         if ($lC_Database->isError()) {
             $error = true;
             break;
         }
     }
     if ($error === false) {
         if ($default === true) {
             $Qupdate = $lC_Database->query('update :table_configuration set configuration_value = :configuration_value where configuration_key = :configuration_key');
             $Qupdate->bindTable(':table_configuration', TABLE_CONFIGURATION);
             $Qupdate->bindInt(':configuration_value', $customers_group_id);
             $Qupdate->bindValue(':configuration_key', 'DEFAULT_CUSTOMERS_GROUP_ID');
             $Qupdate->setLogging($_SESSION['module'], $customers_group_id);
             $Qupdate->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
     }
     $Qgdata = $lC_Database->query('insert into :table_customers_groups_data (customers_group_id, baseline_discount) values (:customers_group_id, :baseline_discount)');
     $Qgdata->bindTable(':table_customers_groups_data', TABLE_CUSTOMERS_GROUPS_DATA);
     $Qgdata->bindInt(':customers_group_id', $customers_group_id);
     $Qgdata->bindFloat(':baseline_discount', $data['baseline']);
     $Qgdata->setLogging($_SESSION['module'], $customers_group_id);
     $Qgdata->execute();
     if ($lC_Database->isError()) {
         $error = true;
     }
     if ($error === false) {
         $lC_Database->commitTransaction();
         if ($default === true) {
             lC_Cache::clear('configuration');
         }
         return $customers_group_id;
     }
     $lC_Database->rollbackTransaction();
     return false;
 }
예제 #20
0
}
// include the list of project filenames
require $lC_Vqmod->modCheck('includes/filenames.php');
// include the list of project database tables
require $lC_Vqmod->modCheck('../includes/database_tables.php');
// include the utility class
require $lC_Vqmod->modCheck('../includes/classes/utility.php');
// instantiate the cache class
require $lC_Vqmod->modCheck('../includes/classes/cache.php');
$lC_Cache = new lC_Cache();
// initally set the language and template cache
if (!file_exists('includes/work/cache/langusges.cache')) {
    lC_Cache::clear('languages');
}
if (!file_exists('includes/work/cache/templates.cache')) {
    lC_Cache::clear('templates');
}
// include the administrators log class
if (file_exists('includes/applications/administrators_log/classes/administrators_log.php')) {
    include $lC_Vqmod->modCheck('includes/applications/administrators_log/classes/administrators_log.php');
}
// include the database class
require $lC_Vqmod->modCheck('../includes/classes/database.php');
$lC_Database = lC_Database::connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD);
$lC_Database->selectDatabase(DB_DATABASE);
// set application wide parameters
$Qcfg = $lC_Database->query('select configuration_key as cfgKey, configuration_value as cfgValue from :table_configuration');
$Qcfg->bindTable(':table_configuration', TABLE_CONFIGURATION);
$Qcfg->setCache('configuration');
$Qcfg->execute();
while ($Qcfg->next()) {
예제 #21
0
 public static function delete($id, $delete_image = false, $delete_products = false)
 {
     global $lC_Database;
     if ($delete_image === true) {
         $Qimage = $lC_Database->query('select manufacturers_image from :table_manufacturers where manufacturers_id = :manufacturers_id');
         $Qimage->bindTable(':table_manufacturers', TABLE_MANUFACTURERS);
         $Qimage->bindInt(':manufacturers_id', $id);
         $Qimage->execute();
         if ($Qimage->numberOfRows() && !lc_empty($Qimage->value('manufacturers_image'))) {
             if (file_exists(realpath('../' . DIR_WS_IMAGES . 'manufacturers/' . $Qimage->value('manufacturers_image')))) {
                 @unlink(realpath('../' . DIR_WS_IMAGES . 'manufacturers/' . $Qimage->value('manufacturers_image')));
             }
         }
     }
     $Qm = $lC_Database->query('delete from :table_manufacturers where manufacturers_id = :manufacturers_id');
     $Qm->bindTable(':table_manufacturers', TABLE_MANUFACTURERS);
     $Qm->bindInt(':manufacturers_id', $id);
     $Qm->setLogging($_SESSION['module'], $id);
     $Qm->execute();
     $Qmi = $lC_Database->query('delete from :table_manufacturers_info where manufacturers_id = :manufacturers_id');
     $Qmi->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO);
     $Qmi->bindInt(':manufacturers_id', $id);
     $Qmi->setLogging($_SESSION['module'], $id);
     $Qmi->execute();
     if ($delete_products === true) {
         $Qproducts = $lC_Database->query('select products_id from :table_products where manufacturers_id = :manufacturers_id');
         $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
         $Qproducts->bindInt(':manufacturers_id', $id);
         $Qproducts->execute();
         while ($Qproducts->next()) {
             lC_Products_Admin::delete($Qproducts->valueInt('products_id'));
         }
     } else {
         $Qupdate = $lC_Database->query('update :table_products set manufacturers_id = null where manufacturers_id = :manufacturers_id');
         $Qupdate->bindTable(':table_products', TABLE_PRODUCTS);
         $Qupdate->bindInt(':manufacturers_id', $id);
         $Qupdate->setLogging($_SESSION['module'], $id);
         $Qupdate->execute();
     }
     lC_Cache::clear('manufacturers');
     return true;
 }
예제 #22
0
 public static function updateRates($service)
 {
     global $lC_Database;
     $result = array();
     $updated_string = '';
     $not_updated_string = '';
     foreach (lc_toObjectInfo(self::getAll(-1))->get('entries') as $currency) {
         $rate = call_user_func('quote_' . $service . '_currency', $currency['code']);
         if (!empty($rate)) {
             $Qupdate = $lC_Database->query('update :table_currencies set value = :value, last_updated = now() where currencies_id = :currencies_id');
             $Qupdate->bindTable(':table_currencies', TABLE_CURRENCIES);
             $Qupdate->bindValue(':value', $rate);
             $Qupdate->bindInt(':currencies_id', $currency['currencies_id']);
             $Qupdate->setLogging($_SESSION['module'], $currency['currencies_id']);
             $Qupdate->execute();
             $updated_string .= $currency['title'] . ' (' . $currency['code'] . '), ';
         } else {
             $not_updated_string .= $currency['title'] . ' (' . $currency['code'] . '), ';
         }
     }
     if (!empty($updated_string)) {
         $updated_string = substr($updated_string, 0, -2);
     }
     if (!empty($not_updated_string)) {
         $not_updated_string = substr($not_updated_string, 0, -2);
     }
     $result['updatedString'] = $updated_string;
     $result['notUpdatedString'] = $not_updated_string;
     lC_Cache::clear('currencies');
     return $result;
 }
예제 #23
0
 public static function uninstall($module_name)
 {
     global $lC_Language, $lC_Vqmod;
     if (file_exists('../includes/modules/' . $_GET['set'] . '/' . $module_name . '.php')) {
         include_once $lC_Vqmod->modCheck('../includes/classes/modules.php');
         include $lC_Vqmod->modCheck('../includes/modules/' . $_GET['set'] . '/' . $module_name . '.php');
         $lC_Language->injectDefinitions('modules/' . $_GET['set'] . '/' . $module_name . '.xml');
         $class = 'lC_' . ucfirst($_GET['set']) . '_' . $module_name;
         $module = new $class();
         $module->remove();
         lC_Cache::clear('configuration');
         lC_Cache::clear('modules_' . $_GET['set']);
         lC_Cache::clear('templates_' . $_GET['set'] . '_layout');
         lC_Cache::clear('languages-en');
         return true;
     }
     return false;
 }
예제 #24
0
 public static function uninstall($key)
 {
     global $lC_Language, $lC_Vqmod;
     if (file_exists('includes/modules/geoip/' . $key . '.php')) {
         $lC_Language->loadIniFile('modules/geoip/' . $key . '.php');
         include $lC_Vqmod->modCheck('includes/modules/geoip/' . $key . '.php');
         $module = 'lC_GeoIP_' . $key;
         $module = new $module();
         $module->remove();
         lC_Cache::clear('modules-geoip');
         lC_Cache::clear('configuration');
         return true;
     }
     return false;
 }
예제 #25
0
 /**
  * Set Maintenance Mode
  *  
  * @access public      
  * @return boolean
  */
 public static function setMaintenanceMode($mode)
 {
     global $lC_Database;
     if ($mode == 'on') {
         $lC_Database->simpleQuery("update " . TABLE_CONFIGURATION . " set configuration_value = '1' where configuration_key = 'STORE_DOWN_FOR_MAINTENANCE'");
     } else {
         $lC_Database->simpleQuery("update " . TABLE_CONFIGURATION . " set configuration_value = '-1' where configuration_key = 'STORE_DOWN_FOR_MAINTENANCE'");
     }
     lC_Cache::clear('configuration');
     return true;
 }
예제 #26
0
 public static function uninstall($module_name)
 {
     global $lC_Vqmod;
     if (file_exists('includes/templates/' . $module_name . '.php')) {
         include $lC_Vqmod->modCheck('includes/templates/' . $module_name . '.php');
         $class = 'lC_Template_' . $module_name;
         $module = new $class();
         $module->remove();
         lC_Cache::clear('configuration');
         lC_Cache::clear('templates');
         return true;
     }
     return false;
 }
예제 #27
0
 public static function delete($id)
 {
     global $lC_Database;
     $error = false;
     $lC_Database->startTransaction();
     $Qrules = $lC_Database->query('delete from :table_weight_classes_rules where weight_class_from_id = :weight_class_from_id or weight_class_to_id = :weight_class_to_id');
     $Qrules->bindTable(':table_weight_classes_rules', TABLE_WEIGHT_CLASS_RULES);
     $Qrules->bindInt(':weight_class_from_id', $id);
     $Qrules->bindInt(':weight_class_to_id', $id);
     $Qrules->setLogging($_SESSION['module'], $id);
     $Qrules->execute();
     if ($lC_Database->isError()) {
         $error = true;
     }
     if ($error === false) {
         $Qclasses = $lC_Database->query('delete from :table_weight_classes where weight_class_id = :weight_class_id');
         $Qclasses->bindTable(':table_weight_classes', TABLE_WEIGHT_CLASS);
         $Qclasses->bindInt(':weight_class_id', $id);
         $Qclasses->setLogging($_SESSION['module'], $id);
         $Qclasses->execute();
         if ($lC_Database->isError()) {
             $error = true;
         }
     }
     if ($error === false) {
         $lC_Database->commitTransaction();
         lC_Cache::clear('weight-classes');
         lC_Cache::clear('weight-rules');
         return true;
     }
     $lC_Database->rollbackTransaction();
     return false;
 }
예제 #28
0
 /**
  * Remove the module configuration keys
  *
  * @access public
  * @return array
  */
 public function remove()
 {
     global $lC_Database, $lC_Language;
     if ($this->hasKeys()) {
         $Qdel = $lC_Database->query('delete from :table_configuration where configuration_key in (":configuration_key")');
         $Qdel->bindTable(':table_configuration', TABLE_CONFIGURATION);
         $Qdel->bindRaw(':configuration_key', implode('", "', $this->getKeys()));
         $Qdel->execute();
     }
     if (file_exists(DIR_FS_CATALOG . 'addons/' . $this->_code . '/languages/' . $lC_Language->getCode() . '.xml')) {
         foreach ($lC_Language->extractAddonDefinitions(DIR_FS_CATALOG . 'addons/' . $this->_code . '/languages/' . $lC_Language->getCode() . '.xml') as $def) {
             $Qdel = $lC_Database->query('delete from :table_languages_definitions where definition_key = :definition_key and content_group = :content_group');
             $Qdel->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
             $Qdel->bindValue(':definition_key', $def['key']);
             $Qdel->bindValue(':content_group', $def['group']);
             $Qdel->execute();
         }
         lC_Cache::clear('languages');
     }
 }
예제 #29
0
 public function uninstall($class)
 {
     global $lC_Vqmod;
     $result = array();
     if (file_exists('includes/modules/product_attributes/' . $class . '.php')) {
         include $lC_Vqmod->modCheck('includes/modules/product_attributes/' . $class . '.php');
         if (class_exists('lC_ProductAttributes_' . $class)) {
             $module = 'lC_ProductAttributes_' . $class;
             $module = new $module();
             if ($module->removeModule($module->getID(), $module->getCode())) {
             } else {
                 $result['rpcStatus'] = -1;
             }
         }
     } else {
         $result = lC_Addons_Admin::uninstallAdminAddonsProductAttributesModule($class);
     }
     lC_Cache::clear('addons');
     lC_Cache::clear('vqmoda');
     return $result;
 }
예제 #30
0
 public static function forget()
 {
     global $lC_Database;
     $Qcfg = $lC_Database->query('delete from :table_configuration where configuration_key = :configuration_key');
     $Qcfg->bindTable(':table_configuration', TABLE_CONFIGURATION);
     $Qcfg->bindValue(':configuration_key', 'DB_LAST_RESTORE');
     $Qcfg->setLogging($_SESSION['module']);
     $Qcfg->execute();
     if (!$lC_Database->isError()) {
         lC_Cache::clear('configuration');
         return true;
     }
     return false;
 }