public function destroy() { self::$started = false; session_unset(); session_destroy(); }
public static function upload($url, $path) { $s = parse_url($url, PHP_URL_SCHEME); $w = stream_get_wrappers(); if (in_array($s, $w) && ini_get('allow_url_fopen')) { if ($fp = fopen($url, 'rb')) { if (self::$fp = fopen($path, 'wb')) { self::$size = stream_copy_to_stream($fp, self::$fp); fclose(self::$fp); } else { fclose($fp); throw new waException('Error while open target file'); } fclose($fp); } else { throw new waException('Error while open source file'); } } elseif ($ch = self::curlInit($url)) { if (self::$fp = fopen($path, 'wb')) { self::$size = 0; waSessionStorage::close(); curl_exec($ch); fclose(self::$fp); if ($errno = curl_errno($ch)) { $message = "Curl error: {$errno}# " . curl_error($ch) . " at [{$path}]"; curl_close($ch); throw new waException($message); } $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($response_code != 200) { curl_close($ch); throw new waException("Invalid server response with code {$response_code} while request {$url}"); } } curl_close($ch); } else { throw new waException('There no available wrappers'); } return self::$size; }