Index: branches/version-2_5-dev/data/mtb_constants_init.php
===================================================================
--- branches/version-2_5-dev/data/mtb_constants_init.php	(revision 20134)
+++ branches/version-2_5-dev/data/mtb_constants_init.php	(revision 20246)
@@ -603,3 +603,11 @@
 /** 外部サイトHTTP取得タイムアウト時間(秒) */
 define('HTTP_REQUEST_TIMEOUT', "5");
+/** プラグインの状態：アップロード済み */
+define('PLUGIN_STATUS_UPLOADED', "1");
+/** プラグインの状態：インストール済み */
+define('PLUGIN_STATUS_INSTALLED', "2");
+/** プラグイン有効/無効：有効 */
+define('PLUGIN_ENABLE_TRUE', "1");
+/** プラグイン有効/無効：無効 */
+define('PLUGIN_ENABLE_FALSE', "2");
 ?>
Index: branches/version-2_5-dev/data/class/SC_CheckError.php
===================================================================
--- branches/version-2_5-dev/data/class/SC_CheckError.php	(revision 20090)
+++ branches/version-2_5-dev/data/class/SC_CheckError.php	(revision 20246)
@@ -621,10 +621,24 @@
             $errFlag = 1;
             $array_ext = explode(".", $_FILES[$value[1]]['name']);
-            $ext = $array_ext[ count ( $array_ext ) - 1 ];
-            $ext = strtolower($ext);
 
             $strExt = "";
 
             foreach ( $value[2] as $checkExt ){
+                $ext = "";
+
+                // チェック拡張子のピリオドの数を取得('tar.gz'の場合1個、'jpg'のように通常は0個)
+                $count_period = substr_count($checkExt, ".");
+                
+                if($count_period > 0) {
+                    for($i = max(array_keys($array_ext)) - $count_period; $i < count($array_ext); $i++) {
+                        $ext .= $array_ext[$i] . ".";
+                    }
+                    $ext = preg_replace("/.$/", "" ,$ext);
+                } else {
+                    $ext = $array_ext[ count ( $array_ext ) - 1 ];
+                }
+
+                $ext = strtolower($ext);
+
                 if ( $ext == $checkExt) {
                     $errFlag = 0;
Index: branches/version-2_5-dev/data/class/pages/admin/system/LC_Page_Admin_System_Plugin.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/system/LC_Page_Admin_System_Plugin.php	(revision 20116)
+++ branches/version-2_5-dev/data/class/pages/admin/system/LC_Page_Admin_System_Plugin.php	(revision 20246)
@@ -24,4 +24,5 @@
 // {{{ requires
 require_once(CLASS_REALDIR . "pages/admin/LC_Page_Admin.php");
+require_once(CLASS_EX_REALDIR . "helper_extends/SC_Helper_FileManager_Ex.php");
 
 /**
@@ -52,18 +53,4 @@
 
     /**
-     * フォームパラメータ初期化
-     *
-     * @return void
-     */
-    function initForm() {
-        $objForm = new SC_FormParam();
-        $objForm->addParam('mode', 'mode', INT_LEN, '', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK'));
-        $objForm->addParam('plugin_name', 'plugin_name', INT_LEN, '', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK'));
-
-        $objForm->setParam($_POST);
-        $this->objForm = $objForm;
-    }
-
-    /**
      * Page のプロセス.
      *
@@ -81,70 +68,64 @@
      */
     function action() {
+        // 認証可否の判定
         SC_Utils_Ex::sfIsSuccess(new SC_Session);
-        $this->initForm();
-        switch($this->getMode()) {
-            // PHP INFOを表示
-            case 'install':
-                $name = $this->objForm->getValue('plugin_name');
-                require_once(DATA_REALDIR.'/plugin/'.$name.'/'.$name.'.php');
-                $plugin = new $name();
-                $plugin->install();
-                break;
-            case 'uninstall':
-                $name = $this->objForm->getValue('plugin_name');
-                require_once(DATA_REALDIR.'/plugin/'.$name.'/'.$name.'.php');
-                $plugin = new $name();
-                $plugin->uninstall();
-                break;
-            case 'enable':
-                $name = $this->objForm->getValue('plugin_name');
-                require_once(DATA_REALDIR.'/plugin/'.$name.'/'.$name.'.php');
-                $plugin = new $name();
-                $plugin->enable();
-
-                break;
-            case 'disable':
-              $name = $this->objForm->getValue('plugin_name');
-                require_once(DATA_REALDIR.'/'.$name.'/'.$name.'.php');
-                $plugin = new $name();
-                $plugin->disable();
-                break;
-            default:
-                $plugins = SC_Helper_Plugin_Ex::getAllPlugin();
-                $this->plugins = array_merge($plugins,
-                $this->getPluginOnFilesystem($plugins));
-                break;
-        }
-
-        $this->arrSystemInfo = $this->getSystemInfo();
-    }
-
-    /*
-     CREATE TABLE dtb_plugin (
-     plugin_id INT NOT NULL,
-     plugin_name VARCHAR(255) NOT NULL DEFAULT "",
-     enable INT NOT NULL DEFAULT 0,
-     del_flg INT NOT NULL DEFAULT 0,
-     class_name VARCHAR(255) NOT NULL DEFAULT NULL,
-     create_date DATETIME NOT NULL,
-     update_date DATETIME NOT NULL,
-     PRIMARY KEY (plugin_id)
-     ) TYPE=InnoDB;
-     */
-
-    function getPluginOnFilesystem($existsPlugins){
-
-        $dir = DATA_REALDIR."plugin/";
-        $arrPlugins = array();
-        if($dh =  opendir($dir)){
-            while(($file = readdir($dh)) !== false){
-                if(!preg_match('/^\\./', $file) && $file !='..' && filetype($dir.$file) == 'dir'){
-                    $arrPlugins[] = array('plugin_name'=>$file,'class_name'=>$file);
-
+
+        // パラメータ管理クラス
+        $objFormParam = new SC_FormParam();
+        // パラメータ情報の初期化
+        $this->lfInitParam($objFormParam);
+        $objFormParam->setParam($_POST);
+        
+        $mode = $this->getMode();
+
+        switch($mode) {
+        case 'install':
+        case 'uninstall':
+        case 'enable':
+        case 'disable':
+            // エラーチェック
+            $this->arrErr = $objFormParam->checkError();
+
+            if(count($this->arrErr) == 0) {
+                $plugin_id = $objFormParam->getValue('plugin_id');
+                $plugin_code = $objFormParam->getValue('plugin_code');
+                
+                // プラグインファイルを読み込み、modeで指定されたメソッドを実行
+                $this->arrErr = $this->lfExecPlugin($plugin_id, $plugin_code, $mode);
+            }
+            break;
+        case 'upload':
+            // プラグイン情報を設定
+            $plugin_code = $this->lfGetPluginCode($_FILES['plugin_file']['name']);
+            $plugin_dir = $this->lfGetPluginDir($plugin_code);
+
+            // ファイルアップロード情報を設定
+            $objUpFile = new SC_UploadFile(TEMPLATE_TEMP_REALDIR, $plugin_dir);
+            $this->lfInitUploadFile($objUpFile);
+
+            // エラーチェック
+            $this->arrErr = $this->lfCheckErrorUploadFile($plugin_code, $plugin_dir);
+
+            if(count($this->arrErr) == 0) {
+                // 一時ディレクトリへアップロード
+                $this->arrErr['plugin_file'] = $objUpFile->makeTempFile('plugin_file', false);
+
+                if($this->arrErr['plugin_file'] == "") {
+                    // プラグイン保存ディレクトリへ解凍
+                    $this->arrErr = $this->lfUploadPlugin($objUpFile, $plugin_dir, $plugin_code, $_FILES['plugin_file']['name']);
+
+                    // 完了メッセージアラート設定
+                    if(count($this->arrErr) == 0) {
+                        $this->tpl_onload = "alert('プラグインをアップロードしました。');";
+                    }
                 }
             }
-        }
-        //        var_dump($arrPlugins);
-        return $arrPlugins;
+            break;
+        default:
+            break;
+        }
+
+        // DBからプラグイン情報を取得
+        $this->plugins = SC_Helper_Plugin_Ex::getAllPlugin();
     }
 
@@ -159,21 +140,182 @@
 
     /**
-     * システム情報を取得する
-     *
-     * @return array
-     */
-    function getSystemInfo() {
-        $objDB = SC_DB_DBFactory_Ex::getInstance();
-
-        $arrSystemInfo = array(
-        array('title' => 'EC-CUBE',  'value' => ECCUBE_VERSION),
-        array('title' => 'OS',       'value' => php_uname()),
-        array('title' => 'DBサーバ',  'value' => $objDB->sfGetDBVersion()),
-        array('title' => 'WEBサーバ', 'value' => $_SERVER['SERVER_SOFTWARE']),
-        array('title' => 'PHP',      'value' => phpversion()),
-        array('title' => 'GD',       'value' => extension_loaded('GD') ? 'Loaded' : '--'),
-        );
-
-        return $arrSystemInfo;
+     * パラメータ初期化.
+     *
+     * @param object $objFormParam
+     * @return void
+     * 
+     */
+    function lfInitParam(&$objFormParam) {
+        $objFormParam->addParam('mode', 'mode', INT_LEN, '', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK'));
+        $objFormParam->addParam('plugin_id', 'plugin_id', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
+        $objFormParam->addParam('plugin_code', 'plugin_code', MTEXT_LEN, '', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK'));
+    }
+
+    /**
+     * アップロードファイルパラメータ初期化.
+     *
+     * @param object $objUpFile SC_UploadFileのインスタンス.
+     * @return void
+     */
+    function lfInitUploadFile(&$objUpFile) {
+        $objUpFile->addFile("プラグイン", 'plugin_file', array('tar', 'tar.gz'), TEMPLATE_SIZE, true, 0, 0, false);
+    }
+
+    /**
+     * アップロードファイルのエラーチェック.
+     * 
+     * @param string $plugin_code
+     * @param string $plugin_dir
+     * @return array エラー情報を格納した連想配列.
+     * 
+     */
+    function lfCheckErrorUploadFile($plugin_code, $plugin_dir) {
+        $arrErr = array();
+
+        // プラグイン重複チェック
+        $plugins = SC_Helper_Plugin_Ex::getAllPlugin();
+        foreach($plugins as $val) {
+            if($val['plugin_code'] == $plugin_code) {
+                $arrErr['plugin_file'] = "※ 同名のプラグインがすでに登録されています。<br/>";
+            }
+        }
+
+        return $arrErr;
+    }
+
+    /**
+     * プラグイン名(物理名)を取得する.
+     * (アップロードされたファイル名をプラグイン名(物理名)とする).
+     * 
+     * @param string $upload_file_name
+     * @return string プラグイン名(物理名).
+     * 
+     */
+    function lfGetPluginCode($upload_file_name) {
+        $array_ext = explode(".", $upload_file_name);
+        return $array_ext[0];
+    }
+
+    /**
+     * プラグイン保存ディレクトリのパスを取得する.
+     *
+     * @param string $plugin_code
+     * @return string プラグイン保存ディレクトリ.
+     * 
+     */
+    function lfGetPluginDir($plugin_code) {
+        $plugin_dir = DATA_REALDIR . 'plugin/' . $plugin_code . '/';
+        return $plugin_dir;
+    }
+
+    /**
+     * プラグインファイルのパスを取得する.
+     * 
+     * @param string $plugin_code
+     * @return string プラグインファイルパス.
+     */
+    function lfGetPluginFilePath($plugin_code) {
+        $plugin_file_path = $this->lfGetPluginDir($plugin_code) . $plugin_code . '.php';
+        return $plugin_file_path;
+    }
+    /**
+     * プラグインをアップロードする.
+     * 
+     * @param object $objUpFile
+     * @param string $plugin_dir
+     * @param string $plugin_code
+     * @param string $plugin_file_name
+     * @return array エラー情報を格納した連想配列.
+     * 
+     */
+    function lfUploadPlugin(&$objUpFile, $plugin_dir, $plugin_code, $plugin_file_name) {
+        $arrErr = array();
+        
+        // 必須チェック
+        $arrErr = $objUpFile->checkEXISTS('plugin_file');
+
+        if(count($arrErr) == 0) {
+            // プラグイン保存ディレクトリ作成
+            if(file_exists($plugin_dir)) {
+                $arrErr['plugin_file'] = "※ 同名のディレクトリがすでに存在します。<br/>";
+            } else {
+                mkdir($plugin_dir);
+            }
+
+            if(count($arrErr) == 0) {
+                // 一時ディレクトリからプラグイン保存ディレクトリへ移動
+                $objUpFile->moveTempFile();
+
+                // プラグイン保存ディレクトリへ解凍
+                SC_Helper_FileManager::unpackFile($plugin_dir . $plugin_file_name);
+
+                // プラグイン情報をDB登録
+                $this->lfRegistData($plugin_dir, $plugin_code);
+            }
+        }
+
+        return $arrErr;
+    }
+
+    /**
+     * プラグイン情報をDB登録.
+     *
+     * @param string $plugin_dir
+     * @param string $plugin_code
+     * @return void
+     *
+     */
+    function lfRegistData($plugin_dir, $plugin_code) {
+        $objQuery =& SC_Query::getSingletonInstance();
+        $sqlval = array();
+        
+        $sqlval['plugin_id'] = $objQuery->nextVal('dtb_plugin_plugin_id');
+        $sqlval['plugin_code'] = $plugin_code;
+        $sqlval['status'] = PLUGIN_STATUS_UPLOADED;
+        $sqlval['enable'] = PLUGIN_ENABLE_FALSE;
+        $sqlval['update_date'] = 'now()';
+        $objQuery->insert('dtb_plugin', $sqlval);
+    }
+
+    /**
+     * プラグインファイルを読み込む.
+     * 
+     * @param string $plugin_code
+     * @return array エラー情報を格納した連想配列.
+     */
+    function lfRequirePluginFile($plugin_code) {
+        $arrErr = array();
+        $plugin_file_path = $this->lfGetPluginFilePath($plugin_code);
+
+        if(file_exists($plugin_file_path)) {
+            require_once($plugin_file_path);
+        } else {
+            $arrErr['plugin_error'] = "※ " . $plugin_code . ".phpが存在しないため実行できません。<br/>";
+        }
+        
+        return $arrErr;
+    }
+
+    /**
+     * プラグインファイルを読み込み、指定されたメソッドを実行する.
+     *
+     * @param integer $plugin_id
+     * @param string $plugin_code
+     * @param string $exec_mode プラグイン実行メソッド名.
+     * @return array エラー情報を格納した連想配列.
+     *
+     */
+    function lfExecPlugin($plugin_id, $plugin_code, $exec_mode) {
+        $arrErr = array();
+
+        // プラグインファイル読み込み
+        $arrErr = $this->lfRequirePluginFile($plugin_code);
+        
+        if(count($arrErr) == 0) {
+            $plugin = new $plugin_code();
+            $arrErr = $plugin->$exec_mode($plugin_id);
+        }
+
+        return $arrErr;
     }
 }
Index: branches/version-2_5-dev/data/Smarty/templates/admin/system/plugin.tpl
===================================================================
--- branches/version-2_5-dev/data/Smarty/templates/admin/system/plugin.tpl	(revision 20116)
+++ branches/version-2_5-dev/data/Smarty/templates/admin/system/plugin.tpl	(revision 20246)
@@ -1,55 +1,107 @@
-<form name="form1" id="form1" method="post" action="?">
+<!--{*
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+*}-->
+<!--<form name="form1" id="form1" method="post" action="?">-->
+<form name="form1" method="post" action="?" enctype="multipart/form-data">
 <input type="hidden" name="mode" value="" />
-<input type="hidden" name="keyname" value="" />
+<input type="hidden" name="plugin_id" value="" />
+<input type="hidden" name="plugin_code" value="" />
+
 <div id="system" class="contents-main">
-  <div class="paging">
-    <!--▼ページ送り-->
-    <!--{$tpl_strnavi}-->
-    <!--▲ページ送り-->
+
+  <h2>プラグイン登録</h2>
+  <table class="form">
+    <tr>
+      <th>プラグイン<span class="attention"> *</span></th>
+      <td>
+        <!--{assign var=key value="plugin_file"}-->
+        <span class="attention"><!--{$arrErr[$key]}--></span>
+        <input type="file" name="<!--{$key}-->" style="<!--{$arrErr[$key]|sfGetErrorColor}-->" class="box54" size="64" <!--{if $arrErr[$key]}-->style="background-color:<!--{$smarty.const.ERR_COLOR|h}-->"<!--{/if}-->>
+      </td>
+    </tr>
+  </table>
+
+  <div class="btn-area">
+    <a class="btn-action" href="javascript:;" onclick="fnModeSubmit('upload', '', '');return false;"><span class="btn-next">この内容で登録する</span></a>
   </div>
   
-  <!--▼メンバー一覧ここから-->
-  <table class="list">
+  <!--▼プラグイン一覧ここから-->
+  <h2>プラグイン一覧</h2>
+  <!--{if count($plugins) > 0}-->
+  <span class="attention"><!--{$arrErr.plugin_error}--><!--{$arrErr.mode}--><!--{$arrErr.plugin_id}--><!--{$arrErr.plugin_code}--></span>
+  <table class="list" width="900">
+    <colgroup width="15%">
+    <colgroup width="10%">
+    <colgroup width="25%">
+    <colgroup width="28%">
+    <colgroup width="7%">
+    <colgroup width="10%">
+    <colgroup width="5%">
     <tr>
-      <th>名前</th>
-      <th>パス</th>
-      <th>有効/無効</th>
+      <th >プラグイン名</th>
+      <th>作者</th>
+      <th>サイトURL</th>
+      <th>説明</th>
+      <th>ステータス</th>
+      <th>操作</th>
       <th>設定</th>
     </tr>
     <!--{section name=data loop=$plugins}-->
-    <!--▼メンバー<!--{$smarty.section.data.iteration}-->-->
     <tr>
-      <td><!--{$plugins[data].plugin_name|h}--></td>
-      <td><!--{$plugins[data].plugin_name|h}--></td>
-      <td>
-        <!--{if $plugins[data].create_date == null}-->
-        <input type="hidden" name="plugin_name" value="<!--{$plugins[data].plugin_name}-->" />
-           <a class="btn-normal" href="javascript:;" name="install" onclick="fnModeSubmit('install','',''); return false;">install</a>
+      <td><!--{$plugins[data].plugin_name|default:$plugins[data].plugin_code|h}--><!--{if $plugins[data].plugin_version != ''}--><br /><!--{$plugins[data].plugin_version|h}--><!--{/if}--></td>
+      <td><!--{$plugins[data].author|default:'-'|h}--></td>
+      <td><!--{$plugins[data].plugin_site_url|default:'-'|h}--></td>
+      <td><!--{$plugins[data].plugin_description|default:'-'|h}--></td>
+      <td class="center">
+        <!--{if $plugins[data].enable == $smarty.const.PLUGIN_ENABLE_TRUE}-->
+        有効
+        <!--{elseif $plugins[data].enable == $smarty.const.PLUGIN_ENABLE_FALSE}-->
+        無効
+        <!--{else}-->-<!--{/if}-->
+      </td>
+      <td class="center">
+        <!--{if $plugins[data].status == $smarty.const.PLUGIN_STATUS_UPLOADED}-->
+        <a class="btn-normal" href="javascript:;" name="install" onclick="fnSetFormValue('plugin_id', '<!--{$plugins[data].plugin_id}-->'); fnModeSubmit('install','plugin_code','<!--{$plugins[data].plugin_code}-->'); return false;">install</a>
         <!--{else}-->
-          <!--{if $plugins[data].enable == 1}-->
-           <a class="btn-normal" href="javascript:;" name="disable" onclick="fnModeSubmit('disable','',''); return false;">disable</a>
+          <!--{if $plugins[data].enable == $smarty.const.PLUGIN_ENABLE_TRUE}-->
+          <a class="btn-normal" href="javascript:;" name="disable" onclick="fnSetFormValue('plugin_id', '<!--{$plugins[data].plugin_id}-->'); fnModeSubmit('disable','plugin_code','<!--{$plugins[data].plugin_code}-->'); return false;">disable</a><br />
           <!--{else}-->
-           <a class="btn-normal" href="javascript:;" name="enable" onclick="fnModeSubmit('enable','',''); return false;">enable</a>
+          <a class="btn-normal" href="javascript:;" name="enable" onclick="fnSetFormValue('plugin_id', '<!--{$plugins[data].plugin_id}-->'); fnModeSubmit('enable','plugin_code','<!--{$plugins[data].plugin_code}-->'); return false;">enable</a><br />
           <!--{/if}-->
-           <a class="btn-normal" href="javascript:;" name="uninstall" onclick="fnModeSubmit('uninstall','',''); return false;">uninstall</a>
+          <a class="btn-normal" href="javascript:;" name="uninstall" onclick="fnSetFormValue('plugin_id', '<!--{$plugins[data].plugin_id}-->'); fnModeSubmit('uninstall','plugin_code','<!--{$plugins[data].plugin_code}-->'); return false;">uninstall</a>
         <!--{/if}-->
       </td>
-      
-      <td>
-      <!--{if $plugins[data].create_date != null && $plugins[data].enable == 1}-->
-        <input type="button" name="preference" value="preference" onclick="" />
-        <!--{/if}-->
+      <td class="center">
+        <!--{if $plugins[data].plugin_setting_path != ''}-->
+        <a href="?" onclick="win03('<!--{$plugins[data].plugin_setting_path}-->','plugin_setting','620','760'); return false;">設定</a>
+        <!--{else}-->-<!--{/if}-->
       </td>
       
     </tr>
-    <!--▲メンバー<!--{$smarty.section.data.iteration}-->-->
     <!--{/section}-->
   </table>
-
-  <div class="paging">
-    <!--▼ページ送り-->
-    <!--{$tpl_strnavi}-->
-    <!--▲ページ送り-->
-  </div>
+  <!--{else}-->
+  登録されているプラグインはありません。
+  <!--{/if}-->
 
 </div>
