function getstatvars_forumstat($fid) { global $_G; $xml = "<chart>\n"; $statvars = array(); $monthdays = array('31', '29', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31'); if (!$fid) { $query = C::t('forum_forum')->fetch_all_fids(); $forums = array(); foreach ($query as $val) { $forums[] = array('fid' => $val['fid'], 'type' => $val['type'], 'name' => $val['name'], 'posts' => $val['posts']); } $statvars['forums'] = $forums; } else { $foruminfo = C::t('forum_forum')->fetch($fid); $statvars['foruminfo'] = array('fid' => $foruminfo['fid'], 'name' => $foruminfo['name'], 'posts' => $foruminfo['posts'], 'threads' => $foruminfo['threads'], 'todayposts' => $foruminfo['todayposts']); $current_date = $end_date = date('Y-m-d'); $current_month = $end_month = date('Y-m'); $current_month_start = $end_month_start = $current_month . '-01'; if ($_GET['month']) { $end_month = trim($_GET['month']); $month = substr($end_month, strpos($end_month, '-') + 1); $end_date = $end_month . '-' . $monthdays[$month - 1]; $end_month_start = $end_month . '-' . '01'; } $statvars['month'] = $end_month; $logs = array(); $xml .= "<xaxis>\n"; $xmlvalue = ''; $xaxisindex = 0; foreach (C::t('forum_statlog')->fetch_all_by_logdate($end_month_start, $end_date, $fid) as $log) { $logs[] = $log; list($yyyy, $mm, $dd) = explode('-', $log['logdate']); $xaxisindex++; $xml .= "<value xid=\"{$xaxisindex}\">{$mm}{$dd}</value>\n"; $xmlvalue .= "<value xid=\"{$xaxisindex}\">{$log['value']}</value>\n"; } $xml .= "</xaxis>\n"; $xml .= "<graphs>\n"; $xml .= "<graph gid=\"0\" title=\"" . diconv(lang('spacecp', 'do_stat_post_number'), CHARSET, 'UTF-8') . "\">\n"; $xml .= $xmlvalue; $xml .= "</graph>\n"; $xml .= "</graphs>\n"; $xml .= "</chart>\n"; if ($_GET['xml']) { @header("Expires: -1"); @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE); @header("Pragma: no-cache"); @header("Content-type: application/xml; charset=utf-8"); echo $xml; exit; } $statvars['logs'] = $logs; $mindate = C::t('forum_statlog')->fetch_min_logdate_by_fid($fid); list($minyear, $minmonth, $minday) = explode('-', $mindate); $minmonth = $minyear . '-' . $minmonth; $month = $minmonth; $monthlist = array(); while (datecompare($month, $current_month) <= 0) { $monthlist[] = $month; $month = getnextmonth($month); } $statvars['monthlist'] = $monthlist; $monthposts = array(); foreach (C::t('forum_statlog')->fetch_all_by_fid_type($fid) as $data) { list($year, $month, $day) = explode('-', $data['logdate']); if (isset($monthposts[$year . '-' . $month])) { $monthposts[$year . '-' . $month] += $data['value']; } else { $monthposts[$year . '-' . $month] = $data['value']; } } $statvars['monthposts'] = $monthposts; } $statvars['statuspara'] = "path=&settings_file=data/stat_setting.xml&data_file=" . urlencode("misc.php?mod=stat&op=forumstat&fid={$fid}&month={$_GET['month']}&xml=1"); return $statvars; }
function getstatvars_forumstat($fid) { global $_G; $xml = "<chart>\n"; $statvars = array(); $monthdays = array('31', '28', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31'); if (!$fid) { $query = DB::query("SELECT fid, name, posts FROM " . DB::table('forum_forum') . " WHERE status<>'3' AND type<>'group'"); $forums = array(); while ($forum = DB::fetch($query)) { $forums[] = $forum; } $statvars['forums'] = $forums; } else { $foruminfo = DB::fetch_first("SELECT fid, name, posts, threads, todayposts FROM " . DB::table('forum_forum') . " WHERE fid='{$fid}'"); $statvars['foruminfo'] = $foruminfo; $current_date = $end_date = date('Y-m-d'); $current_month = $end_month = date('Y-m'); $current_month_start = $end_month_start = $current_month . '-01'; if ($_G['gp_month']) { $end_month = trim($_G['gp_month']); $month = substr($end_month, strpos($end_month, '-') + 1); $end_date = $end_month . '-' . $monthdays[$month - 1]; $end_month_start = $end_month . '-' . '01'; } $statvars['month'] = $end_month; $query = DB::query("SELECT logdate, fid, value\r\n\t\t\tFROM " . DB::table('forum_statlog') . "\r\n\t\t\tWHERE logdate>='{$end_month_start}' AND logdate<='{$end_date}' AND type='1' AND fid='{$fid}'\r\n\t\t\tORDER BY logdate ASC"); $logs = array(); $xml .= "<xaxis>\n"; $xmlvalue = ''; $xaxisindex = 0; while ($log = DB::fetch($query)) { $logs[] = $log; list($yyyy, $mm, $dd) = explode('-', $log['logdate']); $xaxisindex++; $xml .= "<value xid=\"{$xaxisindex}\">{$mm}{$dd}</value>\n"; $xmlvalue .= "<value xid=\"{$xaxisindex}\">{$log['value']}</value>\n"; } $xml .= "</xaxis>\n"; $xml .= "<graphs>\n"; $xml .= "<graph gid=\"0\" title=\"" . diconv(lang('spacecp', 'do_stat_post_number'), CHARSET, 'UTF-8') . "\">\n"; $xml .= $xmlvalue; $xml .= "</graph>\n"; $xml .= "</graphs>\n"; $xml .= "</chart>\n"; if ($_G['gp_xml']) { @header("Expires: -1"); @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE); @header("Pragma: no-cache"); @header("Content-type: application/xml; charset=utf-8"); echo $xml; exit; } $statvars['logs'] = $logs; $mindate = DB::result_first("SELECT MIN(logdate) FROM " . DB::table('forum_statlog') . " WHERE fid='{$fid}'"); list($minyear, $minmonth, $minday) = explode('-', $mindate); $minmonth = $minyear . '-' . $minmonth; $month = $minmonth; $monthlist = array(); while (datecompare($month, $current_month) <= 0) { $monthlist[] = $month; $month = getnextmonth($month); } $statvars['monthlist'] = $monthlist; $query = DB::query("SELECT logdate, `value` FROM " . DB::table('forum_statlog') . " WHERE fid='{$fid}' AND type='1'"); $monthposts = array(); while ($data = DB::fetch($query)) { list($year, $month, $day) = explode('-', $data['logdate']); if (isset($monthposts[$year . '-' . $month])) { $monthposts[$year . '-' . $month] += $data['value']; } else { $monthposts[$year . '-' . $month] = $data['value']; } } $statvars['monthposts'] = $monthposts; } $statvars['statuspara'] = "path=&settings_file=data/stat_setting.xml&data_file=" . urlencode("misc.php?mod=stat&op=forumstat&fid={$fid}&month={$_G['gp_month']}&xml=1"); return $statvars; }