批量导出WordPress访客的名字、URL、邮箱进行回访

时间: 2010-09-27 / 分类: 博客相关 / 浏览次数: 15,344 次 / 253 个评论 发表评论

前些天在灵龙空间看到一篇很有创意的文章,教我们怎么把自己博客中访客的URL输出来,供我们访问用。小杰按照做实验了一下,感觉这个方法很不错。不过只能输出的访客的URL,没有访客的邮箱,而且访客留下的名字是以乱码问号显示的。小杰在网上找了好久还真再没有关于这个方法的文章了。小杰对mysql数据库也不怎么懂,但是还是硬着头皮去寻找解决的方法了。最后还是被攻破了。哈哈。。。

说下小杰是怎么改进灵龙的代码的吧:

  1. 修改输出访客名字是乱码问号问题
    利用这句mysql_query(“set names ‘utf8′”); ,设置php文件读取和写入mysql时使用utf8字符集,这个问题就轻松解决啦,呵呵。。。
  2. 增加输出访客邮箱功能
    在搜索查询语句和输出语句中增加这个comment_author_email,就可以输出访客的邮箱了,啊哦。。。

下面说下小杰的具体方法吧:

  1. 新建一个PHP文件命名为“export-url.php”;
  2. 在这文件中插入以下代码;
    <?php
    $conn = @mysql_connect(‘mysql_host‘, ‘mysql_user‘, ‘mysql_password‘) or die(“Datebase Could not be connected: ” . mysql_error());
    mysql_select_db(‘my_database‘);
    // 排除没有填写 URL 的数据
    mysql_query(“set names ‘utf8′”);
    $result = mysql_query(“SELECT DISTINCT comment_author_url,comment_author_email,comment_author FROM wp_comments WHERE
    comment_author_url != ” AND comment_author_url != ‘http://’”, $conn);
    while($row = mysql_fetch_array($result)) {
    echo $row["comment_author"].” “;
    echo “<a target=’_blank’ href=’”;
    echo $row["comment_author_url"];
    echo “‘>”;
    echo $row["comment_author_url"].” “;
    echo “</a>”;
    echo $row["comment_author_email"].”</br>”;
    }
    mysql_free_result($result);
    ?>
  3. 修改上面代码中的Mysql服务器地址、数据库用户名、数据库密码、Mysql数据库名字(即代码中红色标注部分,其他部分不需修改);
  4. 保存文件后上传到你空间的根目录;
  5. 访问“你网站URL/export-url.php ” 就可以看到如下这个页面啦!
    批量导出WordPress访客的名字、URL、邮箱进行回访

小杰的这个方法还很不错吧,呵呵。。。赶紧试试吧。。。不过有一点小杰还没想出怎么做,就是输出访客信息的时候,把引用通告也输出了。欢迎有什么更好的改进方法的朋友留言!大家一起交流学习吧!

***********************************************************************************************************************************************

下面是按照akasuna的建议修改过的文件(2010年10月17日更新):

更新修改的地方:

  1. spam已经排除掉了,这样页面干净多了
  2. 留言数最多的排在最前面了,方面按照留言多少访问自己的访客
01 <?php
02 $conn = @mysql_connect(‘localhost’, ‘这里改成数据库用户名’, ‘这里改成数据库用户密码’) or die(“Datebase Could not be connected: “ . mysql_error());
03 mysql_select_db(‘这里改成博客的数据库名称’);
04 // 排除没有填写 URL 的数据
05 mysql_query(“set names ‘utf8′”);
06 $result = mysql_query(“SELECT COUNT( * ) AS commentcount, comment_author_url, comment_author_email, comment_author
07 FROM wp_comments
08 WHERE comment_author_url != ”
09 AND comment_type = ”
10 AND comment_author_url != ‘http://’
11 AND comment_approved = ’1′
12 GROUP BY comment_author_url, comment_author_email, comment_author
13 ORDER BY commentcount DESC”, $conn);
14 while($row = mysql_fetch_array($result)) {
15 echo $row["comment_author"].” “;
16 echo “<a target=’_blank’ href=’”;
17 echo $row["comment_author_url"];
18 echo “‘>”;
19 echo $row["comment_author_url"].” “;
20 echo “</a>”;
21 echo $row["comment_author_email"].“</br>”;
22 }
23 mysql_free_result($result);
24 ?>

注意:

上面代码只供观看参考,请勿复制以上代码,以为我没有使用代码高亮插件,其中的引号已经转义。故如果直接复制会出现错误的,下面我提供文件下载:

批量导出WordPress访客的名字、URL、邮箱进行回访
填写您的邮件地址,订阅我们的精彩内容:

253个评论

  1. black friday sales online
    2011/11/19 20:06:06

    The case in point over is one area which i concern yourself with at the same time, how you can display your personal legitimate eagerness and talk about the belief that your product or service is useful if that’s the case.

  2. renters insurance quotes
    2011/09/24 19:09:30

    cheap auto insurance quotes…

    If you go to the net for an on the internet insurance quote, you have a excellent opportunity to find cost-effective along with essential coverage with regard to whichever your current insurance coverage needs may be….

  3. Cai
    2011/09/20 14:16:00

    支持下

  4. Accident Videos
    2011/09/16 05:44:37

    Accident Videos…

    If you want a great to watch funny accident videos then check out my site….

  5. Moncler
    2011/09/05 18:20:21

    this is really interesting blog,I love it.

  6. Moncler Outlet
    2011/09/05 18:15:18

    thanks for ur article,this is really good for us .

  7. Moncler Outlet
    2011/09/05 17:56:28

    pretty site,I will bookmark ur blog,挺好的

  8. Ugg Boots Outlet
    2011/09/05 17:52:08

    it is great to read ur article,thank you.好用;

  9. Moncler
    2011/09/05 17:49:12

    wonderful topic,thank you.谢谢

  10. Best Cinema
    2011/08/25 20:27:22

    Best Cinema…

    If you want a great review about cinemas check out this site….

  11. 小陳
    2011/08/18 00:03:40

    很使用的代码! 谢谢!

  12. [...] 我昨天在《批量导出WordPress访客的名字、URL、邮箱进行回访》一文中了解到下面的代码,你可以通过将其保存为xx.php,然后访问该文件,就可以得出一份其中包含来访者姓名、邮箱和地址的名单: [...]

  13. Yusky
    2011/07/27 01:49:42

    很实用的一个方法~

  14. 品牌顾问
    2011/07/25 18:26:31

    这个有点猛了,。呵呵

  15. 奢侈品
    2011/07/12 18:48:53

    但是还是硬着头皮去寻找解决的方法了

  16. 奢侈品免税店
    2011/07/08 18:16:15

    库也不怎么懂,但是还是硬着头皮

  17. 奢侈品免税店
    2011/07/07 21:51:05

    欧尚风奢侈品商城

  18. 老鹰训练营
    2011/07/01 18:08:32

    写成一个插件,也许更好……

  19. 奢侈品
    2011/06/29 16:37:02

    最后还是被攻破了。哈哈。。。

  20. 奢侈品
    2011/06/14 18:50:14

    对自己Z-Blog博客的优化一点记录

  21. [...] 代码来源:xiaojie [...]

  22. [...] 代码来源:xiaojie [...]

  23. 情趣用品
    2011/03/29 16:59:02

    博主辛苦了,呵呵

  24. 豆包
    2011/03/25 19:46:01

    先收藏,后研究

  25. Nike Running Shoes
    2011/01/24 14:28:29

    good

  26. 王杨德
    2011/01/11 09:50:27

    学习了*^__^*

    • 小杰
      2011/01/11 20:08:33

      谢谢支持了哦,呵呵。。。。。

  27. Zk
    2011/01/04 11:24:18

    WP无所不能!!!顶~~

    • 小杰
      2011/01/04 23:11:16

      wp是很强大啊,呵呵。。。这个程序我也很喜欢啊

  28. 小于
    2011/01/03 10:35:06

    这个方法很不错啊,等以后人多了我就试试看,你别删贴哦
    另:今天的页面访问有些不流畅啊!小于刷新了好几次才能看到啊!

    • 小杰
      2011/01/03 20:24:23

      我自己打开我的博客速度还可以啊,不是你的网速的问题吧,呵呵。。。

  29. 归臧
    2010/12/16 14:06:02

    这个方法确实不错~我通常都是直接用SQL 导出访客的邮箱和网址,其实这个方法更方便一点~

    • 小杰
      2010/12/16 16:36:01

      用这个方法不用去登录数据库了,输入网址很方便就导出来了,呵呵

  30. smilebull
    2010/12/07 21:49:03

    这个好,记录下,以后用

    • 小杰
      2010/12/07 23:19:37

      这个方法很实用,推荐你用一下,呵呵

评论分页: 1 2 3 ... 5

发表评论

您的昵称 (必填哦)

您的邮箱 (必填哦)

您的网站

5+5= (麻烦算一下吧(*^__^*) )