Bläddra i källkod

Login Changes:

If visiting /index.php and /themes/[theme]/index.php exists, will load it.
If visiting /index.php and /themes/[theme]/login.php exists, will load it.
If NEITHER exist, will load /resources/login.php.

If visiting /login.php and /themes/[theme]/login.php exists, will load it.
If DOESN'T exist, will load /resources/login.php/

/resources/login.php reworked, Enhanced theme reworked.
Nate Jones 11 år sedan
förälder
incheckning
e138a2df19
6 ändrade filer med 203 tillägg och 185 borttagningar
  1. 15 0
      core/user_settings/app_languages.php
  2. 17 8
      index.php
  3. 5 2
      login.php
  4. 15 45
      resources/login.php
  5. 0 38
      themes/enhanced/login.php
  6. 151 92
      themes/enhanced/template.php

+ 15 - 0
core/user_settings/app_languages.php

@@ -194,4 +194,19 @@
 	$text['login-message_dismiss']['es-cl'] = "Despedir";
 	$text['login-message_dismiss']['pt-pt'] = "Demitir";
 	$text['login-message_dismiss']['fr-fr'] = "Rejeter";
+
+	$text['label-username']['en-us'] = "Username";
+	$text['label-username']['es-cl'] = "Nombre de Usuario";
+	$text['label-username']['pt-pt'] = "Nome de Utilizador";
+	$text['label-username']['fr-fr'] = "Nom d'Utilisateur";
+
+	$text['label-password']['en-us'] = "Password";
+	$text['label-password']['es-cl'] = "Contraseña";
+	$text['label-password']['pt-pt'] = "Password";
+	$text['label-password']['fr-fr'] = "Mot de Passe";
+
+	$text['label-domain']['en-us'] = "Domain";
+	$text['label-domain']['es-cl'] = "Dominio";
+	$text['label-domain']['pt-pt'] = "Domínio";
+	$text['label-domain']['fr-fr'] = "Domaine";
 ?>

+ 17 - 8
index.php

@@ -25,6 +25,9 @@
 */
 include "root.php";
 
+//clear the session variables
+	session_start();
+
 //if config.php file does not exist then redirect to the install page
 	if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) {
 		//do nothing
@@ -33,9 +36,9 @@ include "root.php";
 	} elseif (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/includes/config.php")) {
 		//move config.php from the includes to resources directory.
 		rename($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/includes/config.php", $_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php");
-	} elseif (file_exists("/etc/fusionpbx/config.php")){
+	} elseif (file_exists("/etc/fusionpbx/config.php")) {
 		//linux
-	} elseif (file_exists("/usr/local/etc/fusionpbx/config.php")){
+	} elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) {
 		//bsd
 	} else {
 		header("Location: ".PROJECT_PATH."/resources/install.php");
@@ -45,14 +48,20 @@ include "root.php";
 //adds multiple includes
 	require_once "resources/require.php";
 
-//show the index page
-	if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/themes/".$_SESSION['domain']['template']['name']."/index.php")){
+// if logged in, redirect to login destination
+if (strlen($_SESSION["username"]) > 0) {
+	header("Location: ".$_SESSION['login']['destination']['url']);
+}
+else {
+	//use custom index, if present, otherwise use custom login, if present, otherwise use default login
+	if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/themes/".$_SESSION['domain']['template']['name']."/index.php")) {
 		require_once "themes/".$_SESSION['domain']['template']['name']."/index.php";
 	}
+	else if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/themes/".$_SESSION['domain']['template']['name']."/login.php")) {
+		require_once "themes/".$_SESSION['domain']['template']['name']."/login.php";
+	}
 	else {
-		require_once "resources/require.php";
-		require_once "resources/header.php";
-		echo "<br /><br />\n";
-		require_once "resources/footer.php";
+		require_once "resources/login.php";
 	}
+}
 ?>

+ 5 - 2
login.php

@@ -21,7 +21,7 @@
 	the Initial Developer. All Rights Reserved.
 
 	Contributor(s):
-	Mark J Crane <[email protected]>
+	Mark J. Crane <[email protected]>
 */
 include "root.php";
 
@@ -35,6 +35,9 @@ include "root.php";
 		//do nothing
 	} elseif (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) {
 		//original directory
+	} elseif (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/includes/config.php")) {
+		//move config.php from the includes to resources directory.
+		rename($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/includes/config.php", $_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php");
 	} elseif (file_exists("/etc/fusionpbx/config.php")){
 		//linux
 	} elseif (file_exists("/usr/local/etc/fusionpbx/config.php")){
@@ -47,7 +50,7 @@ include "root.php";
 //adds multiple includes
 	require_once "resources/require.php";
 
-//include the login
+//use custom login, if present, otherwise use default login
 	if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/themes/".$_SESSION['domain']['template']['name']."/login.php")){
 		require_once "themes/".$_SESSION['domain']['template']['name']."/login.php";
 	}

+ 15 - 45
resources/login.php

@@ -85,62 +85,32 @@
 	}
 
 //show the content
-	echo "<br><br>";
-	echo "<div align='center'>\n";
-	echo "<form name='login' METHOD=\"POST\" action=\"".$_SESSION['login']['destination']['url']."\">\n";
-	echo "<input type='hidden' name='path' value='$path'>\n";
-	echo "<table width='200' border='0'>\n";
-	echo "<tr>\n";
-	echo "<td align='left'>\n";
-	echo "	<strong>".$text['label-username'].":</strong>\n";
-	echo "</td>\n";
-	echo "<td>\n";
-	echo "  <input type=\"text\" style='width: 150px;' class='formfld' name=\"username\">\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
-	echo "<tr>\n";
-	echo "<td align='left'>\n";
-	echo "	<strong>".$text['label-password'].":</strong>\n";
-	echo "</td>\n";
-	echo "<td align='left'>\n";
-	echo "	<input type=\"password\" style='width: 150px;' class='formfld' name=\"password\">\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-
+	echo "<br />\n";
+	echo "<form name='login' method='post' action='".$_SESSION['login']['destination']['url']."'>\n";
+	echo "<input type='hidden' name='path' value='".$path."'>\n";
+	echo "<input type='text' class='formfld' style='text-align: center; min-width: 200px; width: 200px; margin-bottom: 8px;' name='username' id='username' placeholder=\"".$text['label-username']."\"><br />\n";
+	echo "<input type='password' class='formfld' style='text-align: center; min-width: 200px; width: 200px; margin-bottom: 8px;' name='password' placeholder=\"".$text['label-password']."\"><br />\n";
 	if ($_SESSION['login']['domain_name.visible']['boolean'] == "true") {
-		echo "<tr>\n";
-		echo "<td align='left'>\n";
-		echo "	<strong>".$text['label-domain'].":</strong>\n";
-		echo "</td>\n";
-		echo "<td>\n";
 		if (count($_SESSION['login']['domain_name']) > 0) {
-			echo "    <select style='width: 150px;' class='formfld' name='domain_name'>\n";
-			echo "    <option value=''></option>\n";
+			echo "<select style='width: 200px; margin-bottom: 8px;' class='formfld' name='domain_name'>\n";
+			echo "	<option value=''></option>\n";
 			foreach ($_SESSION['login']['domain_name'] as &$row) {
-				echo "    <option value='$row'>$row</option>\n";
+				echo "	<option value='$row'>$row</option>\n";
 			}
-			echo "    </select>\n";
+			echo "</select>\n";
+			echo "<br />";
 		}
 		else {
-			echo "  <input type=\"text\" style='width: 150px;' class='formfld' name=\"domain_name\">\n";
+			echo "<input type='text' class='formfld' style='text-align: center; min-width: 200px; width: 200px; margin-bottom: 8px;' name='domain_name' placeholder=\"".$text['label-domain']."\"><br />\n";
 		}
-		echo "</td>\n";
-		echo "</tr>\n";
 	}
-
-	echo "<tr>\n";
-	echo "<td>\n";
-	echo "</td>\n";
-	echo "<td align=\"right\">\n";
-	echo "  <input type=\"submit\" class='btn' value=\"".$text['button-login']."\">\n";
-	echo "</td>\n";
-	echo "</tr>\n";
-	echo "</table>\n";
+	echo "<br />";
+	echo "<input type='submit' class='btn' style='width: 100px; margin-top: 15px;' value='".$text['button-login']."'>\n";
 	echo "</form>";
-	echo "</div>";
+	echo "<script>document.getElementById('username').focus();</script>";
 
 //add the footer
+	$default_login = true;
 	include "resources/footer.php";
 
 ?>

+ 0 - 38
themes/enhanced/login.php

@@ -1,38 +0,0 @@
-<?php
-/*
-	FusionPBX
-	Version: MPL 1.1
-
-	The contents of this file are subject to the Mozilla Public License Version
-	1.1 (the "License"); you may not use this file except in compliance with
-	the License. You may obtain a copy of the License at
-	http://www.mozilla.org/MPL/
-
-	Software distributed under the License is distributed on an "AS IS" basis,
-	WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-	for the specific language governing rights and limitations under the
-	License.
-
-	The Original Code is FusionPBX
-
-	The Initial Developer of the Original Code is
-	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2013
-	the Initial Developer. All Rights Reserved.
-
-	Contributor(s):
-	Mark J. Crane <[email protected]>
-*/
-include "root.php";
-
-//show the index page
-	if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/themes/".$_SESSION['domain']['template']['name']."/index.php")){
-		require_once "themes/".$_SESSION['domain']['template']['name']."/index.php";
-	}
-	else {
-		require_once "resources/require.php";
-		require_once "resources/header.php";
-		echo "<br /><br />\n";
-		require_once "resources/footer.php";
-	}
-?>

+ 151 - 92
themes/enhanced/template.php

@@ -55,7 +55,7 @@ DIV#page {
 	left: 0px;
 	right: 0px;
 	bottom: 0px;
-	padding: 10px;
+	padding: 0px;
 	overflow: auto;
 }
 
@@ -95,6 +95,30 @@ if (
 	?>
 <?php } ?>
 
+DIV#copyright {
+	background-color: #000;
+	bottom: 0px;
+	left: 0px;
+	right: 0px;
+	height: 20px;
+	-khtml-opacity: 0.2;
+	-moz-opacity: 0.2;
+	-ms-filter: "alpha(opacity=20)";
+	filter: alpha(opacity=20);
+	filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0.2);
+	opacity: 0.2;
+	text-align: center;
+	vertical-align: middle;
+	padding-bottom: 0px;
+	padding-top: 8px;
+}
+
+.copyright {
+	font-size: 11px;
+	font-family: arial;
+	color: #fff;
+}
+
 img {
 	border: none;
 }
@@ -378,9 +402,6 @@ table.tr_hover tr:hover td a {
 	/*background-color: #FFFFFF;*/
 }
 
-.headermain {
-	/*background-color: #7FAEDE;*/
-}
 
 .frm {
 	border: solid 1px #CCCCCC;
@@ -1108,49 +1129,52 @@ legend {
 	?>
 
 	<div id="page" align='center'>
-	<table width='90%' class='border.disabled' border='0' cellpadding='0' cellspacing='0'>
-		<tr>
-			<td align='left' valign='top' class='headermain' height='70px;'>
-				<table border='0' cellpadding='0' cellspacing='0' width='100%'>
-					<tr>
-						<td>
-							<?php
-							if ($_SERVER['PHP_SELF'] != PROJECT_PATH."/resources/install.php") {
-								if (strlen(PROJECT_PATH) > 0) {
-									echo "<a href='".PROJECT_PATH."'><img src='".PROJECT_PATH."/themes/enhanced/images/logo.png' /></a>";
-								}
-								else {
-									echo "<a href='/'><img src='/themes/enhanced/images/logo.png' /></a>";
-								}
-							}
-							?>
-						</td>
-						<td width='100%' style='padding-right: 15px;' align='right' valign='middle'>
-							<?php
-							if ($_SESSION['username'] != '') {
-								echo "<span style='white-space: nowrap;'>";
-								echo "	<span style='color: black; font-size: 10px; font-weight: bold;'>".$text['theme-label-user']."</span>&nbsp;";
-								echo "	<a href='".PROJECT_PATH."/core/user_settings/user_dashboard.php'>";
-								echo $_SESSION['username'];
-								if (count($_SESSION['domains']) > 1) {
-									echo "@".$_SESSION["user_context"];
-								}
-								echo 	"</a>";
-								echo "</span>\n";
-							}
+		<?php if (!$default_login) { ?>
+			<table width='90%' border='0' cellpadding='0' cellspacing='0'>
+				<tr>
+					<td align='left' valign='top'>
+						<table border='0' cellpadding='0' cellspacing='0' width='100%' style='margin-top: 10px;'>
+							<tr>
+								<td>
+									<?php
+									if ($_SERVER['PHP_SELF'] != PROJECT_PATH."/resources/install.php") {
+										if (strlen(PROJECT_PATH) > 0) {
+											echo "<a href='".PROJECT_PATH."'><img src='".PROJECT_PATH."/themes/enhanced/images/logo.png' /></a>";
+										}
+										else {
+											if (!$default_login) {
+												echo "<a href='/'><img src='/themes/enhanced/images/logo.png' /></a>";
+											}
+										}
+									}
+									?>
+								</td>
+								<td width='100%' style='padding-right: 15px;' align='right' valign='middle'>
+									<?php
+									if ($_SESSION['username'] != '') {
+										echo "<span style='white-space: nowrap;'>";
+										echo "	<span style='color: black; font-size: 10px; font-weight: bold;'>".$text['theme-label-user']."</span>&nbsp;";
+										echo "	<a href='".PROJECT_PATH."/core/user_settings/user_dashboard.php'>";
+										echo $_SESSION['username'];
+										if (count($_SESSION['domains']) > 1) {
+											echo "@".$_SESSION["user_context"];
+										}
+										echo 	"</a>";
+										echo "</span>\n";
+									}
 
-							//logged in show the domains block
-							if (strlen($_SESSION["username"]) > 0 && permission_exists("domain_select") && count($_SESSION['domains']) > 1) {
-								echo "<span style='white-space: nowrap; line-height: 45px;'>";
-								echo "	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='color: black; font-size: 10px; font-weight: bold;'>".$text['theme-label-domain']."</span>&nbsp;";
-								echo "	<a href='javascript:void(0);' id='domains_show_text'>".$_SESSION['domain_name']."</a>";
-								echo "	<img id='domains_show_icon' src='".PROJECT_PATH."/themes/enhanced/images/icon_domains_show.png' style='width: 23px; height: 16px; border: none;' title='".$text['theme-label-open_selector']."' align='absmiddle'>";
-								echo "</span>";
-							}
+								//logged in show the domains block
+									if (strlen($_SESSION["username"]) > 0 && permission_exists("domain_select") && count($_SESSION['domains']) > 1) {
+										echo "<span style='white-space: nowrap; line-height: 45px;'>";
+										echo "	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='color: black; font-size: 10px; font-weight: bold;'>".$text['theme-label-domain']."</span>&nbsp;";
+										echo "	<a href='javascript:void(0);' id='domains_show_text'>".$_SESSION['domain_name']."</a>";
+										echo "	<img id='domains_show_icon' src='".PROJECT_PATH."/themes/enhanced/images/icon_domains_show.png' style='width: 23px; height: 16px; border: none;' title='".$text['theme-label-open_selector']."' align='absmiddle'>";
+										echo "</span>";
+									}
 
-							//logged out show the login
-								if ($_SERVER['PHP_SELF'] != PROJECT_PATH."/resources/install.php") {
-									if (strlen($_SESSION["username"]) == 0) {
+								// login form
+									if ($_SERVER['PHP_SELF'] != PROJECT_PATH."/resources/install.php" && !$default_login) {
+										if (strlen($_SESSION["username"]) == 0) {
 										//add multi-lingual support
 											require_once "core/user_settings/app_languages.php";
 											foreach($text as $key => $value) {
@@ -1167,10 +1191,10 @@ legend {
 											echo "		<table width='200' border='0'>\n";
 											echo "			<tr>\n";
 											echo "				<td>\n";
-											echo "		  			<input type='text' class='formfld' style='min-width: 105px; width: 105px; text-align: center;' name='username' placeholder=\"".$text['label-username']."\">\n";
+											echo "		  			<input type='text' class='formfld' style='min-width: 150px; width: 105px; text-align: center;' name='username' placeholder=\"".$text['label-username']."\">\n";
 											echo "				</td>\n";
 											echo "				<td align='left'>\n";
-											echo "					<input type='password' class='formfld' style='min-width: 105px; width: 105px; text-align: center;' name='password' placeholder=\"".$text['label-password']."\">\n";
+											echo "					<input type='password' class='formfld' style='min-width: 150px; width: 105px; text-align: center;' name='password' placeholder=\"".$text['label-password']."\">\n";
 											echo "				</td>\n";
 
 											if ($_SESSION['login']['domain_name.visible']['boolean'] == "true") {
@@ -1187,7 +1211,7 @@ legend {
 													echo "    		</select>\n";
 												}
 												else {
-													echo "  		<input type='text' style='width: 150px;' class='formfld' name='domain_name'>\n";
+													echo "  		<input type='text' style='min-width: 150px; width: 150px;' class='formfld' name='domain_name'>\n";
 												}
 												echo "			</td>\n";
 											}
@@ -1199,60 +1223,95 @@ legend {
 											echo "		</table>\n";
 											echo "	</form>";
 											echo "</div>";
+										}
 									}
-								}
-							?>
+									?>
+								</td>
+							</tr>
+						</table>
+					</td>
+				</tr>
+				<?php
+				if (strlen($_SESSION["username"]) > 0) {
+					?>
+					<tr>
+						<td height='9px'><img src='<!--{project_path}-->/themes/enhanced/images/blank.gif'></td>
+					</tr>
+					<tr>
+						<td class='menu_bar' height='30px'>
+							<!--{menu}-->
 						</td>
 					</tr>
-				</table>
-			</td>
-		</tr>
-		<?php
-		if (strlen($_SESSION["username"]) > 0) {
-			?>
-			<tr>
-				<td height='9px'><img src='<!--{project_path}-->/themes/enhanced/images/blank.gif'></td>
-			</tr>
-			<tr>
-				<td class='menu_bar' height='30px'>
-					<!--{menu}-->
-				</td>
-			</tr>
-			<tr>
-				<td height='9px'><img src='<!--{project_path}-->/themes/enhanced/images/blank.gif'></td>
-			</tr>
+					<tr>
+						<td height='9px'><img src='<!--{project_path}-->/themes/enhanced/images/blank.gif'></td>
+					</tr>
+					<?php
+				}
+				?>
+				<tr>
+					<td valign='top' align='center' width='100%'>
+						<table cellpadding='0' cellspacing='1' border='0' width='100%' style='margin-bottom: 60px;'>
+							<tr>
+								<td class='main_content' valign='top' align='center'>
+									<!--{body}-->
+								</td>
+							</tr>
+						</table>
+					</td>
+				</tr>
+			</table>
+
 			<?php
 		}
-		?>
-		<tr>
-			<td valign='top' align='center' width='100%'>
-				<table cellpadding='0' cellspacing='1' border='0' width='100%'>
+
+		// default login being used
+		else {
+			?>
+			<div class='main_content' style='position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px; padding: 0px;'>
+				<table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'>
 					<tr>
-						<td class='main_content' valign='top' align='center'>
-							<!--{body}-->
+						<td align='center' valign='middle'>
+
+							<style>
+								#default_login {
+									background-color: #fff;
+									display: block;
+									width: 300px;
+									padding: 30px;
+									opacity: 0.93;
+									filter:alpha(opacity=93);
+									-moz-opacity:0.93;
+									-khtml-opacity: 0.93;
+									-webkit-border-radius: 4px;
+									-moz-border-radius: 4px;
+									border-radius: 4px;
+									-webkit-box-shadow: 0px 1px 20px #888;
+									-moz-box-shadow: 0px 1px 20px #888;
+									box-shadow: 0px 1px 20px #888;
+									padding: 30px;
+								}
+							</style>
+
+							<span id='default_login'>
+								<a href='<?php echo PROJECT_PATH; ?>/'><img src='<?php echo PROJECT_PATH; ?>/themes/enhanced/images/logo.png'></a>
+								<br />
+								<!--{body}-->
+							</span>
+							<br /><br /><br />
+
 						</td>
 					</tr>
 				</table>
-			</td>
-		</tr>
-	</table>
+			</div>
+			<?php
+		}
+		?>
+	</div>
+
 	<?php
-	if (substr($_SERVER['PHP_SELF'], -9) != "login.php") {
-		echo "<span class='smalltext'>\n";
-		echo "<br />\n";
-		echo "&copy; Copyright 2008 - ".date("Y")." <a class='smalltext' target='_blank' href='http://www.fusionpbx.com'>fusionpbx.com</a>. All rights reserved.\n";
-		echo "</span><br><br>\n";
-	}
-	else {
-		echo "<!--\n";
-		echo "	http://www.fusionpbx.com \n";
-		echo "	Copyright 2008 - ".date("Y")." \n";
-		echo "	All rights reserved.\n";
-		echo "-->\n";
-	}
+	$copyright .= "&copy; Copyright 2008 - ".date("Y")." <a href='http://www.fusionpbx.com' class='copyright' target='_blank'>fusionpbx.com</a>. All rights reserved.\n";
+	echo "<div id='copyright' style='position: absolute; z-index; 10000;'><span class='copyright'>".$copyright."</span></div>";
 	?>
-	</div>
 
-<br />
 </body>
-</html>
+</html>