/** * @param http $http */ function _auth($http) { $cooks = core::lib('sape_cacher')->get('cookie', $this->_acc->id); if ($cooks == sape_cacher::NOTFOUND) { $cooks = false; } if ($cooks) { $http->RestoreCookies($cooks, 1); $http->prolongate_cookie(14); $this->_authed = true; } else { if (!$this->_in_login) { $this->login(); } } }
function step4() { $clang = $this->getController()->lang; $buildnumber = Yii::app()->getConfig("buildnumber"); $tempdir = Yii::app()->getConfig("tempdir"); $updatekey = Yii::app()->getConfig("updatekey"); $updatebuild = Yii::app()->getConfig("updatebuild"); $rootdir = Yii::app()->getConfig("rootdir"); $publicdir = Yii::app()->getConfig("publicdir"); $tempdir = Yii::app()->getConfig("tempdir"); $aDatabasetype = Yii::app()->db->getDriverName(); // Request the list with changed files from the server $updatekey = getGlobalSetting('updatekey'); $aData = array('clang' => $clang); if (!isset(Yii::app()->session['updateinfo'])) { if ($updateinfo['error'] == 1) { setGlobalSetting('updatekey', ''); } } else { $updateinfo = Yii::app()->session['updateinfo']; } // this is the last step - Download the zip file, unpack it and replace files accordingly // Create DB and file backups now $downloaderror = false; $http = new http(); // Allow redirects $http->follow_redirect = 1; /* Connection timeout */ $http->timeout = 0; /* Data transfer timeout */ $http->data_timeout = 0; $http->user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; $http->GetRequestArguments("http://update.limesurvey.org/updates/download/{$updateinfo['downloadid']}", $arguments); $http->RestoreCookies(Yii::app()->session['updatesession']); $error = $http->Open($arguments); $error = $http->SendRequest($arguments); $http->ReadReplyHeaders($headers); if ($headers['content-type'] == 'text/html') { @unlink($tempdir . '/update.zip'); } else { if ($error == '') { $body = ''; $pFile = fopen($tempdir . '/update.zip', 'w'); for (;;) { $error = $http->ReadReplyBody($body, 100000); if ($error != "" || strlen($body) == 0) { break; } fwrite($pFile, $body); } fclose($pFile); } else { print $error; } } // Now remove all files that are to be deleted according to update process foreach ($updateinfo['files'] as $afile) { if ($afile['type'] == 'D' && file_exists($rootdir . $afile['file'])) { if (is_file($rootdir . $afile['file'])) { unlink($rootdir . $afile['file']); } else { rmdirr($rootdir . $afile['file']); } echo sprintf($clang->gT('File deleted: %s'), $afile['file']) . '<br />'; } } //Now unzip the new files over the existing ones. $new_files = false; if (file_exists($tempdir . '/update.zip')) { Yii::app()->loadLibrary("admin/pclzip/pclzip"); $archive = new PclZip($tempdir . '/update.zip'); if ($archive->extract(PCLZIP_OPT_PATH, $rootdir . '/', PCLZIP_OPT_REPLACE_NEWER) == 0) { die("Error : " . $archive->errorInfo(true)); } else { $new_files = true; unlink($tempdir . '/update.zip'); } } else { $downloaderror = true; } $aData['new_files'] = $new_files; $aData['downloaderror'] = $downloaderror; // PclTraceDisplay(); // Now we have to update version.php if (!$downloaderror) { @ini_set('auto_detect_line_endings', true); $versionlines = file($rootdir . '/application/config/version.php'); $handle = fopen($rootdir . '/application/config/version.php', "w"); foreach ($versionlines as $line) { if (strpos($line, 'buildnumber') !== false) { $line = '$config[\'buildnumber\'] = ' . Yii::app()->session['updateinfo']['toversion'] . ';' . "\r\n"; } fwrite($handle, $line); } fclose($handle); } setGlobalSetting('updatelastcheck', '1980-01-01 00:00'); setGlobalSetting('updateavailable', '0'); setGlobalSetting('updatebuild', ''); setGlobalSetting('updateversion', ''); $this->_renderWrappedTemplate('update', 'step4', $aData); }