squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

login.php
Go to the documentation of this file.
1 <?php
2 
16 define('PAGE_NAME', 'login');
17 
22 define('SM_PATH','../');
23 
24 /* SquirrelMail required files. */
25 require_once(SM_PATH . 'functions/global.php');
26 require_once(SM_PATH . 'functions/i18n.php');
27 require_once(SM_PATH . 'functions/plugin.php');
28 require_once(SM_PATH . 'functions/constants.php');
29 require_once(SM_PATH . 'functions/page_header.php');
30 require_once(SM_PATH . 'functions/html.php');
31 require_once(SM_PATH . 'functions/forms.php');
32 
38 
43 $sep = '';
44 $sel = '';
45 sqGetGlobalVar('session_expired_post', $sep, SQ_SESSION);
46 sqGetGlobalVar('session_expired_location', $sel, SQ_SESSION);
47 
48 /* blow away session */
50 
56 if (!empty($_SESSION)) {
57  $_SESSION = array();
58 }
59 
94 if (!empty($custom_session_handlers)) {
95  $open = $custom_session_handlers[0];
96  $close = $custom_session_handlers[1];
98  $write = $custom_session_handlers[3];
99  $destroy = $custom_session_handlers[4];
100  $gc = $custom_session_handlers[5];
101  session_module_name('user');
102  session_set_save_handler($open, $close, $read, $write, $destroy, $gc);
103 }
104 
105 /* put session_expired_* variables back in session */
107 if (!empty($sel)) {
108  sqsession_register($sel, 'session_expired_location');
109  if (!empty($sep))
110  sqsession_register($sep, 'session_expired_post');
111 }
112 
113 // Disable Browser Caching
114 //
115 header('Cache-Control: no-cache, no-store, must-revalidate');
116 header('Pragma: no-cache');
117 header('Expires: Sat, 1 Jan 2000 00:00:00 GMT');
118 
119 do_hook('login_cookie');
120 
121 $loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '');
122 
123 /* Output the javascript onload function. */
124 
125 $header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
126  "<!--\n".
127  " var alreadyFocused = false;\n".
128  " function squirrelmail_loginpage_onload() {\n".
129  " document.login_form.js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
130  " if (alreadyFocused) return;\n".
131  " var textElements = 0;\n".
132  " for (i = 0; i < document.login_form.elements.length; i++) {\n".
133  " if (document.login_form.elements[i].type == \"text\" || document.login_form.elements[i].type == \"password\") {\n".
134  " textElements++;\n".
135  " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n".
136  " document.login_form.elements[i].focus();\n".
137  " break;\n".
138  " }\n".
139  " }\n".
140  " }\n".
141  " }\n".
142  "// -->\n".
143  "</script>\n";
144 $custom_css = 'none';
145 
146 // Load default theme if possible
147 if (@file_exists($theme[$theme_default]['PATH']))
148  @include ($theme[$theme_default]['PATH']);
149 
150 if (! isset($color) || ! is_array($color)) {
151  // Add default color theme, if theme loading fails
152  $color = array();
153  $color[0] = '#dcdcdc'; /* light gray TitleBar */
154  $color[1] = '#800000'; /* red */
155  $color[2] = '#cc0000'; /* light red Warning/Error Messages */
156  $color[4] = '#ffffff'; /* white Normal Background */
157  $color[7] = '#0000cc'; /* blue Links */
158  $color[8] = '#000000'; /* black Normal text */
159 }
160 
161 displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
162 
163 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" onLoad=\"squirrelmail_loginpage_onload();\">" .
164  "\n" . addForm('redirect.php', 'post', 'login_form');
165 
166 $username_form_name = 'login_username';
167 $password_form_name = 'secretkey';
168 do_hook('login_top');
169 
170 
171 if(sqgetGlobalVar('mailtodata', $mailtodata)) {
172  $mailtofield = addHidden('mailtodata', $mailtodata);
173 } else {
174  $mailtofield = '';
175 }
176 
177 /* If they don't have a logo, don't bother.. */
178 if (isset($org_logo) && $org_logo) {
179  /* Display width and height like good little people */
180  $width_and_height = '';
181  if (isset($org_logo_width) && is_numeric($org_logo_width) &&
182  $org_logo_width>0) {
183  $width_and_height = " width=\"$org_logo_width\"";
184  }
185  if (isset($org_logo_height) && is_numeric($org_logo_height) &&
186  $org_logo_height>0) {
187  $width_and_height .= " height=\"$org_logo_height\"";
188  }
189 }
190 
191 echo html_tag( 'table',
192  html_tag( 'tr',
193  html_tag( 'td',
194  '<center>'.
195  ( isset($org_logo) && $org_logo
196  ? '<img src="' . $org_logo . '" alt="' .
197  sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height .
198  ' /><br />' . "\n"
199  : '' ).
200  ( (isset($hide_sm_attributions) && $hide_sm_attributions) ? '' :
201  '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br />' ."\n".
202  ' ' . _("By the SquirrelMail Project Team") . '<br /></small>' . "\n" ) .
203  html_tag( 'table',
204  html_tag( 'tr',
205  html_tag( 'td',
206  '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n",
207  'center', $color[0] )
208  ) .
209  html_tag( 'tr',
210  html_tag( 'td', "\n" .
211  html_tag( 'table',
212  html_tag( 'tr',
213  html_tag( 'td',
214  _("Name:") ,
215  'right', '', 'width="30%"' ) .
216  html_tag( 'td',
217  addInput($username_form_name, $loginname_value, 0, 0, ' onfocus="alreadyFocused=true;"'),
218  'left', '', 'width="70%"' )
219  ) . "\n" .
220  html_tag( 'tr',
221  html_tag( 'td',
222  _("Password:") ,
223  'right', '', 'width="30%"' ) .
224  html_tag( 'td',
225  addPwField($password_form_name, null, ' onfocus="alreadyFocused=true;"').
226  addHidden('js_autodetect_results', SMPREF_JS_OFF).
227  $mailtofield .
228  addHidden('just_logged_in', '1'),
229  'left', '', 'width="70%"' )
230  ) ,
231  'center', $color[4], 'border="0" width="100%"' ) ,
232  'left',$color[4] )
233  ) .
234  html_tag( 'tr',
235  html_tag( 'td',
236  '<center>'. addSubmit(_("Login")) .'</center>',
237  'left' )
238  ),
239  '', $color[4], 'border="0" width="350"' ) . '</center>',
240  'center' )
241  ) ,
242 '', $color[4], 'border="0" cellspacing="0" cellpadding="0" width="100%"' );
243 do_hook('login_form');
244 echo '</form>' . "\n";
245 
246 do_hook('login_bottom');
247 ?>
248 </body></html>
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
$org_logo_width
$org_logo_width
Definition: config_default.php:47
html_tag
html_tag( $tag, $val='', $align='', $bgcolor='', $xtra='')
Definition: html.php:27
SQ_SESSION
const SQ_SESSION
Definition: global.php:18
addForm
addForm($action, $method='post', $name='', $enctype='', $charset='', $extra='', $add_token=FALSE)
Definition: forms.php:150
sprintf
powered by Systran sprintf(_("Number of supported language pairs: %s"), '36').' '
Definition: options.php:107
html
Definition: html.class.php:18
SMPREF_JS_ON
const SMPREF_JS_ON
Definition: constants.php:53
sqsession_destroy
sqsession_destroy()
Definition: global.php:399
do_hook
do_hook($name)
Definition: plugin.php:42
$sep
$sep
Definition: login.php:43
addInput
addInput($name, $value='', $size=0, $maxlength=0, $extra_attributes='')
Definition: forms.php:65
$theme
$theme[0]['PATH']
Definition: config_default.php:702
set_up_language
set_up_language($sm_language, $do_search=false, $default=false)
Definition: i18n.php:330
$org_name
$org_name
Definition: config_default.php:35
$custom_session_handlers
if(!empty($_SESSION)) global $custom_session_handlers
Definition: login.php:56
$password_form_name
$password_form_name
Definition: login.php:167
SMPREF_JS_OFF
const SMPREF_JS_OFF
Definition: constants.php:52
addSubmit
addSubmit($value, $name=null, $extra_attributes='')
Definition: forms.php:112
$header
$header
Definition: login.php:125
addHidden
addHidden($name, $value)
Definition: forms.php:58
$theme_default
$theme_default
Definition: config_default.php:695
displayHtmlHeader
displayHtmlHeader( $title='SquirrelMail', $xtra='', $do_hook=TRUE)
Definition: page_header.php:21
sqsession_register
sqsession_register($var, $name)
Definition: global.php:289
_
_($str)
Definition: gettext.php:160
$read
$read
Definition: message_details_bottom.php:75
$loginname_value
$loginname_value
Definition: login.php:121
$version
global $version
Definition: config_default.php:26
$custom_css
$custom_css
Definition: login.php:144
addPwField
addPwField($name, $value=null, $extra_attributes='')
Definition: forms.php:34
$color
$color
Definition: load_prefs.php:28
$sel
$sel
Definition: login.php:44
sqsession_is_active
sqsession_is_active()
Definition: global.php:452
$squirrelmail_language
global $squirrelmail_language
Definition: i18n.php:774
SM_PATH
const SM_PATH
Definition: login.php:22
$hide_sm_attributions
$hide_sm_attributions
Definition: config_default.php:567
$org_logo_height
$org_logo_height
Definition: config_default.php:53
$username_form_name
$username_form_name
Definition: login.php:166
$org_logo
$org_logo
Definition: config_default.php:41