コード例 #1
0
 function install($url)
 {
     $dest = $this->location . '/' . basename($url);
     if (!file_exists($dest) && ($err = files::copyRemote($url, $dest) !== true)) {
         return $err;
     } else {
         if (($content = @implode('', @gzfile($dest))) === false) {
             return __('Cannot open file');
         } else {
             if (($list = unserialize($content)) === false) {
                 return __('Plugin not valid');
             } else {
                 if (is_dir($this->location . '/' . $list['name'])) {
                     /*if (files::deltree($this->location.'/'.$list['name']) === false)
                     		{
                     			return 'Impossible de supprimer le plugin existant';
                     		}*/
                     unlink($dest);
                     return __('This plugin still exists. Delete it before.');
                 }
                 foreach ($list['dirs'] as $d) {
                     mkdir($this->location . '/' . $d, fileperms($this->location));
                     chmod($this->location . '/' . $d, fileperms($this->location));
                 }
                 foreach ($list['files'] as $f => $v) {
                     $v = base64_decode($v);
                     $fp = fopen($this->location . '/' . $f, 'w');
                     fwrite($fp, $v, strlen($v));
                     fclose($fp);
                     chmod($this->location . '/' . $f, fileperms($this->location) & ~0111);
                 }
                 unlink($dest);
             }
         }
     }
     return true;
 }