diff --git a/admin-dev/backup.php b/admin-dev/backup.php index 70436c264..0c008563c 100644 --- a/admin-dev/backup.php +++ b/admin-dev/backup.php @@ -30,7 +30,7 @@ define('_PS_ADMIN_DIR_', getcwd()); include(_PS_ADMIN_DIR_.'/../config/config.inc.php'); if (!Context::getContext()->employee->isLoggedBack()) - Tools::redirectAdmin('login.php'); + Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminLogin')); $tabAccess = Profile::getProfileAccess(Context::getContext()->employee->id_profile, Tab::getIdFromClassName('AdminBackup')); diff --git a/admin-dev/init.php b/admin-dev/init.php index 937f585f8..25e5030bc 100644 --- a/admin-dev/init.php +++ b/admin-dev/init.php @@ -37,7 +37,7 @@ if (isset($_GET['logout'])) $context->employee->logout(); if (!isset($context->employee) || !$context->employee->isLoggedBack()) - Tools::redirectAdmin('login.php?redirect='.$_SERVER['REQUEST_URI']); + Tools::redirectAdmin('index.php?controller=AdminLogin&redirect='.$_SERVER['REQUEST_URI']); // Set current index $currentIndex = $_SERVER['SCRIPT_NAME'].(($controller = Tools::getValue('controller')) ? '?controller='.$controller: ''); diff --git a/admin-dev/login.php b/admin-dev/login.php index 36bdce84a..f390651b0 100644 --- a/admin-dev/login.php +++ b/admin-dev/login.php @@ -24,162 +24,5 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ - -ob_start(); -define('_PS_ADMIN_DIR_', getcwd()); -include(_PS_ADMIN_DIR_.'/../config/config.inc.php'); -include(_PS_ADMIN_DIR_.'/functions.php'); - -$clientIsMaintenanceOrLocal = in_array(Tools::getRemoteAddr(), array_merge(array('127.0.0.1'),explode(',', Configuration::get('PS_MAINTENANCE_IP')))); - -$errors = array(); - -if ((empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off') - AND Configuration::get('PS_SSL_ENABLED')) -{ - // You can uncomment theses lines if you want to force https even from localhost and automatically redirect - // header('HTTP/1.1 301 Moved Permanently'); - // header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']); - // exit(); - - // If ssl is enabled, https protocol is required. Exception for maintenance and local (127.0.0.1) IP - if ($clientIsMaintenanceOrLocal) - $errors[] = translate('SSL is activated. However, your IP is allowed to use unsecure mode (Maintenance or local IP).').'
'; - else - $warningSslMessage = translate('SSL is activated. Please connect using the following url to log in in secure mode (https).') - .'

https://'.Tools::getServerName().Tools::safeOutput($_SERVER['REQUEST_URI']).''; -} - -$iso = strtolower(Context::getContext()->language->iso_code); -include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php'); -include(_PS_TRANSLATIONS_DIR_.$iso.'/errors.php'); - -/* Cookie creation and redirection */ -if (Tools::isSubmit('Submit')) -{ - /* Check fields validity */ - $passwd = trim(Tools::getValue('passwd')); - $email = trim(Tools::getValue('email')); - if (empty($email)) - $errors[] = Tools::displayError('E-mail is empty'); - elseif (!Validate::isEmail($email)) - $errors[] = Tools::displayError('Invalid e-mail address'); - elseif (empty($passwd)) - $errors[] = Tools::displayError('Password is blank'); - elseif (!Validate::isPasswd($passwd)) - $errors[] = Tools::displayError('Invalid password'); - else - { - /* Seeking for employee */ - $employee = new Employee(); - if (!$employee->getByemail($email, $passwd)) - { - $errors[] = Tools::displayError('Employee does not exist or password is incorrect.'); - $employee->logout(); - } - else - { - $employee->remote_addr = ip2long(Tools::getRemoteAddr()); - /* Creating cookie */ - $cookie = Context::getContext()->cookie; - $cookie->id_employee = $employee->id; - $cookie->email = $employee->email; - $cookie->profile = $employee->id_profile; - $cookie->passwd = $employee->passwd; - $cookie->remote_addr = $employee->remote_addr; - $cookie->write(); - /* Redirect to admin panel */ - if (isset($_GET['redirect'])) - $url = strval($_GET['redirect'].(isset($_GET['token']) ? ('&token='.$_GET['token']) : '')); - else - $url = 'index.php'; - if (!Validate::isCleanHtml($url)) - die(Tools::displayError()); - echo ' - - - - -
'.translate('Click here to launch Administration panel').'
- - '; - exit ; - } - } -} - -echo ' - - - - - PrestaShop™ - '.translate('Administration panel').''; -echo ' - - -
'; - -if ($nbErrors = sizeof($errors)) -{ - echo ' -
-

'.($nbErrors > 1 ? translate('There are') : translate('There is')).' '.$nbErrors.' '.($nbErrors > 1 ? translate('errors') : translate('error')).'

-
    '; - foreach ($errors AS $error) - echo '
  1. '.$error.'
  2. '; - echo ' -
-
-
'; -} - -echo ' -
-

'.Tools::htmlentitiesUTF8(Configuration::get('PS_SHOP_NAME')).'

-
'; - -$randomNb = rand(100, 999); -if(file_exists(_PS_ADMIN_DIR_.'/../install') OR file_exists(_PS_ADMIN_DIR_.'/../admin')) -{ - echo ' '.translate('For security reasons, you cannot connect to the Back Office until after you have:').'

- - '.translate('delete the /install folder').'
- - '.translate('renamed the /admin folder (eg. ').'/admin'.$randomNb.')
-
'.translate('Please then access this page by the new url (eg. http://www.domain.tld/admin').$randomNb.')
'; -} -else -{ - // If https enabled, we force it except if you try to log in from maintenance or local ip - if ( (empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off') - AND ( Configuration::get('PS_SSL_ENABLED') AND !$clientIsMaintenanceOrLocal) - ) - echo '
'.$warningSslMessage.'
'; - else - echo '
- -
-
- -
-
-
- -
- '; -} -?> - - -
-

© Copyright by PrestaShop. all rights reserved.

-
- -'; +header('Location: index.php?controller=AdminLogin'); \ No newline at end of file diff --git a/admin-dev/password.php b/admin-dev/password.php index deac428d2..bd242e07d 100644 --- a/admin-dev/password.php +++ b/admin-dev/password.php @@ -24,96 +24,4 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ - -define('_PS_ADMIN_DIR_', getcwd()); - -include(_PS_ADMIN_DIR_.'/../config/config.inc.php'); -include(_PS_ADMIN_DIR_.'/functions.php'); - -$errors = array(); - -$id_lang = (int)Configuration::get('PS_LANG_DEFAULT'); -$iso = strtolower(Language::getIsoById((int)$id_lang)); -include(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php'); -/* PrestaShop demo mode */ -if (_PS_MODE_DEMO_) -{ - $errors[] = Tools::displayError('This functionnality has been disabled.'); -} -/* PrestaShop demo mode*/ -else if (isset($_POST['Submit'])) -{ - $errors = array(); - if (empty($_POST['email'])) - $errors[] = Tools::displayError('E-mail is empty'); - elseif (!Validate::isEmail($_POST['email'])) - $errors[] = Tools::displayError('Invalid e-mail address'); - else - { - $employee = new Employee(); - if (!$employee->getByemail($_POST['email']) OR !$employee) - $errors[] = Tools::displayError('This account does not exist'); - else - { - if ((strtotime($employee->last_passwd_gen.'+'.Configuration::get('PS_PASSWD_TIME_BACK').' minutes') - time()) > 0 ) - $errors[] = Tools::displayError('You can regenerate your password only every').' '.Configuration::get('PS_PASSWD_TIME_BACK').' '.Tools::displayError('minute(s)'); - else - { - $pwd = Tools::passwdGen(); - $employee->passwd = md5(pSQL(_COOKIE_KEY_.$pwd)); - $employee->last_passwd_gen = date('Y-m-d H:i:s', time()); - $result = $employee->update(); - if (!$result) - $errors[] = Tools::displayError('An error occurred during your password change.'); - else - { - if(Mail::Send((int)$id_lang, 'password', Mail::l('Your new admin password'), array('{email}' => $employee->email, '{lastname}' => $employee->lastname, '{firstname}' => $employee->firstname, '{passwd}' => $pwd), $employee->email, $employee->firstname.' '.$employee->lastname)) - $confirmation = 'ok'; - } - } - } - } -} - -echo ' - - - - - - PrestaShop™ - '.translate('Administration panel').' - -
'; - -if (sizeof($errors)) -{ - echo '
-

'.translate('There is 1 error').'

-
    '; - foreach ($errors AS $error) - echo '
  1. '.$error.'
  2. '; - echo '
-
'; -} - -echo ' -
-

'.Configuration::get('PS_SHOP_NAME').'

- -
'.translate('Forgot your password?').'

'; -if (isset($confirmation)) - echo '
-
'.translate('Your password has been e-mailed to you').'.
-
> '.translate('back to login home').'
'; -else - echo ' '.translate('Please, enter your e-mail address').' - '.translate('(the one you wrote during your registration) in order to receive your access codes by e-mail').'.
- -
-
-
 
-
- -
-

© Copyright by PrestaShop. all rights reserved.

-
'; \ No newline at end of file +header('Location: index.php?controller=AdminLogin'); \ No newline at end of file diff --git a/admin-dev/pdf.php b/admin-dev/pdf.php index 4bc9a6dc4..8623c8493 100644 --- a/admin-dev/pdf.php +++ b/admin-dev/pdf.php @@ -30,7 +30,7 @@ define('_PS_ADMIN_DIR_', getcwd()); include(_PS_ADMIN_DIR_.'/../config/config.inc.php'); if (!Context::getContext()->employee->id) - Tools::redirectAdmin('login.php'); + Tools::redirectAdmin('index.php?controller=AdminLogin'); $functionArray = array( 'pdf' => 'generateInvoicePDF', diff --git a/admin-dev/themes/template/login/content.tpl b/admin-dev/themes/template/login/content.tpl new file mode 100755 index 000000000..754b7f736 --- /dev/null +++ b/admin-dev/themes/template/login/content.tpl @@ -0,0 +1,103 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 8858 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + + +
+
+ {if isset($errors)} +

{if $nbErrors > 1}{l s='There are'}{else}{l s='There is'}{/if} {$nbErrors}{if $nbErrors > 1} {l s='errors'}{else} {l s='error'}{/if}

+
    + {foreach from=$errors item="error"} +
  1. {$error}
  2. + {/foreach} +
+ {/if} +
+
+ {if isset($warningSslMessage)} +
+ {$warningSslMessage} +
+ {/if} +
+ {if !isset($wrong_folder_name)} +

{$shop_name}

+
+
+ +
+
+ +
+
+
+ + + + +
+ +
+ +
+ {else} +

{$shop_name}

+
+

{l s='For security reasons, you cannot connect to the Back Office until after you have:'}

+

    +
  • {l s='delete the /install folder'}
  • +
  • {l s='renamed the /admin folder (eg.) /admin'}{$randomNb}
  • +
+
{l s='Please then access this page by the new url (eg.) http://www.domain.tld/admin'}{$randomNb}

+
+ {/if} +
+ +

© Copyright by PrestaShop. all rights reserved.

+
\ No newline at end of file diff --git a/classes/AdminController.php b/classes/AdminController.php index 2aaedef09..1cfaf8bb2 100644 --- a/classes/AdminController.php +++ b/classes/AdminController.php @@ -1611,14 +1611,19 @@ class AdminControllerCore extends Controller // ob_start(); if (Tools::getValue('ajax')) $this->ajax = '1'; - + + /* Server Params */ + $protocol_link = (Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://'; + $protocol_content = (isset($useSSL) && $useSSL && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://'; + $this->context->link = new Link($protocol_link, $protocol_content); + $this->timerStart = microtime(true); if (isset($_GET['logout'])) $this->context->employee->logout(); - if (!isset($this->context->employee) || !$this->context->employee->isLoggedBack()) - $this->redirect_after = 'login.php'.(!isset($_GET['logout']) ? '?redirect='.$_SERVER['REQUEST_URI'] : ''); + if (get_class($this) != 'AdminLoginController' && (!isset($this->context->employee) || !$this->context->employee->isLoggedBack())) + $this->redirect_after = $this->context->link->getAdminLink('AdminLogin').(!isset($_GET['logout']) ? '?redirect='.$_SERVER['REQUEST_URI'] : ''); // Set current index $current_index = $_SERVER['SCRIPT_NAME'].(($controller = Tools::getValue('controller')) ? '?controller='.$controller : ''); @@ -1627,11 +1632,7 @@ class AdminControllerCore extends Controller $current_index .= '&back='.urlencode($back); self::$currentIndex = $current_index; - /* Server Params */ - $protocol_link = (Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://'; - $protocol_content = (isset($useSSL) && $useSSL && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://'; - $link = new Link($protocol_link, $protocol_content); - $this->context->link = $link; + // @todo : put the definitions in Controller class if (!defined('_PS_BASE_URL_')) define('_PS_BASE_URL_', Tools::getShopDomain(true)); diff --git a/controllers/admin/AdminLoginController.php b/controllers/admin/AdminLoginController.php new file mode 100755 index 000000000..f56f033d0 --- /dev/null +++ b/controllers/admin/AdminLoginController.php @@ -0,0 +1,206 @@ + +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 8971 $ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +class AdminLoginController extends AdminController +{ + public function __construct() + { + $this->errors = array(); + $this->context = Context::getContext(); + $this->display_header = false; + $this->display_footer = false; + parent::__construct(); + } + + + public function setMedia() + { + $this->addJquery(); + $this->addJqueryPlugin('flip'); + $this->addCSS(_PS_CSS_DIR_.'login.css'); + $this->addJS(_PS_JS_DIR_.'login.js'); + $this->addJqueryUI('ui.widget'); + $this->addJqueryUI('effects.core'); + } + + public function initContent() + { + if ((empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) == 'off') AND Configuration::get('PS_SSL_ENABLED')) + { + // You can uncomment theses lines if you want to force https even from localhost and automatically redirect + // header('HTTP/1.1 301 Moved Permanently'); + // header('Location: '.Tools::getShopDomainSsl(true).$_SERVER['REQUEST_URI']); + // exit(); + $clientIsMaintenanceOrLocal = in_array(Tools::getRemoteAddr(), array_merge(array('127.0.0.1'),explode(',', Configuration::get('PS_MAINTENANCE_IP')))); + // If ssl is enabled, https protocol is required. Exception for maintenance and local (127.0.0.1) IP + if ($clientIsMaintenanceOrLocal) + $this->errors = Tools::displayError('SSL is activated. However, your IP is allowed to use unsecure mode (Maintenance or local IP).'); + else + { + $warningSslMessage = Tools::displayError('SSL is activated. Please connect using the following url to log in in secure mode (https).'); + $warningSslMessage .= 'https://'.Tools::getServerName().Tools::safeOutput($_SERVER['REQUEST_URI']).''; + $this->context->smarty->assign(array('warningSslMessage' => $warningSslMessage)); + } + } + + + + if(file_exists(_PS_ADMIN_DIR_.'/../install') OR file_exists(_PS_ADMIN_DIR_.'/../admin')) + $this->context->smarty->assign( + array( + 'randomNb' => rand(100, 999), + 'wrong_folder_name' => true) + ); + + if ($nbErrors = sizeof($this->errors)) + $this->context->smarty->assign( + array( + 'errors' => $this->errors, + 'nbErrors' => $nbErrors, + 'shop_name' => Tools::safeOutput(Configuration::get('PS_SHOP_NAME')) + ) + ); + $this->setMedia(); + $this->initHeader(); + parent::initContent(); + $this->initFooter(); + } + + public function checkToken() + { + return true; + } + + public function postProcess() + { + if (Tools::isSubmit('submitLogin')) + $this->processLogin(); + elseif (Tools::isSubmit('submitForgot')) + $this->processForgot(); + } + + public function processLogin() + { + /* Check fields validity */ + $passwd = trim(Tools::getValue('passwd')); + $email = trim(Tools::getValue('email')); + if (empty($email)) + $this->errors[] = Tools::displayError('E-mail is empty'); + elseif (!Validate::isEmail($email)) + $this->errors[] = Tools::displayError('Invalid e-mail address'); + + + if (empty($passwd)) + $this->errors[] = Tools::displayError('Password is blank'); + else if (!Validate::isPasswd($passwd)) + $this->errors[] = Tools::displayError('Invalid password'); + + if (!sizeof($this->errors)) + { + /* Seeking for employee */ + $employee = new Employee(); + if (!$employee->getByemail($email, $passwd)) + { + $this->errors[] = Tools::displayError('Employee does not exist or password is incorrect.'); + $employee->logout(); + } + else + { + $employee->remote_addr = ip2long(Tools::getRemoteAddr()); + /* Creating cookie */ + $cookie = Context::getContext()->cookie; + $cookie->id_employee = $employee->id; + $cookie->email = $employee->email; + $cookie->profile = $employee->id_profile; + $cookie->passwd = $employee->passwd; + $cookie->remote_addr = $employee->remote_addr; + $cookie->write(); + + /* Redirect to admin panel */ + if (isset($_GET['redirect'])) + $url = strval($_GET['redirect'].(isset($_GET['token']) ? ('&token='.$_GET['token']) : '')); + else + $url = 'index.php'; + if (!Validate::isCleanHtml($url)) + die(Tools::displayError()); + + if (Tools::isSubmit('ajax')) + die(Tools::jsonEncode(array('hasErrors' => false, 'redirect' => $this->context->link->getAdminLink('AdminHome')))); + else + $this->redirect_after = $this->context->link->getAdminLink('AdminHome'); + } + } + if (Tools::isSubmit('ajax')) + die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors))); + } + + public function processForgot() + { + $email = trim(Tools::getValue('email_forgot')); + if (empty($email)) + $this->errors[] = Tools::displayError('E-mail is empty'); + elseif (!Validate::isEmail($email)) + $this->errors[] = Tools::displayError('Invalid e-mail address'); + else + { + $employee = new Employee(); + if (!$employee->getByemail($email) OR !$employee) + $this->errors[] = Tools::displayError('This account does not exist'); + else if ((strtotime($employee->last_passwd_gen.'+'.Configuration::get('PS_PASSWD_TIME_BACK').' minutes') - time()) > 0 ) + $this->errors[] = Tools::displayError('You can regenerate your password only every').' '.Configuration::get('PS_PASSWD_TIME_BACK').' '.Tools::displayError('minute(s)'); + } + if (_PS_MODE_DEMO_) + $errors[] = Tools::displayError('This functionnality has been disabled.'); + + if(!sizeof($this->errors)) + { + $pwd = Tools::passwdGen(); + $employee->passwd = md5(pSQL(_COOKIE_KEY_.$pwd)); + $employee->last_passwd_gen = date('Y-m-d H:i:s', time()); + $result = $employee->update(); + if (!$result) + $this->errors[] = Tools::displayError('An error occurred during your password change.'); + else + { + $params = array( + '{email}' => $employee->email, + '{lastname}' => $employee->lastname, + '{firstname}' => $employee->firstname, + '{passwd}' => $pwd + ); + + if (Mail::Send((int)Configuration::get('PS_LANG_DEFAULT'), 'password', Mail::l('Your new admin password'), $params, $employee->email, $employee->firstname.' '.$employee->lastname)) + die(Tools::jsonEncode(array('hasErrors' => false, 'confirm' => $this->l('Your password has been e-mailed to you')))); + else + die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => Tools::displayError('An error occurred during your password change.')))); + } + + } + else if (Tools::isSubmit('ajax')) + die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors))); + } +} \ No newline at end of file diff --git a/install-dev/sql/db_settings_lite.sql b/install-dev/sql/db_settings_lite.sql index 22a0fdac5..bf01b55d6 100644 --- a/install-dev/sql/db_settings_lite.sql +++ b/install-dev/sql/db_settings_lite.sql @@ -959,7 +959,7 @@ INSERT INTO `PREFIX_tab` (`id_tab`, `class_name`, `id_parent`, `position`) VALUE (103, 'AdminAccountingManagement', 102, 1), (104, 'AdminAccountingExport', 102, 2), (105, 'AdminCmsCategories', -1, 0), -(106, 'AdminCms', -1, 0); +(106, 'AdminCms', -1, 0), (107, 'AdminLogin', -1 , 0); INSERT INTO `PREFIX_access` (`id_profile`, `id_tab`, `view`, `add`, `edit`, `delete`) (SELECT 1, id_tab, 1, 1, 1, 1 FROM `PREFIX_tab`); diff --git a/js/jquery/plugins/jquery.flip.js b/js/jquery/plugins/jquery.flip.js new file mode 100644 index 000000000..8eb7e0ba6 --- /dev/null +++ b/js/jquery/plugins/jquery.flip.js @@ -0,0 +1,337 @@ +/* + * Flip! jQuery Plugin (http://lab.smashup.it/flip/) + * @author Luca Manno (luca@smashup.it) [http://i.smashup.it] + * [Original idea by Nicola Rizzo (thanks!)] + * + * @version 0.9.9 [Nov. 2009] + * + * @changelog + * v 0.9.9 -> Fix transparency over non-colored background. Added dontChangeColor option. + * Added $clone and $this parameters to on.. callback functions. + * Force hexadecimal color values. Made safe for noConflict use. + * Some refactoring. [Henrik Hjelte, Jul. 10, 2009] + * Added revert options, fixes and improvements on color management. + * Released in Nov 2009 + * v 0.5 -> Added patch to make it work with Opera (thanks to Peter Siewert), Added callbacks [Feb. 1, 2008] + * v 0.4.1 -> Fixed a regression in Chrome and Safari caused by getTransparent [Oct. 1, 2008] + * v 0.4 -> Fixed some bugs with transparent color. Now Flip! works on non-white backgrounds | Update: jquery.color.js plugin or jqueryUI still needed :( [Sept. 29, 2008] + * v 0.3 -> Now is possibile to define the content after the animation. + * (jQuery object or text/html is allowed) [Sept. 25, 2008] + * v 0.2 -> Fixed chainability and buggy innertext rendering (xNephilimx thanks!) + * v 0.1 -> Starting release [Sept. 11, 2008] + * + */ +(function($) { + +function int_prop(fx){ + fx.elem.style[ fx.prop ] = parseInt(fx.now,10) + fx.unit; +} + +var throwError=function(message) { + throw({name:"jquery.flip.js plugin error",message:message}); +}; + +var isIE6orOlder=function() { + // User agent sniffing is clearly out of fashion and $.browser will be be deprectad. + // Now, I can't think of a way to feature detect that IE6 doesn't show transparent + // borders in the correct way. + // Until then, this function will do, and be partly political correct, allowing + // 0.01 percent of the internet users to tweak with their UserAgent string. + // + // Not leadingWhiteSpace is to separate IE family from, well who knows? + // Maybe some version of Opera? + // The second guess behind this is that IE7+ will keep supporting maxHeight in the future. + + // First guess changed to dean edwards ie sniffing http://dean.edwards.name/weblog/2007/03/sniff/ + return (/*@cc_on!@*/false && (typeof document.body.style.maxHeight === "undefined")); +}; + + +// Some named colors to work with +// From Interface by Stefan Petre +// http://interface.eyecon.ro/ + +var colors = { + aqua:[0,255,255], + azure:[240,255,255], + beige:[245,245,220], + black:[0,0,0], + blue:[0,0,255], + brown:[165,42,42], + cyan:[0,255,255], + darkblue:[0,0,139], + darkcyan:[0,139,139], + darkgrey:[169,169,169], + darkgreen:[0,100,0], + darkkhaki:[189,183,107], + darkmagenta:[139,0,139], + darkolivegreen:[85,107,47], + darkorange:[255,140,0], + darkorchid:[153,50,204], + darkred:[139,0,0], + darksalmon:[233,150,122], + darkviolet:[148,0,211], + fuchsia:[255,0,255], + gold:[255,215,0], + green:[0,128,0], + indigo:[75,0,130], + khaki:[240,230,140], + lightblue:[173,216,230], + lightcyan:[224,255,255], + lightgreen:[144,238,144], + lightgrey:[211,211,211], + lightpink:[255,182,193], + lightyellow:[255,255,224], + lime:[0,255,0], + magenta:[255,0,255], + maroon:[128,0,0], + navy:[0,0,128], + olive:[128,128,0], + orange:[255,165,0], + pink:[255,192,203], + purple:[128,0,128], + violet:[128,0,128], + red:[255,0,0], + silver:[192,192,192], + white:[255,255,255], + yellow:[255,255,0], + transparent: [255,255,255] +}; + +var acceptHexColor=function(color) { + if(color && color.indexOf("#")==-1 && color.indexOf("(")==-1){ + return "rgb("+colors[color].toString()+")"; + } else { + return color; + } +}; + +$.extend( $.fx.step, { + borderTopWidth : int_prop, + borderBottomWidth : int_prop, + borderLeftWidth: int_prop, + borderRightWidth: int_prop +}); + +$.fn.revertFlip = function(){ + return this.each( function(){ + var $this = $(this); + $this.flip($this.data('flipRevertedSettings')); + }); +}; + +$.fn.flip = function(settings){ + return this.each( function() { + var $this=$(this), flipObj, $clone, dirOption, dirOptions, newContent, ie6=isIE6orOlder(); + + if($this.data('flipLock')){ + return false; + } + + var revertedSettings = { + direction: (function(direction){ + switch(direction) + { + case "tb": + return "bt"; + case "bt": + return "tb"; + case "lr": + return "rl"; + case "rl": + return "lr"; + default: + return "bt"; + } + })(settings.direction), + bgColor: acceptHexColor(settings.color) || "#999", + color: acceptHexColor(settings.bgColor) || $this.css("background-color"), + content: $this.html(), + speed: settings.speed || 500, + onBefore: settings.onBefore || function(){}, + onEnd: settings.onEnd || function(){}, + onAnimation: settings.onAnimation || function(){} + }; + + $this + .data('flipRevertedSettings',revertedSettings) + .data('flipLock',1) + .data('flipSettings',revertedSettings); + + flipObj = { + width: $this.width(), + height: $this.height(), + bgColor: acceptHexColor(settings.bgColor) || $this.css("background-color"), + fontSize: $this.css("font-size") || "12px", + direction: settings.direction || "tb", + toColor: acceptHexColor(settings.color) || "#999", + speed: settings.speed || 500, + top: $this.offset().top, + left: $this.offset().left, + target: settings.content || null, + transparent: "transparent", + dontChangeColor: settings.dontChangeColor || false, + onBefore: settings.onBefore || function(){}, + onEnd: settings.onEnd || function(){}, + onAnimation: settings.onAnimation || function(){} + }; + + // This is the first part of a trick to support + // transparent borders using chroma filter for IE6 + // The color below is arbitrary, lets just hope it is not used in the animation + ie6 && (flipObj.transparent="#123456"); + + $clone= $this.css("visibility","hidden") + .clone(true) + .data('flipLock',1) + .appendTo("body") + .html("") + .css({visibility:"visible",position:"absolute",left:flipObj.left,top:flipObj.top,margin:0,zIndex:9999,"-webkit-box-shadow":"0px 0px 0px #000","-moz-box-shadow":"0px 0px 0px #000"}); + + var defaultStart=function() { + return { + backgroundColor: flipObj.transparent, + fontSize:0, + lineHeight:0, + borderTopWidth:0, + borderLeftWidth:0, + borderRightWidth:0, + borderBottomWidth:0, + borderTopColor:flipObj.transparent, + borderBottomColor:flipObj.transparent, + borderLeftColor:flipObj.transparent, + borderRightColor:flipObj.transparent, + background: "none", + borderStyle:'solid', + height:0, + width:0 + }; + }; + var defaultHorizontal=function() { + var waist=(flipObj.height/100)*25; + var start=defaultStart(); + start.width=flipObj.width; + return { + "start": start, + "first": { + borderTopWidth: 0, + borderLeftWidth: waist, + borderRightWidth: waist, + borderBottomWidth: 0, + borderTopColor: '#999', + borderBottomColor: '#999', + top: (flipObj.top+(flipObj.height/2)), + left: (flipObj.left-waist)}, + "second": { + borderBottomWidth: 0, + borderTopWidth: 0, + borderLeftWidth: 0, + borderRightWidth: 0, + borderTopColor: flipObj.transparent, + borderBottomColor: flipObj.transparent, + top: flipObj.top, + left: flipObj.left} + }; + }; + var defaultVertical=function() { + var waist=(flipObj.height/100)*25; + var start=defaultStart(); + start.height=flipObj.height; + return { + "start": start, + "first": { + borderTopWidth: waist, + borderLeftWidth: 0, + borderRightWidth: 0, + borderBottomWidth: waist, + borderLeftColor: '#999', + borderRightColor: '#999', + top: flipObj.top-waist, + left: flipObj.left+(flipObj.width/2)}, + "second": { + borderTopWidth: 0, + borderLeftWidth: 0, + borderRightWidth: 0, + borderBottomWidth: 0, + borderLeftColor: flipObj.transparent, + borderRightColor: flipObj.transparent, + top: flipObj.top, + left: flipObj.left} + }; + }; + + dirOptions = { + "tb": function () { + var d=defaultHorizontal(); + d.start.borderTopWidth=flipObj.height; + d.start.borderTopColor=flipObj.bgColor; + d.second.borderBottomWidth= flipObj.height; + d.second.borderBottomColor= flipObj.toColor; + return d; + }, + "bt": function () { + var d=defaultHorizontal(); + d.start.borderBottomWidth=flipObj.height; + d.start.borderBottomColor= flipObj.bgColor; + d.second.borderTopWidth= flipObj.height; + d.second.borderTopColor= flipObj.toColor; + return d; + }, + "lr": function () { + var d=defaultVertical(); + d.start.borderLeftWidth=flipObj.width; + d.start.borderLeftColor=flipObj.bgColor; + d.second.borderRightWidth= flipObj.width; + d.second.borderRightColor= flipObj.toColor; + return d; + }, + "rl": function () { + var d=defaultVertical(); + d.start.borderRightWidth=flipObj.width; + d.start.borderRightColor=flipObj.bgColor; + d.second.borderLeftWidth= flipObj.width; + d.second.borderLeftColor= flipObj.toColor; + return d; + } + }; + + dirOption=dirOptions[flipObj.direction](); + + // Second part of IE6 transparency trick. + ie6 && (dirOption.start.filter="chroma(color="+flipObj.transparent+")"); + + newContent = function(){ + var target = flipObj.target; + return target && target.jquery ? target.html() : target; + }; + + $clone.queue(function(){ + flipObj.onBefore($clone,$this); + $clone.html('').css(dirOption.start); + $clone.dequeue(); + }); + + $clone.animate(dirOption.first,flipObj.speed); + + $clone.queue(function(){ + flipObj.onAnimation($clone,$this); + $clone.dequeue(); + }); + $clone.animate(dirOption.second,flipObj.speed); + + $clone.queue(function(){ + if (!flipObj.dontChangeColor) { + $this.css({backgroundColor: flipObj.toColor}); + } + $this.css({visibility: "visible"}); + + var nC = newContent(); + if(nC){$this.html(nC);} + $clone.remove(); + flipObj.onEnd($clone,$this); + $this.removeData('flipLock'); + $clone.dequeue(); + }); + }); +}; +})(jQuery); diff --git a/js/login.js b/js/login.js new file mode 100644 index 000000000..c5b49ff03 --- /dev/null +++ b/js/login.js @@ -0,0 +1,104 @@ +$(document).ready(function(){ + if (document.getElementById('email')) + document.getElementById('email').focus(); +}); + + +function displayForgotPassword() +{ + $('#error').hide(); + $("#login").flip({ + direction:'tb', + color : '#FFF', + content: $('#forgot_password') + }) +} + +function doAjaxLogin() +{ + $('#error').hide(); + $('#ajax-loader').fadeIn('slow', function () { + $.ajax({ + type:"POST", + url: "ajax-tab.php", + async: true, + dataType: "json", + data : { + ajax: "1", + token: "", + controller: "AdminLogin", + submitLogin: "1", + passwd : $('#passwd').val(), + email : $('#email').val() + }, + success : function(jsonData) + { + if (jsonData.hasErrors) + { + displayErrors(jsonData.errors); + $('#login').effect("shake", { times:3 }, 300); + } + else + { + window.location.href = jsonData.redirect; + } + }, + error: function(XMLHttpRequest, textStatus, errorThrown) { + $('#error').html('

TECHNICAL ERROR:

Details: Error thrown: ' + XMLHttpRequest + '

Text status: ' + textStatus + '

'); + $('#error').fadeIn(); + $('#ajax-loader').fadeOut('slow'); + } + }); + }); + +} + +function doAjaxForgot() +{ + $('#error').hide(); + $('#ajax-loader').fadeIn('slow', function () { + $.ajax({ + type:"POST", + url: "ajax-tab.php", + async: true, + dataType: "json", + data : { + ajax: "1", + token: "", + controller: "AdminLogin", + submitForgot: "1", + email_forgot: $('#email_forgot').val() + }, + success : function(jsonData) + { + if (jsonData.hasErrors) + { + displayErrors(jsonData.errors); + $('#login').effect("shake", { times:3 }, 300); + } + else + { + window.location.href = jsonData.redirect; + } + }, + error: function(XMLHttpRequest, textStatus, errorThrown) { + $('#error').html('

TECHNICAL ERROR:

Details: Error thrown: ' + XMLHttpRequest + '

Text status: ' + textStatus + '

'); + $('#error').fadeIn(); + $('#ajax-loader').fadeOut('slow'); + } + }); + }); +} + +function displayErrors(errors) +{ + str_errors = '

'+(errors.length > 1 ? there_are : there_is )+' '+errors.length+' '+(errors.length > 1 ? label_errors : label_error )+'

    '; + for(error in errors) + //IE6 bug fix + if(error != 'indexOf') + str_errors += '
  1. '+errors[error] + '
  2. '; + $('#ajax-loader').fadeOut('slow'); + $('#error').html(str_errors+'
'); + $('#error').fadeIn(); +} +