Some fixes for password scrambling.
[mailer.git] / ajax.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 09/17/2011 *
4  * ===================                          Last change: 09/17/2011 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ajax.php                                         *
8  * -------------------------------------------------------------------- *
9  * Short description : AJAX backend script                              *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : AJAX-Abfragescript                               *
12  * -------------------------------------------------------------------- *
13  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
14  * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
15  * For more information visit: http://mxchange.org                      *
16  *                                                                      *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or    *
20  * (at your option) any later version.                                  *
21  *                                                                      *
22  * This program is distributed in the hope that it will be useful,      *
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
25  * GNU General Public License for more details.                         *
26  *                                                                      *
27  * You should have received a copy of the GNU General Public License    *
28  * along with this program; if not, write to the Free Software          *
29  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
30  * MA  02110-1301  USA                                                  *
31  ************************************************************************/
32
33 // XDEBUG call
34 //* DEBUG: */ xdebug_start_trace();
35
36 // Load security system
37 require('inc/libs/security_functions.php');
38
39 // Init start time
40 $GLOBALS['__start_time'] = microtime(TRUE);
41
42 /*
43  * Set output to "AJAX mode", proper module and prevent HTML headers/footers
44  * being sent.
45  */
46 $GLOBALS['__output_mode'] = -2;
47 $GLOBALS['__module']      = 'ajax';
48 $GLOBALS['__header_sent'] = 2;
49 $GLOBALS['__footer_sent'] = 2;
50
51 // Load config file
52 require('inc/config-global.php');
53
54 // Load special AJAX library
55 loadIncludeOnce('inc/ajax-functions.php');
56
57 // Init AJAX request (including HTTP status code)
58 initAjax();
59
60 // Load header here
61 loadPageHeader();
62
63 // Process only POST requests and that at least 'level' is set
64 if ((getHttpRequestMethod() == 'POST') && (isPostRequestElementSet('level'))) {
65         // Okay, that is valid, now check that the requested level right is valid
66         if (isValidAjaxRequestLevel()) {
67                 // Process the request
68                 processAjaxRequest();
69
70                 // Is there an error which is not fine?
71                 if (!isAjaxHttpStatusAccepted()) {
72                         // The process was handled but didn't work
73                         reportBug(__FUNCTION__, __LINE__, 'AJAX request level=' . isPostRequestElementSet('level') . ',status=' . getHttpStatus() . ',callback[' . gettype($GLOBALS['ajax_callback_function']) . ']=' . $GLOBALS['ajax_callback_function'] . ' is valid but does not do anything.');
74                 } // END - if
75         } else {
76                 // Not allowed
77                 setHttpStatus('403 Forbidden');
78         }
79 } // END - if
80
81 // Footer
82 loadPageFooter();
83
84 // [EOF]
85 ?>