站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Importing From Roller
”(章节)
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
==从MySQL中导出Roller数据库== For MySQL databases, copy the following script carefully and place it in a [[WordPress:Editing_Files|text editor]] and save it with an appropriate name as a PHP file. Upload it per the instructions above to your Roller server. 对于MySQL数据库,仔细地复制下面的脚本,并且将这个脚本放置到[[WordPress:Editing_Files|文本编辑器]]并且适用适当的名称,将脚本作为PHP文件保存。根据上述的指示,将脚本上传到你的Roller服务器。 <pre> <html> <head> <title>Roller export</title> </head> <body> <? // assumes that Roller is running on MySQL // it also assumes that there is only one blog for user // the character set used by Roller is utf8, but this seems to suit at least // WordPress just fine, so no conversions done // just modify the script, store it somewhere where php execution is allowed // and wget the url // // provided by Madis Kaal <mast@nomad.ee> // $user = "yourusernameonroller"; // in entry body, all occurrencies of $oldresources are // replaced with $newresources $oldresources = "/roller/page/username/"; $newresources = "/roller/page/username/"; // define your database connection here // dbname is name of database // usually, it is on localhost // password is for accessing the db // and user is username for it $username = "dbusername"; $password = "dbpassword"; $hostname = "localhost"; $dbname = "roller"; $dbh = mysql_connect($hostname, $username, $password); $connection = mysql_select_db($dbname,$dbh); // -- this is it, no changes should be needed below ------------------------------- // get ID for user $result = mysql_query("select id from rolleruser where username='".$user."'"); $uid=mysql_result($result,0,0); // get ID for site $result = mysql_query("select id from website where userid='".$uid."'"); $siteid=mysql_result($result,0,0); // get all entries for this site $entries= mysql_query("select id,title,text,pubtime,categoryid,allowcomments,publishentry from weblogentry where websiteid='".$siteid."' order by pubtime"); // dump all entries echo "--------\n"; for($i=0; $i<(mysql_num_rows($entries)); $i++) { // turn the category ID into category name, I know SQL-heads would just // do it in query, but I'm a complete C-head $resultRow = mysql_fetch_array($entries); $c=$resultRow["categoryid"]; $cat=mysql_result(mysql_query("select name from weblogcategory where id='".$c."'"),0,0); // dump metadata first echo "PRIMARY CATEGORY: ".$cat."\n"; echo "AUTHOR: ".$user."\n"; echo "TITLE: ".$resultRow["title"]."\n"; $c=$resultRow["pubtime"]; // convert YYYY-MM-DD hh:mm:ss.ms to MM/DD/YYYY hh:mm:ss echo "DATE: ".substr($c,5,2)."/".substr($c,8,2)."/".substr($c,0,4).substr($c,10,9)."\n"; $c=$resultRow["publishentry"]; if ($c=="t") { $c="1"; } else { $c="0"; }; echo "STATUS: ".$c."\n"; $c=$resultRow["allowcomments"]; if ($c=="t") { $c="1"; } else { $c="0"; }; echo "ALLOW COMMENTS: ".$c."\n"; echo "-----\n"; // done with metadata, multiline entries follow echo "BODY:\n"; $c=str_replace($oldresources,$newresources,$resultRow["text"]); echo $c."\n"; // find comments for the entry $comments=mysql_query("select name,email,url,posttime,remotehost,content from comment where entryid='".$resultRow["id"]."'"); for ($j=0; $j<(mysql_num_rows($comments)); $j++) { $c=mysql_fetch_array($comments); // discard all comments containing url. this gets rid of spam, and also // some legimate comments as well if (strpos($c["content"],"http://")===false) { echo "-----\n"; echo "COMMENT:\n"; echo "AUTHOR: ".$c["name"]."\n"; echo "EMAIL: ".$c["email"]."\n"; echo "URL: ".$c["url"]."\n"; echo "IP: ".$c["remotehost"]."\n"; $d=$c["posttime"]; echo "DATE: ".substr($d,5,2)."/".substr($d,8,2)."/".substr($d,0,4).substr($d,10,9)."\n"; echo $c["content"]."\n"; } } echo "--------\n"; } mysql_close(); ?> </body> </html> </pre> <pre> <html> <head> <title>Roller export</title> </head> <body> <? // 假定Roller在MySQL上运行 // 假定用户只有一个博客 // Roller使用的字符集是utf8,但是似乎至少匹配 // WordPress一切顺利,不需要转变 //只要更改脚本,将脚本储存在能够运行php的位置 // 和 wget the url // // Madis Kaal mast@nomad.ee提供 // $user = "yourusernameonroller"; // 在文章主体部分, $oldresources的所有的occurrencies // 由 $newresources取代 $oldresources = "/roller/page/username/"; $newresources = "/roller/page/username/"; // 在这里定义你的数据库连接 // dbname 是数据库名 // 通常,位于本地主机 // 密码用来访问数据库 //用户是数据库用户名 $username = "dbusername"; $password = "dbpassword"; $hostname = "localhost"; $dbname = "roller"; $dbh = mysql_connect($hostname, $username, $password); $connection = mysql_select_db($dbname,$dbh); // -- 就这么大,下面不需要任何变化了 ------------------------------- // 得到用户ID $result = mysql_query("select id from rolleruser where username='".$user."'"); $uid=mysql_result($result,0,0); // 得到站点ID $result = mysql_query("select id from website where userid='".$uid."'"); $siteid=mysql_result($result,0,0); // 得到这个站点的所有文章 $entries= mysql_query("select id,title,text,pubtime,categoryid,allowcomments,publishentry from weblogentry where websiteid='".$siteid."' order by pubtime"); // dump all entries echo "--------\n"; for($i=0; $i<(mysql_num_rows($entries)); $i++) { // 将类别ID转变为类别名,我知道SQL-heads //只在查询中转变类别ID,但是我是个完成的complete C-head $resultRow = mysql_fetch_array($entries); $c=$resultRow["categoryid"]; $cat=mysql_result(mysql_query("select name from weblogcategory where id='".$c."'"),0,0); // dump metadata first echo "PRIMARY CATEGORY: ".$cat."\n"; echo "AUTHOR: ".$user."\n"; echo "TITLE: ".$resultRow["title"]."\n"; $c=$resultRow["pubtime"]; // 将YYYY-MM-DD hh:mm:ss.ms转变为 MM/DD/YYYY hh:mm:ss echo "日期: ".substr($c,5,2)."/".substr($c,8,2)."/".substr($c,0,4).substr($c,10,9)."\n"; $c=$resultRow["publishentry"]; if ($c=="t") { $c="1"; } else { $c="0"; }; echo "STATUS: ".$c."\n"; $c=$resultRow["allowcomments"]; if ($c=="t") { $c="1"; } else { $c="0"; }; echo "ALLOW COMMENTS: ".$c."\n"; echo "-----\n"; // done with metadata, multiline entries follow echo "BODY:\n"; $c=str_replace($oldresources,$newresources,$resultRow["text"]); echo $c."\n"; // 找到文章的评论 $comments=mysql_query("select name,email,url,posttime,remotehost,content from comment where entryid='".$resultRow["id"]."'"); for ($j=0; $j<(mysql_num_rows($comments)); $j++) { $c=mysql_fetch_array($comments); // 忽视所有包含url的评论。这样会去除垃圾广告,和 // 一些合法的评论 if (strpos($c["content"],"http://")===false) { echo "-----\n"; echo "COMMENT:\n"; echo "AUTHOR: ".$c["name"]."\n"; echo "EMAIL: ".$c["email"]."\n"; echo "URL: ".$c["url"]."\n"; echo "IP: ".$c["remotehost"]."\n"; $d=$c["posttime"]; echo "DATE: ".substr($d,5,2)."/".substr($d,8,2)."/".substr($d,0,4).substr($d,10,9)."\n"; echo $c["content"]."\n"; } } echo "--------\n"; } mysql_close(); ?> </body> </html> </pre>
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)