@@ -22,6 +22,10 @@ |
||
| 22 | 22 | * @author Chirag Shah <[email protected]> |
| 23 | 23 | */ |
| 24 | 24 | class Google_Utils { |
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @param string $data |
|
| 28 | + */ |
|
| 25 | 29 | public static function urlSafeB64Encode($data) { |
| 26 | 30 | $b64 = base64_encode($data); |
| 27 | 31 | $b64 = str_replace(array('+', '/', '\r', '\n', '='), |
@@ -135,6 +135,9 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | + /** |
|
| 139 | + * @param integer $name |
|
| 140 | + */ |
|
| 138 | 141 | Function CookieEncode($value, $name) |
| 139 | 142 | { |
| 140 | 143 | return($name ? str_replace("=", "%25", $value) : str_replace(";", "%3B", $value)); |
@@ -146,6 +149,10 @@ discard block |
||
| 146 | 149 | return($this->error=$error); |
| 147 | 150 | } |
| 148 | 151 | |
| 152 | + /** |
|
| 153 | + * @param string $error |
|
| 154 | + * @param integer $error_code |
|
| 155 | + */ |
|
| 149 | 156 | Function SetPHPError($error, &$php_error_message, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR) |
| 150 | 157 | { |
| 151 | 158 | if(IsSet($php_error_message) |
@@ -154,6 +161,9 @@ discard block |
||
| 154 | 161 | return($this->SetError($error, $error_code)); |
| 155 | 162 | } |
| 156 | 163 | |
| 164 | + /** |
|
| 165 | + * @param string $error |
|
| 166 | + */ |
|
| 157 | 167 | Function SetDataAccessError($error,$check_connection=0) |
| 158 | 168 | { |
| 159 | 169 | $this->error=$error; |
@@ -264,6 +274,9 @@ discard block |
||
| 264 | 274 | return(1); |
| 265 | 275 | } |
| 266 | 276 | |
| 277 | + /** |
|
| 278 | + * @return string |
|
| 279 | + */ |
|
| 267 | 280 | Function ReadChunkSize() |
| 268 | 281 | { |
| 269 | 282 | if($this->remaining_chunk==0) |
@@ -289,6 +302,9 @@ discard block |
||
| 289 | 302 | return(""); |
| 290 | 303 | } |
| 291 | 304 | |
| 305 | + /** |
|
| 306 | + * @return string |
|
| 307 | + */ |
|
| 292 | 308 | Function ReadBytes($length) |
| 293 | 309 | { |
| 294 | 310 | if($this->use_curl) |
@@ -367,6 +383,9 @@ discard block |
||
| 367 | 383 | return(feof($this->connection)); |
| 368 | 384 | } |
| 369 | 385 | |
| 386 | + /** |
|
| 387 | + * @param string $server_type |
|
| 388 | + */ |
|
| 370 | 389 | Function Resolve($domain, &$ip, $server_type) |
| 371 | 390 | { |
| 372 | 391 | if(preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/',$domain)) |
@@ -385,6 +404,9 @@ discard block |
||
| 385 | 404 | return(''); |
| 386 | 405 | } |
| 387 | 406 | |
| 407 | + /** |
|
| 408 | + * @param boolean $ssl |
|
| 409 | + */ |
|
| 388 | 410 | Function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP') |
| 389 | 411 | { |
| 390 | 412 | $domain=$host_name; |
@@ -569,6 +591,9 @@ discard block |
||
| 569 | 591 | |
| 570 | 592 | /* Public methods */ |
| 571 | 593 | |
| 594 | + /** |
|
| 595 | + * @return string |
|
| 596 | + */ |
|
| 572 | 597 | Function GetRequestArguments($url, &$arguments) |
| 573 | 598 | { |
| 574 | 599 | $this->error = ''; |
@@ -767,6 +792,9 @@ discard block |
||
| 767 | 792 | return($this->Disconnect()); |
| 768 | 793 | } |
| 769 | 794 | |
| 795 | + /** |
|
| 796 | + * @param integer $secure |
|
| 797 | + */ |
|
| 770 | 798 | Function PickCookies(&$cookies,$secure) |
| 771 | 799 | { |
| 772 | 800 | if(IsSet($this->cookies[$secure])) |
@@ -1439,6 +1467,11 @@ discard block |
||
| 1439 | 1467 | return(""); |
| 1440 | 1468 | } |
| 1441 | 1469 | |
| 1470 | + /** |
|
| 1471 | + * @param string $name |
|
| 1472 | + * |
|
| 1473 | + * @return string |
|
| 1474 | + */ |
|
| 1442 | 1475 | Function SetCookie($name, $value, $expires="" , $path="/" , $domain="" , $secure=0, $verbatim=0) |
| 1443 | 1476 | { |
| 1444 | 1477 | if(strlen($this->error)) |
@@ -1677,6 +1710,9 @@ discard block |
||
| 1677 | 1710 | return(""); |
| 1678 | 1711 | } |
| 1679 | 1712 | |
| 1713 | + /** |
|
| 1714 | + * @param integer $proxy |
|
| 1715 | + */ |
|
| 1680 | 1716 | Function Authenticate(&$headers, $proxy, &$proxy_authorization, &$user, &$password, &$realm, &$workstation) |
| 1681 | 1717 | { |
| 1682 | 1718 | if($proxy) |
@@ -1937,6 +1973,9 @@ discard block |
||
| 1937 | 1973 | return(""); |
| 1938 | 1974 | } |
| 1939 | 1975 | |
| 1976 | + /** |
|
| 1977 | + * @param integer $length |
|
| 1978 | + */ |
|
| 1940 | 1979 | Function ReadReplyBody(&$body,$length) |
| 1941 | 1980 | { |
| 1942 | 1981 | $body=""; |
@@ -1979,6 +2018,9 @@ discard block |
||
| 1979 | 2018 | return(""); |
| 1980 | 2019 | } |
| 1981 | 2020 | |
| 2021 | + /** |
|
| 2022 | + * @return string |
|
| 2023 | + */ |
|
| 1982 | 2024 | Function ReadWholeReplyBody(&$body) |
| 1983 | 2025 | { |
| 1984 | 2026 | $body = ''; |
@@ -596,6 +596,9 @@ discard block |
||
| 596 | 596 | return(false); |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | + /** |
|
| 600 | + * @param string $error |
|
| 601 | + */ |
|
| 599 | 602 | Function SetPHPError($error, &$php_error_message) |
| 600 | 603 | { |
| 601 | 604 | if(IsSet($php_error_message) |
@@ -604,6 +607,9 @@ discard block |
||
| 604 | 607 | return($this->SetError($error)); |
| 605 | 608 | } |
| 606 | 609 | |
| 610 | + /** |
|
| 611 | + * @param string $message |
|
| 612 | + */ |
|
| 607 | 613 | Function OutputDebug($message) |
| 608 | 614 | { |
| 609 | 615 | if($this->debug) |
@@ -655,6 +661,9 @@ discard block |
||
| 655 | 661 | return(true); |
| 656 | 662 | } |
| 657 | 663 | |
| 664 | + /** |
|
| 665 | + * @param string $error |
|
| 666 | + */ |
|
| 658 | 667 | Function GetRequestError(&$error) |
| 659 | 668 | { |
| 660 | 669 | $error = (IsSet($_GET['error']) ? $_GET['error'] : null); |
@@ -849,6 +858,11 @@ discard block |
||
| 849 | 858 | return $array; |
| 850 | 859 | } |
| 851 | 860 | |
| 861 | + /** |
|
| 862 | + * @param string $function |
|
| 863 | + * @param string $data |
|
| 864 | + * @param string $key |
|
| 865 | + */ |
|
| 852 | 866 | Function HMAC($function, $data, $key) |
| 853 | 867 | { |
| 854 | 868 | switch($function) |
@@ -1146,6 +1160,10 @@ discard block |
||
| 1146 | 1160 | <do> |
| 1147 | 1161 | {/metadocument} |
| 1148 | 1162 | */ |
| 1163 | + /** |
|
| 1164 | + * @param string $url |
|
| 1165 | + * @param string $method |
|
| 1166 | + */ |
|
| 1149 | 1167 | Function CallAPI($url, $method, $parameters, $options, &$response) |
| 1150 | 1168 | { |
| 1151 | 1169 | if(!IsSet($options['Resource'])) |
@@ -1735,6 +1753,9 @@ discard block |
||
| 1735 | 1753 | <do> |
| 1736 | 1754 | {/metadocument} |
| 1737 | 1755 | */ |
| 1756 | + /** |
|
| 1757 | + * @param boolean $success |
|
| 1758 | + */ |
|
| 1738 | 1759 | Function Finalize($success) |
| 1739 | 1760 | { |
| 1740 | 1761 | return($success); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * Generates a random OAuth nonce. |
| 108 | 108 | * If 'force_nonce' is true a nonce is not generated and the value in the configuration will be retained. |
| 109 | 109 | * |
| 110 | - * @param string $length how many characters the nonce should be before MD5 hashing. default 12 |
|
| 110 | + * @param integer $length how many characters the nonce should be before MD5 hashing. default 12 |
|
| 111 | 111 | * @param string $include_time whether to include time at the beginning of the nonce. default true |
| 112 | 112 | * @return void |
| 113 | 113 | */ |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | * |
| 503 | 503 | * @param object $ch curl handle |
| 504 | 504 | * @param string $header the response headers |
| 505 | - * @return the string length of the header |
|
| 505 | + * @return integer string length of the header |
|
| 506 | 506 | */ |
| 507 | 507 | private function curlHeader($ch, $header) { |
| 508 | 508 | $this->response['raw'] .= $header; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * Asks the user for input and returns the line they enter |
| 213 | 213 | * |
| 214 | 214 | * @param string $prompt the text to display to the user |
| 215 | - * @return the text entered by the user |
|
| 215 | + * @return string text entered by the user |
|
| 216 | 216 | */ |
| 217 | 217 | public static function read_input($prompt) { |
| 218 | 218 | echo $prompt; |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * |
| 268 | 268 | * @param string $haystack the string to check inside of |
| 269 | 269 | * @param string $needle the string to check $haystack ends with |
| 270 | - * @return true if $haystack ends with $needle, false otherwise |
|
| 270 | + * @return boolean if $haystack ends with $needle, false otherwise |
|
| 271 | 271 | */ |
| 272 | 272 | public static function endswith($haystack, $needle) { |
| 273 | 273 | $haylen = strlen($haystack); |
@@ -341,6 +341,10 @@ |
||
| 341 | 341 | return $file; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | + /** |
|
| 345 | + * @param string $class |
|
| 346 | + * @param string $ext |
|
| 347 | + */ |
|
| 344 | 348 | private function findFileWithExtension($class, $ext) |
| 345 | 349 | { |
| 346 | 350 | // PSR-4 lookup |
@@ -115,6 +115,9 @@ discard block |
||
| 115 | 115 | return $this->resolveDataPointer($pointer); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | + /** |
|
| 119 | + * @param string $ipAddress |
|
| 120 | + */ |
|
| 118 | 121 | private function findAddressInTree($ipAddress) |
| 119 | 122 | { |
| 120 | 123 | // XXX - could simplify. Done as a byte array to ease porting |
@@ -146,6 +149,9 @@ discard block |
||
| 146 | 149 | } |
| 147 | 150 | |
| 148 | 151 | |
| 152 | + /** |
|
| 153 | + * @param integer $length |
|
| 154 | + */ |
|
| 149 | 155 | private function startNode($length) |
| 150 | 156 | { |
| 151 | 157 | // Check if we are looking up an IPv4 address in an IPv6 tree. If this |
@@ -178,6 +184,9 @@ discard block |
||
| 178 | 184 | return $node; |
| 179 | 185 | } |
| 180 | 186 | |
| 187 | + /** |
|
| 188 | + * @param integer $index |
|
| 189 | + */ |
|
| 181 | 190 | private function readNode($nodeNumber, $index) |
| 182 | 191 | { |
| 183 | 192 | $baseOffset = $nodeNumber * $this->metadata->nodeByteSize; |
@@ -230,6 +239,10 @@ discard block |
||
| 230 | 239 | * are much faster algorithms (e.g., Boyer-Moore) for this if speed is ever |
| 231 | 240 | * an issue, but I suspect it won't be. |
| 232 | 241 | */ |
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * @param string $filename |
|
| 245 | + */ |
|
| 233 | 246 | private function findMetadataStart($filename) |
| 234 | 247 | { |
| 235 | 248 | $handle = $this->fileHandle; |
@@ -276,6 +276,11 @@ discard block |
||
| 276 | 276 | $reader->metadata(); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | + /** |
|
| 280 | + * @param Reader $reader |
|
| 281 | + * @param integer $ipVersion |
|
| 282 | + * @param integer $recordSize |
|
| 283 | + */ |
|
| 279 | 284 | private function checkMetadata($reader, $ipVersion, $recordSize) |
| 280 | 285 | { |
| 281 | 286 | $metadata = $reader->metadata(); |
@@ -303,6 +308,9 @@ discard block |
||
| 303 | 308 | $this->assertGreaterThan(200, $metadata->searchTreeSize); |
| 304 | 309 | } |
| 305 | 310 | |
| 311 | + /** |
|
| 312 | + * @param string $fileName |
|
| 313 | + */ |
|
| 306 | 314 | private function checkIpV4(Reader $reader, $fileName) |
| 307 | 315 | { |
| 308 | 316 | for ($i = 0; $i <= 5; $i++) { |
@@ -341,6 +349,10 @@ discard block |
||
| 341 | 349 | } |
| 342 | 350 | |
| 343 | 351 | // XXX - logic could be combined with above |
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * @param string $fileName |
|
| 355 | + */ |
|
| 344 | 356 | private function checkIpV6(Reader $reader, $fileName) |
| 345 | 357 | { |
| 346 | 358 | $subnets = array('::1:ffff:ffff', '::2:0:0', |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * @param $body |
|
| 28 | + * @param string $body |
|
| 29 | 29 | * @return array |
| 30 | 30 | */ |
| 31 | 31 | public function post($body) |
@@ -82,6 +82,9 @@ discard block |
||
| 82 | 82 | return $curl; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | + /** |
|
| 86 | + * @param resource $curl |
|
| 87 | + */ |
|
| 85 | 88 | private function execute($curl) |
| 86 | 89 | { |
| 87 | 90 | $body = curl_exec($curl); |