Example #1
0
 function readContent()
 {
     $data = read_xml_file($this->server, $this->port, $this->url);
     if (strlen($data) > 0) {
         $dom = new domDocument();
         $dom->loadXML(substr($data, 0, strrpos($data, '>') + 1));
         $arrFeeds = array();
         $count = 0;
         foreach ($dom->getElementsByTagName('item') as $node) {
             if (function_exists('date_parse')) {
                 $date_raw = date_parse($node->getElementsByTagName('pubDate')->item(0)->nodeValue);
                 //$date = date('H:i j.m.Y', mktime($date_raw['hour'], $date_raw['minute'], $date_raw['second'], $date_raw['month'], $date_raw['day'], $date_raw['year']));
                 $date = date('j.m', mktime($date_raw['hour'], $date_raw['minute'], $date_raw['second'], $date_raw['month'], $date_raw['day'], $date_raw['year']));
             } else {
                 $date1 = explode(' ', $node->getElementsByTagName('pubDate')->item(0)->nodeValue);
                 $months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
                 $months_n = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
                 $time = explode(':', $date1[4]);
                 //$date = $time[0] . ':' . $time[1] . ' ' . intval($date1[1]) . '.' . str_replace($months, $months_n, $date1[2]) . '.' . $date1[3];
                 $date = intval($date1[1]) . '.' . str_replace($months, $months_n, $date1[2]);
             }
             $itemRSS = array('title' => mb_convert_case(!$this->decodeUTF ? utf8_decode($node->getElementsByTagName('title')->item(0)->nodeValue) : $node->getElementsByTagName('title')->item(0)->nodeValue, MB_CASE_UPPER, "UTF-8"), 'description' => substr(!$this->decodeUTF ? utf8_decode($node->getElementsByTagName('description')->item(0)->nodeValue) : $node->getElementsByTagName('description')->item(0)->nodeValue, 0, 60), 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue);
             $itemRSS['date'] = $date;
             array_push($arrFeeds, $itemRSS);
             $count++;
             if ($count == $this->nr_of_posts) {
                 break;
             }
         }
         return $arrFeeds;
     }
     return null;
 }
Example #2
0
function download_lmb_files()
{
    global $local_install_dir;
    global $distant_install_ftp;
    global $distant_install_ftp_files;
    global $xml_liste_fichiers;
    global $total_size;
    // Connexion au serveur FTP
    $ftp_id_connect = connect_ftp();
    // Téléchargement du fichier XML et chronométrage pour obtenir un délai estimé
    set_time_limit(300);
    $debut_download = microtime(true);
    if (!ftp_get($ftp_id_connect, $local_install_dir . $xml_liste_fichiers, $distant_install_ftp . $xml_liste_fichiers, FTP_BINARY)) {
        $error = "Impossible de récupérer la liste des fichiers d'installation. (Fichier XML).<br /> Essayez l'installation manuelle.<br />\r\n\t\t\t\tPour plus de renseignement: <br />\r\n\t\t\t\t<a href='http://www.lundimatin.fr/site/forum/viewtopic.php?f=3&t=14' target='_blank'>\r\n\t\t\t\t\thttp://www.lundimatin.fr/site/forum/viewtopic.php?f=3&t=14</a>";
        erreur($error);
    }
    $fin_download = microtime(true);
    $downloaded = filesize($local_install_dir . $xml_liste_fichiers);
    // Lecture de ce fichier
    $xml_infos = read_xml_file();
    // Inscription des informations sur l'état du téléchargement
    $total_size = $xml_infos['install_infos'][0]['TOTAL_SIZE'];
    make_download_state(0, 0, $fin_download);
    // Création de l'arborescence des répertoires
    $dir_list = $xml_infos['install_dirs'];
    foreach ($dir_list as $dir) {
        @mkdir($dir['SRC']);
    }
    // Téléchargement des fichiers 1 à 1
    $files_list = $xml_infos['install_files'];
    foreach ($files_list as $file) {
        set_time_limit(300);
        // Téléchargement du fichier
        ftp_get($ftp_id_connect, "./" . $file['SRC'], $distant_install_ftp_files . $file['SRC'], FTP_BINARY);
        // Inscription des informations sur l'état du téléchargement
        $downloaded += filesize("./" . $file['SRC']);
        make_download_state($downloaded, $file['ID']);
    }
    //Fin du téléchargement des fichiers
    //Vérification au moins une fois du bon téléchargement des fichiers
    foreach ($files_list as $file) {
        set_time_limit(300);
        //le fichier
        if (!file_exists("./" . $file['SRC'])) {
            // Téléchargement du fichier
            ftp_get($ftp_id_connect, "./" . $file['SRC'], $distant_install_ftp_files . $file['SRC'], FTP_BINARY);
        }
    }
    //relance de la vérification
    $liste_missing_files = array();
    foreach ($files_list as $file) {
        set_time_limit(300);
        //le fichier
        if (!file_exists("./" . $file['SRC'])) {
            $liste_missing_files[] = $file['SRC'];
        }
    }
    if (count($liste_missing_files)) {
        $error = "Les fichiers suivants n'ont pas étés téléchargés <br />\r\n\t\t     <span id='view_rapport' style='cursor: pointer;' onClick='javascript:document.getElementById(\"view_missing_files\").style.display=\"\";' >Voir les fichiers manquants</span>\r\n\t\t\t\t <div id='view_missing_files' style='display: none'>(" . implode(", ", $liste_missing_files) . ")</div>.<br /> Essayez l'installation manuelle.<br />\r\n\t\t\t\tPour plus de renseignement: <br />\r\n\t\t\t\t<a href='http://www.lundimatin.fr/site/forum/viewtopic.php?f=3&t=14' target='_blank'>\r\n\t\t\t\t\thttp://www.lundimatin.fr/site/forum/viewtopic.php?f=3&t=14</a>";
        erreur($error);
    }
    return true;
}
Example #3
0
        print_r($sql_screenings);
        echo '<div style="margin-top: 4px; border-bottom: 1px solid grey;"></div>';
        echo '<strong>$sql_cinemas:</strong><br /><br />';
        print_r($sql_cinemas);
        echo '<div style="margin-top: 4px; border-bottom: 1px solid grey;"></div>';
    }
    if (strlen($sql_screenings) > 0) {
        truncate_tables(array('newcms2_catalog_product_screenings', 'newcms2_catalog_product_cinemas'));
        perform_queries(array($sql_screenings, $sql_cinemas));
    } else {
        echo 'Päring <em>$sql_screenings</em> oli tühi.<br />Tabelit `<em>newcms2_catalog_product_screenings</em>` ei tühjendatud.<br />Salvestamise päringut ei sooritatud.<br /><br />';
    }
} elseif ($mode == 'all') {
    echo 'Valitud režiim: kogu info<br /><br />';
    foreach ($url_list as $key => $url) {
        $data = read_xml_file($host, $port, $url);
        if ($data) {
            $dom[$key] = new domDocument();
            $dom[$key]->loadXML($data);
            if (!$dom[$key]) {
                echo '<span style="font-weight: bold; color: red;">Tekkis viga XML\'i parsimisel. [' . $key . ']</span>';
                exit;
            }
        } else {
            echo '<span style="font-weight: bold; color: red;">Ühenduse loomine ebaõnnestus. Info vastuvõtmine ebaõnnestus. [' . $key . ']</span>';
            exit;
        }
    }
    foreach ($dom as $key => $d) {
        $imports[$key] = @simplexml2array(simplexml_import_dom($d));
    }