Example #1
0
 function putContents($file, $contents, $mode = false)
 {
     $tempfile = getTempName($file);
     $temp = fopen($tempfile, 'w+');
     if (!$temp) {
         return false;
     }
     fwrite($temp, $contents);
     fseek($temp, 0);
     //Skip back to the start of the file being written to
     $type = isBinary($contents) ? FTP_BINARY : FTP_ASCII;
     $ret = @ftp_fput($this->link, $file, $temp, $type);
     fclose($temp);
     unlink($tempfile);
     $this->chmod($file, $mode);
     return $ret;
 }
Example #2
0
function downloadAndUnzipAddons(&$addons)
{
    foreach ($addons as $key => $addon) {
        if (!empty($addon['downloadLink'])) {
            $downloadLink = $addon['downloadLink'];
            //$fileMD5 = $updateDetails['fileMD5'];
            $zip = getTempName('addon_' . $addon['slug'] . '.zip');
            appUpdateMsg('Downloading ' . $addon['slug'] . ' package...');
            $isDone = downloadURL($downloadLink, $zip);
            if (!$isDone) {
                //download failed
                appUpdateMsg($addon['slug'] . ' package download failed.', true);
                continue;
            }
            if (!initFileSystem()) {
                appUpdateMsg('Unable to initiate file system.', true);
                return false;
            }
            $unPackResult = unPackToWorkingDir($zip);
            if (!empty($unPackResult) && is_array($unPackResult)) {
                $source = $unPackResult['source'];
                $remoteSource = $unPackResult['remoteSource'];
            } else {
                return false;
            }
            $destination = APP_ROOT;
            if (!copyToRequiredDir($source, $remoteSource, $destination)) {
                return false;
            }
            appUpdateMsg('Unzipped ' . $addon['slug'] . ' package.');
            $addons[$key]['process']['unzipDone'] = true;
            @unlink($zip);
        }
    }
    //return $addons;
}