Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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) {
- try {
- $refreshDelay = 12;
- if ( ( \OC_Appconfig::getValue('core', 'lastsoapicall') + $refreshDelay ) > time() ) {
- $cachedValue = \OC_Appconfig::getValue('core', 'lastsoapivalue');
- if ( $cachedValue ) {
- return $cachedValue;
- }
- }
- $soap = new SoapClient("https://www.ovh.com/soapi/soapi-re-1.35.wsdl");
- $session = $soap->login("nic-ovh", "motDePasse", "fr", false);
- $result = $soap->hostingSummary($session, "domaine.com");
- $soap->logout($session);
- $freeSpace = ((($result->maxWebspace / 1000) * 1024 * 1024 * 1024) - $result->webspace);
- \OC_Appconfig::setValue('core', 'lastsoapivalue', $freeSpace);
- \OC_Appconfig::setValue('core', 'lastsoapicall', time());
- return $freeSpace;
- } catch(SoapFault $fault) {
- OC_Log::write("OVH", "Unable to retrieve info from OVH : " . $fault, OC_Log::ERROR);
- return 0;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement