classes/php5_classes/Cache.class.php

Properties

Description

This holds all the tools for using Geo Cache in it.

Constants

  GEO_NO_COMPRESSION = false

A hard-coded setting, forget what it's for at the moment.


Classes

geoCache

Properties

 
 
System  
No 
No 

Description

This is the main part of the Geo cache system, it does all the "low level" stuff like writing files and escaping cache data.

Methods

_memcacheAddToRegistry, _memcacheInit, _memcacheRemoveFromRegistry, cleanUp, clearCache, expire, file_exists, get, getDefaultSettings, getMemcacheObj, inc, initCacheFilesystem, initSettings, is_writable, memcache_exists, process, quotePhp, quoteVal, rUnlink, read, serializeParams, set, update, write, writeCache,

_memcacheAddToRegistry( string   $filename = '', ) : boolean

Description

Add some file to registry

Arguments

Name Type Description Default
$filename string ''

Return value

Type Description
boolean

_memcacheInit( ) : boolean

Description

Initialize memcache

Return value

Type Description
boolean

_memcacheRemoveFromRegistry( string   $filename, ) : n/a

Description

Remove the file from memcache registry

Arguments

Name Type Description Default
$filename string

Return value

Type Description
n/a n/a

cleanUp( string   $dir = CACHE_DIR, ) : n/a

Description

Goes through all the cache files, and looks for any that should expire, and delete's them.

Arguments

Name Type Description Default
$dir string CACHE_DIR

Return value

Type Description
n/a n/a

clearCache( string   $type = 'all', int   $trys = 0, ) : n/a

Description

Removes all of the cache files from the _geocache sub-folders.

Arguments

Name Type Description Default
$type string

If only want to clear one type of cache

'all'
$trys int

Used internally if using memcache, leave this at default of 0 modules, settings, text, pages, templates, or all(default)

0

Return value

Type Description
n/a n/a

expire( string   $filename, ) : n/a

Description

Expires a certain file from existance (or if using memcache, removes the given index)

Arguments

Name Type Description Default
$filename string

Return value

Type Description
n/a n/a

file_exists(   $filename, ) : bool

Description

Sees if the given filename exists or not.
Filename should be relative to the GEO_CACHE directory (and not allowed to escape that directory)

Arguments

Name Type Description Default
$filename n/a

The filename, relative to the cache directory.

Return value

Type Description
bool

get( String   $index, ) : Mixed

Description

Gets the value for the given setting index

Arguments

Name Type Description Default
$index String

The index for the setting

Return value

Type Description
Mixed The value of the given index, or false if index not found.

getDefaultSettings( ) : Array

Description

Gets a set of default cache settings

Return value

Type Description
Array of default settings for cache

getMemcacheObj( ) : \Memcache

Description

If memcache is turned on, use this to get the memcache object to do fancy things like connecting to several different servers, or changing server settings or something.
Note: If this is called before memcache is initialized, you MUST make a connection to the server yourself using memcache->connect() or memcache->pconnect()

Return value

Type Description
\Memcache

inc( string   $filename, ) : Mixed

Description

Simulate including a cache file previously created using geoCache::write().
Since the cache file will have expiration data on the first line, it cannot be included directly, so this function must be used instead to simulate including the file. Note: when using cache, never design it so that the cache file returns the boolean false, otherwise you will not be able to tell the difference between a cache miss and it just returning false. Instead, wrap the false var in an array or something.

Arguments

Name Type Description Default
$filename string

Return value

Type Description
Mixed Boolean false if the read failed, or the results of what would happen if you included the file.

initCacheFilesystem( bool   $force = false, ) : Boolean

Description

Initializes the cache filesystem, creating files and folders when needed, but only if the cache file system is turned on.

Arguments

Name Type Description Default
$force bool

If true, force it to init even if it already inited in this page load.

false

Return value

Type Description
Boolean true if cache file system was initialized, false otherwise.

initSettings( ) : n/a

Description

Initializes the cache settings, for use in get() and set().

Return value

Type Description
n/a n/a

is_writable( String   $path, ) : Boolean

Description

Correctly checks to see if file or folder is writable.
This accounts for Windows ACLs bug. see http://bugs.php.net/bug.php?id=27609 see http://bugs.php.net/bug.php?id=30931

Arguments

Name Type Description Default
$path String

Be sure to use trailing slash for folders!

Return value

Type Description
Boolean true if file is writable, false otherwise.

memcache_exists( ) : n/a

Description

returns true of false depending on wether memcache is enabled or not

Return value

Type Description
n/a n/a

process( ) : Mixed

Description

Should be over-written by class, this function should take in variables specific to the type of cache (settings, page, template, etc), and do whatever is needed to use the cache.

Return value

Type Description
Mixed return false if process failed.

quotePhp( String   $text, ) : String

Description

Quotes given text to make it safe to use in php file, to prevent code injection. See contents of function to see what is quoted and how.

Arguments

Name Type Description Default
$text String

Return value

Type Description
String quoted text, with any potential open or close converted to be echoed.

quoteVal( Mixed   $var, ) : String

Description

Quotes a given variable, converting it to a string that can be used in a php file to re-create the variable.

Arguments

Name Type Description Default
$var Mixed

Can be any variable type, except object

Return value

Type Description
String that can be eval'd or in php file, to re-create the variable.

rUnlink( string   $dir, boolean   $DeleteMe, ) : n/a

Description

Used by clearCache() to clear all the sub-folders of the cache system.
This is DANGEROUS! Carefull what dir you are sicking this thing on! This blocks deleting if the dir is not inside the cache_dir directory.

Arguments

Name Type Description Default
$dir string
$DeleteMe boolean

Return value

Type Description
n/a n/a

read( String   $filename, ) : n/a

Description

Reads the contents of the given filename, as long as the file has not expired, and is in a sub-folder of the CACHE_DIR.
The filename must be one that was previously written to using geoString::write()

Arguments

Name Type Description Default
$filename String

The filename, relative to the main cache dir CACHE_DIR

Return value

Type Description
n/a n/a

serializeParams( array   $params, ) : string

Description

Serializes params passed in smarty tags, so that can be used as part of cache file name.

Arguments

Name Type Description Default
$params array

Return value

Type Description
string

Tags

Name Description
since Version 7.1.1

set( String   $index, Mixed   $value, ) : n/a

Description

Set the given index to the given value, in the cache settings, and update the cache settings file.

Arguments

Name Type Description Default
$index String
$value Mixed

Can be any type, except Objects.

Return value

Type Description
n/a n/a

update( ) : Boolean

Description

Should be over-written by class, this function should take in variable specific to the type of cache (settings, page, template, etc), and save the cache to a file to be used later by the matching process() function.

Return value

Type Description
Boolean false if update failed.

write( String   $filename, String   $txt, Int   $expire_time = 0, ) : Boolean

Description

Writes the given text to the given file, and records the amount of time to keep the file around.

Arguments

Name Type Description Default
$filename String

relative to cache dir

$txt String

text to write to file (binary safe)

$expire_time Int

Amount of time, in seconds, to keep the file around before expireing it. If 0, file will never expire automatically

0

Return value

Type Description
Boolean True if write was successful, false otherwise.

writeCache( ) : n/a

Description

Writes all the pending files in one go. This is so that this process can be done in app_bottom, so that it is done after the page is already sent to the client.
This is meant to be called from app_bottom.

Return value

Type Description
n/a n/a

Properties

$files, $settings,

array  public  static $files =

Array of files that will be written on page end


Array  public  static $settings =

Cache settings that can be used by get() and set(), and are saved to cache settings file.


geoCacheText

Properties

 
 
System  
No 
No 

Description

Part of Geo Cache system, this part specifically tuned to work best with cacheing language specific messages.

Methods

__construct, expire, getInstance, initCacheFilesystem, process, update,

__construct( ) : n/a

Description

private constructor to keep from creating new outside of getInstance()

Return value

Type Description
n/a n/a

expire( Int   $language_id, Int   $page_id = 0, ) : Boolean

Description

Removes the text data cache for a given language and page

Arguments

Name Type Description Default
$language_id Int
$page_id Int 0

Return value

Type Description
Boolean result of expire attempt.

getInstance( ) : \geoCacheText

Description

Gets an instance of the cache object.

Return value

Type Description
\geoCacheText

initCacheFilesystem( bool   $force = false, ) : Boolean

Description

Inits the cache file system, specific for files needed for text cache.

Arguments

Name Type Description Default
$force bool false

Return value

Type Description
Boolean result of init

process( int   $language_id = 0, int   $page_id = 0, ) : Mixed

Description

Gets the data for the given language and page from the cache.

Arguments

Name Type Description Default
$language_id int 0
$page_id int 0

Return value

Type Description
Mixed The message data for the given page, or false if cache miss.

update( Int   $language_id = 0, Int   $page_id = 0, Array   $text_array = array(), ) : Boolean

Description

Updates the text cache for the given language and page

Arguments

Name Type Description Default
$language_id Int 0
$page_id Int 0
$text_array Array

Array of text, similar to what would be stored in the site_class::messages var.

array()

Return value

Type Description
Boolean result of updating the message data cache.

geoCacheModule

Properties

 
 
System  
No 
No 

Description

Part of Geo Cache system, specifically tuned to work best with cacheing module data (which will be an array).

Methods

__construct, expire, getInstance, initCacheFilesystem, process, update,

__construct( ) : n/a

Description

Constructor, private on purpose to preven creating new one without using getInstance()

Return value

Type Description
n/a n/a

expire( Int   $module_id, ) : n/a

Description

Removes the module data cache for a given module.

Arguments

Name Type Description Default
$module_id Int

Return value

Type Description
n/a n/a

getInstance( ) : \geoCacheModule

Description

Gets an instance of the cache object.

Return value

Type Description
\geoCacheModule

initCacheFilesystem( bool   $force = false, ) : \Result

Description

Inits the cache filesystem, specific for module cache needs.

Arguments

Name Type Description Default
$force bool false

Return value

Type Description
\Result of cache init.

process( Mixed   $module_id = '', ) : False

Description

Processes a given module, and returns the data for that module.

Arguments

Name Type Description Default
$module_id Mixed

Either the module id, or the module replace tag.

''

Return value

Type Description
False if cache miss, or the cached data if cache hit.

update( Mixed   $module_id = 0, Mixed   $data = null, ) : \The

Description

Updates the cache for the given module, or creates the cache if it does not exist yet.

Arguments

Name Type Description Default
$module_id Mixed

Either module_id, or module_replace_tag.

0
$data Mixed

Data to cache for module, non-quoted

null

Return value

Type Description
\The result of the update.

Properties

$instance,

\geoCacheModule  private  static $instance =

Holds instance of class


geoCacheSetting

Properties

 
 
System  
No 
No 

Description

Part of Geo Cache system, specifically tuned to work best with cacheing site-wide key=value type settings.

Methods

__construct, expire, getInstance, initCacheFilesystem, process, update,

__construct( ) : n/a

Description

Private constructor to keep new thingy from being created outside of getInstance()

Return value

Type Description
n/a n/a

expire( String   $type, ) : n/a

Description

Removes the cache for a given setting type.

Arguments

Name Type Description Default
$type String

Type of setting

Return value

Type Description
n/a n/a

getInstance( ) : \geoCacheSetting

Description

Gets an instance of the cache object.

Return value

Type Description
\geoCacheSetting

initCacheFilesystem( bool   $force = false, ) : \result

Description

Inits the cache filesystem, specific for files needed for settings cache

Arguments

Name Type Description Default
$force bool false

Return value

Type Description
\result of init.

process( String   $setting_type = '', ) : \Settings

Description

Processes a given setting type cache

Arguments

Name Type Description Default
$setting_type String ''

Return value

Type Description
\Settings for given setting type, or false if cache miss.

update( String   $setting_type = '', Mixed   $data = null, ) : n/a

Description

Updates the cache for the given template, or creates the cache if it does not exist yet.

Arguments

Name Type Description Default
$setting_type String ''
$data Mixed

The data to store for the settings, can be any variable type except for object, and the same var will be returned by process.

null

Return value

Type Description
n/a n/a

geoCachePage

Properties

 
 
System  
No 
No 

Description

Cache system specifically tuned to work best with cacheing output of pages and modules

Methods

__construct, canCache, checkForFilters, expire, getInstance, initCacheFilesystem, process, quotePage, register, update,

__construct( ) : n/a

Description

Constructor, private so it isn't created outside of getInstance()

Return value

Type Description
n/a n/a

canCache( int|string   $page_id, ) : bool

Description

Whether or not the given page id should be cached or not.

Arguments

Name Type Description Default
$page_id int|string

Page ID or module replace tag

Return value

Type Description
bool

checkForFilters( Mixed   $page_id, ) : Boolean

Description

Checks to see if user is using filters, and if so, checks to see if the given page can still use cache when filters are in effect.

Arguments

Name Type Description Default
$page_id Mixed

Either page_id or module_replace_tag

Return value

Type Description
Boolean true if it is ok to cache the given page taking into account any filters, or false otherwise

expire( Mixed   $page_id, Int   $language_id = 0, Int   $cat_id = 0, Boolean   $logged_in = false, ) : boolean

Description

Removes the cache for the given page, language, cat, and logged in status.

Arguments

Name Type Description Default
$page_id Mixed

page id or module replace tag

$language_id Int 0
$cat_id Int 0
$logged_in Boolean false

Return value

Type Description
boolean results of expire.

getInstance( ) : \geoCachePage

Description

Gets an instance of the cache object.

Return value

Type Description
\geoCachePage

initCacheFilesystem( bool   $force = false, ) : Boolean

Description

Inits the cache file system specific for storeing page cache.

Arguments

Name Type Description Default
$force bool false

Return value

Type Description
Boolean results of init

process( Mixed   $page_id = 0, Int   $language_id = 0, Int   $cat_id = 0, Boolean   $logged_in = false, \(Optional)Boolean   $return = false, array   $params = array(), ) : Mixed

Description

Process cache, echos or returns the cached page, given the page, language, category, and loged in status.

Arguments

Name Type Description Default
$page_id Mixed

page id, or module replace tag

0
$language_id Int 0
$cat_id Int 0
$logged_in Boolean false
$return \(Optional)Boolean

if set to true, will return the cache instead of echoing, this should correspond to how the cache was stored when using update()

false
$params array

The array of parameters passed by smarty tag, added in version 7.1.1

array()

Return value

Type Description
Mixed if $return, will return require filename, otherwise will return true if a cache hit, false otherwise.

quotePage( String   $pageCode, ) : String

Description

Quotes the given text to be used as contents of php cache file, to be used for update()

Arguments

Name Type Description Default
$pageCode String

Non quoted string

Return value

Type Description
String suitable for use in a php cache file.

register( Mixed   $data, ) : n/a

Description

Add new data to be accessible by the cache, stuff like mainbody.

Arguments

Name Type Description Default
$data Mixed

Return value

Type Description
n/a n/a

update( Mixed   $page_id = 0, Int   $language_id = 0, Int   $cat_id = 0, Boolean   $logged_in = false, String   $pageCode = '', array   $params = array(), ) : True

Description

Updates the page cache, given the page, language, category, and logged in status.

Arguments

Name Type Description Default
$page_id Mixed

page id or module replace tag

0
$language_id Int 0
$cat_id Int 0
$logged_in Boolean false
$pageCode String ''
$params array

The array of parameters passed by smarty tag, added in version 7.1.1

array()

Return value

Type Description
True if success, false otherwise.

Properties

$pageData,

Array  private  $pageData =

Array of data for use by the cached page.


Documentation was generated by phpDocumentor 2.2.0 .

Namespaces

  • global

    Packages

    • Default
      • ExampleAddon
        • addon_example_admin
          In charge of doing stuff on the admin side, this is optional.
        • addon_example_info
          Required class for addons, this is the Addon information class, used by the addon system to determine what the addon can do. Also contains info about the addon that can be viewed in the addon management page in the admin.
        • addon_example_pages
          Addon page class, used by the addon system to display pages on the client side.
        • addon_example_setup
          This class is not required. If it, and the function for a particular routine exist, then that function will be called IN ADDITION TO the automated routines of the addon framework.
        • addon_example_tags
          Expects one function for each tag. Function name should be the same as the tag name. Can also have a constructor if anything needs to be constructed.
        • addon_example_util
          This is where to put functions that the main part of the addon will use.
        • eWidgetOrderItem
          This order item is designed to allow users on your site to purchase an eWidget.
      • System
        • DataAccess
          This is the main Database access object.
        • Singleton
          Singleton method class
        • _templateOrderItem
          Developers: use this file as a template to create a new order item.
        • _templatePaymentGateway
          This is the "developer template" payment gateway handler, a developer could use this file as a starting point for creating a new payment gateway in the system.
        • geoAPI
          The main system class for receiving and handling remote API calls, this acts as a translation layer between the communication with the "outside" and each API call.
        • geoAddon
          This is the class that handles anything and everything to do with addons.
        • geoArrayTools
          Utility functions for manipulating arrays
        • geoBrowse
          Contains functions common to browsing listings
        • geoBrowsingFilter
          System for activating, storing, and deactivating browsing filters.
        • geoCJAX
          Class that wraps the CJAX_FRAMEWORK, used to get the CJAX class.
        • geoCache
          This is the main part of the Geo cache system, it does all the "low level" stuff like writing files and escaping cache data.
        • geoCacheModule
          Part of Geo Cache system, specifically tuned to work best with cacheing module data (which will be an array).
        • geoCachePage
          Cache system specifically tuned to work best with cacheing output of pages and modules
        • geoCacheSetting
          Part of Geo Cache system, specifically tuned to work best with cacheing site-wide key=value type settings.
        • geoCacheText
          Part of Geo Cache system, this part specifically tuned to work best with cacheing language specific messages.
        • geoCalendar
          Holds utility method(s) for manipulating stuff dealing with calendar selector.
        • geoCart
          This class is behind the cart, loading all the order items and such and displaying, and processing all the different pages.
        • geoCategory
          Utility class that holds various methods to do stuff with categories in the system.
        • geoCombineResources
          This class helps to combine CSS and JS files, minify them, and optionally compress them.
        • geoCron
          This is the cron job backend, it handles all the communication and security and all that.
        • geoCrypt
          Class to use for encrypting information that needs to be able to be retrieved later.
        • geoDate
          Holds utility method(s) for manipulating stuff dealing with dates.
        • geoEmail
          Class that sends out e-mails.
        • geoFields
          Class that holds settings information for fields to use.
        • geoFieldsField
          A mini object to hold data about a specific field.
        • geoFile
          As the name implies, this is used for file-based utility methods.
        • geoFilter
          A few utility methods, good for filtering stuff.
        • geoFormatString
          Used to display a message nice and pretty, we'll probably be getting rid of this class though so don't go crazy using it.
        • geoHTML
          Class to generate chunks of HTML that are very common, used the most in the admin panel.
        • geoImage
          This class is responsible for a lot of the image processing, along with other aspects like generating the image tag for thumbnails.
        • geoInvoice
          This is the invoice object representing an invoice in the system.
        • geoLeveledField
          Class for doing common things with leveled fields.
        • geoListing
          A listing object, basically a container object for particular listing.
        • geoListingDisplay
          This is basically a container that is responsible for helping to display {listing .
        • geoListingFeed
          Class that helps to render RSS or other types of feeds based on list of listings.
        • geoMaster
          This is dedicated class for getting the value of, and setting, the various "master switches" within the software. Since this is meant as an easy way to get the values of master switches, most of the methods are static.
        • geoNumber
          Utility functions relating to number conversion/manipulation/validation ect.
        • geoOrder
          The geoOrder object, an object representation of an order in the system.
        • geoOrderItem
          The class that all order items must extend.
        • geoPC
          Used for login credential validation, password hashing, etc. along with software licensing.
        • geoPagination
          Utility functions useful for generating pagination of a results page such as when browing ads or searching
        • geoPaymentGateway
          This class should be extended by each different payment gateway, this will have some default functions that each gateway will inherit, and also has a few final static methods used by the system to affect all order items.
        • geoPlanItem
          A container to hold settings for a particular order item type, according to price plan ID, and optionally category ID for category specific settings.
        • geoRecurringBilling
          The geoRecurringBilling object, an object representation of a recurring billing in the system.
        • geoRegion
          Stuff for regions and sub-regions.
        • geoRegistry
          Handy little object, can be used to set registry type settings.
        • geoSearchUtils
          Class for search utilities.
        • geoSellerBuyer
          Handles back-end for the seller/buyer payment gateways, to allow the buyer to more easily pay the seller for a won auction. This handles the underlying system, but the actual work is done by individual seller/buyer gateways, for instance the Paypal buy-now functionality.
        • geoSession
          Manages session storage and session cookies for user sessions.
        • geoString
          Utility functions relating to languages and string manipulation.
        • geoStringData
          This class is to store accented chars, to be used by {@link geoString::removeAccents()}, mainly to keep the String.class.php file un-cluttered.
        • geoTable
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableRow
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableRowset
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableSelect
          Class used to generate a select query, useful when multiple areas want to affect a single query, for instance when generating a search query and there are addons involved.
        • geoTables
          Used to hold database table names, used throughout the code.
        • geoTemplate
          Template object that extends the Smarty class (a 3rd party library) to enable using templates to display things.
        • geoTransaction
          This is the object used for a transaction in the order and invoice system.
        • geoUser
          An object representative of a certain user in the system.
        • geoUserRating
          Store, retrieve, and display inter-user ratings
        • geoUtil
          Misc utility functions
        • geoView
          As the name implies, this is used for creating the page view. It does take a little setup (like any class), the setup is normally done in the display_page method in geoSite, or display_page in geoAdmin if displaying a page in the admin.
        • iApiTransport
          Interface for API Transports, a transport must implement this interface for the system to use it.
        • iOrderItem
          You cannot have abstract static functions, so instead need to have an interface to force the given static functions to be defined.
        • metaDbTables
          Used so that old locations that use the old name geoTables will still work.