mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 23:32:17 +02:00
temp work
This commit is contained in:
@@ -522,7 +522,7 @@ try
|
|||||||
// Next steps:
|
// Next steps:
|
||||||
// specific arguments: 'csv file'
|
// specific arguments: 'csv file'
|
||||||
//
|
//
|
||||||
$sTokenInfo = utils::ReadParam('auth_token_info', null, true, 'raw_data');
|
$sTokenInfo = utils::ReadParam('auth_info', null, true, 'raw_data');
|
||||||
$sLoginMode = utils::ReadParam('login_mode', null, true, 'raw_data');
|
$sLoginMode = utils::ReadParam('login_mode', null, true, 'raw_data');
|
||||||
if (is_null($sLoginMode) || is_null($sTokenInfo)) {
|
if (is_null($sLoginMode) || is_null($sTokenInfo)) {
|
||||||
$sAuthUser = ReadMandatoryParam($oP, 'auth_user', 'raw_data');
|
$sAuthUser = ReadMandatoryParam($oP, 'auth_user', 'raw_data');
|
||||||
@@ -537,7 +537,6 @@ try
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
$oLoginFSMExtensionInstance = LoginWebPage::GetCurrentLoginPlugin($sLoginMode);
|
$oLoginFSMExtensionInstance = LoginWebPage::GetCurrentLoginPlugin($sLoginMode);
|
||||||
|
|
||||||
if ($oLoginFSMExtensionInstance instanceof iTokenLoginUIExtension){
|
if ($oLoginFSMExtensionInstance instanceof iTokenLoginUIExtension){
|
||||||
$aTokenInfo = json_decode(base64_decode($sTokenInfo), true);
|
$aTokenInfo = json_decode(base64_decode($sTokenInfo), true);
|
||||||
|
|
||||||
|
|||||||
@@ -17,42 +17,37 @@ try {
|
|||||||
$sCurrentLoginMode = \Combodo\iTop\Application\Helper\Session::Get('login_mode', '');
|
$sCurrentLoginMode = \Combodo\iTop\Application\Helper\Session::Get('login_mode', '');
|
||||||
$oLoginFSMExtensionInstance = LoginWebPage::GetCurrentLoginPlugin($sCurrentLoginMode);
|
$oLoginFSMExtensionInstance = LoginWebPage::GetCurrentLoginPlugin($sCurrentLoginMode);
|
||||||
|
|
||||||
if ($oLoginFSMExtensionInstance instanceof iTokenLoginUIExtension){
|
if (! $oLoginFSMExtensionInstance instanceof iTokenLoginUIExtension){
|
||||||
/** @var iTokenLoginUIExtension $oLoginFSMExtensionInstance */
|
|
||||||
$aTokenInfo = $oLoginFSMExtensionInstance->GetTokenInfo();
|
|
||||||
$sTokenInfo = base64_encode(json_encode($aTokenInfo));
|
|
||||||
} else {
|
|
||||||
throw new \Exception("cannot call cron asynchronously via current login mode $sCurrentLoginMode");
|
throw new \Exception("cannot call cron asynchronously via current login mode $sCurrentLoginMode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$aCronValues = [];
|
||||||
|
foreach ([ 'status_only', 'verbose', 'debug'] as $sParam){
|
||||||
|
$value = ReadParam($sParam, false);
|
||||||
|
$aCronValues[] = "--$sParam=".escapeshellarg($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var iTokenLoginUIExtension $oLoginFSMExtensionInstance */
|
||||||
|
$aTokenInfo = $oLoginFSMExtensionInstance->GetTokenInfo();
|
||||||
|
$sTokenInfo = base64_encode(json_encode($aTokenInfo));
|
||||||
|
$aCronValues[] = "--auth_info=".escapeshellarg($sTokenInfo);
|
||||||
|
$aCronValues[] = "--login_mode=".escapeshellarg($sCurrentLoginMode);
|
||||||
|
|
||||||
|
$sCliParams=implode(" ", $aCronValues);
|
||||||
|
|
||||||
$sLogFilename = ReadParam("cron_log_file", "cron.log");
|
$sLogFilename = ReadParam("cron_log_file", "cron.log");
|
||||||
$sLogFile = APPROOT."log/$sLogFilename";
|
$sLogFile = APPROOT."log/$sLogFilename";
|
||||||
|
|
||||||
$sCliParams = ReadParam("cron_cli_parameters");
|
|
||||||
|
|
||||||
$bAsynchronous = true;
|
|
||||||
if (is_null($sCliParams)) {
|
|
||||||
$sCliParams = "--help";
|
|
||||||
$bAsynchronous = false;
|
|
||||||
} else {
|
|
||||||
$sCliParams = trim(base64_decode($sCliParams, true));
|
|
||||||
|
|
||||||
$sCliParams = "--auth_token_info=$sTokenInfo ".$sCliParams;
|
|
||||||
$sCliParams = "--login_mode=$sCurrentLoginMode ".$sCliParams;
|
|
||||||
|
|
||||||
if (false !== strpos($sCliParams, '--status_only=1')) {
|
|
||||||
$bAsynchronous = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
touch($sLogFile);
|
touch($sLogFile);
|
||||||
$sPHPExec = trim(\MetaModel::GetConfig()->Get('php_path'));
|
$sPHPExec = trim(\MetaModel::GetConfig()->Get('php_path'));
|
||||||
|
|
||||||
if ($bAsynchronous) {
|
if ($aCronValues['status_only']) {
|
||||||
|
//still synchronous
|
||||||
$sCli = sprintf("$sPHPExec %s/cron.php $sCliParams 2>&1 >>$sLogFile &", __DIR__);
|
$sCli = sprintf("$sPHPExec %s/cron.php $sCliParams 2>&1 >>$sLogFile &", __DIR__);
|
||||||
file_put_contents($sLogFile, $sCli);
|
file_put_contents($sLogFile, $sCli);
|
||||||
$process = popen($sCli, 'r');
|
$process = popen($sCli, 'r');
|
||||||
} else {
|
} else {
|
||||||
|
//asynchronous
|
||||||
$sCli = sprintf("\n $sPHPExec %s/cron.php $sCliParams", __DIR__);
|
$sCli = sprintf("\n $sPHPExec %s/cron.php $sCliParams", __DIR__);
|
||||||
$fp = fopen($sLogFile, 'a+');
|
$fp = fopen($sLogFile, 'a+');
|
||||||
fwrite($fp, $sCli);
|
fwrite($fp, $sCli);
|
||||||
|
|||||||
Reference in New Issue
Block a user