Jump to content

stevel

Members
  • Content count

    2,821
  • Joined

  • Last visited

4 Followers

Profile Information

Recent Profile Visitors

14,557 profile views
  1. stevel

    ULTIMATE Seo Urls 5 - by FWR Media

    A couple of changes to my PDO-sqlite code above. First, remove self::$db = null; in the store function. Second, in file main/usu5.php, function extractCacheData. In the case for sqlite, change: $row = $result->fetch(); to if (is_object($result)) $row = $result->fetch(); I would recommend this edit no matter what. I am using the 1.1 version of the code, have not looked for anything newer.
  2. stevel

    ULTIMATE Seo Urls 5 - by FWR Media

    Robert, the following seems to work as far as using PDO. Pretty simple, really - the part where the database is created and opened is the major change, most everything else can stay as-is.. The one part I am a bit unsure about is the use of the PDO::quote function as a replacement for sqlte_escape_string. (I may not be using the latest version of your contrib.) This is a replacement for includes/cache_system/sqlite.php <?php /** * * ULTIMATE Seo Urls 5 PRO ( version 1.1 ) * * * @package USU5_PRO * @[member='licensed2kill'] http://www.opensource.org/licenses/gpl-2.0.php GNU Public License * @[member='Link'] http://www.fwrmedia.co.uk * @[member='copyright'] Copyright 2008-2009 FWR Media * @[member='copyright'] Portions Copyright 2005 ( rewrite uri concept ) Bobby Easland * @[member='author'] Robert Fisher, FWR Media, http://www.fwrmedia.co.uk * @lastdev $Author:: Rob $: Author of last commit * @lastmod $Date:: 2011-03-21 12:48:04 +0000 (Mon, 21 Mar 2011) $: Date of last commit * @version $Rev:: 206 $: Revision of last commit * @Id $Id:: sqlite.php 206 2011-03-21 12:48:04Z Rob $: Full Details */ /** * Cache system using a SQLite database * * @package USU5_PRO */ final class Sqlite_Cache_Module implements iCache_System { private static $_singleton = null; private static $sqlite_db_file = null; private static $cache_name; private static $cache_on; public static $db; public $extract_query = "SELECT * FROM usu_cache WHERE cache_name = ':cache_name'"; private $insert_query = "INSERT INTO usu_cache (cache_name, cache_data, cache_date) VALUES (':cache_name', ':cache_data', ':cache_date')"; private $insert = false; /** * Class constructor * @[member='access'] private */ private function __construct() { } // end constructor /** * Returns a singleton instance of the class * * Sets the cache name and checks that the cache directory is writeable * @uses defined() * @uses substr() * @uses md5() * @uses is_readable() * @uses trigger_error() * * @[member='access'] public * @throws - triggers an error of type E_USER_WARNING if a new database cannot be created * @return Sqlite_Cache_Module */ public static function i() { if ( !self::$_singleton instanceof Sqlite_Cache_Module ) { if ( Usu_Main::i()->getVar( 'page_modules', substr( Usu_Main::i()->getVar( 'filename' ), 0, -4 ) ) instanceof aPage_Modules ) { self::$cache_on = ( defined( 'USU5_CACHE_ON' ) && ( USU5_CACHE_ON == 'true' ) ) ? true : false; self::$cache_name = md5( Usu_Main::i()->getVar( 'page_modules', substr( Usu_Main::i() ->getVar( 'filename' ), 0, -4 ) ) ->buildCacheName() ); Usu_Main::i()->setVar( 'cache_name', self::$cache_name ); } else { // No module so we set the cache name as the language id plus the called file self::$cache_name = Usu_Main::i()->getVar( 'languages_id' ) . '_' . substr( Usu_Main::i()->getVar( 'filename' ), 0, -4 ); } self::$sqlite_db_file = Usu_Main::i()->getVar( 'cache_system_path' ) . 'sqlite/usu_cache.db'; self::createDatabase(); self::$_singleton = new self; } return self::$_singleton; } // end method /** * Returns a limited singleton instance of the class specifically for admin * * Allows admin to access a limited version of the class in order to truncate the database * * @[member='access'] public * @return Sqlite_Cache_Module */ public static function admini() { if ( !self::$_singleton instanceof Sqlite_Cache_Module ) { self::$sqlite_db_file = realpath( dirname( __FILE__ ) ) . '/sqlite/usu_cache.db'; self::createDatabase(); self::$_singleton = new self; } return self::$_singleton; } /** * Create the SQLite database if it doesn't already exist * * @uses is_readable() * @uses trigger_error() * * @[member='access'] protected * @throws - triggers an error of type E_USER_WARNING if a new database cannot be created * @return void */ protected static function createDatabase() { if ( !is_readable( self::$sqlite_db_file ) ) { $db_file_handle = @fopen(self::$sqlite_db_file,'a'); if (!$db_file_handle){ tep_db_error ('USU DB Create', 0, $e->getMessage()); } else { fclose($db_file_handle); } } try { self::$db = new PDO('sqlite:' . self::$sqlite_db_file,'','',array(PDO::ATTR_PERSISTENT => true)); } catch (PDOException $e) { tep_db_error('USU DB Open',0,$e->getMessage()); die(); } self::createTables(); } /** * Stores the current cache on the destruction of the Usu_Main class * * @see Usu_Main::__destruct() * @uses serialize() * @uses base64_encode() * @uses gzdeflate() * @uses str_replace() * @uses date() * @uses sqlite_escape_string() * @param array $registry_vars - array of data to cache * * @[member='access'] public * @return void */ public function store( array $registry_vars = array() ) { if ( false !== self::$cache_on ) { if ( false !== $this->insert ) { $data = serialize( $registry_vars ); // Serialize the registry of data $rawdata = base64_encode( gzdeflate( $data ) ); // encode and deflate $targets = array( ':cache_name', ':cache_data', ':cache_date' ); $replacements = array( self::$db->quote( self::$cache_name ), self::$db->quote( $rawdata ), date( "Y-m-d H:i:s" ) ); $query = str_replace( $targets, $replacements, $this->insert_query ); self::$db->query( $query ); self::$db = null; } } } /** * Retrieve the cached data * * If $insert becomes bool true then we insert data when storing, bool false we don't save as the cache already exists * * @see Usu_Main::extractCacheData() * * @[member='access'] public * @return void */ public function retrieve() { if ( false !== self::$cache_on ) { $this->insert = Usu_Main::i()->extractCacheData( self::$cache_name, 'sqlite', $this ); } } /** * Cache garbage clearance * * @uses file_exists() * @uses unlink() * @param bool $file_info * * @[member='access'] public * @return void */ public function gc( $file_info = false ) { if ( file_exists( self::$sqlite_db_file ) ) { self::$db->query( 'DELETE FROM usu_cache' ); self::$db->query( 'VACUUM usu_cache' ); } } /** * Retrieve an instance of SQLiteDatabase * * @[member='access'] public * @return SQLiteDatabase */ public function getDb() { return self::$db; } /** * Create the initial table and fileds for SQLiteDatabase * @[member='access'] private */ private static function createTables() { $create_query = " CREATE TABLE usu_cache ( cache_name, cache_data, cache_date ); CREATE UNIQUE INDEX idx_cache_name ON usu_cache( cache_name );"; self::$db->query( $create_query ); } } // end class
  3. stevel

    ULTIMATE Seo Urls 5 - by FWR Media

    I have been happily using this contribution for a year or so. For various reasons, I am forced to switch to PHP 5.4 from the 5.2 I am currently using. On my host, SQLite 2 is provided in PHP 5.2, but in 5.4 they supply only SQLite 3 with the PDO interface. I searched this topic but so far, I have found only other questions about using PDO and no answers. Has anyone successfully modified the contrib to use SQLite through PDO? If so, how?
  4. stevel

    Country-State Selector

    I will comment that if your knowledge of PHP is "very limited", then you will encounter no end of frustration maintaining an osCommerce store. I encourage you to learn enough PHP to understand the code.
  5. stevel

    Country-State Selector

    angel, in my version (1.4), this code fetches the state or zone_id value from the submitted form: if (ACCOUNT_STATE == 'true') { $state = tep_db_prepare_input($HTTP_POST_VARS['state']); if (isset($HTTP_POST_VARS['zone_id'])) { $zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']); } else { $zone_id = -1; // Country-State Selector } } I have not looked at the AJAX version to see what it does.
  6. stevel

    Country-State Selector

    You'll have to debug the PHP - perhaps the form is not being submitted correctly or the code path when the form is submitted has errors. I generally start out by inserting a "var_dump($_POST);" in the form action code to see what was submitted (this will block the later redirect but that's ok.) I then add various echo or var_dump commands through the code until I understand what went wrong.
  7. stevel

    Country-State Selector

    What you need to do is change the address format for the US format (which if I recall is format 1 by default.) Unfortunately there is no interface in osC to actually edit these - all you can do is select among the formats defined. The default format spells out the zone name but you want the zone code instead. I have customized my shops and am away from my sources so what I am about to suggest may not work right for you. Open your database in PHPMyAdmin or whatever you use. Select table address_format. Insert a new row. The address_format_id should be the next value, probably 2. For address_format enter: $firstname $lastname$cr$streets$cr$city, $statezone $postcode and for address_summary, enter: US Once you have finished adding the record, go into your osC admin, and select Locations/Taxes > Countries. Find the entry for United Stated and edit it. Change the Address Format to 2 (or whatever the new format ID was in the step above.) Now you will have to enter a new order and see if the address appears correct, oh and you may have to go back in and create a new address book entry as it will have the old code. What I don't remember is if the standard osC code defines $statezone in the tep_format_address function in includes/general.php. I have customized mine to allow for more flexibility as many countries need specialized formats that the default code doesn't support. I have always had in the back of my head the notion of writing an address format contribution with CORRECT formats for all the countries, but it is daunting work to research each country and get the right format. I've done it for maybe 15 countries so far - there are ten times as many. All that should be needed is for variable $statezone to be defined in the function to be the zone code. If it is not there you should be able to figure out how to add it. Let me know if you run into trouble and I'll help you Sunday or later.
  8. stevel

    ULTIMATE Seo Urls 5 - by FWR Media

    I will defer to Robert on this - and will test it on my sites. It may be that search engines are fine - they will simply get the "cookie usage" page if they try to follow a link to a page that requires a session. Of course, you should have such pages listed in robots.txt. On my site, I do not display such links if there is no session.
  9. stevel

    ULTIMATE Seo Urls 5 - by FWR Media

    You don't want to fix it. This is a fundamental way that osCommerce works. You can set the standard configuration option "Force cookie usage" but that will mean that search engines can't see your site. You should have "Prevent Spider Sessions" enabled and keep the includes/spiders.txt file up to date (see my contrib below) to ensure that search engines don't index URLs with the osCsid value.
  10. stevel

    ULTIMATE Seo Urls 5 - by FWR Media

    If you correctly use tep_href_link to form URLs for links, then they should always have the SEO style. You'd have to look at the PHP code to diagnose that - looking at the web site wouldn't help.
  11. stevel

    ULTIMATE Seo Urls 5 - by FWR Media

    Oh, you're using a template system. Well, you'll have to look at the FILENAME_PRODUCT_LISTING_FEATURED file in the includes/modules directory to see what, if any, code you need to change. In general with templates, all the standard add-on instructions go out the window and you have to hunt down where the code is.
  12. stevel

    ULTIMATE Seo Urls 5 - by FWR Media

    The instructions also say that you may not have that code. It is also possible that you have a variant of it. The default 2.2 store uses a simple link for the Buy Now button. Many store owners replace that with a form so that search engines don't follow it. Perhaps you have not done this or have removed the Buy Now button. If you do have a Buy Now button, show us the code for it and we can advise further.
  13. stevel

    Country-State Selector

    I don't know how you tell customers about shipping now, but most stores compute and display shipping charges on the checkout_shipping page. If you have text on your site that says "Free Shipping!" you need to qualify that as to where you will do free shipping. I don't think the country selection is the place to do it.
  14. stevel

    Country-State Selector

    That's what I get for trying to remember. Sorry to have led you astray. On the pages where you are using this, there will be code like this: while ($zones_values = tep_db_fetch_array($zones_query)) { $zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_name'] . ' (' . $zones_values['zone_code'] . ')'); } At least in this version, this gives you lines such as: New Hampshire (NH) If you just want NH there, then make this: while ($zones_values = tep_db_fetch_array($zones_query)) { $zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_code']); } You will have to repeat this in each file where there is a zone dropdown. Be careful as some of them may use different variable names.
  15. stevel

    Country-State Selector

    No, not those routines. Maybe the routine I am thinking of is in html_output.php. It is the one that creates a dropdown list of zone names. You would replace the call to tep_get_zone_name with one to tep_get_zone_code.
×