public function __construct()
 {
     new Accesshandler("friends");
     if (loggedIn()) {
         new MenuItem(array("name" => "friends", "label" => translate("friends"), "page" => "friends", "menu" => "my_account", "weight" => 50));
         new MenuItem(array("name" => "friend_requests", "label" => translate("friend_requests"), "page" => "Friendrequests", "menu" => "my_account", "weight" => 100));
         new Usersetting(array("name" => "notify_when_friend_request_sent", "field_type" => "dropdown", "options" => array("email" => "Email", "site" => "Site", "both" => "Both", "none" => "None"), "tab" => "notifications", "default_value" => "both"));
         new Usersetting(array("name" => "notify_when_friend_request", "field_type" => "dropdown", "options" => array("email" => "Email", "site" => "Site", "both" => "Both", "none" => "None"), "tab" => "notifications", "default_value" => "both"));
         if (currentPage() == "profile" && pageArray(1)) {
             if (pageArray(1) != getLoggedInUserGuid()) {
                 if (!FriendsPlugin::requestSent(getLoggedInUserGuid(), pageArray(1))) {
                     if (!FriendsPlugin::friends(pageArray(1), getLoggedInUserGuid())) {
                         new MenuItem(array("name" => "add_friend", "label" => translate("add_friend"), "page" => addTokenToURL("action/addFriend/" . pageArray(1)), "menu" => "profile", "weight" => 10, "link_class" => "list-group-item list-group-item-info confirm"));
                     } else {
                         new MenuItem(array("name" => "remove_friend", "label" => translate("remove_friend"), "page" => addTokenToURL("action/removeFriend/" . pageArray(1)), "menu" => "profile", "weight" => 10, "link_class" => "list-group-item list-group-item-warning confirm"));
                     }
                 } else {
                     new MenuItem(array("name" => "friend_request_sent", "label" => translate("friendship_requested"), "page" => "friend", "menu" => "profile", "weight" => 20, "link_class" => "list-group-item confirm"));
                 }
             }
         }
     }
     new ViewExtension("profile/left", "friends/profile", "after");
     new ViewExtension('pages/home_stats', 'pages/friend_stats');
     new ViewExtension("user/buttons", "friends/friend_button");
 }
Example #2
0
 protected final function __construct($glob)
 {
     //Get the main config because it will be used
     if (isset($GLOBALS['db']) && ($result = $GLOBALS['db']->select('CubeCart_config', array('array'), array('name' => 'config'), false, 1, false, false)) !== false) {
         $array_out = $this->_json_decode($result[0]['array']);
     }
     //Remove the db password for safety
     unset($glob['dbpassword']);
     //Remove cache setting due to variable clash
     if (isset($glob['cache'])) {
         unset($glob['cache']);
     }
     if (!empty($array_out)) {
         $this->_config['config'] = $this->_clean($array_out);
         //Merge the main global with the config
         if (is_array($this->_config['config'])) {
             $this->_config['config'] = array_merge($this->_config['config'], $glob);
         }
     } else {
         $this->_config['config'] = $glob;
     }
     // Don't allow cache if current domain is not the real one.
     if (!isset($this->_config['config']['cookie_domain']) || empty($this->_config['config']['cookie_domain'])) {
         $cache = false;
     } elseif (!strstr(currentPage(), trim($this->_config['config']['cookie_domain'], '.'))) {
         $cache = false;
     } else {
         $cache = (bool) $this->_config['config']['cache'];
     }
     $GLOBALS['cache']->enable($cache);
     if (!$cache || defined('CC_IN_ADMIN') && CC_IN_ADMIN) {
         $GLOBALS['cache']->clear();
     }
 }
Example #3
0
 protected final function __construct()
 {
     if (isset($GLOBALS['session'])) {
         //If the language is trying to be changed try to change it
         if ((isset($_POST['set_language']) && ($switch = $_POST['set_language']) || isset($_GET['set_language']) && ($switch = $_GET['set_language'])) && $this->_valid($switch)) {
             $GLOBALS['session']->set('language', $switch, 'client');
             httpredir(currentPage(array('set_language')));
         } else {
             //See if the language is set in the session
             if (!CC_IN_ADMIN && $GLOBALS['session']->has('language', 'client')) {
                 $this->_language = $GLOBALS['session']->get('language', 'client');
             } elseif (CC_IN_ADMIN) {
                 $admin_lang = $GLOBALS['session']->get('user_language', 'admin');
                 $this->_language = !empty($admin_lang) ? $admin_lang : $GLOBALS['config']->get('config', 'default_language');
             } else {
                 //Try the default config language
                 $cl = $GLOBALS['config']->get('config', 'default_language');
                 $this->_language = !empty($cl) && file_exists(CC_ROOT_DIR . '/language/' . $cl . '.xml') && $this->_valid($cl) ? $cl : 'en-GB';
                 if (file_exists(CC_ROOT_DIR . '/language/' . $this->_language . '.xml')) {
                     //Set the language to the session
                     $GLOBALS['session']->set('language', $this->_language, 'client');
                 } else {
                     trigger_error('No valid language found!', E_USER_ERROR);
                 }
             }
         }
     } else {
         $this->_language = 'en-GB';
     }
     $GLOBALS['smarty']->assign("CURRENT_LANGUAGE", $this->_language);
     $this->loadLang();
 }
function pageHeading()
{
    include 'config/pages.config.inc.php';
    $currentPage = currentPage();
    // return $currentPage;
    return isset($pages->{$currentPage}->pageTitle) ? $pages->{$currentPage}->pageTitle : $pages->{$currentPage}->mainNavText;
}
 public function __construct($name, $weight = 500, $buttons = array())
 {
     if (currentPage() == "activity") {
         $activity_tabs = Cache::get("activity_tabs", "site");
         $activity_tabs[$name] = array("name" => $name, "weight" => $weight, "button" => $buttons);
         new Cache("activity_tabs", $activity_tabs, "site");
     }
 }
 public function __construct()
 {
     if (loggedIn()) {
         new MenuItem(array("name" => "profile", "label" => "My Profile", "page" => "profile/" . getLoggedInUserGuid(), "menu" => "my_account", "weight" => 0));
         if (currentPage() == "profile" && pageArray(1) == getLoggedInUserGuid()) {
             new MenuItem(array("name" => "edit_profile", "label" => "Edit Profile", "menu" => "profile", "page" => "editProfile", "list_class" => "active", "link_class" => "list-group-item list-group-item-danger"));
         } elseif (currentPage() == "home" && loggedIn()) {
             new MenuItem(array("name" => "view_my_profile", "label" => "View My Profile", "menu" => "profile", "page" => "profile/" . getLoggedInUserGuid(), "weight" => 10));
             new MenuItem(array("name" => "edit_profile", "label" => "Edit My Profile", "menu" => "profile", "page" => "editProfile", "link_class" => "list-group-item", "weight" => 20));
             if (isEnabledPlugin("members")) {
                 new MenuItem(array("name" => "members", "label" => "Browse Members", "menu" => "profile", "page" => "members", "weight" => 30));
             }
             if (isEnabledPlugin("inviteFriends")) {
                 new MenuItem(array("name" => "invite_friends", "label" => translate("invite_your_friends"), "menu" => "profile", "page" => "members", "weight" => 40));
             }
         }
         if (currentPage() == "profile" && adminLoggedIn()) {
             if (adminLoggedIn()) {
                 $guid = pageArray(1);
                 $user = getEntity($guid);
                 if (is_a($user, "SocialApparatus\\User")) {
                     if (!isAdmin($user)) {
                         new MenuItem(array("name" => "delete", "label" => "Delete User", "page" => "action/deleteUser/{$guid}", "menu" => "profile", "weight" => 100000, "list_class" => "active", "link_class" => "list-group-item list-group-item-danger confirm"));
                         new MenuItem(array("name" => "login_as", "label" => "Login As", "page" => "action/loginas/{$guid}", "menu" => "profile", "weight" => 90000, "list_class" => "active", "link_class" => "list-group-item list-group-item-danger confirm"));
                         if ($user->banned == "true") {
                             new MenuItem(array("name" => "unban", "label" => "Unban", "page" => "action/unbanUser/{$guid}", "menu" => "profile", "weight" => 80000, "list_class" => "active", "link_class" => "list-group-item list-group-item-danger confirm"));
                         } else {
                             new MenuItem(array("name" => "ban", "label" => "Ban", "page" => "action/banUser/{$guid}", "menu" => "profile", "weight" => 80000, "list_class" => "active", "link_class" => "list-group-item list-group-item-danger confirm"));
                         }
                     }
                 }
             }
         }
     }
     if (currentPage() == "profile") {
         new CSS("profile", getSitePath() . "core_plugins/profile/assets/css/profile.css");
         new FooterJS('profile', getSiteURL() . 'core_plugins/profile/assets/js/profile.js', 900, true);
     }
     if (currentPage() == "admin") {
         new ViewExtension("admin/tabs", "admin_tabs/profile_fields");
     }
     new ProfileField("first_name", "First Name", "text", false, false, "form-control", "default", 10);
     new ProfileField("last_name", "Last Name", "text", false, false, "form-control", "default", 20);
     new ProfileField("gender", "Gender", "dropdown", array("Male" => "Male", "Female" => "Female"));
     new ProfileField("birthday", "Birthday", "date");
     new ProfileField("about", "About Me", "textarea");
     new ProfileField("hobbies", "Hobbies", "tags");
     new StorageType("User", "about", "text");
     new ViewExtension("profile/right", "profile/activity");
 }
 function __construct()
 {
     new BlockedContentHandler("BlockedUserContentHandler");
     if (currentPage() == "profile") {
         $guid = pageArray(1);
         if ($guid != getLoggedInUserGuid()) {
             $user = getEntity($guid);
             if (!self::blocked($guid)) {
                 new MenuItem(array("name" => "block", "label" => "Block", "menu" => "profile", "page" => "action/blockUser/" . $guid, "link_class" => 'list-group-item list-group-item-danger'));
             } else {
                 new MenuItem(array("name" => "unblock", "label" => "Unblock", "menu" => "profile", "page" => "action/unBlockUser/" . $guid, "link_class" => "list-group-item list-group-item-success"));
             }
         }
     }
 }
Example #8
0
 public static function publishForPage()
 {
     Plugin_Hook::createTemp('content_load', function () {
         /* outprint the content data that has already been cached */
         currentPage()->publishContentHook();
     });
     /* if the script didn't require a new page we load the template for this one */
     Plugin_Hook::createTemp('script_load', function () {
         self::publishScripts();
     });
     Plugin_Hook::createTemp('meta_load', function () {
         currentPage()->publishMETA();
     });
     /* we need to load the template file for the site and inject our page content */
     self::requireTemplate();
 }
 function __construct()
 {
     if (loggedIn()) {
         if (currentPage() == "profile") {
             if (isEnabledPlugin("Friends")) {
                 $user_one = pageArray(1);
                 $user_two = getLoggedInUserGuid();
                 if (FriendsPlugin::friends($user_one, $user_two)) {
                     new MenuItem(array("name" => "chat", "menu" => "profile", "label" => "Chat", "page" => "action/CreateChat/" . $user_one, "link_class" => "list-group-item list-group-item-success"));
                 }
             }
         }
     }
     new ViewExtension("page_elements/foot", "chat/chat_boxes");
     new CSS("chat", getSitePath() . "core_plugins/chat/assets/css/chat.css", 400);
     new FooterJS("chat", getSiteURL() . "core_plugins/chat/assets/js/chat.js", 400, true);
     new Usersetting(array("name" => "notify_offline_chat", "field_type" => "dropdown", "options" => array("yes" => "Yes", "no" => "No"), "default_value" => "yes", "tab" => "notifications"));
 }
Example #10
0
 protected final function __construct()
 {
     $cache = Cache::getInstance();
     // Should we be showing prices?
     if (Config::getInstance()->get('config', 'catalogue_hide_prices') && !User::getInstance()->is() && !CC_IN_ADMIN && !$GLOBALS['session']->has('admin_id', 'admin_data')) {
         Session::getInstance()->set('hide_prices', true);
     } else {
         Session::getInstance()->delete('hide_prices');
     }
     // Switch Currency
     if (isset($_POST['set_currency']) && !empty($_POST['set_currency']) && ($switch = $_POST['set_currency']) || isset($_GET['set_currency']) && !empty($_GET['set_currency']) && ($switch = $_GET['set_currency'])) {
         if (preg_match('#^[A-Z]{3}$#i', $switch) && ($currency = $GLOBALS['db']->select('CubeCart_currency', array('updated'), array('code' => (string) $switch, 'active' => 1)))) {
             $GLOBALS['session']->set('currency', $switch, 'client');
         }
         httpredir(currentPage(array('set_currency')));
     }
     // Autoload tax tables
     $this->loadCurrencyVars();
 }
Example #11
0
 public function __construct()
 {
     if ($GLOBALS['config']->get('config', 'ssl') && !ADMIN_CP && !CC_SSL && !in_array($_GET['_g'], $this->_ignored_pages)) {
         $current_url = currentPage();
         $current_url = preg_replace('#^http://#', 'https://', $current_url);
         $ssl_url = $GLOBALS['config']->get('config', 'ssl_url');
         if (preg_match('#^' . $ssl_url . '#', $current_url)) {
             // Make sure the domain for SSL is expected
             httpredir($current_url, '', false, 301);
         } else {
             // If not we try to make it based on what we have
             $url_parts = parse_url($current_url);
             $url_parts['path'] = str_replace($GLOBALS['config']->get('config', 'ssl_path'), '/', $url_parts['path']);
             $ssl_url .= !empty($url_parts['path']) ? $url_parts['path'] : '';
             $ssl_url .= !empty($url_parts['query']) ? '?' . $url_parts['query'] : '';
             $anchor = !empty($url_parts['fragment']) ? '#' . $url_parts['fragment'] : '';
             httpredir($ssl_url, $anchor, false, 301);
         }
     }
 }
Example #12
0
 static function draw($scope = "internal")
 {
     $cssArray = Cache::get("css_array", "page");
     switch ($scope) {
         case "internal":
             return "<link href='" . getSiteURL() . "views/page_elements/css.php?page=" . currentPage() . "' rel='stylesheet' media='all'>";
             break;
         case "external":
             $return = NULL;
             if (is_array($cssArray)) {
                 foreach ($cssArray as $css) {
                     if (strpos($css['css'], "http") !== false) {
                         $return .= "<link href='" . $css['css'] . "' rel='stylesheet' media='all'>";
                     }
                 }
             }
             return $return;
             break;
     }
     return NULL;
 }
 public function process()
 {
     $coinbase_order = $this->coinbase->call("orders/" . $_GET["order"]["uuid"])->data;
     $order = Order::getInstance();
     if ($coinbase_order->status == "mispaid") {
         $order->orderStatus(Order::ORDER_PENDING, $this->order_number);
         $order->paymentStatus(Order::PAYMENT_PENDING, $this->order_number);
         $transData['notes'] = "Bitcoin payment mispaid";
         $order->logTransaction($transData);
         $GLOBALS['gui']->setError("Your Bitcoin payment was the incorrect amount. Please contact support to resolve your order.");
     } elseif ($coinbase_order->status == "expired") {
         $order->orderStatus(Order::ORDER_PENDING, $this->order_number);
         $order->paymentStatus(Order::PAYMENT_PENDING, $this->order_number);
         $transData['notes'] = "Bitcoin payment expired";
         $order->logTransaction($transData);
         $GLOBALS['gui']->setError("Your Bitcoin payment has expired before you could make your payment. Please contact support to resolve your order.");
     } else {
         $order->orderStatus(Order::ORDER_PROCESS, $this->order_number);
         $order->paymentStatus(Order::PAYMENT_SUCCESS, $this->order_number);
         $transData['notes'] = "Bitcoin payment successful";
         $order->logTransaction($transData);
     }
     httpredir(currentPage(array('_g', 'type', 'cmd', 'module'), array('_a' => 'complete')));
 }
     $module_type = preg_match("/[a-z]/i", $_GET['type']) ? $_GET['type'] : '';
     $GLOBALS['gui']->addBreadcrumb($lang['navigation']['nav_plugins'], '?_g=plugins');
     // Display Modules
     $GLOBALS['main']->wikiNamespace('Modules');
     if (!empty($_GET['module'])) {
         // Load Module
         $GLOBALS['main']->wikiPage($_GET['module']);
         // Load additional data from XML
         $config_xml = CC_ROOT_DIR . '/modules/' . $module_type . '/' . $_GET['module'] . '/config.xml';
         $xml = new SimpleXMLElement(file_get_contents($config_xml));
         $module_info = array('name' => (string) $xml->info->name);
         $module = array('type' => strtolower($module_type), 'module' => $module_type == 'installer' ? '' : $_GET['module']);
         $GLOBALS['gui']->addBreadcrumb(isset($_GET['variant']) ? $_GET['variant'] : $module_info['name'], $_GET);
         $module_admin = CC_ROOT_DIR . '/modules/' . $module['type'] . '/' . $module['module'] . '/admin/' . $node . '.inc.php';
         if (file_exists($module_admin)) {
             define('MODULE_FORM_ACTION', defined('VAL_SELF') ? constant('VAL_SELF') : currentPage());
             include $module_admin;
         } else {
             trigger_error(sprintf("File '%s' doesn't exist", $module_admin), E_USER_WARNING);
         }
     }
 } else {
     if (strtolower($_GET['_g']) == 'plugin' && isset($_GET['name'])) {
         // Include plugins
         $GLOBALS['main']->wikiNamespace('Plugins');
         foreach ($GLOBALS['hooks']->load('admin.' . strtolower($_GET['name'])) as $hook) {
             include $hook;
         }
     } else {
         if ($_GET['_g'] == '401') {
             $GLOBALS['gui']->setError($lang['navigation']['error_401']);
Example #15
0
 /**
  * Create order
  *
  * @param bool $force
  * @return bool
  */
 public function placeOrder($force_order = false)
 {
     foreach ($GLOBALS['hooks']->load('class.order.place_order') as $hook) {
         include $hook;
     }
     if ($_GET['retrieve'] && isset($_GET['cart_order_id']) && !empty($_GET['cart_order_id'])) {
         // Order retrieval
         if ($this->_retrieveOrder($_GET['cart_order_id'])) {
             httpredir(currentPage(array('cart_order_id', 'retrieve'), array('_a' => 'confirm')));
         }
     } else {
         if (!empty($this->_basket)) {
             // Order Creation/Updating
             $this->_saveAddresses();
             if (isset($this->_basket['cart_order_id']) && !empty($this->_basket['cart_order_id']) && ($check = $GLOBALS['db']->select('CubeCart_order_summary', array('cart_order_id'), array('cart_order_id' => $this->_basket['cart_order_id'], 'status' => 1), false, false, false, false))) {
                 // Order has already been placed and is still pending, so we only need to update
                 $this->_updateOrder();
                 $update = true;
             } else {
                 // Create a new order
                 $this->createOrderId();
                 // Take basket data from session, and insert into database
                 foreach ($this->_basket['contents'] as $key => $item) {
                     $product = $this->_orderAddProduct($item, $key);
                     $this->_basket['contents'][$key] = is_array($product) ? array_merge($product, $item) : $item;
                 }
                 $update = false;
             }
             // Shipping - calculate taxes (if any)
             if (isset($this->_basket['shipping']) && is_array($this->_basket['shipping'])) {
                 Tax::getInstance()->productTax($this->_basket['shipping']['value'], (int) $this->_basket['shipping']['tax_id'], false, 0, 'shipping');
             }
             // Insert Taxes
             $GLOBALS['db']->delete('CubeCart_order_tax', array('cart_order_id' => $this->_order_id));
             if (is_array($this->_basket['order_taxes'])) {
                 foreach ($this->_basket['order_taxes'] as $order_tax) {
                     $order_tax['cart_order_id'] = $this->_order_id;
                     $GLOBALS['db']->insert('CubeCart_order_tax', $order_tax);
                 }
             }
             if (isset($this->_basket['coupons']) && is_array($this->_basket['coupons'])) {
                 $codes_used = array();
                 foreach ($this->_basket['coupons'] as $key => $data) {
                     if ($data['gc']) {
                         // Update gift certificate balance
                         $GLOBALS['db']->update('CubeCart_coupons', array('discount_price' => $data['remainder']), array('code' => $data['voucher']));
                         $certificates_used[] = $data['voucher'];
                     } else {
                         $vouchers_used[] = $data['voucher'];
                         // Update usage count
                         $product_data = unserialize($data['product']);
                         if (is_array($product_data) && count($product_data) > 1) {
                             ## Per product coupons
                             foreach ($this->_basket['contents'] as $hash => $item) {
                                 if (!in_array($item['id'], $product_data)) {
                                     continue;
                                 }
                                 $GLOBALS['db']->update('CubeCart_coupons', array('count' => '+' . (int) $item['quantity']), array('code' => $data['voucher']));
                             }
                         } else {
                             $GLOBALS['db']->update('CubeCart_coupons', array('count' => '+1'), array('code' => $data['voucher']));
                         }
                     }
                 }
                 $note_content = '';
                 if (is_array($certificates_used)) {
                     $note_content .= "\r\n" . $GLOBALS['language']->orders['certificate_codes_used'] . "\r\n" . implode("\r\n", $certificates_used);
                 }
                 if (is_array($vouchers_used)) {
                     $note_content .= "\r\n" . $GLOBALS['language']->orders['discount_codes_used'] . "\r\n" . implode("\r\n", $vouchers_used);
                 }
                 $this->addNote($this->_order_id, $note_content);
             }
             // Set order as 'Pending'
             $this->_basket['order_status'] = constant('ORDER_PENDING');
             foreach ($GLOBALS['hooks']->load('class.order.place_order.basket') as $hook) {
                 include $hook;
             }
             // Insert/Update the order summary
             $this->_orderSummary($update, $force_order);
             $this->_manageStock(self::ORDER_PENDING, $this->_basket['cart_order_id']);
             $this->orderStatus(self::ORDER_PENDING, $this->_basket['cart_order_id'], true);
             if ($this->_basket['total'] == 0) {
                 $this->orderStatus(self::ORDER_PROCESS, $this->_basket['cart_order_id']);
                 httpredir(currentPage(null, array('_a' => 'complete')));
             }
             return true;
         }
     }
     // Go back to the basket page
     httpredir(currentPage(array('cart_order_id'), array('_a' => 'basket')));
     return false;
 }
Example #16
0
 $reviews = $GLOBALS['db']->select('CubeCart_reviews', false, $where, array($filter['field'] => $filter['sort']), $per_page, $page);
 if (isset($_GET['product_id']) && is_numeric($_GET['product_id'])) {
     $product = $GLOBALS['db']->select('CubeCart_inventory', array('name'), array('product_id' => (int) $_GET['product_id']));
 }
 if (!$reviews && isset($product) && $product) {
     $GLOBALS['main']->setACPWarning($lang['reviews']['error_reviews_none']);
     httpredir(currentPage(array('product_id')), 'search');
 }
 if ($reviews) {
     $GLOBALS['smarty']->assign('PAGINATION', $GLOBALS['db']->pagination(false, $per_page, $page, 9));
     foreach ($reviews as $review) {
         if (($product = $GLOBALS['db']->select('CubeCart_inventory', array('name'), array('product_id' => $review['product_id']))) !== false) {
             $review['product'] = $product[0];
             $review['date'] = formatTime($review['time']);
             $review['delete'] = currentPage(null, array('delete' => (int) $review['id']));
             $review['edit'] = currentPage(null, array('edit' => (int) $review['id']));
             $smarty_data['reviews'][] = $review;
         } else {
             $GLOBALS['db']->delete('CubeCart_reviews', array('product_id' => $review['product_id']));
         }
     }
     if (isset($smarty_data['reviews'])) {
         $GLOBALS['smarty']->assign('REVIEWS', $smarty_data['reviews']);
     }
 }
 $fields = array(array('value' => 'rating', 'name' => $lang['documents']['rating']), array('value' => 'time', 'name' => $lang['common']['date']));
 $sorts = array(array('value' => 'DESC', 'name' => $lang['category']['sort_high_low']), array('value' => 'ASC', 'name' => $lang['category']['sort_low_high']));
 $statuses = array(array('value' => '', 'name' => $lang['common']['all']), array('value' => '1', 'name' => $lang['common']['approved']), array('value' => '0', 'name' => $lang['common']['unapproved']));
 foreach ($fields as $field) {
     $field['selected'] = $field['value'] == $filter['field'] ? 'selected="selected"' : '';
     $smarty_data['fields'][] = $field;
Example #17
0
         $smarty_data['e_contents'][] = $content;
         unset($content);
     }
     $GLOBALS['smarty']->assign('EMAIL_CONTENTS', $smarty_data['e_contents']);
 }
 // List Templates
 if (($templates = $GLOBALS['db']->select('CubeCart_email_template')) !== false) {
     foreach ($templates as $template) {
         $template['clone'] = currentPage(null, array('action' => 'clone', 'type' => 'template', 'template_id' => $template['template_id']));
         $template['delete'] = currentPage(null, array('action' => 'delete', 'type' => 'template', 'template_id' => $template['template_id']));
         $template['edit'] = currentPage(null, array('action' => 'edit', 'type' => 'template', 'template_id' => $template['template_id']));
         $smarty_data['e_templates'][] = $template;
     }
     $GLOBALS['smarty']->assign('EMAIL_TEMPLATES', $smarty_data['e_templates']);
 }
 $GLOBALS['smarty']->assign('TEMPLATE_CREATE', currentPage(null, array('action' => 'create', 'type' => 'template')));
 // Importer
 $import = glob(CC_ROOT_DIR . '/language/email_*');
 if ($import) {
     foreach ($import as $source) {
         if (preg_match(Language::EMAIL_FILE, basename($source), $match)) {
             $emails[$match[1]] = basename($source);
         }
     }
     if (isset($emails)) {
         ksort($emails);
         foreach ($emails as $code => $file) {
             $smarty_data['imports'][] = array('code' => $code, 'file' => $file);
         }
     }
     $GLOBALS['smarty']->assign('EMAIL_IMPORT', $smarty_data['imports']);
Example #18
0
                        $GLOBALS['db']->update('CubeCart_inventory', $record, array('product_id' => (int) $product_id));
                    }
                }
            }
        }
    }
    $GLOBALS['main']->setACPNotify($lang['catalogue']['notify_assign_update']);
    httpredir(currentPage());
} elseif (isset($_POST['price'])) {
    $GLOBALS['main']->setACPWarning($lang['common']['error_no_change']);
}
$GLOBALS['main']->addTabControl($lang['catalogue']['title_product_list'], null, currentPage(array('node')));
$GLOBALS['main']->addTabControl($lang['catalogue']['product_add'], null, currentPage(array('node'), array('action' => 'add')));
$GLOBALS['main']->addTabControl($lang['catalogue']['title_category_assign_to'], 'assign');
$GLOBALS['main']->addTabControl($lang['catalogue']['title_option_set_assign'], null, currentPage(null, array('node' => 'optionsets')));
$GLOBALS['gui']->addBreadcrumb($lang['catalogue']['title_category_assigned'], currentPage());
## Product list
if (($products = $GLOBALS['db']->select('CubeCart_inventory', array('product_id', 'name', 'product_code'), false, array('name' => 'ASC'))) !== false) {
    $GLOBALS['smarty']->assign('PRODUCTS', $products);
}
## Category list
if (($category_array = $GLOBALS['db']->select('CubeCart_category', array('cat_name', 'cat_parent_id', 'cat_id'))) !== false) {
    $cat_list[] = '/';
    $seo = SEO::getInstance();
    foreach ($category_array as $category) {
        if ($category['cat_id'] == $category['cat_parent_id']) {
            continue;
        }
        $cat_list[$category['cat_id']] = '/' . $seo->getDirectory($category['cat_id'], false, '/', false, false);
    }
    natcasesort($cat_list);
Example #19
0
 /**
  * Load customer data
  */
 private function _load()
 {
     foreach ($GLOBALS['hooks']->load('class.user.load') as $hook) {
         include $hook;
     }
     if ($GLOBALS['session']->session_data['customer_id'] == '0') {
         return;
     }
     if ($GLOBALS['session']->session_data['customer_id'] && ($result = $GLOBALS['db']->select('CubeCart_customer', false, array('customer_id' => (int) $GLOBALS['session']->session_data['customer_id']), null, 1))) {
         $this->_user_data = $result[0];
         foreach ($GLOBALS['hooks']->load('class.user.load.user') as $hook) {
             include $hook;
         }
         $this->_logged_in = true;
         if (!$GLOBALS['session']->has('user_language', 'client')) {
             $GLOBALS['session']->set('user_language', isset($result[0]['language']) && preg_match(Language::LANG_REGEX, $result[0]['language']) ? $result[0]['language'] : $GLOBALS['config']->get('config', 'default_language'), 'client');
         }
         if ((empty($this->_user_data['email']) || !filter_var($this->_user_data['email'], FILTER_VALIDATE_EMAIL) || empty($this->_user_data['first_name']) || empty($this->_user_data['last_name'])) && !in_array(strtolower($_GET['_a']), array('profile', 'logout'))) {
             // Force account details page
             $GLOBALS['session']->set('temp_profile_required', true);
             httpredir(currentPage(null, array('_a' => 'profile')));
         }
     }
 }
            return "<?php 
echo addslashes(SITEPATH);
?>
";
        },
        pageArray: function () {
            return <?php 
echo json_encode(pageArray());
?>
;
        },
        secret: function () {
            return "<?php 
echo SITESECRET;
?>
";
        },
        loggedInUserGuid() {
            return "<?php 
echo getLoggedInUserGuid();
?>
";
        },
        currentPage:function() {
            return "<?php 
echo currentPage();
?>
";
        }
    };
</script><?php 
    }
    if (!isset($_GET['sort']) || !is_array($_GET['sort'])) {
        $_GET['sort'] = array('time' => 'DESC');
    }
    $current_page = currentPage(array('sort'));
    $thead_sort = array('cart_order_id' => $GLOBALS['db']->column_sort('cart_order_id', $GLOBALS['language']->orders['order_number'], 'sort', $current_page, $_GET['sort']), 'amount' => $GLOBALS['db']->column_sort('amount', $GLOBALS['language']->basket['total'], 'sort', $current_page, $_GET['sort']), 'gateway' => $GLOBALS['db']->column_sort('gateway', $GLOBALS['language']->orders['gateway_name'], 'sort', $current_page, $_GET['sort']), 'date' => $GLOBALS['db']->column_sort('time', $GLOBALS['language']->common['date'], 'sort', $current_page, $_GET['sort']));
    foreach ($GLOBALS['hooks']->load('admin.product.table_head_sort') as $hook) {
        include $hook;
    }
    $GLOBALS['smarty']->assign('THEAD', $thead_sort);
    if (($transactions = $GLOBALS['db']->select('CubeCart_transactions', array('DISTINCT' => 'order_id', 'time', 'amount', 'gateway', 'trans_id'), $where, $_GET['sort'], $per_page, $page)) !== false) {
        if (isset($_GET['search']) && !empty($_GET['search'])) {
            $GLOBALS['main']->setACPNotify(sprintf($GLOBALS['language']->orders['notify_search_logs'], $_GET['search']));
        }
        foreach ($transactions as $transaction) {
            if (!empty($transaction['order_id'])) {
                $transaction['time'] = formatTime($transaction['time']);
                $transaction['amount'] = Tax::getInstance()->priceFormat($transaction['amount']);
                $transaction['link'] = currentPage(array('page', 'sort'), array('order_id' => $transaction['order_id']));
                $smarty_data['transactions'][] = $transaction;
            }
        }
        $GLOBALS['smarty']->assign('ALL_TRANSACTIONS', $smarty_data['transactions']);
    } else {
        if (isset($_GET['search']) && !empty($_GET['search']) && !$transactions) {
            $GLOBALS['gui']->setError(sprintf($GLOBALS['language']->orders['error_search_logs'], $_GET['search']));
        }
    }
    $GLOBALS['smarty']->assign('DISPLAY_ALL_TRANSACTIONS', true);
}
$page_content = $GLOBALS['smarty']->fetch('templates/orders.transactions.php');
        }
        $GLOBALS['smarty']->assign('PASSWORD', true);
        break;
    default:
        switch (true) {
            case isset($_GET['redir']) && !empty($_GET['redir']):
                $redir = $_GET['redir'];
                break;
            case isset($_POST['redir']) && !empty($_POST['redir']):
                $redir = $_POST['redir'];
                break;
            default:
                $redir = currentPage();
        }
        if (isset($_GET['redir']) && !empty($_GET['redir']) && preg_match('/^(http(s?)\\:\\/\\/|ftp\\:\\/\\/|\\/\\/)/i', $redir)) {
            httpredir(currentPage(array('redir')));
        }
        if ($GLOBALS['config']->get('config', 'ssl')) {
            $current_page = currentPage();
            if (CC_SSL) {
                $ssl = array('url' => preg_replace('#^https#', 'http', $current_page), 'icon' => $GLOBALS['config']->get('config', 'adminFolder') . '/skins/' . $GLOBALS['config']->get('config', 'admin_skin') . '/images/ssl_true.png', 'state' => true);
            } else {
                $ssl = array('url' => preg_replace('#^http#', 'https', $current_page), 'icon' => $GLOBALS['config']->get('config', 'adminFolder') . '/skins/' . $GLOBALS['config']->get('config', 'admin_skin') . '/images/ssl_false.png', 'state' => true);
            }
            $GLOBALS['smarty']->assign('SSL', $ssl);
        }
        if (isset($redir) && !empty($redir)) {
            $GLOBALS['smarty']->assign('REDIRECT_TO', $redir);
        }
}
$GLOBALS['gui']->displayCommon();
Example #23
0
 /**
  * Add item to the basket
  *
  * @param int $product_id
  * @param array $optionsArray
  * @param int $quantity
  * @return bool
  */
 public function add($product_id, $optionsArray = null, $quantity = 1)
 {
     foreach ($GLOBALS['hooks']->load('class.cart.add.pre') as $hook) {
         include $hook;
     }
     // Prevent quantities of less than one or non numerical user input
     if (!is_numeric($quantity) || $quantity < 1) {
         $quantity = 1;
     }
     // Don't allow products to be added to the basket if prices are hidden AND they're not logged in
     if ($GLOBALS['session']->get('hide_prices')) {
         if (isset($_GET['_g']) && $_GET['_g'] == 'ajaxadd') {
             $path = $GLOBALS['seo']->buildURL('prod', $_POST['add']);
             $GLOBALS['debug']->supress();
             die('Redir:' . $path);
         } else {
             httpredir(currentPage());
         }
     }
     // Handle gift certs
     $gc = $GLOBALS['config']->get('gift_certs');
     if (isset($gc['product_code']) && $product_id == $gc['product_code'] && !empty($optionsArray)) {
         $hash = md5(recursive_implode('{@}', $optionsArray));
         if (isset($this->basket['contents'][$hash])) {
             // Increment quantity
             $this->basket['contents'][$hash]['quantity'] += $quantity;
             $product = $GLOBALS['catalogue']->getProductData($this->basket['contents'][$hash]['id']);
             $this->basket['contents'][$hash]['total_price_each'] = $product['price'] + $this->basket['contents'][$hash]['option_line_price'];
         } else {
             // Add to basket
             $this->basket['contents'][$hash] = array('id' => $product_id, 'quantity' => $quantity, 'digital' => $optionsArray['method'] == 'e' ? true : false, 'certificate' => array('value' => $optionsArray['value'], 'name' => $optionsArray['name'], 'email' => $optionsArray['email'], 'message' => $optionsArray['message']));
         }
         $this->save();
         httpredir($GLOBALS['config']->get('config', 'basket_jump_to') ? $GLOBALS['rootRel'] . 'index.php?_a=basket' : currentPage(null));
         return true;
     } else {
         if (!is_null($product_id) && is_numeric($product_id)) {
             $proceed = true;
             $options_identifier_string = $GLOBALS['catalogue']->defineOptionsIdentifier($optionsArray);
             $product = $GLOBALS['catalogue']->getProductData($product_id, 1, false, 10, 1, false, $options_identifier_string);
             if ($product) {
                 // Check for options
                 $options = $GLOBALS['catalogue']->getProductOptions($product_id);
                 if ($GLOBALS['catalogue']->getOptionRequired() && ($options && empty($optionsArray))) {
                     // Options needed - Redirect to product page
                     // Set GUI_MESSAGE error, then redirect
                     $GLOBALS['gui']->setError($GLOBALS['language']->catalogue['error_option_required']);
                     $this->redirectToProductPage($product_id);
                     return true;
                 } else {
                     // Check required options have a value!
                     $quantity = is_numeric($quantity) && $quantity > 0 ? $quantity : 1;
                     $stock_level = $GLOBALS['catalogue']->getProductStock($product['product_id'], $options_identifier_string);
                     // Check stock level
                     if ($product['use_stock_level'] && !$GLOBALS['config']->get('config', 'basket_out_of_stock_purchase')) {
                         if ($stock_level <= 0) {
                             $max_stock = 0;
                         } else {
                             $max_stock = $stock_level;
                         }
                     }
                     if (isset($max_stock) && $max_stock <= 0) {
                         if (is_array($optionsArray)) {
                             $stock_note = $GLOBALS['session']->has('restock_note') ? $GLOBALS['session']->get('restock_note') : '';
                             $GLOBALS['session']->delete('restock_note');
                             $GLOBALS['gui']->setError($GLOBALS['language']->catalogue['error_no_stock_available_options'] . ' ' . $stock_note);
                         } else {
                             $GLOBALS['gui']->setError($GLOBALS['language']->catalogue['error_no_stock_available']);
                         }
                         $this->redirectToProductPage($product_id);
                         return false;
                     }
                     $this->checkMinimumProductQuantity($product_id, $quantity, true);
                     // Add item to basket
                     $hash = md5($product['product_id'] . (!empty($optionsArray) ? $product['name'] . recursive_implode('{@}', $optionsArray) : $product['name']));
                     if (isset($this->basket['contents'][$hash])) {
                         // Update quantity
                         if (isset($max_stock)) {
                             $current = $this->basket['contents'][$hash]['quantity'];
                             $request = $current + $quantity;
                             if ($request > $max_stock) {
                                 $GLOBALS['gui']->setError($GLOBALS['language']->checkout['error_too_many_added']);
                                 $quantity = $max_stock - $current;
                                 $stock_warning = true;
                             }
                         }
                         $this->basket['contents'][$hash]['quantity'] += $quantity;
                     } else {
                         // Add to basket
                         if (isset($max_stock) && $quantity > $max_stock) {
                             $GLOBALS['gui']->setError($GLOBALS['language']->checkout['error_too_many_added']);
                             $quantity = $max_stock;
                             $stock_warning = true;
                         }
                         $this->basket['contents'][$hash] = array('id' => $product_id, 'quantity' => $quantity, 'digital' => $product['digital']);
                         if ($options && !empty($optionsArray)) {
                             // Add options to the basket item
                             foreach ($optionsArray as $option_id => $option_value) {
                                 $required = $GLOBALS['db']->select('CubeCart_option_group', array('option_required', 'option_type'), array('option_id' => (int) $option_id));
                                 $require = $required ? (bool) $required[0]['option_required'] : false;
                                 $add_option = true;
                                 if (is_array($option_value)) {
                                     foreach (array_values($option_value) as $value) {
                                         if ($add_option && !$this->_checkOption($value, $require)) {
                                             $add_option = false;
                                             $proceed = false;
                                         } else {
                                             if (empty($option_value)) {
                                                 $add_option = false;
                                             } else {
                                                 $imploded = implode('', $option_value);
                                                 if (empty($imploded)) {
                                                     $add_option = false;
                                                 }
                                             }
                                         }
                                     }
                                 } else {
                                     if ($add_option && !$this->_checkOption($option_value, $require)) {
                                         $add_option = false;
                                         $proceed = false;
                                     } else {
                                         if (empty($option_value) && !is_numeric($option_value)) {
                                             $add_option = false;
                                         }
                                     }
                                 }
                                 if ($add_option) {
                                     $this->basket['contents'][$hash]['options'][$option_id] = $option_value;
                                 } else {
                                     if (!$proceed) {
                                         // Product can't be added without required option
                                         unset($this->basket['contents'][$hash]);
                                         break;
                                     }
                                 }
                             }
                             $this->basket['contents'][$hash]['options_identifier'] = $options_identifier_string;
                             if (!$proceed) {
                                 // No required options selected
                                 if (isset($_GET['_g']) && $_GET['_g'] == 'ajaxadd') {
                                     $GLOBALS['gui']->setError($GLOBALS['language']->catalogue['error_option_required']);
                                     $this->redirectToProductPage($product_id);
                                 } else {
                                     httpredir(currentPage(null, array('error' => 'option')));
                                 }
                                 return false;
                             }
                         }
                     }
                     foreach ($GLOBALS['hooks']->load('class.cart.add.save') as $hook) {
                         include $hook;
                     }
                     //Save before the jump
                     $this->save();
                     foreach ($GLOBALS['hooks']->load('class.cart.add.preredirect') as $hook) {
                         include $hook;
                     }
                     // Jump to basket, or return to product page?
                     $jumpto = $GLOBALS['config']->get('config', 'basket_jump_to') ? $GLOBALS['rootRel'] . 'index.php?_a=basket' : currentPage(null);
                     if (isset($_GET['_g']) && $_GET['_g'] == 'ajaxadd' && $GLOBALS['config']->get('config', 'basket_jump_to')) {
                         $GLOBALS['debug']->supress();
                         die($GLOBALS['seo']->rewriteUrls("Redir:" . $jumpto, true));
                     } elseif (isset($_GET['_g']) && $_GET['_g'] == 'ajaxadd') {
                         $GLOBALS['debug']->supress();
                         if ($stock_warning) {
                             die('Redir:' . $GLOBALS['rootRel'] . 'index.php?_a=basket');
                         }
                     } else {
                         httpredir($jumpto);
                     }
                     return true;
                 }
             }
         }
     }
     return false;
 }
Example #24
0
 * ========================================
 * CubeCart is a registered trade mark of CubeCart Limited
 * Copyright CubeCart Limited 2015. All rights reserved.
 * UK Private Limited Company No. 5323904
 * ========================================
 * Web:   http://www.cubecart.com
 * Email:  sales@cubecart.com
 * License:  GPL-3.0 https://www.gnu.org/licenses/quick-guide-gplv3.html
 */
if (!defined('CC_INI_SET')) {
    die('Access Denied');
}
Admin::getInstance()->permissions('statistics', CC_PERM_READ, true);
global $lang;
if (isset($_POST['select'])) {
    httpredir(currentPage(null, $_POST['select']));
}
$select['year'] = isset($_GET['year']) && is_numeric($_GET['year']) ? (int) $_GET['year'] : date('Y');
$select['month'] = isset($_GET['month']) && in_array($_GET['month'], range(1, 12)) ? str_pad((int) $_GET['month'], 2, '0', STR_PAD_LEFT) : date('m');
$select['day'] = isset($_GET['day']) && in_array($_GET['day'], range(1, 31)) ? str_pad((int) $_GET['day'], 2, '0', STR_PAD_LEFT) : date('d');
$select['status'] = isset($_GET['status']) && in_array($_GET['status'], range(1, 6)) ? (int) $_GET['status'] : 3;
// Sales
$GLOBALS['main']->addTabControl($lang['statistics']['title_sales'], 'stats_sales');
$earliest_order = $GLOBALS['db']->select('CubeCart_order_summary', array('MIN' => 'order_date'), array('status' => $select['status']), array('order_date' => 'ASC'));
// $earliest_order will always return true but MIN_order_date may not have a value
$yearly = $monthly = $daily = $hourly = array();
if (!empty($earliest_order[0]['MIN_order_date'])) {
    $earliest = array('year' => date('Y', $earliest_order[0]['MIN_order_date']), 'month' => date('m', $earliest_order[0]['MIN_order_date']), 'day' => date('d', $earliest_order[0]['MIN_order_date']));
    $orders_all = $GLOBALS['db']->select('CubeCart_order_summary', array('total', 'cart_order_id', 'order_date'), array('status' => (int) $select['status']));
    if ($orders_all) {
        foreach ($orders_all as $key => $data) {
Example #25
0
 /**
  * Display product detail page
  *
  * @param int $product
  * @param bool $popularity
  * @return bool
  */
 public function displayProduct($product = false, $popularity = false)
 {
     if (isset($product) && is_numeric($product)) {
         if (($product = $this->getProductData($product)) !== false) {
             $product['condition'] = $GLOBALS['language']->common[$product['condition']];
             $meta_data = array('name' => $product['name'], 'path' => null, 'description' => $product['seo_meta_description'], 'keywords' => $product['seo_meta_keywords'], 'title' => $product['seo_meta_title']);
             $GLOBALS['seo']->set_meta_data($meta_data);
             // Update popularity
             if ($popularity) {
                 $this->_productPopularity($product['product_id']);
             }
             if (isset($_GET['error']) && !empty($_GET['error'])) {
                 switch (strtolower($_GET['error'])) {
                     case 'option':
                         $GLOBALS['gui']->setError($GLOBALS['language']->catalogue['error_option_required']);
                         break;
                     default:
                         // No error defined
                         break;
                 }
             }
             $this->productAssign($product);
             // Show manfacturer
             if (($manufacturer = $this->getManufacturer($product['manufacturer'])) !== false) {
                 $GLOBALS['smarty']->assign('MANUFACTURER', $manufacturer);
             }
             // Display gallery
             $GLOBALS['smarty']->assign('GALLERY', $this->_productGallery($product['product_id']));
             $product_options = $this->displayProductOptions($product['product_id']);
             $GLOBALS['smarty']->assign('OPTIONS', $product_options);
             $allow_purchase = true;
             $out = $hide = false;
             if ((bool) $product['use_stock_level']) {
                 // Get Stock Level
                 $stock_level = $product_options ? $this->getProductStock($product['product_id'], null, true) : $product['stock_level'];
                 $product['stock_level'] = $stock_level > 0 ? $stock_level : 0;
                 if ((int) $stock_level <= 0) {
                     // Out of Stock
                     if (!$GLOBALS['config']->get('config', 'basket_out_of_stock_purchase')) {
                         // Not Allowed
                         $allow_purchase = false;
                         $out = true;
                     }
                 }
             }
             if ($GLOBALS['session']->get('hide_prices')) {
                 $allow_purchase = false;
                 $hide = true;
             }
             $GLOBALS['smarty']->assign('CTRL_ALLOW_PURCHASE', $allow_purchase);
             $GLOBALS['smarty']->assign('CTRL_HIDE_PRICES', $hide);
             $GLOBALS['smarty']->assign('CTRL_OUT_OF_STOCK', $out);
             $GLOBALS['smarty']->assign('REVIEW_SCORE_MAX', 5);
             //Are we displaying reviews, or the "tell-a-friend" form?
             $GLOBALS['smarty']->assign('CTRL_REVIEW', (bool) $GLOBALS['config']->get('config', 'enable_reviews'));
             // Display Reviews
             $page = isset($_GET['page']) && !empty($_GET['page']) ? $_GET['page'] : 1;
             $per_page = 5;
             if (($reviews = $GLOBALS['db']->select('CubeCart_reviews', false, array('approved' => 1, 'product_id' => $product['product_id']), 'time DESC', $per_page, $page)) !== false) {
                 if (($paginate = $GLOBALS['db']->select('CubeCart_reviews', 'SUM(`rating`) AS Score, COUNT(`id`) as Count', array('approved' => 1, 'product_id' => $product['product_id']))) !== false) {
                     $review_count = (int) $paginate[0]['Count'];
                     $review_score = $paginate[0]['Score'];
                     $GLOBALS['smarty']->assign('PAGINATION', $GLOBALS['db']->pagination($review_count, $per_page, $page));
                 }
                 foreach ($reviews as $review) {
                     if ($review['anon']) {
                         $review['name'] = $GLOBALS['language']->catalogue['review_anon'];
                     }
                     $review['date'] = formatTime($review['time']);
                     $review['date_schema'] = formatTime($review['time'], '%G-%m-%d', true);
                     $review['gravatar'] = md5(strtolower(trim($review['email'])));
                     $review['gravatar_src'] = 'http://www.gravatar.com/avatar/' . $review['gravatar'] . '?d=404&r=g';
                     $headers = get_headers($review['gravatar_src']);
                     $review['gravatar_exists'] = strstr($headers[0], '200') ? true : false;
                     $vars[] = $review;
                 }
                 $GLOBALS['smarty']->assign('REVIEWS', $vars);
                 $GLOBALS['smarty']->assign('REVIEW_COUNT', (int) $review_count);
                 $GLOBALS['smarty']->assign('REVIEW_AVERAGE', round($review_score / $review_count, 1));
             }
             for ($i = 1; $i <= 5; ++$i) {
                 $star = array('value' => $i, 'checked' => isset($_POST['rating']['rating']) && $_POST['rating']['rating'] == $i ? 'checked="checked"' : '');
                 $vars['rating_stars'][] = $star;
                 $GLOBALS['smarty']->assign('RATING_STARS', $vars['rating_stars']);
             }
             $product['url'] = $GLOBALS['seo']->buildURL('prod', $product['product_id'], '&');
             // Get stock level variations for options
             if ($product_options && ($stock_variations = $GLOBALS['db']->select('CubeCart_option_matrix', 'MAX(stock_level) AS max_stock, MIN(stock_level) AS min_stock', array('product_id' => $product['product_id'], 'use_stock' => 1, 'status' => 1), false, 1))) {
                 if (is_numeric($stock_variations[0]['min_stock']) && is_numeric($stock_variations[0]['max_stock'])) {
                     $product['stock_level'] = $stock_variations[0]['min_stock'] == $stock_variations[0]['max_stock'] ? $stock_variations[0]['max_stock'] : $stock_variations[0]['min_stock'] . ' - ' . $stock_variations[0]['max_stock'];
                 }
             }
             $product['stock_level'] = $GLOBALS['config']->get('config', 'stock_level') == '1' ? $product['stock_level'] : false;
             $GLOBALS['smarty']->assign('PRODUCT', $product);
         }
         if (($category = $GLOBALS['db']->select('CubeCart_category_index', false, array('product_id' => (int) $product['product_id'], 'primary' => 1), array('priority' => 'DESC'), 1)) !== false) {
             $string = $GLOBALS['seo']->getDirectory($category[0]['cat_id'], true, '|');
             $cats = explode('|', $string);
             if (is_array($cats)) {
                 foreach ($cats as $cat) {
                     if (preg_match('#^<a href="(.*)">(.*)</a>$#', $cat, $match)) {
                         $GLOBALS['gui']->addBreadcrumb($match[2], $match[1]);
                     }
                 }
             }
             $GLOBALS['gui']->addBreadcrumb($product['name'], currentPage());
         }
         // Output to main GUI
         foreach ($GLOBALS['hooks']->load('class.cubecart.display_product') as $hook) {
             include $hook;
         }
         $content = $GLOBALS['smarty']->fetch('templates/content.product.php');
         $GLOBALS['smarty']->assign('SECTION_NAME', 'product');
         $GLOBALS['smarty']->assign('PAGE_CONTENT', $content);
         return true;
     }
     return false;
 }
Example #26
0
<?php

session_start();
define('DB_NAME', 'dream');
define('DB_USER', 'da');
define('DB_PASSWORD', 'dream-admin2015');
include_once '../include/functions.php';
include_once '../include/DBF.php';
$user = "******";
if (notNull($_SESSION) && notNull($_SESSION['user'])) {
    $user = $_SESSION['user'];
}
$url = explode("/", currentPage());
$page = $url[sizeof($url) - 1];
$myDB = new DBFactory();
$sql = $myDB->getMysqlConnexionWithPDO();
$sql->beginTransaction();
try {
    $statement = "INSERT INTO deadlinks (link) VALUES(:link)";
    $query = $sql->prepare($statement);
    $query->execute(array('link' => currentPage()));
    $sql->commit();
} catch (Exception $e) {
    $sql->rollBack();
}
logWarning($user, 2, $user . " requested a dead link : " . currentPage());
?>
<h1>404</h1>
<p>La page que vous avez demand&eacute; n'existe pas ou plus</p>
<a href="/">Retourner &agrave; l'accueil</a>
Example #27
0
        } else {
            $full = $_POST['drop'] && $_POST['structure'] && $_POST['data'] ? '_full' : '';
            $fileName = CC_ROOT_DIR . '/backup/database' . $full . '_' . CC_VERSION . '_' . $glob['dbdatabase'] . "_" . date("dMy-His") . '.sql';
            $all_tables = isset($_POST['db_3rdparty']) && $_POST['db_3rdparty'] == '1' ? true : false;
            $write = $GLOBALS['db']->doSQLBackup($_POST['drop'], $_POST['structure'], $_POST['data'], $fileName, $_POST['compress'], $all_tables);
            if ($write) {
                $GLOBALS['main']->setACPNotify($lang['maintain']['db_backup_complete']);
            } else {
                $GLOBALS['main']->setACPWarning($lang['maintain']['db_backup_failed']);
            }
        }
        $clear_post = true;
    }
}
if ($clear_post) {
    httpredir(currentPage(array('clearLogs', 'emptyErrorLogs')));
}
########## Tabs ##########
$GLOBALS['main']->addTabControl($lang['maintain']['tab_rebuild'], 'rebuild');
$GLOBALS['main']->addTabControl($lang['maintain']['tab_backup'], 'backup');
$GLOBALS['main']->addTabControl($lang['common']['upgrade'], 'upgrade');
$GLOBALS['main']->addTabControl($lang['maintain']['tab_db'], 'database');
$GLOBALS['main']->addTabControl($lang['maintain']['tab_query_sql'], 'general', '?_g=maintenance&node=sql');
##########
## Database
if (isset($database_result) && $database_result) {
    $GLOBALS['smarty']->assign('TABLES_AFTER', $database_result);
} elseif (($tables = $GLOBALS['db']->getRows()) !== false) {
    foreach ($tables as $table) {
        $table['Data_free'] = $table['Data_free'] > 0 ? formatBytes($table['Data_free'], true) : '-';
        $table_size = $table['Data_length'] + $table['Index_length'];
Example #28
0
## Delete Tax Rule
if (isset($_GET['delete_rule']) && !empty($_GET['delete_rule']) && Admin::getInstance()->permissions('settings', CC_PERM_DELETE)) {
    if ($GLOBALS['db']->delete('CubeCart_tax_rates', array('id' => (int) $_GET['delete_rule']))) {
        $GLOBALS['main']->setACPNotify($lang['settings']['notify_tax_rule_delete']);
    } else {
        $GLOBALS['main']->setACPWarning($lang['settings']['error_tax_rule_delete']);
    }
    $redirect = true;
    $anchor = 'taxrules';
}
if ($updated) {
    ## Generic message as a few things can be updated at once
    $GLOBALS['main']->setACPNotify($lang['settings']['notify_tax_updated']);
}
if ($redirect) {
    httpredir(currentPage(array('delete_class', 'delete_detail', 'delete_rule')), $anchor);
}
###############################################################
## Get countries
if (($countries = $GLOBALS['db']->select('CubeCart_geo_country', array('numcode', 'name'))) !== false) {
    $GLOBALS['smarty']->assign('COUNTRIES', $countries);
    ## Get counties
    $GLOBALS['smarty']->assign('VAL_JSON_COUNTY', state_json());
    $GLOBALS['smarty']->assign('CONFIG', $GLOBALS['config']->get('config'));
}
## Get Tax Classes
if (($tax_classes = $GLOBALS['db']->select('CubeCart_tax_class')) !== false) {
    $GLOBALS['smarty']->assign('TAX_CLASSES', $tax_classes);
    foreach ($tax_classes as $class) {
        $tax_class[$class['id']] = $class['tax_name'];
    }
Example #29
0
        }
    } elseif (isset($_POST['status']) && Admin::getInstance()->permissions('settings', CC_PERM_EDIT)) {
        if ($GLOBALS['config']->set('languages', false, $_POST['status'])) {
            $GLOBALS['main']->setACPNotify($lang['translate']['notify_language_status']);
        } else {
            $GLOBALS['main']->setACPWarning($lang['translate']['error_language_status']);
        }
        httpredir(currentPage());
    }
    $enabled = $GLOBALS['config']->get('languages');
    $GLOBALS['main']->addTabControl($lang['translate']['title_languages'], 'lang_list');
    ## List available language files
    if (($languageList = $GLOBALS['language']->listLanguages()) !== false) {
        foreach ($languageList as $code => $info) {
            $info['status'] = isset($enabled[$code]) ? (int) $enabled[$code] : 1;
            if (file_exists('language/flags/' . $info['code'] . '.png')) {
                $info['flag'] = 'language/flags/' . $info['code'] . '.png';
            } else {
                $info['flag'] = 'language/flags/unknown.png';
            }
            $info['edit'] = currentPage(null, array('language' => $info['code']));
            $info['delete'] = currentPage(null, array('delete' => $info['code']));
            $info['download'] = currentPage(null, array('download' => $info['code']));
            $smarty_data['languages'][] = $info;
        }
        $GLOBALS['main']->addTabControl($lang['translate']['title_language_create'], 'lang_create');
        $GLOBALS['main']->addTabControl($lang['translate']['title_language_import'], 'lang_import');
        $GLOBALS['smarty']->assign('LANGUAGES', $smarty_data['languages']);
    }
}
$page_content = $GLOBALS['smarty']->fetch('templates/settings.language.php');
Example #30
0
 if ($orders) {
     $GLOBALS['smarty']->assign('PAGINATION', $GLOBALS['db']->pagination(false, $per_page, $page, 9));
     if (isset($_GET['customer_id'])) {
         $GLOBALS['main']->setACPNotify(sprintf($lang['orders']['notify_orders_by'], $orders[0]['first_name'], $orders[0]['last_name']));
     }
     if (isset($_GET['search'])) {
         $GLOBALS['main']->setACPNotify($lang['orders']['notify_search_result']);
     }
     foreach ($orders as $order) {
         $order['name'] = isset($order['name']) && !empty($order['name']) ? $order['name'] : sprintf('%s %s %s', $order['title'], $order['first_name'], $order['last_name']);
         $order['icon'] = $order['type'] == 2 || empty($order['customer_id']) ? 'user_ghost' : 'user_registered';
         $order['link_edit'] = currentPage(array('print_hash'), array('action' => 'edit', 'order_id' => $order['cart_order_id']));
         $order['link_customer'] = $order['customer_id'] ? "?_g=customers&action=edit&customer_id=" . $order['customer_id'] : "#";
         $order['link_delete'] = currentPage(array('print_hash'), array('delete' => $order['cart_order_id']));
         // Link needs to be an array with one key
         $order['link_print'] = currentPage(array('print_hash'), array('print[0]' => $order['cart_order_id']));
         $order['status'] = $lang['order_state']['name_' . $order['status']];
         $order['date'] = formatTime($order['order_date']);
         $order['prod_total'] = Tax::getInstance()->priceFormat($order['total']);
         $smarty_data['list_orders'][] = $order;
     }
     $GLOBALS['smarty']->assign('ORDER_LIST', $smarty_data['list_orders']);
 } else {
     if (isset($_GET['search'])) {
         # No orders found
         $GLOBALS['main']->setACPWarning($lang['orders']['error_search_result']);
     }
 }
 $GLOBALS['smarty']->assign('DISPLAY_ORDER_LIST', true);
 // Hook
 foreach ($GLOBALS['hooks']->load('admin.order.index.list') as $hook) {