From 6eb28f7a5b0c0d5cd02897c5fd1b1dab79b8822b Mon Sep 17 00:00:00 2001 From: fujia Date: Tue, 6 Jul 2010 03:28:09 +0000 Subject: [PATCH] + add signature verification. --- trunk/bin/getbugs.php | 26 ++++++++++++++++++++------ trunk/bin/todo.php | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/trunk/bin/getbugs.php b/trunk/bin/getbugs.php index 6da92c6b0c..acc3cb2779 100755 --- a/trunk/bin/getbugs.php +++ b/trunk/bin/getbugs.php @@ -1,7 +1,7 @@ #!/usr/bin/env php fetch($sessionAPI); $session = json_decode($snoopy->results); +$session = json_decode($session->data); /*用户登录*/ +$authHash = md5(md5($password) . $session->rand); $submitVars["account"] = $account; -$submitVars["password"] = $password; +$submitVars["password"] = $authHash; $snoopy->cookies[$session->sessionName] = $session->sessionID; $snoopy->submit($loginAPI, $submitVars); /* 直接调用my模块的bugs页面。*/ $snoopy->fetch($myBugAPI . "&$session->sessionName=$session->sessionID"); $result = json_decode($snoopy->results); -if($result->bugs) + +if($result->status == 'success' && md5($result->data) == $result->md5) { - foreach($result->bugs as $bug) echo $bug->title . "\n"; + $bugs = json_decode($result->data)->bugs; +} +else +{ + echo "called failed or transfered not complete."; + exit; +} + +if($bugs) +{ + foreach($bugs as $bug) echo $bug->id . "\t" . $bug->title . "\n"; } else { echo 'no bugs' . "\n"; } + /* 通过超级model调用。*/ $snoopy->fetch($superMyBugAPI . "&$session->sessionName=$session->sessionID"); $result = json_decode($snoopy->results); -if(is_array($result)) +if(is_object($result)) { - foreach($results as $bug) echo $bug->title . "\n"; + foreach($result as $id=>$bug) echo $id . "\t" . $bug . "\n"; } else { diff --git a/trunk/bin/todo.php b/trunk/bin/todo.php index b3aae0e480..b4f22e4bff 100755 --- a/trunk/bin/todo.php +++ b/trunk/bin/todo.php @@ -1,7 +1,7 @@ #!/usr/bin/env php