Dotclear

Changeset 1059:822b9d78f9cd


Ignore:
Timestamp:
12/10/12 02:49:06 (13 years ago)
Author:
JcDenis
Branch:
twig
Message:
  • First draft for the use of Twig on authentication pages
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • admin/auth.php

    r794 r1059  
    1414 
    1515# If we have a session cookie, go to index.php 
    16 if (isset($_SESSION['sess_user_id'])) 
    17 { 
     16if (isset($_SESSION['sess_user_id'])) { 
    1817     http::redirect('index.php'); 
    1918} 
     
    2322$dlang = http::getAcceptLanguage(); 
    2423$dlang = ($dlang == '' ? 'en' : $dlang); 
    25 if ($dlang != 'en' && preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$dlang)) 
    26 { 
     24if ($dlang != 'en' && preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$dlang)) { 
    2725     l10n::set(dirname(__FILE__).'/../locales/'.$dlang.'/main'); 
    2826} 
    29  
    30 $page_url = http::getHost().$_SERVER['REQUEST_URI']; 
    31  
    32 $change_pwd = $core->auth->allowPassChange() && isset($_POST['new_pwd']) && isset($_POST['new_pwd_c']) && isset($_POST['login_data']); 
    33 $login_data = !empty($_POST['login_data']) ? html::escapeHTML($_POST['login_data']) : null; 
    34 $recover = $core->auth->allowPassChange() && !empty($_REQUEST['recover']); 
    35 $safe_mode = !empty($_REQUEST['safe_mode']); 
    36 $akey = $core->auth->allowPassChange() && !empty($_GET['akey']) ? $_GET['akey'] : null; 
    37 $user_id = $user_pwd = $user_key = $user_email = null; 
    38 $err = $msg = null; 
    3927 
    4028# Auto upgrade 
     
    4331     try { 
    4432          if (($changes = dotclearUpgrade($core)) !== false) { 
    45                $msg = __('Dotclear has been upgraded.').'<!-- '.$changes.' -->'; 
    46           } 
    47      } catch (Exception $e) { 
    48           $err = $e->getMessage(); 
    49      } 
    50 } 
    51  
    52 # If we have POST login informations, go throug auth process 
    53 if (!empty($_POST['user_id']) && !empty($_POST['user_pwd'])) 
     33               $_ctx->setMessage(__('Dotclear has been upgraded.').'<!-- '.$changes.' -->'); 
     34          } 
     35     } 
     36     catch (Exception $e) { 
     37          $_ctx->addError($e->getMessage()); 
     38     } 
     39} 
     40 
     41/** 
     42Actions for authentication on admin pages 
     43*/ 
     44class adminPageAuth 
    5445{ 
    55      $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; 
    56      $user_pwd = !empty($_POST['user_pwd']) ? $_POST['user_pwd'] : null; 
    57 } 
    58 # If we have COOKIE login informations, go throug auth process 
    59 elseif (isset($_COOKIE['dc_admin']) && strlen($_COOKIE['dc_admin']) == 104) 
    60 { 
     46     # Send new password from recover email 
     47     public static function send($akey) 
     48     { 
     49          global $core, $_ctx; 
     50           
     51          $_ctx->akey = true; 
     52           
     53          try  { 
     54               $recover_res = $core->auth->recoverUserPassword($akey); 
     55                
     56               $subject = mb_encode_mimeheader('DotClear '.__('Your new password'),'UTF-8','B'); 
     57               $message = 
     58               __('Username:').' '.$recover_res['user_id']."\n". 
     59               __('Password:').' '.$recover_res['new_pass']."\n\n". 
     60               preg_replace('/\?(.*)$/','',http::getHost().$_SERVER['REQUEST_URI']); 
     61                
     62               $headers[] = 'From: dotclear@'.$_SERVER['HTTP_HOST']; 
     63               $headers[] = 'Content-Type: text/plain; charset=UTF-8;'; 
     64                
     65               mail::sendMail($recover_res['user_email'],$subject,$message,$headers); 
     66               $_ctx->setMessage(__('Your new password is in your mailbox.')); 
     67          } 
     68          catch (Exception $e) { 
     69               $_ctx->addError($e->getMessage()); 
     70          } 
     71     } 
     72      
     73     # Authentication process 
     74     public static function process($form,$user_id,$user_pwd,$user_key=null) 
     75     { 
     76          global $core, $_ctx; 
     77           
     78          # We check the user 
     79          $check_user = $core->auth->checkUser($user_id,$user_pwd,$user_key) === true; 
     80           
     81          $cookie_admin = http::browserUID(DC_MASTER_KEY.$user_id. 
     82               crypt::hmac(DC_MASTER_KEY,$user_pwd)).bin2hex(pack('a32',$user_id)); 
     83           
     84          if ($check_user && $core->auth->mustChangePassword()) 
     85          { 
     86               $form->login_data = join('/',array( 
     87                    base64_encode($user_id), 
     88                    $cookie_admin, 
     89                    $form->user_remember == '' ? '0' : '1' 
     90               )); 
     91                
     92               if (!$core->auth->allowPassChange()) { 
     93                    $_ctx->addError(__('You have to change your password before you can login.')); 
     94               } else { 
     95                    $_ctx->addError(__('In order to login, you have to change your password now.')); 
     96                    $_ctx->change_pwd = true; 
     97               } 
     98          } 
     99          elseif ($check_user && $form->safe_mode != '' && !$core->auth->isSuperAdmin())  
     100          { 
     101               $_ctx->addError(__('Safe Mode can only be used for super administrators.')); 
     102          } 
     103          elseif ($check_user) 
     104          { 
     105               $core->session->start(); 
     106               $_SESSION['sess_user_id'] = $user_id; 
     107               $_SESSION['sess_browser_uid'] = http::browserUID(DC_MASTER_KEY); 
     108                
     109               if ($form->blog != '') { 
     110                    $_SESSION['sess_blog_id'] = $form->blog; 
     111               } 
     112                
     113               if ($form->safe_mode != '' && $core->auth->isSuperAdmin()) { 
     114                    $_SESSION['sess_safe_mode'] = true; 
     115               } 
     116                
     117               if ($form->user_remember != '') { 
     118                    setcookie('dc_admin',$cookie_admin,strtotime('+15 days'),'','',DC_ADMIN_SSL); 
     119               } 
     120                
     121               http::redirect('index.php'); 
     122          } 
     123          else 
     124          { 
     125               if (isset($_COOKIE['dc_admin'])) { 
     126                    unset($_COOKIE['dc_admin']); 
     127                    setcookie('dc_admin',false,-600,'','',DC_ADMIN_SSL); 
     128               } 
     129               $_ctx->addError(__('Wrong username or password')); 
     130          } 
     131     } 
     132      
     133     # Login form action 
     134     public static function login($form) 
     135     { 
     136          global $_ctx; 
     137           
     138          if ($form->user_id != '' && $form->user_pwd != '') { 
     139               self::process($form,$form->user_id,$form->user_pwd); 
     140          } 
     141           
     142          # Send post values to form 
     143          $form->user_id = $form->user_id; 
     144     } 
     145 
     146     # Recover password form action 
     147     public static function recover($form) 
     148     { 
     149          global $core, $_ctx; 
     150           
     151          if ($form->user_id == '' || $form->user_email == '') { 
     152               return; 
     153          } 
     154           
     155          $user_id = $form->user_id; 
     156          $user_email = $form->user_email; 
     157          $page_url = http::getHost().$_SERVER['REQUEST_URI']; 
     158           
     159          try { 
     160               $recover_key = $core->auth->setRecoverKey($user_id,$user_email); 
     161                
     162               $subject = mail::B64Header('DotClear '.__('Password reset')); 
     163               $message = 
     164               __('Someone has requested to reset the password for the following site and username.')."\n\n". 
     165               $page_url."\n".__('Username:').' '.$user_id."\n\n". 
     166               __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.')."\n". 
     167               $page_url.'?akey='.$recover_key; 
     168                
     169               $headers[] = 'From: '.(defined('DC_ADMIN_MAILFROM') && DC_ADMIN_MAILFROM ? DC_ADMIN_MAILFROM : 'dotclear@local'); 
     170               $headers[] = 'Content-Type: text/plain; charset=UTF-8;'; 
     171                
     172               mail::sendMail($user_email,$subject,$message,$headers); 
     173               $_ctx->setMessage(sprintf(__('The e-mail was sent successfully to %s.'),$user_email)); 
     174          } 
     175          catch (Exception $e) { 
     176               $_ctx->addError($e->getMessage()); 
     177          } 
     178           
     179          # Send post values to form 
     180          $form->user_id = $form->user_id; 
     181          $form->user_email = $form->user_email; 
     182     } 
     183 
     184     # Change password form action 
     185     public static function change($form) 
     186     { 
     187          global $core, $_ctx; 
     188           
     189          if ($form->login_data) { 
     190               return; 
     191          } 
     192          $_ctx->change_pwd = true; 
     193           
     194          $new_pwd = (string) $form->new_pwd; 
     195          $new_pwd_c = (string) $form->new_pwd_c; 
     196           
     197          try { 
     198               $tmp_data = explode('/',$form->login_data); 
     199               if (count($tmp_data) != 3) { 
     200                    throw new Exception(); 
     201               } 
     202               $data = array( 
     203                    'user_id'=>base64_decode($tmp_data[0]), 
     204                    'cookie_admin'=>$tmp_data[1], 
     205                    'user_remember'=>$tmp_data[2]=='1' 
     206               ); 
     207               if ($data['user_id'] === false) { 
     208                    throw new Exception(); 
     209               } 
     210                
     211               # Check login informations 
     212               $check_user = false; 
     213               if (isset($data['cookie_admin']) && strlen($data['cookie_admin']) == 104) 
     214               { 
     215                    $user_id = substr($data['cookie_admin'],40); 
     216                    $user_id = @unpack('a32',@pack('H*',$user_id)); 
     217                    if (is_array($user_id)) 
     218                    { 
     219                         $user_id = $user_id[1]; 
     220                         $user_key = substr($data['cookie_admin'],0,40); 
     221                         $check_user = $core->auth->checkUser($user_id,null,$user_key) === true; 
     222                    } 
     223               } 
     224                
     225               if (!$core->auth->allowPassChange() || !$check_user) { 
     226                    $_ctx->change_pwd = false; 
     227                    throw new Exception(); 
     228               } 
     229                
     230               if ($new_pwd != $new_pwd_c) { 
     231                    throw new Exception(__("Passwords don't match")); 
     232               } 
     233                
     234               if ($core->auth->checkUser($user_id,$new_pwd) === true) { 
     235                    throw new Exception(__("You didn't change your password.")); 
     236               } 
     237                
     238               $cur = $core->con->openCursor($core->prefix.'user'); 
     239               $cur->user_change_pwd = 0; 
     240               $cur->user_pwd = $new_pwd; 
     241               $core->updUser($core->auth->userID(),$cur); 
     242                
     243               $core->session->start(); 
     244               $_SESSION['sess_user_id'] = $user_id; 
     245               $_SESSION['sess_browser_uid'] = http::browserUID(DC_MASTER_KEY); 
     246                
     247               if ($data['user_remember']) { 
     248                    setcookie('dc_admin',$data['cookie_admin'],strtotime('+15 days'),'','',DC_ADMIN_SSL); 
     249               } 
     250                
     251               http::redirect('index.php'); 
     252          } 
     253          catch (Exception $e) { 
     254               $_ctx->addError($e->getMessage()); 
     255          } 
     256           
     257          # Send post values to form 
     258          $form->login_data = $form->login_data; 
     259     } 
     260} 
     261 
     262# Form fields 
     263$form = new dcForm($core,'auth','auth.php'); 
     264$form 
     265     ->addField( 
     266          new dcFieldText('user_id','',array( 
     267               "label" => __('Username:')))) 
     268     ->addField( 
     269          new dcFieldPassword('user_pwd','',array( 
     270               "label" => __('Password:')))) 
     271     ->addField( 
     272          new dcFieldText('user_email','',array( 
     273               "label" => __('Email:')))) 
     274     ->addField( 
     275          new dcFieldPassword('new_pwd','',array( 
     276               "label" => __('New password:')))) 
     277     ->addField( 
     278          new dcFieldPassword('new_pwd_c','',array( 
     279               "label" => __('Confirm password:')))) 
     280     ->addField( 
     281          new dcFieldCheckbox ('user_remenber',1,array( 
     282               "label" => __('Remember my ID on this computer')))) 
     283     ->addField( 
     284          new dcFieldSubmit('auth_login',__('log in'),array( 
     285               'action' => array('adminPageAuth','login')))) 
     286     ->addField( 
     287          new dcFieldSubmit('auth_recover',__('recover'),array( 
     288               'action' => array('adminPageAuth','recover')))) 
     289     ->addField( 
     290          new dcFieldSubmit('auth_change',__('change'),array( 
     291               'action' => array('adminPageAuth','change')))) 
     292     ->addField( 
     293          new dcFieldHidden ('safe_mode','0')) 
     294     ->addField( 
     295          new dcFieldHidden ('recover','0')) 
     296     ->addField( 
     297          new dcFieldHidden ('login_data','')) 
     298     ->addField( 
     299          new dcFieldHidden ('blog','')); 
     300 
     301# Context variables 
     302$_ctx->allow_pass_change = $core->auth->allowPassChange(); 
     303$_ctx->change_pwd = $core->auth->allowPassChange() && $form->new_pwd != '' && $form->new_pwd_c != '' && $form->login_data != ''; 
     304$_ctx->recover = $form->recover = $core->auth->allowPassChange() && !empty($_REQUEST['recover']); 
     305$_ctx->safe_mode = $form->safe_mode = !empty($_REQUEST['safe_mode']); 
     306$_ctx->akey = false; 
     307 
     308# If we have no POST login informations and have COOKIE login informations, go throug auth process 
     309if ($form->user_id == '' && $form->user_pwd == ''  
     310 && isset($_COOKIE['dc_admin']) && strlen($_COOKIE['dc_admin']) == 104) { 
     311 
    61312     # If we have a remember cookie, go through auth process with user_key 
    62313     $user_id = substr($_COOKIE['dc_admin'],40); 
    63314     $user_id = @unpack('a32',@pack('H*',$user_id)); 
    64      if (is_array($user_id)) 
    65      { 
     315      
     316     if (is_array($user_id)) { 
    66317          $user_id = $user_id[1]; 
    67318          $user_key = substr($_COOKIE['dc_admin'],0,40); 
    68           $user_pwd = null; 
    69      } 
    70      else 
    71      { 
    72           $user_id = null; 
    73      } 
    74 } 
    75  
    76 # Recover password 
    77 if ($recover && !empty($_POST['user_id']) && !empty($_POST['user_email'])) 
    78 { 
    79      $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; 
    80      $user_email = !empty($_POST['user_email']) ? $_POST['user_email'] : ''; 
    81      try 
    82      { 
    83           $recover_key = $core->auth->setRecoverKey($user_id,$user_email); 
    84            
    85           $subject = mail::B64Header('DotClear '.__('Password reset')); 
    86           $message = 
    87           __('Someone has requested to reset the password for the following site and username.')."\n\n". 
    88           $page_url."\n".__('Username:').' '.$user_id."\n\n". 
    89           __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.')."\n". 
    90           $page_url.'?akey='.$recover_key; 
    91            
    92           $headers[] = 'From: '.(defined('DC_ADMIN_MAILFROM') && DC_ADMIN_MAILFROM ? DC_ADMIN_MAILFROM : 'dotclear@local'); 
    93           $headers[] = 'Content-Type: text/plain; charset=UTF-8;'; 
    94            
    95           mail::sendMail($user_email,$subject,$message,$headers); 
    96           $msg = sprintf(__('The e-mail was sent successfully to %s.'),$user_email); 
    97      } 
    98      catch (Exception $e) 
    99      { 
    100           $err = $e->getMessage(); 
    101      } 
    102 } 
    103 # Send new password 
    104 elseif ($akey) 
    105 { 
    106      try 
    107      { 
    108           $recover_res = $core->auth->recoverUserPassword($akey); 
    109            
    110           $subject = mb_encode_mimeheader('DotClear '.__('Your new password'),'UTF-8','B'); 
    111           $message = 
    112           __('Username:').' '.$recover_res['user_id']."\n". 
    113           __('Password:').' '.$recover_res['new_pass']."\n\n". 
    114           preg_replace('/\?(.*)$/','',$page_url); 
    115            
    116           $headers[] = 'From: dotclear@'.$_SERVER['HTTP_HOST']; 
    117           $headers[] = 'Content-Type: text/plain; charset=UTF-8;'; 
    118            
    119           mail::sendMail($recover_res['user_email'],$subject,$message,$headers); 
    120           $msg = __('Your new password is in your mailbox.'); 
    121      } 
    122      catch (Exception $e) 
    123      { 
    124           $err = $e->getMessage(); 
    125      } 
    126 } 
    127 # Change password and retry to log 
    128 elseif ($change_pwd) 
    129 { 
    130      try 
    131      { 
    132           $tmp_data = explode('/',$_POST['login_data']); 
    133           if (count($tmp_data) != 3) { 
    134                throw new Exception(); 
    135           } 
    136           $data = array( 
    137                'user_id'=>base64_decode($tmp_data[0]), 
    138                'cookie_admin'=>$tmp_data[1], 
    139                'user_remember'=>$tmp_data[2]=='1' 
    140           ); 
    141           if ($data['user_id'] === false) { 
    142                throw new Exception(); 
    143           } 
    144            
    145      # Check login informations 
    146      $check_user = false; 
    147      if (isset($data['cookie_admin']) && strlen($data['cookie_admin']) == 104) 
    148      { 
    149           $user_id = substr($data['cookie_admin'],40); 
    150           $user_id = @unpack('a32',@pack('H*',$user_id)); 
    151           if (is_array($user_id)) 
    152           { 
    153                $user_id = $user_id[1]; 
    154                $user_key = substr($data['cookie_admin'],0,40); 
    155                $check_user = $core->auth->checkUser($user_id,null,$user_key) === true; 
    156           } 
    157      } 
    158       
    159           if (!$core->auth->allowPassChange() || !$check_user) { 
    160                $change_pwd = false; 
    161                throw new Exception(); 
    162           } 
    163            
    164           if ($_POST['new_pwd'] != $_POST['new_pwd_c']) { 
    165                throw new Exception(__("Passwords don't match")); 
    166           } 
    167            
    168           if ($core->auth->checkUser($user_id,$_POST['new_pwd']) === true) { 
    169                throw new Exception(__("You didn't change your password.")); 
    170           } 
    171            
    172           $cur = $core->con->openCursor($core->prefix.'user'); 
    173           $cur->user_change_pwd = 0; 
    174           $cur->user_pwd = $_POST['new_pwd']; 
    175           $core->updUser($core->auth->userID(),$cur); 
    176            
    177           $core->session->start(); 
    178           $_SESSION['sess_user_id'] = $user_id; 
    179           $_SESSION['sess_browser_uid'] = http::browserUID(DC_MASTER_KEY); 
    180            
    181           if ($data['user_remember']) 
    182           { 
    183                setcookie('dc_admin',$data['cookie_admin'],strtotime('+15 days'),'','',DC_ADMIN_SSL); 
    184           } 
    185            
    186           http::redirect('index.php'); 
    187      } 
    188      catch (Exception $e) 
    189      { 
    190           $err = $e->getMessage(); 
    191      } 
    192 } 
    193 # Try to log 
    194 elseif ($user_id !== null && ($user_pwd !== null || $user_key !== null)) 
    195 { 
    196      # We check the user 
    197      $check_user = $core->auth->checkUser($user_id,$user_pwd,$user_key) === true; 
    198       
    199      $cookie_admin = http::browserUID(DC_MASTER_KEY.$user_id. 
    200           crypt::hmac(DC_MASTER_KEY,$user_pwd)).bin2hex(pack('a32',$user_id)); 
    201       
    202      if ($check_user && $core->auth->mustChangePassword()) 
    203      { 
    204           $login_data = join('/',array( 
    205                base64_encode($user_id), 
    206                $cookie_admin, 
    207                empty($_POST['user_remember'])?'0':'1' 
    208           )); 
    209            
    210           if (!$core->auth->allowPassChange()) { 
    211                $err = __('You have to change your password before you can login.'); 
    212           } else { 
    213                $err = __('In order to login, you have to change your password now.'); 
    214                $change_pwd = true; 
    215           } 
    216      } 
    217      elseif ($check_user && !empty($_POST['safe_mode']) && !$core->auth->isSuperAdmin())  
    218      { 
    219           $err = __('Safe Mode can only be used for super administrators.'); 
    220      } 
    221      elseif ($check_user) 
    222      { 
    223           $core->session->start(); 
    224           $_SESSION['sess_user_id'] = $user_id; 
    225           $_SESSION['sess_browser_uid'] = http::browserUID(DC_MASTER_KEY); 
    226            
    227           if (!empty($_POST['blog'])) { 
    228                $_SESSION['sess_blog_id'] = $_POST['blog']; 
    229           } 
    230            
    231           if (!empty($_POST['safe_mode']) && $core->auth->isSuperAdmin()) { 
    232                $_SESSION['sess_safe_mode'] = true; 
    233           } 
    234            
    235           if (!empty($_POST['user_remember'])) { 
    236                setcookie('dc_admin',$cookie_admin,strtotime('+15 days'),'','',DC_ADMIN_SSL); 
    237           } 
    238            
    239           http::redirect('index.php'); 
    240      } 
    241      else 
    242      { 
    243           if (isset($_COOKIE['dc_admin'])) { 
    244                unset($_COOKIE['dc_admin']); 
    245                setcookie('dc_admin',false,-600,'','',DC_ADMIN_SSL); 
    246           } 
    247           $err = __('Wrong username or password'); 
    248      } 
     319          $user_pwd = ''; 
     320           
     321          adminPageAuth::process($form,$user_id,$user_pwd,$user_key); 
     322     } 
     323} 
     324# If we have an akey, go throug send password process 
     325elseif ($core->auth->allowPassChange() && !empty($_GET['akey'])) { 
     326     adminPageAuth::send($_GET['akey']); 
    249327} 
    250328 
    251329if (isset($_GET['user'])) { 
    252      $user_id = $_GET['user']; 
    253 } 
    254  
    255 header('Content-Type: text/html; charset=UTF-8'); 
     330     $form->user_id = $_GET['user']; 
     331} 
     332 
     333$form->setup(); 
     334 
     335$core->tpl->display('auth.html.twig'); 
    256336?> 
    257 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    258 <html xmlns="http://www.w3.org/1999/xhtml" 
    259 xml:lang="<?php echo $dlang; ?>" lang="<?php echo $dlang; ?>"> 
    260 <head> 
    261   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    262   <meta http-equiv="Content-Script-Type" content="text/javascript" /> 
    263   <meta http-equiv="Content-Style-Type" content="text/css" /> 
    264   <meta http-equiv="Content-Language" content="<?php echo $dlang; ?>" /> 
    265   <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" /> 
    266   <meta name="GOOGLEBOT" content="NOSNIPPET" /> 
    267   <title><?php echo html::escapeHTML(DC_VENDOR_NAME); ?></title> 
    268    
    269 <?php 
    270 echo dcPage::jsLoadIE7(); 
    271 echo dcPage::jsCommon(); 
    272 ?> 
    273    
    274      <link rel="stylesheet" href="style/default.css" type="text/css" media="screen" /> 
    275        
    276   <?php 
    277   # --BEHAVIOR-- loginPageHTMLHead 
    278   $core->callBehavior('loginPageHTMLHead'); 
    279   ?> 
    280    
    281   <script type="text/javascript"> 
    282   //<![CDATA[ 
    283   $(window).load(function() { 
    284     var uid = $('input[name=user_id]'); 
    285     var upw = $('input[name=user_pwd]'); 
    286     uid.focus(); 
    287      
    288     if (upw.length == 0) { return; } 
    289      
    290     if ($.browser.mozilla) { 
    291       uid.keypress(processKey); 
    292     } else { 
    293       uid.keydown(processKey); 
    294     } 
    295     function processKey(evt) { 
    296       if (evt.keyCode == 13 && upw.val() == '') { 
    297          upw.focus(); 
    298          return false; 
    299       } 
    300       return true; 
    301     }; 
    302     $.cookie('dc_admin_test_cookie',true); 
    303     if ($.cookie('dc_admin_test_cookie')) { 
    304       $('#cookie_help').hide(); 
    305       $.cookie('dc_admin_test_cookie', '', {'expires': -1}); 
    306     } else { 
    307       $('#cookie_help').show(); 
    308     } 
    309     $('#issue #more').toggleWithLegend($('#issue').children().not('#more')); 
    310   }); 
    311   //]]> 
    312   </script> 
    313 </head> 
    314  
    315 <body id="dotclear-admin" class="auth"> 
    316  
    317 <form action="auth.php" method="post" id="login-screen"> 
    318 <h1><?php echo html::escapeHTML(DC_VENDOR_NAME); ?></h1> 
    319  
    320 <?php 
    321 if ($err) { 
    322      echo '<div class="error">'.$err.'</div>'; 
    323 } 
    324 if ($msg) { 
    325      echo '<p class="message">'.$msg.'</p>'; 
    326 } 
    327  
    328 if ($akey) 
    329 { 
    330      echo '<p><a href="auth.php">'.__('Back to login screen').'</a></p>'; 
    331 } 
    332 elseif ($recover) 
    333 { 
    334      echo 
    335      '<fieldset><legend>'.__('Request a new password').'</legend>'. 
    336      '<p><label for="user_id">'.__('Username:').'</label> '. 
    337      form::field(array('user_id','user_id'),20,32,html::escapeHTML($user_id)).'</p>'. 
    338       
    339      '<p><label for="user_email">'.__('Email:').'</label> '. 
    340      form::field(array('user_email','user_email'),20,255,html::escapeHTML($user_email)).'</p>'. 
    341       
    342      '<p><input type="submit" value="'.__('recover').'" />'. 
    343      form::hidden(array('recover'),1).'</p>'. 
    344      '</fieldset>'. 
    345       
    346      '<div id="issue">'. 
    347      '<p><a href="auth.php">'.__('Back to login screen').'</a></p></div>'; 
    348 } 
    349 elseif ($change_pwd) 
    350 { 
    351      echo 
    352      '<fieldset><legend>'.__('Change your password').'</legend>'. 
    353      '<p><label for="new_pwd">'.__('New password:').'</label> '. 
    354      form::password(array('new_pwd','new_pwd'),20,255).'</p>'. 
    355       
    356      '<p><label for="new_pwd_c">'.__('Confirm password:').'</label> '. 
    357      form::password(array('new_pwd_c','new_pwd_c'),20,255).'</p>'. 
    358      '</fielset>'. 
    359       
    360      '<p><input type="submit" value="'.__('change').'" />'. 
    361      form::hidden('login_data',$login_data).'</p>'; 
    362 } 
    363 else 
    364 { 
    365      if (is_callable(array($core->auth,'authForm'))) 
    366      { 
    367           echo $core->auth->authForm($user_id); 
    368      } 
    369      else 
    370      { 
    371           if ($safe_mode) { 
    372                echo '<fieldset>'; 
    373                echo '<legend>'.__('Safe mode login').'</legend>'; 
    374                echo  
    375                     '<p class="form-note info">'. 
    376                     __('This mode allows you to login without activating any of your plugins. This may be useful to solve compatibility problems').'&nbsp;<br />'. 
    377                     __('Disable or delete any plugin suspected to cause trouble, then log out and log back in normally.'). 
    378                     '</p>'; 
    379           } 
    380           else { 
    381                echo '<div class="fieldset">'; 
    382           } 
    383  
    384           echo 
    385           '<p><label for="user_id">'.__('Username:').'</label> '. 
    386           form::field(array('user_id','user_id'),20,32,html::escapeHTML($user_id)).'</p>'. 
    387            
    388           '<p><label for="user_pwd">'.__('Password:').'</label> '. 
    389           form::password(array('user_pwd','user_pwd'),20,255).'</p>'. 
    390            
    391           '<p>'. 
    392           form::checkbox(array('user_remember','user_remember'),1). 
    393           '<label for="user_remember" class="classic">'. 
    394           __('Remember my ID on this computer').'</label></p>'. 
    395            
    396           '<p><input type="submit" value="'.__('log in').'" /></p>'; 
    397            
    398           if (!empty($_REQUEST['blog'])) { 
    399                echo form::hidden('blog',html::escapeHTML($_REQUEST['blog'])); 
    400           } 
    401           if($safe_mode) { 
    402                echo  
    403                form::hidden('safe_mode',1). 
    404                '</fieldset>'; 
    405           } 
    406           else { 
    407                echo '</div>'; 
    408           } 
    409           echo 
    410           '<p id="cookie_help" class="error">'.__('You must accept cookies in order to use the private area.').'</p>'; 
    411  
    412           echo '<div id="issue">'; 
    413            
    414           if ($safe_mode) { 
    415                echo 
    416                '<p><a href="auth.php" id="normal_mode_link">'.__('Get back to normal authentication').'</a></p>'; 
    417           } else { 
    418                echo '<p id="more"><strong>'.__('Connection issue?').'</strong></p>'; 
    419                if ($core->auth->allowPassChange()) { 
    420                     echo '<p><a href="auth.php?recover=1">'.__('I forgot my password').'</a></p>'; 
    421                } 
    422                echo '<p><a href="auth.php?safe_mode=1" id="safe_mode_link">'.__('I want to log in in safe mode').'</a></p>'; 
    423           } 
    424            
    425           echo '</div>'; 
    426      } 
    427 } 
    428 ?> 
    429 </form> 
    430 </body> 
    431 </html> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map