X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=rpc.php;h=6c94e8f72653a0e6715bd09fe0ee04519c66576e;hp=d0a6c1c9e088ea68c96153a30705fee9af1371a8;hb=a8c8bd8ee5c29db5512230eaeb65e44794e21b89;hpb=fc802d09f196e338f7485e38057ec84df5c81bf2 diff --git a/rpc.php b/rpc.php index d0a6c1c..6c94e8f 100644 --- 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'])) { @@ -48,11 +54,11 @@ class PHPFSPOT_RPC { break; case 'show_available_tags': - $fspot->getAvailableTags(); + print $fspot->getAvailableTags(); break; case 'show_selected_tags': - $fspot->getSelectedTags(); + print $fspot->getSelectedTags(); break; case 'addtag': @@ -95,10 +101,24 @@ class PHPFSPOT_RPC { break; case 'search': - $fspot->startSearch($_GET['for'], $_GET['from'], $_GET['to'], $_GET['sort_order']); + $fspot->startSearch($_GET['for'], $_GET['from'], $_GET['to']); + + if((isset($_GET['from']) && $fspot->isValidDate($_GET['from'])) && + (isset($_GET['to']) && $fspot->isValidDate($_GET['to']))) { + } + else { + $fspot->startSearch($_GET['for']); + } + break; + + case 'update_sort_order': + if(isset($_POST['value']) && is_string($_POST['value'])) { + print $fspot->updateSortOrder($_POST['value']); + } break; case 'get_export': + /* $_GET['mode'] will be validated by getExport() */ $fspot->getExport($_GET['mode']); break; @@ -134,7 +154,7 @@ class PHPFSPOT_RPC { } // process_ajax_request(); -} +} // class PHPFSPOT_RPC $rpc = new PHPFSPOT_RPC(); $rpc->process_ajax_request();