Hi
If anyone is interested in this i will post it. This mod is database driven with a link in admin.
[url]http://www.megapcs4u.co.uk/[/url]
you can always log in to your host and check but it always nice to embed it in CS-Cart admin page. It will make thing a lot easier.
Very nice, i’m interest, please post the code
thanks
[quote name=‘taydu’]Very nice, i’m interest, please post the code[/QUOTE]
same here!!
Hi Zardos,
I would be very interested should you have the code handy.
I have been looking for a admin panel that incorporated the following details
(as your images showed)
Look forward to seeing something soon we hope?
Ok here we go.
[COLOR=Red]Step 1[/COLOR]:
Create a new setup.php file and add this code
```php
$dbhost='localhost';
$dbusername='[COLOR=Red]Your-DB-UserName[/COLOR]';
$dbuserpass='[COLOR=Red]Your-DB-Password[/COLOR]';
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
//select the database
mysql_select_db('[COLOR=Red]Your-DB-Name[/COLOR]') or die('Cannot select database');
//create the table, customize it if you want
$query = 'CREATE TABLE stats(
ip VARCHAR(255) NOT NULL,
hits VARCHAR(20) NOT NULL,
activity DATETIME NOT NULL,
user_agent VARCHAR(255) NOT NULL)';
$result = mysql_query($query);
echo "Table Created!";
?>
```
I would create a new DB for this IP function to keep it seperate from your shop DB. Add your DB info in all three places in the above code. upload it to your root and run it from your browser, (www.your-site.com/setup.php)
[COLOR=Red]Step 2[/COLOR]:
Create a TPL call it if you like stats.tpl and add the code below.
```php
{* $Id: site_info.tpl 1096 2006-01-16 11:20:18Z zeke $ *}
{capture name=“sidebox”}
{php} require_once("visitorstats.php"); {/php}
{[COLOR=Red]$lang.site_stats[/COLOR]} | |
{[COLOR=Red]$lang.unique[/COLOR]} | {php} echo $unique; {/php} |
{[COLOR=Red]$lang.hits[/COLOR]} | {php} echo $hits; {/php} |
{/capture}
{include file="common_templates/sidebox.tpl" title=$lang.site_info content=$smarty.capture.sidebox icon="sidebox_icon_help.gif"}
```
Upload this tpl to your customer/side_boxes and create the three new languages {[COLOR=Red]$lang.site_stats[/COLOR]} and {[COLOR=Red]$lang.unique[/COLOR]} and {[COLOR=Red]$lang.hits[/COLOR]}
[COLOR=Red]Step 3[/COLOR]:
Create a PHP file called "visitorstats.php and put the code below into it.
```php
if ( !defined('IN_CSCART') ) { die('Access denied'); }
// set your infomation.
$dbhost='localhost';
$dbusername='[COLOR=Red]Your-username[/COLOR]';
$dbuserpass='[COLOR=Red]Your-pass-word[/COLOR]';
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
//select the database
mysql_select_db('[COLOR=Red]Your-DB-name[/COLOR]') or die('Cannot select database');
$query = "SELECT COUNT(ip) AS numrows FROM stats WHERE ip='".$_SERVER["REMOTE_ADDR"]."'";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result);
$numrows = $row['numrows'];
if ($numrows == 0) {
mysql_query("INSERT INTO stats(ip,hits,activity,user_agent)VALUES ('".$_SERVER["REMOTE_ADDR"]."','1',now(),'{$_SERVER['HTTP_USER_AGENT']}')");
}else{
mysql_query("UPDATE stats SET hits=hits+1 WHERE ip='".$_SERVER['REMOTE_ADDR']."'");
}
$result = mysql_query("SELECT COUNT(ip) AS numrows FROM stats");
$row = mysql_fetch_array($result);
$unique = $row['numrows'];
$result = mysql_query("SELECT hits FROM stats");
while ($row = mysql_fetch_array($result)) {
$hits += $row['hits'];
}
?>
```
Now upload this file to your root = /public_html/visitorstats.php and !! [COLOR=Red]chmod 644[/COLOR] !!
[COLOR=Red]
Step 4[/COLOR]:
Add this include to your cutomer/main.tpl
{include file="side_boxes/stats.tpl"}
```php
{if !$hide_sideboxes}
{if $settings.Modules.ads == 'Y'}
{include file="addons/ads/ads.tpl" location="L" show_order="B"}
{/if}
{include file="side_boxes/categories.tpl"}
{include file="addons/manufacturers/sidebox_manufacturers.tpl"}
{if $settings.Modules.bestsellers == 'Y'}
{include file="addons/bestsellers/sidebox.tpl"}
{/if}
{include file="side_boxes/site_info.tpl"}
[COLOR=Red]{include file="side_boxes/stats.tpl"}[/COLOR]
{**[ADDONS_DATA]**}
{if $settings.Modules.ads == 'Y'}
{include file="addons/ads/ads.tpl" location="L" show_order="A"}
{/if}
{**[/ADDONS_DATA]**}
{/if}
```
[COLOR=Red]Step 5[/COLOR]:
In admin/side_boxes/look_n_feel.tpl add this.
Visitors IP
just before the {/capture}
[COLOR=Red]Step 6[/COLOR]:
Create a new visitor.php file and add this code.
```php
echo "";
// set your infomation.
$dbhost='localhost';
$dbusername='[COLOR=Red]Your-DB-UserName[/COLOR]';
$dbuserpass='[COLOR=Red]Your-DB-Password[COLOR=Black]'[/COLOR][/COLOR];
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
//select the database
mysql_select_db('[COLOR=Red]Your-DB-Name[/COLOR]') or die('Cannot select database');
echo "
Visitors
";$rowsPerPage = 50; // how many rows on each page?
$pageNum = 1; // when they first visit make use this as default
// if they have come from another page then adjust the settings for this page
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
$query = " SELECT ip,hits,activity,user_agent FROM stats " .
" ORDER BY hits DESC LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');
echo "";
// show the information
$i=1;
while($row = mysql_fetch_array($result))
{
echo "";
$i++;
}
echo "
ID | IP | Hits | Last Visited | User Agent |
".$i." | ".$row['ip']." | ".$row['hits']." | ".$row['activity']." | ".$row['user_agent']." |
// how many rows we have in database
$query = "SELECT COUNT(ip) AS numrows FROM stats";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
// print the link to access each page
$self = $_SERVER['PHP_SELF'];
$nav = '';
for($page = 1; $page <= $maxPage; $page++)
{
if ($page == $pageNum)
{
$nav .= " $page ";
}
else
{
$nav .= " $page ";
}
}
// creating previous and next link
// plus the link to go straight to
// the first and last page
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " [Prev] ";
$first = " [First Page] ";
}
else
{
$prev = ' ';
$first = ' ';
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " [Next] ";
$last = " [Last Page] ";
}
else
{
$next = ' ';
$last = ' ';
}
// print the navigation link(s)
echo "Navigation:". $first . $prev . $nav . $next . $last;
echo "";
?>
```
And again add DB info then upload this to your root = /public_html/visitor.php and !!! [COLOR=Red]chmod this 644[/COLOR] !!
Add this to your style.css
```php
.stats {
color:#333;
font-family:Tahoma, Verdana, Arial, Helvetica, Sans-Serif;
font-size:11px;
font-weight:400;
background-color:inherit;
}
```
Delete the setup.php when you have done.
I think that is all, have fun.
[SIZE=3][B][U][COLOR=Red]This Visitor and IP Mod has now been ! Updated ![/COLOR][/U][/B][/SIZE]
Just recieved an email notification re this.
will implemenrt it as soon as I’ve finished work
thank you very much zardos
Zardos,
This is totally awesome! Hey, where would the visitor.php file be placed? I am just about ready to fire this up but I am not sure where to put the visitor.php file…thanks for the mod!!!
Cheers,
Travis
Hi Travis
Your Welcome
Place the Visitors.php in /public_html :rolleyes:
In logout.tpl add this:
```php
{* $Id: logout.tpl 1462 2006-03-17 12:39:35Z zeke $ *}
{capture name="sidebox"}
```
This is the result:
{$user_info.firstname} {$user_info.lastname} {$lang.is_logged_in} |
LEGEND… ALL HAIL THE MIGHTY ZARDOS…
Thanks again buddy. This will save me heaps of time when people ask are ‘you watching me’?
Zados it would be nice to have a few more display option (by the hour, day, week, month, or years)
How do I make it to display it with in the admin site (all the modules, and side boxs)
thanks
Hi taydu
Try playing around with the code from this post:
[url]http://vb.cs-cart.com/showthread.php?t=742[/url]
Zardos when I added
```php
{include file=“side_boxes/stats.tpl”}
{if !$hide_sideboxes}
{if $settings.Modules.ads == ‘Y’}
{include file=“addons/ads/ads.tpl” location=“L” show_order=“B”}
{/if}
{include file=“side_boxes/categories.tpl”}
{include file=“addons/manufacturers/sidebox_manufacturers.tpl”}
{if $settings.Modules.bestsellers == ‘Y’}
{include file=“addons/bestsellers/sidebox.tpl”}
{/if}
{include file=“side_boxes/site_info.tpl”}
{include file=“side_boxes/stats.tpl”}
{[ADDONS_DATA]}
{if $settings.Modules.ads == ‘Y’}
{include file=“addons/ads/ads.tpl” location=“L” show_order=“A”}
{/if}
{[/ADDONS_DATA]}
{/if}
```
My store won’t display, it just display a white blank page
my current main.tpl is ```php
{* $Id: main.tpl 936 2005-11-21 12:14:30Z vladimir $ *}
{if !$hide_sideboxes}
{/if}
{if !$hide_sideboxes}
{/if}
{if $settings.Modules.ads == 'Y'} {include file="addons/ads/ads.tpl" location="L" show_order="B"} {/if} {include file="side_boxes/categories.tpl"} {include file="addons/manufacturers/sidebox_manufacturers.tpl"} {*{if $settings.Modules.bestsellers == 'Y'} {include file="addons/bestsellers/sidebox.tpl"} {/if} {include file="side_boxes/site_info.tpl"}*} {**[ADDONS_DATA]**} {if $settings.Modules.ads == 'Y'} {include file="addons/ads/ads.tpl" location="L" show_order="A"} {/if} {include file="side_boxes/information_center.tpl"} {include file="side_boxes/fta_channels.tpl"} {**[/ADDONS_DATA]**} |
{if $settings.Modules.ads == 'Y'} {include file="addons/ads/ads.tpl" location="C" show_order="B"} {/if} {include file="content.tpl"} {if $settings.Modules.ads == 'Y'} {include file="addons/ads/ads.tpl" location="C" show_order="A"} {/if} |
{if $settings.Modules.ads == 'Y'} {include file="addons/ads/ads.tpl" location="R" show_order="B"} {/if} {if !$auth.user_id} {include file="side_boxes/login.tpl"} {else} {include file="side_boxes/logout.tpl"} {/if} {if $settings.Modules.news_and_emails == 'Y'} {include file="addons/news_and_emails/side_boxes/news.tpl"} {/if} {if $settings.Modules.bestsellers == 'Y'} {include file="addons/bestsellers/sidebox.tpl"} {/if} {include file="side_boxes/recent_products.tpl"} {if $settings.Modules.ads == 'Y'} {include file="addons/ads/ads.tpl" location="R" show_order="A"} {/if} |
where do I added it in the main.tpl to make it work?
Hi taydu
Add it where you like on the left or right side:
Under:
{include file="side_boxes/site_info.tpl"}
{include file="side_boxes/stats.tpl"}
Or under:
{if $settings.Modules.bestsellers == 'Y'}
{include file="addons/bestsellers/sidebox.tpl"}
{/if}
{include file="side_boxes/stats.tpl"}
{include file="side_boxes/recent_products.tpl"}
when I added the code it my page won’t display
```php
{if $settings.Modules.bestsellers == ‘Y’}
{include file=“addons/bestsellers/sidebox.tpl”}
{/if}
{include file=“side_boxes/stats.tpl”}
{include file=“side_boxes/recent_products.tpl”}
{if $settings.Modules.ads == ‘Y’}
{include file=“addons/ads/ads.tpl” location=“R” show_order=“A”}
{/if}
{/if}
```
Hi taydu
Do you have a URL so i can see what is happening.
www.ftamegadiscount.com
it a live store so I temporary remove the code, let me known when you be able to see it so I can put the code back in
thanks
Hi taydu
Looking at it now
okay i just added the code back in
Hi taydu
Have a look here, i have just installed it in your template as we speak:
[URL=“http://www.megapcs4u.co.uk/mess/index.php”]http://www.megapcs4u.co.uk/mess/index.php[/URL]
You will have to go over the steps to make sure you have not missed anything.