Feb 26

boblog评论系统回归 不指定

felix021 @ 2012-2-26 21:27 [IT » 其他] 评论(1) , 引用(0) , 阅读(7438) | Via 本站原创 | |
数据存在别人那里,总还是不太放心,再加上uyan用起来效果并没有预期那么好,所以决定回归boblog的原始评论系统。

早料到有这么一天的,不过uyan没有提供迁移评论数据的接口,只能自己动手了。

打开chrome的开发人员工具->Network,登录uyan.cc的管理首页,可以看到对 http://uyan.cc/index.php/youyan_admin/getMoreCommentsByDomain/0 的请求,也就是所有通过uyan的评论。把response拷贝出来,大概处理一下,每行一个json object这样,并根据comment_id进行排序(比如 sort -nk4 -t\" replies.php > replies_sorted.txt),然后用一个php脚本转换成对应的sql,最后通过mysql commandline的source命令导入,搞定。

p.s. 刚刚又加了几行代码到 inc/securitycode.php ,把原来的验证码改成表达式格式了,嘿嘿,希望垃圾评论会减少啦~
pps. 又加了几行代码,对评论的回复会有邮件通知啦~

php代码大致如下:
<?php

$f = file("replies_sorted.txt");

$start = 2416; //boblog_replies的repid不支持auto_increment,蛋疼

$sql = '';

foreach ($f as $line)
{
    $json = json_decode($line, true);
    $url = parse_url($json['page_url']);
    if (!isset($url['query'])) continue;
    $blog_id = $url['query'];

    $content = $json['content'];
    $content = mysql_escape_string($content);
    $name = $json['comment_author'];
    if ($name == '')
        $name = $json['show_name'];
    $name = mysql_escape_string($name);
    $sql .= <<<eot
update boblog_blogs set replies=replies+1 where blogid=$blog_id;

INSERT INTO boblog_replies
(repid, reproperty, blogid, reptime , replierid, replier , repemail, repurl, repip , repcontent , html, ubb, emot, adminrepid)
VALUES
($start, 1, $blog_id, unix_timestamp('{$json['time']}')-28800, -1, '{$name}', '{$json['comment_author_email']}', '', '{$json['IP']}', '{$json['content']}', 0, 1, 1, 0);
eot;
    $start++;
}

echo $sql;

?>




欢迎扫码关注:




转载请注明出自 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php
miuc Homepage
2012-2-27 09:22
还是比较喜欢hi表情的stupid
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   *非必须
网址   电邮   [注册]