Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // define mysql connect
- $dbname = "narsisbro_xyz";
- $dbuser = "narsisbro_xyz";
- $dbpass = "TELtnVmHhXJqvk0";
- $dbhost = "localhost";
- $wp_table = "wp_posts"; // define wordpress table name
- $gmt_offset = '+7'; // +7 indonesia, -5 New York, +8 Hong Kong, etc.
- $min_days_old = 1; // tanggal awal post (terbaru)
- $max_days_old = 90; //tanggal akhir post (terlama)
- // connect to db
- mysql_connect($dbhost,$dbuser,$dbpass);
- mysql_select_db($dbname);
- $result = mysql_query("SELECT ID FROM $wp_table WHERE post_type = 'post'") or die(mysql_error());
- while ($l = mysql_fetch_array($result)) {
- $post_id = $l['ID'];
- echo "Updating: $post_id <br>";
- $day = rand($min_days_old, $max_days_old);
- $hour = rand(0, 23);
- $new_date = date( 'Y-m-d H:i:s', strtotime("-$day day -$hour hour") );
- $gmt_new_date = date( 'Y-m-d H:i:s', strtotime("-$day day -$hour hour -$gmt_offset hour") );
- mysql_query("UPDATE $wp_table SET post_date='$new_date', post_date_gmt='$gmt_new_date',
- post_modified='$new_date', post_modified_gmt='$gmt_new_date' WHERE ID='$post_id'")
- or die(mysql_error());
- }
- echo "<hr>DONE!";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement