| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * login.php -- simple login screen |
| 5 | * |
| 6 | * Copyright (c) 1999-2003 The SquirrelMail Project Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * This a simple login screen. Some housekeeping is done to clean |
| 10 | * cookies and find language. |
| 11 | * |
| 12 | * $Id$ |
| 13 | */ |
| 14 | |
| 15 | /* Path for SquirrelMail required files. */ |
| 16 | define('SM_PATH','../'); |
| 17 | |
| 18 | /* SquirrelMail required files. */ |
| 19 | require_once(SM_PATH . 'functions/strings.php'); |
| 20 | require_once(SM_PATH . 'config/config.php'); |
| 21 | require_once(SM_PATH . 'functions/i18n.php'); |
| 22 | require_once(SM_PATH . 'functions/plugin.php'); |
| 23 | require_once(SM_PATH . 'functions/constants.php'); |
| 24 | require_once(SM_PATH . 'functions/page_header.php'); |
| 25 | require_once(SM_PATH . 'functions/html.php'); |
| 26 | require_once(SM_PATH . 'functions/global.php'); |
| 27 | |
| 28 | /* |
| 29 | * $squirrelmail_language is set by a cookie when the user selects |
| 30 | * language and logs out |
| 31 | */ |
| 32 | set_up_language($squirrelmail_language, TRUE, TRUE); |
| 33 | |
| 34 | /** |
| 35 | * Find out the base URI to set cookies. |
| 36 | */ |
| 37 | if (!function_exists('sqm_baseuri')){ |
| 38 | require_once(SM_PATH . 'functions/display_messages.php'); |
| 39 | } |
| 40 | $base_uri = sqm_baseuri(); |
| 41 | |
| 42 | /* |
| 43 | * In case the last session was not terminated properly, make sure |
| 44 | * we get a new one. |
| 45 | */ |
| 46 | |
| 47 | sqsession_destroy(); |
| 48 | |
| 49 | header('Pragma: no-cache'); |
| 50 | |
| 51 | do_hook('login_cookie'); |
| 52 | |
| 53 | /* Output the javascript onload function. */ |
| 54 | |
| 55 | $header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" . |
| 56 | "<!--\n". |
| 57 | " function squirrelmail_loginpage_onload() {\n". |
| 58 | " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n". |
| 59 | " var textElements = 0;\n". |
| 60 | " for (i = 0; i < document.forms[0].elements.length; i++) {\n". |
| 61 | " if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n". |
| 62 | " textElements++;\n". |
| 63 | " if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n". |
| 64 | " document.forms[0].elements[i].focus();\n". |
| 65 | " break;\n". |
| 66 | " }\n". |
| 67 | " }\n". |
| 68 | " }\n". |
| 69 | " }\n". |
| 70 | "// -->\n". |
| 71 | "</script>\n"; |
| 72 | |
| 73 | if (@file_exists($theme[$theme_default]['PATH'])) |
| 74 | @include ($theme[$theme_default]['PATH']); |
| 75 | |
| 76 | displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE ); |
| 77 | |
| 78 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" onLoad=\"squirrelmail_loginpage_onload()\">" . |
| 79 | "\n" . '<form action="redirect.php" method="post">' . "\n"; |
| 80 | |
| 81 | $username_form_name = 'login_username'; |
| 82 | $password_form_name = 'secretkey'; |
| 83 | do_hook('login_top'); |
| 84 | |
| 85 | $loginname_value = (sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : ''); |
| 86 | |
| 87 | /* If they don't have a logo, don't bother.. */ |
| 88 | if (isset($org_logo) && $org_logo) { |
| 89 | /* Display width and height like good little people */ |
| 90 | $width_and_height = ''; |
| 91 | if (isset($org_logo_width) && is_numeric($org_logo_width) && |
| 92 | $org_logo_width>0) { |
| 93 | $width_and_height = " width=\"$org_logo_width\""; |
| 94 | } |
| 95 | if (isset($org_logo_height) && is_numeric($org_logo_height) && |
| 96 | $org_logo_height>0) { |
| 97 | $width_and_height .= " height=\"$org_logo_height\""; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | if(sqgetGlobalVar('mailto', $mailto)) { |
| 102 | $rcptaddress = '<input type="hidden" name="mailto" value="' . urlencode($mailto) . '" />' . "\n"; |
| 103 | } else { |
| 104 | $rcptaddress = ''; |
| 105 | } |
| 106 | echo html_tag( 'table', |
| 107 | html_tag( 'tr', |
| 108 | html_tag( 'td', |
| 109 | '<center>'. |
| 110 | ( isset($org_logo) && $org_logo |
| 111 | ? '<img src="' . $org_logo . '" alt="' . |
| 112 | sprintf(_("%s Logo"), $org_name) .'"' . $width_and_height . |
| 113 | ' /><br />' . "\n" |
| 114 | : '' ). |
| 115 | ( (isset($hide_sm_attributions) && $hide_sm_attributions) ? '' : |
| 116 | '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br />' ."\n". |
| 117 | ' ' . _("By the SquirrelMail Development Team") . '<br /></small>' . "\n" ) . |
| 118 | html_tag( 'table', |
| 119 | html_tag( 'tr', |
| 120 | html_tag( 'td', |
| 121 | '<b>' . sprintf (_("%s Login"), $org_name) . "</b>\n", |
| 122 | 'center', $color[0] ) |
| 123 | ) . |
| 124 | html_tag( 'tr', |
| 125 | html_tag( 'td', "\n" . |
| 126 | html_tag( 'table', |
| 127 | html_tag( 'tr', |
| 128 | html_tag( 'td', |
| 129 | _("Name:") , |
| 130 | 'right', '', 'width="30%"' ) . |
| 131 | html_tag( 'td', |
| 132 | '<input type="text" name="' . $username_form_name .'" value="' . $loginname_value .'" />' , |
| 133 | 'left', '', 'width="*"' ) |
| 134 | ) . "\n" . |
| 135 | html_tag( 'tr', |
| 136 | html_tag( 'td', |
| 137 | _("Password:") , |
| 138 | 'right', '', 'width="30%"' ) . |
| 139 | html_tag( 'td', |
| 140 | '<input type="password" name="' . $password_form_name . '" />' . "\n" . |
| 141 | '<input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF" />' . "\n" . |
| 142 | $rcptaddress . |
| 143 | '<input type="hidden" name="just_logged_in" value="1" />' . "\n", |
| 144 | 'left', '', 'width="*"' ) |
| 145 | ) , |
| 146 | 'center', $color[4], 'border="0" width="100%"' ) , |
| 147 | 'left', $color[4] ) |
| 148 | ) . |
| 149 | html_tag( 'tr', |
| 150 | html_tag( 'td', |
| 151 | '<center><input type="submit" value="' . _("Login") . '" /></center>', |
| 152 | 'left' ) |
| 153 | ), |
| 154 | '', $color[4], 'border="0" width="350"' ) . '</center>', |
| 155 | 'center' ) |
| 156 | ) , |
| 157 | '', $color[4], 'border="0" cellspacing="0" cellpadding="0" width="100%"' ); |
| 158 | do_hook('login_form'); |
| 159 | echo '</form>' . "\n"; |
| 160 | |
| 161 | do_hook('login_bottom'); |
| 162 | echo "</body>\n". |
| 163 | "</html>\n"; |
| 164 | ?> |