Post by Qphoria » Wed Aug 20, 2008 2:31 am

This contrib adds a new menu controller to allow ignoring a particular IP address from affecting statistics.
Useful for testing your site without being picked up as a customer. Currently, the only place this exists is
the “Products Viewed” report, but it is easily modified to include future statistics.

DOWNLOAD
DEMO (user:demo/pass:demo)
To test the demo:
1.  Enter your IP in the Admin IP.
2.  View the Reports->Products Viewed report and take count of a product.
3.  Visit that product on the front end.
4.  Verify the Product Viewed count did NOT increase.
5.  Change the Admin IP to something else.
6.  Visit the product again.
7.  Verify it the viewed count DID increase.

Enjoy
Q!
Last edited by Qphoria on Wed Sep 10, 2008 3:43 am, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by ogun » Wed Aug 20, 2008 4:04 am

nice one, downloading :)

Active Member

Posts

Joined
Tue Aug 14, 2007 6:04 am

Post by Geek » Sat Aug 23, 2008 4:40 am

Nice job!

I had it working for a little while and then I ended up having to wipe the whole cart system out and restart from scratch. When I
tried to re-install it, my menu on the top goes away. Can't figure out why. I think it has something to do with the
'./admin/template/default/module/menu.tpl' file.

This is what my code looks like after I add the change from the original. And this is where my error ends up at.

Code: Select all

        ['', '', '', null, null],
 // Ignore Admin IP - Edited: geek@simplygeek.net
        ['', 'Admin IP', '../admin/index.php?controller=admin_ip’, null, null],
// End of Edit
    ['', '', '', null, null],
        ['', '', '', null, null]
This is what I have to do in order to have my menu come back after it disappears.

Code: Select all

        ['', '', '', null, null],
 // Ignore Admin IP - Edited: geek@simplygeek.net
        //['', 'Admin IP', '../admin/index.php?controller=admin_ip’, null, null],
// End of Edit
    ['', '', '', null, null],
        ['', '', '', null, null]
Any suggestions of what I may be doing wrong?

~Simplygeek.net


New member

Posts

Joined
Sat May 17, 2008 1:00 pm
Location - Cyberspace, the final frontier...

Post by Qphoria » Sat Aug 23, 2008 4:46 am

Honestly, we can't get rid of this file-based menu fast enough!

The string looks ok, but I wonder if it doesn't like you adding the //comments before and after it.

Soon we will have an db-based admin menu (like this) to replace the file-based one and never have these problems again!
Last edited by Qphoria on Sat Aug 23, 2008 4:47 am, edited 1 time in total.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Geek » Sat Aug 23, 2008 5:49 am

Qphoria wrote: Honestly, we can't get rid of this file-based menu fast enough!

The string looks ok, but I wonder if it doesn't like you adding the //comments before and after it.

Soon we will have an db-based admin menu (like this) to replace the file-based one and never have these problems again!
I tried removing the //comments out before I posted and still nothing. I can still make it work by adding '../admin/index.php?controller=admin_ip' on to
the end of my URL and it seems to work fine. I just don't have a direct menu access to it. Oh well, I am sure that we will get it all fixed and straightened
out.

Edit:
I figured out what my problem was now.

Just a note for everyone that wants to use this mod at all, my mistake was that there must have been an extra carriage return (CR) somewhere in the code. The extra CR came from me just "copy, cut, and paste" from the PDF instruction file. I went and I manually edited the '../admin/template/default/module/menu.tpl' file instead of copy and paste and then my problem was fixed. I suggest you edit that file manually and not with your mouse.
Last edited by Anonymous on Sat Aug 23, 2008 12:52 pm, edited 1 time in total.

~Simplygeek.net


New member

Posts

Joined
Sat May 17, 2008 1:00 pm
Location - Cyberspace, the final frontier...

Post by Qphoria » Sat Aug 23, 2008 1:06 pm

good catch!

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Geek » Sat Aug 23, 2008 1:10 pm

Qphoria wrote: good catch!
Haha! I am learning and picking up PHP and the OpenCart system, slowly but surely.

Actually, I have never been so proud of myself before tonight. Ha!
And I almost got a store up and fully functional just the way I need it to be setup as well.

Sorry, just had to gloat for a second there. :) Okay, now back on track...

~Simplygeek.net


New member

Posts

Joined
Sat May 17, 2008 1:00 pm
Location - Cyberspace, the final frontier...

Post by Qphoria » Sat Aug 23, 2008 1:11 pm

Good. can't wait to see the finished product

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by fido-x » Sat Aug 23, 2008 1:30 pm

I've found similar sorts of problems with "cut & paste" of coding, with extra lines of space being added. This is primarily due to Windows using a carriage return AND a line feed, while Linux and Mac just use a carriage return. Text editors in Windows still behave like typewriters!

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by frame » Mon Aug 25, 2008 5:34 pm

I would like to suggest (for the next release, hopefully it will be) to add the possibility to set more IP addresses.

New member

Posts

Joined
Sat Apr 26, 2008 7:24 pm

Post by Qphoria » Mon Aug 25, 2008 5:58 pm

Yea, I was originally going to do a range. Then I thought it might make more sense to do other IPs .... maybe both.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by frame » Mon Oct 06, 2008 10:25 pm

I have created a little mod as an extension to Qphoria's Ignore Admin IP @ Products Viewed Report.
So, this mod ignores admin IP @ People Online Report (as I know when I am online) and is based on the previous mod.
Only 2 extra files have to be modified (please backup them before make changes):

/admin/controller/home.php:

Code: Select all

.
.
function index() {
		$response =& $this->locator->get('response');
		$database =& $this->locator->get('database');
		$url      =& $this->locator->get('url');
		//Added by Frame
		$config   =& $this->locator->get('config');
		//EOF
		$language =& $this->locator->get('language');
		$template =& $this->locator->get('template');
		$customer =& $this->locator->get('customer');
		$currency =& $this->locator->get('currency');
		$module   =& $this->locator->get('module');
.
.
.
.
$view->set('online', $url->ssl('report_online'));
	//Added by Frame
            if ($_SERVER['REMOTE_ADDR'] == $config->get('config_admin_ip')) {
      		    if ($config->get('config_admin_ip_status') == "0") {
			$user_info = $database->getRow("select count(*) as total from session");
									} else {
    	$user_info = $database->getRow("select count(*) as total from session where ip <> '".$config->get('config_admin_ip')."'");}
		} else {
	$user_info = $database->getRow("select count(*) as total from session");
			}
	//EOF
    	$view->set('users', $user_info['total']);
and /admin/controller/report_online.php:

Code: Select all

.
.
function index() { 
		$database =& $this->locator->get('database');
		$language =& $this->locator->get('language');
		//Added by Frame
		$config   =& $this->locator->get('config');
		//EOF
		$response =& $this->locator->get('response');
		$template =& $this->locator->get('template');
		$module   =& $this->locator->get('module');
.
.
foreach ($results as $result) {
			$value = array();
 
			$a = preg_split("/(\w+)\|/", $result['value'], - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);

			for ($i = 0; $i < count($a); $i = $i + 2) {
				$value[$a[$i]] = unserialize($a[$i + 1]);
			}
 		//Added by Frame
            if ($_SERVER['REMOTE_ADDR'] == $config->get('config_admin_ip')) {
      		    if ($config->get('config_admin_ip_status') == "0") {

			if (isset($value['user_id'])) {
				$user_info = $database->getRow("select username from user where user_id = '" . (int)$value['user_id'] . "'");

				$name = $language->get('text_admin', $user_info['username']);
			} elseif (isset($value['customer_id'])) {
				$customer_info = $database->getRow("select concat(firstname,' ',lastname) as name from customer where customer_id = '" . (int)$value['customer_id'] . "'");

				$name = $customer_info['name'];
			} else {
				$name = $language->get('text_guest');
			}
				$rows[] = array(
				'name'  => $name,
				'time'  => date('dS F Y h:i:s A', strtotime($result['time'])),
				'ip'    => $result['ip'],
				'url'   => $result['url'],
				'total' => (isset($value['products']) ? count($value['products']) : 0)
			);
									} else {
			if (isset($value['user_id'])) {
				$user_info = $database->getRow("select username from user where user_id = '" . (int)$value['user_id'] . "'");

				$name = $language->get('text_admin', $user_info['username']);
			}elseif (isset($value['customer_id'])) {
				$customer_info = $database->getRow("select concat(firstname,' ',lastname) as name from customer where customer_id = '" . (int)$value['customer_id'] . "'");

				$name = $customer_info['name'];
			} else {
				$name = $language->get('text_guest');
			}

			if ($_SERVER['REMOTE_ADDR'] <> $result['ip']) {
				$rows[] = array(
				'name'  => $name,
				'time'  => date('dS F Y h:i:s A', strtotime($result['time'])),
				'ip'    => $result['ip'],
				'url'   => $result['url'],
				'total' => (isset($value['products']) ? count($value['products']) : 0)
			);}
										}

		} else {
			if (isset($value['user_id'])) {
				$user_info = $database->getRow("select username from user where user_id = '" . (int)$value['user_id'] . "'");

				$name = $language->get('text_admin', $user_info['username']);
			} elseif (isset($value['customer_id'])) {
				$customer_info = $database->getRow("select concat(firstname,' ',lastname) as name from customer where customer_id = '" . (int)$value['customer_id'] . "'");

				$name = $customer_info['name'];
			} else {
				$name = $language->get('text_guest');
			}
				$rows[] = array(
				'name'  => $name,
				'time'  => date('dS F Y h:i:s A', strtotime($result['time'])),
				'ip'    => $result['ip'],
				'url'   => $result['url'],
				'total' => (isset($value['products']) ? count($value['products']) : 0)
			);
}
//EOF
			
		}

		$view = $this->locator->create('template');

This is not the most beautiful solution but it works (hopefully).
Bye
Frame
Last edited by frame on Tue Oct 07, 2008 2:43 pm, edited 1 time in total.

New member

Posts

Joined
Sat Apr 26, 2008 7:24 pm

Post by frame » Mon Oct 06, 2008 10:28 pm

I have just noticed a little bug, so I modified above the report_online.php
Last edited by frame on Tue Oct 07, 2008 2:41 pm, edited 1 time in total.

New member

Posts

Joined
Sat Apr 26, 2008 7:24 pm

Post by Qphoria » Mon Oct 06, 2008 10:31 pm

Nice. It looks like you added the check on the homepage and added the customer name on the report. Good additions :)

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 10 guests