* Use helper::setcookie.
This commit is contained in:
@@ -803,6 +803,38 @@ class baseHelper
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a cookie.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param int|null $expire
|
||||
* @param string|null $path
|
||||
* @param string $domain
|
||||
* @param bool|null $secure
|
||||
* @param bool $httponly
|
||||
* @static
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public static function setcookie(string $name, string $value = '', int $expire = null, string $path = null, string $domain = '', bool $secure = null, bool $httponly = true)
|
||||
{
|
||||
global $config, $app;
|
||||
|
||||
if($expire === null) $expire = $config->cookieLife;
|
||||
if($path === null) $path = $config->webRoot;
|
||||
if($secure === null) $secure = $config->cookieSecure;
|
||||
|
||||
if(isset($app->worker))
|
||||
{
|
||||
$app->worker->response->setCookie($name, $value, $expire, $path, $domain, $secure, $httponly);
|
||||
}
|
||||
else
|
||||
{
|
||||
return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态码。
|
||||
* Set status code.
|
||||
|
||||
@@ -1210,7 +1210,7 @@ class baseRouter
|
||||
$this->clientLang = $this->config->default->lang;
|
||||
}
|
||||
|
||||
setcookie('lang', (string) $this->clientLang, array('expires' => $this->config->cookieLife, 'path' => (string) $this->config->webRoot, 'domain' => '', 'secure' => $this->config->cookieSecure, 'httponly' => false));
|
||||
helper::setcookie('lang', (string) $this->clientLang, $this->config->cookieLife, (string) $this->config->webRoot, '', $this->config->cookieSecure, false);
|
||||
if(!isset($_COOKIE['lang'])) $_COOKIE['lang'] = $this->clientLang;
|
||||
|
||||
return true;
|
||||
@@ -1264,7 +1264,7 @@ class baseRouter
|
||||
$this->clientTheme = $this->config->default->theme;
|
||||
}
|
||||
|
||||
setcookie('theme', (string) $this->clientTheme, array('expires' => $this->config->cookieLife, 'path' => (string) $this->config->webRoot, 'domain' => '', 'secure' => $this->config->cookieSecure, 'httponly' => false));
|
||||
helper::setcookie('theme', (string) $this->clientTheme, $this->config->cookieLife, (string) $this->config->webRoot, '', $this->config->cookieSecure, false);
|
||||
if(!isset($_COOKIE['theme'])) $_COOKIE['theme'] = $this->clientTheme;
|
||||
|
||||
return true;
|
||||
@@ -1290,7 +1290,7 @@ class baseRouter
|
||||
$this->clientDevice = ($mobile->isMobile() and !$mobile->isTablet()) ? 'mobile' : 'desktop';
|
||||
}
|
||||
|
||||
setcookie('device', $this->clientDevice, array('expires' => $this->config->cookieLife, 'path' => (string) $this->config->webRoot, 'domain' => '', 'secure' => $this->config->cookieSecure, 'httponly' => true));
|
||||
helper::setcookie('device', $this->clientDevice, $this->config->cookieLife, (string) $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
if(!isset($_COOKIE['device'])) $_COOKIE['device'] = $this->clientDevice;
|
||||
|
||||
return $this->clientDevice;
|
||||
|
||||
@@ -635,7 +635,7 @@ class control extends baseControl
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the functions declared in the tao files.
|
||||
* Call the functions declared in the zen files.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $arguments
|
||||
@@ -653,7 +653,7 @@ class control extends baseControl
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the static functions declared in the tao files.
|
||||
* Call the static functions declared in the zen files.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $arguments
|
||||
|
||||
@@ -357,31 +357,6 @@ class helper extends baseHelper
|
||||
return $dateInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a cookie.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param int|null $expire
|
||||
* @param string|null $path
|
||||
* @param string $domain
|
||||
* @param bool|null $secure
|
||||
* @param bool $httponly
|
||||
* @static
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public static function setcookie(string $name, string $value = '', int $expire = null, string $path = null, string $domain = '', bool $secure = null, bool $httponly = true)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if($expire === null) $expire = $config->cookieLife;
|
||||
if($path === null) $path = $config->webRoot;
|
||||
if($secure === null) $secure = $config->cookieSecure;
|
||||
|
||||
return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换类型。
|
||||
* Convert the type.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"require": {
|
||||
"spiral/roadrunner": "v2.0",
|
||||
"nyholm/psr7": "^1.8",
|
||||
"spiral/roadrunner-jobs": "^2.0",
|
||||
"spiral/roadrunner-jobs": "^3.0",
|
||||
"spiral/goridge": "^3.2",
|
||||
"spiral/roadrunner-kv": "^3.0"
|
||||
}
|
||||
|
||||
@@ -259,13 +259,13 @@ class zandResponse implements ResponseInterface
|
||||
$this->stream = Stream::create($body);
|
||||
}
|
||||
|
||||
public function setCookie(string $name, string $value, $expire, ?string $path = null, ?string $domain = null, ?bool $secure = null, ?bool $httpOnly = null, ?string $sameSite = null): static
|
||||
public function setCookie(string $name, string $value, ?int $expire, ?string $path = null, ?string $domain = null, ?bool $secure = null, ?bool $httpOnly = null, ?string $sameSite = null): static
|
||||
{
|
||||
$headerValue = sprintf('%s=%s; path=%s; SameSite=%s', $name, urlencode($value), $path ?? ($domain ? '/' : $this->cookiePath), $sameSite ?? 'Lax');
|
||||
|
||||
if($expire)
|
||||
{
|
||||
$headerValue .= '; Expires='.(date('D, d M Y H:i:s T', strtotime($expire)));
|
||||
$headerValue .= '; Expires='.(date('D, d M Y H:i:s T', $expire));
|
||||
}
|
||||
|
||||
$cookieDomain = $domain ?? $this->cookieDomain;
|
||||
|
||||
@@ -100,6 +100,8 @@ class zandRouter extends router
|
||||
$this->methodName = NULL;
|
||||
$this->rawModule = NULL;
|
||||
$this->rawMethod = NULL;
|
||||
$this->params = NULL;
|
||||
$this->user = NULL;
|
||||
|
||||
self::$loadedConfigs = array();
|
||||
self::$loadedLangs = array();
|
||||
@@ -423,7 +425,7 @@ class zandSession
|
||||
*/
|
||||
public function gc($maxlifetime)
|
||||
{
|
||||
$this->dao->delete(TABLE_SESSION)->where('timestamp')->lt(time() - intval($maxlifetime))->exec();
|
||||
$this->dao->delete()->from(TABLE_SESSION)->where('timestamp')->lt(time() - intval($maxlifetime))->exec();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,14 +152,14 @@ class caselib extends control
|
||||
|
||||
/* Set menu. */
|
||||
$libID = $this->caselib->saveLibState($libID, $libraries);
|
||||
setcookie('preCaseLibID', $libID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('preCaseLibID', $libID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
if($this->cookie->preCaseLibID != $libID)
|
||||
{
|
||||
$_COOKIE['libCaseModule'] = 0;
|
||||
setcookie('libCaseModule', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('libCaseModule', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
}
|
||||
|
||||
if($browseType == 'bymodule') setcookie('libCaseModule', (int)$param, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
if($browseType == 'bymodule') helper::setcookie('libCaseModule', (int)$param, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
if($browseType != 'bymodule') $this->session->set('libBrowseType', $browseType);
|
||||
$moduleID = ($browseType == 'bymodule') ? (int)$param : ($browseType == 'bysearch' ? 0 : ($this->cookie->libCaseModule ? $this->cookie->libCaseModule : 0));
|
||||
$queryID = ($browseType == 'bysearch') ? (int)$param : 0;
|
||||
@@ -224,7 +224,7 @@ class caselib extends control
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$this->loadModel('testcase');
|
||||
setcookie('lastLibCaseModule', (int)$this->post->module, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, false);
|
||||
helper::setcookie('lastLibCaseModule', (int)$this->post->module, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, false);
|
||||
|
||||
$case = form::data($this->config->testcase->form->create)->add('lib', $libID)->get();
|
||||
|
||||
|
||||
@@ -380,7 +380,7 @@ class doc extends control
|
||||
$libID = $this->post->lib;
|
||||
$moduleID = $this->post->module;
|
||||
if(empty($libID) and strpos($this->post->module, '_') !== false) list($libID, $moduleID) = explode('_', $this->post->module);
|
||||
setcookie('lastDocModule', $moduleID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('lastDocModule', $moduleID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
$docResult = $this->doc->create();
|
||||
if(!$docResult or dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
@@ -1043,7 +1043,7 @@ class doc extends control
|
||||
{
|
||||
$this->loadModel('file');
|
||||
if(empty($viewType)) $viewType = !empty($_COOKIE['docFilesViewType']) ? $this->cookie->docFilesViewType : 'list';
|
||||
setcookie('docFilesViewType', $viewType, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('docFilesViewType', $viewType, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
$objects = $this->doc->getOrderedObjects($type, 'nomerge', $objectID);
|
||||
list($libs, $libID, $object, $objectID, $objectDropdown) = $this->doc->setMenuByType($type, $objectID, 0);
|
||||
|
||||
@@ -1068,7 +1068,7 @@ class fileModel extends model
|
||||
for($i = 0; $i < $obLevel; $i++) ob_end_clean();
|
||||
|
||||
/* Set the downloading cookie, thus the export form page can use it to judge whether to close the window or not. */
|
||||
setcookie('downloading', 1, 0, $this->config->webRoot, '', $this->config->cookieSecure, false);
|
||||
helper::setcookie('downloading', 1, 0, $this->config->webRoot, '', $this->config->cookieSecure, false);
|
||||
|
||||
/* Only download upload file that is in zentao. */
|
||||
if($type == 'file' and stripos($content, $this->savePath) !== 0) helper::end();
|
||||
|
||||
@@ -448,7 +448,7 @@ class mr extends control
|
||||
if($this->post->arrange)
|
||||
{
|
||||
$arrange = $this->post->arrange;
|
||||
setcookie('arrange', $arrange);
|
||||
helper::setcookie('arrange', $arrange);
|
||||
}
|
||||
if($this->post->encoding) $encoding = $this->post->encoding;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1530,7 +1530,7 @@ class mrModel extends model
|
||||
{
|
||||
$bugID = $this->dao->lastInsertID();
|
||||
$this->loadModel('file')->updateObjectID($this->post->uid, $bugID, 'bug');
|
||||
setcookie("repoPairs[$repoID]", $data->product);
|
||||
helper::setcookie("repoPairs[$repoID]", $data->product);
|
||||
|
||||
$bugInfo = array();
|
||||
$bugInfo['result'] = 'success';
|
||||
|
||||
@@ -117,7 +117,7 @@ class projectModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
setcookie('lastProject', (string)$this->session->project, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('lastProject', (string)$this->session->project, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
return $this->session->project;
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ class qaModel extends model
|
||||
}
|
||||
|
||||
$branch = ($this->cookie->preBranch !== '' and $branch === '') ? $this->cookie->preBranch : $branch;
|
||||
setcookie('preBranch', $branch, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('preBranch', $branch, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
$product = $this->loadModel('product')->getByID($productID);
|
||||
if($product and $product->type != 'normal') $this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
|
||||
|
||||
@@ -633,7 +633,7 @@ class repo extends control
|
||||
}
|
||||
}
|
||||
|
||||
if($this->cookie->repoRefresh) setcookie('repoRefresh', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
if($this->cookie->repoRefresh) helper::setcookie('repoRefresh', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
/* Synchronous commit only in root path. */
|
||||
if(in_array($repo->SCM, $this->config->repo->gitTypeList) and empty($path) and $infos and empty($revisions)) $this->locate($this->repo->createLink('showSyncCommit', "repoID=$repoID&objectID=$objectID&branch=" . helper::safe64Encode(base64_encode($this->cookie->repoBranch))));
|
||||
@@ -860,7 +860,7 @@ class repo extends control
|
||||
if($this->post->arrange)
|
||||
{
|
||||
$arrange = $this->post->arrange;
|
||||
setcookie('arrange', $arrange);
|
||||
helper::setcookie('arrange', $arrange);
|
||||
}
|
||||
if($this->post->encoding) $encoding = $this->post->encoding;
|
||||
if($this->post->isBranchOrTag) $isBranchOrTag = $this->post->isBranchOrTag;
|
||||
@@ -1449,7 +1449,7 @@ class repo extends control
|
||||
}
|
||||
|
||||
$this->repo->setRepoBranch($branchID);
|
||||
setcookie("syncBranch", $branchID, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie("syncBranch", $branchID, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1483,7 +1483,7 @@ class repo extends control
|
||||
if($branchID) $this->repo->saveExistCommits4Branch($repo->id, $branchID);
|
||||
|
||||
$branchID = reset($branches);
|
||||
setcookie("syncBranch", $branchID, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie("syncBranch", $branchID, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
if($branchID) $this->repo->fixCommit($repoID);
|
||||
}
|
||||
@@ -1518,7 +1518,7 @@ class repo extends control
|
||||
$this->scm->setEngine($repo);
|
||||
|
||||
$this->repo->setRepoBranch($branch);
|
||||
setcookie("syncBranch", $branch, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie("syncBranch", $branch, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
$latestInDB = $this->dao->select('t1.*')->from(TABLE_REPOHISTORY)->alias('t1')
|
||||
->leftJoin(TABLE_REPOBRANCH)->alias('t2')->on('t1.id=t2.revision')
|
||||
@@ -1539,7 +1539,7 @@ class repo extends control
|
||||
{
|
||||
if($branch) $this->repo->saveExistCommits4Branch($repo->id, $branch);
|
||||
|
||||
setcookie("syncBranch", $branch, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie("syncBranch", $branch, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
$this->repo->markSynced($repoID);
|
||||
return print('finish');
|
||||
}
|
||||
|
||||
@@ -1328,7 +1328,7 @@ class repoModel extends model
|
||||
*/
|
||||
public function setRepoBranch($branch)
|
||||
{
|
||||
setcookie("repoBranch", $branch, 0, $this->config->webRoot, '', $this->config->cookieSecure);
|
||||
helper::setcookie("repoBranch", $branch, 0, $this->config->webRoot, '', $this->config->cookieSecure);
|
||||
$_COOKIE['repoBranch'] = $branch;
|
||||
}
|
||||
|
||||
|
||||
@@ -156,8 +156,8 @@ class sso extends control
|
||||
if($this->get->status == 'success')
|
||||
{
|
||||
session_destroy();
|
||||
setcookie('za', false);
|
||||
setcookie('zp', false);
|
||||
helper::setcookie('za', false);
|
||||
helper::setcookie('zp', false);
|
||||
$this->locate($this->createLink('user', 'login'));
|
||||
}
|
||||
$this->locate($this->createLink('user', 'logout'));
|
||||
|
||||
@@ -32,7 +32,7 @@ class testsuiteModel extends model
|
||||
return;
|
||||
}
|
||||
|
||||
setcookie("lastProduct", $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie("lastProduct", $productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
$currentProduct = $this->product->getById($productID);
|
||||
|
||||
$dropMenuLink = helper::createLink('product', 'ajaxGetDropMenu', "objectID=$productID&module=$currentModule&method=$currentMethod&extra=$extra");
|
||||
|
||||
@@ -508,7 +508,7 @@ class testtask extends control
|
||||
{
|
||||
$this->testtask->setMenu($this->products, $productID, $task->branch, $taskID);
|
||||
}
|
||||
setcookie('preTaskID', $taskID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('preTaskID', $taskID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
/* Determines whether an object is editable. */
|
||||
$canBeChanged = common::canBeChanged('testtask', $task);
|
||||
@@ -516,10 +516,10 @@ class testtask extends control
|
||||
if($this->cookie->preTaskID != $taskID)
|
||||
{
|
||||
$_COOKIE['taskCaseModule'] = 0;
|
||||
setcookie('taskCaseModule', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('taskCaseModule', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
}
|
||||
|
||||
if($browseType == 'bymodule') setcookie('taskCaseModule', (int)$param, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
if($browseType == 'bymodule') helper::setcookie('taskCaseModule', (int)$param, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
if($browseType != 'bymodule') $this->session->set('taskCaseBrowseType', $browseType);
|
||||
if($browseType == 'bysuite') $suiteName = $this->loadModel('testsuite')->getById($param)->name;
|
||||
|
||||
@@ -678,7 +678,7 @@ class testtask extends control
|
||||
$this->app->loadLang('execution');
|
||||
$this->app->loadLang('task');
|
||||
$this->session->set('caseList', $this->app->getURI(true), 'qa');
|
||||
setcookie('taskCaseModule', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('taskCaseModule', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
/* Get task and product info, set menu. */
|
||||
$groupBy = empty($groupBy) ? 'story' : $groupBy;
|
||||
@@ -1252,7 +1252,7 @@ class testtask extends control
|
||||
else
|
||||
{
|
||||
/* set cookie for ajax load caselist when close colorbox. */
|
||||
setcookie('selfClose', 1, 0, $this->config->webRoot, '', $this->config->cookieSecure, false);
|
||||
helper::setcookie('selfClose', 1, 0, $this->config->webRoot, '', $this->config->cookieSecure, false);
|
||||
|
||||
if($preAndNext->next and $this->app->tab != 'my')
|
||||
{
|
||||
|
||||
@@ -2406,7 +2406,7 @@ class testtaskModel extends model
|
||||
}
|
||||
|
||||
$branch = ($this->cookie->preBranch !== '' and $branch === '') ? $this->cookie->preBranch : $branch;
|
||||
setcookie('preBranch', $branch, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('preBranch', $branch, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
$product = $this->loadModel('product')->getById($productID);
|
||||
if($product and $product->type != 'normal') $this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
|
||||
|
||||
@@ -2074,7 +2074,7 @@ class treeModel extends model
|
||||
break;
|
||||
}
|
||||
if(strpos($this->session->{$module->type . 'List'}, 'param=' . $moduleID)) $this->session->set($module->type . 'List', str_replace('param=' . $moduleID, 'param=0', $this->session->{$module->type . 'List'}));
|
||||
if($cookieName) setcookie($cookieName, 0, time() - 3600, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
if($cookieName) helper::setcookie($cookieName, 0, time() - 3600, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -973,7 +973,7 @@ class user extends control
|
||||
}
|
||||
else
|
||||
{
|
||||
setcookie('tab', false, time(), $this->config->webRoot);
|
||||
helper::setcookie('tab', false, time(), $this->config->webRoot);
|
||||
$loginExpired = !(preg_match("/(m=|\/)(index)(&f=|-)(index)(&|-|\.)?/", strtolower($this->referer), $output) or $this->referer == $this->config->webRoot or empty($this->referer) or preg_match("/\/www\/$/", strtolower($this->referer), $output));
|
||||
|
||||
$this->loadModel('misc');
|
||||
@@ -1044,9 +1044,11 @@ class user extends control
|
||||
public function logout($referer = 0)
|
||||
{
|
||||
if(isset($this->app->user->id)) $this->loadModel('action')->create('user', $this->app->user->id, 'logout');
|
||||
setcookie('za', false, time() - 3600, $this->config->webRoot);
|
||||
setcookie('zp', false, time() - 3600, $this->config->webRoot);
|
||||
setcookie('tab', false, time() - 3600, $this->config->webRoot);
|
||||
helper::setcookie('za', false, time() - 3600, $this->config->webRoot);
|
||||
helper::setcookie('zp', false, time() - 3600, $this->config->webRoot);
|
||||
helper::setcookie('tab', false, time() - 3600, $this->config->webRoot);
|
||||
|
||||
$_SESSION = array();
|
||||
session_destroy();
|
||||
|
||||
if($this->app->getViewType() == 'json') return print(json_encode(array('status' => 'success')));
|
||||
|
||||
@@ -1180,9 +1180,9 @@ class userModel extends model
|
||||
*/
|
||||
public function keepLogin($user)
|
||||
{
|
||||
setcookie('keepLogin', 'on', $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
setcookie('za', $user->account, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
setcookie('zp', sha1($user->account . $user->password . $this->server->request_time), $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('keepLogin', 'on', $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('za', $user->account, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('zp', sha1($user->account . $user->password . $this->server->request_time), $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,7 +41,7 @@ class webhook extends control
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
|
||||
/* Unset selectedDepts cookie. */
|
||||
setcookie('selectedDepts', '', 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('selectedDepts', '', 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
$this->view->title = $this->lang->webhook->api . $this->lang->colon . $this->lang->webhook->list;
|
||||
$this->view->webhooks = $this->webhook->getList($orderBy, $pager);
|
||||
@@ -188,7 +188,7 @@ class webhook extends control
|
||||
/* Get selected depts. */
|
||||
if($this->get->selectedDepts)
|
||||
{
|
||||
setcookie('selectedDepts', $this->get->selectedDepts, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
helper::setcookie('selectedDepts', $this->get->selectedDepts, 0, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
$_COOKIE['selectedDepts'] = $this->get->selectedDepts;
|
||||
}
|
||||
$selectedDepts = $this->cookie->selectedDepts ? $this->cookie->selectedDepts : '';
|
||||
|
||||
+7
-7
@@ -1,12 +1,12 @@
|
||||
version: "3"
|
||||
|
||||
#service:
|
||||
# cron_schedule:
|
||||
# command: php cron.php
|
||||
# process_num: 1
|
||||
# exec_timeout: 0
|
||||
# restart_sec: 1
|
||||
# relay: pipes
|
||||
service:
|
||||
cron_schedule:
|
||||
command: php cron.php
|
||||
process_num: 1
|
||||
exec_timeout: 0
|
||||
restart_sec: 1
|
||||
relay: pipes
|
||||
|
||||
server:
|
||||
command: php worker.php
|
||||
|
||||
+27
-1
@@ -27,6 +27,8 @@ if($_SERVER['RR_MODE'] === 'jobs')
|
||||
|
||||
if($type == 'zentao')
|
||||
{
|
||||
ob_start();
|
||||
|
||||
parse_str($cmd, $params);
|
||||
if(!isset($params['moduleName']) || !isset($params['methodName'])) continue;
|
||||
|
||||
@@ -35,9 +37,11 @@ if($_SERVER['RR_MODE'] === 'jobs')
|
||||
|
||||
$app->moduleName = $params['moduleName'];
|
||||
$app->methodName = $params['methodName'];
|
||||
$app->rawModule = $params['moduleName'];
|
||||
$app->rawMethod = $params['methodName'];
|
||||
$app->setControlFile();
|
||||
$app->loadModule();
|
||||
$output = ob_get_contents();
|
||||
$output = ob_get_clean();
|
||||
|
||||
$app->closeRequest();
|
||||
}
|
||||
@@ -46,6 +50,9 @@ if($_SERVER['RR_MODE'] === 'jobs')
|
||||
exec($cmd, $output, $return);
|
||||
if($output) $output = implode("\n", $output);
|
||||
}
|
||||
|
||||
$log = date('H:m:s') . "task " . $id . " executed,\ncommand: $cmd.\nreturn : $return.\noutput : $output\n";
|
||||
logCron($app->getLogRoot(), $log);
|
||||
}
|
||||
|
||||
$task->complete();
|
||||
@@ -125,3 +132,22 @@ else
|
||||
$app->closeRequest();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log cron.
|
||||
*
|
||||
* @param string $log
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function logCron($root, $log)
|
||||
{
|
||||
if(!is_writable($root)) return false;
|
||||
|
||||
$file = $root . 'cron.' . date('Ymd') . '.log.php';
|
||||
if(!is_file($file)) $log = "<?php\n die();\n" . $log;
|
||||
|
||||
$fp = fopen($file, "a");
|
||||
fwrite($fp, $log);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user