コード例 #1
0
ファイル: Menu.inc.php プロジェクト: radicaldesigns/amp
 function cache_output()
 {
     $this->_cache =& AMP_get_cache();
     $this->_header =& AMP_getHeader();
     $this->_header->addJavaScript('scripts/folder_tree/tree.js', 'section_menu_tree');
     $this->_header->addJavaScript('scripts/folder_tree/tree_tpl.js', 'section_menu_tree_tpl');
     return $this->cache_js();
 }
コード例 #2
0
ファイル: Request.inc.php プロジェクト: radicalsuz/amp
 function _clear_cache(&$target)
 {
     $cache_key = $target->getCacheKeySearch();
     if (!($cache =& AMP_get_cache())) {
         return false;
     }
     $cache->delete($cache_key);
 }
コード例 #3
0
ファイル: Flash.php プロジェクト: radicaldesigns/amp
 function _init_cache()
 {
     $this->_cache =& AMP_get_cache();
     if (!$this->_cache) {
         return;
     }
     $this->_cache_key_message_urls = $this->_cache->identify($this->_cache_key_message_urls, AMP_SYSTEM_UNIQUE_VISITOR_ID);
     $this->_cache_key_messages = $this->_cache->identify($this->_cache_key_messages, AMP_SYSTEM_UNIQUE_VISITOR_ID);
     $this->_cache_key_errors = $this->_cache->identify($this->_cache_key_errors, AMP_SYSTEM_UNIQUE_VISITOR_ID);
     if ($messages = $this->_cache->retrieve($this->_cache_key_messages)) {
         $this->_messages = $messages;
     }
     if ($message_urls = $this->_cache->retrieve($this->_cache_key_message_urls)) {
         $this->_message_urls = $message_urls;
     }
     if ($errors = $this->_cache->retrieve($this->_cache_key_errors)) {
         $this->_errors = $errors;
     }
 }
コード例 #4
0
 function getCacheKey($component, $id = null)
 {
     static $cache = false;
     if (!$cache) {
         $cache = AMP_get_cache();
     }
     $component_class = is_object($component) ? get_class($component) : $this->getComponentClass($component);
     $cache_key_base = false;
     foreach ($this->components as $key => $class_name) {
         if (strtolower($class_name) != strtolower($component_class)) {
             continue;
         }
         $cache_key_base = sprintf(AMP_CACHE_TOKEN_COMPONENT, $class_name);
         break;
     }
     if (!$cache_key_base) {
         return false;
     }
     if (isset($id)) {
         return AMP_System_Cache::identify($cache_key_base, $id);
     }
     return $cache_key_base;
 }
コード例 #5
0
ファイル: Controller.php プロジェクト: radicalsuz/amp
 function _request_cache($display_key, $action)
 {
     if (array_search($action, $this->_actions_cacheable) === FALSE) {
         return false;
     }
     $cache =& AMP_get_cache();
     if (!$cache) {
         return false;
     }
     $cache_key = sprintf(AMP_CACHE_TOKEN_ACTION_OUTPUT, $action) . $_SERVER['REQUEST_URI'];
     if (defined('AMP_SYSTEM_USER_ID')) {
         $cache_key = $cache->identify($cache_key, AMP_SYSTEM_USER_ID);
     }
     $this->_display->cache($display_key, $cache_key);
     return true;
 }
コード例 #6
0
ファイル: Captcha.inc.php プロジェクト: radicaldesigns/amp
      ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
      SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   
      Last Updated:  18th April 2006                               */
/***************************************************************/
/************************ Documentation ************************/
/*
Documentation is available at http://www.ejeliot.com/pages/2
*/
/************************ Default Options **********************/
// start a PHP session - this class uses sessions to store the generated
// code. Comment out if you are calling already from your application
//session_start();
// class defaults - change to effect globally
$cache =& AMP_get_cache();
$captcha_key_value = AMP_System_Cache::identify('php_captcha', AMP_SYSTEM_UNIQUE_VISITOR_ID);
define('CAPTCHA_SESSION_ID', $captcha_key_value);
define('CAPTCHA_WIDTH', 200);
// max 500
define('CAPTCHA_HEIGHT', 50);
// max 200
define('CAPTCHA_NUM_CHARS', 5);
define('CAPTCHA_NUM_LINES', 70);
define('CAPTCHA_CHAR_SHADOW', false);
define('CAPTCHA_OWNER_TEXT', AMP_SITE_URL);
define('CAPTCHA_CHAR_SET', '');
// defaults to A-Z
define('CAPTCHA_CASE_INSENSITIVE', true);
//define('CAPTCHA_BACKGROUND_IMAGES', '');
define('CAPTCHA_BACKGROUND_IMAGES', AMP_LOCAL_PATH . '/img/captcha_bg1.jpg,' . AMP_LOCAL_PATH . '/img/captcha_bg2.jpg');
コード例 #7
0
ファイル: Menu.inc.php プロジェクト: radicalsuz/amp
 function cache_components()
 {
     $this->_cache =& AMP_get_cache();
     $this->_header =& AMP_getHeader();
     return $this->cache_css() . $this->cache_js() . $this->cache_html();
 }
コード例 #8
0
 function AMP_cacheFlush($key_token = null)
 {
     $cache =& AMP_get_cache();
     if ($cache && strtolower(get_class($cache) == 'AMP_System_Cache_File') && !is_dir(AMP_pathFlip(AMP_SYSTEM_CACHE_PATH))) {
         //don't endlessly repeat file cache clearing
         return;
     }
     if (isset($key_token)) {
         $flush_command = "find " . AMP_SYSTEM_CACHE_PATH . DIRECTORY_SEPARATOR . " -name " . $key_token . "\\* | xargs rm &";
     } else {
         $dbcon = AMP_Registry::getDbcon();
         $dbcon->CacheFlush();
         $flush_command = "rm -rf " . AMP_SYSTEM_CACHE_PATH . DIRECTORY_SEPARATOR . "* &";
     }
     $command_result = false;
     system($flush_command, $command_result);
     if (!isset($key_token) || $key_token == AMP_CACHE_TOKEN_ADODB) {
         //$flush_command = "rm -f `find ". AMP_LOCAL_PATH . DIRECTORY_SEPARATOR . 'cache' ." -name adodb_*.cache` &";
         $flush_command = "find " . AMP_LOCAL_PATH . DIRECTORY_SEPARATOR . 'cache' . " -name ?? | xargs rm -rf &";
         //$flush_command = "find ". AMP_LOCAL_PATH . DIRECTORY_SEPARATOR . 'cache' ." -name adodb_\*.cache | xargs rm &";
         $command_result = false;
         system($flush_command, $command_result);
     }
     if ($command_result) {
         //unix systems should return 0 on success, try a DOS filesystem command
         //this function will not flush memcache on windows, probably no one cares
         $flush_command = "rmdir /S /Q " . AMP_pathFlip(AMP_SYSTEM_CACHE_PATH);
         system($flush_command, $command_result);
         trigger_error('Win flush result was ' . $command_result);
         return;
     }
     if (!$cache) {
         return false;
     }
     $cache->clear($key_token);
     $flash = AMP_System_Flash::instance();
     $flash->restore_cache();
 }
コード例 #9
0
ファイル: cache.php プロジェクト: radicalsuz/amp
<?php

require_once 'AMP/BaseDB.php';
$request_key = isset($_GET['key']) && $_GET['key'] ? $_GET['key'] : false;
if (!$request_key) {
    trigger_error('cache page called without key ' . $_SERVER['REQUEST_URI']);
    exit;
}
if (!($cache =& AMP_get_cache())) {
    trigger_error('cache page failed to load cache');
    exit;
}
$authorized_key = $request_key;
if (defined('AMP_SYSTEM_USER_ID') && AMP_SYSTEM_USER_ID) {
    $authorized_key = $cache->identify($request_key, AMP_SYSTEM_USER_ID);
}
if ($content_type = $cache->header($request_key)) {
    //should send an appropriate header depending on the key type
    header($content_type);
}
$content = $cache->retrieve($authorized_key);
if (!$content) {
    trigger_error('item ' . $request_key . ' not found for user');
    exit;
}
print $content;
AMP_cache_close();
コード例 #10
0
ファイル: Setup.php プロジェクト: radicaldesigns/amp
/*
require_once( 'AMP/System/Lookups.inc.php');
$sites = AMP_lookup( 'subsites');
$server_name = $_SERVER['SERVER_NAME'];
foreach( $sites as $site_id => $site_url ) {
    if ( strpos( $site_url, $_SERVER['SERVER_NAME'])) {
        define( 'AMP_SYSTEM_SETTING_DB_ID', $site_id );
        trigger_error( 'found site id ' . $site_id );
    }
}
if ( !defined( 'AMP_SYSTEM_SETTING_DB_ID')) {
    define( 'AMP_SYSTEM_SETTING_DB_ID', AMP_CONTENT_SECTION_ID_ROOT );
}
*/
//check cache
$system_setup_key = 'SYSTEM_SETUP_' . AMP_SYSTEM_UNIQUE_ID . '_' . AMP_SYSTEM_SETTING_DB_ID;
if (!($SystemSetup = AMP_cache_get($system_setup_key))) {
    $SystemSetup = new AMP_System_Setup(AMP_Registry::getDbcon());
    AMP_cache_set($system_setup_key, $SystemSetup);
}
$SystemSetup->execute();
//default timezone for php 5.3
if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set('America/Los_Angeles');
}
// enable memcache for adodb if memcache is active
if (($cache =& AMP_get_cache()) && strtolower(get_class($cache)) == 'amp_system_cache_memcache') {
    $dbcon =& AMP_Registry::getDbcon();
    $dbcon->memcache = true;
    $dbcon->cacheSecs = AMP_SITE_CACHE_TIMEOUT;
}
コード例 #11
0
ファイル: Lookups.inc.php プロジェクト: radicaldesigns/amp
 function &instance($type, $instance_var = null, $lookup_baseclass = "AMPSystemLookup", $clear_existing = false)
 {
     static $lookup_set = false;
     static $cache = false;
     $empty_value = false;
     if (!$cache) {
         $cache = AMP_get_cache();
     }
     $req_class = $lookup_baseclass . '_' . ucfirst($type);
     if (!class_exists($req_class)) {
         trigger_error(sprintf(AMP_TEXT_ERROR_LOOKUP_NOT_FOUND, $req_class));
         return $empty_value;
     }
     if (!isset($instance_var)) {
         if ($clear_existing) {
             unset($lookup_set[$type]);
             return $empty_value;
         }
         //standard lookup
         if (!isset($lookup_set[$type])) {
             $lookup_cache_key = AMPSystem_Lookup::cache_key($type, $instance_var);
             $cached_lookup = AMP_cache_get($lookup_cache_key);
             if (!($cached_lookup && (!method_exists($cached_lookup, 'allow_cache') || $cached_lookup->allow_cache()))) {
                 $lookup_set[$type] = new $req_class();
                 if (!method_exists($lookup_set[$type], 'allow_cache') || $lookup_set[$type]->allow_cache()) {
                     AMP_cache_set($lookup_cache_key, $lookup_set[$type]);
                 }
             } else {
                 $lookup_set[$type] = $cached_lookup;
             }
         }
     } else {
         //instanced lookup
         if (!isset($lookup_set[$type])) {
             $lookup_set[$type] = array();
         }
         if ($clear_existing) {
             unset($lookup_set[$type][$instance_var]);
             return $empty_value;
         }
         if (!isset($lookup_set[$type][$instance_var])) {
             $lookup_cache_key = AMPSystem_Lookup::cache_key($type, $instance_var);
             $cached_lookup = AMP_cache_get($lookup_cache_key);
             if (!$cached_lookup) {
                 $lookup_set[$type][$instance_var] = new $req_class($instance_var);
                 AMP_cache_set($lookup_cache_key, $lookup_set[$type][$instance_var]);
             } else {
                 $lookup_set[$type][$instance_var] = $cached_lookup;
             }
         }
         return $lookup_set[$type][$instance_var]->dataset;
     }
     //AMP_cache_set( AMP_CACHE_TOKEN_LOOKUP . 'Master__' . AMP_SYSTEM_USER_ID, $lookup_set );
     return $lookup_set[$type]->dataset;
 }