예제 #1
0
 public static function trackActor($email, $action, $properties = array())
 {
     if (class_exists('\\Activity\\Models\\Actions')) {
         \Activity\Models\Actions::trackActor($email, $action, $properties);
     }
     if (class_exists('\\Admin\\Models\\Settings') && class_exists('\\KM')) {
         $settings = \Admin\Models\Settings::fetch();
         if ($settings->enabledIntegration('kissmetrics') && $settings->{'integration.kissmetrics.key'}) {
             \KM::init($settings->{'integration.kissmetrics.key'});
             \KM::identify($email);
             \KM::record($action, $properties);
         }
     }
     return null;
 }
예제 #2
0
 function authenticate($data)
 {
     if ($data === false) {
         $this->destroyData();
         return false;
     }
     if ($this->from_session || $this->from_cookie) {
         $hashed_password = $data['password'];
         // Does not re-hash the password (saving time because the hashed password is in the Session)
     } else {
         $hashed_password = $this->hasher($data['password']);
     }
     switch ($this->user_name_case_folding) {
         case 'lower':
             $data['username'] = strtolower($data['username']);
             break;
         case 'upper':
             $data['username'] = strtoupper($data['username']);
             break;
         default:
             break;
     }
     $conditions = array($this->user_model_name . "." . $this->user_name_field => $data['username'], $this->user_model_name . "." . $this->user_pass_field => $hashed_password);
     if ($this->user_live_field) {
         $field = $this->user_model_name . "." . $this->user_live_field;
         $conditions[$field] = $this->user_live_value;
     }
     $this->controller->{$this->user_model_name}->contain(array('Profile', $this->group_model_name));
     $check = $this->controller->{$this->user_model_name}->find($conditions);
     if ($check) {
         $this->Session->write($this->secure_key(), $check);
         if ($this->allow_cookie && $this->from_post && array_key_exists('remember_me', $data) && $data['remember_me'] == true) {
             // set our cookie!
             if (array_key_exists('cookie_expiry', $data)) {
                 $this->cookie_expiry = $data['cookie_expiry'];
             } else {
                 $this->cookie_expiry;
             }
             if (strtotime($this->cookie_expiry) <= time()) {
                 // Session cookie? might as well not set at all...
             } else {
                 $expiry = strtotime($this->cookie_expiry);
                 $this->setCookieInfo(array('username' => $data['username'], 'password' => $hashed_password, 'expiry' => $expiry), $expiry);
             }
         }
         $this->current_user = $check;
         $this->li = true;
         $this->id = $check[$this->user_model_name]['id'];
         // Initialize Kiss Metrics identity
         KM_init();
         KM::identify($check[$this->user_model_name]['email']);
         // Must be on the correct site
         // - unless they are admin
         /*
         if($check['User']['role_id'] == 3){
         	// Admin, do not redirect
         } else {
         	if(strtolower($check['User']['work_state']) == 'ca'){
         		// Must be on PDC	
         		if(IDC_PDC != 'pdc'){
         			$this->controller->redirect(PDC_BASE_URL);
         		}
         	} else {
         		// Must be on IDC
         		if(IDC_PDC != 'idc'){
         			$this->controller->redirect(IDC_BASE_URL);
         		}
         	}
         }
         */
         return true;
     } else {
         if ($this->from_post) {
             //$this->Session->setFlash($this->login_failed_message);
             return false;
         }
         $this->destroyData();
         return false;
     }
 }
예제 #3
0
 protected static function reset()
 {
     self::$epoch = null;
     self::$id = null;
     self::$key = null;
     self::$logs = array();
     self::$log_dir = '/tmp';
     self::$to_stderr = true;
     self::$use_cron = false;
 }
예제 #4
0
파일: km.php 프로젝트: newvem/KISSmetrics
 protected static function get_hostname()
 {
     if (self::$hostname) {
         return self::$hostname;
     }
     self::$hostname = php_uname('n');
     if (is_callable('gethostname')) {
         if ($hostname = gethostname()) {
             self::$hostname = $hostname;
         }
     }
     self::$hostname = self::array_get($_SERVER, 'HOSTNAME', self::$hostname);
     return self::$hostname;
 }
예제 #5
0
function main()
{
    $kc = new KM();
    $kc->getInfo();
    var_dump($kc->getKS());
}
예제 #6
0
<?php

use lithium\core\Libraries;
$_config = Libraries::get('li3_kissmetrics');
if (isset($_config['key']) && !empty($_config['key'])) {
    if (!isset($_config['options'])) {
        $_config['options'] = array();
    }
    if (!isset($_config['options']['log_dir']) || empty($_config['options']['log_dir'])) {
        $_config['options']['log_dir'] = Libraries::get(true, 'resources') . '/tmp/logs';
    }
    \KM::init($_config['key'], $_config['options']);
}
unset($_config);