function opwUpdateWhosOnline() { global $db; if (isset($_SESSION['user_id'])) { $wo_user_id =& $_SESSION['user_id']; $wo_full_name = $_SESSION['firstname'] . ' ' . $_SESSION['lastname']; } else { $wo_user_id = ''; $wo_full_name = 'Guest'; } $wo_session_id = owpSessionID(); $wo_ip_address = $_SERVER['REMOTE_ADDR']; $wo_last_page_url = addslashes($_SERVER['REQUEST_URI']); $current_time = time(); $xx_mins_ago = $current_time - 900; $owpDBTable = owpDBGetTables(); // remove entries that have expired $db->Execute("DELETE FROM " . $owpDBTable['whos_online'] . " WHERE time_last_click < '" . $xx_mins_ago . "'"); $sql = "SELECT count(*) as total \n FROM " . $owpDBTable['whos_online'] . " \n WHERE session_id = '" . $wo_session_id . "'"; $owp_user_query = $db->Execute($sql); $owp_user = $owp_user_query->fields; if ($owp_user['total'] > 0) { $db->Execute("UPDATE " . $owpDBTable['whos_online'] . " \n \t SET user_id = " . $db->qstr($wo_user_id) . ",\n \t full_name = " . $db->qstr($wo_full_name) . ",\n \t ip_address = " . $db->qstr($wo_ip_address) . ", \t \n \t time_last_click = " . $db->qstr($current_time) . ",\n \t last_page_url = " . $db->qstr($wo_last_page_url) . "\n WHERE session_id = '" . $wo_session_id . "'"); } else { $sql = "INSERT INTO " . $owpDBTable['whos_online'] . " \n (user_id,\n full_name, \n session_id, \n ip_address,\n time_entry,\n time_last_click,\n last_page_url) \n VALUES (" . $db->qstr($wo_user_id) . ',' . $db->qstr($wo_full_name) . ',' . $db->qstr($wo_session_id) . ',' . $db->qstr($wo_ip_address) . ',' . $db->qstr($current_time) . ',' . $db->qstr($current_time) . ',' . $db->qstr($wo_last_page_url) . ")"; $db->Execute($sql); } }
$owpDBTable['languages'] = $prefix_table . 'languages'; $owpDBTable['newsletters'] = $prefix_table . 'newsletters'; $owpDBTable['session'] = $prefix_table . 'sessions'; $owpDBTable['whos_online'] = $prefix_table . 'whos_online'; $owpDBTable['zones'] = $prefix_table . 'zones'; //session require_once OWP_CLASSES_DIR . 'owp_navigation_history.php'; require_once OWP_FUNCTIONS_DIR . 'owp_session.php'; if (isset($_COOKIE[owpSessionName()])) { owpSessionID($_COOKIE[owpSessionName()]); } else { if ($_POST[owpSessionName()]) { owpSessionID($_POST[owpSessionName()]); } else { if ($_GET[owpSessionName()]) { owpSessionID($_GET[owpSessionName()]); } } } owpSessIni(); if (!isset($_SESSION)) { $_SESSION = array(); session_destroy(); } // include the database functions include_once OWP_FUNCTIONS_DIR . 'owp_api.php'; include_once OWP_ADODB_DIR . 'toexport.inc.php'; include_once OWP_ADODB_DIR . 'adodb-errorhandler.inc.php'; include_once OWP_ADODB_DIR . 'adodb.inc.php'; include_once OWP_ADODB_DIR . 'tohtml.inc.php'; // make a connection to the database... now
function display_links($query_numrows, $max_rows_per_page, $max_page_links, $current_page_number, $parameters = '', $page_name = 'page') { global $_SERVER; if ($parameters != '') { $parameters .= '&'; } // calculate number of pages needing links $num_pages = intval($query_numrows / $max_rows_per_page); // $num_pages now contains int of pages needed unless there is a remainder from division if ($query_numrows % $max_rows_per_page) { $num_pages++; } // has remainder so add one page $pages_array = array(); for ($i = 1; $i <= $num_pages; $i++) { $pages_array[] = array('id' => $i, 'text' => $i); } if ($num_pages > 1) { $display_links = owpDrawForm('pages', basename($_SERVER['PHP_SELF']), '', 'get'); if ($current_page_number > 1) { $display_links .= '<a href="' . owpLink(basename($_SERVER['PHP_SELF']), $parameters . $page_name . '=' . ($current_page_number - 1), 'NONSSL') . '" class="splitPageLink">' . PREVNEXT_BUTTON_PREV . '</a> '; } else { $display_links .= PREVNEXT_BUTTON_PREV . ' '; } $display_links .= sprintf(TEXT_RESULT_PAGE, owpPullDownMenu($page_name, $pages_array, '', 'onChange="this.form.submit();"'), $num_pages); if ($current_page_number < $num_pages && $num_pages != 1) { $display_links .= ' <a href="' . owpLink(basename($_SERVER['PHP_SELF']), $parameters . $page_name . '=' . ($current_page_number + 1), 'NONSSL') . '" class="splitPageLink">' . PREVNEXT_BUTTON_NEXT . '</a>'; } else { $display_links .= ' ' . PREVNEXT_BUTTON_NEXT; } if ($parameters != '') { if (substr($parameters, -1) == '&') { $parameters = substr($parameters, 0, -1); } $pairs = explode('&', $parameters); while (list(, $pair) = each($pairs)) { list($key, $value) = explode('=', $pair); $display_links .= owpDrawHiddenField(rawurldecode($key), rawurldecode($value)); } } if (SID) { $display_links .= owpDrawHiddenField(owpSessionName(), owpSessionID()); } $display_links .= '</form>'; } else { $display_links = sprintf(TEXT_RESULT_PAGE, $num_pages, $num_pages); } return $display_links; }