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

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