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/corepla/import_mappe.php
<?php 
require_once( '/var/www/html/corepla/wp-load.php' ); 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

$mappe = array();
$mappe[] = "";
$mappe[] = "CSS";
$mappe[] = "CDR";
$mappe[] = "Riciclo Imprese";
$mappe[] = "ECP";
$mappe[] = "Clienti";
$mappe[] = "Comuni";
$mappe[] = "CC";
$mappe[] = "CSS";
$mappe[] = "RIC";

$entity_id = array();
$infografica = array();
$rows =  $wpdb->get_results( "select * from corepla_mappe" , ARRAY_A);
foreach($rows as $row){
	$new_post = array(
		'post_title' => $row['titolo'],
		'post_content' => $row['note'],
		'post_status' => 'publish',
		'post_date' => date('Y-m-d H:i:s'),
		'post_author' => 1,
		'post_type' => 'punto-su-mappa'
	);
	$post_id = wp_insert_post($new_post);
	add_post_meta($post_id, 'tipo_mappa', $mappe[$row['tipo_mappa']]);
	add_post_meta($post_id, 'indirizzo', $row['indirizzo']);
	add_post_meta($post_id, 'latitudine', $row['latitudine']);
	add_post_meta($post_id, 'longitudine', $row['longitudine']);
        add_post_meta($post_id, 'modifica_manuale', 1);
	add_post_meta($post_id, 'note', $row['note']);
	add_post_meta($post_id, 'chiave_mappa', $row['tipo_mappa']);
	if ($mappe[$row['tipo_mappa']] == "CSS") {
	        add_post_meta($post_id, 'tipo_punto_css', 'Normale');
	}	
	$tipo_punto = "";
	if ($row['tipo_punto'] == "1") {
		
	}
        $tipo_punto = "";
        if ($row['tipo_punto'] == "1") {
        	$tipo_punto = "PEPS";
        }
        if ($row['tipo_punto'] == "2") {
        	$tipo_punto = "PIA";
        }
        if ($row['tipo_punto'] == "3") {
        	$tipo_punto = "PIFU";
        }
        add_post_meta($post_id, 'tipo_punto_riciclo_imprese', $tipo_punto);
}
echo "done";
?>