mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
temp work
This commit is contained in:
@@ -466,7 +466,7 @@ try {
|
||||
// Next steps:
|
||||
// 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');
|
||||
if (is_null($sLoginMode) || is_null($sTokenInfo)) {
|
||||
$sAuthUser = ReadMandatoryParam($oP, 'auth_user', 'raw_data');
|
||||
@@ -481,7 +481,6 @@ try {
|
||||
} else
|
||||
{
|
||||
$oLoginFSMExtensionInstance = LoginWebPage::GetCurrentLoginPlugin($sLoginMode);
|
||||
|
||||
if ($oLoginFSMExtensionInstance instanceof iTokenLoginUIExtension){
|
||||
$aTokenInfo = json_decode(base64_decode($sTokenInfo), true);
|
||||
|
||||
|
||||
@@ -17,42 +17,37 @@ try {
|
||||
$sCurrentLoginMode = \Combodo\iTop\Application\Helper\Session::Get('login_mode', '');
|
||||
$oLoginFSMExtensionInstance = LoginWebPage::GetCurrentLoginPlugin($sCurrentLoginMode);
|
||||
|
||||
if ($oLoginFSMExtensionInstance instanceof iTokenLoginUIExtension){
|
||||
/** @var iTokenLoginUIExtension $oLoginFSMExtensionInstance */
|
||||
$aTokenInfo = $oLoginFSMExtensionInstance->GetTokenInfo();
|
||||
$sTokenInfo = base64_encode(json_encode($aTokenInfo));
|
||||
} else {
|
||||
if (! $oLoginFSMExtensionInstance instanceof iTokenLoginUIExtension){
|
||||
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");
|
||||
$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);
|
||||
$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__);
|
||||
file_put_contents($sLogFile, $sCli);
|
||||
$process = popen($sCli, 'r');
|
||||
} else {
|
||||
//asynchronous
|
||||
$sCli = sprintf("\n $sPHPExec %s/cron.php $sCliParams", __DIR__);
|
||||
$fp = fopen($sLogFile, 'a+');
|
||||
fwrite($fp, $sCli);
|
||||
|
||||
Reference in New Issue
Block a user