"PHP" / Говнокод #5963 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 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'];
    }
}
?>

Понравилось окончание статьи
"Надеюсь, что мы скоро встретимся...
Кто хочет почитать остальные мои статьи - прошу на http://e-code.tnt43.com.
С уважением Карпенко Кирилл, глава IT-отдела ИНПП. "

Запостил: MoLe-X MoLe-X, (Updated )

Комментарии (17) RSS

Добавить комментарий

Я, guest, находясь в здравом уме и твердой памяти, торжественно заявляю:

    А не использовать ли нам bbcode?


    8