Esempio n. 1
0
 public static function load()
 {
     //treat url erasing extra parts
     $current_uri = $_SERVER['REQUEST_URI'];
     //keeping a local copy
     ERewriter::$oldurl = $current_uri;
     $matches = array();
     foreach (EConfig::$data['rewrite'] as $key => $value) {
         if (!is_array($value)) {
             ELog::warning("You need to specify a second value as a rewrite rule in rewrite.conf.php");
             return;
         }
         //handle with normal rewrite that
         //permits to have parameters
         if ($value[1] == "normal") {
             $pos = strpos($current_uri, $key);
             //if we found a rewrite rule that can be applied
             if ($pos !== false) {
                 //rewrite only at the very start of the string
                 if ($pos == 0) {
                     //record the allowed key
                     $matches[strlen($key)] = array($key, $value[0]);
                 }
             }
         } else {
             if ($value[1] == "exact") {
                 $current_uri_t = explode("?", $current_uri)[0];
                 if ($current_uri_t == $key) {
                     if (ERewriter::$rewritable) {
                         $rewritten = str_replace($key, $value[0], $current_uri);
                         //TODO FIX HERE
                         //$rewritten = preg_replace("$key", $value, $current_uri, 1);
                         $_SERVER['REQUEST_URI'] = $rewritten;
                         //setting rewritable to false
                         ERewriter::$rewritable = false;
                         break;
                     }
                 }
             }
         }
     }
     if (ERewriter::$rewritable) {
         ksort($matches);
         $matches = array_reverse(array_values($matches));
         if (isset($matches[0])) {
             $rule = $matches[0];
             $rewritten = str_replace($rule[0], $rule[1], $current_uri);
             //TODO FIX HERE FIRST OCCURRENCE
             //$rewritten = preg_replace("$key", $value, $current_uri, 1);
             $_SERVER['REQUEST_URI'] = $rewritten;
         }
     }
 }
Esempio n. 2
0
 public function handle()
 {
     /*
     // overwrite the 404 error page returncode
     header("HTTP/1.0 200 OK");
     */
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         $method = 'get';
     } elseif ($_SERVER['REQUEST_METHOD'] == 'PUT') {
         $method = 'put';
         parse_str(file_get_contents("php://input"), $put_vars);
     } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $method = 'post';
     } else {
         echo 'internal server error: method not supported';
         exit;
     }
     // preprocess url
     $url = ERewriter::oldurl();
     //erasing get params
     $url = explode('?', $url)[0];
     if (substr($url, strlen($url) - 1) != '/') {
         $url .= '/';
     }
     //$ex=str_replace('?', '/?', $url, $uno);
     $ex = explode('/', $url);
     //var_dump($ex);
     // eventhandler
     if (count($ex) == 2) {
         H01_GUI::showtemplate('apidoc');
         // CONFIG
         // apiconfig - GET - CONFIG
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'config' and count($ex) == 4) {
         $format = $this->readdata('format', 'text');
         $this->config($format);
         // personsearch - GET - PERSON/DATA				parameter als url parameter
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'person' and strtolower($ex[3]) == 'data' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $username = $this->readdata('name', 'text');
         $country = $this->readdata('country', 'text');
         $city = $this->readdata('city', 'text');
         $description = $this->readdata('description', 'text');
         $pc = $this->readdata('pc', 'text');
         $software = $this->readdata('software', 'text');
         $longitude = $this->readdata('longitude', 'float');
         $latitude = $this->readdata('latitude', 'float');
         $distance = $this->readdata('distance', 'float');
         $attributeapp = $this->readdata('attributeapp', 'text');
         $attributekey = $this->readdata('attributekey', 'text');
         $attributevalue = $this->readdata('attributevalue', 'text');
         $page = $this->readdata('page', 'int');
         $pagesize = $this->readdata('pagesize', 'int');
         if ($pagesize < 1 or $pagesize > 100) {
             $pagesize = 10;
         }
         $this->personsearch($format, $username, $country, $city, $description, $pc, $software, $longitude, $latitude, $distance, $attributeapp, $attributekey, $attributevalue, $page, $pagesize);
         // personget - GET - PERSON/DATA/frank
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'person' and strtolower($ex[3]) == 'data' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $username = addslashes($ex[4]);
         $this->personget($format, $username);
         // personaccountbalance - GET - PERSON/BALANCE
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'person' and strtolower($ex[3]) == 'balance' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $this->persongetbalance($format);
         // personget - GET - PERSON/SELF
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'person' and strtolower($ex[3]) == 'self' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $this->personget($format);
         // personedit - POST - PERSON/EDIT
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'person' and strtolower($ex[3]) == 'self' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $longitude = $this->readdata('longitude', 'float');
         $latitude = $this->readdata('latitude', 'float');
         $country = $this->readdata('country', 'text');
         $city = $this->readdata('city', 'text');
         $this->personedit($format, $longitude, $latitude, $country, $city);
         // personcheck - POST - PERSON/CHECK
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'person' and strtolower($ex[3]) == 'check' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $login = $this->readdata('login', 'text');
         $passwd = $this->readdata('password', 'text');
         $this->personcheck($format, $login, $passwd);
         // personadd - POST - PERSON/ADD
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'person' and strtolower($ex[3]) == 'add' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $login = $this->readdata('login', 'text');
         $passwd = $this->readdata('password', 'text');
         $firstname = $this->readdata('firstname', 'text');
         $lastname = $this->readdata('lastname', 'text');
         $email = $this->readdata('email', 'text');
         $this->personadd($format, $login, $passwd, $firstname, $lastname, $email);
         // persongetea - GET - PERSON/ATTRIBUTES/frank/parley/key
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'person' and strtolower($ex[3]) == 'attributes' and count($ex) == 8) {
         $format = $this->readdata('format', 'text');
         $username = addslashes($ex[4]);
         $app = addslashes($ex[5]);
         $key = addslashes($ex[6]);
         $this->personattributeget($format, $username, $app, $key);
         // persongetea - GET - PERSON/ATTRIBUTES/frank/parley
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'person' and strtolower($ex[3]) == 'attributes' and count($ex) == 7) {
         $format = $this->readdata('format', 'text');
         $username = addslashes($ex[4]);
         $app = addslashes($ex[5]);
         $key = '';
         $this->personattributeget($format, $username, $app, $key);
         // persongetea - GET - PERSON/ATTRIBUTES/frank
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'person' and strtolower($ex[3]) == 'attributes' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $username = addslashes($ex[4]);
         $app = '';
         $key = '';
         $this->personattributeget($format, $username, $app, $key);
         // persondeleteea - POST - PERSON/DELETEATTRIBUTE/app/key
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'person' and strtolower($ex[3]) == 'deleteattribute' and count($ex) == 7) {
         $format = $this->readdata('format', 'text');
         $app = addslashes($ex[4]);
         $key = addslashes($ex[5]);
         $this->personattributedelete($format, $app, $key);
         // personsetea - POST - PERSON/SETATTRIBUTE/app/key
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'person' and strtolower($ex[3]) == 'setattribute' and count($ex) == 7) {
         $format = $this->readdata('format', 'text');
         $app = addslashes($ex[4]);
         $key = addslashes($ex[5]);
         $value = $this->readdata('value', 'text');
         $this->personattributeset($format, $app, $key, $value);
         // FAN
         //fanget - GET - FAN/DATA/"contentid" - page,pagesize als url parameter,
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'fan' and strtolower($ex[3]) == 'data' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $content = addslashes($ex[4]);
         $page = $this->readdata('page', 'int');
         $pagesize = $this->readdata('pagesize', 'int');
         if ($pagesize < 1 or $pagesize > 100) {
             $pagesize = 10;
         }
         $this->fanget($format, $content, $page, $pagesize);
         //isfan - GET - FAN/STATUS/"contentid"
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'fan' and strtolower($ex[3]) == 'status' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $content = addslashes($ex[4]);
         $this->isfan($format, $content);
         //addfan - POST - FAN/ADD/"contentid"
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'fan' and strtolower($ex[3]) == 'add' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $content = addslashes($ex[4]);
         $this->addfan($format, $content);
         //removefan - POST - FAN/REMOVE/"contentid"
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'fan' and strtolower($ex[3]) == 'remove' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $content = addslashes($ex[4]);
         $this->removefan($format, $content);
         // FRIEND
         //friendget - GET - FRIEND/DATA/"personid" - page,pagesize als url parameter,
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'friend' and strtolower($ex[3]) == 'data' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $username = addslashes($ex[4]);
         $page = $this->readdata('page', 'int');
         $pagesize = $this->readdata('pagesize', 'int');
         if ($pagesize < 1 or $pagesize > 100) {
             $pagesize = 10;
         }
         $this->friendget($format, $username, $page, $pagesize);
         //friendinvite - POST - FRIEND/INVITE/"username"/	 message als url parameter
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'friend' and strtolower($ex[3]) == 'invite' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $username = addslashes($ex[4]);
         $message = $this->readdata('message', 'text');
         $this->friendinvite($format, $username, $message);
         //friendapprove - POST - FRIEND/APPROVE/"username"/
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'friend' and strtolower($ex[3]) == 'approve' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $username = addslashes($ex[4]);
         $this->friendapprove($format, $username);
         //frienddecline - POST - FRIEND/DECLINE/"username"/
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'friend' and strtolower($ex[3]) == 'decline' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $username = addslashes($ex[4]);
         $this->frienddecline($format, $username);
         //friendcancel - POST - FRIEND/CANCEL/"username"/
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'friend' and strtolower($ex[3]) == 'cancel' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $username = addslashes($ex[4]);
         $this->friendcancel($format, $username);
         //friendcancelinvitation - POST - FRIEND/CANCEL/"username"/
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'friend' and strtolower($ex[3]) == 'cancelinvitation' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $username = addslashes($ex[4]);
         $this->friendcancelinvitation($format, $username);
         //friendsentinvitations - GET - FRIEND/SENTINVITATIONS/
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'friend' and strtolower($ex[3]) == 'sentinvitations' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $page = $this->readdata('page', 'int');
         $pagesize = $this->readdata('pagesize', 'int');
         if ($pagesize < 1 or $pagesize > 100) {
             $pagesize = 10;
         }
         $this->friendsentinvitations($format, $page, $pagesize);
         //friendreceivedinvitations - GET - FRIEND/RECEIVEDINVITATIONS/
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'friend' and strtolower($ex[3]) == 'receivedinvitations' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $page = $this->readdata('page', 'int');
         $pagesize = $this->readdata('pagesize', 'int');
         if ($pagesize < 1 or $pagesize > 100) {
             $pagesize = 10;
         }
         $this->friendreceivedinvitations($format, $page, $pagesize);
         // MESSAGE
         //messagefolders	- GET - MESSAGE/
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'message' and count($ex) == 4) {
         $format = $this->readdata('format', 'text');
         $this->messagefolders($format);
         //messagelist - GET - MESSAGE/"folderid"/	 page,pagesize als url parameter
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'message' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $folder = (int) addslashes($ex[3]);
         $filter = $this->readdata('status', 'text');
         $page = $this->readdata('page', 'int');
         $pagesize = $this->readdata('pagesize', 'int');
         if ($pagesize < 1 or $pagesize > 100) {
             $pagesize = 10;
         }
         $this->messagelist($format, $folder, $page, $pagesize, $filter);
         // messagesend	- POST - MESSAGE/"folderid"
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'message' and strtolower($ex[3]) == '2' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $touser = $this->readdata('to', 'text');
         $subject = $this->readdata('subject', 'text');
         $message = $this->readdata('message', 'text');
         $this->messagesend($format, $touser, $subject, $message);
         // messageget - GET - MESSAGE/"folderid"/"messageid"
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'message' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $folder = (int) addslashes($ex[3]);
         $message = (int) addslashes($ex[4]);
         $this->messageget($format, $folder, $message);
         // ACTIVITY
         // activityget - GET ACTIVITY	 page,pagesize als urlparameter
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'activity' and count($ex) == 4) {
         $format = $this->readdata('format', 'text');
         $page = $this->readdata('page', 'int');
         $pagesize = $this->readdata('pagesize', 'int');
         if ($pagesize < 1 or $pagesize > 100) {
             $pagesize = 10;
         }
         $this->activityget($format, $page, $pagesize);
         // activityput - POST ACTIVITY
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'activity' and count($ex) == 4) {
         $format = $this->readdata('format', 'text');
         $message = $this->readdata('message', 'text');
         $this->activityput($format, $message);
         // CONTENT
         // contentcategories - GET - CONTENT/CATEGORIES
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'categories' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $this->contentcategories($format);
         // contentlicense - GET - CONTENT/LICENSES
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'licenses' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $this->contentlicenses($format);
         // contentdistributions - GET - CONTENT/DISTRIBUTIONS
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'distributions' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $this->contentdistributions($format);
         // contentdependencies - GET - CONTENT/DISTRIBUTIONS
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'dependencies' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $this->contentdependencies($format);
         // contenthomepage - GET - CONTENT/HOMPAGES
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'homepages' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $this->contenthomepages($format);
         // contentlist - GET - CONTENT/DATA - category,search,sort,page,pagesize
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'data' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $contents = $this->readdata('categories', 'text');
         $searchstr = $this->readdata('search', 'text');
         $searchuser = $this->readdata('user', 'text');
         $external = $this->readdata('external', 'text');
         $distribution = $this->readdata('distribution', 'text');
         $license = $this->readdata('license', 'text');
         $sortmode = $this->readdata('sortmode', 'text');
         $page = $this->readdata('page', 'int');
         $pagesize = $this->readdata('pagesize', 'int');
         if ($pagesize < 1 or $pagesize > 100) {
             $pagesize = 10;
         }
         $this->contentlist($format, $contents, $searchstr, $searchuser, $external, $distribution, $license, $sortmode, $page, $pagesize);
         // contentget - GET - CONTENT/DATA/"id"
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'data' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $id = addslashes($ex[4]);
         $this->contentget($format, $id);
         // contentdownload - GET - CONTENT/DOWNLOAD/"id"/"item"
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'download' and count($ex) == 7) {
         $format = $this->readdata('format', 'text');
         $id = addslashes($ex[4]);
         $item = addslashes($ex[5]);
         $this->contentdownload($format, $id, $item);
         // getrecommendations - GET - CONTENT/RECOMMENDATIONS/"id"
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'recommendations' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $id = addslashes($ex[4]);
         $page = $this->readdata('page', 'int');
         $pagesize = $this->readdata('pagesize', 'int');
         $this->contentrecommendations($id, $format, $page, $pagesize);
         // contentvote - POST - CONTENT/VOTE/"id" - good/bad als url parameter
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'vote' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $id = addslashes($ex[4]);
         $vote = $this->readdata('vote', 'text');
         $this->contentvote($format, $id, $vote);
         // contentpreviewdelete - POST - CONTENT/DELETEPREVIEW/"contentid"/"previewid"
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'deletepreview' and count($ex) == 7) {
         $format = $this->readdata('format', 'text');
         $contentid = addslashes($ex[4]);
         $previewid = addslashes($ex[5]);
         $this->contentpreviewdelete($format, $contentid, $previewid);
         // contentpreviewupload - POST - CONTENT/UPLOADPREVIEW/"contentid"/"previewid"
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'uploadpreview' and count($ex) == 7) {
         $format = $this->readdata('format', 'text');
         $contentid = addslashes($ex[4]);
         $previewid = addslashes($ex[5]);
         $this->contentpreviewupload($format, $contentid, $previewid);
         // contentdownloaddelete - POST - CONTENT/DELETEDOWNLOAD/"contentid"
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'deletedownload' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $contentid = addslashes($ex[4]);
         $this->contentdownloaddelete($format, $contentid);
         // contentdownloadupload - POST - CONTENT/UPLOADDOWNLOAD/"contentid"
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'uploaddownload' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $contentid = addslashes($ex[4]);
         $this->contentdownloadupload($format, $contentid);
         // contentadd - POST - CONTENT/ADD
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'add' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $this->contentadd($format);
         // contentedit - POST - CONTENT/EDIT/"contentid"
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'edit' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $contentid = addslashes($ex[4]);
         $this->contentedit($format, $contentid);
         // contentdelete - POST - CONTENT/DELETE/"contentid"
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'content' and strtolower($ex[3]) == 'delete' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $contentid = addslashes($ex[4]);
         $this->contentdelete($format, $contentid);
         // KNOWLEDGEBASE
         // knowledgebaseget - GET - KNOWLEDGEBASE/DATA/"id"
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'knowledgebase' and strtolower($ex[3]) == 'data' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $id = addslashes($ex[4]);
         $this->knowledgebaseget($format, $id);
         // knowledgebaselist - GET - KNOWLEDGEBASE/DATA - category,search,sort,page,pagesize
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'knowledgebase' and strtolower($ex[3]) == 'data' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $contents = $this->readdata('content', 'text');
         $searchstr = $this->readdata('search', 'text');
         $sortmode = $this->readdata('sortmode', 'text');
         $page = $this->readdata('page', 'int');
         $pagesize = $this->readdata('pagesize', 'int');
         if ($pagesize < 1 or $pagesize > 100) {
             $pagesize = 10;
         }
         $this->knowledgebaselist($format, $contents, $searchstr, $sortmode, $page, $pagesize);
         // EVENT
         // eventget - GET - EVENT/DATA/"id"
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'event' and strtolower($ex[3]) == 'data' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $id = addslashes($ex[4]);
         $this->eventget($format, $id);
         // eventlist - GET - EVENT/DATA - type,country,startat,search,sort,page,pagesize
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'event' and strtolower($ex[3]) == 'data' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $type = $this->readdata('type', 'int');
         $country = $this->readdata('country', 'text');
         $startat = $this->readdata('startat', 'text');
         $searchstr = $this->readdata('search', 'text');
         $sortmode = $this->readdata('sortmode', 'text');
         $page = $this->readdata('page', 'int');
         $pagesize = $this->readdata('pagesize', 'int');
         if ($pagesize < 1 or $pagesize > 100) {
             $pagesize = 10;
         }
         $this->eventlist($format, $type, $country, $startat, $searchstr, $sortmode, $page, $pagesize);
         // eventadd - POST - EVENT/ADD
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'event' and strtolower($ex[3]) == 'add' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $this->eventadd($format);
         // eventedit - POST - EVENT/EDIT/"eventid"
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'event' and strtolower($ex[3]) == 'edit' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $eventid = addslashes($ex[4]);
         $this->eventedit($format, $eventid);
         // eventdelete - POST - EVENT/DELETE/"eventid"
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'event' and strtolower($ex[3]) == 'delete' and count($ex) == 6) {
         $format = $this->readdata('format', 'text');
         $eventid = addslashes($ex[4]);
         $this->eventdelete($format, $eventid);
         // COMMENTS
         // commentsget - GET - COMMENTS/GET
     } elseif ($method == 'get' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'comments' and strtolower($ex[3]) == 'data' and count($ex) == 8) {
         $type = addslashes($ex[4]);
         $content = addslashes($ex[5]);
         $content2 = addslashes($ex[6]);
         $format = $this->readdata('format', 'text');
         $page = $this->readdata('page', 'int');
         $pagesize = $this->readdata('pagesize', 'int');
         if ($pagesize < 1 or $pagesize > 2000) {
             $pagesize = 10;
         }
         $this->commentsget($format, $type, $content, $content2, $page, $pagesize);
         // commentsadd - POST - COMMENTS/ADD
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'comments' and strtolower($ex[3]) == 'add' and count($ex) == 5) {
         $format = $this->readdata('format', 'text');
         $type = $this->readdata('type', 'int');
         $content = $this->readdata('content', 'int');
         $content2 = $this->readdata('content2', 'int');
         $parent = $this->readdata('parent', 'int');
         $subject = $this->readdata('subject', 'text');
         $message = $this->readdata('message', 'text');
         $this->commentsadd($format, $type, $content, $content2, $parent, $subject, $message);
         // commentvote - GET - COMMENTS/vote
     } elseif ($method == 'post' and strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'comments' and strtolower($ex[3]) == 'vote' and count($ex) == 6) {
         $id = addslashes($ex[4]);
         $score = $this->readdata('vote', 'int');
         $format = $this->readdata('format', 'text');
         $this->commentvote($format, $id, $score);
         // FORUM
     } elseif (strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'forum') {
         $functioncall = strtolower($ex[3]);
         $subcall = strtolower($ex[4]);
         $argumentcount = count($ex);
         // list - GET - FORUM/LIST
         if ($method == 'get' and $functioncall == 'list' and $argumentcount == 4) {
             $format = $this->readdata('format', 'text');
             $page = $this->readdata('page', 'int');
             $pagesize = $this->readdata('pagesize', 'int');
             // TOPIC section
         } elseif ($functioncall == 'topic') {
             // list - GET - FORUM/TOPIC/LIST
             if ($method == 'get' and $subcall == 'list' and $argumentcount == 10) {
                 $format = $this->readdata('format', 'text');
                 $forum = $this->readdata('forum', 'int');
                 $search = $this->readdata('search', 'text');
                 $description = $this->readdata('description', 'text');
                 $sortmode = $this->readdata('sortmode', 'text');
                 $page = $this->readdata('page', 'int');
                 $pagesize = $this->readdata('pagesize', 'int');
                 // add - POST - FORUM/TOPIC/ADD
             } elseif ($method == 'post' and $subcall == 'add' and $argumentcount == 5) {
                 $format = $this->readdata('format', 'text');
                 $subject = $this->readdata('subject', 'text');
                 $content = $this->readdata('content', 'text');
                 $forum = $this->readdata('forum', 'int');
             }
         }
         // BUILDSERVICE
     } elseif (strtolower($ex[1]) == 'v1' and strtolower($ex[2]) == 'buildservice' and count($ex) > 4) {
         $functioncall = strtolower($ex[4]);
         $argumentcount = count($ex);
         // PROJECT section
         if (strtolower($ex[3] == 'project')) {
             // create - POST - PROJECT/CREATE
             if ($method == 'post' and $functioncall == 'create' and $argumentcount == 6) {
                 $format = $this->readdata('format', 'text');
                 $name = $this->readdata('name', 'text');
                 $version = $this->readdata('version', 'text');
                 $license = $this->readdata('license', 'text');
                 $url = $this->readdata('url', 'text');
                 $developers = $this->readdata('developers', 'text');
                 $summary = $this->readdata('summary', 'text');
                 $description = $this->readdata('description', 'text');
                 $requirements = $this->readdata('requirements', 'text');
                 $specfile = $this->readdata('specfile', 'text');
                 $this->buildserviceprojectcreate($format, $name, $version, $license, $url, $developers, $summary, $description, $requirements, $specfile);
                 // get - GET - PROJECT/GET/"project"
             } elseif ($method == 'get' and $functioncall == 'get' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $projectID = $ex[5];
                 $this->buildserviceprojectget($format, $projectID);
                 // delete - POST - PROJECT/DELETE/"project"
             } elseif ($method == 'post' and $functioncall == 'delete' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $projectID = $ex[5];
                 $this->buildserviceprojectdelete($format, $projectID);
                 // edit - POST - ROJECT/EDIT/"project"
             } elseif ($method == 'post' and $functioncall == 'edit' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $projectID = $ex[5];
                 $name = $this->readdata('name', 'text');
                 $version = $this->readdata('version', 'text');
                 $license = $this->readdata('license', 'text');
                 $url = $this->readdata('url', 'text');
                 $developers = $this->readdata('developers', 'text');
                 $summary = $this->readdata('summary', 'text');
                 $description = $this->readdata('description', 'text');
                 $requirements = $this->readdata('requirements', 'text');
                 $specfile = $this->readdata('specfile', 'text');
                 $this->buildserviceprojectedit($format, $projectID, $name, $version, $license, $url, $developers, $summary, $description, $requirements, $specfile);
                 // listall - GET - PROJECT/LIST
             } elseif ($method == 'get' and $functioncall == 'list' and $argumentcount == 6) {
                 $format = $this->readdata('format', 'text');
                 $page = $this->readdata('page', 'int');
                 $pagesize = $this->readdata('pagesize', 'int');
                 $this->buildserviceprojectlist($format, $page, $pagesize);
                 // generatespecfile - GET - PROJECT/UPLOADSOURCE
             } elseif ($method == 'post' and $functioncall == 'uploadsource' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $projectID = $ex[5];
                 $this->buildserviceprojectuploadsource($format, $projectID);
             } else {
                 $this->reportapisyntaxerror('buildservice/project');
             }
             // REMOTEACCOUNTS section
         } elseif (strtolower($ex[3]) == 'remoteaccounts') {
             if ($method == 'get' and $functioncall == 'list' and $argumentcount == 6) {
                 $format = $this->readdata('format', 'text');
                 $page = $this->readdata('page', 'int');
                 $pagesize = $this->readdata('pagesize', 'int');
                 $this->buildserviceremoteaccountslist($format, $page, $pagesize);
             } elseif ($method == 'post' and $functioncall == 'add' and $argumentcount == 6) {
                 $format = $this->readdata('format', 'text');
                 $type = $this->readdata('type', 'int');
                 $typeid = $this->readdata('typeid', 'text');
                 $data = $this->readdata('data', 'text');
                 $login = $this->readdata('login', 'text');
                 $password = $this->readdata('password', 'text');
                 $this->buildserviceremoteaccountsadd($format, $type, $typeid, $data, $login, $password);
             } elseif ($method == 'post' and $functioncall == 'edit' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $id = $ex[5];
                 $data = $this->readdata('data', 'text');
                 $login = $this->readdata('login', 'text');
                 $password = $this->readdata('password', 'text');
                 $this->buildserviceremoteaccountsedit($format, $id, $login, $password, $data);
             } elseif ($method == 'get' and $functioncall == 'get' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $id = $ex[5];
                 $this->buildserviceremoteaccountsget($format, $id);
             } elseif ($method == 'post' and $functioncall == 'remove' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $id = $ex[5];
                 $this->buildserviceremoteaccountsremove($format, $id);
             } else {
                 $this->reportapisyntaxerror('buildservice/remoteaccounts');
             }
             // BUILDSERVICES section
         } elseif (strtolower($ex[3] == 'buildservices')) {
             if ($method == 'get' and $functioncall == 'list' and $argumentcount == 6) {
                 $format = $this->readdata('format', 'text');
                 $page = $this->readdata('page', 'int');
                 $pagesize = $this->readdata('pagesize', 'int');
                 $this->buildservicebuildserviceslist($format, $page, $pagesize);
             } elseif ($method == 'get' and $functioncall == 'get' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $buildserviceID = $ex[5];
                 $this->buildservicebuildservicesget($format, $buildserviceID);
             } else {
                 $this->reportapisyntaxerror('buildservice/buildservices');
             }
             // JOBS section
         } elseif (strtolower($ex[3] == 'jobs')) {
             // getbuildcapabilities - GET - JOBS/GETBUILDCAPABILITIES
             if ($method == 'get' and $functioncall == 'list' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $projectID = $ex[5];
                 $page = $this->readdata('page', 'int');
                 $pagesize = $this->readdata('pagesize', 'int');
                 $this->buildservicejobslist($format, $projectID, $page, $pagesize);
                 // create - POST - JOBS/CREATE/"project"/"buildsevice"/"target"
             } elseif ($method == 'post' and $functioncall == 'create' and $argumentcount == 9) {
                 $format = $this->readdata('format', 'text');
                 $projectID = $ex[5];
                 $buildserviceID = $ex[6];
                 $target = $ex[7];
                 $this->buildservicejobscreate($format, $projectID, $buildserviceID, $target);
                 // cancel - POST - JOBS/CANCEL/"buildjob"
             } elseif ($method == 'post' and $functioncall == 'cancel' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $buildjobID = $ex[5];
                 $this->buildservicejobscancel($format, $buildjobID);
                 // get - GET - JOBS/GET/"buildjob"
             } elseif ($method == 'get' and $functioncall == 'get' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $buildjobID = $ex[5];
                 $this->buildservicejobsget($format, $buildjobID);
                 // getoutput - GET - JOBS/GETOUTPOT/"buildjob"
             } elseif ($method == 'get' and $functioncall == 'getoutput' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $buildjobID = $ex[5];
                 $this->buildservicejobsgetoutput($format, $buildjobID);
             } else {
                 $this->reportapisyntaxerror('buildservice/jobs');
             }
             // PUBLISHING section
         } elseif (strtolower($ex[3] == 'publishing')) {
             // getpublishingcapabilities - GET - PUBLISHING/GETPUBLISHINGCAPABILITIES
             if ($method == 'get' and $functioncall == 'getpublishingcapabilities' and $argumentcount == 6) {
                 $format = $this->readdata('format', 'text');
                 $page = $this->readdata('page', 'int');
                 $pagesize = $this->readdata('pagesize', 'int');
                 $this->buildservicepublishinggetpublishingcapabilities($format, $page, $pagesize);
                 // getpublisher - GET - PUBLISHING/GETPUBLISHER
             } elseif ($method == 'get' and $functioncall == 'getpublisher' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $publisherID = $ex[5];
                 $this->buildservicepublishinggetpublisher($format, $publisherID);
                 // publishtargetresult - POST - PUBLISHING/PUBLISHTARGETRESULT/"buildjob"/"publisher"
             } elseif ($method == 'post' and $functioncall == 'publishtargetresult' and $argumentcount == 8) {
                 $format = $this->readdata('format', 'text');
                 $buildjobID = $ex[5];
                 $publisherID = $ex[6];
                 $this->buildservicepublishingpublishtargetresult($format, $buildjobID, $publisherID);
                 // savefields - POST - PUBLISHING/SAVEFIELDS/"project"
             } elseif ($method == 'post' and $functioncall == 'savefields' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $projectID = $ex[5];
                 $fields = $this->readdata('fields', 'array');
                 $this->buildservicepublishingsavefields($format, $projectID, $fields);
                 // getfields - GET - PUBLISHING/GETFIELDS/"project"
             } elseif ($method == 'get' and $functioncall == 'getfields' and $argumentcount == 7) {
                 $format = $this->readdata('format', 'text');
                 $projectID = $ex[5];
                 $this->buildservicepublishinggetfields($format, $projectID);
             } else {
                 $this->reportapisyntaxerror('buildservice/publishing');
             }
         } else {
             $this->reportapisyntaxerror('buildservice');
         }
     } else {
         $format = $this->readdata('format', 'text');
         $txt = 'please check the syntax. api specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services' . "\n";
         $txt .= $this->getdebugoutput();
         echo OCSXML::generatexml($format, 'failed', 999, $txt);
     }
     exit;
 }