function sig_handler($signo) { $log = getLog('queue/queued'); $log->setData("\r\n" . 'Signal Receive:' . $signo . ' ' . date('Y-m-d H:i:s')); $pids = @file(ROOT . 'logs/queue/pids'); if (is_array($pids)) { foreach ($pids as $pid) { list(, , $pid) = explode('_', $pid); if (!empty($pid)) { $pid = intval($pid); @posix_kill($pid, SIGTERM); if (file_exists(ROOT . 'logs/queue/pid/' . $pid)) { @unlink(ROOT . 'logs/queue/pid/' . $pid); } } } } switch ($signo) { case SIGHUP: @popen(ROOT . 'daemon/queue/queued.php 2>&1 > /dev/null &', "r"); break; } $log->setData("\r\n" . 'Signal Process Finished:' . date('Y-m-d H:i:s'))->write(); exit; }
public function testServices() { $ins = getAuth(); $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Auth\IAuth::class, $ins); $ins = getView(); $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\View\IView::class, $ins); $ins = getLog(); $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Log\ILog::class, $ins); // $ins = getDB(); // $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Database\MedooDB::class, $ins); // $ins = getRedis(); // $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Database\PRedis::class, $ins); // $ins = getDataPool(); // $this->assertInstanceOf(\Wwtg99\DataPool\Common\IDataPool::class, $ins); $ins = getCache(); $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\Cache::class, $ins); $ins = getSession(); $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\SessionUtil::class, $ins); $ins = getCookie(); $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\CookieUtil::class, $ins); $ins = getOValue(); $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Storage\OldValue::class, $ins); $ins = getAssets(); $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\View\AssetsManager::class, $ins); $ins = getMailer(); $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Utils\Mail::class, $ins); $ins = Flight::Express(); $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Utils\Express::class, $ins); $ins = getPlugin('php'); $this->assertInstanceOf(\Wwtg99\Flight2wwu\Component\Plugin\IPlugin::class, $ins); }
/** * Output function * * @param $type * @param $data */ protected function output($type, $data) { if ($type === Process::ERR) { getLog()->error($data); } else { getLog()->info($data); } }
function __construct() { global $cfg; // squid 服务器列表 $this->squid = $cfg['squid']; //日志操作句柄 $this->log = getLog('squid'); }
/** * gets log and returns messages in an array * @param string $s pre-fetched log contents * @return array list of message strings */ function parseLog($s = null) { if (!$s) { $s = getLog(); } $temp = explode("\n", $s); array_pop($temp); $return = array(); foreach ($temp as $x) { if ($x != '') { $tempo = explode('] ', $x); if (isset($tempo[1])) { $return[] = trim($tempo[1]); } } } return $return; }
/** * Ich bin die Mainfunktion und werde beim Starten dieses Scripts ausgefuehrt */ function main() { $fn = pathinfo(strip_tags($_GET['show'])); $fn = $fn['filename']; if (isset($_GET['show'])) { if ($fn == "latest") { $fn = getLatestFile(); } $title = "Log vom " . $fn; $content = getLog($_GET['show']); } else { $title = "Channellog"; $files = @scandir(LOGDIR); rsort($files); foreach ($files as $file) { if (!strstr($file, ".")) { $day = substr($file, 5, 2) % 2; $content .= "<tt class='color" . $day . "'><a href=show/{$file}>{$file}</a><br /></tt>"; } } } echo fillTpl(array($title, $content)); }
function rejectList() { $query = "SELECT pp_kod,pp_ref_no,pp_tkh_submit,pp_nama,rkatp_desc,rkatp_class FROM p_product\n LEFT JOIN ref_kat_produk ON pp_rkatp_kod = rkatp_kod\n LEFT JOIN p_product_manu ON p_product_manu.ppm_pp_kod = p_product.pp_kod AND ppm_rmr_kod=1\n LEFT JOIN o_syarikat_add ON o_syarikat_add.osa_kod = p_product_manu.ppm_osa_kod\n LEFT JOIN o_syarikat ON o_syarikat.os_kod = o_syarikat_add.osa_os_kod\n WHERE pp_rs_kod IN(1102) AND rkatp_sample_applicable = 1\n GROUP BY pp_kod"; ?> <div class="tab-content pn br-n admin-form"> <input type="hidden" id="mainTitle" value="<?php echo sampleTitle(1, 2); ?> "> <div class="row"> <table class="table table-striped table-bordered table-hover" id="primary" cellspacing="0" width="100%"> <thead> <tr class="alert" align="center"> <td width="5%">No</td> <td width="10%">Call No</td> <td width="65%">Product Name</td> <td width="10%">Send Date</td> <td width="10%">Reject Date</td> </tr> </thead> <tbody> <?php $count = 1; $result = selQuery($query); while ($row = mysqli_fetch_assoc($result)) { ?> <tr align="center"> <td><?php echo $count++; ?> </td> <td><?php echo $row['pp_kod']; ?> </td> <td align="left"> <div class="text-primary"> <b><?php echo $row['pp_nama']; ?> </b> </div> <div class="text-muted"> <?php echo $row['rkatp_desc'] . " - " . $row['rkatp_class']; ?> </div> </td> <td><?php echo displayDate($row['pp_tkh_submit']); ?> </td> <td><?php echo getLog(1102, $row['pp_kod']); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <div class="col-md-12"> </div> <div class="row" align="right"> <div class="btn-group"> <button type="button" class="btn btn-alert dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> Action <span class="caret ml5"></span> </button> <ul class="dropdown-menu" role="menu"> <li><a style="cursor:pointer" onclick="screenList(1)">In Tray</a></li> <li><a style="cursor:pointer" onclick="screenList(2)">Rejected List</a></li> </ul> </div> </div> </div> <?php }
function logPerformance($script_stats) { $log = "<log>\n <date>" . date("Y-m-d H:i:m") . "</date>\n <memory>" . $script_stats['memory'] . "</memory>\n <file>" . $script_stats['file'] . "</file>\n <function>" . $script_stats['function'] . "</function>\n <called_by>" . $script_stats['called_by'] . "</called_by>\n <microsecond>" . $script_stats['ns'] . "</microsecond>\n</log>" . PHP_EOL; fwrite(getLog(LOG_PERFORMANCE), $log); }
//check if there is data still $system = getModule("system"); $is_ready = $system->checkReady(); if ($is_ready && $console && count($argv) > 1 && $argv[1] == "upgrade") { showMessage("Upgrading system...", "primary"); $system->upgradeSystem(); showMessage("System upgraded", "success"); die($end_string); } if ($is_ready && !$force) { showMessage("All modules seem ready, nothing to do.", "warning"); die($end_string); } //RESTART if ($force || !$is_ready) { clearDebugLog(); showMessage("Creating databases and folders", "primary"); $system->restartSystem(); //READY if ($system->checkReady()) { showMessage("LiteFileServer installed, you can go to the <a href='index.html'>main page</a>.", "success"); } else { showMessage("Something went wrong.", "warning"); if (!$console) { echo '<div class="bs-callout bs-callout-<?=$type?>" id="callout-glyphicons-empty-only">' . getLog() . "</div>"; } } } if (!$console) { echo $end_string; }
function process_risk_information_notification($response) { getLog('store.response.log')->log(print_r($response, true), Zend_Log::DEBUG); }
public function __construct() { $this->log = getLog('sendmail'); }
/** * Execute the statements contained in the given file. * @param array file * an sql file * @access protected */ protected function executeSqlFiles(&$files) { $this->getLog()->debug("List of SQL files: " . implode(", ", $files)); if (!is_array($files)) { $this - getLog()->err('executeSqlFile(): parameter has to be an array'); return; } $this->getLog()->debug("Get database connection"); $db = $this->getDbConnection(); $dir = $this->getSqlFileDir(); $success = false; foreach ($files as $f) { $absFile = $dir . '/' . $f; $this->getLog()->debug("Processing file " . $absFile); $lines = file($absFile); $sql = ""; foreach ($lines as $line) { if (trim($line) == "" || strpos($line, "--") !== false) { continue; } $sql .= $line; if (strrpos($sql, ";") !== false) { // trim and remove the ; at the end $sql = substr(trim($sql), 0, -1); $this->getLog()->debug("Executing ... " . str_replace("\n", "", $sql)); if ($db->execute($sql) === false) { $this->getLog()->debug("Failure: " . $db->ErrorMsg()); $success = false; break; } $this->getLog()->debug("Success."); $success = true; $sql = ""; } } } return $success; }
<?php include 'include/global.php'; include 'include/function.php'; if (isset($_GET['action']) && $_GET['action'] == 'index') { ?> <script type="text/javascript"> $('title').html('Log'); </script> <?php $log = getLog(); if (count($log) > 0) { echo "<div class='row'>" . "<div class='col-md-12'>" . "<table class='table table-bordered table-hover'>" . "<thead>" . "<tr>" . "<th class='col-md-4'>Log Time</th>" . "<th class='col-md-4'>Username</th>" . "<th class='col-md-4'>Data</th>" . "</tr>" . "</thead>" . "<tbody>"; foreach ($log as $row) { echo "<tr>" . "<td>" . $row['log_time'] . "</td>" . "<td>" . $row['user_name'] . "</td>" . "<td><code>" . $row['data'] . "</code></td>" . "</tr>"; } echo "</tbody>" . "</table>" . "</div>" . "</div>"; } else { echo 'Log Empty'; } }
if ($logger instanceof \Wwtg99\Flight2wwu\Component\Log\Monolog) { $collector = new \DebugBar\Bridge\MonologCollector($logger->getLogger('main')); foreach ($logger->getLogger(null) as $name => $l) { if ($name != 'main') { $collector->addLogger($l); } } $debugbar['messages']->aggregate($collector); } Flight::set('debugbar', $debugbar); } // handle error \Flight::map('error', function (\Exception $ex) { $max_log = 100; getLog()->error(sprintf('Error (%s) message: %s', $ex->getCode(), $ex->getMessage())); getLog()->error($ex->getTraceAsString()); $m = $ex->getMessage(); if (strlen($m) > $max_log) { $m = substr($m, 0, $max_log) . '...'; } $msg = sprintf('<h1>500 Internal Server Error</h1><h3>%s (%s)</h3>', $m, $ex->getCode()); try { if (Flight::request()->ajax) { \Flight::json(['error' => ['message' => T($m), 'code' => $ex->getCode()]], 200, true, 'utf8', JSON_UNESCAPED_UNICODE); } else { $v = getView(); if ($v) { $v->render('error/500', ['message' => $m, 'code' => $ex->getCode(), 'title' => 'Error']); } else { echo T($msg); }
/** * @param $id */ public function enable($id) { $p = $this->getPluginConfig($id); $name = $p['server_name']; $cls = $p['class_name']; $nm = $p['name']; try { $ins = new \ReflectionClass($cls); $ins = $ins->newInstance(); if ($ins instanceof IPlugin) { $this->enables[$name] = [$id, $ins]; $p['enabled'] = true; $this->setPluginConfig($id, $p); } } catch (\Exception $e) { getLog()->warning("unable to start plugin {$nm}"); } }
public static function forDebug($message, $needVarDump = false) { $output = ob_get_contents(); @ob_end_clean(); ob_start(); echo "<ID:" . UserParameters::getUserId() . ">\n"; echo get_caller_method(); echo '<print>' . PHP_EOL; print_r($message); echo '</print>' . PHP_EOL; if ($needVarDump) { echo '<var_dump>' . PHP_EOL; var_dump($message); echo '</var_dump>' . PHP_EOL; } echo "</ID:" . UserParameters::getUserId() . ">\n"; $outputDebug = ob_get_contents(); ob_end_clean(); ob_start(); fwrite(getLog(LOG_USER_DEBUG), $outputDebug . PHP_EOL . PHP_EOL); echo $output; }
$application = Engine_Api::getInstance()->getApplication(); //$application = Engine_Api::getInstance()->getApplication(); $application->getBootstrap()->bootstrap('frontcontroller'); $application->getBootstrap()->bootstrap('cache'); $application->getBootstrap()->bootstrap('db'); $application->getBootstrap()->bootstrap('translate'); $application->getBootstrap()->bootstrap('frontcontrollermodules'); $application->getBootstrap()->bootstrap('session'); $application->getBootstrap()->bootstrap('manifest'); $application->getBootstrap()->bootstrap('router'); $application->getBootstrap()->bootstrap('view'); $application->getBootstrap()->bootstrap('layout'); $application->getBootstrap()->bootstrap('modules'); function getLog($filename = 'store.notify.log') { $writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/' . $filename); return new Zend_Log($writer); } require_once APPLICATION_PATH . '/application/modules/Socialstore/externals/scripts/library/googlemerchantcalculations.php'; require_once APPLICATION_PATH . '/application/modules/Socialstore/externals/scripts/library/googleresult.php'; require_once APPLICATION_PATH . '/application/modules/Socialstore/externals/scripts/library/googlerequest.php'; require_once APPLICATION_PATH . '/application/modules/Socialstore/externals/scripts/library/googleresponse.php'; $Gresponse = new GoogleResponse(); $xml_response = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : file_get_contents("php://input"); if (get_magic_quotes_gpc()) { $xml_response = stripslashes($xml_response); } $response = $Gresponse->GetParsedXML($xml_response); getLog('store.response.log')->log(var_dump($response, true), Zend_Log::DEBUG); ?>
/** * Update specific item. * Method Post * @param $id * @return mixed */ public function update($id) { if (self::getRequest()->checkMethod('PUT')) { $d = self::getRequest()->getArrayInput($this->updateFields); $data = $this->updateResource($id, $d); if ($data instanceof Message) { return self::getResponse()->setResType('json')->setResCode(200)->setData(TA($data->toApiArray()))->send(); } elseif ($data) { return self::getResponse()->setResType('json')->setResCode(201)->setData($data)->send(); } else { return self::getResponse()->setResType('json')->setResCode(500)->setData(TA(Message::messageList(1)->toApiArray()))->send(); } } elseif (self::getRequest()->checkMethod('PATCH')) { $d = self::getRequest()->getArrayInputN($this->updateFields); $data = $this->updateResource($id, $d); getLog()->warning('===' . print_r($data, true)); if ($data instanceof Message) { return self::getResponse()->setResType('json')->setResCode(200)->setData(TA($data->toApiArray()))->send(); } elseif ($data) { return self::getResponse()->setResType('json')->setResCode(201)->setData($data)->send(); } else { return self::getResponse()->setResType('json')->setResCode(500)->setData(TA(Message::messageList(1)->toApiArray()))->send(); } } else { \Flight::redirect(U('405')); } return false; }
//just to remember we need this IPP_LOG($system_message, $_SESSION['egps_username'], 'ERROR'); } if ($szLevel == "ALL") { $log_query = "SELECT * FROM error_log WHERE 1=1"; } else { $log_query = "SELECT * FROM error_log WHERE level='{$szLevel}'"; } $log_result = mysql_query($log_query); if (!$log_result) { $error_message = "Database query failed (" . __FILE__ . ":" . __LINE__ . "): " . mysql_error() . "<BR>Query: '{$log_query}'<BR>"; return NULL; } return mysql_num_rows($log_result); } $sqlLog = getLog(); if (!$sqlLog) { $system_message = $error_message; IPP_LOG($system_message, $_SESSION['egps_username'], 'ERROR'); } $sqlLogTotals = getLogTotals(); //set back vars... $szBackGetVars = ""; foreach ($_GET as $key => $value) { $szBackGetVars = $szBackGetVars . $key . "=" . $value . "&"; } //strip trailing '&' $szBackGetVars = substr($szBackGetVars, 0, -1); ?> <!DOCTYPE HTML>
/** * Add twig extended functions */ protected function addFunctions() { // isDebug $func = new \Twig_SimpleFunction('isDebug', function () { return isDebug(); }); $this->twig->addFunction($func); // debugbarHead $func = new \Twig_SimpleFunction('debugbarHead', function () { $debugbar = \Flight::get('debugbar'); if ($debugbar) { $debugRender = $debugbar->getJavascriptRenderer(); $debugRender->setBaseUrl(U('assets/debugbar')); return $debugRender->renderHead(); } return ''; }, ['is_safe' => ['html']]); $this->twig->addFunction($func); // renderDubugbar $func = new \Twig_SimpleFunction('renderDebugbar', function () { $debugbar = \Flight::get('debugbar'); if ($debugbar) { $debugRender = $debugbar->getJavascriptRenderer(); return $debugRender->render(); } return ''; }, ['is_safe' => ['html']]); $this->twig->addFunction($func); // renderAssets $func = new \Twig_SimpleFunction('renderAssets', function ($addlib = []) { $ass = getAssets(); if ($addlib) { $ass->addLibrary($addlib); } return $ass->renderCss() . $ass->renderJs(); }, ['is_safe' => ['html']]); $this->twig->addFunction($func); // get resource $func = new \Twig_SimpleFunction('resource', function ($name, $prefix = '') { return getAssets()->getResource($name, $prefix); }); $this->twig->addFunction($func); // isLogin $func = new \Twig_SimpleFunction('isLogin', function () { return getAuth()->isLogin(); }); $this->twig->addFunction($func); // isSuperuser $func = new \Twig_SimpleFunction('isSuperuser', function () { return getAuth()->isSuperuser(); }); $this->twig->addFunction($func); // hasRole $func = new \Twig_SimpleFunction('hasRole', function ($role) { return getAuth()->hasRole($role); }); $this->twig->addFunction($func); // getConfig $func = new \Twig_SimpleFunction('getConfig', function ($name) { return \Flight::get('config')->get($name); }); $this->twig->addFunction($func); // getUser $func = new \Twig_SimpleFunction('getUser', function () { return getAuth()->getUser(); }); $this->twig->addFunction($func); // old value $func = new \Twig_SimpleFunction('old', function ($name, $def = '') { return getOld($name, $def); }); $this->twig->addFunction($func); // log $func = new \Twig_SimpleFunction('log', function ($level, $msg, $context = []) { return getLog()->log($level, $msg, $context); }); $this->twig->addFunction($func); }
function writeLog($client, $s3bucket, $key, $time) { $arr = explode(" ", $time); $log = getLog($client, $s3bucket, $time); // $key = str_replace("/", ":", $key); $log[$key] = $time; $log = json_encode($log); saveLog($client, $s3bucket, $log, $time); }
for ($i = 0; $i < $NumFiles; $i++) { $files[] = array('name' => $path . "/" . $argv[3 + 3 * $i], 'previous' => $argv[4 + 3 * $i], 'actual' => $argv[5 + 3 * $i]); } } // Our POSTer in Gforge $snoopy = new Snoopy(); if ($use_ssl) { $http = "https://"; } else { $http = "http://"; } $SubmitUrl = util_make_url('/plugins/cvstracker/newcommit.php'); $UserArray = posix_getpwuid(posix_geteuid()); $UserName = $UserArray['name']; $Input = file_get_contents("/dev/stdin"); $Log = getLog($Input); $tasks_involved = getInvolvedTasks($Log); $artifacts_involved = getInvolvedArtifacts($Log); if ((!is_array($tasks_involved) || count($tasks_involved) < 1) && (!is_array($artifacts_involved) || count($artifacts_involved) < 1)) { //nothing to post die("No artifacts nor tasks in the commit log\n"); } $i = 0; foreach ($files as $file) { $SubmitVars[$i]["UserName"] = $UserName; $SubmitVars[$i]["Repository"] = $repository; $SubmitVars[$i]["FileName"] = $file['name']; $SubmitVars[$i]["PrevVersion"] = $file['previous']; $SubmitVars[$i]["ActualVersion"] = $file['actual']; $SubmitVars[$i]["Log"] = $Log; $SubmitVars[$i]["TaskNumbers"] = getInvolvedTasks($Log);
print $LOG_FILE; break; case "Tune": $args = array("flag_training" => 0, "flag_tuning" => 1, "flag_recaser" => 0, "id" => $_POST["train_id"], "lm_factor" => $_POST["lm_factor"], "lm_order" => $_POST["lm_order"], "src" => $_POST["src_lang"], "target" => $_POST["tar_lang"], "corpus_training" => $_POST["train_corpus_name"], "corpus_tuning" => $_POST["tune_corpus_name"], "alignment" => $_POST["alignment"], "reordering" => $_POST["reordering"], "with_irstlm" => $_POST["irstlm"], "with_kenlm" => $_POST["kenlm"]); saveConfig(getTrainingConfigFullPath(), $args); MosesCmdRun(getTrainingScriptFullPath(), getTrainingConfigFullPath()); print $LOG_FILE; break; case "Train+Tune": $args = array("flag_training" => 1, "flag_tuning" => 1, "flag_recaser" => 0, "id" => $_POST["train_id"], "lm_factor" => $_POST["lm_factor"], "lm_order" => $_POST["lm_order"], "src" => $_POST["src_lang"], "target" => $_POST["tar_lang"], "corpus_training" => $_POST["train_corpus_name"], "corpus_tuning" => $_POST["tune_corpus_name"], "alignment" => $_POST["alignment"], "reordering" => $_POST["reordering"], "with_irstlm" => $_POST["irstlm"], "with_kenlm" => $_POST["kenlm"]); saveConfig(getTrainingConfigFullPath(), $args); MosesCmdRun(getTrainingScriptFullPath(), getTrainingConfigFullPath()); print $LOG_FILE; break; case "Evaluate": $args = array("id" => $_POST["train_id"], "flag_recaser" => $_POST["recasing"], "flag_evaluation" => $_POST["evaluate"], "src" => $_POST["src_lang"], "target" => $_POST["tar_lang"], "corpus_recaser" => $_POST["recase_corpus_name"], "corpus_eval_src" => $_POST["eval_src_corpus_name"], "corpus_eval_ref" => $_POST["eval_ref_corpus_name"], "corpus_eval_tst" => $_POST["eval_tst_corpus_name"], "evaluation_tool" => $_POST["evaluation_tool"]); saveConfig(getEvaluationConfigFullPath(), $args); MosesCmdRun(getEvaluationScriptFullPath(), getEvaluationConfigFullPath()); print $LOG_FILE; break; case "getTrainingList": print getTrainingList($_POST["src_lang"], $_POST["tar_lang"]); break; case "getAllResults": print getEvalResults($_POST["src_lang"], $_POST["tar_lang"]); break; case "getResult": getLog($_POST["log_file"]); break; } return 0;
function getCommitDate($rev2 = null, $force = false) { $log = getLog($rev2); $domObj = new xmlToArrayParser(implode("\n", $log)); $domArr = $domObj->array; if (isset($domArr['log']['logentry']['date'])) { return getHumanDate($domArr['log']['logentry']['date'], $force); } else { return t('noCommit'); } }