* Add download client method.

This commit is contained in:
chenfeiCF
2018-12-04 15:52:00 +08:00
parent aab0d16d14
commit a05b7d4d4e
4 changed files with 98 additions and 0 deletions
+59
View File
@@ -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.
*
+9
View File
@@ -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';
+9
View File
@@ -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'] = '关于禅道';
+21
View File
@@ -0,0 +1,21 @@
<?php include '../../common/view/header.lite.html.php';?>
<div id='mainContent' class='main-content'>
<div class='main-header'>
<h2><?php echo $lang->downloadClient;?></h2>
</div>
<form method='post' target='hiddenwin'>
<table class='w-p100'>
<tr>
<td>
<?php echo html::radio('os', $lang->misc->client->osList, 'windows64', '', 'block');?>
</td>
</tr>
<tr class='text-center'>
<td>
<?php echo html::submitButton($lang->misc->client->download, '', 'btn btn-primary');?>
</td>
</tr>
</table>
</form>
</div>
<?php include '../../common/view/footer.lite.html.php';?>