Example #1
0
 function checkLogin($name, $password)
 {
     if (empty($name) && empty($password)) {
         return false;
     }
     DB::setQuery('SELECT * FROM users WHERE `mail` = "' . DB::dbStr($name) . '" AND password = "' . DB::dbStr(md5($password)) . '" AND user_type = 1');
     $data = DB::getNum();
     if ($data == 1) {
         $_SESSION['user'] = $data;
         return true;
     } else {
         return false;
     }
 }
Example #2
0
 public function getList()
 {
     $get = $_GET;
     $items = new stdClass();
     $items->position = isset($get['position']) ? $get['position'] : '';
     $items->name = isset($get['name']) ? $get['name'] : '';
     $items->w_name = isset($get['w_name']) ? $get['w_name'] : '';
     $items->published = isset($get['published']) ? $get['published'] : '';
     $items->order_by = isset($get['order_by']) ? $get['order_by'] : '';
     $items->desc = isset($get['desc']) ? $get['desc'] : '';
     $where = array();
     if ($items->position) {
         $where[] = '`position` = ' . DB::dbStr($items->position);
     }
     if ($items->name) {
         $where[] = '`name` LIKE %' . DB::dbStr($items->name) . '%';
     }
     if ($items->w_name) {
         $where[] = '`c_name` = ' . DB::dbStr($items->w_name);
     }
     if ($items->published) {
         $where[] = '`published` = ' . DB::dbStr($items->published);
     }
     $orderby = '';
     if ($items->order_by) {
         $orderby .= 'ORDER BY ' . $items->order_by;
     } else {
         $orderby .= 'ORDER BY id ';
     }
     if ($items->desc && $orderby) {
         $orderby .= $items->desc;
     } else {
         $orderby .= $items->desc;
     }
     $where = count($where) ? ' WHERE (' . implode(') AND (', $where) . ') ' : '';
     DB::setQuery('SELECT * FROM widgets ' . $where . ' ' . $orderby);
     $total = DB::getNum();
     $data = DB::getList();
     $array = array('filter' => $items, 'total' => $total, 'data' => $data);
     return $array;
 }
Example #3
0
 /**
  * 获取根分类的数目
  * @param  integer $id 
  * @return integer      
  */
 public function num($id = 0)
 {
     $sql = "select * from " . self::$table . " where bid='{$id}'";
     return DB::getNum($sql);
 }