function read_logs() { $array_query = array(); $db = new db_query('SELECT * FROM synchronize_trigger LIMIT 1'); $last_sync = mysqli_fetch_assoc($db->result); unset($db); if (!$last_sync) { $last_sync = 0; } else { $last_sync = $last_sync['syn_time']; } $time_string = getdate($last_sync); $sync_year = $time_string['year']; $sync_mon = $time_string['mon']; $sync_mday = $time_string['mday']; $sync_hours = $time_string['hours']; $link_log_sync = $_SERVER['DOCUMENT_ROOT'] . "/log/sync/"; if ($last_sync == 0) { //quét toàn bộ file trong thư mục log $list_file = directoryToArray($link_log_sync); } else { //lấy ra các file cần đọc log $list_file = array(); $from_date = $last_sync; $to_date = time(); $datePeriod = returnDates($from_date, $to_date); foreach ($datePeriod as $date) { $date = getdate($date->getTimestamp()); for ($i = 0; $i < 24; $i++) { if (file_exists($link_log_sync . $date['year'] . '/' . $date['mon'] . '/' . $date['mday'] . '/' . $i . '.log')) { $list_file[] = $link_log_sync . $date['year'] . '/' . $date['mon'] . '/' . $date['mday'] . '/' . $i . '.log'; } } } } foreach ($list_file as $file_log) { if (file_exists($file_log)) { $content = file_get_contents($file_log); $content = explode(PHP_EOL, $content); foreach ($content as $line) { list($time, $query) = explode('|', $line); //$query = decode_combine($query); if ($last_sync > $time) { continue; } $array_query[$time][] = $query; } } } return $array_query; }
$case = 1; if (isset($_GET['case'])) { $case = $_GET['case']; } $query = 0; if (isset($_GET['graphType'])) { $query = $_GET['graphType']; } $view = 0; if (isset($_GET['view'])) { $view = $_GET['view']; } //Each date between 2 date $dateRa = array(); $dateRaValue = array(); $datePeriod = returnDates($sdate, $edate); $a = sizeof($datePeriod); //print $a."<br>"; $b = 1; foreach ($datePeriod as $date) { //echo $date->format('Y-m-d'), PHP_EOL; //$dateRa[] = $date->format('Y-m-d'); if ($b != $a) { //echo $b.", ".$date; $dateRa[] = $date; } //echo "<br>"; $b++; } //print sizeof($dateRa)."<br>"; foreach ($dateRa as $eachDate) {
$case = 1; if (isset($_GET['case'])) { $case = $_GET['case']; } $query = 0; if (isset($_GET['graphType'])) { $query = $_GET['graphType']; } $view = 0; if (isset($_GET['view'])) { $view = $_GET['view']; } //Each date between 2 date $dateRa = array(); $dateRaValue = array(); $datePeriod = returnDates(substr($sdate, 0, 7) . "-01", $edate); $a = sizeof($datePeriod); $b = 1; foreach ($datePeriod as $date) { if ($b != $a) { $dateRa[] = substr($date, 0, 7); } $b++; } //print sizeof($dateRa)."<br>"; foreach ($dateRa as $eachDate) { //print $eachDate."<br>"; $dateRaValue[] = substr($eachDate, 5); } $strSQL = ''; $xbarValue = array();
} $query_country = 'SELECT id_country, audience_history FROM web_facebook_countries WHERE id_country < 247 ORDER BY 1;'; $que_country = db_query_table_results($query_country, array()); while ($row_country = mysql_fetch_assoc($que_country)) { $id_country = $row_country['id_country']; $audience_history = json_decode($row_country['audience_history'], true); $audience_history_data = explode(',', $audience_history['series_data']); $audience_history_axis = explode(',', str_replace("'", '', $audience_history['x_axis'])); $array_values = array(); $current_value = NULL; for ($i = 0, $limit = count($audience_history_data); $i < $limit; $i++) { $date = explode(' ', $audience_history_axis[$i]); $date[1] = getMesNumeric($date[1]); $array_values['20' . $date[2] . '-' . $date[1] . '-' . $date[0]] = $audience_history_data[$i]; } reset($array_values); $first_key = key($array_values); $date1 = $first_key; $date2 = '2015-01-22'; $datePeriod = returnDates($date1, $date2); foreach ($datePeriod as $date) { if (isset($array_values[$date->format('Y-m-d')])) { $current_value = $array_values[$date->format('Y-m-d')]; } $query = 'INSERT INTO facebook_record_country_3_1 VALUES($1, $2, NULL, NULL, \'$3\');'; $row = db_query($query, array($id_country, $current_value, $date->format('Y-m-d')), 1); } }
<?php require_once 'config.php'; function returnDates($from_timestamp, $to_timestamp) { $fromdate = new DateTime(); $fromdate->setTimestamp($from_timestamp); $todate = new DateTime(); $todate->setTimestamp($to_timestamp); return new \DatePeriod($fromdate, new \DateInterval('P1D'), $todate->modify('+1 day')); } $to_date = time(); $from_date = time() - 86400 * 20; //lấy ra các file cần đọc log $list_file = array(); $datePeriod = returnDates($from_date, $to_date); $list_date = array(); foreach ($datePeriod as $date) { $date = getdate($date->getTimestamp()); for ($i = 0; $i < 24; $i++) { $list_file[] = $date['year'] . '/' . $date['mon'] . '/' . $date['mday'] . '/' . $i . '.log'; } } var_dump($list_file);
?> <table width="100%" id="general_last" border="1" style="border-collapse:collapse;" bordercolor="#10A062" cellpadding="0" cellspacing="0"> <thead class="flip-content"> <tr> <th style="text-align:left;">Name of Department</th> <th>Attendance</th> <th>Salary</th> <th>Overtime</th> <th>Total</th> <th>Advance</th> <th>Balance</th> </tr> </thead> <tbody> <?php $datePeriod = returnDates($from, $to); foreach($datePeriod as $date) { $all_dates[]=$date->format('d-m-Y'); } $result=mysql_query("select * from `department` order by `id`"); while($row=mysql_fetch_array($result)) {$i++; $all_reg=""; $all_emp=mysql_query("select distinct `id` from `registration` where `depart_id`='".$row['id']."'"); while($row_emp=@mysql_fetch_array($all_emp)) { $all_reg[]=$row_emp['id']; }