0.9.0 - the ZapV version updated to current php standards. Brave search used, while Bing and Google search api are deprecated
This commit is contained in:
parent
3d4298fe8b
commit
4ddaddda3d
31 changed files with 1778 additions and 1 deletions
99
conf/init.php
Executable file
99
conf/init.php
Executable file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
include_once 'conf.php';
|
||||
|
||||
/**
|
||||
* Define some app-wide constants
|
||||
*/
|
||||
define('ZAP_APP_BASE_DIR', realpath('.' . DIRECTORY_SEPARATOR . '..'));
|
||||
define('ZAP_WEB_DIR', 'www');
|
||||
define('ZAP_RESOURCE_DIR', 'resource');
|
||||
define('ZAP_UTILS_DIR', 'utils');
|
||||
define('ZAP_SESSIONS_DIR', 'sessions');
|
||||
define('ZAP_LIB_DIR', 'lib');
|
||||
define('ZAP_CONF_DIR', 'conf');
|
||||
define('ZAP_TPL_DIR', 'tpl');
|
||||
|
||||
/**
|
||||
* Error decoration
|
||||
*/
|
||||
define('ERROR_PREFIX', 'ZAP Error: ');
|
||||
|
||||
/**
|
||||
* Set include path for application
|
||||
*/
|
||||
function setZAPIncludePath() {
|
||||
$app_dirs = array(ZAP_RESOURCE_DIR, ZAP_UTILS_DIR, ZAP_SESSIONS_DIR,
|
||||
ZAP_LIB_DIR, ZAP_TPL_DIR, ZAP_CONF_DIR);
|
||||
$app_include_path = '';
|
||||
|
||||
foreach ($app_dirs as $app_dir) {
|
||||
$app_include_path .= PATH_SEPARATOR . ZAP_APP_BASE_DIR . DIRECTORY_SEPARATOR . $app_dir;
|
||||
}
|
||||
|
||||
if (set_include_path(get_include_path() . $app_include_path) == false) {
|
||||
throw new Exception(ERROR_PREFIX . 'Error while creating include path...');
|
||||
}
|
||||
|
||||
define('ZAP_INCLUDE_PATH_SET', true);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate autoload function for application
|
||||
*/
|
||||
spl_autoload_register(function ($class_name) {
|
||||
if (!defined('ZAP_INCLUDE_PATH_SET') || ZAP_INCLUDE_PATH_SET === false) {
|
||||
try {
|
||||
setZAPIncludePath();
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
$include_path = get_include_path();
|
||||
$include_path_tokens = explode(':', $include_path);
|
||||
|
||||
foreach ($include_path_tokens as $prefix) {
|
||||
$path[0] = $prefix . DIRECTORY_SEPARATOR . $class_name . '.interface.php';
|
||||
$path[1] = $prefix . DIRECTORY_SEPARATOR . $class_name . '.class.php';
|
||||
|
||||
foreach ($path as $thisPath) {
|
||||
if (file_exists($thisPath)) {
|
||||
require_once $thisPath;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Define remaining app-wide constants
|
||||
*/
|
||||
define('ZAP_MOMENT', date("Y-m-d-H_i_s"));
|
||||
define('ZAP_VERSION', '0.9.0');
|
||||
define('ZAP_SESSION_NAME', 'ZAP');
|
||||
|
||||
// Only start session in web mode (not CLI)
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
Session::start(ZAP_SESSION_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns string of path of template file
|
||||
* @return string
|
||||
*/
|
||||
function getZAPTemplate($tplname) {
|
||||
if (!defined('ZAP_APP_BASE_DIR')) {
|
||||
throw new Exception(ERROR_PREFIX . 'No base directory defined?!');
|
||||
}
|
||||
$tplfile = $tplname . '.tpl';
|
||||
$tplfilepath = ZAP_APP_BASE_DIR . DIRECTORY_SEPARATOR
|
||||
. ZAP_TPL_DIR . DIRECTORY_SEPARATOR . $tplfile;
|
||||
if (file_exists($tplfilepath)) {
|
||||
return $tplfilepath;
|
||||
} else {
|
||||
return ERROR_PREFIX . 'No template';
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue