issue100, switch search to POST HTTP
authorAndreas Unterkircher <unki@netshadow.at>
Sun, 13 Jan 2008 16:45:48 +0000 (17:45 +0100)
committerAndreas Unterkircher <unki@netshadow.at>
Sun, 13 Jan 2008 16:45:48 +0000 (17:45 +0100)
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
phpfspot.class.php
phpfspot.js
rpc.php

index 9a74a9a078a2484f09978f9eb5b891b7464cd8f3..09540400137b2b048bbd82c5a3f9abc78c56b9c5 100644 (file)
@@ -1460,19 +1460,19 @@ class PHPFSPOT {
     */
    public function startSearch($searchfor_tag, $from = 0, $to = 0)
    {
-      if(isset($_GET['from']) && $fspot->isValidDate($_GET['from'])) {
-         $from = $_GET['from'];
+      if(isset($_POST['from']) && $this->isValidDate($_POST['from'])) {
+         $from = $_POST['from'];
       }
-      if(isset($_GET['to']) && $fspot->isValidDate($_GET['to'])) {
-         $to = $_GET['to'];
+      if(isset($_POST['to']) && $this->isValidDate($_POST['to'])) {
+         $to = $_POST['to'];
       }
 
-      if(isset($_GET['for_tag']) && is_string($_GET['for_tag'])) {
-         $searchfor_tag = $_GET['for_tag'];
+      if(isset($_POST['for_tag']) && is_string($_POST['for_tag'])) {
+         $searchfor_tag = $_POST['for_tag'];
       }
 
-      if(isset($_GET['for_name']) && is_string($_GET['for_name'])) {
-         $searchfor_name = $_GET['for_name'];
+      if(isset($_POST['for_name']) && is_string($_POST['for_name'])) {
+         $searchfor_name = $_POST['for_name'];
       }
 
       $this->get_tags();
@@ -1499,6 +1499,8 @@ class PHPFSPOT {
          }
       }
 
+      return "ok";
+
    } // startSearch()
 
    /**
index d11f52477649edc2840e058cba4c603baf8f1172..c90d80e1365e337fb730ff4abed673d02d23c8c3 100644 (file)
@@ -92,9 +92,6 @@ function setCheckedValue(condition, value) {
 
 function startSearch()
 {
-   var searchfor_tag = document.getElementsByName('searchfor_tag')[0].value;
-   var searchfor_name = document.getElementsByName('searchfor_name')[0].value;
-
    from_year = document.getElementById('fromyear').value;
    from_month = document.getElementById('frommonth').value;
    from_day = document.getElementById('fromday').value;
@@ -104,27 +101,32 @@ function startSearch()
    to_day = document.getElementById('today').value;
    to = to_year +"-"+ to_month +"-"+ to_day;
 
-   var request = 'rpc.php?action=search';
+   // Create object with values of the form
+   var objTemp = new Object();
+   objTemp['action'] = 'search';
 
-   if(searchfor_tag != "") {
-      request = request + '&for_tag=' + searchfor_tag;
+   if(document.getElementsByName('searchfor_tag')[0].value != "") {
+      objTemp['for_tag'] = document.getElementsByName('searchfor_tag')[0].value;
    }
-   
-   if(searchfor_name != "") {
-      request = request + '&for_name=' + searchfor_name;
+   if(document.getElementsByName('searchfor_name')[0].value != "") {
+      objTemp['for_name'] = document.getElementsByName('searchfor_name')[0].value;
    }
-   
    if(document.getElementsByName('consider_date')[0].checked == true) {
-      request = request + '&from='+ from +'&to='+ to;
+      objTemp['from'] = from;
+      objTemp['to'] = to;
    }
 
-   HTML_AJAX.grab(encodeURI(request));
+   var retr = HTML_AJAX.post('rpc.php', objTemp);
+   if(retr == "ok") {
+      refreshAvailableTags();
+      refreshSelectedTags();
+      showPhotoIndex();
+   }
+   else {
+      window.alert(retr);
+   }
 
-   refreshAvailableTags();
-   refreshSelectedTags();
-   showPhotoIndex();
-   
-}
+} // startSearch()
 
 function datesearch()
 {
diff --git a/rpc.php b/rpc.php
index 1f8698e408d6e4b0cc1fd9468aac7171cf07f91c..b2d258c5c0748b1530bcc229d4ebfcafc6232c09 100644 (file)
--- a/rpc.php
+++ b/rpc.php
@@ -43,10 +43,15 @@ class PHPFSPOT_RPC {
       /* if no action is specified, no need to further process this
        * function here.
        */
-      if(!isset($_GET['action']))
+      if(!isset($_GET['action']) && !isset($_POST['action']))
          return;
 
-      switch($_GET['action']) {
+      if(isset($_GET['action']))
+         $action = $_GET['action'];
+      if(isset($_POST['action']))
+         $action = $_POST['action'];
+
+      switch($action) {
          case 'showphoto':
             if(isset($_GET['id']) && is_numeric($_GET['id'])) {
                $fspot->showPhoto($_GET['id']);
@@ -102,7 +107,7 @@ class PHPFSPOT_RPC {
             break;
 
          case 'search':
-            $fspot->startSearch($_GET['for']);
+            print $fspot->startSearch($_GET['for']);
             break;
 
          case 'update_sort_order':