Skip to content

Commit

Permalink
fix : in china download Composer FAILED
Browse files Browse the repository at this point in the history
doc : update config.simple default help doc
  • Loading branch information
sendya committed Aug 17, 2016
1 parent 4d49e9c commit 5d23d26
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
7 changes: 7 additions & 0 deletions Data/Config.simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

/**
* Site Name
* 网站名称
* 模板 LOGO 若是图制,则需自行修改图片
* 其余所有页面展示名称皆为此配置项内容
*/
define('SITE_NAME', 'SS Cat');

Expand Down Expand Up @@ -67,6 +70,10 @@

/**
* Database Connection:
* 请修改此处配置:
* dbname 数据库名称
* host 数据库连接IP地址
* 最后两项 root password 替换成你的数据库 用户 与 密码
*/
Core\Database::initialize('mysql:dbname=sspanel;host=localhost;port=3306;charset=UTF8', 'root', 'password');

Expand Down
46 changes: 29 additions & 17 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,25 @@ function colorize($text, $status) {
return chr(27) . "$out" . "$text" . chr(27) . "[0m";
}

function download_composer($url) {
echo 'Downloading composer...';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$binary = curl_exec($ch);
if (curl_errno($ch)) {
echo colorize('FAILED!' . PHP_EOL . curl_error($ch), 'FAILURE');
curl_close($ch);
return false;
}
$fp = fopen(ROOT_PATH . 'composer.phar', 'wb');
fputs($fp, $binary);
fclose($fp);
curl_close($ch);
echo 'Done!' . PHP_EOL;
}

function print_arr($arr) {
foreach($arr as $ret) {
echo $ret . PHP_EOL;
Expand All @@ -125,22 +144,9 @@ function print_arr($arr) {
switch ($argv[1]) {
case 'install':
if (!file_exists(ROOT_PATH . 'composer.phar')) {
echo 'Downloading composer...';
$ch = curl_init("http://getcomposer.org/composer.phar");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$binary = curl_exec($ch);
if (curl_errno($ch)) {
echo colorize('FAILED!' . PHP_EOL . curl_error($ch), 'FAILURE');
curl_close($ch);
break;
if (download_composer("http://getcomposer.org/composer.phar") === false) {
download_composer("http://static.loacg.com/soft/composer.phar");
}
$fp = fopen(ROOT_PATH . 'composer.phar', 'wb');
fputs($fp, $binary);
fclose($fp);
curl_close($ch);
echo 'Done!' . PHP_EOL;
}
exec(PHP_BINARY . ' ' . ROOT_PATH . 'composer.phar -V', $return_arr);
print_arr($return_arr);
Expand All @@ -161,7 +167,7 @@ function print_arr($arr) {
echo colorize('It seems composer failed to install package', 'FAILURE') . PHP_EOL;
break;
}
echo 'Now reloading packages and config...';
echo 'Now reloading packages and config...'. PHP_EOL;
$configFile = DATA_PATH . 'Config.php';
if (!file_exists($configFile)) {
echo 'Config Unknown... copying..' . PHP_EOL;
Expand All @@ -171,7 +177,13 @@ function print_arr($arr) {
}

@include ROOT_PATH . 'Package/autoload.php';
@include DATA_PATH . 'Config.php';
try {
@include DATA_PATH . 'Config.php';
} catch (PDOException $e) {
echo colorize('Database not available! Please modify ./Data/Config.php and try again', 'WARNING') . PHP_EOL;
break;
}

if (Option::getConfig('ENCRYPT_KEY') == 'Please generate key and paste here') {
Option::setConfig('ENCRYPT_KEY', Option::createKey());
}
Expand Down

0 comments on commit 5d23d26

Please sign in to comment.