- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
<?php
class security extends engine{
    var $temp=array();
    function getUserId(){
        $hash=explode('::',$_COOKIE['site_hash']);
        $id=$hash[0];
        return $id;
    }
    function getUserSecurityAccess($id){
        if(is_numeric($id)){
            $id=rawurlencode($id);
            $conn_id=mysql_connect('host','user','passwd');
            mysql_select_db('database');
            $q=mysql_query("SELECT groupid FROM `users`
                            WHERE id='".$id."'",$conn_id);
            if($q){
                if(mysql_numrows($q)!=0){
                    $result=@mysql_fetch_assoc($q);
                    return $result['group_id'];
                }else{
                    return -1;
                }
            }else{
                return -1;
            }
            mysql_close($conn_id);
        }else{
            return -1;
        }
    }
    function checkUserPermission($module,$act){
        #return true;
        $this->temp=array();
        $this->temp['_result']=0;
        $this->temp['_uid']=explode('::',$_COOKIE['site_hash']);
        $this->temp['_uid']=$this->temp['_uid'][0];
        $this->temp['_gid']=$this->getUserSecurityAccess($this->temp['_uid']);
        $this->temp['_conn_id']=mysql_connect('host','user','passwd');
        mysql_select_db('database');
        $this->temp['_q1']=mysql_query('SELECT perms'
                        .'FROM `secure_groups`' 
                        .'WHERE id='.$this->temp['_gid']);    
        $this->temp['_access_stamp']=mysql_fetch_assoc($this->temp['_q1']);
        $this->temp['_access_stamp']=$this->temp['_access_stamp']['perms'];
        $this->temp['_access_stamp']=explode(';',$this->temp['_access_stamp']);
        $this->temp['_access_stamp']=array_slice($this->temp['_access_stamp'],0,-1);
        foreach($this->temp['_access_stamp'] as $this->temp['v']){
            $this->temp['_mod_access']=explode(':',$this->temp['v']);
            $this->temp['_mod_indefier']=$this->temp['_mod_access'][0];
            if($this->temp['_mod_indefier']==$module){
                $this->temp['_perms']=explode(',',$this->temp['_mod_access'][1]);
                switch($act){
                    case 'r':
                        $this->temp['_result']=($this->temp['_perms'][0]==1)? 1:0;
                        break;
                    case 'w':
                        $this->temp['_result']=($this->temp['_perms'][1]==1)? 1:0;
                        break;
                }
                break;
            }
        }
        mysql_close($conn_id);
        return $this->temp['_result'];
    }
}
?>
                                 
        
завод для распила нанотехнологий
Судя по тому сколько здесь(на govnokod.ru) развелось PHP говна, можно сделать вывод что PHP просто сотворен для говнокодеров что-бы говнокодить...
[/offtop]
на пхп действительно невозможно писать неговно
так считаю из за тех, кто на нем пишет
я не пишу)
как сказал мой знакомый перешедший с джава, "пишу херню каку-то, а оно все-равно работает":)
Но писать то можно, и даже нужно "нехерню".
> $id=rawurlencode($id);
вопрос - ЗАЧЕМ???