Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Smart Search and PHP7

 
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4
 
Thread Tools
  #1  
Old 01-24-2017, 02:13 AM
 
susilosaja susilosaja is offline
 

Advanced Member
  
Join Date: Feb 2013
Posts: 88
 

Default Smart Search and PHP7

Has anyone tried making the latest unencrypted version of Smart Search to work on PHP7? I just upgraded to PHP7, and found some errors with it.

On the front-end, the ajax predictive search show some errors regarding the use of some deprecated functions, the mysql_ functions and preg_replace. Managed to fix these.

On the back-end, opening Tools - Smart Search just show a blank page.
__________________
Susilo
X-Cart 4.7.6 Gold Plus
Template : Ultra Responsive Template
Search module : Cloud Search
PHP 7
Reply With Quote
  #2  
Old 01-24-2017, 11:13 AM
  BCSE's Avatar 
BCSE BCSE is online now
 

X-Guru
  
Join Date: Apr 2003
Location: Ohio - bcsengineering.com
Posts: 3,060
 

Default Re: Smart Search and PHP7

We could help you if you'd like to drop us an email. We would need access to the apache error log file to see what is wrong so we can better quote.

http://www.bcsengineering.com/free_quote/

thanks!

Carrie
__________________
Custom Development, Custom Coding and Pre-built modules for X-cart since 2002!

We support X-cart versions 3.x through 5.x!

Home of the famous Authorize.net DPM & CIM Modules, Reward Points Module, Point of Sale module, Speed Booster modules and more!


Over 200 X-cart Mods available & Thousands of Customizations Since 2002 - bcsengineering.com

Please E-Mail us for questions/support!
Reply With Quote
  #3  
Old 01-24-2017, 06:06 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Smart Search and PHP7

we can get this fixed for you. Just open a ticket at https://www.cflsystems.com/support/
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #4  
Old 02-05-2017, 09:12 PM
 
mattstyle2 mattstyle2 is offline
 

Advanced Member
  
Join Date: Apr 2015
Posts: 54
 

Default Re: Smart Search and PHP7

I got alterdcart onepage checkout to work with php 7 and xc4.7.7

remove:
PHP Code:
// Redefine mysql_real_escape_string for PHP 7 (X-Cart 4.7.x)
if (!function_exists('mysql_real_escape_string') AND class_exists('XCDbCommon'))
{
    
// Extend X-Cart DB class to get protected $link value
    
if (!class_exists('SD_XCDbCommon'))
    {
        class 
SD_XCDbCommon extends XCDbCommon {
            public function 
getLink()
            {
                global 
$sql_obj;
                return 
$sql_obj->link;
            }
        }
    }

    
// Overwrite mysql_real_escape_string with mysqli_real_escape_string
    
function mysql_real_escape_string ($string '')
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_real_escape_string($link->getLink(), $string);
    }


from modules/cdseolinks/cdseo_config.php if you have that installed.. if not just add the code below to init.php

and move it to
/init.php after
PHP Code:
func_set_time_limit(SECONDS_PER_MIN 5); 

and add a mysql_insert_id function so it looks like this

PHP Code:
// smarty3 needs a lot of time to compile all templates_c from scratch
func_set_time_limit(SECONDS_PER_MIN 5);

// Redefine mysql_real_escape_string for PHP 7 (X-Cart 4.7.x)
if (!function_exists('mysql_real_escape_string') AND class_exists('XCDbCommon'))
{
    
// Extend X-Cart DB class to get protected $link value
    
if (!class_exists('SD_XCDbCommon'))
    {
        class 
SD_XCDbCommon extends XCDbCommon {
            public function 
getLink()
            {
                global 
$sql_obj;
                return 
$sql_obj->link;
            }
        }
    }

    
// Overwrite mysql_real_escape_string with mysqli_real_escape_string
    
function mysql_real_escape_string ($string '')
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_real_escape_string($link->getLink(), $string);
    }
    function 
mysql_insert_id ()
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_insert_id($link->getLink());
    }
    
}

/**
 * Allow displaying content in functions, registered in register_shutdown_function()
 */
$zlib_oc ini_get('zlib.output_compression'); 

This will bring back the old mysql functions


then mod /modules/Checkout_One/JSON.php (not sure this is required but I had to do it for hhvm to work).

PHP Code:
function encodeUnsafe($var)
    {
        
// see bug #16908 - regarding numeric locale printing
       // $lc = setlocale(LC_NUMERIC, 0);
       // setlocale(LC_NUMERIC, 'C');
        
$ret $this->_encode($var);
        
//setlocale(LC_NUMERIC, $lc);
        
return json_encode($var);
        
//        return $ret;
        
    

change that function to use json_encode

finally change a template file:
/skin/common_files/modules/Checkout_One/checkout_one_payment_methods.tpl
line 29:
PHP Code:
{foreach from=$payment_methods item=v}
                        <
tbody{* matt remvoe if $v.membershipids || $v.is_cod == 'Y'style="display:none;"{/if*} id="radio_trcell_{$v.paymentid}">
                            <
tr class="{cycle values='rowA,rowB'}"

just comment out the code to make things display:none.. The radio buttons for payment were not available.

seems to work.. I did a test order with a bad cc # and it declined it.. Using BSCE's authorize.net's DPM mod.. Still nned to figure out a way to subscribe mail chimp users still.. I'll update this as I work on it.

also, there's a few @mysql_query functions in the Checkout_One code you need to change to @db_query

find those..
cd modules/Checkout_One
grep -r --include="*.php" "@mysql_query"

find all instances and change to "@db_query"
there's not that many.





-Matt
__________________
4.7.7.
php7.1, AWS RDS database
memcache, reboot theme AWS EC2 load balancer, 2 c5.large instances CDSEO Shop By Filters,
AC onepage checkout and checkout tools,
altercart cash rewards, bcse DPM for paypal
Reply With Quote

The following 2 users thank mattstyle2 for this useful post:
Thomasb134 (04-20-2019), zone1creative (09-12-2018)
  #5  
Old 02-05-2017, 10:20 PM
 
xim xim is offline
 

X-Cart team
  
Join Date: Nov 2004
Posts: 677
 

Default Re: Smart Search and PHP7

Check this cloud service: https://market.x-cart.com/addons/cloudsearch.html

It provides more functionality than SmartSearch
__________________
Sincerely yours, Max Vydrin
Reply With Quote
  #6  
Old 02-07-2017, 08:12 PM
 
susilosaja susilosaja is offline
 

Advanced Member
  
Join Date: Feb 2013
Posts: 88
 

Default Re: Smart Search and PHP7

Thanks for both the offers regarding Smart Search. I managed to fix it. Tools - Smart Search on the backend showed a blank page because it still uses the deprecated mysql_query function. It didn't show the error because there was this error suppresing operator '@' in front of those functions. The fix is just basically replacing all mysql_query function with xcart's db functions.
__________________
Susilo
X-Cart 4.7.6 Gold Plus
Template : Ultra Responsive Template
Search module : Cloud Search
PHP 7
Reply With Quote
  #7  
Old 02-07-2017, 08:25 PM
 
susilosaja susilosaja is offline
 

Advanced Member
  
Join Date: Feb 2013
Posts: 88
 

Default Re: Smart Search and PHP7

Quote:
Originally Posted by xim
Check this cloud service: https://market.x-cart.com/addons/cloudsearch.html

It provides more functionality than SmartSearch

The drawback I find with Cloud Search is that it couldn't search on custom fields, which I do need. And the pricing. Other than that it seems like good stuff.
__________________
Susilo
X-Cart 4.7.6 Gold Plus
Template : Ultra Responsive Template
Search module : Cloud Search
PHP 7
Reply With Quote
  #8  
Old 02-07-2017, 08:41 PM
 
mattstyle2 mattstyle2 is offline
 

Advanced Member
  
Join Date: Apr 2015
Posts: 54
 

Default Re: Smart Search and PHP7

Quote:
Originally Posted by susilosaja
The drawback I find with Cloud Search is that it couldn't search on custom fields, which I do need. And the pricing. Other than that it seems like good stuff.


you can modify modules/Cloud_Search/func.php

to make it search custom fields!
just mod the query
func_query("
SELECT p.product AS name,
p.productcode AS sku,
p.descr AS description,
p.fulldescr AS fullDescription,
p.productid AS id,
p.keywords AS keywords,

then append to description:
$products[$k]['description'].=" ".$p['keywords'];

--- how bout that?!

CS is pretty cheap compared to other search providers such as SLI search.

-Matt
__________________
4.7.7.
php7.1, AWS RDS database
memcache, reboot theme AWS EC2 load balancer, 2 c5.large instances CDSEO Shop By Filters,
AC onepage checkout and checkout tools,
altercart cash rewards, bcse DPM for paypal
Reply With Quote

The following user thanks mattstyle2 for this useful post:
susilosaja (03-02-2017)
  #9  
Old 02-07-2017, 11:44 PM
 
susilosaja susilosaja is offline
 

Advanced Member
  
Join Date: Feb 2013
Posts: 88
 

Default Re: Smart Search and PHP7

Quote:
Originally Posted by mattstyle2
you can modify modules/Cloud_Search/func.php

to make it search custom fields!
just mod the query
func_query("
SELECT p.product AS name,
p.productcode AS sku,
p.descr AS description,
p.fulldescr AS fullDescription,
p.productid AS id,
p.keywords AS keywords,

then append to description:
$products[$k]['description'].=" ".$p['keywords'];

--- how bout that?!

CS is pretty cheap compared to other search providers such as SLI search.

-Matt

Thanks! I might look into this again later.
__________________
Susilo
X-Cart 4.7.6 Gold Plus
Template : Ultra Responsive Template
Search module : Cloud Search
PHP 7
Reply With Quote
  #10  
Old 02-21-2017, 06:38 AM
 
Pop Electronics Pop Electronics is offline
 

Senior Member
  
Join Date: Oct 2006
Posts: 131
 

Default Re: Smart Search and PHP7

Quote:
Originally Posted by mattstyle2
I got alterdcart onepage checkout to work with php 7 and xc4.7.7

remove:
PHP Code:
// Redefine mysql_real_escape_string for PHP 7 (X-Cart 4.7.x)
if (!function_exists('mysql_real_escape_string') AND class_exists('XCDbCommon'))
{
    
// Extend X-Cart DB class to get protected $link value
    
if (!class_exists('SD_XCDbCommon'))
    {
        class 
SD_XCDbCommon extends XCDbCommon {
            public function 
getLink()
            {
                global 
$sql_obj;
                return 
$sql_obj->link;
            }
        }
    }

    
// Overwrite mysql_real_escape_string with mysqli_real_escape_string
    
function mysql_real_escape_string ($string '')
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_real_escape_string($link->getLink(), $string);
    }


from modules/cdseolinks/cdseo_config.php if you have that installed.. if not just add the code below to init.php

and move it to
/init.php after
PHP Code:
func_set_time_limit(SECONDS_PER_MIN 5); 

and add a mysql_insert_id function so it looks like this

PHP Code:
// smarty3 needs a lot of time to compile all templates_c from scratch
func_set_time_limit(SECONDS_PER_MIN 5);

// Redefine mysql_real_escape_string for PHP 7 (X-Cart 4.7.x)
if (!function_exists('mysql_real_escape_string') AND class_exists('XCDbCommon'))
{
    
// Extend X-Cart DB class to get protected $link value
    
if (!class_exists('SD_XCDbCommon'))
    {
        class 
SD_XCDbCommon extends XCDbCommon {
            public function 
getLink()
            {
                global 
$sql_obj;
                return 
$sql_obj->link;
            }
        }
    }

    
// Overwrite mysql_real_escape_string with mysqli_real_escape_string
    
function mysql_real_escape_string ($string '')
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_real_escape_string($link->getLink(), $string);
    }
    function 
mysql_insert_id ()
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_insert_id($link->getLink());
    }
    
}

/**
 * Allow displaying content in functions, registered in register_shutdown_function()
 */
$zlib_oc ini_get('zlib.output_compression'); 

This will bring back the old mysql functions


then mod /modules/Checkout_One/JSON.php (not sure this is required but I had to do it for hhvm to work).

PHP Code:
function encodeUnsafe($var)
    {
        
// see bug #16908 - regarding numeric locale printing
       // $lc = setlocale(LC_NUMERIC, 0);
       // setlocale(LC_NUMERIC, 'C');
        
$ret $this->_encode($var);
        
//setlocale(LC_NUMERIC, $lc);
        
return json_encode($var);
        
//        return $ret;
        
    

change that function to use json_encode

finally change a template file:
/skin/common_files/modules/Checkout_One/checkout_one_payment_methods.tpl
line 29:
PHP Code:
{foreach from=$payment_methods item=v}
                        <
tbody{* matt remvoe if $v.membershipids || $v.is_cod == 'Y'style="display:none;"{/if*} id="radio_trcell_{$v.paymentid}">
                            <
tr class="{cycle values='rowA,rowB'}"

just comment out the code to make things display:none.. The radio buttons for payment were not available.

seems to work.. I did a test order with a bad cc # and it declined it.. Using BSCE's authorize.net's DPM mod.. Still nned to figure out a way to subscribe mail chimp users still.. I'll update this as I work on it.

also, there's a few @mysql_query functions in the Checkout_One code you need to change to @db_query

find those..
cd modules/Checkout_One
grep -r --include="*.php" "@mysql_query"

find all instances and change to "@db_query"
there's not that many.





-Matt

Thanks, whis also works when still on php 5.6 but upgrading to X-Cart 4.7.7, I did not have to change mysql_query though for just 4.7.7 on php 5.5.
__________________
X-Cart 4.7.7
Fashion Walk template
CDSEO pro, remember anoymous carts, checkout one and some mods I've done myself (ideal, froogle, export shipping labels)
@Linux php5.6, mysql5.6, dedicated server
iDeal Advanced v3.3.1 integration
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:12 AM.

   

 
X-Cart forums © 2001-2020