Ejemplo n.º 1
0
 function update()
 {
     $rep = $this->getResponse('json');
     $this->msg = 'Votre Version de Business Open Suite est déjà à jours';
     $project = simplexml_load_file('project.xml');
     $local_version = $project->info->version->__toString();
     $data = array('module' => 'bos', 'action' => 'updater:info');
     $bos_info = jHttp::quickPost(UPDATE_URL . 'index.php', $data);
     $bos_info = json_decode($bos_info);
     if ($bos_info->version != $local_version) {
         $tempname = uniqid() . '.zip';
         $bos = jHttp::quickGet(UPDATE_URL . 'bos.zip');
         file_put_contents('var/uploads/' . $tempname, $bos);
         $this->unpackUpdate('var/uploads/' . $tempname);
         unlink('var/uploads/' . $tempname);
         $this->msg = 'votre version de Business Open Suite a été mise à jours';
         $this->success = true;
     }
     $rep->data = array('success' => $this->success, 'msg' => $this->msg);
     return $rep;
 }
 /**
  * read an flux with an url parameter
  * @param string $url
  */
 public function __construct($url)
 {
     try {
         $stream = jHttp::quickGet($url);
     } catch (Exception $e) {
         throw new jException('jelix~errors.xml.remote.feed.error');
     }
     if (!$stream) {
         throw new jException('jelix~errors.xml.remote.feed.error');
     }
     libxml_use_internal_errors(true);
     $xml = simplexml_load_string($stream);
     if ($xml === false) {
         $errors = '';
         foreach (libxml_get_errors() as $error) {
             $errors .= $error->message . "; ";
         }
         throw new jException('jelix~errors.xml.loading.document.error', array($errors));
     }
     libxml_use_internal_errors();
     libxml_clear_errors();
     $this->xml = $xml;
 }