2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WindowsAzure用NetCommons2のinstall.inc.php

Posted at

BASE_DIR, BASE_URL, DB設定不要でWindowsAzureのWebサイトにリンクされたClearDBのMySQLに接続できる設定ファイルになります。

webapp/config/へアップして使ってください。

<?php
/**
 * インストール時configファイル
 *
 * @package     NetCommons.component
 * @author      Noriko Arai,Ryuji Masukawa
 * @copyright   2006-2007 NetCommons Project
 * @license     http://www.netcommons.org/license.txt  NetCommons License
 * @project     NetCommons Project, supported by National Institute of Informatics
 * @access      public
 */
 
// ------------------------------------------
// 設定ファイルのパス(固定:変更不可)
// ------------------------------------------
define('INSTALL_INC_DIR', transPathSeparator(dirname(__FILE__)));
 
// ----------------------------
// ベースのURL値
// ----------------------------
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']!='off') {
    $protocol = 'https://';
}else{
    $protocol = 'http://';
}
$url = $protocol . $_SERVER['HTTP_HOST'];
// AzureSubDirectoryCheck
$NCRootPath = dirname(dirname(dirname(__FILE__)));
$subPath = substr($NCRootPath, strpos($NCRootPath, 'wwwroot') + 7);
if($subPath){
    $subPath = str_replace(DIRECTORY_SEPARATOR, '/', $subPath);
    $url .= $subPath;
}

define('BASE_URL', $url);
// -------------------------------------------------
// ベースのURL値(ソースがあるCoreのNetCommonsのURL)
// 基本:BASE_URLと同じ
// -------------------------------------------------
define('CORE_BASE_URL', BASE_URL);
// ----------------------------
// NetCommonsのBaseディレクトリの設定
// ソース格納場所
// ----------------------------
if(!defined("BASE_DIR")) {
	define('BASE_DIR', dirname(START_INDEX_DIR));
}



// ----------------------------
// NetCommonsのHTDOCSディレクトリの設定
// 画像ファイル、CSSファイル格納場所
// デフォルト(START_INDEX_DIR)
// ----------------------------
define('HTDOCS_DIR', START_INDEX_DIR);

// ----------------------------
// テーマ用ディレクトリ
// デフォルト(BASE_DIR."/webapp/style)
// ----------------------------
define('STYLE_DIR', BASE_DIR . '/webapp/style');

// ----------------------------
// ファイルアップロード関連のディレクトリ設定
// (注意)ディレクトリ指定での最後に「/」をつけること
// デフォルト(BASE_DIR  . '/webapp/uploads/')
// ----------------------------
define('FILEUPLOADS_DIR', dirname(INSTALL_INC_DIR) . '/uploads/');

// ----------------------------
// データベース用設定値
// ----------------------------
// azure clearDB
$keys = array_keys($_SERVER);
$keyNameArray = preg_grep('/MYSQLCONNSTR/', $keys);
if(count($keyNameArray) > 0){
    $keyName = array_shift($keyNameArray);
    $dbString = $_SERVER[$keyName];

    $vars = explode(';', $dbString);
    $params = array();
    foreach ($vars as $value) {
        list($paramName,$paramValue) = explode('=', $value);
        $params[$paramName] = $paramValue;
    }

    $dbDns = sprintf('mysql://%s:%s@%s/%s',
        $params['User Id'],
        $params['Password'],
        $params['Data Source'],
        $params['Database']
        );
    define('DATABASE_DSN', $dbDns);

}else{
    define('DATABASE_DSN', 'mysql://user:pass@dbhost/dbname');
}
    define('DATABASE_PREFIX', 'netcommons2_');
    define('DATABASE_PCONNECT', 0);
    define('DATABASE_CHARSET',  'utf8');    


require_once BASE_DIR . "/webapp/config/maple.inc.php";
require_once BASE_DIR . "/webapp/config/define.inc.php";
?>
2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?