|
发表于 2015-12-6 12:52:22
|
显示全部楼层
不用这么麻烦 用这个login.php就好了 k& x- r l# l; g, \* W2 u
7 }- P$ C |% ~7 P. l# B7 D' u; {5 U5 I- <?php
! q( C% s/ y! p, i, p - $error = '';
3 l4 `+ {. i" e5 l: }* v - $_SESSION['imobi_data'] = array('imVersion' => '3.7', 'xmlVersion' => '3.5');
n2 ~* N/ b6 Y! l" S% `7 A
. e5 U8 x$ F" T3 t1 i3 E( x) e- if ($_SERVER['REQUEST_METHOD'] == 'POST')
$ g( S/ @5 T' K! b* g% n# ?; O) N - {' j2 h: g+ `7 n! @, B# ^% @% ?3 T
- include( 'mt/mt_pconnect.php' );
% ^( v1 r [1 w; P - include( 'mt/mt_pwd.php' );4 X+ K1 M9 o% R6 @" A
- $userName = $_POST['userName'];
6 w9 s E3 m- \' u3 M- R, s - $user_password = $_POST['userPassword'];
" }, G5 H1 B7 @% o7 v - $loginSql = $db -> prepare('SELECT * FROM mt_account WHERE user_name=:user_name');, m! o4 D4 _* h: j
- $loginSql -> bindParam(':user_name', $userName);
$ m! C* q. x& s2 _$ k5 }
% x) L' C. a6 Q4 g, p. K- if ($loginSql -> execute()) Y" d: S; F9 I3 `# e$ W
- {
/ a+ z8 |, A. C T1 n! L* ~ - $data = $loginSql -> fetch(PDO :: FETCH_ASSOC);# @3 a4 @' N! |2 P) H. C% k0 N% K
- if ($data)( X( T8 Q! r, n( Z
- {
. H1 p! k2 n2 [% M/ b. T1 B% h( a f9 X - $bcrypt = new Bcrypt();, q" M: e& l: o3 P
- $isGood = $bcrypt -> verify($user_password, $data['user_password']);+ X" O2 }5 K6 N1 Z# T% d
- if (!$isGood)8 s) P! b5 B) |; G
- {- K1 y, d8 f5 \* P4 n
- $error = 'Your password is incorrect.';
8 g( V; ]" I7 k0 u; _# {( ` - } / \% c9 F0 l9 B. A
- else
: S! s7 k# u# ^ - {
& f' l$ j2 \2 C6 r% `* y - $_SESSION['iMobi_sessionTime'] = time();8 N" Z5 z8 U: \4 W8 m! {8 \
- $_SESSION['iMobi_userName'] = $userName;" J; ?: H7 x: C9 h+ T
- $_SESSION['iMobi_userId'] = $data['user_id'];
! X4 G4 q" i2 H - $_SESSION['iMobi_timeout'] = $data['user_timeout'];* C7 x( Z0 v, W: Q9 L
- $_SESSION['iMobi_timezone'] = $data['user_timezone'];
* z7 }6 ]: B) f1 M0 e - $_SESSION['iMobi_Login'] = true;
( B. F& g+ W# `7 `/ i - 2 {% b! ?: z- @9 N, ?$ f( q% [
- if (!empty($_SESSION['lastPage'])). ]9 `: P2 Q6 D% i
- {) n4 |) j# q3 |; p- m5 j2 z
- $redirect = $_SESSION['lastPage'];
- O7 s: i% I- S- I/ F, F: ] - unset($_SESSION[lastPage]);
3 n! s) D9 r- O% O* E6 s' t% f - }
' _7 r7 R! w( _$ \; b/ c2 U8 h1 i - else g& b" Y n& J- g* w: u( c
- {
8 [: v8 K& Q! P/ { - $redirect = 'campaigns.php';
V, z8 h1 N& B8 ?+ ]4 T) F - }
A7 b/ G2 g# }) L4 ]/ V1 c
% k- O0 b( b4 H2 q3 y4 G0 r- header('location: ' . $redirect);
/ r" v1 e$ K$ T; L+ N% Z - exit();. ~8 o+ |3 Z3 g+ ?2 o
- } . R" F2 }8 z5 V- Z7 h$ o4 G( b& A5 X
- } 9 g' |' |" q5 ?( ~( z# M& q4 r
- else
: U) l+ D0 B" w8 Z9 T' h; @ - {
9 b) w9 c H3 Z: Q9 D3 o - $error = 'The username entered is not found.';
* |% q! O i) y5 N$ i - }' v+ h6 l: H% G
- }. ]1 e7 L+ u/ o7 b6 y8 ~
- else
. ~. z$ E5 L, u6 e) v: Y - {% _+ |2 G# a- K/ d( S
- $error = $loginSql -> errorCode();' k8 K# s& B& a1 h
- $error = ($error == '3D000' ? 'Database Connection Error: (DATABASE NOT DEFINED) - The database in mt/mt_config.php is blank. Enter a database name in mt/mt_config.php to connect to the database.<br><br>(Also, be sure the correct databse user name and password are entered in mt/mt_config.php)' : 'Error Code - ' . $error);: t4 t3 ~$ }( z1 X( T5 v
- }
" D% k! y+ v7 R6 H2 \ - }7 J' N# S0 c U6 Y
- ?> G4 h3 U; a! `7 S! c2 Y% D
- <!DOCTYPE html>2 m0 u& V6 x1 N' f R( ~
- <html>
$ w1 ^: p) u3 N6 D# e - ! W3 k4 I) e* s8 s7 D
- <body>( ~/ b( h1 X# S; N2 C3 F9 c
- & |: L. N% C7 Y8 C
- <div id="content">5 R2 M2 W# C& E9 _# k" m
- <div id="main">
% {/ D$ a) I: [& {7 _( w - <h1>Login</h1>
& V* g. Q" @: \# [9 v/ W - <?php
0 W b: ]1 x* A3 S- A) D' E - if (!empty($error))
6 y5 o( `( O0 q! L4 ] - {% }7 u+ c1 Y& k' o( n; n
- echo '<div class="error">' . $error . '</div>';
" I8 X. @0 Y$ o - }# {/ H' x. e( G- a
- ?>) b, l0 [! Q4 S' Y4 N
- <div id="login">- _% u- Z0 E: K! T0 A
- <form method="post" action="">
& O. {4 j- M3 }# D0 R - <input type="hidden" name="tokenId" value="605871997">
# {" e5 o& \0 e0 q& \5 h- N/ i - <input type="hidden" name="846c3d198c2af4004cdc58e6e5f00468d81bdda4" value="921541f1e1363396dda7d30197ea67593e9f6bcc">
/ I% q7 R+ o! R: @: \ - <table class="login">; G4 x8 f8 `) F, j, A( t1 D
- <tr>
2 v3 `9 d( `$ t) e) u - <td class="name">Username:</td>
7 L8 |; W: [/ S8 a. W - <td><input id="userName" type="text" name="userName" value=""></td>
% C: D9 G( `4 |! u5 B$ K) C - </tr> u4 B5 T7 K9 s b( ?
- <tr>. m1 ^8 o1 X! _( _8 l( ?6 v
- <td class="name">Password:</td>
% i% J. c* f6 }, y0 ]+ K: S1 Q) u - <td>1 C6 Z# ]) a: C$ b0 H" L
- <input id="userPassword" type="password" name="userPassword"> ( m2 t" X. l7 Y
- </td>
3 l, n. R _3 H I7 o" L$ J - </tr>
5 F+ f, N8 V9 q. ^3 X - <tr>
) X( @0 G Z5 A - <td colspan="2" style="text-align:center"><input id="submit" style="margin:5px 0 0 0" class="submit_btn" type="submit" value="Sign In"></td>
. G$ |* I+ a. i$ P: N - </tr>
6 a! A; S& y: w/ i# \; L - </table>
( p5 d4 P: y7 K% j& M: s - </form>8 Z( f5 m+ s$ p m2 V4 N, B
- </div>9 k# D: d+ u( L& ^. \; X
- </div> ~/ d1 n' ?4 S# a9 {6 z$ ], W
- </div># ^' r/ z+ g! w" d1 O) W, h% K1 c- @
. n, l* A. I( |" H& `- </body>& \) {; S$ e: N0 s! v$ H0 h
- </html>: Y c+ z9 G: o% y
复制代码 |
|