]> git.defcon.no Git - hermes/blobdiff - api/numbers.php
Forgot one instance of 'permitedcalls' ...
[hermes] / api / numbers.php
index 7874394a1a98a65a685cffc0552ddcdf93e27658..39e861ea052d32f27111872edf32406bb4a7110e 100644 (file)
@@ -1,4 +1,30 @@
 <?php
+/*
+#  Copyright (c) 2012, Gjøvik University College
+#  All rights reserved.
+
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions are met:
+#      * Redistributions of source code must retain the above copyright
+#        notice, this list of conditions and the following disclaimer.
+#      * Redistributions in binary form must reproduce the above copyright
+#        notice, this list of conditions and the following disclaimer in the
+#        documentation and/or other materials provided with the distribution.
+#      * Neither the name of the Gjøvik University College nor the
+#        names of its contributors may be used to endorse or promote products
+#        derived from this software without specific prior written permission.
+#       
+#  THIS SOFTWARE IS PROVIDED BY Gjøvik University College ''AS IS'' AND ANY
+#  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+#  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+#  DISCLAIMED. IN NO EVENT SHALL Gjøvik University College BE LIABLE FOR ANY
+#  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+#  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+#  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+#  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
 require_once('config.php');
 require_once('lib/auth_base.php');
 require_once('lib/common_functions.php');
@@ -28,12 +54,12 @@ token_auth();
                        $limit = 0;
                        $random = false;
                        $search = null;
-                       if ( array_key_exists('limit', $_GET ) && is_numeric( $_GET['limit']))
-                               $limit = $_GET['limit'];
+                       if ( array_key_exists('limit', $_POST ) && is_numeric( $_POST['limit']))
+                               $limit = $_POST['limit'];
 
-                       if ( array_key_exists('search', $_GET ) )
-                               $search = $_GET['search'];
-                       else if ( array_key_exists('random', $_GET ) && (strtolower( $_GET['random'] ) === 'true'))
+                       if ( array_key_exists('search', $_POST ) )
+                               $search = $_POST['search'];
+                       else if ( array_key_exists('random', $_POST ) && (strtolower( $_POST['random'] ) === 'true'))
                                $random = true;
 
                        $numbers = null;
@@ -55,10 +81,10 @@ token_auth();
                        print json_encode( array( 'response' => 'failed', 'cause' => 'empty', 'detail' => 'Empty result.' ));
                        break;
                case "/add_range":
-                       if ( array_key_exists('start', $_GET) && array_key_exists('end', $_GET) )
+                       if ( array_key_exists('start', $_POST) && array_key_exists('end', $_POST) )
                        {
-                               $start = $_GET['start'];
-                               $end = sql_clean( $_GET['end'] );
+                               $start = $_POST['start'];
+                               $end = sql_clean( $_POST['end'] );
                                $result = add_range( $start, $end );
                                if ( $result === 'ok' )
                                {
@@ -73,9 +99,9 @@ token_auth();
                case "/add":
                        // TODO: This should return better responses!
                        //  Currently, it will fail with "invalid"
-                       if ( array_key_exists('number', $_GET))
+                       if ( array_key_exists('number', $_POST))
                        {
-                               $number = $_GET['number'];
+                               $number = $_POST['number'];
 
                                if (! verify_e164( $number ) )
                                {
@@ -102,9 +128,9 @@ token_auth();
                        print json_encode ( array( 'response' => 'invalid') );
                        break;
                case "/remove":
-                       if ( array_key_exists('number', $_GET))
+                       if ( array_key_exists('number', $_POST))
                        {
-                               $number = $_GET['number'];
+                               $number = $_POST['number'];
 
                                if (! verify_e164( $number ) )
                                {
@@ -127,9 +153,9 @@ token_auth();
                        print json_encode ( array( 'response' => 'invalid') );
                        break;
                case "/inpool":
-                       if ( array_key_exists('number', $_GET))
+                       if ( array_key_exists('number', $_POST))
                        {
-                               $number = $_GET['number'];
+                               $number = $_POST['number'];
                                if ( number_inpool( $number ) )
                                        print  json_encode ( array( 'response' => 'ok', 'number' => $number ) );
                                else