<?php
/************************************************************************
- * MXChange v0.2.1 Start: 04/12/2004 *
- * ================ Last change: 04/18/2004 *
+ * Mailer v0.2.1-FINAL Start: 04/12/2004 *
+ * =================== Last change: 04/18/2004 *
* *
* -------------------------------------------------------------------- *
* File : what-admins_add.php *
* -------------------------------------------------------------------- *
* Kurzbeschreibung : Neues Administrator-Account anlegen *
* -------------------------------------------------------------------- *
- * *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
* -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
************************************************************************/
// Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
-{
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
- require($INC);
-}
-// Add description as navigation point
-ADD_DESCR("admin", basename(__FILE__));
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+ die();
+} // END - if
-global $CACHE;
+// Add description as navigation point
+addYouAreHereLink('admin', __FILE__);
// Display form is default
$FORM = true;
-if ((isset($_POST['add'])) && (!empty($_POST['login'])) && (!empty($_POST['email'])) && (!empty($_POST['pass1'])) && (!empty($_POST['pass2'])) && ($_POST['pass1'] == $_POST['pass2']))
-{
- // Add admin when not added already
- $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_admins WHERE login='%s' LIMIT 1",
- array($_POST['login']), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 0)
- {
- // Login does not exist so we can create it.
- $FORM = false;
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_admins (login, password, email) VALUES ('%s', '%s', '%s')",
- array($_POST['login'], generateHash($_POST['pass1']), $_POST['email']), __FILE__, __LINE__);
+// Is the form sent?
+if (isFormSent('add')) {
+ // Check all
+ if ((isPostRequestParameterSet('login')) && (isPostRequestParameterSet('email')) && (isPostRequestParameterSet('pass1')) && (isPostRequestParameterSet('pass2')) && (postRequestParameter('pass1') == postRequestParameter('pass2'))) {
+ // Add admin when not added already
+ if (addAdminAccount(postRequestParameter('login'), generateHash(postRequestParameter('pass1')), postRequestParameter('email')) == 'done') {
+ // Do not ouput any form!
+ $FORM = false;
- // Admin login saved
- LOAD_TEMPLATE ("admin_settings_saved", false, "<FONT class=\"admin_done\">".ADMIN_ADMINS_ADD_DONE."</FONT>");
+ // Admin login saved
+ displayMessage('{--ADMIN_ADMINS_ADD_DONE--}');
- // Remove cache file
- if (EXT_IS_ACTIVE("cache"))
- {
- if ($CACHE->cache_file("admins", true)) $CACHE->cache_destroy();
- }
- }
- else
- {
- // Free memory
- SQL_FREERESULT($result);
- }
-}
+ // Run filter chain
+ runFilterChain('post_admin_added', postRequestArray());
+ } // END - if
+ } // END - if
+} // END - if
-if ($FORM)
-{
- // Clear unset variables
- if (empty($_POST['login'])) $_POST['login'] = "";
- if (empty($_POST['email'])) $_POST['email'] = "";
+// Shall we display the form?
+if ($FORM === true) {
+ // Prepare content
+ $content = merge_array(
+ array('login' => '', 'email' => ''),
+ postRequestArray()
+ );
// Load form from template
- LOAD_TEMPLATE("admin_admins_add");
-}
-//
+ loadTemplate('admin_add_admins', false, $content);
+} // END - if
+
+// [EOF]
?>