Пример #1
0
 public function update($category)
 {
     $cat = new Category_Model();
     if ($cat->category_exists($category) and apiler::is_authorized()) {
         $xml = apiler::get_xml();
         $result = new Result_Model();
         if ($result->insert($category, $_SERVER['PHP_AUTH_USER'], $xml['value'])) {
             print "OK";
             die;
         } else {
             header("HTTP/1.1 400 Bad Request");
             echo "Invalid request";
             die;
         }
     } else {
         header("HTTP/1.0 404 Not Found");
         die('Category not found or not authorized');
     }
 }
Пример #2
0
 public function login($username, $password)
 {
     // hash password
     $password = $this->hash($password);
     if ($this->db->query("SELECT id FROM users WHERE username='******' AND password='******'")->count() > 0) {
         return true;
     } else {
         return false;
     }
 }
Пример #3
0
 /**
  * Verify credentials
  *
  * @return string Returns string "OK" if login is successful and error otherwise
  */
 public function login()
 {
     if (apiler::is_authorized()) {
         print "OK";
         die;
     } else {
         apiler::not_authorized();
     }
 }