Exemplo n.º 1
0
 public static function lookup_c($id)
 {
     global $memcache;
     $key = "user-{$id}";
     $r = $memcache->get($key);
     if (!$r) {
         $r = Twollo_User::lookup($id);
         $memcache->set($key, $r);
     }
     return $r;
 }
Exemplo n.º 2
0
<?php

require_once "base.inc.php";
require_once "models/user.inc.php";
require_once "HTTP.php";
if ($_POST['other']) {
    HTTP::redirect("{$_GET['user']}+{$_POST['other']}");
    exit;
}
$user = Twollo_User::lookup_c($_GET['user']);
//var_dump($user->to_array());
$smarty->assign('user', $user->to_array());
$smarty->display('user.tpl');
//  print '<pre>'; var_dump($commonFriendIds); print '</pre>';
Exemplo n.º 3
0
    $user = $_GET['user'];
    if ($user) {
        $_SESSION['user'] = $user;
    } else {
        $user = $_SESSION['user'];
    }
    return $user;
}
if ($_POST['user'] && $_POST['other']) {
    HTTP::redirect("u/{$_POST['user']}+{$_POST['other']}");
}
$user = getUser();
$smarty->assign('user', $user);
$other = $_GET['other'];
if (!isset($_SESSION['count'])) {
    $_SESSION['count'] = 0;
}
$_SESSION['count']++;
if ($user && $other) {
    $logger->log("Finding commonality between {$user} and {$other}.", PEAR_LOG_INFO);
    $user_obj = Twollo_User::lookup_c($user);
    $other_obj = Twollo_User::lookup_c($other);
    $commonFriendIds = array_intersect($user_obj->get_friend_ids(), $other_obj->get_friend_ids());
    $commonFollowerIds = array_intersect($user_obj->get_follower_ids(), $other_obj->get_follower_ids());
    //  print '<pre>'; var_dump($commonFriendIds); print '</pre>';
    $smarty->assign('commonFriendsCount', count($commonFriendIds));
    $smarty->assign('commonFollowersCount', count($commonFollowerIds));
    $smarty->display('result.tpl');
} else {
    $smarty->display('form.tpl');
}