AvocadoAmber/AvocadoEdition_Light/adm/write_count.php

206 lines
7.9 KiB
PHP
Raw Normal View History

2022-09-17 20:50:50 +09:00
<?php
$sub_menu = '300820';
2024-09-23 11:07:19 +09:00
include_once "./_common.php";
2022-09-17 20:50:50 +09:00
check_demo();
auth_check($auth[$sub_menu], 'r');
// http://www.jqplot.com/
2024-09-19 20:57:39 +09:00
add_stylesheet('<link rel="stylesheet" href="' . G5_PLUGIN_URL . '/jqplot/jquery.jqplot.css">', 0);
add_javascript('<script src="' . G5_PLUGIN_URL . '/jqplot/jquery.jqplot.js"></script>', 0);
add_javascript('<script src="' . G5_PLUGIN_URL . '/jqplot/plugins/jqplot.canvasTextRenderer.min.js"></script>', 0);
add_javascript('<script src="' . G5_PLUGIN_URL . '/jqplot/plugins/jqplot.categoryAxisRenderer.min.js"></script>', 0);
add_javascript('<script src="' . G5_PLUGIN_URL . '/jqplot/plugins/jqplot.pointLabels.min.js"></script>', 0);
add_javascript('<!--[if lt IE 9]><script src="' . G5_PLUGIN_URL . '/jqplot/excanvas.js"></script><![endif]-->', 0);
2022-09-17 20:50:50 +09:00
if (!($graph == 'line' || $graph == 'bar'))
2024-09-19 20:57:39 +09:00
$graph = 'line';
2022-09-17 20:50:50 +09:00
if ($graph == 'bar') {
2024-09-19 20:57:39 +09:00
// 바 타입으로 사용하는 코드입니다.
add_javascript('<script src="' . G5_PLUGIN_URL . '/jqplot/jqplot.barRenderer.min.js"></script>', 0);
add_javascript('<script src="' . G5_PLUGIN_URL . '/jqplot/jqplot.categoryAxisRenderer.min.js"></script>', 0);
add_javascript('<script src="' . G5_PLUGIN_URL . '/jqplot/jqplot.pointLabels.min.js"></script>', 0);
2022-09-17 20:50:50 +09:00
}
$g5['title'] = '글,댓글 현황';
2024-09-23 11:07:19 +09:00
include_once "./admin.head.php";
2022-09-17 20:50:50 +09:00
$period_array = array(
2024-09-19 20:57:39 +09:00
'오늘' => array('시간', 0),
'어제' => array('시간', 0),
'7일전' => array('일', 7),
'14일전' => array('일', 14),
'30일전' => array('일', 30),
'3개월전' => array('주', 90),
'6개월전' => array('주', 180),
'1년전' => array('월', 365),
'2년전' => array('월', 365 * 2),
'3년전' => array('월', 365 * 3),
'5년전' => array('년', 365 * 5),
'10년전' => array('년', 365 * 10),
2022-09-17 20:50:50 +09:00
);
$is_period = false;
2024-09-19 20:57:39 +09:00
foreach ($period_array as $key => $value) {
if ($key == $period) {
$is_period = true;
break;
}
2022-09-17 20:50:50 +09:00
}
if (!$is_period)
2024-09-19 20:57:39 +09:00
$period = '오늘';
2022-09-17 20:50:50 +09:00
$day = $period_array[$period][0];
$today = date('Y-m-d', G5_SERVER_TIME);
$yesterday = date('Y-m-d', G5_SERVER_TIME - 86400);
if ($period == '오늘') {
2024-09-19 20:57:39 +09:00
$from = $today;
$to = $from;
2022-09-17 20:50:50 +09:00
} else if ($period == '어제') {
2024-09-19 20:57:39 +09:00
$from = $yesterday;
$to = $from;
2022-09-17 20:50:50 +09:00
} else if ($period == '내일') {
2024-09-19 20:57:39 +09:00
$from = date('Y-m-d', G5_SERVER_TIME + (86400 * 2));
$to = $from;
2022-09-17 20:50:50 +09:00
} else {
2024-09-19 20:57:39 +09:00
$from = date('Y-m-d', G5_SERVER_TIME - (86400 * $period_array[$period][1]));
$to = $yesterday;
2022-09-17 20:50:50 +09:00
}
$sql_bo_table = '';
if ($bo_table)
2024-09-19 20:57:39 +09:00
$sql_bo_table = "and bo_table = '$bo_table'";
2022-09-17 20:50:50 +09:00
switch ($day) {
2024-09-19 20:57:39 +09:00
case '시간':
2024-09-30 01:58:32 +09:00
$sql = "SELECT substr(bn_datetime,6,8) as hours, sum(if(wr_id=wr_parent,1,0)) as wcount, sum(if(wr_id=wr_parent,0,1)) as ccount FROM {$g5['board_new_table']} where substr(bn_datetime,1,10) between '$from' and '$to' {$sql_bo_table} group by hours order by bn_datetime ";
2024-09-19 20:57:39 +09:00
$result = sql_query($sql);
for ($i = 0; $row = sql_fetch_array($result); $i++) {
// 월-일 시간
$line1[] = "['" . substr($row['hours'], 0, 8) . "'," . $row['wcount'] . ']';
$line2[] = "['" . substr($row['hours'], 0, 8) . "'," . $row['ccount'] . ']';
}
break;
case '일':
2024-09-30 01:58:32 +09:00
$sql = "SELECT substr(bn_datetime,1,10) as days, sum(if(wr_id=wr_parent,1,0)) as wcount, sum(if(wr_id=wr_parent,0,1)) as ccount FROM {$g5['board_new_table']} where substr(bn_datetime,1,10) between '$from' and '$to' {$sql_bo_table} group by days order by bn_datetime ";
2024-09-19 20:57:39 +09:00
$result = sql_query($sql);
for ($i = 0; $row = sql_fetch_array($result); $i++) {
// 월-일
$line1[] = "['" . substr($row['days'], 5, 5) . "'," . $row['wcount'] . ']';
$line2[] = "['" . substr($row['days'], 5, 5) . "'," . $row['ccount'] . ']';
}
break;
case '주':
2024-09-30 01:58:32 +09:00
$sql = "SELECT concat(substr(bn_datetime,1,4), '-', weekofyear(bn_datetime)) as weeks, sum(if(wr_id=wr_parent,1,0)) as wcount, sum(if(wr_id=wr_parent,0,1)) as ccount FROM {$g5['board_new_table']} where substr(bn_datetime,1,10) between '$from' and '$to' {$sql_bo_table} group by weeks order by bn_datetime ";
2024-09-19 20:57:39 +09:00
$result = sql_query($sql);
for ($i = 0; $row = sql_fetch_array($result); $i++) {
// 올해의 몇주로 보여주면 바로 확인이 안되므로 주를 날짜로 바꾼다.
// 년-월-일
list($lyear, $lweek) = explode('-', $row['weeks']);
$date = date('y-m-d', strtotime($lyear . 'W' . str_pad($lweek, 2, '0', STR_PAD_LEFT)));
$line1[] = "['" . $date . "'," . $row['wcount'] . ']';
$line2[] = "['" . $date . "'," . $row['ccount'] . ']';
}
break;
case '월':
2024-09-30 01:58:32 +09:00
$sql = "SELECT substr(bn_datetime,1,7) as months, sum(if(wr_id=wr_parent,1,0)) as wcount, sum(if(wr_id=wr_parent,0,1)) as ccount FROM {$g5['board_new_table']} where substr(bn_datetime,1,10) between '$from' and '$to' {$sql_bo_table} group by months order by bn_datetime ";
2024-09-19 20:57:39 +09:00
$result = sql_query($sql);
for ($i = 0; $row = sql_fetch_array($result); $i++) {
// 년-월
$line1[] = "['" . substr($row['months'], 2, 5) . "'," . $row['wcount'] . ']';
$line2[] = "['" . substr($row['months'], 2, 5) . "'," . $row['ccount'] . ']';
}
break;
case '년':
2024-09-30 01:58:32 +09:00
$sql = "SELECT substr(bn_datetime,1,4) as years, sum(if(wr_id=wr_parent,1,0)) as wcount, sum(if(wr_id=wr_parent,0,1)) as ccount FROM {$g5['board_new_table']} where substr(bn_datetime,1,10) between '$from' and '$to' {$sql_bo_table} group by years order by bn_datetime ";
2024-09-19 20:57:39 +09:00
$result = sql_query($sql);
for ($i = 0; $row = sql_fetch_array($result); $i++) {
// 년(4자리)
$line1[] = "['" . substr($row['years'], 0, 4) . "'," . $row['wcount'] . ']';
$line2[] = "['" . substr($row['years'], 0, 4) . "'," . $row['ccount'] . ']';
}
break;
2022-09-17 20:50:50 +09:00
}
?>
<div id="wr_cont">
2024-09-19 20:57:39 +09:00
<form>
2022-09-17 20:50:50 +09:00
<select name="bo_table">
2024-09-19 20:57:39 +09:00
<option value="">전체게시판</a>
<?php
2024-09-30 01:58:32 +09:00
$sql = "SELECT bo_table, bo_subject FROM {$g5['board_table']} ORDER BY bo_count_write DESC ";
2024-09-19 20:57:39 +09:00
$result = sql_query($sql);
for ($i = 0; $row = sql_fetch_array($result); $i++) {
echo "<option value=\"{$row['bo_table']}\"";
if ($bo_table == $row['bo_table'])
2022-09-17 20:50:50 +09:00
echo ' selected="selected"';
2024-09-19 20:57:39 +09:00
echo ">{$row['bo_subject']}</option>\n";
}
?>
2022-09-17 20:50:50 +09:00
</select>
<select name="period">
2024-09-19 20:57:39 +09:00
<?php
foreach ($period_array as $key => $value) {
2022-09-17 20:50:50 +09:00
echo "<option value=\"{$key}\"";
if ($key == $period)
2024-09-19 20:57:39 +09:00
echo " selected=\"selected\"";
2022-09-17 20:50:50 +09:00
echo ">{$key}</option>\n";
2024-09-19 20:57:39 +09:00
}
?>
2022-09-17 20:50:50 +09:00
</select>
<select name="graph">
2024-09-19 20:57:39 +09:00
<option value="line" <?php echo ($graph == 'line' ? 'selected="selected"' : ''); ?>>선그래프</option>
<option value="bar" <?php echo ($graph == 'bar' ? 'selected="selected"' : ''); ?>>막대그래프</option>
2022-09-17 20:50:50 +09:00
</select>
<input type="submit" class="btn_submit" value="확인">
2024-09-19 20:57:39 +09:00
</form>
<ul id="grp_color">
<li><span></span> </li>
<li class="color2"><span></span>댓글 </li>
</ul>
2022-09-17 20:50:50 +09:00
</div>
<br>
<div id="chart_wr">
2024-09-19 20:57:39 +09:00
<?php
if (empty($line1) || empty($line2)) {
2022-09-17 20:50:50 +09:00
echo "<h5>그래프를 만들 데이터가 없습니다.</h5>\n";
2024-09-19 20:57:39 +09:00
} else {
?>
<div id="chart1" style="height:500px; width:100%;"></div>
<div>
<script>
$(document).ready(function () {
var line1 = [<?php echo implode($line1, ','); ?>];
var line2 = [<?php echo implode($line2, ','); ?>];
var plot1 = $.jqplot('chart1', [line1, line2], {
2022-09-17 20:50:50 +09:00
seriesDefaults: {
2024-09-19 20:57:39 +09:00
<?php if ($graph == 'bar') { ?>
renderer: $.jqplot.BarRenderer,
<?php } ?>
pointLabels: { show: true }
2022-09-17 20:50:50 +09:00
},
2024-09-19 20:57:39 +09:00
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
label: '<?php echo $day; ?>',
pad: 0,
max: 23
},
yaxis: {
label: '글수',
min: 0
}
2022-09-17 20:50:50 +09:00
}
2024-09-19 20:57:39 +09:00
});
2022-09-17 20:50:50 +09:00
});
2024-09-19 20:57:39 +09:00
</script>
<?php
}
2022-09-17 20:50:50 +09:00
2024-09-23 11:07:19 +09:00
include_once "./admin.tail.php";
2024-09-19 20:57:39 +09:00
?>