HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.34
System: Linux atalantini.com 3.10.0-1127.13.1.el7.x86_64 #1 SMP Tue Jun 23 15:46:38 UTC 2020 x86_64
User: root (0)
PHP: 7.2.34
Disabled: NONE
Upload Files
File: /var/www/html/www.uscornatese.it/json/homepage.php
<?php
require_once('../wp-load.php' );
global $wpdb;
$maxLastNews =  100;
$sql = "(select * from wp_posts where post_status = 'publish' and id in (select object_id from wp_term_relationships where term_taxonomy_id = 1))  order by post_date desc limit 0, " . $maxLastNews . ";";
$records = $wpdb->get_results($sql);

$values = array();
foreach ( $records as $record )  {
	$id = $record->ID;
	$date = $record->post_date;
	$pdate = explode("-", substr($date, 0, 10));
	$post_date = $pdate[2] . "-" . $pdate[1] . "-" . $pdate[0]; 
	$record->post_date = $post_date;
        $record->post_title = strip_tags(strtolower($record->post_title));
        $image = get_the_post_thumbnail_url($id);
	if ($image == "") {
		$image = "/panel.png";
	}
	$record->image = $image;
	$values[] = $record;
}
$hash = array();

$hash['primopiano'] = $values;
// ultima ora
$sql = "(select * from wp_posts where post_status = 'publish' and id in (select object_id from wp_term_relationships where term_taxonomy_id = 4)) order by post_date desc limit 0, " . $maxLastNews . ";";
$records = $wpdb->get_results($sql);

$values = array();
foreach ( $records as $record )  {
        $id = $record->ID;
        $date = $record->post_date;
        $pdate = explode("-", substr($date, 0, 10));
        $post_date = $pdate[2] . "-" . $pdate[1] . "-" . $pdate[0];
        $record->post_title = strip_tags(strtolower($record->post_title));
        $record->post_date = $post_date;
        $image = get_the_post_thumbnail_url($id);
        if ($image == "") {
                $image = "/panel.png";
        }
        $record->image = $image;
        $values[] = $record;
}
$hash['ultimaora'] = $values;

// speciali
$sql = "(select * from wp_posts where post_status = 'publish' and id in (select object_id from wp_term_relationships where term_taxonomy_id = 3)) order by post_date desc limit 0, " . $maxLastNews . ";";
$records = $wpdb->get_results($sql);
$values = array();
foreach ( $records as $record )  {
        $id = $record->ID;
        $date = $record->post_date;
        $pdate = explode("-", substr($date, 0, 10));
        $post_date = $pdate[2] . "-" . $pdate[1] . "-" . $pdate[0];
        $record->post_title = strip_tags(strtolower($record->post_title));
        $record->post_date = $post_date;
        $image = get_the_post_thumbnail_url($id);
        if ($image == "") {
                $image = "/panel.png";
        }
        $record->image = $image;
        $values[] = $record;
}
$hash['speciali'] = $values;


// topnews
$sql = "(select * from wp_posts where post_status = 'publish' and id in (select object_id from wp_term_relationships where term_taxonomy_id = 5)) order by post_date desc limit 0, " . $maxLastNews. ";";
$records = $wpdb->get_results($sql);

$values = array();
foreach ( $records as $record )  {
        $id = $record->ID;
        $date = $record->post_date;
        $pdate = explode("-", substr($date, 0, 10));
        $post_date = $pdate[2] . "-" . $pdate[1] . "-" . $pdate[0];
        $record->post_title = strip_tags(strtolower($record->post_title));
        $record->post_date = $post_date;
        $image = get_the_post_thumbnail_url($id);
        if ($image == "") {
                $image = "/panel.png";
        }
        $record->image = $image;
        $values[] = $record;
}
$hash['topnews'] = $values;

// ultime partite
$sql = "select * from wp_posts where post_status = 'publish' order by post_date desc limit 0, " . $maxLastNews . ";";
$records = $wpdb->get_results($sql);

$values = array();
foreach ( $records as $record )  {
        $id = $record->ID;
        $date = $record->post_date;
        $record->post_title = strip_tags(strtolower($record->post_title));
        $pdate = explode("-", substr($date, 0, 10));
        $post_date = $pdate[2] . "-" . $pdate[1] . "-" . $pdate[0];
        $record->post_date = $post_date;
        $image = get_the_post_thumbnail_url($id);
        if ($image == "") {
                $image = "/panel.png";
        }
        $record->image = $image;
        $values[] = $record;
}
$hash['ultimepartite'] = $values;


echo json_encode($hash);
?>