diff --git a/module/misc/control.php b/module/misc/control.php index 50be5e57d2..f43da9e03a 100644 --- a/module/misc/control.php +++ b/module/misc/control.php @@ -84,6 +84,65 @@ class misc extends control echo $this->misc->hello2(); } + /** + * Download zentao client. + * + * @access public + * @return void + */ + public function downloadClient() + { + if($_POST) + { + $clientDir = $this->app->getBasePath() . 'tmp/cache/client/'; + if(!is_dir($clientDir))mkdir($clientDir, 0755, true); + + $account = $this->app->user->account; + $packageFile = $clientDir . $account . 'client.zip'; + $loginFile = $clientDir . 'config.json'; + + /* write login info into tmp file. */ + $loginInfo = new stdclass(); + $defaultUser = new stdclass(); + $defaultUser->server = common::getSysURL(); + $defaultUser->account = $account; + $loginInfo->ui = $defaultUser; + + $loginInfo = json_encode($loginInfo); + + file_put_contents($packageFile, file_get_contents("http://dl.cnezsoft.com/notify/newest/zentaonotify.win_32.zip")); + file_put_contents($loginFile, $loginInfo); + + define('PCLZIP_TEMPORARY_DIR', $clientDir); + $this->app->loadClass('pclzip', true); + + /* remove the old config.json, add a new one. */ + $archive = new pclzip($packageFile); + $result = $archive->delete(PCLZIP_OPT_BY_NAME, 'config.json'); + if($result == 0) die("Error : " . $archive->errorInfo(true)); + + if($this->post->os == 'windows64' or $this->post->os == 'windows32') + { + } + if($this->post->os == 'linux64' or $this->post->os == 'linux32') + { + } + if($this->post->os == 'mac') + { + } + + $result = $archive->add($loginFile, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_ADD_PATH, 'client'); + if($result == 0) die("Error : " . $archive->errorInfo(true)); + + $zipContent = file_get_contents($packageFile); + unlink($loginFile); + unlink($packageFile); + $this->fetch('file', 'sendDownHeader', array('fileName' => 'client.zip', 'zip', $zipContent)); + } + + $this->display(); + } + /** * Down notify. * diff --git a/module/misc/lang/en.php b/module/misc/lang/en.php index 7d2e1542a2..8b8b5fa375 100644 --- a/module/misc/lang/en.php +++ b/module/misc/lang/en.php @@ -15,6 +15,15 @@ $lang->misc->ping = 'Ping'; $lang->misc->api = 'https://api.zentao.net'; $lang->misc->enApi = 'http://api.zentao.pm'; +$lang->misc->client = new stdclass(); +$lang->misc->client->download = 'Download'; + +$lang->misc->client->osList['windows64'] = 'Windows 64'; +$lang->misc->client->osList['windows32'] = 'Windows 32'; +$lang->misc->client->osList['linux64'] = 'Linux 64'; +$lang->misc->client->osList['linux32'] = 'Linux 32'; +$lang->misc->client->osList['mac'] = 'Mac'; + $lang->misc->zentao = new stdclass(); $lang->misc->zentao->version = 'Version %s'; $lang->misc->zentao->labels['about'] = 'About'; diff --git a/module/misc/lang/zh-cn.php b/module/misc/lang/zh-cn.php index 314baec923..24eb26bd7c 100644 --- a/module/misc/lang/zh-cn.php +++ b/module/misc/lang/zh-cn.php @@ -15,6 +15,15 @@ $lang->misc->ping = '防超时'; $lang->misc->api = 'https://api.zentao.net'; $lang->misc->enApi = 'http://api.zentao.pm'; +$lang->misc->client = new stdclass(); +$lang->misc->client->download = '下载'; + +$lang->misc->client->osList['windows64'] = 'Windows 64位'; +$lang->misc->client->osList['windows32'] = 'Windows 32位'; +$lang->misc->client->osList['linux64'] = 'Linux 64位'; +$lang->misc->client->osList['linux32'] = 'Linux 32位'; +$lang->misc->client->osList['mac'] = 'Mac版'; + $lang->misc->zentao = new stdclass(); $lang->misc->zentao->version = '版本%s'; $lang->misc->zentao->labels['about'] = '关于禅道'; diff --git a/module/misc/view/downloadclient.html.php b/module/misc/view/downloadclient.html.php new file mode 100644 index 0000000000..524c9ff3f2 --- /dev/null +++ b/module/misc/view/downloadclient.html.php @@ -0,0 +1,21 @@ + +