2 // Copyright (c) 2008, u6k.yu1@gmail.com
\r
3 // All rights reserved.
\r
5 // Redistribution and use in source and binary forms, with or without
\r
6 // modification, are permitted provided that the following conditions are met:
\r
7 // * Redistributions of source code must retain the above copyright
\r
8 // notice, this list of conditions and the following disclaimer.
\r
9 // * Redistributions in binary form must reproduce the above copyright
\r
10 // notice, this list of conditions and the following disclaimer in the
\r
11 // documentation and/or other materials provided with the distribution.
\r
12 // * Neither the name of the u6k nor the
\r
13 // names of its contributors may be used to endorse or promote products
\r
14 // derived from this software without specific prior written permission.
\r
16 // THIS SOFTWARE IS PROVIDED BY u6k.yu1@gmail.com ``AS IS'' AND ANY
\r
17 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
\r
18 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
19 // DISCLAIMED. IN NO EVENT SHALL u6k.yu1@gmail.com BE LIABLE FOR ANY
\r
20 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
\r
21 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
\r
22 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
\r
23 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
\r
25 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 require_once("MDB2.php");
\r
29 require_once(dirname(__FILE__) . "/../common/common.php");
\r
30 require_once(dirname(__FILE__) . "/../config/config.php");
\r
32 function login($name, $password) {
\r
34 *
\88ø
\90\94\82ð
\8am
\94F
\82µ
\82Ü
\82·
\81B
\r
37 throw new ArgumentException("name
\88ø
\90\94\82ª
\8bó
\82Å
\82·
\81B");
\r
39 if (!is_string($name)) {
\r
40 throw new ArgumentException("name
\88ø
\90\94\82ª
\95¶
\8e\9a\97ñ
\8c^
\82Å
\82Í
\82 \82è
\82Ü
\82¹
\82ñ
\81B");
\r
42 if (empty($password)) {
\r
43 throw new ArgumentException("password
\88ø
\90\94\82ª
\8bó
\82Å
\82·
\81B");
\r
45 if (!is_string($password)) {
\r
46 throw new ArgumentException("password
\88ø
\90\94\82ª
\95¶
\8e\9a\97ñ
\8c^
\82Å
\82Í
\82 \82è
\82Ü
\82¹
\82ñ
\81B");
\r
50 *
\83f
\81[
\83^
\83x
\81[
\83X
\82©
\82ç
\83A
\83J
\83E
\83\93\83g
\8fî
\95ñ
\82ð
\8c\9f\8dõ
\82µ
\81A
\83\8d\83O
\83C
\83\93\8am
\94F
\82ð
\8ds
\82¢
\82Ü
\82·
\81B
\r
53 $con = MDB2::connect($config);
\r
54 $con->loadModule("Extended");
\r
59 account.name as name,
\r
60 account.real_name as real_name,
\r
61 account.email as email
\r
67 max(create_time) as latest_time
\r
74 and password = :password
\r
77 account.id = latest_account.id
\r
78 and account.create_time = latest_account.latest_time
\r
79 and account.enable = :enable
\r
84 "password" => md5($password),
\r
87 $param_type = array(
\r
89 "password" => "text",
\r
90 "enable" => "integer"
\r
93 $result = $con->getOne($sql, $type, $param, $param_type);
\r