-
Notifications
You must be signed in to change notification settings - Fork 1
/
class.session.vo.php
71 lines (53 loc) · 1.46 KB
/
class.session.vo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
*
*/
class session
{
// random seed
private static $RSeed = 0;
var $session_id, $uid , $start_time , $end_time , $session_code;
function __construct($uid , $start_time , $end_time )
{
$this->uid = $uid;
$this->start_time = $start_time;
$this->end_time = $end_time;
$this->session_code = $this->num(1,9999999);
$this->session_id = 0;
}
// set seed
public static function seed($s = 0) {
self::$RSeed = abs(intval($s)) % 9999999 + 1;
self::num();
}
// generate random number
public static function num($min = 0, $max = 9999999) {
if (self::$RSeed == 0) self::seed(mt_rand());
self::$RSeed = (self::$RSeed * 125) % 2796203;
return self::$RSeed % ($max - $min + 1) + $min;
}
/* returns json for the vo */
public function toJSON(){
$a = array(
"uid" => $this->uid,
"start_time" => $this->start_time,
"end_time" => $this->end_time,
"session_code" => $this->session_code);
return json_encode($a);
}
/* returns xml for the vo */
public function toXML(){
//todo
}
/* convenience funciton to view contents of driver object */
public function show() {
echo "<table>";
echo "<tr><td>session_id</td><td>$this->session_id()</td></tr>";
echo "<tr><td>uid</td><td>$this->uid</td></tr>";
echo "<tr><td>start_time</td><td>$this->start_time</td></tr>";
echo "<tr><td>end_time</td><td>$this->end_time</td></tr>";
echo "<tr><td>session_code</td><td>$this->session_code</td></tr>";
echo "</table>";
}
}
?>