CODE STYLE, workflow/engine/methods/setup/ PART 1
FILES: appCacheViewAjax.php appCacheViewConf.php appearance.php calendarDelete.php calendarEdit.php calendarList.php calendarSave.php calendarValidate.php calendar_Ajax.php clearCompiled.php clearCompiledAjax.php connectionDB.php connectionWS.php cron.php cronAjax.php customFunctions.php debug.php deleteSessions.php emailSystemCron.php emailSystemSpool.php emailSystemTest.php emails.php emails_Ajax.php emails_Save.php environmentSettings.php environmentSettingsAjax.php
This commit is contained in:
@@ -1,39 +1,33 @@
|
||||
<?php
|
||||
function mktimeDate($date)
|
||||
{
|
||||
$arrayAux = getdate(strtotime($date));
|
||||
|
||||
$mktDate = mktime(
|
||||
$arrayAux["hours"],
|
||||
$arrayAux["minutes"],
|
||||
$arrayAux["seconds"],
|
||||
$arrayAux["mon"],
|
||||
$arrayAux["mday"],
|
||||
$arrayAux["year"]
|
||||
);
|
||||
function mktimeDate ($date)
|
||||
{
|
||||
$arrayAux = getdate( strtotime( $date ) );
|
||||
|
||||
$mktDate = mktime( $arrayAux["hours"], $arrayAux["minutes"], $arrayAux["seconds"], $arrayAux["mon"], $arrayAux["mday"], $arrayAux["year"] );
|
||||
|
||||
return $mktDate;
|
||||
}
|
||||
|
||||
function cronArraySet($str, $filter)
|
||||
function cronArraySet ($str, $filter)
|
||||
{
|
||||
$arrayAux = explode("|", $str);
|
||||
$arrayAux = explode( "|", $str );
|
||||
|
||||
$date = "";
|
||||
$workspace = "";
|
||||
$action = "";
|
||||
$status = "";
|
||||
$description = trim($arrayAux[0]);
|
||||
$date = "";
|
||||
$workspace = "";
|
||||
$action = "";
|
||||
$status = "";
|
||||
$description = trim( $arrayAux[0] );
|
||||
|
||||
if (count($arrayAux) > 1) {
|
||||
$date = (isset($arrayAux[0]))? trim($arrayAux[0]) : "";
|
||||
$workspace = (isset($arrayAux[1]))? trim($arrayAux[1]) : "";
|
||||
$action = (isset($arrayAux[2]))? trim($arrayAux[2]) : "";
|
||||
$status = (isset($arrayAux[3]))? trim($arrayAux[3]) : "";
|
||||
$description = (isset($arrayAux[4]))? trim($arrayAux[4]) : "";
|
||||
if (count( $arrayAux ) > 1) {
|
||||
$date = (isset( $arrayAux[0] )) ? trim( $arrayAux[0] ) : "";
|
||||
$workspace = (isset( $arrayAux[1] )) ? trim( $arrayAux[1] ) : "";
|
||||
$action = (isset( $arrayAux[2] )) ? trim( $arrayAux[2] ) : "";
|
||||
$status = (isset( $arrayAux[3] )) ? trim( $arrayAux[3] ) : "";
|
||||
$description = (isset( $arrayAux[4] )) ? trim( $arrayAux[4] ) : "";
|
||||
}
|
||||
|
||||
$mktDate = (!empty($date))? mktimeDate($date) : 0;
|
||||
$mktDate = (! empty( $date )) ? mktimeDate( $date ) : 0;
|
||||
|
||||
//Filter
|
||||
$sw = 1;
|
||||
@@ -57,68 +51,63 @@ function cronArraySet($str, $filter)
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($filter["dateFrom"]) && $mktDate > 0) {
|
||||
if (!(mktimeDate($filter["dateFrom"]) <= $mktDate)) {
|
||||
if (! empty( $filter["dateFrom"] ) && $mktDate > 0) {
|
||||
if (! (mktimeDate( $filter["dateFrom"] ) <= $mktDate)) {
|
||||
$sw = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($filter["dateTo"]) && $mktDate > 0) {
|
||||
if (!($mktDate <= mktimeDate($filter["dateTo"] . " 23:59:59"))) {
|
||||
if (! empty( $filter["dateTo"] ) && $mktDate > 0) {
|
||||
if (! ($mktDate <= mktimeDate( $filter["dateTo"] . " 23:59:59" ))) {
|
||||
$sw = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$arrayData = array();
|
||||
$arrayData = array ();
|
||||
|
||||
if ($sw == 1) {
|
||||
$arrayData = array(
|
||||
"DATE" => $date,
|
||||
"WORKSPACE" => $workspace,
|
||||
"ACTION" => $action,
|
||||
"STATUS" => $status,
|
||||
"DESCRIPTION" => $description
|
||||
$arrayData = array ("DATE" => $date,"WORKSPACE" => $workspace,"ACTION" => $action,"STATUS" => $status,"DESCRIPTION" => $description
|
||||
);
|
||||
}
|
||||
|
||||
return $arrayData;
|
||||
}
|
||||
|
||||
function cronDataGet($filter, $r, $i)
|
||||
function cronDataGet ($filter, $r, $i)
|
||||
{
|
||||
$r = $r + 1; //+ 1, to determine the next page
|
||||
$i = $i + 1;
|
||||
|
||||
$arrayData = array();
|
||||
$arrayData = array ();
|
||||
$strAux = null;
|
||||
$numRec = 0;
|
||||
$cont = 0;
|
||||
|
||||
$file = PATH_DATA . "log" . PATH_SEP . "cron.log";
|
||||
|
||||
if (file_exists($file)) {
|
||||
$fh = fopen($file, "r");
|
||||
if (file_exists( $file )) {
|
||||
$fh = fopen( $file, "r" );
|
||||
|
||||
for($pos = 0; fseek($fh, $pos, SEEK_END) !== -1; $pos--) {
|
||||
$char = fgetc($fh);
|
||||
for ($pos = 0; fseek( $fh, $pos, SEEK_END ) !== - 1; $pos --) {
|
||||
$char = fgetc( $fh );
|
||||
|
||||
if ($char == "\n") {
|
||||
$strAux = trim($strAux);
|
||||
$strAux = trim( $strAux );
|
||||
|
||||
if (!empty($strAux)) {
|
||||
$arrayAux = cronArraySet($strAux, $filter);
|
||||
if (! empty( $strAux )) {
|
||||
$arrayAux = cronArraySet( $strAux, $filter );
|
||||
|
||||
if (count($arrayAux) > 0) {
|
||||
if (count( $arrayAux ) > 0) {
|
||||
$cont = $cont + 1;
|
||||
|
||||
if ($cont >= $i && count($arrayData) + 1 <= $r) {
|
||||
if ($cont >= $i && count( $arrayData ) + 1 <= $r) {
|
||||
$arrayData[] = $arrayAux;
|
||||
$numRec = $cont;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($arrayData) == $r) {
|
||||
if (count( $arrayData ) == $r) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -129,74 +118,67 @@ function cronDataGet($filter, $r, $i)
|
||||
$strAux = $char . $strAux;
|
||||
}
|
||||
|
||||
$strAux = trim($strAux);
|
||||
$strAux = trim( $strAux );
|
||||
|
||||
if (!empty($strAux)) {
|
||||
$arrayAux = cronArraySet($strAux, $filter);
|
||||
if (! empty( $strAux )) {
|
||||
$arrayAux = cronArraySet( $strAux, $filter );
|
||||
|
||||
if (count($arrayAux) > 0) {
|
||||
if (count( $arrayAux ) > 0) {
|
||||
$cont = $cont + 1;
|
||||
|
||||
if ($cont >= $i && count($arrayData) + 1 <= $r) {
|
||||
if ($cont >= $i && count( $arrayData ) + 1 <= $r) {
|
||||
$arrayData[] = $arrayAux;
|
||||
$numRec = $cont;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fh);
|
||||
fclose( $fh );
|
||||
}
|
||||
|
||||
//Delete element
|
||||
$r = $r - 1;
|
||||
|
||||
if (count($arrayData) > $r) {
|
||||
$arrayAux = array_pop($arrayData);
|
||||
if (count( $arrayData ) > $r) {
|
||||
$arrayAux = array_pop( $arrayData );
|
||||
}
|
||||
|
||||
return array($numRec, $arrayData);
|
||||
return array ($numRec,$arrayData
|
||||
);
|
||||
}
|
||||
|
||||
$option = (isset( $_REQUEST["option"] )) ? $_REQUEST["option"] : null;
|
||||
|
||||
|
||||
|
||||
|
||||
$option = (isset($_REQUEST["option"]))? $_REQUEST["option"] : null;
|
||||
|
||||
$response = array();
|
||||
$response = array ();
|
||||
|
||||
switch ($option) {
|
||||
case "LST":
|
||||
$pageSize = $_REQUEST["pageSize"];
|
||||
$pageSize = $_REQUEST["pageSize"];
|
||||
$workspace = $_REQUEST["workspace"];
|
||||
$status = $_REQUEST["status"];
|
||||
$dateFrom = $_REQUEST["dateFrom"];
|
||||
$dateTo = $_REQUEST["dateTo"];
|
||||
$status = $_REQUEST["status"];
|
||||
$dateFrom = $_REQUEST["dateFrom"];
|
||||
$dateTo = $_REQUEST["dateTo"];
|
||||
|
||||
$arrayFilter = array(
|
||||
"workspace" => $workspace,
|
||||
"status" => $status,
|
||||
"dateFrom" => str_replace("T00:00:00", null, $dateFrom),
|
||||
"dateTo" => str_replace("T00:00:00", null, $dateTo)
|
||||
$arrayFilter = array ("workspace" => $workspace,"status" => $status,"dateFrom" => str_replace( "T00:00:00", null, $dateFrom ),"dateTo" => str_replace( "T00:00:00", null, $dateTo )
|
||||
);
|
||||
|
||||
$limit = isset($_REQUEST["limit"])? $_REQUEST["limit"] : $pageSize;
|
||||
$start = isset($_REQUEST["start"])? $_REQUEST["start"] : 0;
|
||||
$limit = isset( $_REQUEST["limit"] ) ? $_REQUEST["limit"] : $pageSize;
|
||||
$start = isset( $_REQUEST["start"] ) ? $_REQUEST["start"] : 0;
|
||||
|
||||
list($numRec, $data) = cronDataGet($arrayFilter, $limit, $start);
|
||||
list ($numRec, $data) = cronDataGet( $arrayFilter, $limit, $start );
|
||||
|
||||
$response = array("success" => true, "resultTotal" => $numRec, "resultRoot" => $data);
|
||||
$response = array ("success" => true,"resultTotal" => $numRec,"resultRoot" => $data
|
||||
);
|
||||
break;
|
||||
|
||||
case "EMPTY":
|
||||
$status = 1;
|
||||
|
||||
try {
|
||||
$file = PATH_DATA . "log" . PATH_SEP . "cron.log";
|
||||
|
||||
if (file_exists($file)) {
|
||||
if (file_exists( $file )) {
|
||||
//file_put_contents($file, null);
|
||||
unlink($file);
|
||||
unlink( $file );
|
||||
}
|
||||
|
||||
$response["status"] = "OK";
|
||||
@@ -211,5 +193,5 @@ switch ($option) {
|
||||
break;
|
||||
}
|
||||
|
||||
echo G::json_encode($response);
|
||||
echo G::json_encode( $response );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user