mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 06:38:00 +02:00
Login page shortcodes updated to use class. {LOGO=login} added for consistent logo site-wide. ie. use pref or use file.
This commit is contained in:
118
e107_core/shortcodes/batch/login_shortcodes.php
Normal file
118
e107_core/shortcodes/batch/login_shortcodes.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
|
||||
class login_shortcodes extends e_shortcode
|
||||
{
|
||||
var $secImg = false;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$pref = e107::getPref();
|
||||
$this->secImg = ($pref['logcode'] && extension_loaded("gd")) ? true : false;
|
||||
}
|
||||
|
||||
function sc_login_username_label($parm='')
|
||||
{
|
||||
$pref = e107::getPref();
|
||||
$allowEmailLogin = varset($pref['allowEmailLogin'],0);
|
||||
$ulabel = array(LAN_LOGIN_1,LAN_LOGIN_28,LAN_LOGIN_29);
|
||||
return $ulabel[$allowEmailLogin];
|
||||
}
|
||||
|
||||
function sc_login_table_loginmessage($parm='')
|
||||
{
|
||||
return LOGINMESSAGE;
|
||||
}
|
||||
|
||||
function sc_login_table_username($parm='') //FIXME use $frm
|
||||
{
|
||||
return "<input class='tbox' type='text' name='username' id='username' size='40' maxlength='100' />";
|
||||
}
|
||||
|
||||
function sc_login_table_password($parm='') //FIXME use $frm
|
||||
{
|
||||
$pref = e107::getPref();
|
||||
$text = "<input class='tbox' type='password' name='userpass' id='userpass' size='40' maxlength='100' />";
|
||||
|
||||
if (!USER && e107::getSession()->is('challenge') && varset($pref['password_CHAP'],0))
|
||||
{
|
||||
$text .= "<input type='hidden' name='hashchallenge' id='hashchallenge' value='".e107::getSession()->get('challenge')."' />\n\n";
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
function sc_login_table_secimg_lan($parm='')
|
||||
{
|
||||
if(!$this->secImg){ return; }
|
||||
return e107::getSecureImg()->renderLabel();
|
||||
// return LAN_LOGIN_13;
|
||||
}
|
||||
|
||||
|
||||
function sc_login_table_secimg_hidden($parm='')
|
||||
{
|
||||
if(!$this->secImg){ return; }
|
||||
// return "<input type='hidden' name='rand_num' value='".$sec_img->random_number."' />"; // Not required.
|
||||
}
|
||||
|
||||
function sc_login_table_secimg_secimg($parm='')
|
||||
{
|
||||
if(!$this->secImg){ return; }
|
||||
return e107::getSecureImg()->renderImage();
|
||||
// return e107::getSecureImg()->r_image();
|
||||
}
|
||||
|
||||
function sc_login_table_secimg_textboc($parm='')
|
||||
{
|
||||
if(!$this->secImg){ return; }
|
||||
return e107::getSecureImg()->renderInput();
|
||||
// return "<input class='tbox' type='text' name='code_verify' size='15' maxlength='20' />";
|
||||
}
|
||||
|
||||
function sc_login_table_autologin($parm='')//FIXME use $frm
|
||||
{
|
||||
return "<input type='checkbox' name='autologin' value='1' />";
|
||||
}
|
||||
|
||||
|
||||
function sc_login_table_autologin_lan($parm='')
|
||||
{
|
||||
return LAN_LOGIN_8;
|
||||
}
|
||||
|
||||
function sc_login_table_submit($parm="") //FIXME use $frm
|
||||
{
|
||||
return "<input class='btn btn-primary button' type='submit' name='userlogin' value=\"".LAN_LOGIN_9."\" />";
|
||||
}
|
||||
|
||||
|
||||
function sc_login_table_footer_userreg()
|
||||
{
|
||||
$pref = e107::getPref();
|
||||
|
||||
if ($pref['user_reg'])
|
||||
{
|
||||
$text = "<a href='".e_SIGNUP."'>".LAN_LOGIN_11."</a>";
|
||||
$text .= " <a href='".e_BASE."fpw.php'>".LAN_LOGIN_12."</a>";
|
||||
return $text;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ' '; // In case no registration system enabled
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
@@ -4,12 +4,12 @@
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
// ##### LOGIN HEADER TABLE -----------------------------------------------------------------------
|
||||
if(!isset($LOGIN_TABLE_HEADER))
|
||||
if(!isset($LOGIN_TABLE_HEADER)) //FIXME - use {LOGO} .
|
||||
{
|
||||
$LOGIN_TABLE_HEADER .= "
|
||||
<div style='width:100%;text-align:center; margin-left: auto;margin-right: auto'><br />
|
||||
<div style='text-align:center;width:70%;margin-left: auto;margin-right: auto'>
|
||||
".(file_exists(THEME."images/login_logo.png") ? "<img src='".THEME_ABS."images/login_logo.png' alt='' />\n" : "<img src='".e_IMAGE."logo.png' alt='' />\n" );
|
||||
{LOGO=login}";
|
||||
}
|
||||
|
||||
// ##### LOGIN TABLE -----------------------------------------------------------------------------
|
||||
@@ -52,7 +52,9 @@ if(!isset($LOGIN_TABLE))
|
||||
<td class='forumheader3' rowspan='".($LOGIN_TABLE_SECIMG_SECIMG ? 3 : 2)."' style='width:20%; vertical-align: middle; margin-left: auto; margin-right: auto; text-align: center;'>".(file_exists(THEME."images/password.png") ? "<img src='".THEME_ABS."images/password.png' alt='' />\n" : "<img src='".e_IMAGE."generic/password.png' alt='' />\n" )."</td>\n</tr>\n
|
||||
<tr>\n<td class='forumheader3'>".LAN_LOGIN_2."</td>\n<td class='forumheader3'>{LOGIN_TABLE_PASSWORD}
|
||||
</td>\n</tr>\n";
|
||||
if($LOGIN_TABLE_SECIMG_SECIMG)
|
||||
|
||||
|
||||
if(LOGIN_CAPTCHA)
|
||||
{
|
||||
$LOGIN_TABLE .= "<tr><td class='forumheader3'>{LOGIN_TABLE_SECIMG_LAN}</td>\n<td class='forumheader3'>{LOGIN_TABLE_SECIMG_HIDDEN} {LOGIN_TABLE_SECIMG_SECIMG} {LOGIN_TABLE_SECIMG_TEXTBOC}</td>\n</tr>\n";
|
||||
}
|
||||
@@ -66,10 +68,10 @@ if(!isset($LOGIN_TABLE))
|
||||
if(!isset($LOGIN_TABLE_FOOTER))
|
||||
{
|
||||
$LOGIN_TABLE_FOOTER = "
|
||||
<div style='width:70%;margin-right:auto;margin-left:auto'>
|
||||
<div style='margin-bottom:100px; width:70%;margin-right:auto;margin-left:auto'>
|
||||
<div style='text-align:center'><br />
|
||||
{LOGIN_TABLE_FOOTER_USERREG}
|
||||
<a href='".e_BASE."fpw.php'>".LAN_LOGIN_12."</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -78,4 +80,25 @@ if(!isset($LOGIN_TABLE_FOOTER))
|
||||
// ##### ------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// Starter for v2. - Bootstrap
|
||||
|
||||
$LOGIN_TEMPLATE['xxxxx'] = '
|
||||
|
||||
<h2 class="form-signin-heading">Please sign in</h2>
|
||||
<input type="text" class="input-block-level" placeholder="Email address">
|
||||
<input type="password" class="input-block-level" placeholder="Password">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" value="remember-me"> Remember me
|
||||
</label>
|
||||
<button class="btn btn-large btn-primary" type="submit">Sign in</button>
|
||||
|
||||
';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
@@ -44,30 +44,56 @@ class siteinfo_shortcodes // must match the folder name of the plugin.
|
||||
parse_str(vartrue($parm)); // Optional {LOGO=file=file_name} or {LOGO=link=url} or {LOGO=file=file_name&link=url}
|
||||
// Paths to image file, link are relative to site base
|
||||
$tp = e107::getParser();
|
||||
|
||||
|
||||
$logopref = e107::getConfig('core')->get('sitelogo');
|
||||
$logo = $tp->replaceConstants($logopref);
|
||||
|
||||
if(vartrue($logopref) && is_readable($logo))
|
||||
$logop = $tp->replaceConstants($logopref);
|
||||
|
||||
if($parm == 'login') // Login Page. BC fix.
|
||||
{
|
||||
$logo = $tp->replaceConstants($logopref,'abs');
|
||||
$path = $tp->replaceConstants($logopref);
|
||||
if(vartrue($logopref) && is_readable($logop))
|
||||
{
|
||||
$logo = $tp->replaceConstants($logopref,'abs');
|
||||
$path = $tp->replaceConstants($logopref);
|
||||
}
|
||||
elseif(is_readable(THEME."images/login_logo.png"))
|
||||
{
|
||||
|
||||
$logo = THEME_ABS."images/login_logo.png";
|
||||
$path = THEME."images/login_logo.png";
|
||||
}
|
||||
else
|
||||
{
|
||||
$logo = e_IMAGE_ABS."logo.png";
|
||||
$path = e_IMAGE."logo.png";
|
||||
}
|
||||
}
|
||||
elseif (isset($file) && $file && is_readable($file))
|
||||
else
|
||||
{
|
||||
$logo = e_HTTP.$file; // HTML path
|
||||
$path = e_BASE.$file; // PHP path
|
||||
}
|
||||
else if (is_readable(THEME.'images/e_logo.png'))
|
||||
{
|
||||
$logo = THEME_ABS.'images/e_logo.png'; // HTML path
|
||||
$path = THEME.'images/e_logo.png'; // PHP path
|
||||
}
|
||||
else
|
||||
{
|
||||
$logo = e_IMAGE_ABS.'logo.png'; // HTML path
|
||||
$path = e_IMAGE.'logo.png'; // PHP path
|
||||
|
||||
if(vartrue($logopref) && is_readable($logop))
|
||||
{
|
||||
$logo = $tp->replaceConstants($logopref,'abs');
|
||||
$path = $tp->replaceConstants($logopref);
|
||||
}
|
||||
elseif (isset($file) && $file && is_readable($file))
|
||||
{
|
||||
$logo = e_HTTP.$file; // HTML path
|
||||
$path = e_BASE.$file; // PHP path
|
||||
}
|
||||
else if (is_readable(THEME.'images/e_logo.png'))
|
||||
{
|
||||
$logo = THEME_ABS.'images/e_logo.png'; // HTML path
|
||||
$path = THEME.'images/e_logo.png'; // PHP path
|
||||
}
|
||||
else
|
||||
{
|
||||
$logo = e_IMAGE_ABS.'logo.png'; // HTML path
|
||||
$path = e_IMAGE.'logo.png'; // PHP path
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO Parm for resizing the logo image with thumb.php
|
||||
|
||||
$dimensions = getimagesize($path);
|
||||
|
||||
|
107
login.php
107
login.php
@@ -26,46 +26,54 @@ if ((USER || e_LOGIN != e_SELF) && !getperms('0')) // Disable page if user logge
|
||||
exit();
|
||||
}
|
||||
|
||||
$HEADER = '';
|
||||
$FOOTER=''; // Avoids strange displays when debug enabled! (But doesn't completely maintain XHTML formatting)
|
||||
define('e_IFRAME',true);
|
||||
//$HEADER = '';
|
||||
//$FOOTER=''; // Avoids strange displays when debug enabled! (But doesn't completely maintain XHTML formatting)
|
||||
|
||||
require_once(HEADERF);
|
||||
$use_imagecode = ($pref['logcode'] && extension_loaded("gd"));
|
||||
if ($use_imagecode)
|
||||
{
|
||||
require_once(e_HANDLER."secure_img_handler.php");
|
||||
$sec_img = new secure_image;
|
||||
}
|
||||
|
||||
define("LOGIN_CAPTCHA", $use_imagecode);
|
||||
|
||||
//if (LOGIN_CAPTCHA)
|
||||
//{
|
||||
//require_once(e_HANDLER."secure_img_handler.php");
|
||||
//$sec_img = new secure_image;
|
||||
//}
|
||||
|
||||
if (!USER || getperms('0'))
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (!defined('LOGINMESSAGE')) define('LOGINMESSAGE', ''); // LOGINMESSAGE only appears with errors
|
||||
require_once(e_HANDLER.'form_handler.php');
|
||||
$rs = new form;
|
||||
$text = "";
|
||||
$allowEmailLogin = varset($pref['allowEmailLogin'],0);
|
||||
$ulabel = array(LAN_LOGIN_1,LAN_LOGIN_28,LAN_LOGIN_29);
|
||||
require_once(e_HANDLER.'form_handler.php'); // required for BC
|
||||
$rs = new form; // required for BC
|
||||
|
||||
|
||||
// $text = "";
|
||||
// $allowEmailLogin = varset($pref['allowEmailLogin'],0);
|
||||
// $ulabel = array(LAN_LOGIN_1,LAN_LOGIN_28,LAN_LOGIN_29);
|
||||
|
||||
$LOGIN_USERNAME_LABEL = $ulabel[$allowEmailLogin];
|
||||
$LOGIN_TABLE_LOGINMESSAGE = LOGINMESSAGE;
|
||||
$LOGIN_TABLE_USERNAME = "<input class='tbox' type='text' name='username' id='username' size='40' maxlength='100' />";
|
||||
$LOGIN_TABLE_PASSWORD = "<input class='tbox' type='password' name='userpass' id='userpass' size='40' maxlength='100' />";
|
||||
if (!USER && e107::getSession()->is('challenge') && varset($pref['password_CHAP'],0))
|
||||
{
|
||||
$LOGIN_TABLE_PASSWORD .= "<input type='hidden' name='hashchallenge' id='hashchallenge' value='".e107::getSession()->get('challenge')."' />\n\n";
|
||||
}
|
||||
if ($use_imagecode)
|
||||
{
|
||||
$LOGIN_TABLE_SECIMG_LAN = LAN_LOGIN_13;
|
||||
$LOGIN_TABLE_SECIMG_HIDDEN = "<input type='hidden' name='rand_num' value='".$sec_img->random_number."' />";
|
||||
$LOGIN_TABLE_SECIMG_SECIMG = $sec_img->r_image();
|
||||
$LOGIN_TABLE_SECIMG_TEXTBOC = "<input class='tbox' type='text' name='code_verify' size='15' maxlength='20' />";
|
||||
}
|
||||
$LOGIN_TABLE_AUTOLOGIN = "<input type='checkbox' name='autologin' value='1' />";
|
||||
$LOGIN_TABLE_AUTOLOGIN_LAN = LAN_LOGIN_8;
|
||||
$LOGIN_TABLE_SUBMIT = "<input class='btn btn-primary button' type='submit' name='userlogin' value=\"".LAN_LOGIN_9."\" />";
|
||||
// $LOGIN_USERNAME_LABEL = $ulabel[$allowEmailLogin];
|
||||
// $LOGIN_TABLE_LOGINMESSAGE = LOGINMESSAGE;
|
||||
// $LOGIN_TABLE_USERNAME = "<input class='tbox' type='text' name='username' id='username' size='40' maxlength='100' />";
|
||||
// $LOGIN_TABLE_PASSWORD = "<input class='tbox' type='password' name='userpass' id='userpass' size='40' maxlength='100' />";
|
||||
|
||||
// if (!USER && e107::getSession()->is('challenge') && varset($pref['password_CHAP'],0))
|
||||
// {
|
||||
// $LOGIN_TABLE_PASSWORD .= "<input type='hidden' name='hashchallenge' id='hashchallenge' value='".e107::getSession()->get('challenge')."' />\n\n";
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// if ($use_imagecode)
|
||||
// {
|
||||
// $LOGIN_TABLE_SECIMG_LAN = LAN_LOGIN_13;
|
||||
// $LOGIN_TABLE_SECIMG_HIDDEN = "<input type='hidden' name='rand_num' value='".$sec_img->random_number."' />";
|
||||
// $LOGIN_TABLE_SECIMG_SECIMG = $sec_img->r_image();
|
||||
// $LOGIN_TABLE_SECIMG_TEXTBOC = "<input class='tbox' type='text' name='code_verify' size='15' maxlength='20' />";
|
||||
// }
|
||||
// $LOGIN_TABLE_AUTOLOGIN = "<input type='checkbox' name='autologin' value='1' />";
|
||||
// $LOGIN_TABLE_AUTOLOGIN_LAN = LAN_LOGIN_8;
|
||||
// $LOGIN_TABLE_SUBMIT = "<input class='btn btn-primary button' type='submit' name='userlogin' value=\"".LAN_LOGIN_9."\" />";
|
||||
|
||||
if (!isset($LOGIN_TABLE) || !$LOGIN_TABLE)
|
||||
{
|
||||
@@ -82,29 +90,34 @@ if (!USER || getperms('0'))
|
||||
require_once(e_CORE."templates/login_template.php");
|
||||
}
|
||||
}
|
||||
$text = preg_replace("/\{(.*?)\}/e", 'varset($\1,"\1")', $LOGIN_TABLE);
|
||||
|
||||
$sc = e107::getScBatch('login');
|
||||
$text = $tp->parseTemplate($LOGIN_TABLE,true);
|
||||
|
||||
|
||||
|
||||
// $text = preg_replace("/\{(.*?)\}/e", 'varset($\1,"\1")', $LOGIN_TABLE);
|
||||
|
||||
if(getperms('0'))
|
||||
{
|
||||
echo "<div class='alert alert-block alert-error center'> You are currently logged in.</div>";
|
||||
}
|
||||
|
||||
echo preg_replace("/\{(.*?)\}/e", 'varset($\1,"\1")', $LOGIN_TABLE_HEADER);
|
||||
|
||||
// $login_message = LAN_LOGIN_3." | ".SITENAME;
|
||||
$login_message = SITENAME;
|
||||
// echo preg_replace("/\{(.*?)\}/e", 'varset($\1,"\1")', $LOGIN_TABLE_HEADER);
|
||||
$login_message = SITENAME; // $login_message = LAN_LOGIN_3." | ".SITENAME;
|
||||
|
||||
echo $tp->parseTemplate($LOGIN_TABLE_HEADER);
|
||||
$ns->tablerender($login_message, $text, 'login_page');
|
||||
|
||||
$LOGIN_TABLE_FOOTER_USERREG = ' '; // In case no registration system enabled
|
||||
if ($pref['user_reg'])
|
||||
{
|
||||
$LOGIN_TABLE_FOOTER_USERREG = "<a href='".e_SIGNUP."'>".LAN_LOGIN_11."</a>";
|
||||
}
|
||||
echo preg_replace("/\{([^ ]*?)\}/e", 'varset($\1,"\1")', $LOGIN_TABLE_FOOTER);
|
||||
echo $tp->parseTemplate($LOGIN_TABLE_FOOTER);
|
||||
|
||||
|
||||
// echo preg_replace("/\{([^ ]*?)\}/e", 'varset($\1,"\1")', $LOGIN_TABLE_FOOTER);
|
||||
}
|
||||
|
||||
echo "</body></html>";
|
||||
require_once(FOOTERF);
|
||||
exit;
|
||||
//echo "</body></html>";
|
||||
|
||||
$sql->db_Close();
|
||||
// $sql->db_Close();
|
||||
|
||||
?>
|
Reference in New Issue
Block a user