', 0); add_javascript('', 0); add_javascript('', 0); add_javascript('', 0); add_javascript('', 0); add_javascript('', 0); if (!($graph == 'line' || $graph == 'bar')) $graph = 'line'; if ($graph == 'bar') { // 바 타입으로 사용하는 코드입니다. add_javascript('', 0); add_javascript('', 0); add_javascript('', 0); } $g5['title'] = '글,댓글 현황'; include_once "./admin.head.php"; $period_array = array( '오늘' => 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), ); $is_period = false; foreach ($period_array as $key => $value) { if ($key == $period) { $is_period = true; break; } } if (!$is_period) $period = '오늘'; $day = $period_array[$period][0]; $today = date('Y-m-d', G5_SERVER_TIME); $yesterday = date('Y-m-d', G5_SERVER_TIME - 86400); if ($period == '오늘') { $from = $today; $to = $from; } else if ($period == '어제') { $from = $yesterday; $to = $from; } else if ($period == '내일') { $from = date('Y-m-d', G5_SERVER_TIME + (86400 * 2)); $to = $from; } else { $from = date('Y-m-d', G5_SERVER_TIME - (86400 * $period_array[$period][1])); $to = $yesterday; } $sql_bo_table = ''; if ($bo_table) $sql_bo_table = "and bo_table = '$bo_table'"; switch ($day) { case '시간': $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 "; $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 '일': $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 "; $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 '주': $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 "; $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 '월': $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 "; $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 '년': $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 "; $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; } ?>