/** * check that the nonce is not repeated */ function check_nonce($consumer, $token, $nonce, $timestamp) { // verify that the nonce is uniqueish $found = $this->data_store->lookup_nonce($consumer, $token, $nonce, $timestamp); if ($found) { ___throwException("Nonce already used: {$nonce}"); } }
function _output($path, $type = null) { $toFile = false; //输出到文件 if ($path != 'stream') { if (!is_dir(dirname($path))) { ___throwException('指定的路径不可用 =>' . $path); } $type = pathinfo($path, PATHINFO_EXTENSION); $toFile = true; } //png的alpha校正 $this->_pngalpha($type); if ($type == "jpg") { $type = "jpeg"; } $func = "image" . $type; if (!function_exists($func)) { $type = 'gif'; $func = 'imagegif'; } if ($toFile) { call_user_func($func, $this->img, $path); } else { if (!headers_sent()) { header("Content-type:image/" . $type); } call_user_func($func, $this->img); } return $this; }
/** * builds the Authorization: header */ function to_header() { $out = 'Authorization: OAuth realm=""'; $total = array(); foreach ($this->parameters as $k => $v) { if (substr($k, 0, 5) != "oauth") { continue; } if (is_array($v)) { ___throwException('Arrays not supported in headers'); } $out .= ',' . ns_OAuthUtil::urlencode_rfc3986($k) . '="' . ns_OAuthUtil::urlencode_rfc3986($v) . '"'; } return $out; }