コード例 #1
0
ファイル: auth.php プロジェクト: synchrotalk/synchrotalk
 private function RefactorDirectAnswer()
 {
     // This code is not working and has to be re-factored
     $user = $network->log_in($login, $password);
     phoxy_protected_assert($user, "Login/password invalid");
     $user['network'] = $network;
     $accounts[$network] = ["network" => $network, "login" => $login, "password" => $password, "user" => $user];
     return ["design" => "accounts/create/welcome", "data" => ['user' => $user, 'next' => 'inbox'], "script" => "user", "before" => "user.login"];
 }
コード例 #2
0
ファイル: accounts.php プロジェクト: synchrotalk/synchrotalk
 private function get_account_object($account_id)
 {
     if (!empty($this->loaded_accounts[$account_id])) {
         return $this->loaded_accounts[$account_id];
     }
     $account = db::Query("SELECT *\n      FROM personal.tokens\n      WHERE uid=\$1\n        AND account_id=\$2", [db::UID(), $account_id], true);
     phoxy_protected_assert($account(), "Account not found. Please connect again");
     list($obj, $user) = $this->network_signin($account->network, json_decode($account->token_data, true));
     db::Query("UPDATE personal.tokens\n        SET profile_id=\$2\n        WHERE account_id=\$1", [$account_id, $user->id]);
     return $this->loaded_accounts[$account_id] = $obj;
 }
コード例 #3
0
ファイル: network.php プロジェクト: synchrotalk/synchrotalk
 public function get_network_object($network)
 {
     $storage_functor = phoxy::Load('user')->StorageShortcut();
     $accounts =& $storage_functor()['accounts'];
     if (!is_array($accounts)) {
         $accounts = [];
     }
     phoxy_protected_assert(!isset($accounts[$network]), "In demo mode one account per social network");
     $networks = phoxy::Load('networks');
     phoxy_protected_assert($networks->supported($network), "Social network unsupported");
     $obj = $networks->get_network_object($network);
     $this->init_network_object($obj, $network);
     return $obj;
 }
コード例 #4
0
ファイル: include.php プロジェクト: phoxy/phoxy
function IncludeModule($dir, $module)
{
    $args = [];
    if (is_array($module)) {
        $args = $module[1];
        $module = $module[0];
    }
    if (substr($dir, 0, 2) === './') {
        $dir = substr($dir, 2);
    }
    $module_file = str_replace('\\', '/', $module);
    $file = "{$dir}/{$module_file}.php";
    if (stripos($file, "..") !== false) {
        return null;
    }
    if (!file_exists($file)) {
        return null;
    }
    global $phoxy_loading_module;
    $phoxy_loading_module = $module;
    include_once __DIR__ . "/api.php";
    try {
        global $_phoxy_loaded_classes;
        if (isset($_phoxy_loaded_classes[$dir][$module])) {
            return $_phoxy_loaded_classes[$dir][$module];
        }
        $classname = $module;
        $cross_include = class_exists($classname);
        if ($cross_include) {
            include 'virtual_namespace_helper.php';
        } else {
            include_once $file;
        }
        if (!class_exists($classname)) {
            die('Class include failed. File do not carrying that');
        }
        $obj = InstanceClassByName($classname, $args);
        if (!isset($_phoxy_loaded_classes[$dir])) {
            $_phoxy_loaded_classes[$dir] = [];
        }
        $_phoxy_loaded_classes[$dir][$module] = $obj;
        return $obj;
    } catch (phoxy_protected_call_error $e) {
        throw $e;
    } catch (Exception $e) {
        phoxy_protected_assert(false, ["error" => "Uncaught script exception at module load"]);
    }
}
コード例 #5
0
ファイル: api.php プロジェクト: phoxy/phoxy
 public function __call($name, $arguments)
 {
     $ret = $this->Call($name, $arguments);
     phoxy_protected_assert(!empty($ret['data']), "Probably internal inconsistence inside phoxy, please bug report");
     // raw calls do not affects restrictions
     if ($this->ShouldSkipPostProcess($name)) {
         return $ret;
     } else {
         phoxy_return_worker::NewCache($ret['cache']);
     }
     if (!isset($ret['data'])) {
         return phoxy_protected_assert(empty($ret['error']), $ret);
     }
     $d = $ret['data'];
     // Reverse public method translation
     if (is_array($d) && !empty($d[$name])) {
         $d = $d[$name];
     }
     if ($this->expect_simple_result && is_array($d) && count($d) === 1 && !isset($d[0])) {
         return reset($d);
     }
     return $d;
 }
コード例 #6
0
ファイル: auth.php プロジェクト: Exsul/inyo
 protected function uid()
 {
     phoxy_protected_assert($this->is_user_authorized(), ["exception" => "auth_required", "origin" => $this->GetExceptionOrigin(), "cache" => "no", "data" => ["origin" => $this->GetExceptionOrigin()]]);
     return $this->login();
 }
コード例 #7
0
ファイル: phoxy_return_worker.php プロジェクト: phoxy/phoxy
 private static function ParseCache($str)
 {
     $str = trim($str);
     if ($str == 'no') {
         return -1;
     }
     $arr = preg_split('/([0-9]+)([wdhms]?)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
     phoxy_protected_assert(count($arr) > 1, "Cache string parse error");
     $base = 0;
     $ret = 0;
     while (true) {
         $amount = $arr[$base + 1];
         $modifyer = $arr[$base + 2];
         if ($modifyer === '') {
             $modifyer = 's';
         }
         $mult = 1;
         switch ($modifyer) {
             case 'w':
                 $mult *= 7;
             case 'd':
                 $mult *= 24;
             case 'h':
                 $mult *= 60;
             case 'm':
                 $mult *= 60;
             case 's':
                 $mult *= 1;
         }
         $ret += (int) $amount * $mult;
         $base += 3;
         if ($base + 2 >= count($arr)) {
             break;
         }
     }
     return $ret;
 }
コード例 #8
0
ファイル: okcupid.php プロジェクト: Enelar/okcupid
 public final function get_receiver_by_nick($nick)
 {
     $site = $this->curl("http://www.okcupid.com/profile/{$nick}");
     //echo $site;
     // GlobalMessaging.open('4205836261586580239')
     $match = preg_match("/GlobalMessaging.open.*?(\\d+)/", $site, $matches);
     phoxy_protected_assert($match, "Receiver id determination failed. Api changed?");
     phoxy_protected_assert(count($matches) > 1, "Access token not found! Api changed!");
     return $matches[1];
 }
コード例 #9
0
ファイル: tokens.php プロジェクト: synchrotalk/synchrotalk
 public function info($account_id)
 {
     $account = db::Query("SELECT *\n      FROM personal.tokens\n      WHERE uid=\$1 AND account_id=\$2", [db::UID(), $account_id], true);
     phoxy_protected_assert($account(), "Internal issue: account not found");
     return $this->PrepareAccount($account);
 }
コード例 #10
0
ファイル: db.php プロジェクト: synchrotalk/synchrotalk
 public static function UID()
 {
     $uid = phoxy::Load('user/store')->MyUID();
     phoxy_protected_assert($uid, "Please log in to continue");
     return $uid;
 }
コード例 #11
0
ファイル: cache.php プロジェクト: synchrotalk/synchrotalk
 public function AccountID()
 {
     phoxy_protected_assert($this->account_id, "Please set account for cache request");
     return $this->account_id;
 }