classes/php5_classes/API.class.php

Properties

Description

Holds the geoAPI class.

Constants

  IN_GEO_API = 1




Classes

geoAPI

Properties

 
 
System  
No 
No 

Description

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.
Note that as of Version 6.0.0, this loads the API but leaves it up to a "transport" to get params and send data back to the client.

Methods

__construct, addCallback, addTransport, call, checkUserToken, currentTransportType, failure, getCallBacks, getKeyFor, getTransports, hasCallback, hasTransport, load, loadTransports, resetKey, resetUserToken, return_error_with_delay, serve, setTransport, success, time,

__construct( ) : \geoAPI

Description

Constructor, initializes all the class vars and loads the tasks.

Return value

Type Description
\geoAPI

addCallback( string   $methodname, string   $filename, ) : n/a

Description

Adds a callback (AKA a remote API call) that could be called.
Normally this is not called directly.

Arguments

Name Type Description Default
$methodname string
$filename string

Return value

Type Description
n/a n/a

addTransport( string   $transportName, string   $filename, ) : n/a

Description

Add a new transport to the possible transports that can be used

Arguments

Name Type Description Default
$transportName string
$filename string

Return value

Type Description
n/a n/a

Tags

Name Description
since Version 6.0.0

call( string   $methodname, mixed   $args, ) : n/a

Description

Runs the specified remote api task, if that task is valid.
Usually just used internally.

Arguments

Name Type Description Default
$methodname string
$args mixed

Return value

Type Description
n/a n/a

checkUserToken( string   $username, string   $token, ) : boolean

Description

Verifies that the given user token is valid.

Arguments

Name Type Description Default
$username string
$token string

Return value

Type Description
boolean

currentTransportType( ) : string

Description

What transport type is being used for this page load, or empty string if it hasn't figured that out yet.

Return value

Type Description
string

Tags

Name Description
since Version 6.0.0

failure( string   $message = 'API Request Failed', int   $errno = 1000, int   $delay = 0, ) : n/a

Description

Can be used by API calls to throw a failure. Can add an artifitial delay to the response for "security" if desired (for instance, if wrong password or similar, something that might attempt to be brute-forced) by specifying delay in seconds.
Note that this causes the error to be sent to the client, and depending on the transport, may exit. If you want to guarantee continuation, instead store the error as part of the args passed back.

Arguments

Name Type Description Default
$message string

Message for error

'API Request Failed'
$errno int

Random number to identify specific API problem internally

1000
$delay int

Delay in seconds, if any (help slow down brute-force)

0

Return value

Type Description
n/a n/a

Tags

Name Description
since Version 6.0.0

getCallBacks( ) : array

Description

Gets the array of valid callbacks.

Return value

Type Description
array

getKeyFor( string   $apiCall = '', ) : string

Description

Gets the site key for the given api call.
If no call is given, returns key that works with all api calls. Note: API system does needed checks, you should not need to do any checks within any api call to make sure the key is valid.

Arguments

Name Type Description Default
$apiCall string ''

Return value

Type Description
string The key for the given remote API call.

getTransports( ) : array

Description

Gets an array of transports currently possible.

Return value

Type Description
array

Tags

Name Description
since Version 6.0.0

hasCallback( string   $callback, ) : bool

Description

Whether or not the specified callback (aka methodname aka api call) exists

Arguments

Name Type Description Default
$callback string

Return value

Type Description
bool

Tags

Name Description
since Version 6.0.0

hasTransport( string   $transport, ) : bool

Description

Whether or not the specified transport exists and is usable or not.

Arguments

Name Type Description Default
$transport string

Return value

Type Description
bool

Tags

Name Description
since Version 6.0.0

load( string   $dir = '', string   $methodname = 'core', ) : n/a

Description

Loads all the remote API tasks found in the given directory.

Arguments

Name Type Description Default
$dir string

The absolute directory to be looking in.

''
$methodname string

The remote API call name, usually just leave this at default to load all.

'core'

Return value

Type Description
n/a n/a

loadTransports( string   $dir = '', ) : n/a

Description

Loads all the transport layer implementations possible. Mostly used internally, but could be used by some custom mod to force loading transports from specific folder.

Arguments

Name Type Description Default
$dir string ''

Return value

Type Description
n/a n/a

Tags

Name Description
since Version 6.0.0

resetKey( string   $newKey = '', ) : n/a

Description

Resets the remote API security key.

Arguments

Name Type Description Default
$newKey string

if blank, a random key is generated.

''

Return value

Type Description
n/a n/a

resetUserToken( string   $username, ) : Mixed

Description

Resets a user's remote api token (or sets it for the first time)

Arguments

Name Type Description Default
$username string

Return value

Type Description
Mixed The new api token if successful, or false on failure.

return_error_with_delay( string   $error_msg, int   $delay_time = 5, ) : n/a

Description

Sort of an alias of {@see geoAPI::failure()}, kept around for backwards-compatibility on API calls

Arguments

Name Type Description Default
$error_msg string
$delay_time int

The amount of time before showing the error message (for security reasons, can artificially increase the amount of time it takes, to make it take a lot longer to attempt brute-force)

5

Return value

Type Description
n/a n/a

serve( string   $force_transport = '', ) : n/a

Description

Sort of the boot-strapper for the API, this serves the API call, including output back to the client.

Arguments

Name Type Description Default
$force_transport string

If specified, will use force the use of the specified transport (or die trying).

''

Return value

Type Description
n/a n/a

setTransport( string   $transport, ) : n/a

Description

Set which transport to use for this page load. Recommended not to change mid-stream or it could cause weird problems. Attempting to use invalid transport results in script dieing.

Arguments

Name Type Description Default
$transport string

Return value

Type Description
n/a n/a

Tags

Name Description
since Version 6.0.0

success( mixed   $data, ) : n/a

Description

Sends the data using the active transport and depending on the transport, may exit the script.

Arguments

Name Type Description Default
$data mixed

The data to return to the client.

Return value

Type Description
n/a n/a

Tags

Name Description
since Version 6.0.0

time( ) : int

Description

Utility function that returns the current time, adjusted for the time shift as set in the admin.

Return value

Type Description
int

Properties

$_callbacks, $_transport, $_transports, $addon, $db, $product_configuration, $session,

array  private  $_callbacks =

An array of API calls mapped to the absolute file location used for that call.


\iApiTransport  private  $_transport =

The transport actually used for this page load


  private  $_transports =

The transport class


\geoAddon  public  $addon =

geoAddon object, can be used by cron tasks by using $this->addon


\DataAccess  public  $db =

Database object, can be used by api tasks by using $this->db


\geoPC  public  $product_configuration =

geoPC object, can be used by api tasks by using $this->product_configuration


\geoSession  public  $session =

Session object, can be used by api tasks by using $this->session


Interfaces

iApiTransport

Properties

 
 
System  
 
 

Description

Interface for API Transports, a transport must implement this interface for the system to use it.

Methods

exitAfterOutput, getCall, getParams, getType, outputError, outputSuccess,

exitAfterOutput( ) : bool

Description

Whether or not script should exit after output success/failure is called.
This is here to allow "local" transports to prevent the rest of the script from stopping. Any "remote" transport should return true.

Return value

Type Description
bool

getCall( ) : string

Description

Get the requested API call name, somthing like core.misc.echo

Return value

Type Description
string

getParams( ) : array

Description

Get array of parameters based on whatever the transport uses for passing parameters in.

Return value

Type Description
array

getType( ) : \string;

Description

The type of transport, should be the filename minus the .php and in all lowercase. Note that the filename shoudl be all lowercase anyways.

Return value

Type Description
\string;

outputError( int   $errno, string   $errmsg, int   $addDelay, ) : bool

Description

Output an error to the client. Responsible for adding a delay if $addDelay is not 0, and applicable for transport. This is used by API call to return an error back to the client, this is the "final" output back to the client.

Arguments

Name Type Description Default
$errno int

Just a number used to help quickly identify an error

$errmsg string

Error message to return back

$addDelay int

Delay time in seconds, used to slow down brute force attempts

Return value

Type Description
bool Should return false once output sent to client.

outputSuccess( mixed   $data, ) : bool

Description

Output given data to the client. Should be able to handle arrays, string, numbers, etc. This is used to send the data returned by the API call back to the client, in other words it is called once and should result in the info being sent back to the client in full.

Arguments

Name Type Description Default
$data mixed

Return value

Type Description
bool Should return true once output is sent to client.
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.