$blocksize) $key=pack('H*', $hashfunc($key)); $key=str_pad($key,$blocksize,chr(0x00)); $ipad=str_repeat(chr(0x36),$blocksize); $opad=str_repeat(chr(0x5c),$blocksize); $hmac = pack( 'H*',$hashfunc( ($key^$opad).pack( 'H*',$hashfunc( ($key^$ipad).$data ) ) ) ); return $hmac; } function oauth_hmacsha1($key, $data) { return base64_encode(hmacsha1($key, $data)); } function upload_GS($sourcefile, $targetfile, $secret_key, $authkey) { $fp = fopen ($sourcefile, "r"); $ch = curl_init(); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_URL, "http://storage.directlinkhosting.cz.cc$targetfile"); curl_setopt($ch, CURLOPT_PUT, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_INFILE, $fp); curl_setopt($ch, CURLOPT_INFILESIZE, filesize($sourcefile)); $signature = ''; $msgsigned = ''; $date = gmdate(DATE_RFC1123); $msgsigned = "PUT\n\n\n$date\nx-goog-acl:public-read\n/storage.directlinkhosting.cz.cc$targetfile"; $signature = oauth_hmacsha1($secret_key,$msgsigned); $headers = array( "PUT $targetfile HTTP/1.1", "Host: storage.directlinkhosting.cz.cc", "Date: ".$date, "Content-Length: " . filesize($localfile), "x-goog-acl: public-read", "Authorization: GOOG1 $authkey:".$signature ); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $http_result = curl_exec($ch); $error = curl_error($ch); $http_code = curl_getinfo($ch ,CURLINFO_HTTP_CODE); curl_close($ch); fclose($fp); if ($http_code == "200") { return true; } else { return false; } } ?>