/** * 输出临时图片文件(只输出未关联到任何回复的附件,主要用于编辑器新上传的图片显示) */ public function imgAction() { $this->_helper->viewRenderer->setNeverRender(); $fid = $this->_request->getQuery('aid'); /* @var $file Dao_Td_Attachment_Record_File */ $file = $this->getDao('Dao_Td_Attachment_File')->getFile(array('fileid' => $fid)); if (null === $file || $file->tuduId || $file->uniqueId != $this->_user['uniqueid']) { return; } $sid = Zend_Session::getId(); $auth = md5($sid . $fid . $this->_session->auth['logintime']); $url = $this->_options['sites']['file'] . $this->_options['upload']['cgi']['download'] . "?sid={$sid}&fid={$fid}&auth={$auth}&email={$this->_session->auth['address']}&action=view"; $content = Oray_Function::httpRequest($url); $this->_response->setHeader('Content-Length', strlen($content)); $this->_response->setHeader('Content-Type', $file->type); $this->_response->sendHeaders(); echo $content; // 取消输出 $this->getFrontController()->returnResponse(true); }
/** * 在线升级 */ public function indexAction() { $operation = $this->_request->getParam('operation'); $this->view->operation = $operation; $this->view->tuduversion = TUDU_VERSION; if (empty($operation)) { return $this->render('index'); } if ($operation == 'check') { // 检查是否有新版本 $check = Oray_Function::httpRequest($this->_upgradeUrl); $upgrade = json_decode($check, true); if (empty($upgrade['lastest'])) { $this->view->unupgrade = true; return $this->render('index'); } $lastest = $upgrade['lastest']; if (TUDU_VERSION == $lastest['version'] && TUDU_RELEASE == $lastest['release']) { $this->view->islastest = true; return $this->render('index'); } // WWW_ROOT目录是否可写 if (!$this->dirWriteable(WWW_ROOT)) { $this->view->diswriteable = true; $this->view->rootpath = WWW_ROOT; return $this->render('index'); } $this->view->checkfinsh = true; $this->view->lastest = $lastest; } elseif ($operation == 'upgrade') { $downloadUrl = $this->_request->getParam('fileurl'); $lastestMd5 = $this->_request->getParam('filemd5'); $upgradeFile = $this->downloadFile($downloadUrl, 120); if ($upgradeFile == 'empty_url' || $upgradeFile == 'timeout' || $upgradeFile == 'mkdir_error') { return $this->showMsg($upgradeFile); } // 验证MD5 if (md5_file($upgradeFile) != $lastestMd5) { return $this->showMsg('md5_error'); } // 解压缩 $ret = $this->unZip($upgradeFile); if (!$ret['success']) { return $this->showMsg('unzip_error'); } // 判断目录文件是否有相应的文件 $dirs = $this->getDirs($this->_updatePath, true); $errorPerm = array(); foreach ($dirs as $item) { if ($item['path'] == $upgradeFile) { continue; } $destDir = WWW_ROOT . DIRECTORY_SEPARATOR . $item['entry']; if (!$this->checkPerm($destDir, $item['type'])) { $errorPerm[] = $destDir; } } if (!empty($errorPerm)) { return $this->showMsg('error_perm', $errorPerm); } // 复制替换目录文件 $dirs = $this->getDirs($this->_updatePath); foreach ($dirs as $item) { $this->copyDir($item['path'], WWW_ROOT . DIRECTORY_SEPARATOR . $item['entry']); } // 完成,删除更新的目录;清除smarty模板编译缓存 $this->rmdirs($this->_updatePath); $this->clearSmartyCache(); return $this->showMsg('upgrade_finish'); } }
/** * * @param string $url * @param mixed $headers * @param array $data * @return string */ private function _request($url, $content = '', $headers = null) { return Oray_Function::httpRequest($url, $content, $headers); }