Created
June 6, 2010 02:55
-
-
Save nunocodex/427239 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Rapidshare_Com | |
{ | |
/** | |
* @var string | |
*/ | |
public static $cookie = 'rs_cookie_data.php'; | |
/** | |
* Factory Pattern. | |
* | |
* @author Namaless | |
*/ | |
public static function factory() | |
{ | |
// Controllo se è attivo cURL. | |
if ( ! function_exists('curl_init') ) | |
{ | |
die('cURL not found.'); | |
} | |
} | |
/** | |
* Login | |
* | |
* @return array | |
* @author Namaless | |
**/ | |
public static function login($username, $password) | |
{ | |
$post_data = array | |
( | |
'login' => $username, | |
'password' => $password | |
); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, 'https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi'); | |
curl_setopt($ch, CURLOPT_POST, TRUE); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($ch, CURLOPT_COOKIEJAR, self::$cookie); | |
$buffer = curl_exec($ch); | |
$error = curl_errno($ch); | |
$info = curl_getinfo($ch); | |
curl_close($ch); | |
// controllo se il login è stato effettuato correttamente. | |
return strpos($buffer, $username); | |
} | |
/** | |
* Logout | |
* | |
* @return array | |
* @author Namaless | |
**/ | |
public static function logout() | |
{ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, 'https://ssl.rapidshare.com/cgi-bin/premium.cgi?logout=1'); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($ch, CURLOPT_COOKIEJAR, self::$cookie); | |
$buffer = curl_exec($ch); | |
$error = curl_errno($ch); | |
$info = curl_getinfo($ch); | |
curl_close($ch); | |
@unlink(self::$cookie); | |
// controllo se il login è stato effettuato correttamente. | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment