get() static public method

读取文件信息
static public get ( string $filename, string $name, $type = '' ) : boolean
$filename string 文件名
$name string 信息名 mtime或者content
return boolean
Beispiel #1
0
 function query()
 {
     $log = new Log();
     $log->pagename = get_query_var('pagename');
     $data = $log->get();
     $this->total = count($data);
     return $data;
 }
Beispiel #2
0
 public function testLaunchFile()
 {
     \Core::require_file('core', 'Tools\\Log.php');
     \Log::drop();
     \Log::record('CoreTest', 'Just a test');
     $log = \Log::get();
     $datetime = date('d-m-Y H:i:s');
     $this->assertEquals($log, "[{$datetime}] : Just a test (CoreTest)\r\n");
 }
Beispiel #3
0
 function truncate()
 {
     if (is_writable($this->fileName)) {
         unlink($this->fileName);
     }
 }
 /**
  * Get log with specified name
  * @param $name
  * @return Log
  */
 static function get($name)
Beispiel #4
0
 public function displayDebugger()
 {
     $data['memory'] = $this->getMemory();
     $data['brightery_version'] = $this->getFrameworkVersion();
     $data['php_version'] = $this->getPhpVersion();
     $data['status_code'] = $this->getStatusCode();
     $data['route'] = $this->getRoute();
     $data['execution_time'] = $this->getExecutionTime();
     $data['config'] = $this->getConfiguration();
     $data['queries'] = $this->getDatabase();
     $data['phpinfo'] = $this->getPHPinfo();
     $data['mac_address'] = $this->getMacAddress();
     $data['db_connection'] = $this->getCurrentConnections();
     $data['log'] = Log::get();
     $data['assets'] = $this->getAssets();
     return Brightery::loadFile([ROOT, 'styles', 'system', 'debug.php'], false, $data);
 }
Beispiel #5
0
 /**
  * Dashboard view
  * Check if an user is logged
  * and if he is an admin : redirect to login page if failed.
  */
 public function index()
 {
     Tools::admin_logged();
     $user = Session::get('user');
     if (Tools::is_admin($user)) {
         $post = Tools::data();
         if (!empty($post)) {
             if ($post['action'] === 'dropLog') {
                 return json_encode(array('status' => Log::drop()));
             }
         }
         // ADMIN VIEW
         $datas = array('title' => 'Admin Dashbord', 'user' => $user, 'log' => Tools::format(Log::get(10), 'html'));
         $this->__view->set_content_type("html")->set_template('admin/bo/default.tpl');
         $this->__view->set_body('admin', 'bo/index.tpl');
         $this->__view->set_js(array('admin/index.js'));
         $this->__view->attach_data($datas);
         return $this->display();
     }
 }
Beispiel #6
0
 public function doNow()
 {
     if (!isset($this->id)) {
         throw new JobHandlerException("Jobs doesn't exists");
     }
     DB::query('update ' . DelayedJob::TABLE . ' set locked_at="' . date("Y-m-d H:i:s") . '" where id="' . $this->id . '"');
     include_once $this->handler['file'];
     Log::get('dj')->info(" DelayedJob start working.Class " . $this->handler['class'] . " run the method " . $this->handler['method'] . "()");
     Log::get('dj')->info(" Cheking the queue.Quie " . $this->queue . " is free");
     $counter = $this->attempts;
     while ($counter > 0) {
         try {
             Log::get('dj')->info(" There are " . $counter . " attempts.");
             $counter--;
             DB::query('update ' . DelayedJob::TABLE . ' set attempts=attempts-1 where id="' . $this->id . '"');
             if (isset($this->handler['param'])) {
                 $ret = call_user_func_array(array($this->handler['class'], $this->handler['method']), $this->handler['param']);
             }
             if (!$ret) {
                 DB::query('update ' . DelayedJob::TABLE . ' set failed_at="' . date("Y-m-d H:i:s") . '" where id="' . $this->id . '"');
                 Log::get('dj')->error("Command was completed  with error (" . var_export($ret, true) . ")![ FAILED ]");
             } else {
                 DB::query('update ' . DelayedJob::TABLE . ' set finished_at="' . date("Y-m-d H:i:s") . '", failed_at = null where id="' . $this->id . '"');
                 Log::get('dj')->info(" Command was completed successfully![ OK ]");
                 break 1;
             }
         } catch (Exception $e) {
             Log::get('dj')->error("Work is Fail [ FAILED ]");
             Log::get('dj')->error('Message: ' . $e->getMessage());
             continue;
         }
     }
 }
Beispiel #7
0
<?php

include_once '../system/config.php';
include_once '../system/functions.php';
$order = '';
$prefix = 'log02';
$objLog = new Log();
$_data = $objLog->get();
echo json_encode($_data);
Beispiel #8
0
 public function testDropLog()
 {
     \Log::drop();
     $log = \Log::get();
     $this->assertEquals($log, '');
 }
Beispiel #9
0
 /**
  * Insert into database all fields need to work. Run the JobHandler immediatly if 
  * unset run time. Else run JobHandler with system command 'at' with set time.
  * @param null
  * @return null
  */
 public function add()
 {
     $config_php_path = Config::get("php_cli_path");
     $php_path = exec("which php");
     if (empty($php_path) || !is_executable($php_path)) {
         $php_path = $config_php_path;
     }
     // Config::get("php_path");
     if (empty($php_path) || !is_executable($php_path)) {
         Log::get('dj')->error("PHP executable not found or could not be executed");
         throw new DelayedJobException("PHP executable not found");
     }
     if (empty($this->at)) {
         $sql = "INSERT INTO " . self::TABLE . "(priority,handler,run_at,queue,attempts) values( ? , ? , now() , ? , ?)";
         $stmt = DB::getStmt($sql, 'issi');
         $stmt->execute(array($this->getPriority(), serialize($this->getHandler()), $this->getQueue(), $this->getAttempts()));
         Log::get('dj')->info(" =======================");
         Log::get('dj')->info(" Call the JobHandler.php");
         exec($php_path . ' ' . trim(escapeshellarg(dirname(__FILE__) . "/JobHandler.php"), "'") . ' >> ' . $this->logFile . ' 2>&1 &');
     } else {
         $sql = "INSERT INTO " . self::TABLE . "(priority,handler,run_at,queue,attempts) values(? , ? , FROM_UNIXTIME( ? ) , ? , ? )";
         $stmt = DB::getStmt($sql, 'isssi');
         $stmt->execute(array($this->getPriority(), serialize($this->getHandler()), $this->getAt(), $this->getQueue(), $this->getAttempts()));
         Log::get('dj')->info(" =======================");
         Log::get('dj')->info(" Call command at for the JobHandler.php");
         Log::get('dj')->info(" =======================");
         exec('echo "' . $php_path . ' ' . trim(escapeshellarg(dirname(__FILE__) . '/JobHandler.php'), "'") . ' 2>&1 >> ' . $this->logFile . ' " | at ' . $this->getAtSys());
     }
 }
Beispiel #10
0
     $query_count = DBManager::get()->query_count;
     Metrics::gauge('core.database.queries', $query_count, 0.1);
 }, Metrics::startTimer());
 require 'lib/phplib/page_open.php';
 StudipFileloader::load('config_local.inc.php', $GLOBALS, compact('STUDIP_BASE_PATH'));
 require 'config.inc.php';
 require_once 'lib/functions.php';
 require_once 'lib/language.inc.php';
 require_once 'lib/visual.inc.php';
 require_once 'lib/deputies_functions.inc.php';
 //setup default logger
 Log::get()->setHandler($GLOBALS['TMP_PATH'] . '/studip.log');
 if (Studip\ENV == 'development') {
     Log::get()->setLogLevel(Log::DEBUG);
 } else {
     Log::get()->setLogLevel(Log::ERROR);
 }
 // set default time zone
 date_default_timezone_set($DEFAULT_TIMEZONE ?: @date_default_timezone_get());
 // set assets url
 Assets::set_assets_url($GLOBALS['ASSETS_URL']);
 // globale template factory anlegen
 require_once 'vendor/flexi/lib/flexi.php';
 $GLOBALS['template_factory'] = new Flexi_TemplateFactory($STUDIP_BASE_PATH . '/templates');
 // set default exception handler
 // command line or http request?
 if (isset($_SERVER['REQUEST_METHOD'])) {
     set_exception_handler('studip_default_exception_handler');
 }
 // set default pdo connection
 DBManager::getInstance()->setConnection('studip', 'mysql:host=' . $GLOBALS['DB_STUDIP_HOST'] . ';dbname=' . $GLOBALS['DB_STUDIP_DATABASE'], $GLOBALS['DB_STUDIP_USER'], $GLOBALS['DB_STUDIP_PASSWORD']);
Beispiel #11
0
<div class="col-md-12">
	<?php 
$obj = new Log();
$data = $obj->get();
?>

    <table id="table-content" class="display table-bordered table-hover table-striped" cellspacing="0" width="100%">
        <thead>
			<tr>
				<th>Uin</th>
				<th>Tablename</th>
				<th>Field</th>
				<th>Action</th>
				<th>Value Before</th>
				<th>Value After</th>
				<th>Modified By</th>
				<th>Modified On</th>
			</tr>
        </thead>
        <tbody id="table-body">
			<?php 
foreach ($data as $value) {
    ?>
				<tr>
					<?php 
    foreach ($value as $v) {
        ?>

						<td>
							<?php 
        echo $v;
Beispiel #12
0
 public function send()
 {
     $this->send_headers(true);
     echo $this->body();
     // todo: debug
     echo "\n<pre>\n" . Log::get() . "</pre>";
     flush();
 }
 /**
  * @brief runInfo 输出运行信息
  *
  * @return void
  */
 public function runInfo()
 {
     $run_time = number_format(microtime(TRUE) - LogX::$_globalVars['RUN']['TIME'], 4) * 1000;
     // DEBUG 模式下输出额外信息
     if (defined('LOGX_DEBUG')) {
         Log::add(_t('Process time:') . $run_time . 'ms.', E_USER_NOTICE);
         if (function_exists('memory_get_usage')) {
             $app_mem = memory_get_usage() - LogX::$_globalVars['RUN']['MEM'];
             Log::add(_t('Memory usage:') . $app_mem / 1024 . 'KB.', E_USER_NOTICE);
         }
         if (function_exists('memory_get_peak_usage')) {
             $app_mem = memory_get_peak_usage();
             Log::add(_t('Max memory usage:') . $app_mem / 1024 . 'KB.', E_USER_NOTICE);
         }
         Log::add(_t('Queries:') . Database::$querynum . '. ' . _t('Query time:') . Database::$querytime * 1000 . 'ms.', E_USER_NOTICE);
         $content = "以下是应用运行过程中的跟踪信息:\n\n";
         $content .= '当前页面:' . Request::S('REQUEST_URI', 'string') . "\n";
         $content .= '请求方法:' . Request::S('REQUEST_METHOD', 'string') . "\n";
         $content .= '通信协议:' . Request::S('SERVER_PROTOCOL', 'string') . "\n";
         $content .= '请求时间:' . date('Y-m-d H:i:s', Request::S('REQUEST_TIME', 'string')) . "\n";
         $content .= '用户代理:' . Request::S('HTTP_USER_AGENT', 'string') . "\n";
         $content .= "\n日志记录:\n\n";
         foreach (Log::get() as $log) {
             $content .= '[' . $log['LEVEL'] . '] ' . $log['MESSAGE'] . "\n";
         }
         $files = get_included_files();
         $content .= "\n加载文件:" . str_replace("\n", "\n", substr(substr(print_r($files, true), 7), 0, -2));
         if (function_exists('debug_backtrace')) {
             $content .= "\nBACKTRACE:\n\n" . var_export(debug_backtrace(), true);
         }
         echo $content;
     } else {
         echo 'Processed in ' . $run_time . ' ms, ' . Database::$querynum . ' queries.';
     }
 }
Beispiel #14
0
 public function execute($last_result, $parameters = array())
 {
     $verbose = $parameters['verbose'];
     $sets = DbManager::get()->fetchFirst("SELECT DISTINCT cr.set_id FROM courseset_rule cr INNER JOIN coursesets USING(set_id)\n                          WHERE type = 'ParticipantRestrictedAdmission' AND algorithm_run = 0");
     if (count($sets)) {
         if ($verbose) {
             echo date('r') . ' - Starting seat distribution ' . chr(10);
             $old_logger = Log::get()->getHandler();
             $old_log_level = Log::get()->getLogLevel();
             @mkdir($GLOBALS['TMP_PATH'] . '/seat_distribution_logs');
             $logfile = $GLOBALS['TMP_PATH'] . '/seat_distribution_logs/' . date('Y-m-d-H-i') . '_seat_distribution.log';
             if (is_dir($GLOBALS['TMP_PATH'] . '/seat_distribution_logs')) {
                 Log::get()->setHandler($logfile);
                 Log::get()->setLogLevel(Log::DEBUG);
                 echo 'logging to ' . $logfile . chr(10);
             } else {
                 echo 'could not create directory ' . $GLOBALS['TMP_PATH'] . '/seat_distribution_logs' . chr(10);
             }
         }
         foreach ($sets as $set_id) {
             $courseset = new CourseSet($set_id);
             if ($courseset->isSeatDistributionEnabled() && !$courseset->hasAlgorithmRun() && $courseset->getSeatDistributionTime() < time()) {
                 if ($verbose) {
                     echo ++$i . ' ' . $courseset->getId() . ' : ' . $courseset->getName() . chr(10);
                     $applicants = AdmissionPriority::getPriorities($set_id);
                     $courses = SimpleCollection::createFromArray(Course::findMany($courseset->getCourses()))->toGroupedArray('seminar_id', words('name veranstaltungsnummer'));
                     $captions = array(_("Nachname"), _("Vorname"), _("Nutzername"), _('Nutzer-ID'), _('Veranstaltung-ID'), _("Veranstaltung"), _("Nummer"), _("Priorität"));
                     $data = array();
                     $users = User::findEachMany(function ($user) use($courses, $applicants, &$data) {
                         $app_courses = $applicants[$user->id];
                         asort($app_courses);
                         foreach ($app_courses as $course_id => $prio) {
                             $row = array();
                             $row[] = $user->nachname;
                             $row[] = $user->vorname;
                             $row[] = $user->username;
                             $row[] = $user->id;
                             $row[] = $course_id;
                             $row[] = $courses[$course_id]['name'];
                             $row[] = $courses[$course_id]['veranstaltungsnummer'];
                             $row[] = $prio;
                             $data[] = $row;
                         }
                     }, array_keys($applicants), 'ORDER BY Nachname');
                     $applicants_file = $GLOBALS['TMP_PATH'] . '/seat_distribution_logs/applicants_' . $set_id . '.csv';
                     if (array_to_csv($data, $applicants_file, $captions)) {
                         echo 'applicants written to ' . $applicants_file . chr(10);
                     }
                 }
                 $courseset->distributeSeats();
             }
         }
         if ($verbose) {
             Log::get()->setHandler($old_logger);
             Log::get()->setLogLevel($old_log_level);
         }
     } else {
         if ($verbose) {
             echo date('r') . ' - Nothing to do' . chr(10);
         }
     }
 }