Released under the terms of the GNU General Public License.
You should have received a copy of the GNU General Public License,
along with this software. In the main directory, see: /licensing/
If not, see: .
*/
/*
Direct access denial.
*/
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
exit ("Do not access this file directly.");
/*
The __autoload function for all Ad Squares widget classes.
This highly optimizes the widget. Giving it a much smaller footprint.
See: http://www.php.net/manual/en/function.spl-autoload-register.php
*/
if (!function_exists ("ws_widget__ad_squares_classes")) /* Already exists? */
{
function ws_widget__ad_squares_classes ($class = FALSE) /* Build dynamic __autoload function. */
{
static $c; /* Holds the classes directory location ( location is optimized with a static var ). */
static $c_class_dirs; /* All possible dir & sub-directory locations ( with a static var ). */
/**/
if (strpos ($class, "c_ws_widget__ad_squares_") === 0 && strpos ($class, "c_ws_widget__ad_squares_pro_") === false)
{
$c = (!isset ($c)) ? dirname (dirname (__FILE__)) . "/classes" : $c; /* Configures location of classes. */
$c_class_dirs = (!isset ($c_class_dirs)) ? array_merge (array ($c), _ws_widget__ad_squares_classes_scan_dirs_r ($c)) : $c_class_dirs;
/**/
$class = str_replace ("_", "-", str_replace ("c_ws_widget__ad_squares_", "", $class));
/**/
foreach ($c_class_dirs as $class_dir) /* Start looking for the class. */
if ($class_dir === $c || strpos ($class, basename ($class_dir)) === 0)
if (file_exists ($class_dir . "/" . $class . ".inc.php"))
{
include_once $class_dir . "/" . $class . ".inc.php";
/**/
break; /* Now stop looking. */
}
}
}
function _ws_widget__ad_squares_classes_scan_dirs_r ($starting_dir = FALSE)
{
$dirs = array (); /* Initialize dirs array. */
/**/
foreach (func_get_args () as $starting_dir)
if (is_dir ($starting_dir)) /* Does this directory exist? */
foreach (scandir ($starting_dir) as $dir) /* Scan this directory. */
if ($dir !== "." && $dir !== ".." && is_dir ($dir = $starting_dir . "/" . $dir))
$dirs = array_merge ($dirs, array ($dir), _ws_widget__ad_squares_classes_scan_dirs_r ($dir));
/**/
return $dirs; /* Return array of all directories. */
}
/**/
spl_autoload_register ("ws_widget__ad_squares_classes"); /* Register __autoload. */
}
?>