- /*--------------------------------------------------\
- | | | session.inc |
- |---------------------------------------------------|
- | front_accounting |
- | http://open-accounting.sourceforge.net/ |
- | by KylieTech Consulting |
- | http://frontaccounting.com/ |
- | by Joe Hunt Consulting |
- \--------------------------------------------------*/
-
- if (!isset($path_to_root))
+/**********************************************************************
+ Copyright (C) FrontAccounting, LLC.
+ Released under the terms of the GNU General Public License, GPL,
+ as published by the Free Software Foundation, either version 3
+ of the License, or (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
+function output_html($text)
+{
+ global $before_box, $Ajax, $messages;
+ // Fatal errors are not send to error_handler,
+ // so we must check the output
+ if ($text && preg_match('/\bFatal error(<.*?>)?:(.*)/i', $text, $m)) {
+ $Ajax->aCommands = array(); // Don't update page via ajax on errors
+ $text = preg_replace('/\bFatal error(<.*?>)?:(.*)/i','', $text);
+ $messages[] = array(E_ERROR, $m[2], null, null);
+ }
+ $Ajax->run();
+ return in_ajax() ? fmt_errors() : ($before_box.fmt_errors().$text);
+}
+//----------------------------------------------------------------------------------------
+
+function kill_login()
+{
+ session_unset();
+ session_destroy();
+}
+//----------------------------------------------------------------------------------------
+
+function login_fail()
+{
+ global $path_to_root;
+
+ header("HTTP/1.1 401 Authorization Required");
+ echo "<center><br><br><font size='5' color='red'><b>" . _("Incorrect Password") . "<b></font><br><br>";
+ echo "<b>" . _("The user and password combination is not valid for the system.") . "<b><br><br>";
+
+ echo _("If you are not an authorized user, please contact your system administrator to obtain an account to enable you to use the system.");
+ echo "<br><a href='$path_to_root/index.php'>" . _("Try again") . "</a>";
+ echo "</center>";
+
+ kill_login();
+ die();
+}
+
+//----------------------------------------------------------------------------------------
+
+function check_page_security($page_security)
+{
+ if (!$_SESSION["wa_current_user"]->check_user_access())