root / rpc.php

View | Annotate | Download (3.3 KB)

1 b11bf223 Andreas
 <?php
2 b11bf223 Andreas
3 9a37d81c Andreas
 /***************************************************************************
4 b11bf223 Andreas
  *
5 9a37d81c Andreas
  * Nephthys - file sharing management
6 b11bf223 Andreas
  * Copyright (c) by Andreas Unterkircher, unki@netshadow.at
7 b11bf223 Andreas
  *
8 9a37d81c Andreas
  *  This file is part of Nephthys.
9 9a37d81c Andreas
  *
10 9a37d81c Andreas
  *  Nephthys is free software: you can redistribute it and/or modify
11 b11bf223 Andreas
  *  it under the terms of the GNU General Public License as published by
12 9a37d81c Andreas
  *  the Free Software Foundation, either version 3 of the License, or
13 9a37d81c Andreas
  *  (at your option) any later version.
14 b11bf223 Andreas
  *
15 9a37d81c Andreas
  *  Nephthys is distributed in the hope that it will be useful,
16 b11bf223 Andreas
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 b11bf223 Andreas
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 b11bf223 Andreas
  *  GNU General Public License for more details.
19 b11bf223 Andreas
  *
20 b11bf223 Andreas
  *  You should have received a copy of the GNU General Public License
21 9a37d81c Andreas
  *  along with Nephthys. If not, see <http://www.gnu.org/licenses/>.
22 b11bf223 Andreas
  *
23 9a37d81c Andreas
  ***************************************************************************/
24 b11bf223 Andreas
25 b11bf223 Andreas
 require_once "nephthys.class.php";
26 b11bf223 Andreas
27 b11bf223 Andreas
 class NEPHTHYS_RPC {
28 b11bf223 Andreas
29 b11bf223 Andreas
    public function __construct()
30 b11bf223 Andreas
    {
31 b11bf223 Andreas
       session_start();
32 b11bf223 Andreas
33 b11bf223 Andreas
    } // __construct()
34 b11bf223 Andreas
35 b11bf223 Andreas
    public function process_ajax_request()
36 b11bf223 Andreas
    {
37 b11bf223 Andreas
       require_once 'HTML/AJAX/Server.php';
38 b11bf223 Andreas
39 b11bf223 Andreas
       $server = new HTML_AJAX_Server();
40 b11bf223 Andreas
       $server->handleRequest();
41 b11bf223 Andreas
42 78ea2461 Andreas
       /* was there only an init call, then stop */
43 78ea2461 Andreas
       if($_GET['mode'] == 'init' && $_GET['client'] == 'all')
44 78ea2461 Andreas
          return true;
45 78ea2461 Andreas
46 27af6e13 Andreas
       define("RPC_CALL", uniqid());
47 27af6e13 Andreas
48 b11bf223 Andreas
       $nephthys = new NEPHTHYS();
49 b11bf223 Andreas
50 0bc46f67 Andreas
       // if no action has been specified we are going to redirect
51 0bc46f67 Andreas
       // this request to Nephthys start page.
52 0bc46f67 Andreas
       if(!isset($_GET['action']) && !isset($_POST['action'])) {
53 0bc46f67 Andreas
          Header("Location: ". $nephthys->cfg->web_path);
54 b11bf223 Andreas
          return;
55 0bc46f67 Andreas
       }
56 b11bf223 Andreas
57 b11bf223 Andreas
       if(isset($_GET['action']))
58 b11bf223 Andreas
          $action = $_GET['action'];
59 b11bf223 Andreas
       if(isset($_POST['action']))
60 b11bf223 Andreas
          $action = $_POST['action'];
61 b11bf223 Andreas
62 b11bf223 Andreas
       switch($action) {
63 123b4741 Andreas
          case 'get_content':
64 bc003de0 Andreas
             print $nephthys->get_content();
65 3d90b322 Andreas
             break;
66 c8a1fee6 Andreas
          case 'get_menu':
67 bc003de0 Andreas
             print $nephthys->get_menu();
68 c8a1fee6 Andreas
             break;
69 da8cd0c3 Andreas
          case 'store':
70 da8cd0c3 Andreas
             print $nephthys->store();
71 da8cd0c3 Andreas
             break;
72 c8a1fee6 Andreas
          case 'login':
73 c8a1fee6 Andreas
             print $nephthys->login();
74 5453eb2a Andreas
             break;
75 5453eb2a Andreas
          case 'logout':
76 c8a1fee6 Andreas
             print $nephthys->logout();
77 5453eb2a Andreas
             break;
78 848b4dbd Andreas
          case 'notifybucket':
79 848b4dbd Andreas
             print $nephthys->notifybucket();
80 dde393b3 Andreas
             break;
81 848b4dbd Andreas
          case 'deletebucket':
82 848b4dbd Andreas
             print $nephthys->delete_bucket();
83 3d90b322 Andreas
             break;
84 fda203d7 Andreas
          case 'validateemail':
85 8f9d867a Andreas
             if(isset($_POST['address']) && !empty($_POST['address']) && $nephthys->is_valid_email($_POST['address']))
86 fda203d7 Andreas
                print "ok";
87 fda203d7 Andreas
             else
88 fda203d7 Andreas
                print "failed";
89 fda203d7 Andreas
             break;
90 fbaee801 Andreas
          case 'sortorder':
91 fbaee801 Andreas
             print $nephthys->update_sort_order();
92 fbaee801 Andreas
             break;
93 d08c99b8 Andreas
          case 'getxmllist':
94 d08c99b8 Andreas
             print $nephthys->get_xml_list();
95 d08c99b8 Andreas
             break;
96 45ec4be6 Andreas
          case 'get_bucket_info':
97 45ec4be6 Andreas
             print $nephthys->get_bucket_info();
98 45ec4be6 Andreas
             break;
99 27af6e13 Andreas
          case 'filemgr':
100 27af6e13 Andreas
             print $nephthys->load_filemgr();
101 27af6e13 Andreas
             break;
102 da8cd0c3 Andreas
          default:
103 81d72baa Andreas
             print "unkown action ". $action;
104 da8cd0c3 Andreas
             break;
105 b11bf223 Andreas
       }
106 b11bf223 Andreas
107 b11bf223 Andreas
    } // process_ajax_request();
108 b11bf223 Andreas
109 b11bf223 Andreas
 } // class NEPHTHYS_RPC
110 b11bf223 Andreas
111 b11bf223 Andreas
 $rpc = new NEPHTHYS_RPC();
112 b11bf223 Andreas
 $rpc->process_ajax_request();
113 b11bf223 Andreas
114 b392cb9b Andreas
 // vim: set filetype=php expandtab softtabstop=3 tabstop=3 shiftwidth=3 autoindent smartindent:
115 b11bf223 Andreas
 ?>