Terima Kasih Simple XML
Alhamdulillah, puasa hari kedua sudah berhasil di jalankan. Semoga apa yang kita kerjakan tidak sia-sia dan bernilai pahala. Amiin.
Seiring dengan bertambahnya jam terbang Istri saya di blogosphere sebagai full time blogger yang membutuhkan kemudahan yang lebih, baik itu di bidang ganti theme, ujicoba plugin dan future posting dan sebagainya akhirnya memutuskan untuk pindah dari blogspot ke wordpress.
Proses migrasi itu sendiri berlangsung mulus kecuali di sisi komennya, waktu mulai ngeblog di tahun 2004 proses komen di blogspot tidak seflexibel sekarang sehingga pilihan untuk komen di handle oleh haloscan.
Lumayan sayang juga jika komen yang sudah banyak itu tidak ikut di migrasikan sehingga di putuskan untuk turut serta di migrasikan.
Googling dengan keyword ‘import haloscan’ menghasilkan petunjuk ke beberapa resources :
Resource nomer 2 diperlukan karena mo ngirit aja :-) karena cukup dengan resource nomer 1 sebenarnya cukup tapi harus bayar donasi $12 dulu.
Singkat cerita akhirnya bisa di hasilkan file export.xml dan siap di olah untuk di masukkan ke tabel wp_comments dan sekaligus mengupdate tabel wp_posts.
Di awal mau modifikasi script import_haloscan.php dari resource 1, tapi berhubung gak jalan akhirnya googling utk pelajari xml hehehehe.
Finally, ini dia script php yang menggunakan simple xml sebagai andra and thebackbone tulang punggungnya, pastikan untuk menjalankan script ini simple xml sudah ada di jajaran modul phpnya.
Bisa di intip dulu pake phpinfo() :
Berikut isi haloscan.php, script untuk import file xml berisi komentar dari haloscan :
<?php
/*
haloscan.php
created by Alamsyah Rasyid on September 02 2008
use at your own risk.
*/
mysql_connect("localhost","root","");
mysql_select_db("nike");
/*
sample content of data.php ::
*/
include 'data.php'; // put xml file here.
$xml = new SimpleXMLElement($xmlstr);
/* Looping using foreach */
foreach ($xml->comment as $comment) {
$name_author=$comment->name;
$email_author=$comment->email;
$url_author=$comment->url;
$time_author=$comment->time;
$ip_author=$comment->ip;
$comment_text=$comment->text;
//find post_id
$thid=$comment->thread;
$find_cid=mysql_query("select post_id from wp_postmeta where metavalue='$thid'");
list($post_id)=mysql_fetch_row($find_cid);
//insert into wp_comments
$que_komen=mysql_query("insert into wp_comments set comment_post_ID='$post_id',comment_author='$name_author',
comment_author_email='$email_author',comment_author_url='$url_author',comment_author_IP='$ip_author',comment_date='$time_author',
comment_date_gmt='$time_author',comment_content='$comment_text'");
//get sum of comments and update comment count
$sum_post=mysql_query("select count(comment_ID) as comment_sum from wp_comments where comment_post_ID='$post_id'");
list($sum_of_comment)=mysql_fetch_row($sum_post);
echo 'jumlah :'.$sum_of_comment.' post id: '.$post_id.'
';
$update_count=mysql_query("update wp_posts set comment_count='$sum_of_comment' where ID='$post_id'");
}
echo 'Successfully processed';
?>
Maaf, kalau berantakan :-)
Untuk versi zipnya, bisa di download di sini.
Kembali ke rsync server materi ;-)
Incoming search terms for the article:
- simpleXML
- simple xml
- apakah ada looping untuk script xml
- tambah data xml dengan php
- simple xml menggunakan
- script php pencarian data xml
- php script tuk merubah isi text yang ada dalam file xml
- menjalankan XML
- menjalankan file xml
- jalankan script xml
- how to put php in xml
- count xml data with simpleXML
- comment xml
- xml put and post in php
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.




Terima kasih sayang :)
Nikes last blog post..Pindah dari Blogspot ke WordPress
Mantep Mantep ;)
Jauharis last blog post..Karena Jogja Begitu Menggoda
top markotop!
wekekekke!
trendys last blog post..Ziarah Makam!
wahh keluarga blogger juga yah mas
mantab mas
Wah mantep om… Ini tips yang sangat membantu blogger yang mau migrasi ke wordpress. Thanks for share it om…
Adieskas last blog post..Telat Jaga Warnet
nggak salah saya mampir kesini, soalnya ada niat buat pindah ke WP. tak bookmark ya mas ???
@Nike : it’s my pleasure :-)
@trendy : itu pak Khtop :-)
@Gelandangan : iya mas :-)
@Adieska : cuman kalau ada kendala di comment mas, kl gak ada gak di pake kok :-)
@blogger insyaf : silakan mas :-)