~registry/flses/trunk

« back to all changes in this revision

Viewing changes to classes/flses.php

  • Committer: fabi
  • Date: 2009-07-07 14:48:05 UTC
  • Revision ID: fabi@alter-laptop-20090707144805-ceffkld1ou8nwss0
 - Created Rights Management

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
        
36
36
        public function __construct()
37
37
        {
38
 
                $sql = "SELECT * FROM `".cFlsesMySQLprefix."users` ;";
 
38
                $this->user = $this->parseuserdata($this->userid);
 
39
        }
 
40
        
 
41
        public function test()
 
42
        {
 
43
                print_r($this->user);
 
44
                $this->setaccess("test4","This is a test",19);
 
45
        }
 
46
        
 
47
        public function parseuserdata($id)
 
48
        {
 
49
                $sql = "SELECT * FROM `".cFlsesMySQLprefix."users` WHERE `id`='{$id}';";
39
50
                $res = mysql_query($sql);
40
51
                if($res)
41
52
                {
42
53
                        $user = mysql_fetch_object($res);
43
 
                        $this->user = $user;
44
54
                        $access = explode(";",$user->access);
45
 
                        $this->user->access = array();
 
55
                        $user->access = array();
46
56
                        foreach($access as $item)
47
57
                        {
48
58
                                $arr = explode("=",$item);
49
 
                                $this->user->access[$arr[0]] = $arr[1];
 
59
                                $user->access[$arr[0]] = $arr[1];
50
60
                        }
 
61
                        return $user;
51
62
                } else {
52
63
                        echo "xx";
53
64
                }
54
65
        }
55
66
        
 
67
        
56
68
        public function access($arg)
57
69
        {
58
70
                return $this->user->access[$arg];
59
71
        }
60
72
        
 
73
        public function setaccess($arg,$val,$uid="")
 
74
        {
 
75
                if(!$uid)
 
76
                {       
 
77
                        $uid = $this->userid;
 
78
                        $user = $this->user;
 
79
                }
 
80
                else
 
81
                {
 
82
                        $user = $this->parseuserdata($uid);
 
83
                }
 
84
                $length = count($user->access);
 
85
                $i = 0;
 
86
                foreach($user->access as $key => $value)
 
87
                {
 
88
                        $i++;
 
89
                        echo "<br>";
 
90
                        echo $key;
 
91
                        echo " - ";
 
92
                        echo $value;
 
93
                        if($key == $arg)
 
94
                        {
 
95
                                $string .= $key;
 
96
                                $string .= "=";
 
97
                                $string .= $val;
 
98
                                if($i < $length)
 
99
                                        $string .= ";";
 
100
                                $done = true;
 
101
                        } else {
 
102
                                $string .= $key;
 
103
                                $string .= "=";
 
104
                                $string .= $value;
 
105
                                if($i < $length)
 
106
                                        $string .= ";";
 
107
                        }
 
108
                }
 
109
                if(!$done)
 
110
                {
 
111
                        $string .= ";";
 
112
                        $string .= $arg;
 
113
                        $string .= "=";
 
114
                        $string .= $val;
 
115
                }
 
116
                
 
117
                $sql = "UPDATE `".cFlsesMySQLprefix."users` 
 
118
                        SET `access` = '{$string}' 
 
119
                        WHERE `id` = '{$uid}';";
 
120
                mysql_query($sql);
 
121
        }
 
122
        
61
123
        ## Global Function Area ##
62
124
 
63
125
        public function genCode($player)