Roggie Posted November 18, 2009 Posted November 18, 2009 Hey all... I am having 2 problems actually, the first is that I am repeatedly getting a 500 error when trying to access the "Whos Online" function of the admisistrative side of os Commerce. Initially, my host advised that I had offending code within Application_Bottoms.php , and in fact found a text line that was not coded correctly and also a missing semi=colon... This was corrected but I continue to get the 500 error. I also believe that there may be a problem within "Whos_Online.php". I have inserted both of these files below. I am NOT a programmer and have the barest of understanding of html and php. I AM able to make changes when instructed what the problem is. Please take a look at both files below, (applications_bottom.php & whos_Online.php), and see if you can identify a code problem that would produce a 500 error. My host company has begged off of trying to determine the problem as they say it is occuring within os Commerce and not their server. What might be pertinent, though I am not sure, is that I hadn't accessed the Whos online module in months. It was working fine when I did, but upon to trying to use it now, (I have a new advertising campaign), I am getting the 500 error. Interestingly the whos_online module works about 10% of the time. Constant refreshing will eventually produce the resultant report, but more often than not the error occurs. PLEASE help!!! First, here is the php file for Includes/Applications_bottom: <?php /* $Id: application_bottom.php 1739 2007-12-20 00:52:16Z hpdl $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ // close session (store variables) tep_session_close(); if (STORE_PAGE_PARSE_TIME == 'true') { $time_start = explode(' ', PAGE_PARSE_START_TIME); $time_end = explode(' ', microtime()); $parse_time = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3); error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ' - ' . getenv('REQUEST_URI') . ' (' . $parse_time . 's)' . "\n", 3, STORE_PAGE_PARSE_TIME_LOG); if (DISPLAY_PAGE_PARSE_TIME == 'true') { echo '<span class="smallText">Parse Time: ' . $parse_time . 's</span>'; } } if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded == true) && ($ini_zlib_output_compression < 1) ) { if ( (PHP_VERSION < '4.0.4') && (PHP_VERSION >= '4') ) { tep_gzip_output(GZIP_LEVEL); } ?> ***************************************************************************************** Now here is the php file for Whos_online.php (Includes/whos_online.php) <?php /* $Id: whos_online.php 1739 2007-12-20 00:52:16Z hpdl $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ function tep_update_whos_online() { global $customer_id; if (tep_session_is_registered('customer_id')) { $wo_customer_id = $customer_id; $customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); $customer = tep_db_fetch_array($customer_query); $wo_full_name = $customer['customers_firstname'] . ' ' . $customer['customers_lastname']; } else { $wo_customer_id = ''; $wo_full_name = 'Guest'; } $wo_session_id = tep_session_id(); $wo_ip_address = getenv('REMOTE_ADDR'); $wo_last_page_url = getenv('REQUEST_URI'); $current_time = time(); $xx_mins_ago = ($current_time - 900); // remove entries that have expired tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'"); $stored_customer_query = tep_db_query("select count(*) as count from " . TABLE_WHOS_ONLINE . " where session_id = '" . tep_db_input($wo_session_id) . "'"); $stored_customer = tep_db_fetch_array($stored_customer_query); if ($stored_customer['count'] > 0) { tep_db_query("update " . TABLE_WHOS_ONLINE . " set customer_id = '" . (int)$wo_customer_id . "', full_name = '" . tep_db_input($wo_full_name) . "', ip_address = '" . tep_db_input($wo_ip_address) . "', time_last_click = '" . tep_db_input($current_time) . "', last_page_url = '" . tep_db_input($wo_last_page_url) . "' where session_id = '" . tep_db_input($wo_session_id) . "'"); } else { tep_db_query("insert into " . TABLE_WHOS_ONLINE . " (customer_id, full_name, session_id, ip_address, time_entry, time_last_click, last_page_url) values ('" . (int)$wo_customer_id . "', '" . tep_db_input($wo_full_name) . "', '" . tep_db_input($wo_session_id) . "', '" . tep_db_input($wo_ip_address) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($wo_last_page_url) . "')"); } } ?> I am desperate to get this working... thanks Roggie
FIMBLE Posted November 18, 2009 Posted November 18, 2009 HiServer 500 errors are generally caused by file permissions being incorrect, they can be caused by a code error but the permissions should be the first thing to check. Make sure the file is at 644. I have attached to fresh copies of the above files for you to try out also Nic application_bottom.php whos_online.php Sometimes you're the dog and sometimes the lamp post [/url] My Contributions
Roggie Posted November 18, 2009 Author Posted November 18, 2009 HiServer 500 errors are generally caused by file permissions being incorrect, they can be caused by a code error but the permissions should be the first thing to check. Make sure the file is at 644. I have attached to fresh copies of the above files for you to try out also Nic Fimble, I cannot tell you how much I appreciate the assistance. Two things... I am not a programmer, at all. The file for "whos_online" that you've sent is considerable longer than the existing one... should I be inserting the one you've sent in its place? I am very afraid to try this unless and until I know its the right thing to do... Additonally, all the files in my entire database have permissions that are set to 755. I am hosted by Globat.com and they alerted me a couple of months ago that their service was going through a total upgrade. AS my site continued to work I didn't investigate exactly what was done. Should I change the permission on the one file, all of the files, what? Again I appreciate your assistance, and your patience...
FIMBLE Posted November 18, 2009 Posted November 18, 2009 Hi No problem, glad to help, if the permissions sorted out your problem discard the files i uploaded. As a rule of thumb for permisisons Folder 755, never higher ... if this causes you problems then contact your host, 777 is like locking the door and going out, but leaving your keys in the locked door Files that do not need write permissions, 644 or 444 if able to Files that need write access 666 Regards Nic Sometimes you're the dog and sometimes the lamp post [/url] My Contributions
Roggie Posted November 18, 2009 Author Posted November 18, 2009 Hi No problem, glad to help, if the permissions sorted out your problem discard the files i uploaded. As a rule of thumb for permisisons Folder 755, never higher ... if this causes you problems then contact your host, 777 is like locking the door and going out, but leaving your keys in the locked door Files that do not need write permissions, 644 or 444 if able to Files that need write access 666 Regards Nic
Roggie Posted November 18, 2009 Author Posted November 18, 2009 heh heh heh... I am too ignorant to decern some of your answers... so let me ask you some direct questions.... If you could answer them in turn it might help... 1. Can I just change the permissions number for the one file without ramificationsconsequences elsewhere on the site? 2. I don't know which files need write permissions and which don't. As mentioned previously, I am not a programmer.... I have the site for 18 mos and simply log into Admin to add products, process orders and view who's online. Everything seems to be working fine with the exception of who's online. I sent the exact files in my first email hoping to have someone spot an error if one exists. The permisssions issue that you've raised sounds plausible as Globat, (my host), did an upgrade some months ago and may have changed all the permisssions. I hate these folks.... Please addvise. Thanks Roggie
FIMBLE Posted November 18, 2009 Posted November 18, 2009 Hi All files change to 644 if one complains about not being able to write then you know it has to be changed. all folder change to 755. Im not sure off the top of my head how many (if any) need write permissions on a standard osc install Nic Sometimes you're the dog and sometimes the lamp post [/url] My Contributions
Roggie Posted November 18, 2009 Author Posted November 18, 2009 Hi All files change to 644 if one complains about not being able to write then you know it has to be changed. all folder change to 755. Im not sure off the top of my head how many (if any) need write permissions on a standard osc install Nic OK I changed on the "Whos_Online.php" to 644, no change... still getting a 500 error.... I didn't want to change the entire "Includes" directory.... so tried the fix on just the one file.... any other suggestions? Is there a way to check the code in the file for errors? Very frustrating.... also, remember I mentioned that in some cases, (very rare), the function DOES work. 9 time out of 10 it won't, but it's not a complete failure..... please advise...
FIMBLE Posted November 18, 2009 Posted November 18, 2009 I just noticed you said you file is in admin/ includes / whos_online.php was that an error? Nic Sometimes you're the dog and sometimes the lamp post [/url] My Contributions
Roggie Posted November 18, 2009 Author Posted November 18, 2009 I just noticed you said you file is in admin/ includes / whos_online.php was that an error? Nic The files is located at root/includes/functions/whos_online.php
FIMBLE Posted November 18, 2009 Posted November 18, 2009 OK but the file you need to be checking for permissions is your admin / whos_online.php I checked that includes / functions / whos_online.php with my copy and its an exact match Nic Sometimes you're the dog and sometimes the lamp post [/url] My Contributions
Roggie Posted November 18, 2009 Author Posted November 18, 2009 OK but the file you need to be checking for permissions is your admin / whos_online.php I checked that includes / functions / whos_online.php with my copy and its an exact match Nic Ohhhhhhhhhhh doing that now!
Roggie Posted November 18, 2009 Author Posted November 18, 2009 Wheeeeeeeeeeee!!!! Nic, you are the MAN!! That seems to have done the trick! I changed the permisssion to 644 of the "other" whos_Online and with 3 refreshes I'm getting the report everytime!!! I owe you BIG time!!! Thanks!!
FIMBLE Posted November 18, 2009 Posted November 18, 2009 thats OK im glad you got it sorted out :-) Nic Sometimes you're the dog and sometimes the lamp post [/url] My Contributions
Roggie Posted November 18, 2009 Author Posted November 18, 2009 thats OK im glad you got it sorted out :-) Nic Aw crap, I spoke too soon... It worked a couple of times and now the same 500 error... I don't understand why it works sometimes and then not othertimes.... oh well, I have to run an errand.... will be back in about 90 min.... thanks again Fimble...
MrPhil Posted November 18, 2009 Posted November 18, 2009 Common causes of '500' errors: http://www.oscommerce.com/forums/topic/345637-internal-server-error/page__view__findpost__p__1442374 Information on setting permissions in general: http://www.oscommerce.com/forums/index.php?showtopic=327395&view=findpost&p=1443272
Recommended Posts
Archived
This topic is now archived and is closed to further replies.