| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * http://www.lockon.co.jp/
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /* [̾¾Î] SC_Customer
|
|---|
| 9 | * [³µÍ×] ²ñ°÷´ÉÍý¥¯¥é¥¹
|
|---|
| 10 | */
|
|---|
| 11 | class SC_Customer {
|
|---|
| 12 |
|
|---|
| 13 | var $conn;
|
|---|
| 14 | var $email;
|
|---|
| 15 | var $customer_data; // ²ñ°÷¾ðÊó
|
|---|
| 16 |
|
|---|
| 17 | function SC_Customer( $conn = '', $email = '', $pass = '' ) {
|
|---|
| 18 | // ¥»¥Ã¥·¥ç¥ó³«»Ï
|
|---|
| 19 | /* startSession¤«¤é°Üư 2005/11/04 ÃæÀî */
|
|---|
| 20 | sfDomainSessionStart();
|
|---|
| 21 |
|
|---|
| 22 | // DBÀܳ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®
|
|---|
| 23 | $DB_class_name = "SC_DbConn";
|
|---|
| 24 | if ( is_object($conn)){
|
|---|
| 25 | if ( is_a($conn, $DB_class_name)){
|
|---|
| 26 | // $conn¤¬$DB_class_name¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤Ç¤¢¤ë
|
|---|
| 27 | $this->conn = $conn;
|
|---|
| 28 | }
|
|---|
| 29 | } else {
|
|---|
| 30 | if (class_exists($DB_class_name)){
|
|---|
| 31 | //$DB_class_name¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òºîÀ®¤¹¤ë
|
|---|
| 32 | $this->conn = new SC_DbConn();
|
|---|
| 33 | }
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | if ( is_object($this->conn) ) {
|
|---|
| 37 | // Àµ¾ï¤ËDB¤ËÀܳ¤Ç¤¤ë
|
|---|
| 38 | if ( $email ){
|
|---|
| 39 | // email¤«¤é¸ÜµÒ¾ðÊó¤ò¼èÆÀ¤¹¤ë
|
|---|
| 40 | // $this->setCustomerDataFromEmail( $email );
|
|---|
| 41 | }
|
|---|
| 42 | } else {
|
|---|
| 43 | echo "DBÀܳ¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀ¸À®¤Ë¼ºÇÔ¤·¤Æ¤¤¤Þ¤¹";
|
|---|
| 44 | exit;
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | if ( strlen($email) > 0 && strlen($pass) > 0 ){
|
|---|
| 48 | $this->getCustomerDataFromEmailPass( $email, $pass );
|
|---|
| 49 | }
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | function getCustomerDataFromEmailPass( $pass, $email ) {
|
|---|
| 53 | // ËÜÅÐÏ¿¤µ¤ì¤¿²ñ°÷¤Î¤ß
|
|---|
| 54 | $sql = "SELECT * FROM dtb_customer WHERE email ILIKE ? AND del_flg = 0 AND status = 2";
|
|---|
| 55 | $result = $this->conn->getAll($sql, array($email));
|
|---|
| 56 | $data = $result[0];
|
|---|
| 57 |
|
|---|
| 58 | // ¥Ñ¥¹¥ï¡¼¥É¤¬¹ç¤Ã¤Æ¤¤¤ì¤Ð¸ÜµÒ¾ðÊó¤òcustomer_data¤Ë¥»¥Ã¥È¤·¤Ætrue¤òÊÖ¤¹
|
|---|
| 59 | if ( sha1($pass . ":" . AUTH_MAGIC) == $data['password'] ){
|
|---|
| 60 | $this->customer_data = $data;
|
|---|
| 61 | $this->startSession();
|
|---|
| 62 | return true;
|
|---|
| 63 | }
|
|---|
| 64 | return false;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | // ¥Ñ¥¹¥ï¡¼¥É¤ò³Îǧ¤»¤º¤Ë¥í¥°¥¤¥ó
|
|---|
| 68 | function setLogin($email) {
|
|---|
| 69 | // ËÜÅÐÏ¿¤µ¤ì¤¿²ñ°÷¤Î¤ß
|
|---|
| 70 | $sql = "SELECT * FROM dtb_customer WHERE email ILIKE ? AND del_flg = 0 AND status = 2";
|
|---|
| 71 | $result = $this->conn->getAll($sql, array($email));
|
|---|
| 72 | $data = $result[0];
|
|---|
| 73 | $this->customer_data = $data;
|
|---|
| 74 | $this->startSession();
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | // ¥»¥Ã¥·¥ç¥ó¾ðÊó¤òºÇ¿·¤Î¾ðÊó¤Ë¹¹¿·¤¹¤ë
|
|---|
| 78 | function updateSession() {
|
|---|
| 79 | $sql = "SELECT * FROM dtb_customer WHERE customer_id = ? AND del_flg = 0";
|
|---|
| 80 | $customer_id = $this->getValue('customer_id');
|
|---|
| 81 | $arrRet = $this->conn->getAll($sql, array($customer_id));
|
|---|
| 82 | $this->customer_data = $arrRet[0];
|
|---|
| 83 | $_SESSION['customer'] = $this->customer_data;
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | // ¥í¥°¥¤¥ó¾ðÊó¤ò¥»¥Ã¥·¥ç¥ó¤ËÅÐÏ¿¤·¡¢¥í¥°¤Ë½ñ¤¹þ¤à
|
|---|
| 87 | function startSession() {
|
|---|
| 88 | sfDomainSessionStart();
|
|---|
| 89 | $_SESSION['customer'] = $this->customer_data;
|
|---|
| 90 | // ¥»¥Ã¥·¥ç¥ó¾ðÊó¤ÎÊݸ
|
|---|
| 91 | gfPrintLog("access : user=".$this->customer_data['customer_id'] ."\t"."ip=". $_SERVER['REMOTE_HOST'], CUSTOMER_LOG_PATH );
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | // ¥í¥°¥¢¥¦¥È¡¡$_SESSION['customer']¤ò²òÊü¤·¡¢¥í¥°¤Ë½ñ¤¹þ¤à
|
|---|
| 95 | function EndSession() {
|
|---|
| 96 | // $_SESSION['customer']¤Î²òÊü
|
|---|
| 97 | unset($_SESSION['customer']);
|
|---|
| 98 | // ¥í¥°¤ËµÏ¿¤¹¤ë
|
|---|
| 99 | gfPrintLog("logout : user=".$this->customer_data['customer_id'] ."\t"."ip=". $_SERVER['REMOTE_HOST'], CUSTOMER_LOG_PATH );
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | // ¥í¥°¥¤¥ó¤ËÀ®¸ù¤·¤Æ¤¤¤ë¤«È½Äꤹ¤ë¡£
|
|---|
| 103 | function isLoginSuccess() {
|
|---|
| 104 | // ¥í¥°¥¤¥ó»þ¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤ÈDB¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬°ìÃפ·¤Æ¤¤¤ë¾ì¹ç
|
|---|
| 105 | if(sfIsInt($_SESSION['customer']['customer_id'])) {
|
|---|
| 106 | $objQuery = new SC_Query();
|
|---|
| 107 | $email = $objQuery->get("dtb_customer", "email", "customer_id = ?", array($_SESSION['customer']['customer_id']));
|
|---|
| 108 | if($email == $_SESSION['customer']['email']) {
|
|---|
| 109 | return true;
|
|---|
| 110 | }
|
|---|
| 111 | }
|
|---|
| 112 | return false;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | // ¥Ñ¥é¥á¡¼¥¿¤Î¼èÆÀ(Á´¥Ñ¥é¥á¡¼¥¿)
|
|---|
| 116 | function getAllValue() {
|
|---|
| 117 | return $_SESSION['customer'];
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | // ¥Ñ¥é¥á¡¼¥¿¤Î¼èÆÀ
|
|---|
| 121 | function getValue($keyname) {
|
|---|
| 122 | return $_SESSION['customer'][$keyname];
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | // ¥Ñ¥é¥á¡¼¥¿¤Î¥»¥Ã¥È
|
|---|
| 126 | function setValue($keyname, $val) {
|
|---|
| 127 | $_SESSION['customer'][$keyname] = $val;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | // ÃÂÀ¸Æü·î¤Ç¤¢¤ë¤«¤É¤¦¤«¤ÎȽÄê
|
|---|
| 131 | function isBirthMonth() {
|
|---|
| 132 | $arrRet = split("[- :/]", $_SESSION['customer']['birth']);
|
|---|
| 133 | $birth_month = intval($arrRet[1]);
|
|---|
| 134 | $now_month = intval(date("m"));
|
|---|
| 135 |
|
|---|
| 136 | if($birth_month == $now_month) {
|
|---|
| 137 | return true;
|
|---|
| 138 | }
|
|---|
| 139 | return false;
|
|---|
| 140 | }
|
|---|
| 141 | }
|
|---|
| 142 | ?> |
|---|