You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
3.0 KiB
100 lines
3.0 KiB
<?php
|
|
|
|
class PremiumizeMe {
|
|
/**
|
|
* Converti le lien d'un hoster en un lien premiumizeme + informations
|
|
*
|
|
* @param string $url Url d'un hoster
|
|
*
|
|
* @return array[string]mixed Informations sur le lien premiumizeme
|
|
*/
|
|
static function getLink($url) {
|
|
$fields = [
|
|
'method' => 'directdownloadlink',
|
|
'params[login]' => getenv('PREM_LOGIN'),
|
|
'params[pass]' => getenv('PREM_PASS'),
|
|
'params[link]' => $url
|
|
];
|
|
$httpFields = http_build_query($fields);
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, 'http://api.premiumize.me/pm-api/v1.php?'.$httpFields);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
$curlResult = curl_exec($ch);
|
|
curl_close($ch);
|
|
$data = json_decode($curlResult);
|
|
// TODO : exception et non exit bourrin
|
|
if (400 === $data->status) {
|
|
echo 'Erreur : Je ne supporte pas de fournisseur, merci de revenir a la page des téléchargement et d\'en choisir un autre.<br><br>Erreur exacte :<br>'.$data->statusmessage;
|
|
exit();
|
|
}
|
|
if (null === $data->result) {
|
|
if (503 === $data->status) {
|
|
echo 'Erreur : Il semble que le lien ne fonctionne plus.<br>Vous pouvez verifier vous-même ici : <a href="'.$url.'">'.$url.'</a><br><br>';
|
|
echo 'Erreur exacte :<br>'.$data->statusmessage;
|
|
} else {
|
|
echo 'Erreur : <br>'.$data->statusmessage;
|
|
}
|
|
exit();
|
|
} else {
|
|
$retour = get_object_vars($data->result);
|
|
return $retour;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Retourne les informations sur l'etat actuel du compte.
|
|
*
|
|
* @return array[string]mixed
|
|
*/
|
|
static function getStatus() {
|
|
$fields = [
|
|
'method' => 'accountstatus',
|
|
'params[login]' => getenv('PREM_LOGIN'),
|
|
'params[pass]' => getenv('PREM_PASS')
|
|
];
|
|
$httpFields = http_build_query($fields);
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, 'http://api.premiumize.me/pm-api/v1.php?'.$httpFields);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
$curlResult = curl_exec($ch);
|
|
curl_close($ch);
|
|
$data = json_decode($curlResult);
|
|
$retour = get_object_vars($data->result);
|
|
$tmpDT = new DateTime();
|
|
$tmpDT->setTimestamp($retour['expires']);
|
|
$retour['expires'] = $tmpDT;
|
|
return $retour;
|
|
}
|
|
|
|
/**
|
|
* Retourne la liste des hosters ainsi que les regexps lie.
|
|
*
|
|
* @return array[mixed]mixed
|
|
*/
|
|
static function getHosters() {
|
|
$fields = [
|
|
'method' => 'hosterlist',
|
|
'params[login]' => getenv('PREM_LOGIN'),
|
|
'params[pass]' => getenv('PREM_PASS')
|
|
];
|
|
$httpFields = http_build_query($fields);
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, 'http://api.premiumize.me/pm-api/v1.php?'.$httpFields);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
$curlResult = curl_exec($ch);
|
|
curl_close($ch);
|
|
$data = json_decode($curlResult);
|
|
$retour = get_object_vars($data->result);
|
|
|
|
foreach($retour['hosterlist'] as $hoster) {
|
|
$retour['hostershort'][] = strstr($hoster, '.', true);
|
|
}
|
|
return $retour;
|
|
}
|
|
}
|