Skip to content

Commit

Permalink
リファクタリング
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasess committed Oct 19, 2007
1 parent 254c65c commit 5fbbcee
Show file tree
Hide file tree
Showing 10 changed files with 342 additions and 28 deletions.
Empty file added data/cache/dummy
Empty file.
178 changes: 178 additions & 0 deletions data/class/SC_Initial.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
<?php
/*
* Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
*
* http://www.lockon.co.jp/
*/

/**
* アプリケーションの初期設定クラス.
*
* @author LOCKON CO.,LTD.
* @version $Id$
*/
class SC_Initial {

// {{{ cunstructor

/**
* コンストラクタ.
*/
function SC_Initial() {

/** EC-CUBEのバージョン */
define('ECCUBE_VERSION', "2.0");
}

// }}}
// {{{ functions

/**
* 初期設定を行う.
*
* @access protected
* @return void
*/
function init() {
$this->requireInitialConfig();
$this->defineDSN();
$this->setErrorReporting();
$this->mbstringInit();
$this->defineConstants();
$this->createCacheDir();
}

/**
* 初期設定ファイルを読み込む.
*
* @access protected
* @return void
*/
function requireInitialConfig() {

require_once(realpath(dirname( __FILE__)) ."/../install.php");
}

/**
* DSN を定義する.
*
* @access protected
* @return void
*/
function defineDSN() {
if(defined('DB_TYPE') && defined('DB_USER') && defined('DB_PASSWORD')
&& defined('DB_SERVER') && defined('DB_PORT') && defined('DB_NAME')) {
/** サイト用DB */
define ("DEFAULT_DSN",
DB_TYPE . "://" . DB_USER . ":" . DB_PASSWORD . "@"
. DB_SERVER . ":" .DB_PORT . "/" . DB_NAME);
} else {
define("DEFAULT_DSN", "pgsql://nobody:password@localhost:5432/eccubedb");
}
}


/**
* エラーレベル設定を行う.
*
* ・推奨値
* 開発時 - E_ALL
* 運用時 - E_ALL & ~E_NOTICE
*
* @access protected
* @return void
*/
function setErrorReporting() {
error_reporting(E_ALL & ~E_NOTICE);
}

/**
* マルチバイト文字列設定を行う.
*
* TODO SJIS-win や, eucJP-win への対応
*
* @access protected
* @return void
*/
function mbstringInit() {
ini_set("mbstring.http_input", CHAR_CODE);
ini_set("mbstring.http_output", CHAR_CODE);
ini_set("auto_detect_line_endings", 1);
ini_set("default_charset", CHAR_CODE);
ini_set("mbstring.internal_encoding", CHAR_CODE);
ini_set("mbstring.detect_order", "auto");
ini_set("mbstring.substitute_character", "none");
}

/**
* 定数を設定する.
*
* mtb_constants.php を読み込んで定数を設定する.
* キャッシュディレクトリに存在しない場合は, 初期データからコピーする.
*
* @access protected
* @return void
*/
function defineConstants() {

$errorMessage = "<div style='color: #F00; font-weight: bold; "
. "background-color: #FEB; text-align: center'>"
. CACHE_PATH
. " にユーザ書込み権限(777等)を付与して下さい。</div>";

// 定数を設定
if (is_file(CACHE_PATH . "mtb_constants.php")) {
require_once(CACHE_PATH . "mtb_constants.php");

// キャッシュが無ければ, 初期データからコピー
} elseif (is_file(CACHE_PATH . "../mtb_constants_init.php")) {

$mtb_constants = file_get_contents(CACHE_PATH . "../mtb_constants_init.php");
if (is_writable(CACHE_PATH)) {
$handle = fopen(CACHE_PATH . "mtb_constants.php", "w");
if (!$handle) {
die($errorMessage);
}
if (fwrite($handle, $mtb_constants) === false) {
die($errorMessage);
}
fclose($handle);

require_once(CACHE_PATH . "mtb_constants.php");
} else {
die($errorMessage);
}
} else {
die(CACHE_PATH . "../mtb_constants_init.php が存在しません");
}
}

/**
* 各種キャッシュディレクトリを生成する.
*
* Smarty キャッシュディレクトリを生成する.
*
* @access protected
* @return void
*/
function createCacheDir() {
if (defined("HTML_PATH")) {
if (!file_exists(COMPILE_DIR)) {
mkdir(COMPILE_DIR);
}

if (!file_exists(MOBILE_COMPILE_DIR)) {
mkdir(MOBILE_COMPILE_DIR);
}

if (!file_exists(COMPILE_ADMIN_DIR)) {
mkdir(COMPILE_ADMIN_DIR);
}

if (!file_exists(COMPILE_FTP_DIR)) {
mkdir(COMPILE_FTP_DIR);
}
}
}
}
?>
30 changes: 30 additions & 0 deletions data/class/SC_Initial_Mobile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*
* Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
*
* http://www.lockon.co.jp/
*/

// {{{ requires
require_once(CLASS_PATH . "SC_Initial.php");

/**
* モバイルアプリケーションの初期設定クラス.
*
* @author LOCKON CO.,LTD.
* @version $Id$
*/
class SC_Initial_Mobile extends SC_Initial {

// {{{ cunstructor

/**
* コンストラクタ.
*/
function SC_Initial_Mobile() {
parent::SC_Initial();

define('MOBILE_SITE', true);
}
}
?>
3 changes: 2 additions & 1 deletion data/class/db/SC_DB_DBFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function getInstance() {
break;

default:
return new SC_DB_DBFactory();
}
}

Expand All @@ -52,7 +53,7 @@ function getDSN($dsn = "") {
if(defined('DEFAULT_DSN')) {
$dsn = DEFAULT_DSN;
} else {
return;
return "";
}
}
return $dsn;
Expand Down
30 changes: 30 additions & 0 deletions data/class_extends/SC_Initial_Ex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*
* Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
*
* http://www.lockon.co.jp/
*/

// {{{ requires
require_once(CLASS_PATH . "SC_Initial.php");

/**
* アプリケーションの初期設定クラス(拡張).
*
* SC_Initial をカスタマイズする場合はこのクラスを編集する.
*
* @author LOCKON CO.,LTD.
* @version $Id$
*/
class SC_Initial_Ex extends SC_Initial {

// {{{ constructor

/**
* コンストラクタ
*/
function SC_Initial_Ex() {
parent::SC_Initial();
}
}
?>
30 changes: 30 additions & 0 deletions data/class_extends/SC_Initial_Mobile_Ex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*
* Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
*
* http://www.lockon.co.jp/
*/

// {{{ requires
require_once(CLASS_PATH . "SC_Initial_Mobile.php");

/**
* モバイルアプリケーションの初期設定クラス(拡張).
*
* SC_Initial_Mobile をカスタマイズする場合はこのクラスを編集する.
*
* @author LOCKON CO.,LTD.
* @version $Id$
*/
class SC_Initial_Mobile_Ex extends SC_Initial_Mobile {

// {{{ constructor

/**
* コンストラクタ
*/
function SC_Initial_Mobile_Ex() {
parent::SC_Initial_Mobile();
}
}
?>
70 changes: 46 additions & 24 deletions html/install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function LC_Page() {
//$mode = lfGetFileMode($temp_dir);

if(!is_writable($temp_dir)) {
SC_Utils_Ex::sfErrorHeader($temp_dir . "にユーザ書込み権限(777等)を付与して下さい。", true);
SC_Utils_Ex::sfErrorHeader($temp_dir . "にユーザ書込み権限(777, 707等)を付与して下さい。", true);
exit;
}

Expand Down Expand Up @@ -373,38 +373,42 @@ function lfDispStep0($objPage) {
"../user_data",
"../cp",
"../upload",
".." . HTML2DATA_DIR . "Smarty/templates_c",
".." . HTML2DATA_DIR . "conf/cache",
".." . HTML2DATA_DIR . "downloads",
".." . HTML2DATA_DIR . "logs"
".." . HTML2DATA_DIR . "cache/",
".." . HTML2DATA_DIR . "class/",
".." . HTML2DATA_DIR . "Smarty/",
".." . HTML2DATA_DIR . "downloads/"
);

$mess = "";
$err_file = false;
foreach($arrWriteFile as $val) {
if(file_exists($val)) {
$mode = lfGetFileMode($val);
$real_path = realpath($val);

// ディレクトリの場合
if(is_dir($val)) {
if(is_writable($val)) {
$mess.= ">> ○:$real_path($mode) <br>アクセス権限は正常です。<br>";

$arrDirs = listdirs($val);
foreach ($arrDirs as $path) {
if(file_exists($path)) {
$mode = lfGetFileMode($path);
$real_path = realpath($path);

// ディレクトリの場合
if(is_dir($path)) {
if(is_writable($path)) {
//$mess.= ">> ○:$real_path($mode) <br>アクセス権限は正常です。<br>";
} else {
$mess.= ">> ×:$real_path($mode) <br>ユーザ書込み権限(777, 707等)を付与して下さい。<br>";
$err_file = true;
}
} else {
$mess.= ">> ×:$real_path($mode) <br>ユーザ書込み権限(777等)を付与して下さい。<br>";
$err_file = true;
if(is_writable($path)) {
//$mess.= ">> ○:$real_path($mode) <br>アクセス権限は正常です。<br>";
} else {
$mess.= ">> ×:$real_path($mode) <br>ユーザ書込み権限(666, 606等)を付与して下さい。<br>";
$err_file = true;
}
}
} else {
if(is_writable($val)) {
$mess.= ">> ○:$real_path($mode) <br>アクセス権限は正常です。<br>";
} else {
$mess.= ">> ×:$real_path($mode) <br>ユーザ書込み権限(666等)を付与して下さい。<br>";
$err_file = true;
}
$mess.= ">> ×:$path が見つかりません。<br>";
$err_file = true;
}
} else {
$mess.= ">> ×:$val が見つかりません。<br>";
$err_file = true;
}
}

Expand Down Expand Up @@ -450,6 +454,7 @@ function lfDispStep0($objPage) {
if(!file_exists($path)) {
mkdir($path);
}
$mess.= ">> ○:アクセス権限は正常です。<br>";
}

$objPage->mess = $mess;
Expand Down Expand Up @@ -1044,4 +1049,21 @@ function lfInsertCSVData($csv_id,$col,$disp_name,$rank,$create_date,$update_date
$sql = "insert into dtb_csv(csv_id,col,disp_name,rank,create_date,update_date) values($csv_id,'$col','$disp_name',$rank,$create_date,$update_date);";
$objDb->sfDataExists("dtb_csv", "csv_id = ? AND col = ?", array($csv_id, $col), $dsn, $sql, true);
}

/**
* $dir を再帰的に辿ってパス名を配列で返す.
*
* @param string 任意のパス名
* @return array $dir より下層に存在するパス名の配列
* @see http://www.php.net/glob
*/
function listdirs($dir) {
static $alldirs = array();
$dirs = glob($dir . '/*');
if (count($dirs) > 0) {
foreach ($dirs as $d) $alldirs[] = $d;
}
foreach ($dirs as $dir) listdirs($dir);
return $alldirs;
}
?>
Loading

0 comments on commit 5fbbcee

Please sign in to comment.