Blame view

js/tiny_mce/plugins/ajaxfilemanager/inc/class.auth.php 1.98 KB
8d65d0ce   andryeyev   init
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
  <?php
  /**
   * the purpose I added this class is to make the file system much flexible 
   * for customization.
   * Actually,  this is a kind of interface and you should modify it to fit your system
   * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
   * @link www.phpletter.com
   * @since 4/August/2007
   */
          class Auth
          {
                  var $__loginIndexInSession = 'ajax_user';
  				private $db;
  				
                  function __construct()
                  {
                        $this->db = sdb::getInstance();  
                  }
                  
                  function Auth()
                  {
                          $this->__construct();
  						
                  }
                  /**
                   * check if the user has logged
                   *
                   * @return boolean
                   */
                  function isLoggedIn()
                  {
                         // return (!empty($_SESSION[$this->__loginIndexInSession])?true:false);
                         //  if((isset($_SESSION['user']['login']) && $_SESSION['user']['login']==ADMIN_USER) && (isset($_SESSION['user']['psw']) && $_SESSION['user']['psw']==ADMIN_PSW))return true;
                        if( $this->db->getOne("select count(*) from users where login=? and psw=?",array($_SESSION['login'], $_SESSION['psw'])) ) return true;   
                           return false;
  
                  }
                  /**
                   * validate the username & password
                   * @return boolean
                   *
                   */
                  function login()
                  {
                          if($_POST['username'] == CONFIG_LOGIN_USERNAME && $_POST['password'] == CONFIG_LOGIN_PASSWORD)
                          {
                                  $_SESSION[$this->__loginIndexInSession] = true;
                                  return true;
                          }else 
                          {
                                  return false;
                          }
                  }
          }
  ?>