Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define ('WP_USE_THEMES',false);
- require('../wp-load.php');
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- header('Content-type:text/html; charset=utf-8');
- global $wpdb;
- $wpdb->show_errors();
- $rez = $wpdb->get_results(
- 'select count(*), a.post_type, d.taxonomy, e.name, max(a.post_date)
- from wp_posts a left outer join wp_term_relationships b on
- a.id=b.object_id left outer join wp_term_taxonomy d on
- b.term_taxonomy_id=d.term_taxonomy_id
- left outer join wp_terms e on d.term_id=e.term_id
- group by a.post_type, d.taxonomy, e.name order by a.post_type, d.taxonomy, e.name
- ', ARRAY_N);
- foreach ($rez as $row) {
- echo date('d.m.Y',strtotime($row[4])).' '.$row[1].' '.$row[2].' '.$row[3].' - '.$row[0].'<br/>';
- }
- ?>
- <?php
- //--------------------------------------------------------------------
- define ('WP_USE_THEMES',false);
- require('../wp-load.php');
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- header('Content-type:text/html; charset=utf-8');
- session_start();
- $step = isset($_SESSION['step']) && isset($_GET['step']) ? $_SESSION['step'] : 0;
- if (!isset($_GET['step']))
- $_SESSION['zdate'] = strtotime('2013-6-5');
- $q = new WP_Query(array('post_type'=>'digest', 'offset'=>$step*10, 'posts_per_page'=>10,
- 'orderby'=>'date', 'order'=>'DESC'));
- while ($q->have_posts()) {
- $q->the_post();
- echo get_the_id().' '.get_the_title().' '.get_the_date('d.m.Y H:i',get_the_id()).'<br/>';
- if (strtotime(get_the_date('Y-m-d',get_the_id()))==$_SESSION['zdate']) {
- echo 'date get<br/>';
- $_SESSION['zdate'] = $_SESSION['zdate']-20*24*3600;
- wp_set_object_terms(get_the_id(), 'primary_dir', 'direction');
- }
- else {
- delete_all(get_the_id());
- }
- //$inf = get_term_by('slug','primary_dir','direction');
- //$inf = $inf->term_id;
- }
- //---------------------------
- function delete_all($pid) {
- $imgs = array();
- $pids = array();
- if (has_post_thumbnail($pid)) {
- $tid = get_post_thumbnail_id($pid);
- $pids[] = $tid;
- }
- foreach (array('thumbnail','medium','large','full') as $size) {
- $imgs[] = reset(wp_get_attachment_image_src($tid, $size));
- }
- $imgs[] = wp_get_attachment_thumb_url($tid);
- $att = & get_children(array('post_type'=>'attachment','post_parent'=>$pid));
- foreach ($att as $attt) {
- $pids[] = $attt->ID;
- $imgs[] = get_attached_file($attt->ID);
- foreach (array('thumbnail','medium','large','full') as $size) {
- $imgs[] = reset(wp_get_attachment_image_src($attt->ID,$size));
- }
- }
- $pids = array_unique($pids);
- $imgs = array_unique($imgs);
- echo '<pre>'.print_r($imgs,true).print_r($pids,true).'</pre>';
- foreach ($pids as $pidz) {
- wp_delete_post($pidz, true);
- }
- wp_delete_post($pid, true);
- }
- echo '<br/><br/>current step: '.$step;
- echo '<br/>date: '.date('d.m.Y', $_SESSION['zdate']);
- $step++;
- $_SESSION['step'] = $step;
- ?>
- <div id="countz"></div>
- <script type="text/javascript">
- window.onload = function () {
- var tm= 5;
- var zz = setInterval( function() {
- var uu = document.getElementById('countz');
- uu.innerHTML = 'reload after '+tm+ ' s';
- tm--;
- if (tm==0) {
- clearInterval(zz);
- location.replace('<?php echo $_SERVER['PHP_SELF'].'?step';?>');
- }
- } , 1000)
- }
- </script>
- <?php
- //----------------------------------------------
- define ('WP_USE_THEMES',false);
- require('../wp-load.php');
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- header('Content-type:text/html; charset=utf-8');
- global $wpdb;
- $rez = $wpdb->get_results('select count(*), post_type from wp_posts group by post_type', ARRAY_N);
- foreach ($rez as $row) {
- echo $row[1].' '.$row[0].'<br/>';
- }
- ?>
- <?php
- //----------------------------------------------
- define ('WP_USE_THEMES',false);
- require('../wp-load.php');
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- header('Content-type:text/html; charset=utf-8');
- $args = array('posts_per_page'=>10, 'orderby'=>'modified', 'order'=>'DESC','post_type'=>'digest');
- $posts = get_posts($args);
- foreach ($posts as $el) {
- if (has_post_thumbnail($el->ID)) {
- $img = get_post_thumbnail_id($el->ID, 'thumbnail');
- }
- $category = get_the_category($el->ID);
- echo $el->ID.' '.$el->post_title.' '.$el->post_modified.' '.$category[0]->name.'<br/>';
- }
- ?>
- <?php
- //----------------------------------------------
- define ('WP_USE_THEMES',false);
- require('../wp-load.php');
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- header('Content-type:text/html; charset=utf-8');
- get_cats(0);
- function get_cats($parent) {
- $cats = get_categories('hide_empty=0&parent='.$parent);
- if (count($cats)==0)
- return;
- echo '<div style="margin-left:50px;">';
- foreach ($cats as $el) {
- echo $el->term_id.' '.$el->name.' '.$el->slug.' '.$el->count.'<br/>';
- get_cats($el->term_id);
- }
- echo '</div>';
- }
- ?>
- <?php
- //----------------------------------------------
- define ('WP_USE_THEMES',false);
- require('../wp-load.php');
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- header('Content-type:text/html; charset=utf-8');
- session_start();
- $step = (isset($_SESSION['step'])) ? $_SESSION['step'] : 0;
- $args = array('posts_per_page'=>10, 'offset'=>$step*10);
- $posts = get_posts($args);
- if (count($posts)==0)
- break;
- foreach ($posts as $el) {
- echo $el->ID.' '.$el->ping_status.'<br/>';
- if ($el->ping_status=='open') {
- wp_update_post(array('ID'=>$el->ID, 'ping_status'=>'closed'));
- echo '*** '.$el->ID.' '.$el->post_title.' '.$el->ping_status.'<br/>';
- }
- }
- echo '</table>';
- echo 'current step '.$step.'<br/>';
- $_SESSION['step']=$step+1;
- ?>
- <div id="counterr"></div>
- <script type="text/javascript">
- window.onload = function() {
- var cnt=5;
- var zz = setInterval( function() {
- var uu = document.getElementById('counterr');
- uu.innerHTML = 'reload after '+cnt+' s';
- cnt--;
- if (cnt==0) {
- clearInterval(zz);
- location.replace(location.href);
- }
- }, 1000)
- }
- </script>
- <?php
- //----------------------------------------------
- define ('WP_USE_THEMES',false);
- require('../wp-load.php');
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- header('Content-type:text/html; charset=utf-8');
- echo '<table style="border:solid 1px;"><tr><td>post</td><td>link</td><td>parent</td><td>meta</td>
- <td>date</td><td>start</td>
- </tr>';
- for ($i=0; $i<1000; $i++) {
- $args = array('posts_per_page'=>10, 'offset'=>$i*10, 'post_type'=>'attachment');
- $posts = get_posts($args);
- if (count($posts)==0)
- break;
- foreach ($posts as $el) {
- echo '<tr>';
- echo '<td style="border: solid 1px;">'.$el->ID.' '.$el->post_title.'</td>';
- $link = wp_get_attachment_image_src($el->ID,'full');
- echo '<td>'.$link[0].'</td>';
- $parent = get_post_ancestors($el->ID,false);
- echo '<td>'.$parent[0].'</td>';
- echo '<td></td></tr>';
- }
- }
- echo '</table>';
- ?>
- <?php
- //----------------------------------------------
- define ('WP_USE_THEMES',false);
- require('../wp-load.php');
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- header('Content-type:text/html; charset=utf-8');
- for ($i=0; $i<1000; $i++) {
- $args = array('posts_per_page'=>10, 'offset'=>$i*10);
- $posts = get_posts($args);
- if (count($posts)==0)
- break;
- echo '<table><tr><td>post</td><td>categories</td><td>tags</td><td>meta</td></tr>';
- foreach ($posts as $el) {
- echo '<tr><td>'.$el->ID.' '.$el->post_title.'</td>';
- $cats = get_the_category($el->ID);
- foreach ($cats as $key=>$cat) {
- $cats[$key] = $cat->name;
- }
- echo '<td>'.implode(',', $cats).'</td>';
- $tags = get_the_tags($el->ID);
- $f = create_function('$a','return $a->name;');
- if (!is_array($tags))
- $tags = array();
- $tags = array_map($f, $tags);
- echo '<td>'.implode(',', $tags).'</td>';
- echo '<td></td>';
- echo '</tr>';
- }
- echo '</table>';
- }
- ?>
- <?php
- //----------------------------------------------
- define ('WP_USE_THEMES',false);
- require('../wp-load.php');
- ini_set('display_errors',1);
- error_reporting(E_ALL);
- $arr = array();
- for ($i=0; $i<100; $i++) {
- $args = array('posts_per_page'=>10, 'offset'=>$i*10);
- echo $i.' - ';
- $posts = get_posts($args);
- if (count($posts)==0)
- break;
- foreach ($posts as $el) {
- if ($el->comment_count>0 ) {
- $arr[] = $el;
- }
- }
- }
- echo '<br/>';
- $urls = array();
- ob_start();
- while (list($key,$val) = each($arr)) {
- echo $val->ID.' '.$val->post_title.' '.$val->comment_count.'<br/><br/>';
- $args = array('post_id'=>$val->ID);
- $comm = get_comments($args);
- echo '<table><tr><th>id</th><th>author</th><th>email</th><th>comm</th><th>type</th>'.
- '<th>date</th><th>userid</th></tr>';
- foreach ($comm as $el) {
- echo '<tr><td>'.$el->comment_ID.'</td><td>'.$el->comment_author.
- '</td><td>'.$el->comment_author_url.'</td><td>'.
- $el->comment_content.'</td><td>'.$el->comment_type.'</td><td>'.
- $el->comment_date.'</td><td>'.$el->user_id.'</td></tr>';
- $urls[] = $el->comment_author_url;
- }
- echo '</table>';
- }
- $tabb = ob_get_clean();
- $urls = (array_count_values($urls));
- arsort($urls);
- ob_start();
- echo '<table><tr><td>url</td><td>count</td></tr>';
- foreach ($urls as $key=>$value) {
- echo '<tr><td>'.$key.'</td><td>'.$value.'</td></tr>';
- }
- echo '</table>';
- $tabb4 = ob_get_clean();
- $urls = array_keys($urls);
- $urls = array_map('zzz', $urls);
- function zzz($a) {
- return str_replace(strstr(substr(strstr($a,'//'),2),'/'),'',$a);
- }
- //$urls = array_values(array_unique($urls));
- $urls = array_count_values ($urls);
- arsort($urls);
- while (list($key,$val) = each($urls)) {
- echo $key.' '.$val.'<br/>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement