"; $pg = $page+1; $pages = ceil($count / 10); if ($pg > 1) { $n = $pg-1; print "« "; } if ($pg < 6) { $from = 1; } else { $from = $pg-5; if ($from > 1) { print " [...] "; } } if ($pg > ($pages - 5)) { $from = $pages - 10; $to = $pages; } else { if ($pages > 9) { $to = $from+10; } else { $to = $from+$pages-1; } } if ($from < 1) { $from = 1; } for($c=$from;$c<=$to;$c++) { if ($c == $pg) {$class=' style="font-weight: bold;"';} else {$class='';} print "".($c)." "; } if ($to < $pages) { print " [...] "; } if ($pg < $pages) { $n = $pg+1; print "» "; } print "
"; } function explore_insert_post($params) { global $wpdb; $wpdb->show_errors = true; $query = "INSERT INTO $wpdb->posts (`post_author`,`post_date`,`post_date_gmt`,`post_content`,`post_title`,`post_status`,`post_parent`,`post_type`) VALUES('1','".date("Y-m-d H:i:s")."','".date("Y-m-d H:i:s")."','','New page','publish','$params','page');"; $wpdb->query($query); $insid = $wpdb->insert_id; return $insid; } function explore_it() { global $wpdb; if ($_GET['edit']) { le_it(); } else { if (isset($_POST['bulkdelete'])) { $bulk = $_POST['bulk']; foreach($bulk as $id) { $wpdb->query("DELETE FROM $wpdb->posts WHERE `ID`='$id' LIMIT 1;"); } print '

Pages deleted

'; } if (isset($_GET['delete'])) { $id = intval($_GET['delete']); $wpdb->query("DELETE FROM $wpdb->posts WHERE `ID`='$id' LIMIT 1;"); print '

Page deleted

'; } if (isset($_GET['addpage'])) { if (preg_match("/explore\.php/", $_SERVER["HTTP_REFERER"])) { $parent = intval($_GET['parent']); $newid = explore_insert_post($parent); print " "; } } print "

Pages

"; if (isset($_GET['parent'])) { $parent = intval($_GET['parent']); } else { $parent = 0; } if ($parent != 0) { $p_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE `ID`='$parent' LIMIT 1;"); } else { $p_title = "Root"; } print "

Create page in \"".$p_title."\"

"; if ($parent != 0) { $upid = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE `ID`='".$parent."' LIMIT 1 ;"); print "

↑.. (Up)

"; } $count = $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->posts WHERE `post_type`='page' AND `post_parent`='".$parent."';"); if (isset($_GET['paged'])) { $page = intval($_GET['paged']) - 1; } else { $page = 0; } if ($parent != 67) { $limit = "LIMIT ".($page*10).",10"; explore_pagination($page,$parent,$count); } $pages = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type`='page' AND `post_parent`='".$parent."' ORDER BY `ID` ASC $limit;"); print "
"; $alt_row = true; foreach((array)$pages as $page) { ?>"; print ""; print ""; print ""; print ""; print ""; print ""; } print "
 
ID
Title
Actions
".$page->ID."


"; print "
"; } } function le_it() { if (!isset($_GET['id'])) { header("Location: /wp-admin/admin.php?page=explore.php"); print ""; die(); } global $wpdb; $id = intval($_GET['id']); if (isset($_POST['set'])) { $post_title = $wpdb->prepare($_POST['post_title']); $content = $wpdb->prepare($_POST['content']); $parent_id = $wpdb->prepare($_POST['parent_id']); $wpdb->query("UPDATE $wpdb->posts SET `post_title`='$post_title',`post_content`='$content',`post_parent`='$parent_id' WHERE `ID`='$id' LIMIT 1;"); echo '

Page updated

'; } print "

Edit page

"; $post = $wpdb->get_row("SELECT post_title,post_content,post_parent FROM $wpdb->posts WHERE `ID`='$id' LIMIT 1;"); print "
post_title ) )."\" id=\"title\" autocomplete=\"off\" />
"; ?>