forked from typecho-fans/plugins
-
Notifications
You must be signed in to change notification settings - Fork 26
/
panel.php
71 lines (65 loc) · 2.45 KB
/
panel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) {
exit;
}
$success = true;
try {
$dbConfig = $options->plugin('EmlogToTypecho');
/** 初始化一个db */
if (Typecho_Db_Adapter_Mysql::isAvailable()) {
$emlogDb = new Typecho_Db('Mysql', $dbConfig->prefix);
} else {
$emlogDb = new Typecho_Db('Pdo_Mysql', $dbConfig->prefix);
}
/** 只读即可 */
$emlogDb->addServer(array(
'host' => $dbConfig->host,
'user' => $dbConfig->user,
'password' => $dbConfig->password,
'charset' => 'utf8',
'port' => $dbConfig->port,
'database' => $dbConfig->database
), Typecho_Db::READ);
$rows = $emlogDb->fetchAll($emlogDb->select()->from('table.options'));
$static = array();
foreach ($rows as $row) {
$static[$row['option_name']] = $row['option_value'];
}
} catch (Typecho_Db_Exception $e) {
$success = false;
}
include 'header.php';
include 'menu.php';
?>
<div class="main">
<div class="body container">
<?php include 'page-title.php'; ?>
<div class="row typecho-page-main" role="form">
<div class="col-mb-12 col-tb-8 col-tb-offset-2">
<?php if ($success): ?>
<div class="message notice">
<form action="<?php $options->index('/action/emlog-to-typecho'); ?>" method="post">
<?php _e('我们检测到了 Emlog 系统信息, 点击下方的按钮开始数据转换, 数据转换可能会耗时较长.'); ?>
<ul>
<li><strong><?php echo $static['blogname']; ?></strong></li>
<li><?php echo $static['bloginfo']; ?></li>
<li><code><?php echo $static['blogurl']; ?></code></li>
</ul>
<button type="submit" class="btn primary"><?php _e('开始数据转换 »'); ?></button>
</form>
</div>
<?php else: ?>
<div class="message error">
<?php _e('我们在连接到 Emlog 的数据库时发生了错误, 请<a href="%s">重新设置</a>你的信息.',
Typecho_Common::url('options-plugin.php?config=EmlogToTypecho', $options->adminUrl)); ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php
include 'copyright.php';
include 'common-js.php';
include 'footer.php';
?>