Example #1
0
 function _apc_const($key, $constants = false, $case_sen = true)
 {
     // pass empty $constants array() to delete constants
     if ($values == false) {
         return apc_load_constants($key, $case_sen);
     } else {
         return apc_define_constants($key, $constants);
     }
 }
Example #2
0
Becomes:
	define('KU_NAME', 'Mychan');
Warning: Do not insert single quotes in the value yourself, or else you will cause problems.  To overcome this, you use what is called escaping, which is the process of adding a backslash before the single quote, to show it is part of the string:
	define('KU_NAME', 'Jason\'s chan');
*/
// Sets error reporting to hide notices.
error_reporting(E_ALL ^ E_NOTICE);
if (!headers_sent()) {
    header('Content-Type: text/html; charset=utf-8');
}
$cf = array();
// Caching (this needs to be set at the start because if enabled, it skips the rest of the configuration process)
$cf['KU_APC'] = false;
$cache_loaded = false;
if ($cf['KU_APC']) {
    if (apc_load_constants('config')) {
        $cache_loaded = true;
    }
}
if (!$cache_loaded) {
    // Database
    $cf['KU_DBTYPE'] = 'mysql';
    // Database type. Valid values are mysql and mysqli (reccomended for mysql).
    // PostgreSQL is also supported. Supported values are postgres64, postgres7 and postgres8. Only postgres8 is tested.
    // SQLite is also supported. Set to sqlite to use. SQLite will not use any database software, only a single file.
    $cf['KU_DBHOST'] = '127.0.0.1';
    // Database hostname. On SQLite this has no effect.
    $cf['KU_DBDATABASE'] = 'DB_NAME_HERE';
    // Database... database. On SQLite this will be the path to your database file. Secure this file.
    $cf['KU_DBUSERNAME'] = '******';
    // Database username. On SQLite this has no effect.
Example #3
0
 public function loadConstants($key, $sensitive = true)
 {
     if (CACHE_STATUS) {
         apc_load_constants($key, $sensitive);
     }
     return false;
 }
Example #4
0
 /**
  * Loads global constants from the given key
  * @param mixed The index to be used
  */
 public final function loadConstants($key)
 {
     if ($this->keyExists($key)) {
         apc_load_constants($this->getIndexKey($key));
     }
 }
Example #5
0
File: APC.php Project: techart/tao
 /**
  * Загружает набор констант из кэша
  *
  * @param string $key
  * @param bool   $case_sensitive
  *
  * @return array
  */
 public static function load_constants($key, $case_sensitive = true)
 {
     return apc_load_constants($key, $case_sensitive);
 }
Example #6
0
 public function loadConstants($key, $sensitive = TRUE)
 {
     if (_cacheStatus) {
         apc_load_constants($key, $sensitive);
     }
     return FALSE;
 }
Example #7
0
/*
 * If APC is not running.
 */
if (!extension_loaded('apc') || ini_get('apc.enabled') != 1) {
    /*
     * Include the site's config file.
     */
    if ((include INCLUDE_PATH . '/config.inc.php') === FALSE) {
        die('Cannot run without a config.inc.php file. See the installation documentation.');
    }
    define('APC_RUNNING', FALSE);
} else {
    /*
     * Attempt to load the config file constants out of APC.
     */
    $result = apc_load_constants('config');
    /*
     * If loading from APC worked, just set the include path.
     */
    if ($result == TRUE) {
        set_include_path(get_include_path() . PATH_SEPARATOR . INCLUDE_PATH);
    } else {
        /*
         * Load constants from the config file.
         */
        if ((include INCLUDE_PATH . '/config.inc.php') === FALSE) {
            die('Cannot run without a config.inc.php file. See the installation documentation.');
        }
        define('APC_RUNNING', TRUE);
        /*
         * And then save them to APC.
function constants_load($key_)
{
    return apc_load_constants(COMPONENTS_CACHE_NAMESPACE . "-{$key_}", true);
}
Example #9
0
 /**
  * Load Constants from APC
  */
 public static function initialize_ConstantsAndPaths()
 {
     // ensure that apc is loaded as extension
     define('APC', (bool) extension_loaded('apc'));
     // try to load constants from APC
     if (APC === true) {
         // constants retrieved from APC
         apc_load_constants('CLANSUITE_CONSTANTS', true);
         return;
     }
     // if apc is off or
     // if apc is on, but apc_load_constants did not retrieve any constants yet (first run)
     // then define constants
     if (APC === false or defined('NL') == false) {
         self::define_ConstantsAndPaths();
         /**
          * Store Constants to APC
          */
         if (APC === true) {
             // catch user-defined constants as array
             $constantsarray = get_defined_constants(true);
             // remove starttime constant
             unset($constantsarray['user']['STARTTIME']);
             apc_define_constants('CLANSUITE_CONSTANTS', $constantsarray['user'], false);
             unset($constantsarray);
         }
     }
     /**
      * SET INCLUDE PATHS
      *
      * We set INCLUDE PATHS for PEAR and other 3th party Libraries by defining an paths array first.
      * We are not setting the clansuite core path here, because files located there are handled via autoloading.
      *
      * The $paths array is set to the php environment with set_include_path().
      * Note, that for set_include_path() to work properly the path order is important!
      * <first path to look>:<second path>:<etc>:
      *
      * If you need to add something: use or absolute path constants (ROOT*) or realpath($your_path).
      */
     $paths = array(dirname(KOCH), KOCH, ROOT, ROOT_VENDOR, ROOT_LIBRARIES, ROOT_LIBRARIES . 'PEAR' . DIRECTORY_SEPARATOR);
     // attach original include paths
     set_include_path(implode($paths, PATH_SEPARATOR) . PATH_SEPARATOR . get_include_path());
     //var_dump(get_include_path());
     unset($paths);
 }
 /**
  * @param string $key_
  *
  * @return boolean
  */
 public static function constantsLoad($key_)
 {
     return apc_load_constants(COMPONENTS_CACHE_NAMESPACE . "-{$key_}");
 }