source: temp/branches/mobile/html/mobile/forgot/index.php @ 11411

Revision 11411, 5.0 KB checked in by rebelt, 17 years ago (diff)

修正です。

  • Property svn:eol-style set to native
Line 
1<?php
2/**
3 * ¥â¥Ð¥¤¥ë¥µ¥¤¥È/¥Ñ¥¹¥ï¡¼¥É¤ò˺¤ì¤¿Êý
4 */
5
6require_once('../require.php');
7
8class LC_Page {
9    var $errmsg;
10    var $arrReminder;
11    var $temp_password;
12
13    function LC_Page() {
14        $this->tpl_mainpage = 'forgot/index.tpl';
15        $this->tpl_title = '¥Ñ¥¹¥ï¡¼¥É¤ò˺¤ì¤¿Êý';
16        $this->tpl_mainno = '';
17    }
18}
19
20$conn = new SC_DBConn();
21$objPage = new LC_Page();
22$objPage = sfGetPageLayout($objPage, false, DEF_LAYOUT);
23$objView = new SC_SiteView();
24$objSess = new SC_Session();
25$CONF = sf_getBasisData();                  // ŹÊÞ´ðËܾðÊó
26// ¥¯¥Ã¥­¡¼´ÉÍý¥¯¥é¥¹
27$objCookie = new SC_Cookie(COOKIE_EXPIRE);
28
29if (isset($_SESSION['mobile']['kara_mail_from'])) {
30    if (!isset($_POST['mode'])) {
31        $_POST['mode'] = 'mail_check';
32    }
33    $_POST['email'] = $_SESSION['mobile']['kara_mail_from'];
34}
35
36if ( $_POST['mode'] == 'mail_check' ){
37    //¥á¥¢¥ÉÆþÎÏ»þ
38    $_POST['email'] = strtolower($_POST['email']);
39    $sql = "SELECT * FROM dtb_customer WHERE (email ILIKE ? OR email_mobile ILIKE ?) AND status = 2 AND del_flg = 0";
40    $result = $conn->getAll($sql, array($_POST['email'], $_POST['email']) );
41   
42    if ( $result[0]['reminder'] ){      // Ëܲñ°÷ÅÐÏ¿ºÑ¤ß¤Î¾ì¹ç
43        // ÆþÎÏemail¤¬Â¸ºß¤¹¤ë     
44        $_SESSION['forgot']['email'] = $_POST['email'];
45        $_SESSION['forgot']['reminder'] = $result[0]['reminder'];
46        // ¥Ò¥ß¥Ä¤ÎÅú¤¨ÆþÎϲèÌÌ
47        $objPage->Reminder = $arrReminder[$_SESSION['forgot']['reminder']];
48        $objPage->tpl_mainpage = 'forgot/secret.tpl';
49    } else {
50        $sql = "SELECT customer_id FROM dtb_customer WHERE email ILIKE ? AND status = 1 AND del_flg = 0";   //²¾ÅÐÏ¿Ãæ¤Î³Îǧ
51        $result = $conn->getAll($sql, array($_POST['email']) );
52        if ($result) {
53            $objPage->errmsg = "¤´ÆþÎϤÎemail¥¢¥É¥ì¥¹¤Ï¸½ºß²¾ÅÐÏ¿Ãæ¤Ç¤¹¡£<br>ÅÐÏ¿¤ÎºÝ¤Ë¤ªÁ÷¤ê¤·¤¿¥á¡¼¥ë¤ÎURL¤Ë¥¢¥¯¥»¥¹¤·¡¢<br>Ëܲñ°÷ÅÐÏ¿¤ò¤ª´ê¤¤¤·¤Þ¤¹¡£";
54        } else {        //¡¡ÅÐÏ¿¤·¤Æ¤¤¤Ê¤¤¾ì¹ç
55            $objPage->errmsg = "¤´ÆþÎϤÎemail¥¢¥É¥ì¥¹¤ÏÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤»¤ó";
56        }
57    }
58   
59} elseif( $_POST['mode'] == 'secret_check' ){
60    //¥Ò¥ß¥Ä¤ÎÅú¤¨ÆþÎÏ»þ
61   
62    if ( $_SESSION['forgot']['email'] ) {
63        // ¥Ò¥ß¥Ä¤ÎÅú¤¨¤Î²óÅú¤¬Àµ¤·¤¤¤«¥Á¥§¥Ã¥¯
64       
65        $sql = "SELECT * FROM dtb_customer WHERE (email ILIKE ? OR email_mobile ILIKE ?) AND del_flg = 0";
66        $result = $conn->getAll($sql, array($_SESSION['forgot']['email'], $_SESSION['forgot']['email']) );
67        $data = $result[0];
68       
69        if ( $data['reminder_answer'] === $_POST['input_reminder'] ){
70            // ¥Ò¥ß¥Ä¤ÎÅú¤¨¤¬Àµ¤·¤¤
71                       
72            // ¿·¤·¤¤¥Ñ¥¹¥ï¡¼¥É¤òÀßÄꤹ¤ë
73            $objPage->temp_password = gfMakePassword(8);
74                       
75            if(FORGOT_MAIL == 1) {
76                // ¥á¡¼¥ë¤ÇÊѹ¹ÄÌÃΤò¤¹¤ë
77                lfSendMail($CONF, $_SESSION['forgot']['email'], $data['name01'], $objPage->temp_password);
78            }
79           
80            // DB¤ò½ñ¤­´¹¤¨¤ë
81            $sql = "UPDATE dtb_customer SET password = ?, update_date = now() WHERE customer_id = ?";
82            $conn->query( $sql, array( sha1($objPage->temp_password . ":" . AUTH_MAGIC) ,$data['customer_id']) );
83           
84            // ´°Î»²èÌ̤Îɽ¼¨
85            $objPage->tpl_mainpage = 'forgot/complete.tpl';
86           
87            // ¥»¥Ã¥·¥ç¥óÊÑ¿ô¤Î²òÊü
88            $_SESSION['forgot'] = array();
89            unset($_SESSION['forgot']);
90           
91        } else {
92            // ¥Ò¥ß¥Ä¤ÎÅú¤¨¤¬Àµ¤·¤¯¤Ê¤¤
93           
94            $objPage->Reminder = $arrReminder[$_SESSION['forgot']['reminder']];
95            $objPage->errmsg = "¥Ñ¥¹¥ï¡¼¥É¤ò˺¤ì¤¿¤È¤­¤Î¼ÁÌä¤ËÂФ¹¤ë²óÅú¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó";
96            $objPage->tpl_mainpage = 'forgot/secret.tpl';
97
98        }
99   
100       
101    } else {
102        // ¥¢¥¯¥»¥¹¸µ¤¬ÉÔÀµ¤Þ¤¿¤Ï¡¢¥»¥Ã¥·¥ç¥óÊÝ»ý´ü´Ö¤¬ÀÚ¤ì¤Æ¤¤¤ë
103        $objPage->errmsg = "email¥¢¥É¥ì¥¹¤òºÆÅÙÅÐÏ¿¤·¤Æ¤¯¤À¤µ¤¤¡£<br />Á°²ó¤ÎÆþÎϤ«¤é»þ´Ö¤¬·Ð¤Ã¤Æ¤¤¤Þ¤¹¤È¡¢ËÜ¥á¥Ã¥»¡¼¥¸¤¬É½¼¨¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£";
104    }
105}
106
107// ¥Ç¥Õ¥©¥ë¥ÈÆþÎÏ
108if($_POST['email'] != "") {
109    // POSTÃͤòÆþÎÏ
110    $objPage->tpl_login_email = $_POST['email'];
111} else {
112    // ¥¯¥Ã¥­¡¼ÃͤòÆþÎÏ
113    $objPage->tpl_login_email = $objCookie->getCookie('login_email');
114}
115
116// ¶õ¥á¡¼¥ëÍѤΥȡ¼¥¯¥ó¤òºîÀ®¡£
117if (MOBILE_USE_KARA_MAIL) {
118    $token = gfPrepareKaraMail('forgot/index.php');
119    if ($token !== false) {
120        $objPage->tpl_kara_mail_to = MOBILE_KARA_MAIL_ADDRESS_USER . MOBILE_KARA_MAIL_ADDRESS_DELIMITER . 'forgot_' . $token . '@' . MOBILE_KARA_MAIL_ADDRESS_DOMAIN;
121    }
122}
123
124//----¡¡¥Ú¡¼¥¸É½¼¨
125$objView->assignobj($objPage);
126$objView->display(SITE_FRAME);
127
128//-----------------------------------------------------------------------------------------------------------------------------------
129
130function lfSendMail($CONF, $email, $customer_name, $temp_password){
131    //¡¡¥Ñ¥¹¥ï¡¼¥ÉÊѹ¹¤ªÃΤ餻¥á¡¼¥ëÁ÷¿®
132   
133    $objPage = new LC_Page();
134    $objPage->customer_name = $customer_name;
135    $objPage->temp_password = $temp_password;
136    $objMailText = new SC_SiteView();
137    $objMailText->assignobj($objPage);
138   
139    $toCustomerMail = $objMailText->fetch("mail_templates/forgot_mail.tpl");
140    $objMail = new GC_SendMail();
141   
142    $objMail->setItem(
143                          ''                                //¡¡°¸Àè
144                        , "¥Ñ¥¹¥ï¡¼¥É¤¬Êѹ¹¤µ¤ì¤Þ¤·¤¿" ."¡Ú" .$CONF["shop_name"]. "¡Û"      //¡¡¥µ¥Ö¥¸¥§¥¯¥È
145                        , $toCustomerMail                   //¡¡ËÜʸ
146                        , $CONF["email03"]                  //¡¡ÇÛÁ÷¸µ¥¢¥É¥ì¥¹
147                        , $CONF["shop_name"]                //¡¡ÇÛÁ÷¸µ¡¡Ì¾Á°
148                        , $CONF["email03"]                  //¡¡reply_to
149                        , $CONF["email04"]                  //¡¡return_path
150                        , $CONF["email04"]                  //  Errors_to
151
152                                                        );
153    $objMail->setTo($email, $customer_name ." ÍÍ");
154    $objMail->sendMail();   
155   
156}
157
158
159?>
160
Note: See TracBrowser for help on using the repository browser.