Advertisement
Guest User

dodol

a guest
Nov 26th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php
  2. // define mysql connect
  3. $dbname = "narsisbro_xyz";
  4. $dbuser = "narsisbro_xyz";
  5. $dbpass = "TELtnVmHhXJqvk0";
  6. $dbhost = "localhost";
  7.  
  8. $wp_table = "wp_posts"; // define wordpress table name
  9.  
  10. $gmt_offset = '+7'; // +7 indonesia, -5 New York, +8 Hong Kong, etc.
  11.  
  12. $min_days_old = 1; // tanggal awal post (terbaru)
  13. $max_days_old = 90; //tanggal akhir post (terlama)
  14.  
  15. // connect to db
  16. mysql_connect($dbhost,$dbuser,$dbpass);
  17. mysql_select_db($dbname);
  18.  
  19.  
  20. $result = mysql_query("SELECT ID FROM $wp_table WHERE post_type = 'post'") or die(mysql_error());
  21. while ($l = mysql_fetch_array($result)) {
  22. $post_id = $l['ID'];
  23. echo "Updating: $post_id <br>";
  24.  
  25. $day = rand($min_days_old, $max_days_old);
  26. $hour = rand(0, 23);
  27.  
  28. $new_date = date( 'Y-m-d H:i:s', strtotime("-$day day -$hour hour") );
  29. $gmt_new_date = date( 'Y-m-d H:i:s', strtotime("-$day day -$hour hour -$gmt_offset hour") );
  30.  
  31. mysql_query("UPDATE $wp_table SET post_date='$new_date', post_date_gmt='$gmt_new_date',
  32. post_modified='$new_date', post_modified_gmt='$gmt_new_date' WHERE ID='$post_id'")
  33. or die(mysql_error());
  34.  
  35. }
  36.  
  37. echo "<hr>DONE!";
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement