Skip to content

Commit

Permalink
修正由于GAE的MySQL连接参数变化导致的安装失败问题
Browse files Browse the repository at this point in the history
  • Loading branch information
KimiChen committed Apr 24, 2014
1 parent d9ee03d commit 10d23e0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,8 @@ function _u() {

/** 初始用户 */
$password = empty($config['userPassword']) ? substr(uniqid(), 7) : $config['userPassword'];
$hasher = new PasswordHash(8, true);

$installDb->query($installDb->insert('table.users')->rows(array('name' => $config['userName'], 'password' => $hasher->HashPassword($password), 'mail' => $config['userMail'],
$installDb->query($installDb->insert('table.users')->rows(array('name' => $config['userName'], 'password' => Typecho_Common::hash($password), 'mail' => $config['userMail'],
'url' => 'http://www.typecho.org', 'screenName' => $config['userName'], 'group' => 'administrator', 'created' => Typecho_Date::gmtTime())));

unset($_SESSION['typecho']);
Expand Down Expand Up @@ -472,6 +471,7 @@ function _u() {
}

$config = str_replace($replace, array_values($dbConfig), _r('config'));
$dbConfig['dsn'] = str_replace($replace, array_values($dbConfig), $dbConfig['dsn']);
}

if (!isset($config) && $success && !_r('created')) {
Expand Down
23 changes: 17 additions & 6 deletions install/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,20 @@
<?php elseif ('GAE' == $engine): ?>
<!-- GAE -->
<h3 class="warning"><?php _e('系统将为您自动匹配 %s 环境的安装选项', 'GAE'); ?></h3>
<?php if (0 === strpos($adapter, 'Pdo_')): ?>
<li>
<label class="typecho-label" for="dbHost"><?php _e('数据库实例名'); ?></label>
<input type="text" class="text" name="dbHost" id="dbHost" value="<?php _v('dbHost'); ?>"/>
<p class="description"><?php _e('请填入您在Cloud SQL面板中创建的数据库实例名称,示例:<em class="warning">/cloudsql/typecho-gae:typecho</em>'); ?></p>
</li>
<?php else: ?>
<li>
<label class="typecho-label" for="dbPort"><?php _e('数据库实例名'); ?></label>
<input type="text" class="text" name="dbPort" id="dbPort" value="<?php _v('dbPort'); ?>"/>
<p class="description"><?php _e('请填入您在Cloud SQL面板中创建的数据库实例名称'); ?></p>
<label class="typecho-label" for="dbHost"><?php _e('数据库实例名'); ?></label>
<input type="text" class="text" name="dbHost" id="dbHost" value="<?php _v('dbHost'); ?>"/>
<p class="description"><?php _e('请填入您在Cloud SQL面板中创建的数据库实例名称,示例:<em class="warning">:/cloudsql/typecho-gae:typecho</em>'); ?></p>
</li>
<?php endif; ?>

<li>
<label class="typecho-label" for="dbUser"><?php _e('数据库用户名'); ?></label>
<input type="text" class="text" name="dbUser" id="dbUser" value="<?php _v('dbUser'); ?>" />
Expand All @@ -119,20 +128,22 @@
</li>

<?php if (0 === strpos($adapter, 'Pdo_')): ?>
<input type="hidden" name="dbDsn" value="mysql:dbname={database};unix_socket={host};charset=<?php _e('utf8'); ?>" />
<input type="hidden" name="config" value="array (
'dsn' => 'mysql:dbname={database};unix_socket=/cloudsql/{host}:{port};charset=<?php _e('utf8'); ?>',
'dsn' => 'mysql:dbname={database};unix_socket={host};charset=<?php _e('utf8'); ?>',
'user' => '{user}',
'password' => '{password}'
)" />
<?php else: ?>
<input type="hidden" name="config" value="array (
'host' => ':/cloudsql/{host}:{port}',
'host' => '{host}',
'database' => '{database}',
'user' => '{user}',
'password' => '{password}'
)" />
<?php endif; ?>
<input type="hidden" name="dbHost" value="<?php echo $_SERVER['APPLICATION_ID'] ?>" />


<?php else: ?>
<li>
<label class="typecho-label" for="dbHost"><?php _e('数据库地址'); ?></label>
Expand Down

0 comments on commit 10d23e0

Please sign in to comment.