function from_tumblr() { global $sessionkey; $db = get_db_connectiuon(); list($sessionkey, $cookies, $u) = get_login_cookie($db); $page = getPage(); $agent = Net_UserAgent_Mobile::singleton(); // paging a page if ($agent->isDoCoMo()) { $page = ceil($page / 2); } //$postid = getPostId(); $url = 'http://www.tumblr.com/dashboard/'; if ($page > 1) { $url .= $page; } if ($postid > 1) { $url .= "/{$postid}"; } #print "<!--$url-->"; $retry = 2; while ($retry--) { $req =& new HTTP_Request($url); $req->setMethod(HTTP_REQUEST_METHOD_GET); foreach ($cookies as $v) { $req->addCookie($v['name'], $v['value']); } if (PEAR::isError($req->sendRequest())) { $err = 1; } $code = $req->getResponseCode(); if ($code == 302) { $err = true; if ($u['email']) { list($err, $cookies) = update_cookie_info($u['email'], $u['password'], true, $u['hash']); } if ($err) { $retry = 0; break; } } else { if ($code == 200) { return $req->getResponseBody(); } else { print '<html><body><pre>x_x'; print " {$code} "; print '</body></html>'; exit; } } } if ($retry == 0) { header('Location: /login'); } else { print '<html><body><pre>x_x'; print '</body></html>'; } exit; }
function __construct() { $post_id = $_REQUEST['id']; $this->db = $db = get_db_connectiuon(); list($sessionkey, $cookies) = get_login_cookie($db); $this->sessionkey = $sessionkey; $this->page = $page = getPage(); }
function validate_login_cookie() { $cookie = get_login_cookie(); $username = $cookie['username']; $password = $cookie['password']; $expiration = $cookie['expiration']; $expired = $expiration; // Quick check to see if an honest cookie has expired if ($expired < time()) { return false; } $userdata = get_userdatabyusername($username); $user_id = $userdata->ID; if ($userdata->password == $password && !empty($password)) { return $user_id; } return false; }
function __construct() { $post_id = $_REQUEST['id']; $this->db = $db = get_db_connectiuon(); list($sessionkey, $cookies) = get_login_cookie($db); $this->sessionkey = $sessionkey; $this->page = $page = getPage(); $pid = getmypid(); $this->postid = $postid = (int) $_REQUEST['postid']; if (preg_match('%^http://([a-z\\-_.]+\\.)+\\w{2,4}(/mobile)?/post/\\d+$%i', $link = (string) $_REQUEST['permalink'])) { $this->permalink = $link; } else { $link = ''; } $uniqkey = "{$pid}-{$postid}-{$sessionkey}"; $set = new Net_Gearman_Set(); $task = new Net_Gearman_Task('reblog', array(cookies => $cookies, postid => $postid, sessionkey => $sessionkey, permalink => $this->permalink, token => $_REQUEST['token'], uniqkey => $uniqkey), $uniqkey, Net_Gearman_Task::JOB_BACKGROUND); // $task->attachCallback('result'); $set->addTask($task); $client = new Net_Gearman_Client(array('localhost:37003')); $client->runSet($set); }