diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ead6d4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/data +/install.php \ No newline at end of file diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..76849a4 --- /dev/null +++ b/.htaccess @@ -0,0 +1,8 @@ + +RewriteEngine On +RewriteBase / +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ /index.php/$1 [L] + + \ No newline at end of file diff --git a/README.md b/README.md index e65ef63..72b6d1b 100755 --- a/README.md +++ b/README.md @@ -1,56 +1,93 @@ -介绍 -==== +# MiniCMS -MiniCMS是一个针对个人网站设计的微型内容管理系统。它的特点是: +## 项目介绍 -1. 不需要数据库在支持,只需要一个可以运行PHP的Web环境 +MiniCMS是一个针对个人网站设计的微型内容管理系统。 + +主要特点: + +1. 不需要数据库支持,只需要一个可以运行 PHP 的 Web 环境 2. 只针对个人网站设计,没有复杂的成员管理和权限设置 3. 没有分类只有标签,免除发布文章时到底该怎么分类的纠结 -4. 只有“文章”和“页面”两该个系统,没有“评论”、“插件”、“主题”,让你更专注于创造内容 +4. 只有“文章”和“页面”两个系统,没有“评论”、“插件”,让你更专注于创造内容 +5. 其他功能:网站基本信息、状态、主题、URL 类型、ICP 备案号、账号和密码等可在后台配置 -安装 -==== +## 安装 -1. 下载最新版的install.php,上传到网站根目录 -2. 浏览器访问根目录下instal.php,填入网站信息和初始账号密码 +1. 下载最新版的 install.php,上传到网站根目录 +2. 浏览器访问根目录下 instal.php,填入网站信息和初始账号密码 3. 开始安装 -结构 -==== +## 文件结构 ``` -mc-admin 后台 -mc-files 内容 - |--theme 主题 +index.php 入口文件 +admin 后台管理 +core 核心 +theme 主题 +data 内容数据 + |--config.php 配置文件 |--posts 文章 | |--data 数据 | |--index 索引 |--pages 页面 |--data 数据 |--index 索引 +.htaccess Apache rewrite 配置文件 +nginx.conf Nginx rewrite 配置 +``` + +## URL 格式 + +默认 query 模式 + +文章: `http://example.com/?post/[a-z0-9]{6}` + +标签: `http://example.com/?tag/[^/]+` + +日期: `http://example.com/?date/([0-9]{4}-[0-9]{2}` + +页面: `http://example.com/?([-a-zA-Z0-9]+)+` + +可选 history 模式,需要服务器支持开启路径重写 + +文章: `http://example.com/post/[a-z0-9]{6}` + +标签: `http://example.com/tag/[^/]+` + +日期: `http://example.com/date/([0-9]{4}-[0-9]{2}` + +页面: `http://example.com/([-a-zA-Z0-9]+)+` + +## 模板标签 + ``` - -URL格式 -======= +app_site_name() // 网站标题 +app_site_desc() // 网站描述 +app_nick_name() // 站长昵称 + +app_theme_url() // 主题文件夹中文件的URL -文章: http://1234n.com/?post/[a-z0-5]{6} -标签: http://1234n.com/?tag/[^/]+/ -页面: http://1234n.com/?([-a-zA-Z0-5]+/)+ - -模板标签 -======= +app_next_post() // 循环获取文章 +app_post_title() // 文章标题 +app_post_link() // 文章标题A链接 +app_post_content() // 文章内容 +app_post_url() // 文章URL +app_post_date() // 文章发布日期 +app_post_time() // 文章发布时间 +app_post_tags() // 文章标签 +app_comment_code()// 文章评论代码 +app_footer_code() // 网页底部代码 ``` -mc_site_name() // 网站标题 -mc_site_desc() // 网站描述 -mc_user_nick() // 站长昵称 - -mc_theme_url() // 主题文件夹中文件的URL - -mc_next_post() // 循环获取文章 -mc_the_name() // 文章标题 -mc_the_date() // 发布日期 -mc_the_time() // 发布时间 -mc_the_content() // 文章内容 -mc_the_tags() // 文章标签 + +## 打包发布 + +打包安装包文件 install.php 的构建命令 + +```shell +# 使用 php 命令执行 +php build.php [指定版本号] +# 示例 +php build.php 1.2.5 ``` diff --git a/admin/common.php b/admin/common.php new file mode 100644 index 0000000..97ba008 --- /dev/null +++ b/admin/common.php @@ -0,0 +1,57 @@ +> 5; + } + $output[] = $out; + } + return $output; +} + +function post_sort($a, $b) +{ + $a_date = $a['date']; + $b_date = $b['date']; + + if ($a_date != $b_date) + return $a_date > $b_date ? -1 : 1; + + return $a['time'] > $b['time'] ? -1 : 1; +} diff --git a/mc-admin/editor.php b/admin/editor.php similarity index 100% rename from mc-admin/editor.php rename to admin/editor.php diff --git a/admin/foot.php b/admin/foot.php new file mode 100755 index 0000000..549358e --- /dev/null +++ b/admin/foot.php @@ -0,0 +1,7 @@ + + + + + diff --git a/admin/head.php b/admin/head.php new file mode 100755 index 0000000..0a21714 --- /dev/null +++ b/admin/head.php @@ -0,0 +1,50 @@ + + + + + + + MiniCMS + + + + + + + + + + +
+
\ No newline at end of file diff --git a/admin/index.php b/admin/index.php new file mode 100755 index 0000000..b3839d8 --- /dev/null +++ b/admin/index.php @@ -0,0 +1,56 @@ + + +
+
管理面板
+ + +
+ 前台: + 首页 + 存档 + 订阅 + 地图 +
+
+ 系统: + 设置 + 退出登录 +
+
+ +
+ 资源链接: + @Github + 官方网站 + 技术支持 +
+ + \ No newline at end of file diff --git a/admin/login.php b/admin/login.php new file mode 100755 index 0000000..8315585 --- /dev/null +++ b/admin/login.php @@ -0,0 +1,70 @@ + + + + + + <?php echo htmlspecialchars($app_config['site_name']); ?> - Powered by MiniCMS + + + + + + + + + + + diff --git a/admin/logout.php b/admin/logout.php new file mode 100755 index 0000000..8f219fa --- /dev/null +++ b/admin/logout.php @@ -0,0 +1,4 @@ +" + + unset($app_pages[$page_old_path]); + + file_put_contents( + $index_file, + "" ); } } - + $data = array( 'file' => $page_file, 'path' => $page_path, @@ -110,30 +110,31 @@ 'time' => $page_time, 'can_comment' => $page_can_comment, ); - - $index_file = '../mc-files/pages/index/'.$page_state.'.php'; - + + $index_file = PATH_ROOT . '/data/pages/index/' . $page_state . '.php'; + require $index_file; - - $mc_pages[$page_path] = $data; - ksort($mc_pages); - - file_put_contents($index_file, - "" + $app_pages[$page_path] = $data; + + ksort($app_pages); + + file_put_contents( + $index_file, + "" ); - + $data['content'] = $page_content; - + file_put_contents($file_path, serialize($data)); - + $succeed = true; } } else if (isset($_GET['file'])) { - $file_path = '../mc-files/pages/data/'.$_GET['file'].'.dat'; - + $file_path = PATH_ROOT . '/data/pages/data/' . $_GET['file'] . '.dat'; + $data = unserialize(file_get_contents($file_path)); - + $page_file = $data['file']; $page_path = $data['path']; $page_state = $data['state']; @@ -144,84 +145,97 @@ $page_can_comment = isset($data['can_comment']) ? $data['can_comment'] : '1'; } ?> + +
- + - -
页面已发布。 查看页面
- -
页面已保存到“草稿箱”。 打开草稿箱
- + +
页面已发布。 查看页面
+ +
页面已保存到“草稿箱”。 打开草稿箱
+
- +
- +
- +
- 时间: - - - - -   - : - : - + 时间: + - + - +   + : + : +
评论:
- - + +
- + \ No newline at end of file diff --git a/admin/page.php b/admin/page.php new file mode 100755 index 0000000..be0d856 --- /dev/null +++ b/admin/page.php @@ -0,0 +1,358 @@ +"); + + if ($state != 'delete') { + $index_file2 = PATH_ROOT . '/data/pages/index/delete.php'; + + require $index_file2; + + $app_pages[$id] = $page; + + file_put_contents($index_file2, ""); + } else { + unlink(PATH_ROOT . '/data/pages/data/' . $page['file'] . '.dat'); + } +} + +function revert_page($id) +{ + global $state, $index_file, $app_pages; + + $page = $app_pages[$id]; + + $prev_state = $page['prev_state']; + + unset($page['prev_state']); + + unset($app_pages[$id]); + + file_put_contents($index_file, ""); + + $index_file2 = PATH_ROOT . '/data/pages/index/' . $prev_state . '.php'; + + require $index_file2; + + $app_pages[$id] = $page; + + ksort($app_pages); + + file_put_contents($index_file2, ""); +} + +load_pages(); + +if (isset($_GET['delete']) || (isset($_GET['apply']) && $_GET['apply'] == 'delete')) { + if (isset($_GET['apply']) && $_GET['apply'] == 'delete') { + $ids = explode(',', $_GET['ids']); + foreach ($ids as $id) { + if (trim($id) == '') + continue; + delete_page($id); + load_pages(); + } + } else { + delete_page($_GET['delete']); + } + //load_posts(); + Header('Location:page.php?done=true&state=' . $state); + exit(); +} + +if (isset($_GET['revert']) || (isset($_GET['apply']) && $_GET['apply'] == 'revert')) { + if (isset($_GET['apply']) && $_GET['apply'] == 'revert') { + $ids = explode(',', $_GET['ids']); + foreach ($ids as $id) { + if (trim($id) == '') + continue; + revert_page($id); + load_pages(); + } + } else { + revert_page($_GET['revert']); + } + //load_posts(); + Header('Location:page.php?done=true&state=' . $state); + exit(); +} + +if (isset($_GET['done'])) { + $message = '操作成功'; +} + +$page_ids = array_keys($app_pages); +$page_count = count($page_ids); + +$date_array = array(); + +for ($i = $page_count - 1; $i >= 0; $i--) { + $page_id = $page_ids[$i]; + $page = $app_pages[$page_id]; + $date_array[] = substr($page['date'], 0, 7); +} + +$date_array = array_unique($date_array); + +if (isset($_GET['date'])) { + $filter_date = $_GET['date']; +} else { + $filter_date = ''; +} + +$app_pages2 = array(); + +for ($i = 0; $i < $page_count; $i++) { + $page_id = $page_ids[$i]; + $page = $app_pages[$page_id]; + + if ($filter_date != '' && strpos($page['date'], $filter_date) !== 0) + continue; + + $app_pages2[$page_id] = $page; +} + +$app_pages = $app_pages2; + +$page_ids = array_keys($app_pages); +$page_count = count($page_ids); + +$last_page = ceil($page_count / 10); + +if (isset($_GET['page'])) { + $page_num = $_GET['page']; +} else { + $page_num = 1; +} + +if ($page_num > 1) { + $prev_page = $page_num - 1; +} else { + $prev_page = 1; +} +if ($page_num < $last_page) { + $next_page = $page_num + 1; +} else { + $next_page = $last_page; +} +if ($page_num < $last_page) { + $next_page = $page_num + 1; +} else { + $next_page = $last_page; +} +if ($page_num < 0) { + $page_num = 1; +} else if ($page_num > $last_page) { + $page_num = $last_page; +} +?> + + + +
+ +
+ 页面管理 + 创建页面 +
+
+ 已发布 + 草稿箱 + 回收站 +
+
+ + + + + + + + + + 共 项   + « + + 第 页,共 页 + + » + + +
+
+ + + + + + + + + + + = ($page_num * 10)) continue; + $page_id = $page_ids[$i]; + $page = $app_pages[$page_id]; ?> + > + + + + + + + + + + + + + + + +
标题路径日期
+ +
+ 编辑 + + 还原 + 删除 + + 回收 + + 查看 +
+
/
标题路径日期
+
+
+ + + + + + 共 项   + « + + 第 页,共 页 + + » + + +
+ \ No newline at end of file diff --git a/mc-admin/post-edit.php b/admin/post-edit.php similarity index 82% rename from mc-admin/post-edit.php rename to admin/post-edit.php index 24abdd0..f69ffc1 100755 --- a/mc-admin/post-edit.php +++ b/admin/post-edit.php @@ -1,5 +1,7 @@ " + "" ); } } @@ -104,16 +106,16 @@ 'can_comment' => $post_can_comment, ); - $index_file = '../mc-files/posts/index/'.$post_state.'.php'; + $index_file = PATH_ROOT . '/data/posts/index/'.$post_state.'.php'; require $index_file; - $mc_posts[$post_id] = $data; + $app_posts[$post_id] = $data; - uasort($mc_posts, "post_sort"); + uasort($app_posts, "post_sort"); file_put_contents($index_file, - "" + "" ); $data['content'] = $post_content; @@ -123,7 +125,7 @@ $succeed = true; } } else if (isset($_GET['id'])) { - $file_path = '../mc-files/posts/data/'.$_GET['id'].'.dat'; + $file_path = PATH_ROOT . '/data/posts/data/'.$_GET['id'].'.dat'; $data = unserialize(file_get_contents($file_path)); @@ -137,41 +139,42 @@ $post_can_comment = isset($data['can_comment']) ? $data['can_comment'] : '1'; } ?> +
-
文章已发布。 查看文章
+
文章已发布。 查看文章
文章已保存到“草稿箱”。 打开草稿箱
- +
diff --git a/admin/post.php b/admin/post.php new file mode 100755 index 0000000..ef122ca --- /dev/null +++ b/admin/post.php @@ -0,0 +1,376 @@ +"); + + if ($state != 'delete') { + $index_file2 = PATH_ROOT . '/data/posts/index/delete.php'; + + require $index_file2; + + $app_posts[$id] = $post; + + file_put_contents($index_file2, ""); + } else { + unlink(PATH_ROOT . '/data/posts/data/' . $id . '.dat'); + } +} + +function revert_post($id) +{ + global $state, $index_file, $app_posts; + + $post = $app_posts[$id]; + + $prev_state = $post['prev_state']; + + unset($post['prev_state']); + + unset($app_posts[$id]); + + file_put_contents($index_file, ""); + + $index_file2 = PATH_ROOT . '/data/posts/index/' . $prev_state . '.php'; + + require $index_file2; + + $app_posts[$id] = $post; + + uasort($app_posts, "post_sort"); + + file_put_contents($index_file2, ""); +} + +load_posts(); + +if (isset($_GET['delete']) || (isset($_GET['apply']) && $_GET['apply'] == 'delete')) { + if (isset($_GET['apply']) && $_GET['apply'] == 'delete') { + $ids = explode(',', $_GET['ids']); + foreach ($ids as $id) { + if (trim($id) == '') + continue; + delete_post($id); + load_posts(); + } + } else { + delete_post($_GET['delete']); + } + //load_posts(); + Header('Location:post.php?done=true&state=' . $state); + exit(); +} + +if (isset($_GET['revert']) || (isset($_GET['apply']) && $_GET['apply'] == 'revert')) { + if (isset($_GET['apply']) && $_GET['apply'] == 'revert') { + $ids = explode(',', $_GET['ids']); + foreach ($ids as $id) { + if (trim($id) == '') + continue; + revert_post($id); + load_posts(); + } + } else { + revert_post($_GET['revert']); + } + //load_posts(); + Header('Location:post.php?done=true&state=' . $state); + exit(); +} + +if (isset($_GET['done'])) { + $message = '操作成功'; +} + +$post_ids = array_keys($app_posts); +$post_count = count($post_ids); + +$date_array = array(); +$tags_array = array(); + +for ($i = 0; $i < $post_count; $i++) { + $post_id = $post_ids[$i]; + $post = $app_posts[$post_id]; + $date_array[] = substr($post['date'], 0, 7); + $tags_array = array_merge($tags_array, $post['tags']); +} + +$date_array = array_unique($date_array); +$tags_array = array_unique($tags_array); + +if (isset($_GET['tag'])) + $filter_tag = $_GET['tag']; +else + $filter_tag = ''; + +if (isset($_GET['date'])) + $filter_date = $_GET['date']; +else + $filter_date = ''; + +$app_posts2 = array(); + +for ($i = 0; $i < $post_count; $i++) { + $post_id = $post_ids[$i]; + $post = $app_posts[$post_id]; + + if ($filter_tag != '' && !in_array($filter_tag, $post['tags'])) { + continue; + } + + if ($filter_date != '' && strpos($post['date'], $filter_date) !== 0) { + continue; + } + + $app_posts2[$post_id] = $post; +} + +$app_posts = $app_posts2; + +$post_ids = array_keys($app_posts); +$post_count = count($post_ids); + +$last_page = ceil($post_count / 10); + +if (isset($_GET['page'])) + $page_num = $_GET['page']; +else + $page_num = 1; + +if ($page_num > 1) + $prev_page = $page_num - 1; +else + $prev_page = 1; + +if ($page_num < $last_page) + $next_page = $page_num + 1; +else + $next_page = $last_page; + +if ($page_num < 0) + $page_num = 1; +else if ($page_num > $last_page) + $page_num = $last_page; +?> + + + +
+ +
文章管理撰写文章
+
+ 已发布 + 草稿箱 + 回收站 +
+
+ + + + + + + + + + + 共 项   + « + + 第 页,共 页 + + » + + +
+
+ + + + + + + + + + + = ($page_num * 10)) continue; + $post_id = $post_ids[$i]; + $post = $app_posts[$post_id]; ?> + > + + + + + + + + + + + + + + + +
标题标签日期
+ +
+ 编辑 + + 还原 + 删除 + + 回收 + + 查看 +
+
+ + + +
标题标签日期
+
+
+ + + + + + 共 项   + « + + 第 页,共 页 + + » + + +
+ \ No newline at end of file diff --git a/admin/settings.php b/admin/settings.php new file mode 100755 index 0000000..df0734e --- /dev/null +++ b/admin/settings.php @@ -0,0 +1,176 @@ +"; + + file_put_contents(PATH_ROOT . '/data/config.php', $code); + + if ($_POST['user_pass'] != '' || $user_name_changed) { + setcookie('token', md5($app_config['user_name'] . '_' . $app_config['user_pass'])); + } + + $display_info = true; +} + +$site_name = $app_config['site_name']; +$site_desc = $app_config['site_desc']; +$site_keywords = $app_config['site_keywords']; +$site_link = $app_config['site_link']; +$site_theme = $app_config['site_theme']; +$site_route = $app_config['site_route']; +$site_status = $app_config['site_status']; +$site_icpno = $app_config['site_icpno']; +$nick_name = $app_config['nick_name']; +$user_name = $app_config['user_name']; +$comment_code = isset($app_config['comment_code']) ? $app_config['comment_code'] : ''; +$footer_code = isset($app_config['footer_code']) ? $app_config['footer_code'] : ''; + +?> + + + +
设置保存成功!
+ +
站点设置
+
+
+
网站标题
+ +
起个好听的名字。
+
+
+
+
网站描述
+ +
用简洁的文字描述本站点。
+
+
+
+
网站关键词
+ +
用关键词描述本站点,请使用半角逗号,分隔。
+
+
+
+
网站地址
+ +
+
+
+
+
网站主题
+ +
+
+
+
+
链接形式
+ +
注意:路径模式需要服务端支持
+
+
+
+
网站状态
+ +
关闭网站时,前台显示关闭维护页面,所有页面不可看。
+
+
+
+
ICP备案号
+ +
+
+
+
+
站长昵称
+ +
+
+
+
+
管理员帐号
+ +
+
+
+
+
管理员密码
+ +
不修改请留空
+
+
+
+
确认密码
+ +
不修改请留空
+
+
+
+
评论代码
+ +
第三方评论服务所提供的评论代码,例如:Disqus新浪微博评论箱 等。设置此选项后,MiniCMS 就拥有了评论功能。
+
+
+
+
底部代码
+ +
网站底部代码:如统计代码、文本文案等。
+
+
+
+
+
+ +
+
+
+ + diff --git a/mc-admin/style.css b/admin/style.css similarity index 66% rename from mc-admin/style.css rename to admin/style.css index 7574376..bff46cc 100755 --- a/mc-admin/style.css +++ b/admin/style.css @@ -1,35 +1,39 @@ * { font-family:"Microsoft YaHei",Segoe UI,Tahoma,Arial,Verdana,sans-serif; } html, body { padding:0; margin:0; } body { font-size:14px; background:#f9f9f9; } -a { text-decoration:none; color:#426DC9; } +a { text-decoration:none; color:#0000ff; } form { padding:0; margin:0; } select { border:solid 1px #e0e0e0; padding:2px; border-radius:3px 3px 3px 3px; background:#fff; } - .clear { clear:both; height:0; padding:0; margin:0; font-size:0; border:none; } -#menu { width:900px; margin:20px auto; border-radius:0 0 3px 3px; } -#menu_title { margin:0; font-size:24px; float:left; padding:8px 0 0 0; font-weight:normal; } -#menu_title a { color:#333; text-shadow: 0 1px 0 #FFFFFF;} +#menu { max-width:1000px; margin:10px auto; border-radius:0 0 3px 3px; } +#menu_title { margin:0; float:left; padding-top: 8px; font-size:24px;letter-spacing: 2px; } #menu ul, #menu li { list-style:none; margin:0; padding:0; } #menu ul { float:right; } #menu li { float:left; } -#menu ul a { font-size:16px; display:block; padding:10px 24px; } -#menu .current a, #menu li a:hover { color:#cc0000; border-bottom:2px solid #cc0000; } +#menu ul a { font-size:16px; display:block; padding:10px 24px; border-bottom: 2px solid transparent;} +#menu .current a, +#menu li a:hover { color:#cc0000; border-bottom-color:#cc0000; } #submenu { border-bottom:solid 1px #e0e0e0; } #submenu ul, #submenu li { list-style:none; margin:0; padding:0; } #submenu li { float:left; } #submenu li a { display:block; padding:6px 18px; background:#f0f0f0; border:solid 1px #e0e0e0; margin:6px 0 6px 6px; text-decoration:none; color:#426DC9; } -#content { width:900px; margin:20px auto; background:#fff; border:solid 1px #e0e0e0; border-radius:3px 3px 3px 3px; } +#content { max-width:1000px; margin:10px auto; background:#fff; border:solid 1px #ccc; border-radius:3px 3px 3px 3px; } #content_box { padding:20px; } -#footer { color:#888; margin-top:20px; padding:12px 0; width:900px; margin:0 auto; font-size:12px; border-top:solid 1px #e0e0e0; } +#footer { max-width:1000px; margin:0 auto 10px; } #footer span { float:right; } +#footer .footer_box { color:#888; font-size:12px; } + +.link { text-decoration:none; color:#0000ff; } +.link:hover { background:#bc0000; color:#fff; } .link_button { background:#efefef; padding:2px 4px; font-size:12px; margin-right:4px; border-radius:3px 3px 3px 3px; } -.link_button:hover, .link_button.current { background:#bc0000; color:#fff; } +.link_button:hover, +.link_button.current { background:#bc0000; color:#fff; } .table_list table { border:0; width:100%; border:solid 1px #e0e0e0; border-top:0; color:#333; border-radius:3px 3px 3px 3px; font-size:12px; } .table_list td { padding:8px; border-top:solid 1px #e0e0e0; vertical-align:top; } @@ -40,7 +44,6 @@ select { border:solid 1px #e0e0e0; padding:2px; border-radius:3px 3px 3px 3px; b .table_list .row_name { font-size:14px; } .table_list .row_tool { margin-top:8px; } -.table_list_tool span { margin-right:20px; } .table_list_tool { color:#333; } .table_list { padding:6px 0; } @@ -57,17 +60,42 @@ div.updated, div.error { border-radius:3px; border-style:solid; border-width:1px .admin_page_name { font-size:24px; padding-bottom:16px; color:#333; } .admin_page_name a { margin-left:10px; } +.admin_index_help { padding-top: 10px; border-top: solid 1px #e0e0e0; } + .small_form .name { font-size:16px; font-weight:bold; color:#333; } .small_form .label { color:#333; padding-bottom:4px; } .small_form .field { margin-top:20px; } .small_form .textbox { width:95%; border:solid 1px #ccc; padding:4px; border-radius:3px; } .small_form .info { color:#666; font-size:12px; padding-top:4px; } -.small_form .button { padding:6px 20px; } +.small_form .button { text-align: center; } -.small_form2 .label { float:left; width:150px; padding:4px 0 0 0; } +.small_form2 .label { float:left; width:100px; padding:4px 0 0 0; } .small_form2 .textbox { width:300px; float:left; } +.small_form2 select.textbox { width:310px; float:left; } .small_form2 .field_body { width:300px; } -.small_form2 .info { width:300px; float:left; margin-left:40px; } +.small_form2 .info { width:300px; float:left; margin-left:2px; } .edit_textbox { width:99%;border:solid 1px #ccc; font-size:20px; padding:3px 4px; border-radius:3px; } .edit_textarea { height:400px;width:99%;font-size:13px;border:solid 1px #ccc;padding:3px 4px; border-radius:3px; } + +@media (max-width: 660px) { + body { + padding-left: 5px; + padding-right: 5px; + } + #menu_title { + padding-top: unset; + } + #menu ul a { + padding: 6px 10px; + } + #content_box { + padding: 10px; + } + .admin_page_name { + font-size: 14px; + } + .admin_page_name a { + margin-left: 2px; + } +} \ No newline at end of file diff --git a/build.php b/build.php old mode 100644 new mode 100755 index 90d5de3..c91ddc7 --- a/build.php +++ b/build.php @@ -1,71 +1,77 @@ + + + + + + + + + + + + + <?php app_site_name(); ?> + + + + +
+
+ 很抱歉!网站关闭(正在维护中)。 +

很抱歉

+ +

该站点已经关闭
请联系管理员了解详情!

+
+
+
+ +
+ + + \ No newline at end of file diff --git a/core/common.php b/core/common.php new file mode 100755 index 0000000..aee8464 --- /dev/null +++ b/core/common.php @@ -0,0 +1,34 @@ +404 Not Found

The page that you have requested could not be found.

"; + exit(); +} + +function app_get_url($app_path_type, $app_path_name = '', $path = '', $print = true) +{ + global $app_config; + $r = @$app_config['site_route'] == 'path' ? '/' : '/?'; + $t = empty($app_path_type) ? '' : $app_path_type . '/'; + $n = empty($app_path_name) ? '' : $app_path_name; + + $url = $r . $t . $n; + $url = str_replace('//', '/', $url); + $url = rtrim($url, '/'); + $url = $app_config['site_link'] . $url; + + if ($print) { + echo $url; + return; + } + + return $url; +} + diff --git a/core/installer.php b/core/installer.php new file mode 100644 index 0000000..7e85a7d --- /dev/null +++ b/core/installer.php @@ -0,0 +1,226 @@ + + + + +MiniCMS 安装程序 + + + + +
+
MiniCMS 安装程序
+
v/*APP_VERSION*/
+
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+ +
检测到 MiniCMS 配置文件,将使用升级模式安装。
+
+ + + +失败]'; + } + } else { + $install_failed = true; + echo '[无法创建目录]'; + } + echo '
'; + } + + if (isset($_POST["start_install"])) { + ?> +
+'; + echo "创建数据目录"; + if (@mkdir('data/', 0744, true)) { + echo '[成功]'; + } else { + $install_failed = true; + echo '[失败]'; + } + echo '
'; + } + if (!is_file('data/config.php')) { + $is_upgrade = false; + echo '
'; + echo "创建配置文件"; + if (!@file_put_contents('data/config.php', + " '/*APP_VERSION*/',". + "'site_link' => '{$_POST['sitelink']}',". + "'site_name' => '{$_POST['sitename']}',". + "'site_desc' => '又一个 MiniCMS 网站',". + "'site_keywords' => 'MiniCMS',". + "'site_theme' => 'default',". + "'site_route' => 'default',". + "'site_icpno' => '',". + "'site_status' => 'open',". + "'user_name' => '{$_POST['username']}',". + "'user_pass' => '{$_POST['password']}',". + "'nick_name' => '{$_POST['nickname']}',". + "'comment_code' => '',". + "'footer_code' => '');?>" + )) { + $install_failed = true; + echo '[失败]'; + } + echo '
'; + } else { + echo '
'; + echo "升级配置文件"; + require 'data/config.php'; + $app_config['version'] = '/*APP_VERSION*/'; + if (!@file_put_contents('data/config.php', "")) { + $install_failed = true; + echo '[失败]'; + } + echo '
'; + } + + if (!is_dir('data/posts/index')) { + echo '
'; + echo "创建文章索引目录"; + if (@mkdir('data/posts/index', 0744, true)) { + echo '
'; + echo "创建页面索引文件"; + if ( + !@file_put_contents('data/posts/index/delete.php', '') || + !@file_put_contents('data/posts/index/publish.php', '') || + !@file_put_contents('data/posts/index/draft.php', '') + ) { + $install_failed = true; + echo '[失败]'; + rmdir('data/posts/index'); + } + echo '
'; + } else { + $install_failed = true; + echo '[失败]'; + echo '
'; + } + } + + if (!is_dir('data/pages/index')) { + echo '
'; + echo "创建页面索引目录"; + if (@mkdir('data/pages/index', 0744, true)) { + echo '
'; + echo "创建页面索引文件"; + if ( + !@file_put_contents('data/pages/index/delete.php', '') || + !@file_put_contents('data/pages/index/publish.php', '') || + !@file_put_contents('data/pages/index/draft.php', '') + ) { + $install_failed = true; + echo '[失败]'; + rmdir('data/pages/index'); + } + echo '
'; + } else { + $install_failed = true; + echo '[失败]'; + echo '
'; + } + } +} +?> +
+ +
升级安装失败
+ +
升级安装完毕
+ +
安装文件无法删除,请手工删除。
+ +
+ + + +
+ + +
+
+ + \ No newline at end of file diff --git a/mc-files/markdown.php b/core/markdown.php similarity index 100% rename from mc-files/markdown.php rename to core/markdown.php diff --git a/core/rss.php b/core/rss.php new file mode 100644 index 0000000..fc86673 --- /dev/null +++ b/core/rss.php @@ -0,0 +1,33 @@ + +'; ?> + + + + <?php app_site_name(); ?> + + + zh_CN + hourly + 1 + MiniCMS + + + <?php app_post_title(); ?> + + + + +"); echo "\n"; ?> + ]]> + + + + + diff --git a/core/tags.php b/core/tags.php new file mode 100755 index 0000000..0eac717 --- /dev/null +++ b/core/tags.php @@ -0,0 +1,421 @@ +'; + echo $text; + echo ''; +} + +function app_goto_new($text) +{ + global $app_path_type, $app_path_name, $app_page_no, $app_config; + echo ''; + echo $text; + echo ''; +} + +function app_date_list($item_begin = '
  • ', $item_gap = '', $item_end = '
  • ') +{ + global $app_dates, $app_config; + + if (isset($app_dates)) { + $date_count = count($app_dates); + + for ($i = 0; $i < $date_count; $i++) { + $date = $app_dates[$i]; + + echo $item_begin; + echo ''; + echo $date; + echo ''; + echo $item_end; + + if ($i < $date_count - 1) + echo $item_gap; + } + } +} + +function app_tag_list($item_begin = '
  • ', $item_gap = '', $item_end = '
  • ') +{ + global $app_tags, $app_config; + + if (isset($app_tags)) { + $tag_count = count($app_tags); + + for ($i = 0; $i < $tag_count; $i++) { + $tag = $app_tags[$i]; + + echo $item_begin; + echo ''; + echo htmlspecialchars($tag); + echo ''; + echo $item_end; + + if ($i < $tag_count - 1) + echo $item_gap; + } + } +} + +function app_next_post() +{ + global $app_posts, $app_post_ids, $app_post_count, $app_post_i, $app_post_i_end, $app_post_id, $app_post, $app_page_no, $app_post_per_page; + + if (!isset($app_posts)) { + return false; + } + + if (!isset($app_post_i)) { + $app_post_i = 0 + ($app_page_no - 1) * $app_post_per_page; + $app_post_i_end = $app_post_i + $app_post_per_page; + if ($app_post_count < $app_post_i_end) + $app_post_i_end = $app_post_count; + } + + if ($app_post_i == $app_post_i_end) { + return false; + } + + if (!isset($app_post_ids[$app_post_i])) { + return false; + } + + $app_post_id = $app_post_ids[$app_post_i]; + $app_post = $app_posts[$app_post_id]; + $app_post_i += 1; + return true; +} + +/** + * 文章标题 + */ +function app_post_title($print = true) +{ + global $app_post; + + if ($print) { + echo htmlspecialchars($app_post['title']); + return; + } + + return htmlspecialchars($app_post['title']); +} + +/** + * 文章发布日期 + */ +function app_post_date($print = true) +{ + global $app_post; + + if ($print) { + echo $app_post['date']; + return; + } + + return $app_post['date']; +} + +/** + * 文章发布时间 + */ +function app_post_time($print = true) +{ + global $app_post; + + if ($print) { + echo $app_post['time']; + return; + } + + return $app_post['time']; +} + +/** + * 文章标签链接 + */ +function app_post_tags($item_begin = '', $item_gap = ', ', $item_end = '', $as_link = true) +{ + global $app_post, $app_config; + + $tags = $app_post['tags']; + + $count = count($tags); + + for ($i = 0; $i < $count; $i++) { + $tag = $tags[$i]; + + echo $item_begin; + + if ($as_link) { + echo ''; + } + + echo htmlspecialchars($tag); + + if ($as_link) { + echo ''; + } + + echo $item_end; + + if ($i < $count - 1) { + echo $item_gap; + } + } +} + +/** + * 文章内容 + */ +function app_post_content($print = true) +{ + global $app_data; + + if (!isset($app_data)) { + global $app_post_id; + + $data = unserialize(file_get_contents('data/posts/data/' . $app_post_id . '.dat')); + + $html = MarkdownExtra::defaultTransform($data['content']); + } else { + $html = MarkdownExtra::defaultTransform($app_data['content']); + } + + if ($print) { + echo htmlspecialchars_decode($html); + return; + } + + return $html; +} + +/** + * 文章标题+链接 + */ +function app_post_link() +{ + global $app_post; + + echo ''; + echo htmlspecialchars($app_post['title']); + echo ''; +} + +/** + * 文章访问URL + */ +function app_post_url($print = true) +{ + global $app_post_id, $app_post, $app_config; + $url = app_get_url('post', $app_post_id); + + if ($print) { + echo $url; + return; + } + + return $url; +} + +/** + * 是否可评论 + */ +function app_can_comment() +{ + global $app_post_id, $app_post; + + return isset($app_post['can_comment']) ? $app_post['can_comment'] == '1' : true; +} + +/** + * 文章评论代码 + */ +function app_comment_code() +{ + global $app_config; + + echo isset($app_config['comment_code']) ? $app_config['comment_code'] : ''; +} + +/** + * 网页底部代码 + */ +function app_footer_code() +{ + global $app_config; + + echo isset($app_config['footer_code']) ? $app_config['footer_code'] : ''; +} diff --git a/core/xml.php b/core/xml.php new file mode 100644 index 0000000..2839c1c --- /dev/null +++ b/core/xml.php @@ -0,0 +1,19 @@ + +'; ?> + + + + 1.00 + + always + + + + + 0.8 + + daily + + + + \ No newline at end of file diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..0f1ea46 Binary files /dev/null and b/favicon.ico differ diff --git a/index.php b/index.php index 19f36a1..fbe3e05 100755 --- a/index.php +++ b/index.php @@ -1,138 +1,174 @@ +// 加载视图 +if (isset($app_config['site_status']) && $app_config['site_status'] == 'closed') { + require PATH_ROOT . '/core/closed.php'; +} else if (in_array($app_path_type, ['index', 'post', 'tag', 'date', 'archive', 'page'])) { + require PATH_ROOT . '/theme/' . $app_config['site_theme'] . '/index.php'; +} elseif ($app_path_type == 'xml') { + require PATH_ROOT . '/core/xml.php'; +} elseif ($app_path_type == 'rss') { + require PATH_ROOT . '/core/rss.php'; +} else { + app_404(); +} diff --git a/mc-admin/conf.php b/mc-admin/conf.php deleted file mode 100755 index 28adb04..0000000 --- a/mc-admin/conf.php +++ /dev/null @@ -1,97 +0,0 @@ - -"; - - file_put_contents('../mc-files/mc-conf.php', $code); - - if ($_POST['user_pass'] != '' || $user_name_changed) { - setcookie('mc_token', md5($mc_config['user_name'].'_'.$mc_config['user_pass'])); - } - - $display_info = true; -} - -$site_name = $mc_config['site_name']; -$site_desc = $mc_config['site_desc']; -$site_link = $mc_config['site_link']; -$user_nick = $mc_config['user_nick']; -$user_name = $mc_config['user_name']; -$comment_code = isset($mc_config['comment_code']) ? $mc_config['comment_code'] : ''; -?> -
    - -
    设置保存成功!
    - -
    站点设置
    -
    -
    -
    网站标题
    - -
    -
    -
    -
    网站描述
    - -
    用简洁的文字没描述本站点。
    -
    -
    -
    -
    网站地址
    - -
    -
    -
    -
    -
    站长昵称
    - -
    -
    -
    -
    -
    后台帐号
    - -
    -
    -
    -
    -
    后台密码
    - -
    -
    -
    -
    -
    确认密码
    - -
    -
    -
    -
    -
    评论代码
    - -
    第三方评论服务所提供的评论代码,例如:Disqus新浪微博评论箱 等。设置此选项后,MiniCMS就拥有了评论功能。
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - diff --git a/mc-admin/foot.php b/mc-admin/foot.php deleted file mode 100755 index b1c3ae1..0000000 --- a/mc-admin/foot.php +++ /dev/null @@ -1,5 +0,0 @@ -
    -
    - - - diff --git a/mc-admin/head.php b/mc-admin/head.php deleted file mode 100755 index 1c47eed..0000000 --- a/mc-admin/head.php +++ /dev/null @@ -1,74 +0,0 @@ -> 5; - } - $output[] = $out; - } - return $output; -} - -function post_sort($a, $b) { - $a_date = $a['date']; - $b_date = $b['date']; - - if ($a_date != $b_date) - return $a_date > $b_date ? -1 : 1; - - return $a['time'] > $b['time'] ? -1 : 1; -} -?> - - - - - MiniCMS - - - - -
    -
    diff --git a/mc-admin/index.php b/mc-admin/index.php deleted file mode 100755 index c5f3209..0000000 --- a/mc-admin/index.php +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - MiniCMS - - - -
    -
    MiniCMS
    -
    -
    -
    帐号
    -
    -
    密码
    -
    -
    -
    -
    -
    - - diff --git a/mc-admin/page.php b/mc-admin/page.php deleted file mode 100755 index 1b0a5e6..0000000 --- a/mc-admin/page.php +++ /dev/null @@ -1,348 +0,0 @@ -"); - - if ($state != 'delete') { - $index_file2 = '../mc-files/pages/index/delete.php'; - - require $index_file2; - - $mc_pages[$id] = $page; - - file_put_contents($index_file2, ""); - } else { - unlink('../mc-files/pages/data/'.$page['file'].'.dat'); - } -} - -function revert_page($id) { - global $state, $index_file, $mc_pages; - - $page = $mc_pages[$id]; - - $prev_state = $page['prev_state']; - - unset($page['prev_state']); - - unset($mc_pages[$id]); - - file_put_contents($index_file, ""); - - $index_file2 = '../mc-files/pages/index/'.$prev_state.'.php'; - - require $index_file2; - - $mc_pages[$id] = $page; - - ksort($mc_pages); - - file_put_contents($index_file2, ""); -} - -load_pages(); - -if (isset($_GET['delete']) || (isset($_GET['apply']) && $_GET['apply'] == 'delete')) { - if (isset($_GET['apply']) && $_GET['apply'] == 'delete') { - $ids = explode(',', $_GET['ids']); - foreach ($ids as $id) { - if (trim($id) == '') - continue; - delete_page($id); - load_pages(); - } - } else { - delete_page($_GET['delete']); - } - //load_posts(); - Header('Location:page.php?done=true&state='.$state); - exit(); -} - -if (isset($_GET['revert']) || (isset($_GET['apply']) && $_GET['apply'] == 'revert')) { - if (isset($_GET['apply']) && $_GET['apply'] == 'revert') { - $ids = explode(',', $_GET['ids']); - foreach ($ids as $id) { - if (trim($id) == '') - continue; - revert_page($id); - load_pages(); - } - } else { - revert_page($_GET['revert']); - } - //load_posts(); - Header('Location:page.php?done=true&state='.$state); - exit(); -} - -if (isset($_GET['done'])) { - $message = '操作成功'; -} - -$page_ids = array_keys($mc_pages); -$page_count = count($page_ids); - -$date_array = array(); - -for ($i = $page_count - 1; $i >= 0; $i --) { - $page_id = $page_ids[$i]; - $page = $mc_pages[$page_id]; - $date_array[] = substr($page['date'], 0, 7); -} - -$date_array = array_unique($date_array); - -if (isset($_GET['date'])) - $filter_date = $_GET['date']; -else - $filter_date = ''; - -$mc_pages2 = array(); - -for ($i = 0; $i < $page_count; $i ++) { - $page_id = $page_ids[$i]; - $page = $mc_pages[$page_id]; - - if ($filter_date != '' && strpos($page['date'], $filter_date) !== 0) - continue; - - $mc_pages2[$page_id] = $page; -} - -$mc_pages = $mc_pages2; - -$page_ids = array_keys($mc_pages); -$page_count = count($page_ids); - -$last_page = ceil($page_count / 10); - -if (isset($_GET['page'])) - $page_num = $_GET['page']; -else - $page_num = 1; - -if ($page_num > 1) - $prev_page = $page_num - 1; -else - $prev_page = 1; - -if ($page_num < $last_page) - $next_page = $page_num + 1; -else - $next_page = $last_page; - -if ($page_num < $last_page) - $next_page = $page_num + 1; -else - $next_page = $last_page; - -if ($page_num < 0) - $page_num = 1; -else if ($page_num > $last_page) - $page_num = $last_page; -?> - - - -
    - -
    管理页面创建页面
    -
    -已发布 -草稿箱 -回收站 -
    -
    - - - - - - - - - - 共 项   - « - - 第 页,共 页 - - » - - -
    -
    - - - - - - - - - = ($page_num * 10)) continue; $page_id = $page_ids[$i]; $page = $mc_pages[$page_id]; ?> - > - - - - - - - - - - - - -
    标题路径日期
    - -
    - 编辑 - - 还原 - 删除 - - 回收 - - 查看 -
    -
    标题路径日期
    -
    -
    - - - - - - 共 项   - « - - 第 页,共 页 - - » - - -
    - diff --git a/mc-admin/post.php b/mc-admin/post.php deleted file mode 100755 index 290304b..0000000 --- a/mc-admin/post.php +++ /dev/null @@ -1,364 +0,0 @@ -"); - - if ($state != 'delete') { - $index_file2 = '../mc-files/posts/index/delete.php'; - - require $index_file2; - - $mc_posts[$id] = $post; - - file_put_contents($index_file2, ""); - } else { - unlink('../mc-files/posts/data/'.$id.'.dat'); - } -} - -function revert_post($id) { - global $state, $index_file, $mc_posts; - - $post = $mc_posts[$id]; - - $prev_state = $post['prev_state']; - - unset($post['prev_state']); - - unset($mc_posts[$id]); - - file_put_contents($index_file, ""); - - $index_file2 = '../mc-files/posts/index/'.$prev_state.'.php'; - - require $index_file2; - - $mc_posts[$id] = $post; - - uasort($mc_posts, "post_sort"); - - file_put_contents($index_file2, ""); -} - -load_posts(); - -if (isset($_GET['delete']) || (isset($_GET['apply']) && $_GET['apply'] == 'delete')) { - if (isset($_GET['apply']) && $_GET['apply'] == 'delete') { - $ids = explode(',', $_GET['ids']); - foreach ($ids as $id) { - if (trim($id) == '') - continue; - delete_post($id); - load_posts(); - } - } else { - delete_post($_GET['delete']); - } - //load_posts(); - Header('Location:post.php?done=true&state='.$state); - exit(); -} - -if (isset($_GET['revert']) || (isset($_GET['apply']) && $_GET['apply'] == 'revert')) { - if (isset($_GET['apply']) && $_GET['apply'] == 'revert') { - $ids = explode(',', $_GET['ids']); - foreach ($ids as $id) { - if (trim($id) == '') - continue; - revert_post($id); - load_posts(); - } - } else { - revert_post($_GET['revert']); - } - //load_posts(); - Header('Location:post.php?done=true&state='.$state); - exit(); -} - -if (isset($_GET['done'])) { - $message = '操作成功'; -} - -$post_ids = array_keys($mc_posts); -$post_count = count($post_ids); - -$date_array = array(); -$tags_array = array(); - -for ($i = 0; $i < $post_count; $i ++) { - $post_id = $post_ids[$i]; - $post = $mc_posts[$post_id]; - $date_array[] = substr($post['date'], 0, 7); - $tags_array = array_merge($tags_array, $post['tags']); -} - -$date_array = array_unique($date_array); -$tags_array = array_unique($tags_array); - -if (isset($_GET['tag'])) - $filter_tag = $_GET['tag']; -else - $filter_tag = ''; - -if (isset($_GET['date'])) - $filter_date = $_GET['date']; -else - $filter_date = ''; - -$mc_posts2 = array(); - -for ($i = 0; $i < $post_count; $i ++) { - $post_id = $post_ids[$i]; - $post = $mc_posts[$post_id]; - - if ($filter_tag != '' && !in_array($filter_tag, $post['tags'])) - continue; - - if ($filter_date != '' && strpos($post['date'], $filter_date) !== 0) - continue; - - $mc_posts2[$post_id] = $post; -} - -$mc_posts = $mc_posts2; - -$post_ids = array_keys($mc_posts); -$post_count = count($post_ids); - -$last_page = ceil($post_count / 10); - -if (isset($_GET['page'])) - $page_num = $_GET['page']; -else - $page_num = 1; - -if ($page_num > 1) - $prev_page = $page_num - 1; -else - $prev_page = 1; - -if ($page_num < $last_page) - $next_page = $page_num + 1; -else - $next_page = $last_page; - -if ($page_num < 0) - $page_num = 1; -else if ($page_num > $last_page) - $page_num = $last_page; -?> - - - -
    - -
    管理文章撰写文章
    -
    -已发布 -草稿箱 -回收站 -
    -
    - - - - - - - - - - - 共 项   - « - - 第 页,共 页 - - » - - -
    -
    - - - - - - - - - = ($page_num * 10)) continue; $post_id = $post_ids[$i]; $post = $mc_posts[$post_id]; ?> - > - - - - - - - - - - - - -
    标题标签日期
    - -
    - 编辑 - - 还原 - 删除 - - 回收 - - 查看 -
    -
    标题标签日期
    -
    -
    - - - - - - 共 项   - « - - 第 页,共 页 - - » - - -
    - diff --git a/mc-files/mc-core.php b/mc-files/mc-core.php deleted file mode 100755 index e2227e6..0000000 --- a/mc-files/mc-core.php +++ /dev/null @@ -1,14 +0,0 @@ -404 Not Found"; - echo "The page that you have requested could not be found."; - exit(); -} -?> diff --git a/mc-files/mc-rss.php b/mc-files/mc-rss.php deleted file mode 100644 index 43d7376..0000000 --- a/mc-files/mc-rss.php +++ /dev/null @@ -1,31 +0,0 @@ - -'; ?> - - - <?php mc_site_name(); ?> - - - zh_CN - hourly - 1 - http://1234n.com/?projects/minicms/ - - - <?php mc_the_title(); ?> - - - - -"); echo "\n"; ?> - ]]> - - - - diff --git a/mc-files/mc-tags.php b/mc-files/mc-tags.php deleted file mode 100755 index 5e2dda8..0000000 --- a/mc-files/mc-tags.php +++ /dev/null @@ -1,379 +0,0 @@ -'; - echo $text; - echo ''; - } else { - echo ''; - echo $text; - echo ''; - } -} - -function mc_goto_new($text) { - global $mc_get_type, $mc_get_name, $mc_page_num, $mc_config; - - if ($mc_get_type == 'tag') { - echo ''; - echo $text; - echo ''; - } else { - echo ''; - echo $text; - echo ''; - } -} - -function mc_date_list($item_begin='
  • ', $item_gap='', $item_end='
  • ') { - global $mc_dates, $mc_config; - - if (isset($mc_dates)) { - $date_count = count($mc_dates); - - for ($i = 0; $i < $date_count; $i ++) { - $date = $mc_dates[$i]; - - echo $item_begin; - echo ''; - echo $date; - echo ''; - echo $item_end; - - if ($i < $date_count - 1) - echo $item_gap; - } - } -} - -function mc_tag_list($item_begin='
  • ', $item_gap='', $item_end='
  • ') { - global $mc_tags, $mc_config; - - if (isset($mc_tags)) { - $tag_count = count($mc_tags); - - for ($i = 0; $i < $tag_count; $i ++) { - $tag = $mc_tags[$i]; - - echo $item_begin; - echo ''; - echo htmlspecialchars($tag); - echo ''; - echo $item_end; - - if ($i < $tag_count - 1) - echo $item_gap; - } - } -} - -function mc_next_post() { - global $mc_posts, $mc_post_ids, $mc_post_count, $mc_post_i, $mc_post_i_end, $mc_post_id, $mc_post, $mc_page_num, $mc_post_per_page; - - if (!isset($mc_posts)) - return false; - - if (!isset($mc_post_i)) { - $mc_post_i = 0 + ($mc_page_num - 1) * $mc_post_per_page; - $mc_post_i_end = $mc_post_i + $mc_post_per_page; - if ($mc_post_count < $mc_post_i_end) - $mc_post_i_end = $mc_post_count; - } - - if ($mc_post_i == $mc_post_i_end) - return false; - - if (!isset($mc_post_ids[$mc_post_i])) - return false; - - $mc_post_id = $mc_post_ids[$mc_post_i]; - - $mc_post = $mc_posts[$mc_post_id]; - - $mc_post_i += 1; - - return true; -} - -function mc_the_title($print = true) { - global $mc_post; - - if ($print) { - echo htmlspecialchars($mc_post['title']); - return; - } - - return htmlspecialchars($mc_post['title']); -} - -function mc_the_date($print = true) { - global $mc_post; - - if ($print) { - echo $mc_post['date']; - return; - } - - return $mc_post['date']; -} - -function mc_the_time($print = true) { - global $mc_post; - - if ($print) { - echo $mc_post['time']; - return; - } - - return $mc_post['time']; -} - -function mc_the_tags($item_begin='', $item_gap=', ', $item_end='', $as_link = true) { - global $mc_post, $mc_config; - - $tags = $mc_post['tags']; - - $count = count($tags); - - for ($i = 0; $i < $count; $i ++) { - $tag = $tags[$i]; - - echo $item_begin; - - if ($as_link) { - echo ''; - } - - echo htmlspecialchars($tag); - - if ($as_link) { - echo ''; - } - - echo $item_end; - - if ($i < $count - 1) - echo $item_gap; - } -} - -function mc_the_content($print = true) { - global $mc_data; - - if (!isset($mc_data)) { - global $mc_post_id; - - $data = unserialize(file_get_contents('mc-files/posts/data/'.$mc_post_id.'.dat')); - - $html = MarkdownExtra::defaultTransform($data['content']); - } - else { - $html = MarkdownExtra::defaultTransform($mc_data['content']); - } - - if ($print) { - echo $html; - return; - } - - return $html; -} - -function mc_the_link() { - global $mc_post_id, $mc_post, $mc_config; - - echo ''; - echo htmlspecialchars($mc_post['title']); - echo ''; -} - -function mc_the_url($print = true) { - global $mc_post_id, $mc_post, $mc_config; - - $url = htmlentities($mc_config['site_link']).'/?post/'.$mc_post_id; - - if ($print) { - echo $url; - return; - } - - return $url; -} - -function mc_can_comment() { - global $mc_post_id, $mc_post; - - return isset($mc_post['can_comment']) ? $mc_post['can_comment'] == '1' : true; -} - -function mc_comment_code() { - global $mc_config; - - echo isset($mc_config['comment_code']) ? $mc_config['comment_code'] : ''; -} -?> diff --git a/mc-files/theme/index.php b/mc-files/theme/index.php deleted file mode 100755 index 6f4bebb..0000000 --- a/mc-files/theme/index.php +++ /dev/null @@ -1,89 +0,0 @@ - - - - - -<?php if (mc_is_post() || mc_is_page()) { mc_the_title(); ?> | <?php mc_site_name(); } else { mc_site_name(); ?> | <?php mc_site_desc(); }?> - - - -
    - -
    -
    - -
    -

    -
    by at
    -
    -
    - - - - -
    - -
    by at
    */ ?> -
    -
    - - - - -
    -

    月份

    -
      - -
    -
    -
    -

    标签

    -
      - -
    -
    -
    - - -
    - -
    - -
    - -
    -

    -
    by at
    -
    -
    - -
    - - - - - - -
    -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    - - diff --git a/mc-files/theme/style.css b/mc-files/theme/style.css deleted file mode 100755 index 4ee9195..0000000 --- a/mc-files/theme/style.css +++ /dev/null @@ -1,56 +0,0 @@ -body { font-family:"Microsoft YaHei",Segoe UI,Tahoma,Arial,Verdana,sans-serif; font-size:14px; width:960px; margin:0 auto; background:#FFF; } -a { color:#44f; text-decoration:none; } -a:hover { color:#bc0000; } -p { padding:0; margin:16px 0; line-height:20px; } -.clearer { clear:both; } -img { border:0; } -h1,h2,h3,h4,h5,h6,b,strong { color:#3f3f3f; } - -#main { width:960px; margin:0 auto; } -#sitename { font-size:28px; color:#333; text-shadow: 0 1px 0 #fff; } -#sitename a { color:#3f3f3f; } -#sitename a:hover { color:#44f; } -#header { margin:40px 0 40px 0; } -#side { float:left; width:150px; } -#navbar { margin-top:30px; } -#navbar ul, #navbar li { list-style:none; margin:0; padding:0; } -#navbar a { color:#44F; font-size:18px; display:block; padding-bottom:20px; } -#navbar a:hover { color:#bc0000; } -#page_info { font-size:16px; margin-bottom:20px; color:#888; } -#page_info span { padding:4px; background:#bc0000; color:#fff; border-radius:3px; } - -#content { float:right; width:100%; margin-left:-160px; } -#content_box { margin-left:160px; border-left:solid 1px #ccc; padding-left:20px; } -#content .post .title { font-weight:normal; font-size:24px; color:#333; text-shadow: 0 1px 0 #ffffff; margin:0; padding:0 0 10px 0; } -#content .post .title a { color:#3f3f3f; } -#content .post .title a:hover { color:#44f; } -#content .post .tags { padding-bottom:10px; color:#888; font-size:11px; } -#content .post .tags a { color:#fff; background:#aaa; padding:2px 4px; margin-right:6px; border-radius:3px; } -#content .post .tags a:hover { background:#bc0000; } -#content .post .content { margin-bottom:1.625em; } -#content .post img { max-width:780px; } - -#content .post_list { } -#content .post_list .post { padding-bottom:40px; } -#content .post_list .tags { padding-bottom:0; } - -#content .tag_list ul, -#content .tag_list li, -#content .date_list ul, -#content .date_list li { list-style:none; margin:0; padding:0; } - -#content .tag_list, #content .date_list { float:left; width:200px; } -#content .tag_list li, -#content .date_list li { margin-bottom:8px;} - -#page_bar { margin-top:20px; } - -#footer { text-align:center; margin:30px 0; color:#888; } -pre, pre.code, pre.prettyprint { margin-bottom:18px; padding:10px !important; font-size:13px; background:#fff; color:#000; font-family: monospace; border:solid 1px #afafaf; overflow-x:scroll;} -pre * { font-family: monospace; } - -.page_nav { float:right; border-right:solid 1px #ccc; } -.page_nav, .page_nav li { list-style:none; margin:0; padding:0; } -.page_nav li { float:left; } -.page_nav a { display:block; padding:6px 20px; } -.page_nav a { border:solid 1px #ccc; border-right:0; } diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..f72172e --- /dev/null +++ b/nginx.conf @@ -0,0 +1,6 @@ +location / { + if (!-e $request_filename) { + rewrite ^(.*)$ /index.php?s=/$1 last; + break; + } +} \ No newline at end of file diff --git a/theme/default/index.php b/theme/default/index.php new file mode 100755 index 0000000..39123ce --- /dev/null +++ b/theme/default/index.php @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + <?php if (app_is_post() || app_is_page()) { app_post_title(); ?> | <?php app_site_name();} else { app_site_name(); ?> | <?php app_site_desc(); } ?> + + + + +
    + + +
    +
    + +
    +

    +
    by at
    +
    +
    + + +
    + +
    by at
    */ ?> +
    +
    + + + + +
    +

    月份

    +
    +
    +
    +

    标签

    +
    +
    +
    + + +
    标签:
    + +
    月份:
    + +
    + +
    +

    +
    by at
    +
    +
    + +
    + + + + + + +
    +
    +
    +
    + +
    +
    +
    + +
    + + + \ No newline at end of file diff --git a/theme/default/style.css b/theme/default/style.css new file mode 100755 index 0000000..26ae9c5 --- /dev/null +++ b/theme/default/style.css @@ -0,0 +1,71 @@ +body { font-family:"Microsoft YaHei",Segoe UI,Tahoma,Arial,Verdana,sans-serif; font-size:14px; margin:0 auto; background:#FFF; } +a { color:#44f; text-decoration:none; } +a:hover { color:#bc0000; } +p { padding:0; margin:16px 0; line-height:20px; } +.clearer { clear:both; } +img { border:0; } +h1,h2,h3,h4,h5,h6,b,strong { color:#3f3f3f; } + +#main { width: 960px; margin:0 auto; } +#header { padding: 30px; border-left: solid 1px #ccc; } +#sitename { font-size:28px; color:#333; } +#sitename a { padding: 0 4px; } +#navbar { margin-top: 0; } +#navbar ul, #navbar li { list-style:none; margin:0; padding:0; } +#navbar a { font-size:18px; display:block; padding:10px 0; text-align: center; } +#page_info { font-size:16px; margin-bottom:20px; color:#888; } +#page_info span { padding:4px; background:#bc0000; color:#fff; border-radius:3px; } + +#sidebar { float:left; width:150px; border: solid 1px #ccc; border-left-color: transparent;} +#content { float:right; width: 80%; width: -moz-calc(100% - 160px); width: -webkit-calc(100% - 160px); width: calc(100% - 160px); } +#content_box { border:solid 1px #ccc; padding:20px;border-right-color: transparent;border-bottom-color: transparent; } +#content .post .title { font-weight:normal; font-size:24px; color:#333; text-shadow: 0 1px 0 #ffffff; margin:0; padding:0 0 10px 0; } +#content .post .title a { color:#3f3f3f; } +#content .post .title a:hover { color:#44f; } +#content .post .tags { color:#888; font-size:11px; } +#content .post .tags a { color:#fff; background:#aaa; padding:2px 4px; margin-right:6px; border-radius:3px; } +#content .post .tags a:hover { background:#bc0000; } +#content .post .content { margin-bottom:1.625em; } +#content .post img { max-width:780px; } + +#content .post_list .post { padding-bottom: 10px; } +#content .post_list .post + .post { padding-top: 20px; } +#content .post_list .tags { padding-bottom:0; } + +#content .tag_list ul, +#content .tag_list li, +#content .date_list ul, +#content .date_list li { list-style:none; margin:0; padding:0; } + +#content .tag_list, #content .date_list { float:left; width: 50%; } +#content .tag_list li, +#content .date_list li { margin-bottom:8px;} + +#page_bar { margin-top:20px; } + +.link { text-decoration:none; color:#0000ff; } +.link:hover, .link:hover a { background:#0000ff; color:#fff; } + +#footer { text-align:center; padding: 20px 0; color:#888;border-top: solid 1px #ccc;} +pre, pre.code, pre.prettyprint { margin-bottom:18px; padding:10px !important; font-size:13px; background:#fff; color:#000; font-family: monospace; border:solid 1px #afafaf; overflow-x:scroll;} +pre * { font-family: monospace; } + +.page_nav { float:right; border-right:solid 1px #ccc; } +.page_nav, .page_nav li { list-style:none; margin:0; padding:0; } +.page_nav li { float:left; } +.page_nav a { display:block; padding:6px 20px; } +.page_nav a { border:solid 1px #ccc; border-right:0; } + +@media (max-width: 960px) { + body { padding: 0 10px; } + #main { width: 100%; } + #header { border-left: none; padding: 20px; } + #sitename { text-align: center; } + #sidebar { float:none; width:100%; border: none;} + #navbar { border:solid 1px #ccc; } + #navbar ul { display: flex; justify-content: center; } + #navbar a { padding: 5px 10px; } + #content { width: 100%; float:none; margin-left:auto; } + #content_box { margin: 10px auto; border:solid 1px #ccc; padding: 10px; } + #content .tag_list, #content .date_list { text-align: center; } +} \ No newline at end of file