source: branches/dev/data/downloads/module/security/security.php @ 12107

Revision 12107, 4.4 KB checked in by naka, 19 years ago (diff)
Line 
1<?php
2/**
3 *
4 * @copyright   2000-2006 LOCKON CO.,LTD. All Rights Reserved.
5 * @version CVS: $Id: ebis_tag.php,v 1.0 2006/10/26 04:02:40 naka Exp $
6 * @link        http://www.lockon.co.jp/
7 *
8 */
9 
10//¥Ú¡¼¥¸´ÉÍý¥¯¥é¥¹
11class LC_Page {
12    //¥³¥ó¥¹¥È¥é¥¯¥¿
13    function LC_Page() {
14        //¥á¥¤¥ó¥Æ¥ó¥×¥ì¡¼¥È¤Î»ØÄê
15        $this->tpl_mainpage = MODULE_PATH . 'security/security.tpl';
16        $this->tpl_subtitle = '¥»¥­¥å¥ê¥Æ¥£¥Á¥§¥Ã¥¯';
17    }
18}
19
20$objPage = new LC_Page();
21$objView = new SC_AdminView();
22
23switch($_POST['mode']) {
24case 'edit':
25    // install.inc¤Î±£ÊÃ
26    $hidden_inc = MODULE_PATH . 'security/install_inc.php';
27    if(!file_exist($hidden_inc)) {
28       
29    }
30    break;
31default:
32    break;
33}
34
35$arrList[] = sfCheckOpenData();
36$arrList[] = sfCheckInstall();
37$arrList[] = sfCheckIDPass('admin', 'password');
38$arrList[] = sfCheckInstallInc();
39
40$objPage->arrList = $arrList;
41
42$objView->assignobj($objPage);                  //ÊÑ¿ô¤ò¥Æ¥ó¥×¥ì¡¼¥È¤Ë¥¢¥µ¥¤¥ó¤¹¤ë
43$objView->display($objPage->tpl_mainpage);      //¥Æ¥ó¥×¥ì¡¼¥È¤Î½ÐÎÏ
44//-------------------------------------------------------------------------------------------------------
45// ÀßÄê¥Õ¥¡¥¤¥ë(data)¤Î¥Ñ¥¹¤¬¸ø³«¥Ñ¥¹¤Ç¤Ê¤¤¤«³Îǧ¤¹¤ë
46function sfCheckOpenData() {
47    // ¥É¥­¥å¥á¥ó¥È¥ë¡¼¥È¤Î¥Ñ¥¹¤ò¿ä¬¤¹¤ë¡£
48    $doc_root = ereg_replace(URL_DIR . "$","/",HTML_PATH);
49    $data_path = realpath(DATA_PATH);
50   
51    // data¤Î¥Ñ¥¹¤¬¥É¥­¥å¥á¥ó¥È¥ë¡¼¥È°Ê²¼¤Ë¤¢¤ë¤«È½Äê
52    if(ereg("^".$doc_root, $data_path)) {
53        $arrResult['result'] = "¡ß";
54        $arrResult['detail'] = "ÀßÄê¥Õ¥¡¥¤¥ë¤¬¡¢¸ø³«¤µ¤ì¤Æ¤¤¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£<br>";
55        $arrResult['detail'].= "/data/¥Ç¥£¥ì¥¯¥È¥ê¤Ï¡¢Èó¸ø³«¤Î¥Ñ¥¹¤ËÀßÃÖ¤·¤Æ²¼¤µ¤¤¡£";
56    } else {
57        $arrResult['result'] = "¡û";
58        $arrResult['detail'] = "ÀßÄê¥Õ¥¡¥¤¥ë¤Ï¡¢¸ø³«¥Ñ¥¹ÇÛ²¼¤Ë¸ºß¤·¤Þ¤»¤ó¡£";       
59    }
60   
61    $arrResult['title'] = "ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÊݸ¥Ñ¥¹";
62    return $arrResult;
63}
64
65// ¥¤¥ó¥¹¥È¡¼¥ë¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹¤ë¤«³Îǧ¤¹¤ë
66function sfCheckInstall() {
67    // ¥¤¥ó¥¹¥È¡¼¥ë¥Õ¥¡¥¤¥ë¤Î¸ºß¥Á¥§¥Ã¥¯
68    $inst_path = HTML_PATH . "install/index.php";
69   
70    if(file_exists($inst_path)) {
71        $arrResult['result'] = "¡ß";
72        $arrResult['detail'] = "/install/index.php¤Ï¡¢¥¤¥ó¥¹¥È¡¼¥ë´°Î»¸å¤Ë¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡£";           
73    } else {
74        $arrResult['result'] = "¡û";
75        $arrResult['detail'] = "/install/index.php¤Ï¡¢¸«¤Ä¤«¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡£";   
76    }
77   
78    $arrResult['title'] = "¥¤¥ó¥¹¥È¡¼¥ë¥Õ¥¡¥¤¥ë¤Î¥Á¥§¥Ã¥¯";
79    return $arrResult;
80}
81
82// ´ÉÍý¼Ô¥æ¡¼¥¶¤ÎID/¥Ñ¥¹¥ï¡¼¥É¥Á¥§¥Ã¥¯
83function sfCheckIDPass($user, $password) {
84    $objQuery = new SC_Query();
85    $sql = "SELECT password FROM dtb_member WHERE login_id = ?";
86    // DB¤«¤é°Å¹æ²½¥Ñ¥¹¥ï¡¼¥É¤ò¼èÆÀ¤¹¤ë¡£
87    $arrRet = $objQuery->getAll($sql, array($user));
88    // ¥æ¡¼¥¶ÆþÎϥѥ¹¥ï¡¼¥É¤ÎȽÄê
89    $ret = sha1($password . ":" . AUTH_MAGIC);
90   
91    if($ret == $arrRet[0]['password']) {
92        $arrResult['result'] = "¡ß";
93        $arrResult['detail'] = "Èó¾ï¤Ë¿ä¬¤Î¤·¤ä¤¹¤¤´ÉÍý¼ÔID¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£¸Ä¿Í¾ðÊóϳ±Ì¤Î´í¸±À­¤¬¹â¤¤¤Ç¤¹¡£";       
94    } else {
95        if(count($arrRet) > 0) {
96            $arrResult['result'] = "¢¤";
97            $arrResult['detail'] = "´ÉÍý¼Ô̾¤Ë¡Öadmin¡×¤òÍøÍѤ·¤Ê¤¤¤è¤¦¤Ë¤·¤Æ²¼¤µ¤¤¡£";               
98        } else {
99            $arrResult['result'] = "¡û";
100            $arrResult['detail'] = "ÆÈ¼«¤ÎID¡¢¥Ñ¥¹¥ï¡¼¥É¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤è¤¦¤Ç¤¹¡£";               
101        }
102    }
103   
104    $arrResult['title'] = "ID/¥Ñ¥¹¥ï¡¼¥É¤Î¥Á¥§¥Ã¥¯";
105    return $arrResult;
106}
107
108
109// install.inc¤Î¥Õ¥¡¥¤¥ë¤ò¥Á¥§¥Ã¥¯¤¹¤ë
110function sfCheckInstallInc() {
111    if(sfIsNormalInstallInc()) {
112        $arrResult['result'] = "¡ß";
113        $arrResult['detail'] = "install.inc¤ÎÆâÍÆ¤ò±£Êä·¤Þ¤¹¤«¡©";
114        $arrResult['detail'].= "<input type='submit' value='±£Ê乤ë'>";       
115    } else {
116        $arrResult['result'] = "¡û";
117        $arrResult['detail'] = "install.inc¤Î±£ÊÃÂкö¤¬¤È¤é¤ì¤Æ¤¤¤Þ¤¹¡£";                       
118    }
119    $arrResult['title'] = "install.inc¤Î¥Á¥§¥Ã¥¯";
120    return $arrResult;
121}
122
123// install.inc¤¬±£Êøå¤Î¤â¤Î¤«È½Äꤹ¤ë
124function sfIsNormalInstallInc() {
125    // install.inc¤Î¥Ñ¥¹¤ò¼èÆÀ¤¹¤ë
126    $inst_inc = DATA_PATH . 'install.inc';
127    if(file_exists($inst_inc)) {
128        if($fp = fopen($inst_inc, "r")) {
129            $data = fread($fp, filesize($inst_inc));
130            fclose($fp);
131        }
132        if(ereg("DB_PASSWORD", $data)) {
133            return true;
134        }
135    }
136    return false;
137}
138
139?>
Note: See TracBrowser for help on using the repository browser.