Skip to content

Instantly share code, notes, and snippets.

@RyujiAMANO
Last active December 27, 2015 08:38
Show Gist options
  • Save RyujiAMANO/7297323 to your computer and use it in GitHub Desktop.
Save RyujiAMANO/7297323 to your computer and use it in GitHub Desktop.
WindowsAzure用NetCommons2のinstall.inc.php ref: http://qiita.com/RyujiAMANO/items/6b267765e61300d3a2c9
<?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";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment