Advertisement
jbriguet

local_ovh.php

Dec 16th, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <?php
  2. /*
  3. * Implantation "made-in-OVH" de disk_free_space()
  4. * ATTENTION : pensez à remplacer les arguments de
  5. * $soap->login() avec votre propre identifiant et mot de passe.
  6. * Vous devez aussi indiquer votre domaine dans $soap->hostingSummary().
  7. */
  8.  
  9. function ovh_free_space($path) {
  10.     try {
  11.         $refreshDelay = 12;
  12.         if ( ( \OC_Appconfig::getValue('core', 'lastsoapicall') + $refreshDelay ) > time() ) {
  13.             $cachedValue = \OC_Appconfig::getValue('core', 'lastsoapivalue');
  14.             if ( $cachedValue ) {
  15.                 return $cachedValue;
  16.             }
  17.         }
  18.  
  19.         $soap = new SoapClient("https://www.ovh.com/soapi/soapi-re-1.35.wsdl");
  20.         $session = $soap->login("nic-ovh", "motDePasse", "fr", false);
  21.         $result = $soap->hostingSummary($session, "domaine.com");
  22.         $soap->logout($session);
  23.  
  24.         $freeSpace = ((($result->maxWebspace / 1000) * 1024 * 1024 * 1024) - $result->webspace);
  25.  
  26.         \OC_Appconfig::setValue('core', 'lastsoapivalue', $freeSpace);
  27.         \OC_Appconfig::setValue('core', 'lastsoapicall', time());
  28.  
  29.         return $freeSpace;
  30.     } catch(SoapFault $fault) {
  31.         OC_Log::write("OVH", "Unable to retrieve info from OVH : " . $fault, OC_Log::ERROR);
  32.         return 0;
  33.     }
  34. }
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement