function admin_menu($help_file = '') { $pntable = pnDBGetTables(); list($newsubs) = db_select_one_row("SELECT count(*) FROM {$pntable['queue']}"); if (!pnSecAuthAction(0, "::", '::', ACCESS_EDIT)) { // suppress admin display - return to index. pnRedirect('index.php'); } else { menu_title('admin.php', _ADMINMENU); menu_graphic(pnConfigGetVar('admingraphic')); if ($help_file != '') { menu_help($help_file, _ONLINEMANUAL); } $mods = pnModGetAdminMods(); if ($mods == false) { // there aren't admin modules return; } foreach ($mods as $mod) { // Hack until the new news module comes into being // TODO - remove this at appropriate time if ($mod['name'] == 'AddStory') { $mod['name'] = 'Stories'; } if (pnSecAuthAction(0, "{$mod['name']}::", '::', ACCESS_EDIT)) { if (file_exists("modules/" . pnVarPrepForOS($mod['directory']) . "/pnadmin.php")) { $file = "modules/" . pnVarPrepForOS($mod['directory']) . "/pnimages/admin."; if (file_exists($file . 'gif')) { $imgfile = $file . 'gif'; } elseif (file_exists($file . 'jpg')) { $imgfile = $file . 'jpg'; } elseif (file_exists($file . 'png')) { $imgfile = $file . 'png'; } else { $imgfile = 'modules/NS-Admin/images/default.gif'; } menu_add_option(pnVarPrepForDisplay(pnModURL($mod['name'], 'admin')), $mod['displayname'], $imgfile); } else { $file = "modules/" . pnVarPrepForOS($mod['directory']) . "/images/admin."; if (file_exists($file . 'gif')) { $imgfile = $file . 'gif'; } elseif (file_exists($file . 'jpg')) { $imgfile = $file . 'jpg'; } elseif (file_exists($file . 'png')) { $imgfile = $file . 'png'; } else { $imgfile = 'modules/NS-Admin/images/default.gif'; } menu_add_option("admin.php?module={$mod['directory']}&op=main", $mod['displayname'], $imgfile); } } } } }
$topGrouping = getConfigValue($link, 'topGrouping'); ////get valid groupings that can be generated from the available data $query = 'SELECT '; $query .= 'DATEDIFF(MAX(date),MIN(date))'; $query .= ' FROM '; $query .= 'trafficSummaries'; if (!empty($_REQUEST['minDate']) && $_REQUEST['minDate'] != '') { $whereQuery = ' WHERE '; $whereQuery .= " date>='" . $_REQUEST['minDate'] . "'"; $whereQuery .= ' AND '; $whereQuery .= " date<='" . $_REQUEST['maxDate'] . "'"; } if (isset($whereQuery)) { $query .= $whereQuery; } $dbDays = db_select_one_row($link, $query); $dbDays = $dbDays['0']; if ($dbDays > 365) { $validGrouping = 'Yearly'; } elseif ($dbDays > 31) { $validGrouping = 'Monthly'; } elseif ($dbDays > 7) { $validGrouping = 'Weekly'; } else { $validGrouping = 'Daily'; } //Choose the grouping closest to the user selected if ($dateGroupings[$validGrouping] < $dateGroupings[$topGrouping]) { $topGrouping = $validGrouping; } $pageVars['topGrouping'] = $topGrouping;
function getActiveUsers($link) { global $pageVars, $s; $time = date('H:i:s', $pageVars['lastTimestamp'] - 600); $query = "SELECT "; $query .= 'COUNT(DISTINCTROW ip) AS users'; $query .= ' FROM traffic WHERE '; $query .= "date='" . $pageVars['date'] . "'"; $query .= " AND "; $query .= "time>'{$time}'"; $recordSet = db_select_one_row($link, $query); return $recordSet['users']; }
debug('Full host url is ' . $dbUrl, 40, __FILE__, __LINE__); debug('Searching id of host ' . $dbUrl . '...', 40, __FILE__, __LINE__); $query = "SELECT id FROM sites WHERE date='" . $dbRecord['date'] . "' AND site='" . $dbUrl . "'"; $recordSet = db_select_one_row($link, $query); if ($recordSet['id'] == '') { debug('Not found. Inserting to database...', 40, __FILE__, __LINE__); $query = "INSERT INTO sites(site,date) VALUES ('{$dbUrl}','" . $dbRecord['date'] . "')"; $sitesID = db_insert($link, $query); } else { debug('Found.', 40, __FILE__, __LINE__); $sitesID = $recordSet['id']; } debug('Site ID is: ' . $sitesID, 40, __FILE__, __LINE__); debug('Searching id of user ' . $dbRecord['authuser'] . '...', 40, __FILE__, __LINE__); $query = "SELECT id FROM users WHERE date='" . $dbRecord['date'] . "' AND authuser='******'authuser'] . "'"; $recordSet = db_select_one_row($link, $query); if ($recordSet['id'] == '') { debug('Not found. Inserting to database...', 40, __FILE__, __LINE__); $query = "INSERT INTO users(authuser,date) VALUES ('" . $dbRecord['authuser'] . "','" . $dbRecord['date'] . "')"; $usersID = db_insert($link, $query); } else { debug('Found.', 40, __FILE__, __LINE__); $usersID = $recordSet['id']; } debug('User ID is: ' . $usersID, 40, __FILE__, __LINE__); debug('Updating trafficSummaries...', 40, __FILE__, __LINE__); $query = 'UPDATE '; $query .= 'trafficSummaries SET '; $query .= $dbRecord['field'] . '=' . $dbRecord['field'] . '+' . $dbRecord['bytes']; $query .= ' WHERE '; $query .= "date='" . $dbRecord['date'] . "'";