missing function keyword for process_ajax_request()
[phpfspot.git] / rpc.php
diff --git a/rpc.php b/rpc.php
index 4ffae5f5fbddd3cc58884f25c3136e8abcd809e2..0bd04fe9d036e1bef630467205bc07849685dd04 100644 (file)
--- a/rpc.php
+++ b/rpc.php
@@ -31,7 +31,7 @@ class PHPFSPOT_RPC {
 
    } // __construct()
 
-   function process_ajax_request()
+   public function process_ajax_request()
    {
       require_once 'HTML/AJAX/Server.php';
 
@@ -40,6 +40,12 @@ class PHPFSPOT_RPC {
 
       $fspot = new PHPFSPOT();
 
+      /* if no action is specified, no need to further process this
+       * function here.
+       */
+      if(!isset($_GET['action']))
+         return;
+
       switch($_GET['action']) {
          case 'showphoto':
             if(isset($_GET['id']) && is_numeric($_GET['id'])) {
@@ -95,10 +101,18 @@ class PHPFSPOT_RPC {
             break;
 
          case 'search':
-            $fspot->startSearch($_GET['for'], $_GET['from'], $_GET['to'], $_GET['sort_order']);
+               $fspot->startSearch($_GET['for'], $_GET['sort_order'], $_GET['from'], $_GET['to']);
+            
+            if((isset($_GET['from']) && $fspot->isValidDate($_GET['from'])) &&
+               (isset($_GET['to']) && $fspot->isValidDate($_GET['to']))) {
+            }
+            else {
+               $fspot->startSearch($_GET['for'], $_GET['sort_order']);
+            }
             break;
 
          case 'get_export':
+            /* $_GET['mode'] will be validated by getExport() */
             $fspot->getExport($_GET['mode']);
             break;
 
@@ -107,9 +121,9 @@ class PHPFSPOT_RPC {
             break;
 
          case 'get_calendar_matrix':
-            if((is_numeric($_GET['year']) || $_GET['year'] == "") &&
-               (is_numeric($_GET['month']) || $_GET['month'] == "") &&
-               (is_numeric($_GET['day']) || $_GET['month'] == "")) {
+            if((is_numeric($_GET['year']) || !isset($_GET['year'])) &&
+               (is_numeric($_GET['month']) || !isset($_GET['month'])) &&
+               (is_numeric($_GET['day']) || !isset($_GET['day']))) {
                $fspot->get_calendar_matrix($_GET['year'], $_GET['month'], $_GET['day']);
             }
             break;
@@ -134,7 +148,7 @@ class PHPFSPOT_RPC {
 
    } // process_ajax_request();
 
-}
+} // class PHPFSPOT_RPC
 
 $rpc = new PHPFSPOT_RPC();
 $rpc->process_ajax_request();