| 1 | <?php |
|---|
| 2 | // load configuration variables from database, plog-globals, & plog-includes/plog-functions |
|---|
| 3 | require_once(dirname(dirname(__FILE__)).'/plog-load-config.php'); |
|---|
| 4 | require(PLOGGER_DIR.'plog-admin/plog-admin.php'); |
|---|
| 5 | require_once(PLOGGER_DIR.'plog-admin/plog-admin-functions.php'); |
|---|
| 6 | |
|---|
| 7 | $output = ''; |
|---|
| 8 | |
|---|
| 9 | $action_result = array(); |
|---|
| 10 | |
|---|
| 11 | if ($_POST['action'] == 'update') { |
|---|
| 12 | |
|---|
| 13 | // What field are we updating? |
|---|
| 14 | $field = $_POST['field']; |
|---|
| 15 | |
|---|
| 16 | // With what? |
|---|
| 17 | $content = str_replace(array(' ', '%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 = ' '; |
|---|
| 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 = ' '; |
|---|
| 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 = ' '; |
|---|
| 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 = ' '; |
|---|
| 66 | } |
|---|
| 67 | echo stripslashes($content); |
|---|
| 68 | } else { |
|---|
| 69 | echo plog_tr('Error').": ".$result['errors']; |
|---|
| 70 | } |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | if ($_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 | |
|---|
| 81 | if ($_POST['action'] == 'list-collections') { |
|---|
| 82 | $output .= plog_collection_manager($_POST['page'], $_SESSION['entries_per_page']); |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | if (!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 | } |
|---|
| 90 | close_db(); |
|---|
| 91 | close_ftp(); |
|---|
| 92 | echo $output; |
|---|
| 93 | |
|---|
| 94 | ?> |
|---|