<?php
 class Online2DB extends ADO { var $className = 'Online2'; public function __construct( $app, $dburi, $debug=false, $tmode=true, $dformat='') { $this->owner = $app; if ( !empty($dburi)) $this->dburi = $dburi; return parent::__construct( $this->dburi, $debug, $tmode, $dformat); } public function get_records($lines_per_page, $page=0) { if ( isset($GLOBALS['nas'])) { $GLOBALS['nas'] = urldecode($GLOBALS['nas']); $GLOBALS['nas'] = str_replace(' ', '=2B', str_replace(':', '=253A', $GLOBALS['nas'])); } if (!empty($GLOBALS['nas'])) $res = $this->GetAll("SELECT count(*) FROM sk_online WHERE call_to LIKE '".$GLOBALS['nas']."%'"); else $res = $this->GetAll("SELECT count(*) FROM sk_online"); $limits = false; if ( $page >= 0) { $low = $page*$lines_per_page; $high = $lines_per_page; $limits = true; } $ext = ''; if (!empty($GLOBALS['nas'])) $ext = " AND call_to LIKE '".$GLOBALS['nas']."%'"; $query = SQL_GET_ONLINE_DATA_MAIN; $query .= $ext.' ORDER BY sk_online.Start_Time DESC'; if ( $limits) { $query .= ' OFFSET '.$low.' LIMIT '.$high; } $allRecs = $this->GetAll($query); return array($res[0], $allRecs); } public function get_records_for_provider($lines_per_page, $page=0) { if ( isset($GLOBALS['nas'])) { $GLOBALS['nas'] = urldecode($GLOBALS['nas']); $GLOBALS['nas'] = str_replace(' ', '=2B', str_replace(':', '=253A', $GLOBALS['nas'])); } if (!empty($GLOBALS['nas'])) $res = $this->GetAll("SELECT count(*) FROM sk_online,sk_service_set,sk_packets WHERE sk_online.gid=sk_packets.gid AND sk_packets.service_set_id=sk_service_set.service_set_id AND sk_service_set.provider_id='".$GLOBALS['PROVIDER']."' AND sk_online.call_to LIKE '".$GLOBALS['nas']."%'"); else $res = $this->GetAll("SELECT count(*) FROM sk_online,sk_service_set,sk_packets WHERE sk_online.gid=sk_packets.gid AND sk_packets.service_set_id=sk_service_set.service_set_id AND sk_service_set.provider_id='".$GLOBALS['PROVIDER']."'"); $limits = false; if ( $page >= 0) { $low = $page*$lines_per_page; $high = $lines_per_page; $limits = true; } $ext = ''; if (!empty($GLOBALS['nas'])) $ext = " AND sk_online.call_to LIKE '".$GLOBALS['nas']."%'"; $query = sprintf(SQL_GET_ONLINE_DATA_PROV, $GLOBALS['PROVIDER']); $query .= $ext.' ORDER BY sk_online.Start_Time DESC'; if ( $limits) { $query .= ' OFFSET '.$low.' LIMIT '.$high; } $allRecs = $this->GetAll($query); return array($res[0], $allRecs); } public function get_records_for_lowlevel($lines_per_page, $page=0) { $orgunit = $this->GetAll( "SELECT orgunit FROM sk_objects WHERE obj_id='".$GLOBALS['SSXID']."'"); $res = $this->GetAll("SELECT count(*) FROM sk_online,sk_group_tracker WHERE sk_online.gid=sk_group_tracker.gid AND sk_group_tracker.obj_id='".$GLOBALS['SSXID']."' AND sk_online.username LIKE '%".$orgunit[0][0]."%'"); $limits = false; if ( $page >= 0) { $low = $page*$lines_per_page; $high = $lines_per_page; $limits = true; } $query = sprintf(SQL_GET_ONLINE_DATA_SPEC, $GLOBALS['SSXID'], '%'.$orgunit[0][0].'%'); $query .= ' ORDER BY Start_Time DESC'; if ( $limits) { $query .= ' OFFSET '.$low.' LIMIT '.$high; } $allRecs = $this->GetAll($query); return array($res[0], $allRecs); } } ?>
