Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

This site can’t be reached 127.0.0.1


josh1r

Recommended Posts

Hi. I'm using a very old version of osc (I honestly don't recall which one, nor do I recall how to check, as it's been ages since I've worked on my site).  

In any case, I just noticed this error:  This site can’t be reached 127.0.0.1 refused to connect. Try: Checking the connection Checking the proxy and the firewall ERR_CONNECTION_REFUSED

I contacted my webhost who said:

"It seems that the website is set to redirect its home URL to 127.0.0.1, which is localhost. I attempted to manually check your files and database for any entries for this, but I was unable to find how to alleviate it from the server side."

Again, I haven't made any changes to the site in many months/years, so I assume the host changed something on their end that would have caused the issue.  If I manually type in a url from the website, I can completely browse the site.  It seems that only going to the home page of / or /index.php causes the problem.  

Any thoughts on how to fix this?

Thank you!
 

 

Link to comment
Share on other sites

The cause will most likely be in either the includes/configure.php file or the roots .htaccess file. I think the latter is the more likely. There is probably incorrect redirect code in it. You can post it here if you would like someone to look at it.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Thank you.  here is my htaccess.  i changed my website same to just 'domain' for now.

i'm sure the below is a mess as it's been updated over the years many times, though has not been touched in a few years so i'm not sure why i'm suddenly having issues.

thank you.

 

deny from 109.187.84.170

<IfModule mod_dtimeout.c>
<Files ~ ".php">
   SetEnv DynamicTimeout 300
</Files>
</IfModule>


RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
RewriteCond %{HTTP_USER_AGENT} (bot|crawl|robot)
RewriteCond %{HTTP_USER_AGENT} !(bing|Google|msn|MSR|Twitter) [NC]
RewriteRule ^/?.*$ "http\:\/\/127\.0\.0\.1" [R,L]


ErrorDocument 404 /404.php
#ErrorDocument 403 /404.php

Options -Indexes
Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]


RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  # Change RewriteBase using the instructions above  
  RewriteBase / 
  RewriteRule ^([a-z0-9/-]+)-p-([0-9]+).html$ product_info.php [NC,L,QSA]
  RewriteRule ^([a-z0-9/-]+)-c-([0-9_]+).html$ index.php [NC,L,QSA]
  RewriteRule ^([a-z0-9/-]+)-m-([0-9]+).html$ index.php [NC,L,QSA]
  RewriteRule ^([a-z0-9/-]+)-pi-([0-9]+).html$ popup_image.php [NC,L,QSA]
  RewriteRule ^([a-z0-9/-]+)-pr-([0-9]+).html$ product_reviews.php [NC,L,QSA]
  RewriteRule ^([a-z0-9/-]+)-pri-([0-9]+).html$ product_reviews_info.php [NC,L,QSA]
 # Articles contribution
  RewriteRule ^([a-z0-9/-]+)-t-([0-9_]+).html$ articles.php [NC,L,QSA]
  RewriteRule ^([a-z0-9/-]+)-au-([0-9]+).html$ articles.php [NC,L,QSA]
  RewriteRule ^([a-z0-9/-]+)-a-([0-9]+).html$ article_info.php [NC,L,QSA]
 # Information pages
  RewriteRule ^([a-z0-9/-]+)-i-([0-9]+).html$ information.php [NC,L,QSA]
 # Links contribution
  RewriteRule ^([a-z0-9/-]+)-links-([0-9_]+).html$ links.php [NC,L,QSA]
 # Newsdesk contribution
 RewriteRule ^([a-z0-9/-]+)-n-([0-9]+).html$ newsdesk_info.php [NC,L,QSA]
 RewriteRule ^([a-z0-9/-]+)-nc-([0-9]+).html$ newsdesk_index.php [NC,L,QSA]
 RewriteRule ^([a-z0-9/-]+)-nri-([0-9]+).html$ newsdesk_reviews_info.php [NC,L,QSA]
 RewriteRule ^([a-z0-9/-]+)-nra-([0-9]+).html$ newsdesk_reviews_article.php [NC,L,QSA]


RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

<ifModule mod_deflate.c>
 AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
</ifModule>

<IfModule mod_expires.c>
   ExpiresActive on
   ExpiresByType text/html "access 1 week"
   ExpiresByType text/css "access 1 week"
   ExpiresByType application/javascript "access 1 month"
   ExpiresByType text/plain "access 1 month"
   ExpiresByType image/jpg "access 1 month"
   ExpiresByType image/gif "access 1 month"
   ExpiresByType image/png "access 1 month"
   ExpiresByType application/pdf "access 1 month"
   ExpiresByType application/x-shockwave-flash "access 1 month"
   ExpiresDefault "access 1 week" 
  </IfModule>
  
  # BEGIN Cache-Control Headers
<ifModule mod_headers.c>
  <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
    Header set Cache-Control "public"
  </filesMatch>
  <filesMatch "\.(css)$">
    Header set Cache-Control "public"
  </filesMatch>
  <filesMatch "\.(js)$">
    Header set Cache-Control "private"
  </filesMatch>
  <filesMatch "\.(html|php)$">
    Header set Cache-Control "private, must-revalidate"
  </filesMatch>
</ifModule>
# END Cache-Control Headers
<Files 403.shtml>
order allow,deny
allow from all
</Files>

deny from 173.192.238.1/32
deny from 173.192.238.2/31
deny from 173.192.238.4/30
deny from 173.192.238.8/29
deny from 173.192.238.16/28
deny from 173.192.238.32/27
deny from 173.192.238.64/27
deny from 173.192.238.96/30
deny from 174.36.241.1/32
deny from 174.36.241.2/31
deny from 174.36.241.4/30
deny from 174.36.241.8/29
deny from 174.36.241.16/28
deny from 174.36.241.32/27
deny from 174.36.241.64/26
deny from 174.36.241.128/26
deny from 174.36.241.192/27
deny from 174.36.241.224/28
deny from 174.36.241.240/29
deny from 174.36.241.248/31
deny from 174.36.241.250/32
deny from 174.36.228.1/32
deny from 174.36.228.2/31
deny from 174.36.228.4/30
deny from 174.36.228.8/29
deny from 174.36.228.16/28
deny from 174.36.228.32/27
deny from 174.36.228.64/26
deny from 174.36.228.128/26
deny from 174.36.228.192/27
deny from 174.36.228.224/28
deny from 174.36.228.240/29
deny from 174.36.228.248/31
deny from 174.36.228.250/32

BrowserMatchNoCase yandex  tard
BrowserMatchNoCase spinn3r  tard

Order Deny,Allow 
Deny from 94.228.34.*      
Deny from 5.10.83.*      
Deny from 74.215.156.*      
Deny from env=tard

BrowserMatchNoCase crawl bad_bot
Order Deny,Allow
Deny from env=bad_bot
deny from 94.228.34.249
deny from 92.19.126.136
deny from 68.168.103.200
#deny from 185.25.32.39
deny from 163.172.16.139
deny from 163.172.0.0/16
deny from 212.83.0.0/16
deny from 64.62.252.162
AddHandler application/x-httpd-php52 .php .php5 .php4 .php3
 

Link to comment
Share on other sites

RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
RewriteCond %{HTTP_USER_AGENT} (bot|crawl|robot)
RewriteCond %{HTTP_USER_AGENT} !(bing|Google|msn|MSR|Twitter) [NC]
RewriteRule ^/?.*$ "http\:\/\/127\.0\.0\.1" [R,L]

hash this out, then if necessary clear your browser cache, and check.

Link to comment
Share on other sites

That unfortunately didn't help

However, after changing php version to a newer one, but then reverting to the older version of 5.2 that I've been using (since my old version of osc can't handle newer php), https://www.domain.com/index.php now works fine, although https://www.domain.com still gives the 127...error.  

Any idea why not having index.php would work?  

Separately, and I haven't looked into this yet, is it remotely easy to get my old osc working with newer php?  Or is that going to be an overwhelming task?

Link to comment
Share on other sites

RewriteRule ^/?.*$ "http\:\/\/127\.0\.0\.1" [R,L]

This is clearly the rule causing the redirect to 127.0.0.1

I don't see how changing the php version would have any effect here.

Your old osC can be patched to work on php 7+. You need to add a debugger to show you the errors, then you can ask for advice here on the open forum on how to fix them. Alternatively you need to hire someone to do that task for you.

Link to comment
Share on other sites

I completely removed the line above mentioning the 127 from my .htaccess file and it still doesn't work :(

Regarding the debugger, can you point me in the right direction to get started?

Thank you again.

Link to comment
Share on other sites

10 minutes ago, Hotclutch said:

You sure you cleared your browser cache ? That may cause you to think the htaccess change is not working.

yeah, even tried different browsers and other computers.

as for the debugger.  i have it installed and am seeing various items on the screen (I set it to 'screen' for now).  how do i best proceed in figuring out what is causing errors due to php version?  do i need to first change php version at my host, then see what happens?  normally i can't get the site to work at all if the php is too new.

Link to comment
Share on other sites

In your host control panel there may be an option under php configuration -> display errors. If it is set to off, then you may need to turn it on.

You need to change the php version to see the errors. V2.3.4.1 patched can run on php7.4

Most of the errors will be of the type:

1) The each() function is deprecated.

2) Methods with the same name as their class will not be constructors in a future version of PHP

Depending on how far back you are, you may have more work to do.

Link to comment
Share on other sites

2.2 is very old. You are going to have to see how much work is involved.

Backup your site files and database before starting this work so that you can rollback if necessary. This is an updated includes/functions/compatibility.php

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2012 osCommerce

  Released under the GNU General Public License
*/

////
// Recursively handle magic_quotes_gpc turned off.
// This is due to the possibility of have an array in
// $HTTP_xxx_VARS
// Ie, products attributes
  function do_magic_quotes_gpc(&$ar) {
    if (!is_array($ar)) return false;

    foreach($ar as $key => $value) {
      if (is_array($ar[$key])) {
        do_magic_quotes_gpc($ar[$key]);
      } else {
        $ar[$key] = addslashes($value);
      }
    }
    reset($ar);
  }

  if (PHP_VERSION >= 4.1) {
    $HTTP_GET_VARS =& $_GET;
    $HTTP_POST_VARS =& $_POST;
    $HTTP_COOKIE_VARS =& $_COOKIE;
    $HTTP_SESSION_VARS =& $_SESSION;
    $HTTP_POST_FILES =& $_FILES;
    $HTTP_SERVER_VARS =& $_SERVER;
  } else {
    if (!is_array($HTTP_GET_VARS)) $HTTP_GET_VARS = array();
    if (!is_array($HTTP_POST_VARS)) $HTTP_POST_VARS = array();
    if (!is_array($HTTP_COOKIE_VARS)) $HTTP_COOKIE_VARS = array();
  }

// handle magic_quotes_gpc turned off.
  #if (!get_magic_quotes_gpc()) {
    #do_magic_quotes_gpc($HTTP_GET_VARS);
    #do_magic_quotes_gpc($HTTP_POST_VARS);
    #do_magic_quotes_gpc($HTTP_COOKIE_VARS);
  #}

// set default timezone if none exists (PHP 5.3 throws an E_WARNING)
  if (PHP_VERSION >= '5.2') {
    date_default_timezone_set(defined('CFG_TIME_ZONE') ? CFG_TIME_ZONE : date_default_timezone_get());
  }

  if (!function_exists('checkdnsrr')) {
    function checkdnsrr($host, $type) {
      if(tep_not_null($host) && tep_not_null($type)) {
        @exec("nslookup -type=" . escapeshellarg($type) . " " . escapeshellarg($host), $output);
        foreach($output as $k => $line) {
          if(preg_match("/^$host/i", $line)) {
            return true;
          }
        }
      }
      return false;
    }
  }

/*
 * stripos() natively supported from PHP 5.0
 * From Pear::PHP_Compat
 */

  if (!function_exists('stripos')) {
    function stripos($haystack, $needle, $offset = null) {
      $fix = 0;

      if (!is_null($offset)) {
        if ($offset > 0) {
          $haystack = substr($haystack, $offset, strlen($haystack) - $offset);
          $fix = $offset;
        }
      }

      $segments = explode(strtolower($needle), strtolower($haystack), 2);

// Check there was a match
      if (count($segments) == 1) {
        return false;
      }

      $position = strlen($segments[0]) + $fix;

      return $position;
    }
  }
?>

 

Link to comment
Share on other sites

Thank you and, to confirm, if I upload the compatibility file above,  will it make changes to other files/dbase (hence that's what I need to backup)?  

Assuming I try this, what happens next (i.e. might it magically fix the site and make it work with higher versions of php, will it generate errors showing what else I need to fix, or might it just break the site)?  

Link to comment
Share on other sites

6 hours ago, Hotclutch said:

You need to turn php 7 on, if your site breaks, then you have to look at the error that's causing it. 

Thank you.  Where will I find the errors?  Just in the browser itself, or is there some reporting somewhere?  

And, in your best guesstimate, based on my very old version, are there likely to be a ton of errors/it won't be easy to fix, or is there a chance I get lucky and it's not so bad?  

Link to comment
Share on other sites

@josh1rI suggest  you rename the .htaccess file to .htaccessOFF and the try going to the site with no file name in the url. If it works, the problem is in that file. Note that doing this may prevent parts of the shop from working so don't leave it changed. Just rename it for a quick test and rename it back.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

5 minutes ago, Jack_mcs said:

@josh1rI suggest  you rename the .htaccess file to .htaccessOFF and the try going to the site with no file name in the url. If it works, the problem is in that file. Note that doing this may prevent parts of the shop from working so don't leave it changed. Just rename it for a quick test and rename it back.

Thank you.  I still get the error w/o having an .htacess or renaming it.  Other parts of the site of course break, but the plain www.domain.com still gives the error.

Link to comment
Share on other sites

1 hour ago, josh1r said:

I still get the error w/o having an .htacess or renaming it.

Are you saying that if you go to your site without a file name, like ...com/ that it redirects to 127.0.0.1? If so, then check your includes/application_top.php file for that IP or any redirect code to an external site. If you can't find it, then it would have to be due to your server or something with your computer. To make sure it is not the latter, enter your url in http://kproxy.com and see if the problem still exists. If it does, then it is your server. I know your host said otherwise but that doesn't mean it is true.

I suppose one final possibility is that your code has hacker code in it. To check that, copy all of your files to your computer and search for the IP and any link to http:// and https://. The last two will return some results since some modules will have url's so you need to evaluate each one to see if they are valid or not.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...