Пример #1
0
 /**
  * Register new user
  * 
  * @access public
  * @return string Returns "OK" string upon succession and error message otherwise
  */
 public function register()
 {
     $xml = apiler::get_xml();
     try {
         $user = new User_Model($xml->login, $xml->password, $xml->email, $xml->description);
         $this->store_avatar($user->get_id($xml->login));
         echo "OK";
     } catch (Exception $e) {
         echo $e->getMessage() . "\n";
         die;
     }
 }
Пример #2
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');
     }
 }