Jump to content

Buffering issues, and new orders don't show in the order section after upgrade to v6.2.0.


Recommended Posts

I just upgraded from Cubecart v6.1.15 to v6.2.0 a few weeks ago and after I log onto the admin control panel of the store, and make a few clicks on any of the options there (eg. store settings), it will buffer for a long time without showing. Also when a customer places an order, it does not show up in the order section, I only receive an email from paypal indicating that an order has been placed and when I check the Transaction logs, it displays this at the note section Payment problem. The amount paid (24.93) doesn't match the total order amount ().
But when I login as the customer and replicate the order by looking at the error log, it's the same amount as the transactional amount. Can anyone please help me?

System Error Log.png

Link to comment
Share on other sites

Welcome Ferguson230! Glad to see you made it to the forums.

We certainly need to look carefully at the end of the admin source file dashboard.index.inc.php.

Plus, that large error log entry has way too much stuff in it.

Where is that McAfee SECURE icon coming from?

Link to comment
Share on other sites

The McAfee Secure is coming from a script I placed in main.php, could that be causing the errors or buffering?

The code below is from the dashboard.index.inc.php.

## Get recent extensions 
/* Start ignoring statements
if($GLOBALS['session']->has('recent_extensions')) {
    $GLOBALS['smarty']->assign("RECENT_EXTENSIONS", $GLOBALS['session']->get('recent_extensions'));
} else {
    $request = new Request('www.cubecart.com', '/extensions/json');
    $request->skiplog(true);
    $request->setMethod('get');
    $request->cache(true);
    $request->setSSL();
    $request->setUserAgent('CubeCart');

    $response = $request->send();
    if($response) {
        $response = json_decode($response, true);
        $GLOBALS['session']->set('recent_extensions', $response);
        $GLOBALS['smarty']->assign("RECENT_EXTENSIONS", $response);
}
End ignoring statements */

## Check current version
if (false && !$GLOBALS['session']->has('version_check') && $request = new Request('www.cubecart.com', '/version-check/'.CC_VERSION)) {

 

## Latest News (from RSS)
/* Start ignoring statements
if ($GLOBALS['config']->has('config', 'default_rss_feed') && !$GLOBALS['config']->isEmpty('config', 'default_rss_feed') && filter_var($GLOBALS['config']->get('config', 'default_rss_feed'), FILTER_VALIDATE_URL)) {

    if($GLOBALS['session']->has('rss_news')) {
        $GLOBALS['smarty']->assign('NEWS', $GLOBALS['session']->get('rss_news'));
    } else {

        $default_rss_feed = $GLOBALS['config']->get('config', 'default_rss_feed');

        $url = (preg_match('/(act=rssout&id=1|1-cubecart-news-announcements)/', $default_rss_feed)) ? 'https://forums.cubecart.com/forum/1-news-announcements.xml' : $default_rss_feed;

        $url = parse_url($url);
        $path = (isset($url['query'])) ? $url['path'].'?'.$url['query'] : $url['path'];
        $request = new Request($url['host'], $path);
        $request->setSSL();
        $request->cache(true);
        $request->skiplog(true);
        $request->setMethod('get');

        if (($response = $request->send()) !== false) {
            try {
                if (($data = new SimpleXMLElement($response)) !== false) {
                    foreach ($data->channel->children() as $key => $value) {
                        if ($key == 'item') continue;
                        $news[$key] = (string)$value;
                    }
                    if ($data['version'] >= 2) {
                        $i = 1;
                        foreach ($data->channel->item as $item) {
                            $news['items'][] = array(
                                'title'   => (string)$item->title,
                                'link'   => (string)$item->link,
                            );
                            if($i==5) break;
                            $i++;
                        }
                    }
                    $GLOBALS['session']->set('rss_news', $news);
                    $GLOBALS['smarty']->assign('NEWS', $news);
                }
            } catch (Exception $e) {
                trigger_error($e->getMessage(), E_USER_WARNING);
            }
        }
    }
}
End ignoring statements */
$GLOBALS['main']->addTabControl($lang['dashboard']['title_store_overview'], 'advanced');

$count = array(
    'products' => number_format((int)$GLOBALS['db']->count('CubeCart_inventory', 'product_id')),
    'categories' => number_format((int)$GLOBALS['db']->count('CubeCart_category', 'cat_id')),
    'orders' => number_format((int)$GLOBALS['db']->count('CubeCart_order_summary', 'cart_order_id')),
    'customers' => number_format((int)$GLOBALS['db']->count('CubeCart_customer', 'customer_id'))
);

$tmp1 = 0;
$tmp2 = 0;

$system = array(
    'cc_version' => CC_VERSION,
    'cc_build'  => null,
    'php_version' => PHP_VERSION,
    'mysql_version' => $GLOBALS['db']->serverVersion(),
    'server'  => htmlspecialchars($_SERVER['SERVER_SOFTWARE']),
    'client'  => htmlspecialchars($_SERVER['HTTP_USER_AGENT']),
    'dir_images' => dirsize(CC_ROOT_DIR.'/images', $tmp1),
    'dir_files'  => dirsize(CC_ROOT_DIR.'/files', $tmp2),
);

$GLOBALS['smarty']->assign('SYS', $system);
$GLOBALS['smarty']->assign('PHP', ini_get_all());
$GLOBALS['smarty']->assign('COUNT', $count);

$GLOBALS['main']->addTabControl($lang['common']['search'], 'sidebar');

foreach ($GLOBALS['hooks']->load('admin.dashboard.custom_quick_tasks') as $hook) include $hook;
if(isset($custom_quick_tasks) && is_array($custom_quick_tasks)) {
    $GLOBALS['smarty']->assign('CUSTOM_QUICK_TASKS', $custom_quick_tasks);
}

$page_content = $GLOBALS['smarty']->fetch('templates/dashboard.index.php');
 

Link to comment
Share on other sites

I assume you copy-pasted just a few ranges of the whole file.

Just to be clear:

=-=-=-=-=-=-=-=- Many, many lines of code go here =-=-=-=-=-=-=-=-

## Get recent extensions
## Check current version
if (false && !$GLOBALS['session']->has('version_check') && $request = new Request('www.cubecart.com', '/version-check/'.CC_VERSION)) {

=-=-=-=-=- Many, many lines of code go here =-=-=-=-=-=-=- 

## Latest News (from RSS)

What you pasted seems correct. Except, please use the Code window (the <> icon) to paste in your code.

The McAfee thing you put in the main.php template, I assume is javascript. So, to determine if it is the javascript wanting to fetch something from McAfee causing the delay, or if it is CubeCart taking a long time to deliver the page, we need to use the browser's diagnostics features to view the Network panel and watch when the browser says the page has completely arrived.

Link to comment
Share on other sites

<?php
/**
 * CubeCart v6
 * ========================================
 * CubeCart is a registered trade mark of CubeCart Limited
 * Copyright CubeCart Limited 2017. All rights reserved.
 * UK Private Limited Company No. 5323904
 * ========================================
 * Web:   http://www.cubecart.com
 * Email:  [email protected]
 * License:  GPL-3.0 https://www.gnu.org/licenses/quick-guide-gplv3.html
 */

if (!defined('CC_INI_SET')) die('Access Denied');

global $glob, $lang, $admin_data;

## Quick tour
$GLOBALS['smarty']->assign('QUICK_TOUR', true);

if(isset($_GET['ignore_update']) && $_GET['ignore_update']>0) {
	$GLOBALS['db']->update('CubeCart_extension_info', array('modified' => time()), array('file_id' => (int)$_GET['ignore_update']));
	$GLOBALS['main']->setACPNotify($lang['dashboard']['ignore_update']);
	$GLOBALS['session']->delete('version_check');
	httpredir(currentPage(array('ignore_update')));
}

## Save notes
if (isset($_POST['notes']['dashboard_notes'])) {
	$update = array('dashboard_notes' => $_POST['notes']['dashboard_notes']);
	if ($GLOBALS['db']->update('CubeCart_admin_users', $update, array('admin_id' => Admin::getInstance()->get('admin_id')))) {
		$GLOBALS['session']->delete('', 'admin_data');
		$GLOBALS['main']->setACPNotify($lang['dashboard']['notice_notes_save']);
	} else {
		$GLOBALS['main']->setACPWarning($lang['dashboard']['error_notes_save']);
	}
	httpredir(currentPage());
}

## Delete admin folder if it exists and shouldn't
if($glob['adminFolder']!=='admin' && file_exists(CC_ROOT_DIR.'/admin')) {
	recursiveDelete(CC_ROOT_DIR.'/admin');
	if(file_exists(CC_ROOT_DIR.'/admin')) {
		$GLOBALS['main']->setACPWarning($lang['dashboard']['delete_admin_folder']);	
	}
}
## Delete admin file if it exists and shouldn't
if($glob['adminFile']!=='admin.php' && file_exists(CC_ROOT_DIR.'/admin.php')) {
	unlink(CC_ROOT_DIR.'/admin.php');
	if(file_exists(CC_ROOT_DIR.'/admin.php')) {
		$GLOBALS['main']->setACPWarning($lang['dashboard']['delete_admin_file']);	
	}
}

## Check if setup folder remains after install/upgrade
if ($glob['installed'] && file_exists(CC_ROOT_DIR.'/setup')) {
	## Attempt auto delete as we have just upgraded or installed
	if(isset($_COOKIE['delete_setup']) && $_COOKIE['delete_setup']) {
		recursiveDelete(CC_ROOT_DIR.'/setup');
		unlink(CC_ROOT_DIR.'/setup');
		setcookie('delete_setup', '', time()-3600);
	}

	$history = $GLOBALS['db']->misc('SELECT `version` FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_history` ORDER BY `time` DESC LIMIT 1');
	if (version_compare(CC_VERSION, $history[0]['version'], '>')) {
		$GLOBALS['main']->setACPWarning(sprintf($lang['dashboard']['error_version'], CC_VERSION, $history[0]['version']));
	} elseif (file_exists(CC_ROOT_DIR.'/setup')) {
		$GLOBALS['main']->setACPWarning($lang['dashboard']['error_setup_folder']);
	}
}
## Are they using the mysql root user?
if ($glob['dbusername'] == 'root' && !(bool)$GLOBALS['config']->get('config', 'debug')) {
	$GLOBALS['main']->setACPWarning($lang['dashboard']['error_mysql_root'], true, false);
}
## Is caching disabled
if (!(bool)$GLOBALS['config']->get('config', 'cache')) {
	$GLOBALS['main']->setACPWarning($lang['dashboard']['error_caching_disabled']);
}
## Windows only - Is global.inc.php writable?
if (substr(PHP_OS, 0, 3) !== 'WIN' && is_writable('includes/global.inc.php')) {
	if (!chmod('includes/global.inc.php', 0444)) {
		$GLOBALS['main']->setACPWarning($lang['dashboard']['error_global_risk']);
	}
}

$mysql_mode = $GLOBALS['db']->misc('SELECT @@sql_mode;');
if (stristr($mysql_mode[0]['@@sql_mode'], 'strict')) {
	$GLOBALS['main']->setACPWarning($lang['setup']['error_strict_mode']);
}


## Get recent extensions 
/* Start ignoring statements
if($GLOBALS['session']->has('recent_extensions')) {
	$GLOBALS['smarty']->assign("RECENT_EXTENSIONS", $GLOBALS['session']->get('recent_extensions'));
} else {
	$request = new Request('www.cubecart.com', '/extensions/json');
	$request->skiplog(true);
	$request->setMethod('get');
	$request->cache(true);
	$request->setSSL();
	$request->setUserAgent('CubeCart');

	$response = $request->send();
	if($response) {
		$response = json_decode($response, true);
		$GLOBALS['session']->set('recent_extensions', $response);
		$GLOBALS['smarty']->assign("RECENT_EXTENSIONS", $response);
}
End ignoring statements */

## Check current version
if (false && !$GLOBALS['session']->has('version_check') && $request = new Request('www.cubecart.com', '/version-check/'.CC_VERSION)) {
	$request->skiplog(true);
	$request->setMethod('get');
	$request->cache(true);
	$request->setSSL();
	$request->setUserAgent('CubeCart');
	
	$request_data = array('version' => CC_VERSION);

	$extension_versions = $GLOBALS['db']->select('CubeCart_extension_info');
	if(is_array($extension_versions)) {
		$extension_check = array();
		foreach($extension_versions as $v) {
			if(file_exists(CC_ROOT_DIR.$v['dir'])) {
				$extension_check[$v['file_id']] = $v['modified'];
			} else {
				$GLOBALS['db']->delete('CubeCart_extension_info', array('file_id' => $v['file_id']));
			}
		}
		if(count($extension_check)>0) {
			$request_data['extensions'] = $extension_check;
		}
	}

	$request->setData($request_data);
	$response = $request->send();
	
	if ($response !== false) {
		
		$response_array = json_decode($response, true);

		if (version_compare($response_array['version'], CC_VERSION, '>')) {
			$GLOBALS['main']->setACPWarning(sprintf($lang['dashboard']['error_version_update'], $response_array['version'], CC_VERSION).' <a href="?_g=maintenance&node=index#upgrade">'.$lang['maintain']['upgrade_now'].'</a>');
		}
		if(isset($response_array['updates']) && is_array($response_array['updates'])) {
			$version_check = $response_array['updates'];
		} else {
			$version_check = true;
		}
		$GLOBALS['session']->set('version_check', $version_check);
	}
}

$GLOBALS['smarty']->assign('DASH_NOTES', Admin::getInstance()->get('dashboard_notes'));

$GLOBALS['main']->wikiPage('Dashboard');
### Dashboard ###
$GLOBALS['main']->addTabControl($lang['dashboard']['title_dashboard'], 'dashboard');
## Quick Stats
if (Admin::getInstance()->permissions('statistics', CC_PERM_READ, false, false)) {
	$total_sales = $GLOBALS['db']->query('SELECT SUM(`total`) as `total_sales` FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_order_summary` WHERE `status` = 3;');
	$quick_stats['total_sales'] = Tax::getInstance()->priceFormat((float)$total_sales[0]['total_sales']);

	$ave_order  = $GLOBALS['db']->query('SELECT AVG(`total`) as `ave_order` FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_order_summary` WHERE `status` = 3;');
	$quick_stats['ave_order'] = Tax::getInstance()->priceFormat((float)$ave_order[0]['ave_order']);

	$this_year    = date('Y');
	$this_month   = date('m');
	$this_month_start  = mktime(0, 0, 0, $this_month, '01', $this_year);
	## Work out prev month looks silly but should stop -1 month on 1st March returning January (28 Days in Feb)
	$last_month   = date('m', strtotime("-1 month", mktime(12, 0, 0, $this_month, 15, $this_year)));
	$last_year    = ($last_month < $this_month) ? $this_year : ($this_year - 1);
	$last_month_start  = mktime(0, 0, 0, $last_month, '01', $last_year);
	$last_year_start   = mktime(0, 0, 0, '01', '01', $this_year - 1);

	$last_month_sales  = $GLOBALS['db']->query('SELECT SUM(`total`) as `last_month` FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_order_summary` WHERE `status` in(2,3) AND `order_date` > '.$last_month_start.' AND `order_date` < '.$this_month_start.';');
	$quick_stats['last_month'] = Tax::getInstance()->priceFormat((float)$last_month_sales[0]['last_month']);

	$this_month_sales  = $GLOBALS['db']->query('SELECT SUM(`total`) as `this_month` FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_order_summary` WHERE `status` in(2,3) AND `order_date` > '.$this_month_start.';');
	$quick_stats['this_month'] = Tax::getInstance()->priceFormat((float)$this_month_sales[0]['this_month']);

	$GLOBALS['smarty']->assign('QUICK_STATS', $quick_stats);

	## Statistics (Google Charts)
	$sales = $GLOBALS['db']->select('CubeCart_order_summary', array('order_date', 'total'), array('order_date' => '>='.$last_year_start, 'status' => array(2, 3), 'total' => '>0'));
	$data= array();
	if ($sales) { ## Get data to put in chart
		foreach ($sales as $sale) {
			$year = date('Y', $sale['order_date']);
			$month = date('M', $sale['order_date']);
			if (isset($data[$year][$month])) {
				$data[$year][$month] += sprintf('%0.2f', $sale['total']);
			} else {
				$data[$year][$month] = sprintf('%0.2f', $sale['total']);
			}
		}
	}

	$this_year = date('Y');
	$last_year = $this_year - 1;

	$chart_data['data'] = "['Month', '$this_year', '$last_year'],";

	for ($month = 1; $month <= 12; $month++) {
		$m = date("M", mktime(0, 0, 0, $month, 10));
		$last_year_month = (isset($data[$last_year][$m]) && $data[$last_year][$m]>0) ? $data[$last_year][$m] : 0;
		$this_year_month = (isset($data[$this_year][$m]) && $data[$this_year][$m]>0) ? $data[$this_year][$m] : 0;
		$chart_data['data'] .= "['$m',  $this_year_month, $last_year_month],";
	}

	$chart_data['title'] = $lang['dashboard']['title_sales_stats'].': '.$last_year.' - '.$this_year;
	$GLOBALS['smarty']->assign('CHART', $chart_data);

}
## Last 5 orders
if (($last_orders = $GLOBALS['db']->select('CubeCart_order_summary', array('cart_order_id', 'first_name', 'last_name', 'name'), false, array('order_date' => 'DESC'), 5)) !== false) {
	$GLOBALS['smarty']->assign('LAST_ORDERS', $last_orders);
}

## Quick Tasks
$date_format = "Y-m-d";
$today   = date($date_format);
$quick_tasks['today']   = urlencode(date($date_format));
$quick_tasks['this_weeks'] = urlencode(date($date_format, strtotime("last monday")));
foreach ($GLOBALS['hooks']->load('admin.dashboard.quick_tasks') as $hook) include $hook;
$GLOBALS['smarty']->assign('QUICK_TASKS', $quick_tasks);

## Pending Orders Tab
$page  = (isset($_GET['orders'])) ? $_GET['orders'] : 1;
$unsettled_count  = $GLOBALS['db']->count('CubeCart_order_summary', 'cart_order_id', array('status' => array(1, 2)));

// Pending Orders Sort
$order_by = '';
if (!isset($_GET['sort']) || !is_array($_GET['sort'])) {
	$_GET['sort'] = array('order_date' => 'ASC');
}
$key = array_keys($_GET['sort'])[0];
$sort = ($_GET['sort'][$key] === 'ASC' ? 'ASC' : 'DESC'); // only allow ASC or DESC sort values
if (!in_array($key, array('cart_order_id','first_name','status','order_date','total'))) {
	$order_by = '`dashboard` DESC, `status` DESC, `order_date` ASC';
}

$current_page = currentPage(array('sort'));
$thead_sort = array (
	'cart_order_id' => $GLOBALS['db']->column_sort('cart_order_id', $lang['orders']['order_number'] , 'sort', $current_page, $_GET['sort'], 'orders'),
	'first_name' => $GLOBALS['db']->column_sort('first_name', $lang['common']['name'], 'sort', $current_page, $_GET['sort'], 'orders'),
	'status' => $GLOBALS['db']->column_sort('status', $lang['common']['status'], 'sort', $current_page, $_GET['sort'], 'orders'),
	'order_date' => $GLOBALS['db']->column_sort('order_date', $lang['common']['date'], 'sort', $current_page, $_GET['sort'], 'orders'),
	'total' => $GLOBALS['db']->column_sort('total', $lang['basket']['total'], 'sort', $current_page, $_GET['sort'], 'orders'),
);

$GLOBALS['smarty']->assign('THEAD_ORDERS', $thead_sort);
$order_by = (empty($order_by) ? '`dashboard` DESC, `'.$key.'` '.$sort : $order_by);

$results_per_page = 25;
$unsettled_orders = $GLOBALS['db']->select('CubeCart_order_summary', array('cart_order_id', 'name', 'first_name', 'last_name', 'order_date', 'customer_id', 'total', 'status'), 'status IN (1,2) OR `dashboard` = 1', $order_by, $results_per_page, $page);

if ($unsettled_orders) {
	$tax = Tax::getInstance();
	$GLOBALS['main']->addTabControl($lang['dashboard']['title_orders_unsettled'], 'orders', null, null, $unsettled_count);
	
	foreach($unsettled_orders as $order) {
		$customer_ids[$order['customer_id']] = true;
	}
	$customers_in = implode(array_keys($customer_ids),',');
	
	$customers = $GLOBALS['db']->select('CubeCart_customer', array('type','customer_id'), 'customer_id IN ('.$customers_in.')');
	foreach($customers as $customer) {
		$customer_type[$customer['customer_id']] = $customer['type'];
	}

	for ($i = 1; $i <= 6; ++$i) {
		$smarty_data['order_status'][] = array(
			'id'  => $i,
			'selected' => (isset($summary[0]) && isset($summary[0]['status']) && (int)$summary[0]['status'] === $i) ? ' selected="selected"' : '',
			'string' => $lang['order_state']['name_'.$i],
		);
	}
	$GLOBALS['smarty']->assign('LIST_ORDER_STATUS', $smarty_data['order_status']);

	foreach ($unsettled_orders as $order) {
		$cart_order_ids[] = "'".$order['cart_order_id']."'";
		$order['icon'] = $customer_type[$order['customer_id']]==1 ? 'user_registered' : 'user_ghost'; // deprecated since 6.1.5
		$order['type'] = (empty($customer_type[$order['customer_id']])) ? 2 : $customer_type[$order['customer_id']];
		$order['cust_type'] = array("1" => 'title_key_registered', "2" => 'title_key_unregistered');
		$order['date'] = formatTime($order['order_date']);
		$order['total'] = Tax::getInstance()->priceFormat($order['total']);
		$order['status'] = $lang['order_state']['name_'.$order['status']];
		$order['link_print'] = '?_g=orders&print%5B0%5D='.$order['cart_order_id'];
		$orders[$order['cart_order_id']] = $order;
	}
	if (($notes = $GLOBALS['db']->select('CubeCart_order_notes', '`cart_order_id`,`time`,`content`', array('cart_order_id' => $cart_order_ids))) !== false) {
		foreach ($notes as $note) {
			$order_notes[$note['cart_order_id']]['notes'][] = $note;
		}
		$orders = merge_array($orders, $order_notes);
	}

	foreach ($GLOBALS['hooks']->load('admin.dashboard.unsettled_orders') as $hook) include $hook;
	
	$GLOBALS['smarty']->assign('ORDERS', $orders);
	$GLOBALS['smarty']->assign('ORDER_PAGINATION', $GLOBALS['db']->pagination($unsettled_count, $results_per_page, $page, $show = 5, 'orders', 'orders', $glue = ' ', $view_all = true));
}

## Product Reviews Tab
$page  = (isset($_GET['reviews'])) ? $_GET['reviews'] : 1;
if (($reviews = $GLOBALS['db']->select('CubeCart_reviews', false, array('approved' => '0'), false, 25, $page)) !== false) {
	$reviews_count = $GLOBALS['db']->getFoundRows();

	$GLOBALS['main']->addTabControl($lang['dashboard']['title_reviews_pending'], 'product_reviews', null, null, $reviews_count);
	foreach ($reviews as $review) {
		$product   = $GLOBALS['db']->select('CubeCart_inventory', array('name'), array('product_id' => (int)$review['product_id']));
		$review['product'] = $product[0];
		$review['date']  = formatTime($review['time']);
		$review['delete'] = "?_g=products&node=reviews&delete=".(int)$review['id'].'&token='.SESSION_TOKEN;
		$review['edit']  = "?_g=products&node=reviews&edit=".(int)$review['id'];
		$review['stars'] = 5;
		$review_list[] = $review;
	}
	$GLOBALS['smarty']->assign('REVIEWS', $review_list);
	$GLOBALS['smarty']->assign('REVIEW_PAGINATION', $GLOBALS['db']->pagination($reviews_count, 25, $page, $show = 5, 'reviews', 'product_reviews', $glue = ' ', $view_all = true));
}

## Stock Warnings
$page  = (isset($_GET['stock'])) ? $_GET['stock'] : 1;

$tables = '`'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_inventory` AS `I` LEFT JOIN `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_option_matrix` AS `M` on `I`.`product_id` = `M`.`product_id`';

$fields = 'I.name, I.product_code, I.stock_level AS I_stock_level, I.stock_warning AS I_stock_warning, I.product_id, M.stock_level AS M_stock_level, M.use_stock as M_use_stock, M.cached_name';

$where = 'use_stock_level = 1';
$where .= ' AND (';
//$where .= '(M.use_stock = 1 AND M.status = 1 AND M.stock_level <= '.(int)$GLOBALS['config']->get('config', 'stock_warn_level').')';
$where .= '((I.stock_warning > 0 AND M.stock_level <= I.stock_warning AND M.status = 1 AND M.use_stock = 1) OR (I.stock_warning <= 0 AND M.status = 1 AND M.use_stock = 1 AND M.stock_level <= '.(int)$GLOBALS['config']->get('config', 'stock_warn_level').'))';
$where .= ' OR ';
$where .= '((I.stock_warning > 0 AND I.stock_level <= I.stock_warning) OR (I.stock_warning <= 0 AND I.stock_level <= '.(int)$GLOBALS['config']->get('config', 'stock_warn_level').'))';
$where .= ')';

// Stock Warnings Sort
if (!isset($_GET['sort']) || !is_array($_GET['sort'])) {
	$_GET['sort'] = array('stock_level' => 'DESC');
}
$key = array_keys($_GET['sort'])[0];
$sort = ($_GET['sort'][$key] === 'ASC' ? 'ASC' : 'DESC'); // only allow ASC or DESC sort values
if (!in_array($key, array('name','stock_level','product_code'))) {
	$key = 'stock_level';
	$sort = 'DESC';
}

$current_page = currentPage(array('sort'));
$thead_sort = array (
	'stock_level' => $GLOBALS['db']->column_sort('stock_level', $lang['dashboard']['stock_level'], 'sort', $current_page, $_GET['sort'], 'stock_warnings'),
	'name' => $GLOBALS['db']->column_sort('name', $lang['catalogue']['product_name'], 'sort', $current_page, $_GET['sort'], 'stock_warnings'),
	'product_code' => $GLOBALS['db']->column_sort('product_code', $lang['catalogue']['product_code'], 'sort', $current_page, $_GET['sort'], 'stock_warnings'),
);

$GLOBALS['smarty']->assign('THEAD_STOCK', $thead_sort);
$order_by = 'I.`'.$key.'` '.$sort;

$result_limit = 20;

if ($stock_c = $GLOBALS['db']->select($tables, $fields, $where)) {
	$stock_count = count($stock_c);
	$stock = $GLOBALS['db']->select($tables, $fields, $where, $order_by, $result_limit, $page);
	$GLOBALS['smarty']->assign('STOCK', $stock);
	$GLOBALS['main']->addTabControl($lang['dashboard']['title_stock_warnings'], 'stock_warnings', null, null, $stock_count);
	$GLOBALS['smarty']->assign('STOCK_PAGINATION', $GLOBALS['db']->pagination($stock_count, $result_limit, $page, $show = 5, 'stock', 'stock_warnings', $glue = ' ', $view_all = true));

	foreach ($GLOBALS['hooks']->load('admin.dashboard.stock.post') as $hook) include $hook;
}

if($GLOBALS['session']->has('version_check')) {
	$extension_updates = $GLOBALS['session']->get('version_check');
	$file_ids = (is_array($extension_updates) && !empty($extension_updates) ? array_keys($extension_updates) : array(-1));
	$extension_updates = $GLOBALS['db']->select('CubeCart_extension_info', false, array('file_id' => $file_ids));
	if($extension_updates) {
		$GLOBALS['main']->addTabControl($lang['dashboard']['title_extension_updates'], 'extension_updates', null, null, count($extension_updates));
		$GLOBALS['smarty']->assign('EXTENSION_UPDATES', $extension_updates);
	}
}

foreach ($GLOBALS['hooks']->load('admin.dashboard.tabs') as $hook) include $hook;
if(isset($smarty_data['plugin_tabs'])) {
	$GLOBALS['smarty']->assign('PLUGIN_TABS', $smarty_data['plugin_tabs']);
}


## Latest News (from RSS)
/* Start ignoring statements
if ($GLOBALS['config']->has('config', 'default_rss_feed') && !$GLOBALS['config']->isEmpty('config', 'default_rss_feed') && filter_var($GLOBALS['config']->get('config', 'default_rss_feed'), FILTER_VALIDATE_URL)) {

	if($GLOBALS['session']->has('rss_news')) {
		$GLOBALS['smarty']->assign('NEWS', $GLOBALS['session']->get('rss_news'));
	} else {

		$default_rss_feed = $GLOBALS['config']->get('config', 'default_rss_feed');

		$url = (preg_match('/(act=rssout&id=1|1-cubecart-news-announcements)/', $default_rss_feed)) ? 'https://forums.cubecart.com/forum/1-news-announcements.xml' : $default_rss_feed;

		$url = parse_url($url);
		$path = (isset($url['query'])) ? $url['path'].'?'.$url['query'] : $url['path'];
		$request = new Request($url['host'], $path);
		$request->setSSL();
		$request->cache(true);
		$request->skiplog(true);
		$request->setMethod('get');

		if (($response = $request->send()) !== false) {
			try {
				if (($data = new SimpleXMLElement($response)) !== false) {
					foreach ($data->channel->children() as $key => $value) {
						if ($key == 'item') continue;
						$news[$key] = (string)$value;
					}
					if ($data['version'] >= 2) {
						$i = 1;
						foreach ($data->channel->item as $item) {
							$news['items'][] = array(
								'title'   => (string)$item->title,
								'link'   => (string)$item->link,
							);
							if($i==5) break;
							$i++;
						}
					}
					$GLOBALS['session']->set('rss_news', $news);
					$GLOBALS['smarty']->assign('NEWS', $news);
				}
			} catch (Exception $e) {
				trigger_error($e->getMessage(), E_USER_WARNING);
			}
		}
	}
}
End ignoring statements */
$GLOBALS['main']->addTabControl($lang['dashboard']['title_store_overview'], 'advanced');

$count = array(
	'products' => number_format((int)$GLOBALS['db']->count('CubeCart_inventory', 'product_id')),
	'categories' => number_format((int)$GLOBALS['db']->count('CubeCart_category', 'cat_id')),
	'orders' => number_format((int)$GLOBALS['db']->count('CubeCart_order_summary', 'cart_order_id')),
	'customers' => number_format((int)$GLOBALS['db']->count('CubeCart_customer', 'customer_id'))
);

$tmp1 = 0;
$tmp2 = 0;

$system = array(
	'cc_version' => CC_VERSION,
	'cc_build'  => null,
	'php_version' => PHP_VERSION,
	'mysql_version' => $GLOBALS['db']->serverVersion(),
	'server'  => htmlspecialchars($_SERVER['SERVER_SOFTWARE']),
	'client'  => htmlspecialchars($_SERVER['HTTP_USER_AGENT']),
	'dir_images' => dirsize(CC_ROOT_DIR.'/images', $tmp1),
	'dir_files'  => dirsize(CC_ROOT_DIR.'/files', $tmp2),
);

$GLOBALS['smarty']->assign('SYS', $system);
$GLOBALS['smarty']->assign('PHP', ini_get_all());
$GLOBALS['smarty']->assign('COUNT', $count);

$GLOBALS['main']->addTabControl($lang['common']['search'], 'sidebar');

foreach ($GLOBALS['hooks']->load('admin.dashboard.custom_quick_tasks') as $hook) include $hook;
if(isset($custom_quick_tasks) && is_array($custom_quick_tasks)) {
	$GLOBALS['smarty']->assign('CUSTOM_QUICK_TASKS', $custom_quick_tasks);
}

$page_content = $GLOBALS['smarty']->fetch('templates/dashboard.index.php');


Thanks Bsmither for teaching me about the <>, I had no clue, sorry if I strained your eyes earlier. The full code for dashboard.index.inc.php is posted above.

 

This is my main.php in the admin section from the templates folder.
<!DOCTYPE html>
<html class="no-js" xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="utf-8">
   <head>
      <meta charset="utf-8">
      <title>{$LANG.dashboard.title_admin_cp}</title>
      <link rel="shortcut icon" href="{$STORE_URL}/favicon.ico" type="image/x-icon">
      <link href='//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700' rel='stylesheet' type='text/css'>
      <link rel="stylesheet" type="text/css" href="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/styles/layout.css?{$VERSION_HASH}" media="screen">
      <link rel="stylesheet" href="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/styles/font-awesome.min.css?{$VERSION_HASH}">
      {foreach from=$JQUERY_STYLES item=style}
      <link rel="stylesheet" type="text/css" href="{$style}?{$VERSION_HASH}" media="screen">
      {/foreach}
      {foreach from=$HEAD_CSS item=style}
      <link rel="stylesheet" type="text/css" href="{$style}?{$VERSION_HASH}" media="screen">
      {/foreach}
      <link rel="stylesheet" type="text/css" href="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/js/styles/styles.php?{$VERSION_HASH}" media="screen">
      <link rel="stylesheet" type="text/css" href="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/styles/dropzone.css?{$VERSION_HASH}" media="screen">
      {foreach from=$HEAD_JS item=js_src}
      <script type="text/javascript" src="{$js_src}"></script>
      {/foreach}
   </head>
   
  {literal}<script type="text/javascript" src="https://cdn.ywxi.net/js/1.js" async></script>{/literal}

   

   <body>
      <div id="header">
         <a href="?"><img src="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/images/logo2.png" width="130" height="32" id="logo"></a>
         <span class="user_info">{$LANG.settings.title_welcome_back} <a href="?_g=settings&node=admins&action=edit&admin_id={$ADMIN_UID}">{$ADMIN_USER}</a> - <a href="?_g=logout&amp;token={$SESSION_TOKEN}">{$LANG.account.logout} <i class="fa fa-sign-out"></i></a></span>
      </div>
      <div id="wrapper">
         <div id="navigation">
            {include file='templates/common.search.php'}
            {include file='templates/common.navigation.php'}
         </div>
         {include file='templates/common.breadcrumb.php'}
         <div id="content">
            <div id="tab_control">
            {foreach from=$TABS item=tab}
               <div {if !empty($tab.tab_id)}id="{$tab.tab_id}" {/if}class="tab">
               {if !empty($tab.notify)}<span class="tab_notify">{$tab.notify}</span>{/if}
               <a href="{$tab.url}{$tab.target}"{if !empty($tab.accesskey)} accesskey="{$tab.accesskey}"{/if} target="{$tab.a_target}">{$tab.name}</a>
            </div>
            {/foreach}
         </div>
         <div id="content_body">
            {include file='templates/common.gui_message.php'}
            <div id="page_content">
               <div id="loading_content"><i class="fa fa-spinner fa-pulse"></i></div>
               {$DISPLAY_CONTENT}
            </div>
         </div>
         {include file='templates/ccpower.php'}
      </div>
      </div>
      <div style="display: none" id="val_admin_folder">{$SKIN_VARS.admin_folder}</div>
      <div style="display: none" id="val_admin_file">{$SKIN_VARS.admin_file}</div>
      <div style="display: none" id="val_skin_folder">{$SKIN_VARS.skin_folder}</div>
      <div style="display: none" id="val_admin_lang">{$val_admin_lang}</div>
      <ol id="joyrideTour" style="display: none">
         <li data-button="{$LANG.dashboard.ok_go}">
            <h2>{$LANG.common.hi_casual} {$ADMIN_USER_FIRST_NAME}!</h2>
            <p>{$LANG.dashboard.tour_welcome}</p>
         </li>
         <li data-id="nav_settings">
            <h2>1. {$LANG.navigation.nav_settings_store}</h2>
            <p>{$LANG.dashboard.tour_1}</p>
         </li>
         <li data-id="nav_categories">
            <h2>2. {$LANG.navigation.nav_categories}</h2>
            <p>{$LANG.dashboard.tour_2}</p>
         </li>
         <li data-id="nav_products">
            <h2>3. {$LANG.navigation.nav_products}</h2>
            <p>{$LANG.dashboard.tour_3}</p>
         </li>
         <li data-id="nav_marketplace">
            <h2>4. {$LANG.navigation.nav_marketplace}</h2>
            <p>{$LANG.dashboard.tour_4}</p>
         </li>
         <li data-id="nav_plugins">
            <h2>5. {$LANG.navigation.nav_plugins}</h2>
            <p>{$LANG.dashboard.tour_5}</p>
         </li>
         <li data-id="nav_docs">
            <h2>6. {$LANG.dashboard.tour_6_title}</h2>
            <p>{$LANG.dashboard.tour_6}</p>
         </li>
         <li class="joyride_tour_end" data-button="{$LANG.common.close}">
            <h2>{$LANG.common.thats_it}</h2>
            {$LANG.dashboard.tour_end}
         </li>
      </ol>
      <script type="text/javascript" src="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/js/jquery-1.11.2.min.js"></script>
      <script type="text/javascript" src="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/js/jquery-ui-1.11.2.min.js"></script>
      <script type="text/javascript" src="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/js/plugins.php?{$VERSION_HASH}"></script>
      <!-- Include CKEditor -->
      <script type="text/javascript" src="includes/ckeditor/ckeditor.js"></script>
      <script type="text/javascript" src="includes/ckeditor/adapters/jquery.js"></script>
      <script src="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/js/dropzone.js"></script>
      <script>
         {literal}
         $(window).load(function() {
           $("#joyrideTour").joyride({
             autoStart: {/literal}{$TOUR_AUTO_START}{literal},
             postStepCallback: function (index, tip) {
               if (index == 6) {
                  $('<p><iframe src="//player.vimeo.com/video/118638908" width="500" height="313" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></p>').insertAfter($(".joyride_tour_end p").last());
               }
             },
             postRideCallback: function (){
              $.ajax({url: "{/literal}{$SKIN_VARS.admin_file}{literal}?_g=settings&node=admins&tour_shown={/literal}{$ADMIN_UID}{literal}"});
             },
           });
         });
         {/literal}
      </script>
      <script type="text/javascript" src="{$SKIN_VARS.admin_folder}/skins/{$SKIN_VARS.skin_folder}/js/admin.js?{$VERSION_HASH}"></script>
      {if isset($CLOSE_WINDOW)}
      <script type="text/javascript">
         $(document).ready(function () {
          setInterval(function() { window.close(); }, 1000);
         });
      </script>
      {/if}
      {foreach from=$EXTRA_JS item=js_src}
      <script type="text/javascript" src="{$js_src}"></script>
      {/foreach}
      {foreach from=$BODY_JS item=js_src}
      <script type="text/javascript" src="{$js_src}"></script>
      {/foreach}
   </body>
</html>

 

Link to comment
Share on other sites

Quick notes:

Lines 104 - 110:

	$response = $request->send();
	if($response) {
		$response = json_decode($response, true);
		$GLOBALS['session']->set('recent_extensions', $response);
		$GLOBALS['smarty']->assign("RECENT_EXTENSIONS", $response);
}
End ignoring statements */

The closing brace for the if() block is missing.

But this is inside a block comment. That said, this is the only weird thing I have found. Everything else checks out.

Link to comment
Share on other sites

## Get recent extensions 
/* Start ignoring statements
if($GLOBALS['session']->has('recent_extensions')) {
	$GLOBALS['smarty']->assign("RECENT_EXTENSIONS", $GLOBALS['session']->get('recent_extensions'));
} else {
	$request = new Request('www.cubecart.com', '/extensions/json');
	$request->skiplog(true);
	$request->setMethod('get');
	$request->cache(true);
	$request->setSSL();
	$request->setUserAgent('CubeCart');

	$response = $request->send();
	if($response) {
		$response = json_decode($response, true);
		$GLOBALS['session']->set('recent_extensions', $response);
		$GLOBALS['smarty']->assign("RECENT_EXTENSIONS", $response);
       }
   }
 }
End ignoring statements */

Thanks Bsmither, I now have this, but it's still buffering...could it be because of the attached pic from the databse in the maintainance section of the admin panel? I selected the options highlighted in orange and used the repair option below, but there seem to be no change.

 

Database Log.png

Buffering.png

Link to comment
Share on other sites

Still working on the "Unexpected end of file". And, now you have one too many closing braces.

A 'throbber' (the indicator that says javascript is waiting for a response to an AJAX request - some browsers did at one time use a throbber in the address bar to indicate waiting for a page to load) suggests that javascript has crashed, did not load, or waiting for data. On the Dashboard, this is typically caused by Google not drawing the charts.

What page did you post the screen grab above with the throbber?

None of the four available actions on the list of database tables will not remove extra indexes.

Link to comment
Share on other sites

 

## Get recent extensions 
/* Start ignoring statements
if($GLOBALS['session']->has('recent_extensions')) {
	$GLOBALS['smarty']->assign("RECENT_EXTENSIONS", $GLOBALS['session']->get('recent_extensions'));
} else {
	$request = new Request('www.cubecart.com', '/extensions/json');
	$request->skiplog(true);
	$request->setMethod('get');
	$request->cache(true);
	$request->setSSL();
	$request->setUserAgent('CubeCart');

	$response = $request->send();
	if($response) {
		$response = json_decode($response, true);
		$GLOBALS['session']->set('recent_extensions', $response);
		$GLOBALS['smarty']->assign("RECENT_EXTENSIONS", $response);
       }
   }
End ignoring statements */

Once again, thanks Bsmither for both your time and ability to teach  I will add the term 'throbber' to my list of terms going forward.
I did remove one of the braces at the end.

 

Link to comment
Share on other sites

If you are using the Firefox browser, open its Developer Tools. Then request the Customers page.

Examining the Network pane of the Tools window, determine id any request has a 404 response.

Examining the Console pane, determine if any errors were encountered by any javascript script.

Link to comment
Share on other sites

Bootstrapped manifest not allowed to use 'resource' directive. chrome.manifest:1
Bootstrapped manifest not allowed to use 'resource' directive. chrome.manifest:7
Bootstrapped manifest not allowed to use 'resource' directive. chrome.manifest:2
Use of nsIFile in content process is deprecated.
NetUtil.jsm:302:12
Use of nsIFile in content process is deprecated. filesystem.js:40:9
Key event not available on some keyboard layouts: key=“i modifiers=“accel,alt,shift id=“key_browserToolbox browser.xul
[Show/hide message details.] TypeError: jQuery(...).cropper is not a function plugins.php:146:1876
[Show/hide message details.] TypeError: $(...).rating is not a function admin.js:388:9
[Show/hide message details.] TypeError: $(...).joyride is not a function admin_vsp6wd.php:6:12
[Show/hide message details.] TelemetryStopwatch: key "TELEMETRY_PENDING_LOAD_MS" was already initialized TelemetryStopwatch.jsm:352
[Show/hide message details.] TelemetryStopwatch: requesting elapsed time for nonexisting stopwatch. Histogram: "TELEMETRY_PENDING_LOAD_MS", key: "null"
TelemetryStopwatch.jsm:373

I used the browser console in Firefox after I clicked on customer list.

 

Link to comment
Share on other sites

Doesn't look like output from the Firefox Console I am familiar with, but whatever.

So, a lot of javascript is not loading/running.

Check to see if this file exists: /admin_xXxXxX/skins/default/js/plugins/jquery.cropper.min.js

If it doesn't, then CubeCart has not been installed completely.

Link to comment
Share on other sites

You caught it earlier when you started asking about where the McAfee SECURE was coming from, and also when you defined what a throbber was....I thought about your Ajax request statement for awhile and that’s what made me decide to take the JavaScript code out...

You did teach me more than one way to look at a problem...

@bsmither Does cubecart has some kind of upvote system like Quora or stack overflow? 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...