function lfInitWebParam($objWebParam)
{
    global $objDb;
    if (defined('HTTP_URL')) {
        $normal_url = HTTP_URL;
    } else {
        $dir = preg_replace('|install/.*$|', '', $_SERVER['REQUEST_URI']);
        $normal_url = 'http://' . $_SERVER['HTTP_HOST'] . $dir;
    }
    if (defined('HTTPS_URL')) {
        $secure_url = HTTPS_URL;
    } else {
        $dir = preg_replace('|install/.*$|', '', $_SERVER['REQUEST_URI']);
        $secure_url = 'http://' . $_SERVER['HTTP_HOST'] . $dir;
    }
    // 店名、管理者メールアドレスを取得する。(再インストール時)
    if (defined('DEFAULT_DSN')) {
        $dsn = array('phptype' => DB_TYPE, 'username' => DB_USER, 'password' => DB_PASSWORD, 'protocol' => 'tcp', 'hostspec' => DB_SERVER, 'port' => DB_PORT, 'database' => DB_NAME);
        $objQuery = new SC_Query($dsn);
        $tables = $objQuery->listTables();
        if (!PEAR::isError($tables) && in_array('dtb_baseinfo', $tables)) {
            $arrRet = $objQuery->select('shop_name, email01', 'dtb_baseinfo');
            $shop_name = $arrRet[0]['shop_name'];
            $admin_mail = $arrRet[0]['email01'];
        }
    }
    // 管理機能のディレクトリ名を取得(再インストール時)
    $oldAdminDir = SC_Utils_Ex::sfTrimURL(ADMIN_DIR);
    if (defined('ADMIN_FORCE_SSL')) {
        $admin_force_ssl = ADMIN_FORCE_SSL;
    } else {
        $admin_force_ssl = '';
    }
    if (defined('ADMIN_ALLOW_HOSTS')) {
        $arrAllowHosts = unserialize(ADMIN_ALLOW_HOSTS);
        $admin_allow_hosts = '';
        foreach ($arrAllowHosts as $val) {
            $admin_allow_hosts .= $val . "\n";
        }
    } else {
        $admin_allow_hosts = '';
    }
    if (defined('MAIL_BACKEND')) {
        $mail_backend = MAIL_BACKEND;
    } else {
        $mail_backend = 'mail';
    }
    if (defined('SMTP_HOST')) {
        $smtp_host = SMTP_HOST;
    }
    if (defined('SMTP_PORT')) {
        $smtp_port = SMTP_PORT;
    }
    if (defined('SMTP_USER')) {
        $smtp_user = SMTP_USER;
    }
    if (defined('SMTP_PASSWORD')) {
        $smtp_password = SMTP_PASSWORD;
    }
    $objWebParam->addParam('店名', 'shop_name', MTEXT_LEN, '', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'), $shop_name);
    $objWebParam->addParam('管理者:メールアドレス', 'admin_mail', null, '', array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK'), $admin_mail);
    $objWebParam->addParam('管理者:ログインID', 'login_id', ID_MAX_LEN, '', array('EXIST_CHECK', 'SPTAB_CHECK', 'ALNUM_CHECK'));
    $objWebParam->addParam('管理者:パスワード', 'login_pass', ID_MAX_LEN, '', array('EXIST_CHECK', 'SPTAB_CHECK', 'ALNUM_CHECK'));
    $objWebParam->addParam('管理機能:ディレクトリ', 'admin_dir', ID_MAX_LEN, 'a', array('EXIST_CHECK', 'SPTAB_CHECK', 'ALNUM_CHECK'), $oldAdminDir);
    $objWebParam->addParam('管理機能:SSL制限', 'admin_force_ssl', 1, 'n', array('SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'), $admin_force_ssl);
    $objWebParam->addParam('管理機能:IP制限', 'admin_allow_hosts', LTEXT_LEN, 'an', array('IP_CHECK', 'MAX_LENGTH_CHECK'), $admin_allow_hosts);
    $objWebParam->addParam('URL(通常)', 'normal_url', MTEXT_LEN, '', array('EXIST_CHECK', 'URL_CHECK', 'MAX_LENGTH_CHECK'), $normal_url);
    $objWebParam->addParam('URL(セキュア)', 'secure_url', MTEXT_LEN, '', array('EXIST_CHECK', 'URL_CHECK', 'MAX_LENGTH_CHECK'), $secure_url);
    $objWebParam->addParam('ドメイン', 'domain', MTEXT_LEN, '', array('MAX_LENGTH_CHECK'));
    $objWebParam->addParam('メーラーバックエンド', 'mail_backend', STEXT_LEN, 'a', array('MAX_LENGTH_CHECK', 'EXIST_CHECK'), $mail_backend);
    $objWebParam->addParam('SMTPホスト', 'smtp_host', STEXT_LEN, 'a', array('MAX_LENGTH_CHECK'), $smtp_host);
    $objWebParam->addParam('SMTPポート', 'smtp_port', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), $smtp_port);
    $objWebParam->addParam('SMTPユーザー', 'smtp_user', STEXT_LEN, 'a', array('MAX_LENGTH_CHECK'), $smtp_user);
    $objWebParam->addParam('SMTPパスワード', 'smtp_password', STEXT_LEN, 'a', array('MAX_LENGTH_CHECK'), $smtp_password);
    return $objWebParam;
}
 /**
  * CSVファイルからインサート実行.
  *
  * @param  SC_Query $objQuery
  * @param  string $dir
  * @param  string $mode
  * @return boolean
  */
 public function lfExeInsertSQL(&$objQuery, $dir, $mode)
 {
     $tbl_flg = false;
     $col_flg = false;
     $ret = true;
     $pagelayout_flg = false;
     $arrVal = array();
     $arrCol = array();
     $arrAllTableList = $objQuery->listTables();
     $objDir = dir($dir);
     while (false !== ($file_name = $objDir->read())) {
         if (!preg_match('/^((dtb|mtb|plg)_(\\w+))\\.csv$/', $file_name, $matches)) {
             continue;
         }
         $file_path = $dir . $file_name;
         $table = $matches[1];
         // テーブル存在チェック
         if (!in_array($table, $arrAllTableList)) {
             if ($mode === 'restore_config') {
                 continue;
             }
             return false;
         }
         // csvファイルからデータの取得
         $fp = fopen($file_path, 'r');
         if ($fp === false) {
             trigger_error($file_name . ' のファイルオープンに失敗しました。', E_USER_ERROR);
         }
         GC_Utils_Ex::gfPrintLog('リストア実行: ' . $table);
         $objQuery->delete($table);
         $line = 0;
         $arrColName = array();
         while (!feof($fp)) {
             $line++;
             $arrCsvLine = fgetcsv($fp, 1024 * 1024);
             // 1行目: 列名
             if ($line === 1) {
                 $arrColName = $arrCsvLine;
                 continue;
             }
             // 空行を無視
             // false との比較は PHP 5.2.x Windows バグ対応
             // 参考: http://www.php.net/manual/ja/function.fgetcsv.php#98502
             if ($arrCsvLine === array(null) || $arrCsvLine === false) {
                 continue;
             }
             $arrVal = array_combine($arrColName, $arrCsvLine);
             $objQuery->insert($table, $arrVal);
             SC_Utils_Ex::extendTimeOut();
         }
         fclose($fp);
     }
     return $ret;
 }
Exemplo n.º 3
0
function lfInitWebParam($objWebParam)
{
    global $objDb;
    if (defined('HTTP_URL')) {
        $normal_url = HTTP_URL;
    } else {
        $dir = ereg_replace("install/.*\$", "", $_SERVER['REQUEST_URI']);
        $normal_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
    }
    if (defined('HTTPS_URL')) {
        $secure_url = HTTPS_URL;
    } else {
        $dir = ereg_replace("install/.*\$", "", $_SERVER['REQUEST_URI']);
        $secure_url = "http://" . $_SERVER['HTTP_HOST'] . $dir;
    }
    // 店名、管理者メールアドレスを取得する。(再インストール時)
    if (defined('DEFAULT_DSN')) {
        $objQuery = new SC_Query();
        $tables = $objQuery->listTables();
        if (!PEAR::isError($tables) && in_array("dtb_baseinfo", $tables)) {
            $arrRet = $objQuery->select("shop_name, email01", "dtb_baseinfo");
            $shop_name = $arrRet[0]['shop_name'];
            $admin_mail = $arrRet[0]['email01'];
        }
    }
    // 管理機能のディレクトリ名を取得(再インストール時)
    $oldAdminDir = SC_Utils_Ex::sfTrimURL(ADMIN_DIR);
    if (defined('ADMIN_FORCE_SSL')) {
        $admin_force_ssl = ADMIN_FORCE_SSL;
    } else {
        $admin_force_ssl = '';
    }
    if (defined('ADMIN_ALLOW_HOSTS')) {
        $arrAllowHosts = unserialize(ADMIN_ALLOW_HOSTS);
        $admin_allow_hosts = '';
        foreach ($arrAllowHosts as $val) {
            $admin_allow_hosts .= $val . "\n";
        }
    } else {
        $admin_allow_hosts = '';
    }
    $objWebParam->addParam("店名", "shop_name", MTEXT_LEN, "", array("EXIST_CHECK", "MAX_LENGTH_CHECK"), $shop_name);
    $objWebParam->addParam("管理者:メールアドレス", "admin_mail", null, "", array("EXIST_CHECK", "EMAIL_CHECK", "EMAIL_CHAR_CHECK"), $admin_mail);
    $objWebParam->addParam("管理者:ログインID", "login_id", ID_MAX_LEN, "", array("EXIST_CHECK", "SPTAB_CHECK", "ALNUM_CHECK"));
    $objWebParam->addParam("管理者:パスワード", "login_pass", ID_MAX_LEN, "", array("EXIST_CHECK", "SPTAB_CHECK", "ALNUM_CHECK"));
    $objWebParam->addParam("管理機能:ディレクトリ", "admin_dir", ID_MAX_LEN, "a", array("EXIST_CHECK", "SPTAB_CHECK", "ALNUM_CHECK"), $oldAdminDir);
    $objWebParam->addParam("管理機能:SSL制限", "admin_force_ssl", 1, "n", array("SPTAB_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"), $admin_force_ssl);
    $objWebParam->addParam("管理機能:IP制限", "admin_allow_hosts", LTEXT_LEN, "an", array("IP_CHECK", "MAX_LENGTH_CHECK"), $admin_allow_hosts);
    $objWebParam->addParam("URL(通常)", "normal_url", MTEXT_LEN, "", array("EXIST_CHECK", "URL_CHECK", "MAX_LENGTH_CHECK"), $normal_url);
    $objWebParam->addParam("URL(セキュア)", "secure_url", MTEXT_LEN, "", array("EXIST_CHECK", "URL_CHECK", "MAX_LENGTH_CHECK"), $secure_url);
    $objWebParam->addParam("ドメイン", "domain", MTEXT_LEN, "", array("MAX_LENGTH_CHECK"));
    return $objWebParam;
}