public static function get($key) { if (static::$config === null) { include APP_ROOT . static::CONFIG_FILE; static::$config = $emlauncher_config[mfwServerEnv::getEnv()]; } return isset(static::$config[$key]) ? static::$config[$key] : null; }
function apache_log($key, $value) { static $log = array(); if (function_exists('apache_setenv')) { $log['env'] = mfwServerEnv::getEnv(); $log[$key] = $value; apache_setenv('LOGMSG', json_encode($log)); } }
protected function __construct() { include APP_ROOT . self::CONFIG_FILE; $this->title = isset($application_config['title']) ? $application_config['title'] : ''; $this->identifier = isset($application_config['identifier']) ? $application_config['identifier'] : ''; $i = str_replace(' ', '_', $this->identifier); $env = mfwServerEnv::getEnv(); $branch = basename(APP_ROOT); $this->cache_prefix = "{$i}_{$env}_{$branch}_"; }
/** * 環境を指定(設定読み込み). * 必ず最初に呼ぶ. * @return 成功なら$env, 失敗ならnull. */ public static function setEnv($env) { include APP_ROOT . self::CONFIG_FILE; self::$env = $env; if (isset($serverenv_config[$env])) { self::$config = $serverenv_config[$env]; } else { static::errorLog("undefined environment"); self::$config = null; } return self::$config; }
public static function getPDO($name = null) { if ($name === null) { $name = self::DEFAULT_DBNAME; } $env = mfwServerEnv::getEnv(); if (!isset(self::$con_pool[$env][$name])) { $conf = mfwServerEnv::databaseSetting($name); $pdo = new PDO($conf['dsn'], $conf['user'], $conf['pass'], array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8')); self::$con_pool[$env][$name] = $pdo; } return self::$con_pool[$env][$name]; }
/** * memcacheサーバに接続. * @return Memcache object. */ protected static function connect() { if (is_null(self::$mc)) { $conf = mfwServerEnv::memcache(); if (!$conf) { throw new Exception('memcache server undefined'); } $mc = new Memcache(); if ($mc->connect($conf['host'], $conf['port'])) { self::$mc = $mc; } else { error_log("cannot connect memcached ({$conf['host']}:{$conf['port']})"); } } return self::$mc; }
protected static function initialize_curl($url, $headers, $timeout) { $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); if (!empty($headers)) { curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); } if ($timeout) { curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); } $proxy = mfwServerEnv::httpProxy(); if ($proxy) { curl_setopt($curl, CURLOPT_PROXY, $proxy['host']); curl_setopt($curl, CURLOPT_PROXYPORT, $proxy['port']); } return $curl; }
/** * コマンド実行. * @param string $command 'swf2xml' or 'xml2swf' * @param string $data SWF or XML datastream * @param bool $cp932 内部文字コード=shift_jis * @return XML or SWF datastream */ protected function execCommand($command, $data, $cp932) { $swfmill = mfwServerEnv::swfmill(); if (!$swfmill) { throw new RuntimeException('no swfmill command in serverenv_config'); } $opt = $cp932 ? '-e cp932' : ''; $cmd = "{$swfmill} {$opt} {$command} stdin stdout"; $desc = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')); $process = proc_open($cmd, $desc, $pipes); fwrite($pipes[0], $data); fclose($pipes[0]); $ret = stream_get_contents($pipes[1]); fclose($pipes[1]); $err = stream_get_contents($pipes[2]); fclose($pipes[2]); proc_close($process); if ($err) { error_log($err); } return $ret; }
<?php require_once __DIR__ . '/../initialize.php'; require_once APP_ROOT . '/mainmodules/MainModules.php'; try { mfwServerEnv::setEnv($_SERVER['MFW_ENV']); list($headers, $content) = MainModules::execute(); foreach ($headers as $h) { header($h); } echo $content; } catch (Exception $e) { header(mfwActions::HTTP_500_INTERNALSERVERERROR); echo "<h1>500 Internal Server Error</h1>\n"; echo $e->getMessage(); }
<?php require_once dirname(__FILE__) . '/../mfw/initialize.php'; require_once APP_ROOT . '/core/vendor/optionparse.php'; require_once APP_ROOT . '/model/Repository.php'; require_once APP_ROOT . '/model/Filter.php'; require_once APP_ROOT . '/model/PullRequest.php'; require_once APP_ROOT . '/model/PullRequestAlert.php'; mfwServerEnv::setEnv('metahub_vm'); $owner = trim(file_get_contents(APP_ROOT . '/../apiauth/github_project_owner')); // oauth2 access token. $token = trim(file_get_contents(dirname(__FILE__) . '/../apiauth/github_accesstoken')); $parser = new Optionparse(array('description' => 'scan pullrequests', 'arguments' => '[repository ...]')); $parser->addOption('help', array('short_name' => '-h', 'long_name' => '--help', 'description' => 'show this help message')); $options = $parser->parse(); if ($options['help']) { $parser->displayUsage(); exit(0); } /*---------------------------------------------------------------------------- * repository一覧 */ if (!empty($options['_arguments_'])) { $repolist = RepositoryDb::selectSetByNames($options['_arguments_']); } else { $repolist = RepositoryDb::selectAll(); } if (empty($repolist)) { echo "no repository\n"; exit(-1); }
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <title><?php echo isset($page_title) ? htmlspecialchars($page_title) . ' | ' : ''; echo $title_prefix; ?> EMLauncher</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <?php if (mfwServerEnv::getEnv() === 'local') { ?> <link href="/bootstrap/bootswatch/spacelab/bootstrap.min.css" rel="stylesheet" media="screen"> <script src="/jquery/jquery.js"></script> <script src="/bootstrap/3.0.0/js/bootstrap.min.js"></script> <link href="/font-awesome/4.0.1/css/font-awesome.min.css" rel="stylesheet"> <?php } else { ?> <link href="//netdna.bootstrapcdn.com/bootswatch/3.0.0/spacelab/bootstrap.min.css" rel="stylesheet" media="screen"> <script src="//code.jquery.com/jquery.js"></script> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.1/css/font-awesome.min.css" rel="stylesheet"> <?php } ?> <link rel="stylesheet" href="<?php echo url('/css/customize.css'); ?> " type="text/css">