Exemple #1
0
function update_cookie_info($email, $password, $persistent, &$hash = null)
{
    $url = 'http://www.tumblr.com/login';
    $err = false;
    $req =& new HTTP_Request($url);
    $req->setMethod(HTTP_REQUEST_METHOD_POST);
    $req->addPostData("email", $email);
    $req->addPostData("password", $password);
    if (PEAR::isError($req->sendRequest())) {
        $err = 1;
    } else {
        $res = $req->getResponseBody();
        if (strstr($res, '<meta http-equiv="Refresh" content="0;url=/dashboard">') === false) {
            $err = 1;
        } else {
            $cookies = $req->getResponseCookies();
            $cookie_content = serialize($cookies);
            $k = calc_sha1($email, $password);
            if ($persistent == '') {
                $email = '';
                $password = '';
            }
            $db = get_db_connectiuon();
            if ($hash) {
                $db->query('UPDATE auth SET cookie = ? WHERE hash = ?', array($cookie_content, $hash));
            } else {
                $hash = $k;
                $db->query('INSERT auth (hash, cookie, email, password) VALUES (?,?,?,?)', array($k, $cookie_content, $email, $password));
            }
        }
    }
    if ($err) {
        $err = 'login failed.';
    }
    return array($err, $cookies);
}
 function sha1($source)
 {
     global $lC_Vqmod;
     if (function_exists('mhash')) {
         if (($hash = @mhash(MHASH_SHA1, $source)) !== false) {
             return bin2hex($hash);
         }
     }
     if (!function_exists('calc_sha1')) {
         include $lC_Vqmod->modCheck('ext/sha1/sha1.php');
     }
     return calc_sha1($source);
 }
 function sha1($source)
 {
     if (function_exists('mhash')) {
         if (($hash = @mhash(MHASH_SHA1, $source)) !== false) {
             return bin2hex($hash);
         }
     }
     if (!function_exists('calc_sha1')) {
         include 'ext/sha1/sha1.php';
     }
     return calc_sha1($source);
 }