source-function-F_list_online_users

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
Overview

Classes

Interfaces

Exceptions

Functions

  1: <?php
  2: //============================================================+
  3: // File name   : tce_functions_levels.php
  4: // Begin       : 2001-10-18
  5: // Last Update : 2011-05-24
  6: //
  7: // Description : Functions to display online users' data.
  8: //
  9: // Author: Nicola Asuni
 10: //
 11: // (c) Copyright:
 12: //               Nicola Asuni
 13: //               Tecnick.com LTD
 14: //               www.tecnick.com
 15: //               info@tecnick.com
 16: //
 17: // License:
 18: //    Copyright (C) 2004-2010  Nicola Asuni - Tecnick.com LTD
 19: //    See LICENSE.TXT file for more information.
 20: //============================================================+
 21: 
 22: /**
 23:  * @file
 24:  * Functions to display online users' data.
 25:  * @package com.tecnick.tcexam.admin
 26:  * @author Nicola Asuni
 27:  * @since 2001-10-18
 28:  */
 29: 
 30: /**
 31:  * Display online users form using F_list_online_users function.
 32:  * @author Nicola Asuni
 33:  * @since 2001-10-18
 34:  * @param $wherequery (string) users selection query
 35:  * @param $order_field (string) order by column name
 36:  * @param $orderdir (string) oreder direction
 37:  * @param $firstrow (string) number of first row to display
 38:  * @param $rowsperpage (string) number of rows per page
 39:  * @return false in case of empty database, true otherwise
 40:  */
 41: function F_show_online_users($wherequery, $order_field, $orderdir, $firstrow, $rowsperpage)
 42: {
 43:     global $l;
 44:     require_once('../config/tce_config.php');
 45:     F_list_online_users($wherequery, $order_field, $orderdir, $firstrow, $rowsperpage);
 46:     return true;
 47: }
 48: 
 49: /**
 50:  * Display online users.
 51:  * @author Nicola Asuni
 52:  * @since 2001-10-18
 53:  * @param $wherequery (string) users selection query
 54:  * @param $order_field (string) order by column name
 55:  * @param $orderdir (int) oreder direction
 56:  * @param $firstrow (int) number of first row to display
 57:  * @param $rowsperpage (int) number of rows per page
 58:  * @return false in case of empty database, true otherwise
 59:  */
 60: function F_list_online_users($wherequery, $order_field, $orderdir, $firstrow, $rowsperpage)
 61: {
 62:     global $l, $db;
 63:     require_once('../config/tce_config.php');
 64:     require_once('../../shared/code/tce_functions_page.php');
 65:     require_once('tce_functions_user_select.php');
 66:     
 67:     //initialize variables
 68:     $orderdir = intval($orderdir);
 69:     $firstrow = intval($firstrow);
 70:     $rowsperpage = intval($rowsperpage);
 71:     
 72:     // order fields for SQL query
 73:     if (empty($order_field) or (!in_array($order_field, array('cpsession_id', 'cpsession_data')))) {
 74:         $order_field = 'cpsession_expiry';
 75:     }
 76:     if ($orderdir == 0) {
 77:         $nextorderdir = 1;
 78:         $full_order_field = $order_field;
 79:     } else {
 80:         $nextorderdir = 0;
 81:         $full_order_field = $order_field.' DESC';
 82:     }
 83: 
 84:     if (!F_count_rows(K_TABLE_SESSIONS)) { //if the table is void (no items) display message
 85:         echo '<h2>'.$l['m_databasempty'].'</h2>';
 86:         return false;
 87:     }
 88: 
 89:     if (empty($wherequery)) {
 90:         $sql = 'SELECT * FROM '.K_TABLE_SESSIONS.' ORDER BY '.$full_order_field.'';
 91:     } else {
 92:         $wherequery = F_escape_sql($db, $wherequery);
 93:         $sql = 'SELECT * FROM '.K_TABLE_SESSIONS.' '.$wherequery.' ORDER BY '.$full_order_field.'';
 94:     }
 95:     if (K_DATABASE_TYPE == 'ORACLE') {
 96:         $sql = 'SELECT * FROM ('.$sql.') WHERE rownum BETWEEN '.$firstrow.' AND '.($firstrow + $rowsperpage).'';
 97:     } else {
 98:         $sql .= ' LIMIT '.$rowsperpage.' OFFSET '.$firstrow.'';
 99:     }
100: 
101:     echo '<div class="container">'.K_NEWLINE;
102:     echo '<table class="userselect">'.K_NEWLINE;
103:     echo '<tr>'.K_NEWLINE;
104:     echo '<th>'.$l['w_user'].'</th>'.K_NEWLINE;
105:     echo '<th>'.$l['w_level'].'</th>'.K_NEWLINE;
106:     echo '<th>'.$l['w_ip'].'</th>'.K_NEWLINE;
107:     echo '</tr>'.K_NEWLINE;
108: 
109:     if ($r = F_db_query($sql, $db)) {
110:         while ($m = F_db_fetch_array($r)) {
111:             $this_session = F_session_string_to_array($m['cpsession_data']);
112:             echo '<tr>';
113:             echo '<td align="left">';
114:             $user_str = '';
115:             if ($this_session['session_user_lastname']) {
116:                 $user_str .= urldecode($this_session['session_user_lastname']).', ';
117:             }
118:             if ($this_session['session_user_firstname']) {
119:                 $user_str .= urldecode($this_session['session_user_firstname']).'';
120:             }
121:             $user_str .= ' ('.urldecode($this_session['session_user_name']).')';
122:             if (F_isAuthorizedEditorForUser($this_session['session_user_id'])) {
123:                 echo '<a href="tce_edit_user.php?user_id='.$this_session['session_user_id'].'">'.$user_str.'</a>';
124:             } else {
125:                 echo $user_str;
126:             }
127:             echo '</td>';
128:             echo '<td>'.$this_session['session_user_level'].'</td>';
129:             echo '<td>'.$this_session['session_user_ip'].'</td>';
130:             echo '</tr>'.K_NEWLINE;
131:         }
132:     } else {
133:         F_display_db_error();
134:     }
135:     echo '</table>'.K_NEWLINE;
136: 
137:     // --- ------------------------------------------------------
138:     // --- page jump
139:     if ($rowsperpage > 0) {
140:         $sql = 'SELECT count(*) AS total FROM '.K_TABLE_SESSIONS.' '.$wherequery.'';
141:         if (!empty($order_field)) {
142:             $param_array = '&amp;order_field='.urlencode($order_field).'';
143:         }
144:         if (!empty($orderdir)) {
145:             $param_array .= '&amp;orderdir='.$orderdir.'';
146:         }
147:         $param_array .= '&amp;submitted=1';
148:         F_show_page_navigator($_SERVER['SCRIPT_NAME'], $sql, $firstrow, $rowsperpage, $param_array);
149:     }
150:     echo '<div class="pagehelp">'.$l['hp_online_users'].'</div>'.K_NEWLINE;
151:     echo '</div>'.K_NEWLINE;
152:     return true;
153: }
154: 
155: //============================================================+
156: // END OF FILE
157: //============================================================+
158: 
 

© 2004-2018 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy