public static function incrementPage($page) { $addr = Statistics::getUserIP(); $record = Statistics::firstOrNew(array('page' => $page, 'addr' => $addr)); $record->times++; $record->save(); }
Statistics::processUsageData($RequestData, $Dataset); $Data['datasets'][] = $Dataset; } $ReservationData = $Database->rawQuery(str_replace('table_name', 'reservations', $query)); if (!empty($ReservationData)) { $Dataset = array('label' => 'Reservations', 'clrkey' => 1); Statistics::processUsageData($ReservationData, $Dataset); $Data['datasets'][] = $Dataset; } break; case 'approvals': $Labels = $Database->rawQuery("SELECT to_char(timestamp,'{$LabelFormat}') AS key\n\t\t\t\t\tFROM log\n\t\t\t\t\tWHERE timestamp > NOW() - INTERVAL '2 MONTHS' AND reftype = 'post_lock'\n\t\t\t\t\tGROUP BY key\n\t\t\t\t\tORDER BY MIN(timestamp)"); Statistics::processLabels($Labels, $Data); $Approvals = $Database->rawQuery("SELECT\n\t\t\t\t\t\tto_char(MIN(timestamp),'{$LabelFormat}') AS key,\n\t\t\t\t\t\tCOUNT(*)::INT AS cnt\n\t\t\t\t\tFROM log\n\t\t\t\t\tWHERE timestamp > NOW() - INTERVAL '2 MONTHS' AND reftype = 'post_lock'\n\t\t\t\t\tGROUP BY to_char(timestamp,'{$LabelFormat}')\n\t\t\t\t\tORDER BY MIN(timestamp)"); if (!empty($Approvals)) { $Dataset = array('label' => 'Approved posts'); Statistics::processUsageData($Approvals, $Dataset); $Data['datasets'][] = $Dataset; } break; } Statistics::postprocessTimedData($Data); CoreUtils::createUploadFolder($CachePath); file_put_contents($CachePath, JSON::encode($Data)); Response::done(array('data' => $Data)); } CoreUtils::notFound(); } HTTP::pushResource('/about/stats-posts'); HTTP::pushResource('/about/stats-approvals'); CoreUtils::loadPage(array('title' => 'About', 'do-css', 'js' => array('Chart', $do)));