예제 #1
0
 function Validate($sUserCode, $bCaseInsensitive = true)
 {
     if ($bCaseInsensitive) {
         $sUserCode = strtoupper($sUserCode);
     }
     //if (!empty($_SESSION[CAPTCHA_SESSION_ID]) && $sUserCode == $_SESSION[CAPTCHA_SESSION_ID]) {
     $cached_code = AMP_cache_get(CAPTCHA_SESSION_ID);
     //trigger_error( 'found cached code ' . $cached_code . 'vs '. $sUserCode );
     if (!$cached_code) {
         $cached_code = AMP_Form_Element_Captcha::validate(CAPTCHA_SESSION_ID);
     }
     //trigger_error( 'found cached code ' . $cached_code . 'vs '. $sUserCode );
     if ($cached_code && $sUserCode == $cached_code) {
         // clear to prevent re-use
         //unset($_SESSION[CAPTCHA_SESSION_ID]);
         AMP_cache_delete(CAPTCHA_SESSION_ID);
         AMP_Form_Element_Captcha::delete(CAPTCHA_SESSION_ID);
         return true;
     }
     return false;
 }
예제 #2
0
 function _clearCached()
 {
     $system_setup_key = 'SYSTEM_SETUP_' . AMP_SYSTEM_UNIQUE_ID;
     AMP_cache_delete($system_setup_key);
 }
예제 #3
0
 function clearCached($component)
 {
     if (AMP_DEBUG_MODE_COMPONENT_CACHE_INACTIVE) {
         return true;
     }
     $id = isset($component->id) ? $component->id : null;
     $cache_key = $this->getCacheKey($component, $id);
     return AMP_cache_delete($cache_key);
 }
예제 #4
0
function AMP_lookup_clear_cached($type, $instance_var = null)
{
    //delete from memcache
    require_once "AMP/System/Lookups.inc.php";
    $key = AMPSystem_Lookup::cache_key($type, $instance_var);
    AMP_cache_delete($key);
    //clear existing in-memory copy
    /*
      $lookup_types = array( 'AMPSystem_Lookup' => 'AMPSystemLookup_', 
               'AMPContent_Lookup' => 'AMPContentLookup_', 
               'FormLookup' => 'FormLookup_');
      $instance = AMP_to_camelcase( $lookup_type );
      $value = false;
      foreach( $lookup_types as $base_type => $prefix ) {
     if ( !class_exists( $prefix . ucfirst( $instance ))) continue;
     call_user_func_array( array( $base_type, 'instance'), array( $instance, $lookup_var, str_replace( '_', '', $prefix), true ));
      }
    */
}
예제 #5
0
function FlushMemCache($key = false, $host, $port, $debug = false)
{
    $AMP_key = AMP_CACHE_TOKEN_ADODB . $key;
    if ($key) {
        return AMP_cache_delete($AMP_key);
    } else {
        return AMP_cacheFlush();
    }
    /***
     * ADODB standard library memcache code
     * not used by AMP
     **/
    if (!function_exists('memcache_pconnect')) {
        if ($debug) {
            ADOConnection::outp(" Memcache module PECL extension not found!<br>\n");
        }
        return;
    }
    $memcache = new Memcache();
    if (!@$memcache->pconnect($host, $port)) {
        if ($debug) {
            ADOConnection::outp(" Can't connect to memcache server on: {$host}:{$port}<br>\n");
        }
        return;
    }
    if ($key) {
        if (!$memcache->delete($key)) {
            if ($debug) {
                ADOConnection::outp("CacheFlush: {$key} entery doesn't exist on memcached server!<br>\n");
            }
        } else {
            if ($debug) {
                ADOConnection::outp("CacheFlush: {$key} entery flushed from memcached server!<br>\n");
            }
        }
    } else {
        if (!$memcache->flush()) {
            if ($debug) {
                ADOConnection::outp("CacheFlush: Failure flushing all enteries from memcached server!<br>\n");
            }
        } else {
            if ($debug) {
                ADOConnection::outp("CacheFlush: All enteries flushed from memcached server!<br>\n");
            }
        }
    }
    return;
}