From 0fbb9acf2b52bf239ba51b7ad2ef8501d2e0436f Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 20 Mar 2013 18:41:27 -0700 Subject: [PATCH] Login page shortcodes updated to use class. {LOGO=login} added for consistent logo site-wide. ie. use pref or use file. --- .../shortcodes/batch/login_shortcodes.php | 118 ++++++++++++++++++ e107_core/templates/login_template.php | 33 ++++- e107_plugins/siteinfo/e_shortcode.php | 64 +++++++--- login.php | 107 +++++++++------- 4 files changed, 251 insertions(+), 71 deletions(-) create mode 100644 e107_core/shortcodes/batch/login_shortcodes.php diff --git a/e107_core/shortcodes/batch/login_shortcodes.php b/e107_core/shortcodes/batch/login_shortcodes.php new file mode 100644 index 000000000..5677c6c3b --- /dev/null +++ b/e107_core/shortcodes/batch/login_shortcodes.php @@ -0,0 +1,118 @@ +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 ""; + } + + function sc_login_table_password($parm='') //FIXME use $frm + { + $pref = e107::getPref(); + $text = ""; + + if (!USER && e107::getSession()->is('challenge') && varset($pref['password_CHAP'],0)) + { + $text .= "\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 ""; // 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 ""; + } + + function sc_login_table_autologin($parm='')//FIXME use $frm + { + return ""; + } + + + function sc_login_table_autologin_lan($parm='') + { + return LAN_LOGIN_8; + } + + function sc_login_table_submit($parm="") //FIXME use $frm + { + return ""; + } + + + function sc_login_table_footer_userreg() + { + $pref = e107::getPref(); + + if ($pref['user_reg']) + { + $text = "".LAN_LOGIN_11.""; + $text .= "   ".LAN_LOGIN_12.""; + return $text; + } + else + { + return ' '; // In case no registration system enabled + } + } + + +} + +?> \ No newline at end of file diff --git a/e107_core/templates/login_template.php b/e107_core/templates/login_template.php index ee0661e50..cdd8fbede 100644 --- a/e107_core/templates/login_template.php +++ b/e107_core/templates/login_template.php @@ -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 .= "

- ".(file_exists(THEME."images/login_logo.png") ? "\n" : "\n" ); + {LOGO=login}"; } // ##### LOGIN TABLE ----------------------------------------------------------------------------- @@ -52,7 +52,9 @@ if(!isset($LOGIN_TABLE)) ".(file_exists(THEME."images/password.png") ? "\n" : "\n" )."\n\n \n".LAN_LOGIN_2."\n{LOGIN_TABLE_PASSWORD} \n\n"; - if($LOGIN_TABLE_SECIMG_SECIMG) + + + if(LOGIN_CAPTCHA) { $LOGIN_TABLE .= "{LOGIN_TABLE_SECIMG_LAN}\n{LOGIN_TABLE_SECIMG_HIDDEN} {LOGIN_TABLE_SECIMG_SECIMG} {LOGIN_TABLE_SECIMG_TEXTBOC}\n\n"; } @@ -66,10 +68,10 @@ if(!isset($LOGIN_TABLE)) if(!isset($LOGIN_TABLE_FOOTER)) { $LOGIN_TABLE_FOOTER = " -
+

{LOGIN_TABLE_FOOTER_USERREG} -    ".LAN_LOGIN_12." +
@@ -78,4 +80,25 @@ if(!isset($LOGIN_TABLE_FOOTER)) // ##### ------------------------------------------------------------------------------------------ + +// Starter for v2. - Bootstrap + +$LOGIN_TEMPLATE['xxxxx'] = ' + + + + + + + + '; + + + + + + + ?> \ No newline at end of file diff --git a/e107_plugins/siteinfo/e_shortcode.php b/e107_plugins/siteinfo/e_shortcode.php index 3183fdb62..9f87ebf00 100644 --- a/e107_plugins/siteinfo/e_shortcode.php +++ b/e107_plugins/siteinfo/e_shortcode.php @@ -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); diff --git a/login.php b/login.php index ef01cbe72..2722f415c 100644 --- a/login.php +++ b/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 = ""; - $LOGIN_TABLE_PASSWORD = ""; - if (!USER && e107::getSession()->is('challenge') && varset($pref['password_CHAP'],0)) - { - $LOGIN_TABLE_PASSWORD .= "\n\n"; - } - if ($use_imagecode) - { - $LOGIN_TABLE_SECIMG_LAN = LAN_LOGIN_13; - $LOGIN_TABLE_SECIMG_HIDDEN = ""; - $LOGIN_TABLE_SECIMG_SECIMG = $sec_img->r_image(); - $LOGIN_TABLE_SECIMG_TEXTBOC = ""; - } - $LOGIN_TABLE_AUTOLOGIN = ""; - $LOGIN_TABLE_AUTOLOGIN_LAN = LAN_LOGIN_8; - $LOGIN_TABLE_SUBMIT = ""; +// $LOGIN_USERNAME_LABEL = $ulabel[$allowEmailLogin]; +// $LOGIN_TABLE_LOGINMESSAGE = LOGINMESSAGE; +// $LOGIN_TABLE_USERNAME = ""; +// $LOGIN_TABLE_PASSWORD = ""; + + // if (!USER && e107::getSession()->is('challenge') && varset($pref['password_CHAP'],0)) + // { + // $LOGIN_TABLE_PASSWORD .= "\n\n"; + // } + + + +// if ($use_imagecode) +// { +// $LOGIN_TABLE_SECIMG_LAN = LAN_LOGIN_13; +// $LOGIN_TABLE_SECIMG_HIDDEN = ""; + // $LOGIN_TABLE_SECIMG_SECIMG = $sec_img->r_image(); +// $LOGIN_TABLE_SECIMG_TEXTBOC = ""; +// } +// $LOGIN_TABLE_AUTOLOGIN = ""; +// $LOGIN_TABLE_AUTOLOGIN_LAN = LAN_LOGIN_8; +// $LOGIN_TABLE_SUBMIT = ""; 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 "
You are currently logged in.
"; } - 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 = "".LAN_LOGIN_11.""; - } - 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 ""; +require_once(FOOTERF); +exit; +//echo ""; -$sql->db_Close(); +// $sql->db_Close(); ?> \ No newline at end of file