当前位置: 首页>>代码示例>>PHP>>正文


PHP Google_Config::setCacheClass方法代码示例

本文整理汇总了PHP中Google_Config::setCacheClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Google_Config::setCacheClass方法的具体用法?PHP Google_Config::setCacheClass怎么用?PHP Google_Config::setCacheClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Google_Config的用法示例。


在下文中一共展示了Google_Config::setCacheClass方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     $this->gadwp = GADWP();
     include_once GADWP_DIR . 'tools/autoload.php';
     $config = new Google_Config();
     $config->setCacheClass('Google_Cache_Null');
     if (function_exists('curl_version')) {
         $curlversion = curl_version();
         if (isset($curlversion['version']) && version_compare(PHP_VERSION, '5.3.0') >= 0 && version_compare($curlversion['version'], '7.10.8') >= 0 && defined('GADWP_IP_VERSION') && GADWP_IP_VERSION) {
             $config->setClassConfig('Google_IO_Curl', array('options' => array(CURLOPT_IPRESOLVE => GADWP_IP_VERSION)));
             // Force CURL_IPRESOLVE_V4 or CURL_IPRESOLVE_V6
         }
     }
     $this->client = new Google_Client($config);
     $this->client->setScopes('https://www.googleapis.com/auth/analytics.readonly');
     $this->client->setAccessType('offline');
     $this->client->setApplicationName('Google Analytics Dashboard');
     $this->client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');
     $this->set_error_timeout();
     $this->managequota = 'u' . get_current_user_id() . 's' . get_current_blog_id();
     $this->access = array_map(array($this, 'map'), $this->access);
     if ($this->gadwp->config->options['ga_dash_userapi']) {
         $this->client->setClientId($this->gadwp->config->options['ga_dash_clientid']);
         $this->client->setClientSecret($this->gadwp->config->options['ga_dash_clientsecret']);
         $this->client->setDeveloperKey($this->gadwp->config->options['ga_dash_apikey']);
     } else {
         $this->client->setClientId($this->access[0]);
         $this->client->setClientSecret($this->access[1]);
     }
     $this->service = new Google_Service_Analytics($this->client);
     if ($this->gadwp->config->options['ga_dash_token']) {
         $token = $this->gadwp->config->options['ga_dash_token'];
         if ($token) {
             try {
                 $this->client->setAccessToken($token);
                 $gadwp->config->options['ga_dash_token'] = $this->client->getAccessToken();
             } catch (Google_IO_Exception $e) {
                 GADWP_Tools::set_cache('ga_dash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e), $this->error_timeout);
             } catch (Google_Service_Exception $e) {
                 GADWP_Tools::set_cache('ga_dash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html("(" . $e->getCode() . ") " . $e->getMessage()), $this->error_timeout);
                 GADWP_Tools::set_cache('ga_dash_gapi_errors', array($e->getCode(), (array) $e->getErrors()), $this->error_timeout);
                 $this->reset_token();
             } catch (Exception $e) {
                 GADWP_Tools::set_cache('ga_dash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e), $this->error_timeout);
                 $this->reset_token();
             }
             if (is_multisite() && $this->gadwp->config->options['ga_dash_network']) {
                 $this->gadwp->config->set_plugin_options(true);
             } else {
                 $this->gadwp->config->set_plugin_options();
             }
         }
     }
 }
开发者ID:RagnarDanneskjold,项目名称:goodbyeloans.com,代码行数:54,代码来源:gapi.php

示例2: __construct

 public function __construct()
 {
     $this->gadwp = GADWP();
     include_once GADWP_DIR . 'tools/autoload.php';
     $config = new Google_Config();
     $config->setCacheClass('Google_Cache_Null');
     if (function_exists('curl_version')) {
         $curlversion = curl_version();
         if (isset($curlversion['version']) && version_compare(PHP_VERSION, '5.3.0') >= 0 && version_compare($curlversion['version'], '7.10.8') >= 0 && defined('GADWP_IP_VERSION') && GADWP_IP_VERSION) {
             $config->setClassConfig('Google_IO_Curl', array('options' => array(CURLOPT_IPRESOLVE => GADWP_IP_VERSION)));
             // Force
             // CURL_IPRESOLVE_V4
             // or
             // CURL_IPRESOLVE_V6
         }
     }
     $this->client = new Google_Client($config);
     $this->client->setScopes('https://www.googleapis.com/auth/analytics.readonly');
     $this->client->setAccessType('offline');
     $this->client->setApplicationName('Google Analytics Dashboard');
     $this->client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');
     $this->set_error_timeout();
     $this->managequota = 'u' . get_current_user_id() . 's' . get_current_blog_id();
     if ($this->gadwp->config->options['ga_dash_userapi']) {
         $this->client->setClientId($this->gadwp->config->options['ga_dash_clientid']);
         $this->client->setClientSecret($this->gadwp->config->options['ga_dash_clientsecret']);
         $this->client->setDeveloperKey($this->gadwp->config->options['ga_dash_apikey']);
     } else {
         $this->client->setClientId($this->gadwp->config->access[0]);
         $this->client->setClientSecret($this->gadwp->config->access[1]);
         $this->client->setDeveloperKey($this->gadwp->config->access[2]);
     }
     $this->service = new Google_Service_Analytics($this->client);
     if ($this->gadwp->config->options['ga_dash_token']) {
         $token = $this->gadwp->config->options['ga_dash_token'];
         $token = $this->refresh_token();
         if ($token) {
             $this->client->setAccessToken($token);
         }
     }
 }
开发者ID:nilmadhab,项目名称:webtutplus,代码行数:41,代码来源:gapi.php

示例3: array

 function __construct()
 {
     global $GADASH_Config;
     include_once $GADASH_Config->plugin_path . '/tools/autoload.php';
     $config = new Google_Config();
     $config->setCacheClass('Google_Cache_Null');
     if (function_exists('curl_version')) {
         $curlversion = curl_version();
         if (isset($curlversion['version']) and version_compare($curlversion['version'], '7.10.8') >= 0 and defined('GADWP_IP_VERSION') and GADWP_IP_VERSION) {
             $config->setClassConfig('Google_IO_Curl', array('options' => array(CURLOPT_IPRESOLVE => GADWP_IP_VERSION)));
             // Force CURL_IPRESOLVE_V4 OR CURL_IPRESOLVE_V6
         }
     }
     $this->client = new Google_Client($config);
     $this->client->setScopes('https://www.googleapis.com/auth/analytics.readonly');
     $this->client->setAccessType('offline');
     $this->client->setApplicationName('Google Analytics Dashboard');
     $this->client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');
     $this->set_error_timeout();
     $this->managequota = 'u' . get_current_user_id() . 's' . get_current_blog_id();
     if ($GADASH_Config->options['ga_dash_userapi']) {
         $this->client->setClientId($GADASH_Config->options['ga_dash_clientid']);
         $this->client->setClientSecret($GADASH_Config->options['ga_dash_clientsecret']);
         $this->client->setDeveloperKey($GADASH_Config->options['ga_dash_apikey']);
     } else {
         $this->client->setClientId('65556128781.apps.googleusercontent.com');
         $this->client->setClientSecret('Kc7888wgbc_JbeCpbFjnYpwE');
         $this->client->setDeveloperKey('AIzaSyBG7LlUoHc29ZeC_dsShVaBEX15SfRl_WY');
     }
     $this->service = new Google_Service_Analytics($this->client);
     if ($GADASH_Config->options['ga_dash_token']) {
         $token = $GADASH_Config->options['ga_dash_token'];
         $token = $this->ga_dash_refresh_token();
         if ($token) {
             $this->client->setAccessToken($token);
         }
     }
 }
开发者ID:hkarriche,项目名称:wordpress,代码行数:38,代码来源:gapi.php

示例4: setCache

 /**
  * Set the Cache object
  * @param Google_Cache_Abstract $cache
  */
 public function setCache(Google_Cache_Abstract $cache)
 {
     $this->config->setCacheClass(get_class($cache));
     $this->cache = $cache;
 }
开发者ID:hzhou9,项目名称:coupon_deal,代码行数:9,代码来源:Client.php

示例5: googleAuthenticate

/** Google authentication */
function googleAuthenticate($code)
{
    $state = getGoogleAuthenticateState();
    if ($state === false) {
        return;
    }
    include dirname(__DIR__) . '/config/config.php';
    global $CDASH_DB_HOST, $CDASH_DB_LOGIN, $CDASH_DB_PASS, $CDASH_DB_NAME;
    $SessionCachePolicy = 'private_no_expire';
    // initialize the session
    session_name('CDash');
    session_cache_limiter($SessionCachePolicy);
    session_set_cookie_params($CDASH_COOKIE_EXPIRATION_TIME);
    @ini_set('session.gc_maxlifetime', $CDASH_COOKIE_EXPIRATION_TIME + 600);
    session_start();
    // check that the anti-forgery token is valid
    if ($state->csrfToken != $_SESSION['cdash']['csrfToken']) {
        add_log('state anti-forgery token mismatch: ' . $state->csrfToken . ' vs ' . $_SESSION['cdash']['csrfToken'], 'googleAuthenticate', LOG_ERR);
        return;
    }
    $redirectURI = strtok(get_server_URI(false), '?');
    // The return value of get_server_URI can be inconsistent.
    // It simply returns $CDASH_BASE_URL if that variable is set, yielding a
    // return value like http://mydomain.com/CDash.
    // If this variable is not set, then it will return the full URI including
    // the current script, ie
    // http://mydomain.com/CDash/googleauth_callback.php.
    //
    // Make sure that redirectURI contains the path to our callback script.
    if (strpos($redirectURI, 'googleauth_callback.php') === false) {
        $redirectURI .= '/googleauth_callback.php';
    }
    try {
        $config = new Google_Config();
        if ($CDASH_MEMCACHE_ENABLED) {
            $config->setCacheClass('Google_Cache_Memcache');
            list($server, $port) = $CDASH_MEMCACHE_SERVER;
            $config->setClassConfig('Google_Cache_Memcache', 'host', $server);
            $config->setClassConfig('Google_Cache_Memcache', 'port', $port);
        }
        $client = new Google_Client($config);
        $client->setClientId($GOOGLE_CLIENT_ID);
        $client->setClientSecret($GOOGLE_CLIENT_SECRET);
        $client->setRedirectUri($redirectURI);
        $client->authenticate($_GET['code']);
        $oauth = new Google_Service_Oauth2($client);
        $me = $oauth->userinfo->get();
        $tokenResponse = json_decode($client->getAccessToken());
    } catch (Google_Auth_Exception $e) {
        add_log('Google access token request failed: ' . $e->getMessage(), 'googleAuthenticate', LOG_ERR);
        return;
    }
    // Check if this email address appears in our user database
    $email = strtolower($me->getEmail());
    $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
    pdo_select_db("{$CDASH_DB_NAME}", $db);
    $sql = 'SELECT id,password FROM ' . qid('user') . " WHERE email='" . pdo_real_escape_string($email) . "'";
    $result = pdo_query("{$sql}");
    if (pdo_num_rows($result) == 0) {
        // if no match is found, redirect to pre-filled out registration page
        pdo_free_result($result);
        $firstname = $me->getGivenName();
        $lastname = $me->getFamilyName();
        header("Location: register.php?firstname={$firstname}&lastname={$lastname}&email={$email}");
        return false;
    }
    $user_array = pdo_fetch_array($result);
    $pass = $user_array['password'];
    if ($state->rememberMe) {
        require_once 'include/login_functions.php';
        setRememberMeCookie($user_array['id']);
    }
    $sessionArray = array('login' => $email, 'passwd' => $user_array['password'], 'ID' => session_id(), 'valid' => 1, 'loginid' => $user_array['id']);
    $_SESSION['cdash'] = $sessionArray;
    session_write_close();
    pdo_free_result($result);
    header("Location: {$state->requestedURI}");
    return true;
    // authentication succeeded
}
开发者ID:kitware,项目名称:cdash,代码行数:81,代码来源:googleauth_callback.php


注:本文中的Google_Config::setCacheClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。