Created
October 17, 2017 08:45
-
-
Save satiridev/09ca2497048f3dc7fd628c38b28c22cc to your computer and use it in GitHub Desktop.
Check the number of post content in wordpress multiplesite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* count all blog posts | |
* blog which has most content will be suspect breach | |
*/ | |
$link = mysqli_connect("127.0.0.1", "dbuser", "dbpass", "dbname"); | |
if (!$link) { | |
echo "Connection failed \n"; | |
exit; | |
} | |
$sqlblogs = "select blog_id,domain,path from wp_blogs order by blog_id"; | |
$result = mysqli_query($link, $sqlblogs); | |
while($row = $result->fetch_object()) { | |
$blog_id = $row->blog_id; | |
$sqlCheckPostSize = "select count(*) as 'totalpost' from wp_{$blog_id}_posts where post_type='post' and post_status='publish'"; | |
$countResult = mysqli_query($link, $sqlCheckPostSize); | |
if ($countResult) { | |
$realResult = $countResult->fetch_object(); | |
echo "{$blog_id} - {$row->domain}, post number : {$realResult->totalpost} \n"; | |
} | |
} | |
mysqli_free_result($result); | |
mysqli_close($link); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment