File: /var/www/nclive/technc/add_all_page.php
<?php
include 'config.php';
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$id = $_REQUEST['id'];
$TABLE_POST = "naukri_wp_posts";
$EXAM_CATEGORY = "sp_exam_category";
$TABLE_EXAM = "sp_exam";
$TABLE_STATE = "sp_states";
$TABLE_CITY = "sp_city";
$EXAM_TYPE = "sp_exam_type";
$TABLE_KVS_NVS = "sp_kvs_navodya";
$host = $_SERVER['SERVER_NAME']; // domain for creating post page
$user_id = 1;
include('function.php'); // to make new post page
if ($id == "all-pages") {
// echo $id.' =1' ;
$post_parent = '102'; // exams id
$post_content = '[shortcode_exam_list]';
$getDataQuery = "SELECT e.exam_id, e.post_name, e.url_slug from $TABLE_EXAM as e left join $TABLE_STATE as s on s.state_id=e.state_id left join $EXAM_TYPE as t on t.type_id = e.type_id left join $EXAM_CATEGORY as c on c.cat_id = e.cat_id WHERE e.exam_id != ''";
$getData = $db->prepare($getDataQuery);
$getData->execute();
$a = 1;
while ($querydata = $getData->fetch()) {
$post_name = $querydata['url_slug'];
$post_title = $querydata['post_name'];
$exist_page = $db->prepare("SELECT count(ID) as countId FROM $TABLE_POST WHERE post_name = '" . $post_name . "' AND post_status = 'publish'");
$exist_page->execute();
$check_page = $exist_page->fetch(PDO::FETCH_ASSOC);
if ($check_page['countId'] == 0) {
if ($a <= 100) {
createPostPages($post_title, $post_content, $post_name, $user_id, $post_parent, $host);
echo '<div class="alert alert-success"><strong>Page successfully created of ' . $post_title . ' </strong></div>';
}
$a++;
}
}
}
if ($id == "nvs-kvs-page") {
// echo $id.' =2' ;
$getDataQuery = "SELECT kn.id, kn.name, kn.url_slug, kn.type from $TABLE_KVS_NVS as kn LEFT JOIN $TABLE_STATE as s on s.state_id = kn.state_id LEFT JOIN $TABLE_CITY as c on c.city_id = kn.city_id WHERE kn.id !=''";
$getData = $db->prepare($getDataQuery);
$getData->execute();
$a = 1;
while ($querydata = $getData->fetch()) {
if($querydata['type'] == 'KVS'){
$post_parent = '546'; // kvs exams id
$post_content = '[shortcode_kvs_detail]';
} else if($querydata['type'] == 'NVS'){
$post_parent = '548'; // nvs exams id
$post_content = '[shortcode_nvs_detail]';
}
$post_name = $querydata['url_slug'];
$post_title = $querydata['name'];
$exist_page = $db->prepare("SELECT count(ID) as countId FROM $TABLE_POST WHERE post_name = '" . $post_name . "' AND post_status='publish'");
$exist_page->execute();
$check_page = $exist_page->fetch(PDO::FETCH_ASSOC);
if ($check_page['countId'] == 0) {
if ($a <= 100) {
// echo $post_parent.' = '. $post_content.'<br/>';
// echo "SELECT count(ID) as countId FROM $TABLE_POST WHERE post_name = '" . $post_name . "' AND post_status='publish'" ;
createPostPages($post_title, $post_content, $post_name, $user_id, $post_parent, $host);
echo '<div class="alert alert-success"><strong>Page successfully created of ' . $post_title . ' </strong></div>';
}
$a++;
}
else{
echo '<div class="alert alert-danger"><strong>Page Not created of ' . $post_title . ' </strong></div>';
}
}
}