1 <?php defined('SYSPATH') OR die('No direct access allowed.');
3 * API controller for communicating with mobile clients
5 * @author Artem Daniliants <artem@daniliants.com>
6 * @copyright (c) 2010 Speed Freak team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 class Api_Controller extends Controller{
13 * Default action when no parameters are given to controller
15 public function index(){
16 url::redirect(Kohana::config('api.default_redirect'),301);
20 * New user registration
22 public function register(){
23 $xml = $this->get_xml();
25 $user = new User_Model($xml->login, $xml->password, $xml->email);
28 catch (Exception $e) {
29 echo $e->getMessage() . "\n";
35 * Returns XML file supplied by client
37 private function get_xml(){
38 if (isset($_POST['xml'])){
39 $xml = simplexml_load_string($_POST['xml']);
41 elseif (isset($_FILES['xml'])){
42 $xml = simplexml_load_file($_FILES['xml']['tmp_name']);
45 header("HTTP/1.1 400 Bad Request");
46 echo "Please supply required parameters";