root / rpc.php

View | Annotate | Download (5.3 KB)

1 37091420 Andreas
 <?php
2 37091420 Andreas
3 37091420 Andreas
 /* *************************************************************************
4 37091420 Andreas
  *
5 7617d447 Andreas
  * phpfspot, presents your F-Spot photo collection in Web browsers.
6 7617d447 Andreas
  *
7 7617d447 Andreas
  * Copyright (c) by Andreas Unterkircher
8 37091420 Andreas
  *
9 37091420 Andreas
  *  This program is free software; you can redistribute it and/or modify
10 37091420 Andreas
  *  it under the terms of the GNU General Public License as published by
11 37091420 Andreas
  *  the Free Software Foundation; either version 2 of the License, or
12 6e2d319e Andreas
  *  any later version.
13 37091420 Andreas
  *
14 37091420 Andreas
  *  This program is distributed in the hope that it will be useful,
15 37091420 Andreas
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 37091420 Andreas
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 37091420 Andreas
  *  GNU General Public License for more details.
18 37091420 Andreas
  *
19 37091420 Andreas
  *  You should have received a copy of the GNU General Public License
20 37091420 Andreas
  *  along with this program; if not, write to the Free Software
21 37091420 Andreas
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 37091420 Andreas
  *
23 37091420 Andreas
  * *************************************************************************/
24 37091420 Andreas
25 37091420 Andreas
 require_once "phpfspot.class.php";
26 37091420 Andreas
27 cc5fc15f Andreas
 /**
28 cc5fc15f Andreas
  * PHPFSPOT_RPC class
29 cc5fc15f Andreas
  *
30 cc5fc15f Andreas
  * handles AJAX-RPC calls from client browsers
31 cc5fc15f Andreas
  * @package phpfspot
32 cc5fc15f Andreas
  */
33 37091420 Andreas
 class PHPFSPOT_RPC {
34 37091420 Andreas
35 cc5fc15f Andreas
    /**
36 cc5fc15f Andreas
     * PHPFSPOT_RPC constructor
37 cc5fc15f Andreas
     */
38 37091420 Andreas
    public function __construct()
39 37091420 Andreas
    {
40 cc5fc15f Andreas
       /* start PHP session */
41 37091420 Andreas
       session_start();
42 37091420 Andreas
43 37091420 Andreas
    } // __construct()
44 37091420 Andreas
45 3ca950a9 Andreas
    public function process_ajax_request()
46 37091420 Andreas
    {
47 37091420 Andreas
       require_once 'HTML/AJAX/Server.php';
48 37091420 Andreas
49 37091420 Andreas
       $server = new HTML_AJAX_Server();
50 37091420 Andreas
       $server->handleRequest();
51 37091420 Andreas
52 cc5fc15f Andreas
       $phpfspot = new PHPFSPOT();
53 37091420 Andreas
54 d52a300c Andreas
       /* if no action is specified, no need to further process this
55 d52a300c Andreas
        * function here.
56 d52a300c Andreas
        */
57 f95833e6 Andreas
       if(!isset($_GET['action']) && !isset($_POST['action']))
58 d52a300c Andreas
          return;
59 d52a300c Andreas
60 f95833e6 Andreas
       if(isset($_GET['action']))
61 f95833e6 Andreas
          $action = $_GET['action'];
62 f95833e6 Andreas
       if(isset($_POST['action']))
63 f95833e6 Andreas
          $action = $_POST['action'];
64 f95833e6 Andreas
65 f95833e6 Andreas
       switch($action) {
66 37091420 Andreas
          case 'showphoto':
67 256fffa6 Andreas
             if(isset($_GET['id']) && is_numeric($_GET['id'])) {
68 9471faab Andreas
                print $phpfspot->showPhoto($_GET['id']);
69 256fffa6 Andreas
             }
70 37091420 Andreas
             break;
71 193a2982 Andreas
72 af0be8f9 Andreas
          case 'getxmltaglist':
73 cc5fc15f Andreas
             print $phpfspot->get_xml_tag_list();
74 af0be8f9 Andreas
             break;
75 af0be8f9 Andreas
76 193a2982 Andreas
          case 'show_available_tags':
77 cc5fc15f Andreas
             print $phpfspot->getAvailableTags();
78 193a2982 Andreas
             break;
79 193a2982 Andreas
80 193a2982 Andreas
          case 'show_selected_tags':
81 cc5fc15f Andreas
             print $phpfspot->getSelectedTags();
82 193a2982 Andreas
             break;
83 193a2982 Andreas
84 193a2982 Andreas
          case 'addtag':
85 d9ee4599 Andreas
             if(isset($_POST['id']) && is_numeric($_POST['id'])) {
86 cc5fc15f Andreas
                print $phpfspot->addTag($_POST['id']);
87 256fffa6 Andreas
             }
88 193a2982 Andreas
             break;
89 193a2982 Andreas
90 193a2982 Andreas
          case 'deltag':
91 d9ee4599 Andreas
             if(isset($_POST['id']) && is_numeric($_POST['id'])) {
92 cc5fc15f Andreas
                print $phpfspot->delTag($_POST['id']);
93 256fffa6 Andreas
             }
94 193a2982 Andreas
             break;
95 193a2982 Andreas
96 6f67421b Andreas
          case 'reset':
97 cc5fc15f Andreas
             $phpfspot->resetTagSearch();
98 cc5fc15f Andreas
             $phpfspot->resetNameSearch();
99 cc5fc15f Andreas
             $phpfspot->resetTags();
100 cc5fc15f Andreas
             $phpfspot->resetDateSearch();
101 f36faab3 Andreas
             $phpfspot->resetRateSearch();
102 cc5fc15f Andreas
             $phpfspot->resetPhotoView();
103 193a2982 Andreas
             break;
104 193a2982 Andreas
105 ad475b7b Andreas
          case 'tagcondition':
106 d9ee4599 Andreas
             if(isset($_POST['mode']) && in_array($_POST['mode'], Array('or', 'and'))) {
107 cc5fc15f Andreas
                print $phpfspot->setTagCondition($_POST['mode']);
108 256fffa6 Andreas
             }
109 ad475b7b Andreas
             break;
110 ad475b7b Andreas
111 60b6594f Andreas
          case 'show_photo_index':
112 256fffa6 Andreas
             if(isset($_GET['begin_with']) && is_numeric($_GET['begin_with'])) {
113 256fffa6 Andreas
                $_SESSION['begin_with'] = $_GET['begin_with'];
114 256fffa6 Andreas
             }
115 256fffa6 Andreas
             else {
116 256fffa6 Andreas
                unset($_SESSION['begin_with']);
117 256fffa6 Andreas
             }
118 addc9889 Andreas
             if(isset($_GET['last_photo']) && is_numeric($_GET['last_photo']))
119 addc9889 Andreas
                $_SESSION['last_photo'] = $_GET['last_photo'];
120 addc9889 Andreas
121 89f78a74 Andreas
             print $phpfspot->showPhotoIndex();
122 60b6594f Andreas
             break;
123 d902cdfd Andreas
124 588923cb Andreas
          case 'showcredits':
125 cc5fc15f Andreas
             $phpfspot->showCredits();
126 588923cb Andreas
             break;
127 588923cb Andreas
128 984b068b Andreas
          case 'search':
129 cc5fc15f Andreas
             print $phpfspot->startSearch();
130 5bc35081 Andreas
             break;
131 5bc35081 Andreas
132 5bc35081 Andreas
          case 'update_sort_order':
133 5bc35081 Andreas
             if(isset($_POST['value']) && is_string($_POST['value'])) {
134 cc5fc15f Andreas
                print $phpfspot->updateSortOrder($_POST['value']);
135 8223eed3 Andreas
             }
136 4a0b6f61 Andreas
             break;
137 4a0b6f61 Andreas
138 6198d8ac Andreas
          case 'update_photo_version':
139 6198d8ac Andreas
             if(isset($_POST['photo_version']) && is_numeric($_POST['photo_version']) &&
140 6198d8ac Andreas
                isset($_POST['photo_idx']) && is_numeric($_POST['photo_idx'])) {
141 6198d8ac Andreas
                print $phpfspot->update_photo_version($_POST['photo_idx'], $_POST['photo_version']);
142 6198d8ac Andreas
             }
143 6198d8ac Andreas
             break;
144 6198d8ac Andreas
145 e0ff14d4 Andreas
          case 'get_export':
146 7f6d9076 Andreas
             /* $_GET['mode'] will be validated by getExport() */
147 cc5fc15f Andreas
             $phpfspot->getExport($_GET['mode']);
148 e0ff14d4 Andreas
             break;
149 e0ff14d4 Andreas
150 15a6c1b6 Andreas
          case 'get_photo_to_show':
151 6198d8ac Andreas
             print $phpfspot->get_current_photo();
152 15a6c1b6 Andreas
             break;
153 15a6c1b6 Andreas
154 4a0b6f61 Andreas
          case 'get_calendar_matrix':
155 5bc4f098 Andreas
             if(isset($_GET['date']) && is_string($_GET['date'])) {
156 5bc4f098 Andreas
                $phpfspot->get_calendar_matrix($_GET['date']);
157 de91ca83 Andreas
             }
158 4a0b6f61 Andreas
             break;
159 4a0b6f61 Andreas
160 3d567f23 Andreas
          case 'what_to_do':
161 cc5fc15f Andreas
             print $phpfspot->whatToDo();
162 3d567f23 Andreas
             break;
163 3d567f23 Andreas
164 005562e4 Andreas
          case 'reset_slideshow':
165 cc5fc15f Andreas
             print $phpfspot->resetSlideShow();
166 005562e4 Andreas
             break;
167 005562e4 Andreas
168 005562e4 Andreas
          case 'get_next_slideshow_img':
169 cc5fc15f Andreas
             print $phpfspot->getNextSlideShowImage();
170 005562e4 Andreas
             break;
171 a36bd6f4 Andreas
172 a36bd6f4 Andreas
          case 'get_prev_slideshow_img':
173 cc5fc15f Andreas
             print $phpfspot->getPrevSlideShowImage();
174 a36bd6f4 Andreas
             break;
175 005562e4 Andreas
176 37091420 Andreas
       }
177 37091420 Andreas
178 37091420 Andreas
    } // process_ajax_request();
179 37091420 Andreas
180 d52a300c Andreas
 } // class PHPFSPOT_RPC
181 37091420 Andreas
182 37091420 Andreas
 $rpc = new PHPFSPOT_RPC();
183 37091420 Andreas
 $rpc->process_ajax_request();
184 37091420 Andreas
185 37091420 Andreas
 ?>