name = 'blog'; if ($blog) { $blog_editor->cur_data = array( 'title' => $blog['title'], 'content_md' => $blog['content_md'], 'content' => $blog['content'], 'tags' => queryBlogTags($blog['id']), 'is_hidden' => $blog['is_hidden'] ); } else { $blog_editor->cur_data = array( 'title' => $_GET['title'] ?: '新博客', 'content_md' => '', 'content' => '', 'tags' => array(), 'is_hidden' => isset($_GET['is_hidden']) ? $_GET['is_hidden'] : true, ); } if ($blog) { $blog_editor->blog_url = HTML::blog_url(UOJContext::user()['username'], "/post/{$blog['id']}"); } else { $blog_editor->blog_url = null; } function updateBlog($id, $data) { DB::update("update blogs set title = '".DB::escape($data['title'])."', content = '".DB::escape($data['content'])."', content_md = '".DB::escape($data['content_md'])."', is_hidden = {$data['is_hidden']} where id = {$id}"); } function insertBlog($data) { DB::insert("insert into blogs (title, content, content_md, poster, is_hidden, post_time) values ('".DB::escape($data['title'])."', '".DB::escape($data['content'])."', '".DB::escape($data['content_md'])."', '".Auth::id()."', {$data['is_hidden']}, now())"); } $blog_editor->save = function($data) { global $blog; $ret = array(); if ($blog) { updateBlog($blog['id'], $data); } else { insertBlog($data); $blog = array('id' => DB::insert_id(), 'tags' => array()); $ret['blog_id'] = $blog['id']; $ret['blog_write_url'] = HTML::blog_url(UOJContext::user()['username'], "/post/{$blog['id']}/write"); $ret['blog_url'] = HTML::blog_url(UOJContext::user()['username'], "/post/{$blog['id']}"); } if ($data['tags'] !== $blog['tags']) { DB::delete("delete from blogs_tags where blog_id = {$blog['id']}"); foreach ($data['tags'] as $tag) { DB::insert("insert into blogs_tags (blog_id, tag) values ({$blog['id']}, '".DB::escape($tag)."')"); } } return $ret; }; $blog_editor->runAtServer(); ?>
写博客
style="display: none" > 博客 ID:
printHTML() ?>

提示

  1. 题解发布后还需要返回对应题目的题解页面 手动输入博客 ID 来将本文添加到题目的题解列表中(博客 ID 可以在右上角找到);
  2. 请勿引用不稳定的外部资源(如来自个人服务器的图片或文档等),以便备份及后期维护;
  3. 请勿在博文中直接插入大段 HTML 代码,这可能会破坏页面的显示,可以考虑使用 转换工具 转换后再作修正;
  4. 图片上传推荐使用 S2OJ 图床,以免后续产生外链图片大量失效的情况。

帮助:UOJ 博客使用教程