コード例 #1
0
ファイル: hub.php プロジェクト: jonolsson/Saturday
 /**
  * Handle a subscription request.
  *
  * @param $post
  *   A valid PubSubHubbub subscription request.
  */
 public function subscribe($post)
 {
     //error_log(
     //print_r($post);
     // Authenticate
     $received_secret = $post['secret'];
     api_log::log('DEBUG', "Received secret: {$received_secret}");
     $cfg = api_config::getInstance()->hub;
     $secret = md5($cfg['secret'] . $post['hub_callback']);
     if ($secret == $received_secret and isset($post['hub_topic']) && isset($post['hub_callback']) && $this->verify($post)) {
         $this->subscriptions->save($post['hub_topic'], $post['hub_callback'], isset($post['secret']) ? $post['secret'] : '');
         //  header('HTTP/1.1 204 "No Content"', null, 204);
         //    exit(); */
         echo "Good";
         return true;
     }
     echo "not found";
     return false;
     //header('HTTP/1.1 404 "Not Found"', null, 404);
     //exit(); */
 }
コード例 #2
0
ファイル: pam.php プロジェクト: jonolsson/Saturday
 public function login($username, $password)
 {
     if ($username === '' && $password === '') {
         $username = $this->request->getParam('username');
         $password = $this->request->getParam('password');
     }
     //print_r($username);
     if (!empty($username)) {
         if ($this->checkAuth()) {
             $this->logout();
         }
         $crudColumns = $this->getConfiguredColumns();
         //print_r($crudColumns);
         // $hash = $this->getOpt('hash');
         //$sql = 'SELECT SUBSTR('.$crudColumns['password'].',1,'.(int)$hash['saltLength'].')
         //    FROM '.$this->config->crud['crudTable'].'
         //    WHERE '.$crudColumns['username'].' = '.$this->db->quote($username);
         //$stmt = $this->db->prepare($sql);
         //$stmt->execute(array());
         //$salt = $stmt->fetchColumn();
         //if (empty($salt)) {
         //    api_log::log(api_log::INFO, 'Salt not found in Database');
         //}
         //$hashedPW = api_helpers_hashHelper::crypt_pass($password, $salt, $hash);
         $select = array();
         foreach ($crudColumns as $alias => $val) {
             $select[] = $val . ' AS ' . $alias;
         }
         $select = implode(' ,', $select);
         $sql = 'SELECT ' . $select . ' FROM ' . $this->config->pam['table'] . ' WHERE ' . $crudColumns['username'] . ' = :username';
         //echo $sql;
         api_log::log(api_log::DEBUG, $sql);
         $stmt = $this->db->prepare($sql);
         $sqlParams = array('username' => $username);
         $stmt->execute($sqlParams);
         //echo "Here";
         //print_r($sqlParams);
         $userData = $stmt->fetch(PDO::FETCH_ASSOC);
         //print_r($userData);
         // Check password
         if (empty($userData)) {
             api_log::log(api_log::INFO, 'Credentials not correct');
             //    echo "Credential not correct";
         } else {
             if (!$this->checkPassword($password, $userData['password'])) {
                 api_log::log(api_log::INFO, 'Password not correct');
                 //              echo "Passwords wrong";
             } else {
                 session_regenerate_id(true);
                 unset($userData['password']);
                 //            echo "<br />";
                 //            print_r($this->config->appname);
                 //            echo "<br />";
                 //$_SESSION[$this->config->appname]['user'] = $userData;
                 api_log::log(api_log::INFO, 'Login Successful creating user session');
                 api_session::set('user', $userData);
             }
         }
     }
     return $this->checkAuth();
 }
コード例 #3
0
ファイル: pdoext.php プロジェクト: jonolsson/Saturday
 public function query($statement)
 {
     api_log::log(api_log::INFO, $statement instanceof pdoext_Query ? $statement->toSql($this) : $statement);
     return parent::query($statement);
     //$this->log($statement instanceOf pdoext_Query ? $statement->toSql($this) : $statement));
 }