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

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