示例#1
0
 function get_cached_version($action)
 {
     require_once 'AMP/System/Cache/File.php';
     $file_cache = new AMP_System_Cache_File();
     $cache_key = AMP_CACHE_TOKEN_IMAGE . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
     if (defined('AMP_SYSTEM_USER_ID') && AMP_SYSTEM_USER_ID) {
         $cache_key = AMP_System_Cache::identify($cache_key, AMP_SYSTEM_USER_ID);
     }
     $file_name = $file_cache->authorize($cache_key);
     $file_path = $file_cache->path($file_name);
     if ($this->_display($file_path)) {
         return true;
     }
     return $file_path;
 }
示例#2
0
      (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');
define('CAPTCHA_MIN_FONT_SIZE', 16);
function AMP_cached_image_request()
{
    require_once 'AMP/System/Cache/File.php';
    $cache_key = AMP_CACHE_TOKEN_IMAGE . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    if (defined('AMP_SYSTEM_USER_ID') && AMP_SYSTEM_USER_ID) {
        $cache_key = AMP_System_Cache::identify($cache_key, AMP_SYSTEM_USER_ID);
    }
    $file_cache = new AMP_System_Cache_File();
    $file_name = $file_cache->authorize($cache_key);
    $file_path = $file_cache->path($file_name);
    if (!file_exists($file_path)) {
        return false;
    }
    header("Content-Type: " . mime_content_type($file_path));
    $fRef = fopen($file_path, 'r');
    fpassthru($fRef);
    fclose($fRef);
    return true;
}
示例#4
0
文件: File.php 项目: radicalsuz/amp
 function authorize($key)
 {
     $authorized_key = false;
     $standard_key = parent::authorize($key);
     if ($standard_key) {
         //check for the slash char
         $illegal_characters = array('/', ':', '?', DIRECTORY_SEPARATOR, ';', ',', '*', '"', '\'', '<', '>', '!', '&', '+', '{', '}', '[', ']', '%', '#', '$');
         $authorized_key = str_replace($illegal_characters, '__IC__', $standard_key);
         //$authorized_key = urlencode($standard_key );
     }
     return $authorized_key;
 }
示例#5
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;
 }
示例#6
0
 function cache_key($type, $instance_var = null)
 {
     $lookup_cache_key = AMP_CACHE_TOKEN_LOOKUP . AMP_from_camelcase($type);
     if (defined('AMP_SYSTEM_USER_ID')) {
         $lookup_cache_key = AMP_System_Cache::identify($lookup_cache_key, AMP_SYSTEM_USER_ID);
     }
     if (!isset($instance_var)) {
         return $lookup_cache_key;
     }
     //instanced lookup
     return AMP_System_Cache::identify($lookup_cache_key . 'K', $instance_var);
 }