Advertisement
janter13

FIX PERMALINK POST WP DARI EXPORT MWB

Oct 29th, 2016
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.62 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. syaratnya cuman udah di export doang xmlnya, biar bisa di update
  5. ewat mysql
  6. edan sih mwb -,-, hasil import link post jadi kek eeq
  7. */
  8.  
  9. function tengah($string, $awal, $akhir){
  10. $string = " ".$string;
  11. $strings = strpos($string,$awal);
  12. if ($strings == 0) return "";
  13. $strings += strlen($awal);
  14. $antara = strpos($string,$akhir,$strings) - $strings;
  15. return substr($string,$strings,$antara);
  16. }
  17.  
  18. // ganti coker sama file cooki login mywapblogmu
  19.  
  20. function auto($url){
  21.   $curl = curl_init();
  22.   curl_setopt($curl, CURLOPT_URL,$url);
  23.   curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
  24.   curl_setopt($curl, CURLOPT_COOKIEFILE, 'coker');
  25.   $ch = curl_exec($curl);
  26.   curl_close($curl);
  27.   return($ch);
  28.   }
  29.  
  30.  
  31. // Dari wp-config
  32. $db = '';
  33. $user = '';
  34. $pass = '';
  35. $host = 'localhost';
  36.  
  37. $conn = mysql_connect($host, $user, $pass, $db);
  38. if(!$conn){
  39. die("Connection failed");
  40. }else{
  41. echo "oke";
  42. }
  43. mysql_select_db($db);
  44.  
  45. // 17 = jumlah page di link bawah itu
  46. for($i=1;$i<=17;$i++){
  47. $a = explode("<a", tengah(auto("http://www.mywapblog.com/id/manage_post.php?page_num=$i"), "<ol>", "</ol>"));
  48. foreach($a as $b){
  49. $full = tengah($b, 'href="', '</a>');
  50. if(ereg('xhtml', $full)){
  51. // ganti nijigen-kun sama domen mwbmu
  52. $ganti = array('http://www.nijigen-kun.id/', '.xhtml',);
  53. $link = str_replace($ganti, "",substr($full, 0, strpos($full, '"')));
  54. $judul = substr($full, strpos($full, '>')+1);
  55. $query = "UPDATE wp_posts SET post_name='$link' WHERE post_title='$judul'" ;
  56. $hasil = mysql_query($query);
  57. if($hasil) {
  58. echo $link.'<br>'.$judul.'<br>SUKSES<hr>';
  59. }else{
  60. echo $link.'<br>'.$judul.'<br>GAGAL<hr>';
  61. }
  62. }
  63. }
  64. }
  65.  
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement