prefix}listapdf"; $datacorrenteunix = strtotime(date('Y-m-d')); $query = "SELECT * FROM {$wpdb->prefix}listapdf"; $results = $wpdb->get_results($query); $controllo = false; $selezionesenzafine = false; foreach ($results as $result) { $dataconfrontoiniziounix = strtotime($result->data_partenza); $dataconfrontofineunix = strtotime($result->data_fine); $hafine = $result->hafine; if ($hafine){ if (!$selezionesenzafine){ if ($datacorrenteunix <= $dataconfrontofineunix){ if ($datacorrenteunix >= $dataconfrontoiniziounix){ $controllo = true; $nomefileprescelto = $result->nome_file; $urlfileprescelto = $result->url_completo; } } } } else { $controllo = true; $selezionesenzafine = true; $nomefileprescelto = $result->nome_file; $urlfileprescelto = $result->url_completo; } } if ($controllo){ $cartelle = dirname(__FILE__); $ultimacartella = basename($cartelle); $urlcomp = site_url().'/wp-content/plugins/'.$ultimacartella.'/menu/'; $finalurl = $urlcomp.$urlfileprescelto; if (!is_string($etichetta)){ $contenutohtml = generahtmlmodal($finalurl); } else { $contenutohtml = generahtmlmodalridotto($finalurl,$etichetta); } return array("nome"=>$nomefileprescelto, "url"=>$finalurl,'html'=>$contenutohtml,'controllo'=>$controllo); } else { return array ('controllo'=>$controllo); } } function generacssmodal (){ return ' '; } function generajsmodal() { return ' '; } function generahtmlmodal($filepdf){ if (controllamenu()) { $cartelle = dirname(__FILE__); $ultimacartella = basename($cartelle); $urlcomp = site_url().'/wp-content/plugins/'.$ultimacartella.'/'; return '
'; } else { return ''; } } function generahtmlmodalridotto($filepdf,$etichetta){ if (controllamenu()) { $cartelle = dirname(__FILE__); $ultimacartella = basename($cartelle); $urlcomp = site_url().'/wp-content/plugins/'.$ultimacartella.'/'; return '
'.$etichetta.'
'; } else { return ''; } } function controllamenu() { $cartelle = dirname(__FILE__); $ultimacartella = basename($cartelle); $target_dir = $_SERVER['DOCUMENT_ROOT']."/wp-content/plugins/".$ultimacartella."/"; $json_data = file_get_contents($target_dir.'settings.json'); // Decode the JSON data into a PHP associative array $settings = json_decode($json_data, true); $statomenu = false; // Controllo su stato "active" if (isset($settings['active']) && $settings['active'] === 'yes') { $statomenu= true; } return $statomenu; } function scrivisujson ($dato) { $cartelle = dirname(__FILE__); $ultimacartella = basename($cartelle); $target_dir = $_SERVER['DOCUMENT_ROOT']."/wp-content/plugins/".$ultimacartella."/"; $json_data = file_get_contents($target_dir.'settings.json'); // Decode the JSON data into a PHP associative array $settings = json_decode($json_data, true); if ($settings !== null) { $settings['active'] = $dato; // Encode the modified settings array back to JSON format $new_json_data = json_encode($settings, JSON_PRETTY_PRINT); // Write the updated JSON data back to the settings.json file file_put_contents($target_dir . 'settings.json', $new_json_data); } }