Created
July 24, 2014 08:19
-
-
Save ybart/f5ffb52f91c531bf2417 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 | |
/* | |
* Implantation "made-in-OVH" de disk_free_space() | |
* ATTENTION : pensez à remplacer les arguments de | |
* $soap->login() avec votre propre identifiant et mot de passe. | |
* Vous devez aussi indiquer votre domaine dans $soap->hostingSummary(). | |
*/ | |
function ovh_free_space($path){ | |
$cache_file = "data/quotas.cache.txt"; | |
if (file_exists($cache_file) && (filemtime($cache_file) > (time() - 60 * 60 ))) { | |
// Cache file is less than five minutes old. | |
// Don't bother refreshing, just use the file as-is. | |
$result = json_decode(file_get_contents($cache_file)); | |
} else { | |
// Our cache is out-of-date, so load the data from our remote server, | |
// and also save it over our cache for next time. | |
try{ | |
$soap = new SoapClient("https://www.ovh.com/soapi/soapi-re-1.63.wsdl"); | |
$session = $soap->login("xxxxxxx-ovh", "xxxxxxxxxxx","fr", false); | |
$result = $soap->hostingSummary($session, "onepark.fr"); | |
$soap->logout($session); | |
file_put_contents($cache_file, json_encode($result), LOCK_EX); | |
} catch(SoapFault $fault){ | |
echo $fault; | |
return 0; | |
} | |
} | |
$quota = ((($result->maxWebspace / 1000) * 1024 * 1024 * 1024) - $result->webspace); | |
return $quota; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment