source: trunk/plog-admin/plog-rpc.php @ 590

Revision 590, 2.6 KB checked in by sidtheduck, 19 months ago (diff)

Large commit based on work with Kim Parsell and myself
Should be ready for a release candidate after this commit.
Items worked on:

  • Large overhaul for code cleanup and syntax standardization
  • Security fixes for folder permissions on all server environments (now all directories should be set to 0755 and all files set to 0644)
  • Works compeletely with safe_mode restrictions using FTP commands
  • Beginnings of plugin usage (no architecture yet, but start of code standardization and addon code)
  • Fixing comments and adding security
  • More error messages
  • Minor fixes to upgrade and install process
  • Should fix tickets #188, #206, #194, #195, #197, #201, #203, #204, #89, #174, #200
  • Many other minor edits that I can't remember now (hopefully future commits will be much smaller and deal with individual issues, enhancements, or bugs)
Line 
1<?php
2// load configuration variables from database, plog-globals, & plog-includes/plog-functions
3require_once(dirname(dirname(__FILE__)).'/plog-load-config.php');
4require(PLOGGER_DIR.'plog-admin/plog-admin.php');
5require_once(PLOGGER_DIR.'plog-admin/plog-admin-functions.php');
6
7$output = '';
8
9$action_result = array();
10
11if ($_POST['action'] == 'update') {
12
13        // What field are we updating?
14        $field = $_POST['field'];
15
16        // With what?
17        $content = str_replace(array('&nbsp;', '%20', '%26nbsp%3B'), ' ', $_POST['content']);
18        $content = trim($content);
19
20        // Now we parse the field to be updated and the id number from the field variable
21        $var = split('-', $field);
22        $type = $var[0];
23        $field = $var[1];
24        $id = $var[2];
25
26        //print "debug: field = ".$field.", content = ".$content.", id = ".$id;
27
28        if ($type == 'picture') {
29                $result = update_picture_field($id, $field, $content);
30                if ($result['output']) {
31                        if (empty($content)) {
32                                $content = '&nbsp;';
33                        }
34                        echo stripslashes($content);
35                } else {
36                        echo plog_tr('Error').": ".$result['errors'];
37                }
38        }
39        elseif ($type == 'album') {
40                $result = update_album_field($id, $field, $content);
41                if ($result['output']) {
42                        if (empty($content)) {
43                                $content = '&nbsp;';
44                        }
45                        echo stripslashes($content);
46                } else {
47                        echo plog_tr('Error').": ".$result['errors'];
48                }
49        }
50        elseif ($type == 'collection') {
51                $result = update_collection_field($id, $field, $content);
52                if ($result['output']) {
53                        if (empty($content)) {
54                                $content = '&nbsp;';
55                        }
56                        echo stripslashes($content);
57                } else {
58                        echo plog_tr('Error').": ".$result['errors'];
59                }
60        }
61        elseif ($type == 'comment') {
62                $result = update_comment_field($id, $field, $content);
63                if ($result['output']) {
64                        if (empty($content)) {
65                                $content = '&nbsp;';
66                        }
67                        echo stripslashes($content);
68                } else {
69                        echo plog_tr('Error').": ".$result['errors'];
70                }
71        }
72}
73
74if ($_POST['action'] == 'add-collection') {
75        $action_result = add_collection($_POST['name'], $_POST['description']);
76        if (empty($action_result['errors'])) {
77                $output .= "<script type='text/javascript'>Element.show('add_item_link');Element.hide('add_item_form');Form.reset('add_form');</script>";
78        }
79}
80
81if ($_POST['action'] == 'list-collections') {
82        $output .= plog_collection_manager($_POST['page'], $_SESSION['entries_per_page']);
83}
84
85if (!empty($action_result['errors'])) {
86        $output .= "\n\t" . '<p class="errors" id="rpc_message">'.$action_result['errors'].'</p>' . "\n";
87} elseif (!empty($action_result['output'])) {
88        $output .= "\n\t" . '<p class="actions" id="rpc_message">'.$action_result['output'].'</p>' . "\n";
89}
90close_db();
91close_ftp();
92echo $output;
93
94?>
Note: See TracBrowser for help on using the repository browser.