Jump to content

Recommended Posts

@@Jack_mcs

 

Hi Jack,

 

That one gives this error:

 

1048 - Column 'set_function' cannot be null

 

INSERT INTO configuration ( configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, use_function ) VALUES ('API Key','VIEW_COUNTER_API_KEY', 'Your API KEY', 'Enter your IPInfoDB.com API Key here.

 

You can get your key at http://ipinfodb.com/register.php', '6507', '2', NULL, now(), NULL)

 

[TEP STOP]


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

I tried it here in a 2.3.3.4 shop and didn't get any failures. It must be a server setting that is detecting it. But no matter, the code is wrong anyway. This should work - really. :)

   // create configuration variables
   $fields = " configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added, use_function ";
   $fields_short = " configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added ";
   $db_sql_array = array(array("INSERT INTO configuration (" . $fields . ")  VALUES ('ON/OFF', 'VIEW_COUNTER_ENABLED', 'false', 'View Counter <br>(true=on false=off)', '" . $configuration_group_id . "', '" . ($sortID++). "', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), NULL)"),
					  array("INSERT INTO configuration (" . $fields_short . ") VALUES ('API Key','VIEW_COUNTER_API_KEY', 'Your API KEY', 'Enter your IPInfoDB.com API Key here.<br><br>You can get your key at http://ipinfodb.com/register.php', '" . $configuration_group_id . "', '" . ($sortID++). "', now())"),
					  array("INSERT INTO configuration (" . $fields_short . ")  VALUES ('Active Time','VIEW_COUNTER_ACTIVE_TIME', '10', 'The numbre of minutes to show active visitors.', '" . $configuration_group_id . "', '" . ($sortID++). "', now())"),
					  array("INSERT INTO configuration (" . $fields . ")  VALUES ('Bad Bot Trap', 'VIEW_COUNTER_BAD_BOT_TRAP', 'Email', 'Choose how to handle the bad bot trap.<br><br><b>Ban:</b> Ban the IP<br><b>Email:</b> Send an Email containing the IP<br><b>Both:</b> Both of the above<br><b>Off:</b> Nothing will be done', '" . $configuration_group_id . "', '" . ($sortID++). "', 'tep_cfg_select_option(array(\'Ban\', \'Email\', \'Both\', \'Off\'), ', now(), NULL)"),
					  array("INSERT INTO configuration (" . $fields_short . ")  VALUES ('Force Reset','VIEW_COUNTER_FORCE_RESET', '2', 'The maximum number of days to keep the IP\'s in the database. The View counter table will grow very large if not cleared and data over a few days is probably of no use.', '" . $configuration_group_id . "', '" . ($sortID++). "', now())"),
					  array("INSERT INTO configuration (" . $fields_short . ")  VALUES ('Force Reset Storage','VIEW_COUNTER_FORCE_RESET_STORAGE', '14', 'The maximum number of days to keep the IP\'s in the storage table. This table is used for reports. It will grow very large if not cleared on a regular basis.', '" . $configuration_group_id . "', '" . ($sortID++). "', now())"),
					  array("INSERT INTO configuration (" . $fields_short . ")  VALUES ('Hide Admin Links','VIEW_COUNTER_HIDE_ADMIN_LINKS', '', 'Do not show admin links for these IP\'s. Use a comma separted list for multiple IP\'s.', '" . $configuration_group_id . "', '" . ($sortID++). "', now())"),
					  array("INSERT INTO configuration (" . $fields . ")  VALUES ('Kick Off', 'VIEW_COUNTER_ENABLE_KILL_SESSION', 'false', 'Enable the ability to kick off customes.', '" . $configuration_group_id . "', '" . ($sortID++). "', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), NULL)"),
					  array("INSERT INTO configuration (" . $fields_short . ")  VALUES ('Page Refresh Period','VIEW_COUNTER_PAGE_REFRESH', '120', 'How often, in seconds, to refresh the main page in admin.', '" . $configuration_group_id . "', '" . ($sortID++). "', now())"),
					  array("INSERT INTO configuration (" . $fields_short . ")  VALUES ('Rows Per Page','VIEW_COUNTER_MAX_ROWS', '20', 'The maximum number of rows to display in the list.', '" . $configuration_group_id . "', '" . ($sortID++). "', now())"),
					  array("INSERT INTO configuration (" . $fields_short . ")  VALUES ('Send Emails To','VIEW_COUNTER_SEND_EMAILS_TO', '', 'The email address any emails created by View Counter will be sent to. If left empty, the shops email address will be used.', '" . $configuration_group_id . "', '" . ($sortID++). "', now())"),
					  array("INSERT INTO configuration (" . $fields . ")  VALUES ('Show Flags', 'VIEW_COUNTER_SHOW_FLAGS', 'true', 'Display the country flags. Turning this off will speed up the display. <br>(true=on false=off)', '" . $configuration_group_id . "', '" . ($sortID++). "', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), NULL)"),
					  array("INSERT INTO configuration (" . $fields . ")  VALUES ('Show Account Details', 'VIEW_COUNTER_SHOW_ACCOUNT_DETAILS', 'true', 'Display the account details of the visitor, if possible. If multiple accounts exist, they will all be shown. Enabling this option may cause a slow-down, depending upon the site. <br>(true=on false=off)', '" . $configuration_group_id . "', '" . ($sortID++). "', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), NULL)"),
					  array("INSERT INTO configuration (" . $fields . ")  VALUES ('Version Checker', 'VIEW_COUNTER_ENABLE_VERSION_CHECKER', 'false', 'Enable to automatically check if a new version is available. <br>(true=on false=off)', '" . $configuration_group_id . "', '" . ($sortID++). "', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now(), NULL)"));

Share this post


Link to post
Share on other sites

Thanks Jack,

 

That Sql change worked :)

 

However, had to make a couple of changes to the files:

 

admin/view_counter.php line changed

require(DIR_WS_CLASSES . 'ip2location.php');

to

require(DIR_WS_CLASSES . 'ip2locationlite.class.php');

 

without the above change I was getting a Blank page.

 

However I now see on the monitor page the screenshot below, with no errors in the admin error log:

post-253268-0-91354800-1388744696_thumb.png


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

I apologize for all of the problems. When this was initially written, ip2location.com had an online database where the code would download the IP data as it ran. But, for whatever reason, they decided to move to a database that had to be downloaded and interrogated locally. So I had to rewrite quite a bit of the code and I forgot that they changed the class file so that didn't make it into the package. I'll do that in the next version but for now, please go to http://www.ip2location.com/developers/php and download the IP2Location PHP module (near the top of the page). Extract the IP2Location.php file and upload it into the admin classes directory. If you have already gotten your key and downloaded the database, renamed and uploaded it, then it should work at that point.

Share this post


Link to post
Share on other sites

Thanks Jack,

 

Downloaded the IP2Location.php from that location - uploaded it to admin/includes/classes (made sure the name was the same with regards to capitals etc) and on the monitor screen I still get as per the screenshot above - even though there are live customers on the site.

 

Sorry to be a pain.....


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

Are we supposed to leave the file zipped and rename the zip; unzip the folder and rename the folder, or unzip and rename one of the files in the contents?

Share this post


Link to post
Share on other sites

@@newburns extract and rename the file IP2Location.php to ip2location.php

 

Now it works as it should - Untick the "Spoofed Only" box on the monitor screen.

 

Thanks Jack - looks good!


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

Oh - One last thing from me - the DB you suggested to download and unzip (the 72mb one) turned out to be 400+ mb when unzipped - so I went for one of the lighter databases to save some space...........


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

That's what I'm asking about. Extract the DB and rename folder or a certain file? There's a video file in there.

Share this post


Link to post
Share on other sites

just the large file in the folder


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

@@Mort-lemur Yes, the database file is huge but it does give the most information about an IP. You can look at the descriptions on the download page (right column) and see the data that is available. If you don't want all of those fields, then choosing one of the smaller databases is fine.

Share this post


Link to post
Share on other sites

Thanks Jack,

 

All is working well now :)

 

How is the kick-off and banned messages generated and displayed to the customers? I cant seem to work that one out.

 

Many Thanks


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

Good. I'm glad to hear it is working. For the messages to work, you first have to enable the "Kick Off" option in the settings. For the kick off message, it is coded in the includes/languages/English.php fil (see TEXT_VIEW_COUNTER_KILL_MESSAGE). If you want to send a customer a friendly message, that is done in the tools section. For both of those, I suggest clicking around your site to generate an entry in View Counter and then using those features on your IP. They won't affect anyone else.There isn't a message sent when banning and IP since the person wouldn't be able to see it.

Share this post


Link to post
Share on other sites

I don't understand if I'm missing files or what ...

 

A lot of options result in a non-existent page not-for-use.php

Also, all of the tools seem to require .htacess to be Apache writable. I am not keen on having world writable files.

Secondly, the htaccess rewrite won't work for me because my web URL is mtrosemedia.org/store/view_counter_trap.php and the rewrite is mtrosemedia.org/view_counter_trap.php

Lastly, this is my .htaccess file... how am I supposed to utilize the addon. Any country I select in the Country Blocking does not load into the .htaccess when I have it world writable.

<IfModule mod_headers.c>
 <FilesMatch "\.(js|css|xml|gz)$">
   Header append Vary Accept-Encoding
 </FilesMatch>
</IfModule>
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$">
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 30 days"
</IfModule>
Header unset ETag
FileETag None
</FilesMatch>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# Or, compress certain file types by extension:
<files *.html>
SetOutputFilter DEFLATE
</files>
Options +FollowSymLinks
RewriteEngine On
# view counter trap anyone trying to access admin
RewriteCond %{REQUEST_URI} \"/admin/\"
RewriteRule (.*) view_counter_trap.php [L]
# Begin IP deny by View Counter from www.oscommerce-solution.com
order allow,deny
allow from all
# End IP deny by View Counter from www.oscommerce-solution.com

Share this post


Link to post
Share on other sites

There's nothing in the code that uses not-for-use.php so that seems to be a problem in your shop.

 

There's nothing in the instructions that state the .htaccess file should be world-writeable. It needs to be user-writeable but that is the standard setting on most servers. But if you want to set the permissions to not writeable at all, then you can't use the tools in this addon. But, in that case, you also cannot use the tools in your control panel that allow setting some option that uses the .htaccess file.

 

The code to write to the .htaccess file uses the shops configure settings. if it is writing to the wrong location, then your confiugre file is not setup correctly.

 

Country blocking isn't done using the .htaccess file. You select the countries to be blocked in the tools section and the code handles it from there.

Share this post


Link to post
Share on other sites

Jack,

 

A couple of observations from me as this is not quite functioning correctly on my 2.3.3.4 store on php 5.4.21:

  • The auto refresh is not functioning - it counts down to zero then continues counting in Minus numbers
  • I have tried sending messages to users (myself) both as friendly and as Kick-Off - these are not displayed to the customer


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

For the auto-refresh, find this line in the admin/includes/view_counter_header.php file

 require(DIR_WS_INCLUDES . 'template_top.php');

and add this below it

 if (basename($_SERVER['PHP_SELF']) == FILENAME_VIEW_COUNTER) { ?>
   <meta http-equiv="refresh" content="<?php echo VIEW_COUNTER_PAGE_REFRESH; ?>">
<?php
 }

For the kick off message, I don't know what that might be. It is working here and all of the shops I've installed it into, though only two have been 2.3.3.4. When you click the Kick button in admin, is a success message displayed at the top of the page? If so, be sure the line you click on is active. Session ID's are stored and if you have and option to change them or you click on an old one, the customer would never see the message. Please try this. Go to the shop and login and click on some page. In View Counter, you should see your name and the last page you chose. Click Kick for that line. Does it still fail?

Share this post


Link to post
Share on other sites

@@Jack_mcs Thanks Jack,

The code change has got the auto-refresh working now.

 

I tried the Kick test you suggested - I get a success message in admin saying IP xxxxxxx has been kicked - but I am still logged on as a customer and no message is seen.


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

Did you try to click something on the shop side after sending the kick message? The message doesn't display until the next click on the shop side. Does it work if you turn off all of the settings in admin->Configuration->Sessions, except for prevent spider?

Share this post


Link to post
Share on other sites

@@Jack_mcs nope - Only setting I had true was force cookies - turned that off and no difference - I can stay logged on and continue to browse the site with no messages.

 

Would the fact that Im using configuration cache affect this?

 

Thanks


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

I see an error has appeared in the catalog error log:

 

PHP Warning: session_destroy(): Trying to destroy uninitialized session in /home/xxxxxx/public_html/includes/functions/sessions.php on line 166
.

 

Lines 165 & 166 are :

function tep_session_destroy() {
   return session_destroy();


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

I don't think configuration cache is causing a problem because the kick off setting is being seen. That error you are seeing can only occur (with regards to View Counter) if the kick off message is received on the shop side. It seems the stored session ID isn't matching the active one for some reason. Please try this. In includes/modules/view_counter.php, find

		 tep_db_query("delete from " . TABLE_VIEW_COUNTER_SESSION_KILL . " where session_id = '" . tep_db_input(tep_session_id()) . "'");
		 tep_session_destroy($sid);

and add this above it

		 if (isset($_GET['test'])) {
			 echo 's1= '.$sid.'<br>s2= '. tep_db_input(tep_session_id()) . '<br>s3= '.tep_session_id();
		 }

Then go to the shop side and click on some link to make sure the session is active. Then go to the View Counter and kick off that IP. Then on the shop side, click in the url box and add ?test, or if there is already a ? in the url, add &test and press enter. You should see two strings displayed. Do they match?

 

Also, either before or after the above, go into the database and empty the view_counter and view_counter_session_kill tables and try the kick off option.

Edited by Jack_mcs

Share this post


Link to post
Share on other sites

Thanks Jack,

 

Tried that - no kick off and no messages displayed when I input ?test at the end of the url after modding the code. - I emptied both database tables prior to trying this 3 times - both as guest and as a loggod on customer. - Got the same error message in my log as above.

 

Im wondering if the sessions are not being created correctly - as when I hover over some of the active "File Name" entries on the monitor pane I get the message "The session ID does not exist or is invalid"

 

This is the same on both 2.3.3.4 sites I have installed this on...


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

Could this be down to the was sessions are handled / stored / accessed on 2.3.3.4 and Php 5.4 ?


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

Those results don't make sense to me. You said you see the message sent successfully in admin and the failure on the shop side can only occur if the message is received yet you are not getting anything printed out. Even if it were missing the session ID completely, it should display something. All I can think is that this may have something to do with php 5.4 since my version here is 5.3.I will setup 5.4 and test it when I can find the time, though I don't know when that will be.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×