function filtre($type, $filtre) { // cette fonction est très gourmande en ressources. $liste_des_types = array(); echo "\n" . '<select name="filtre">' . "\n"; // Articles if ($type == 'articles') { echo '<option value="">' . $GLOBALS['lang']['label_article_derniers'] . '</option>' . "\n"; $query = "SELECT DISTINCT substr(bt_date, 1, 6) AS date FROM articles ORDER BY bt_id DESC"; $tab_tags = list_all_tags('articles', FALSE); $BDD = 'sqlite'; // Commentaires } elseif ($type == 'commentaires') { echo '<option value="">' . $GLOBALS['lang']['label_comment_derniers'] . '</option>' . "\n"; $tab_auteur = nb_entries_as('commentaires', 'bt_author'); $query = "SELECT DISTINCT substr(bt_id, 1, 6) AS date FROM commentaires ORDER BY bt_id DESC"; $BDD = 'sqlite'; // Liens } elseif ($type == 'links') { echo '<option value="">' . $GLOBALS['lang']['label_link_derniers'] . '</option>' . "\n"; // $tab_auteur = nb_entries_as('links', 'bt_author'); // uncomment when readers will be able to post links $tab_tags = list_all_tags('links', FALSE); $query = "SELECT DISTINCT substr(bt_id, 1, 6) AS date FROM links ORDER BY bt_id DESC"; $BDD = 'sqlite'; // Fichiers } elseif ($type == 'fichiers') { // crée un tableau où les clé sont les types de fichiers et les valeurs, le nombre de fichiers de ce type. $files = $GLOBALS['liste_fichiers']; $tableau_mois = array(); if (!empty($files)) { foreach ($files as $id => $file) { $type = $file['bt_type']; if (!array_key_exists($type, $liste_des_types)) { $liste_des_types[$type] = 1; } else { $liste_des_types[$type]++; } } } arsort($liste_des_types); echo '<option value="">' . $GLOBALS['lang']['label_fichier_derniers'] . '</option>' . "\n"; $filtre_type = ''; $BDD = 'fichier_txt_files'; } if ($BDD == 'sqlite') { try { $req = $GLOBALS['db_handle']->prepare($query); $req->execute(array()); while ($row = $req->fetch()) { $tableau_mois[$row['date']] = mois_en_lettres(substr($row['date'], 4, 2)) . ' ' . substr($row['date'], 0, 4); } } catch (Exception $x) { die('Erreur affichage form_filtre() : ' . $x->getMessage()); } } elseif ($BDD == 'fichier_txt_files') { foreach ($GLOBALS['liste_fichiers'] as $e) { if (!empty($e['bt_id'])) { // mk array[201005] => "May 2010", uzw $tableau_mois[substr($e['bt_id'], 0, 6)] = mois_en_lettres(substr($e['bt_id'], 4, 2)) . ' ' . substr($e['bt_id'], 0, 4); } } krsort($tableau_mois); } /// BROUILLONS echo '<option value="draft"'; echo $filtre == 'draft' ? ' selected="selected"' : ''; echo '>' . $GLOBALS['lang']['label_invisibles'] . '</option>' . "\n"; /// PUBLIES echo '<option value="pub"'; echo $filtre == 'pub' ? ' selected="selected"' : ''; echo '>' . $GLOBALS['lang']['label_publies'] . '</option>' . "\n"; /// PAR DATE if (!empty($tableau_mois)) { echo '<optgroup label="' . $GLOBALS['lang']['label_date'] . '">' . "\n"; foreach ($tableau_mois as $mois => $label) { echo '<option value="' . htmlentities($mois) . '"'; echo substr($filtre, 0, 6) == $mois ? ' selected="selected"' : ''; echo '>' . $label . '</option>' . "\n"; } echo '</optgroup>' . "\n"; } /// PAR AUTEUR S'IL S'AGIT DES COMMENTAIRES OU DE LIENS if (!empty($tab_auteur)) { echo '<optgroup label="' . $GLOBALS['lang']['pref_auteur'] . '">' . "\n"; foreach ($tab_auteur as $nom) { if (!empty($nom['nb'])) { echo '<option value="auteur.' . $nom['bt_author'] . '"'; echo $filtre == 'auteur.' . $nom['bt_author'] ? ' selected="selected"' : ''; if (strlen($nom['bt_author']) > 40) { mb_internal_encoding('UTF-8'); $pseudo = mb_substr($nom['bt_author'], 0, 39) . '…'; } else { $pseudo = $nom['bt_author']; } echo '>' . $pseudo . ' (' . $nom['nb'] . ')' . '</option>' . "\n"; } } echo '</optgroup>' . "\n"; } /// PAR TYPE S'IL S'AGIT DES FICHIERS if (!empty($liste_des_types)) { echo '<optgroup label="' . 'Type' . '">' . "\n"; foreach ($liste_des_types as $type => $nb) { if (!empty($type)) { echo '<option value="type.' . $type . '"'; echo $filtre == 'type.' . $type ? ' selected="selected"' : ''; echo '>' . $type . ' (' . $nb . ')' . '</option>' . "\n"; } } echo '</optgroup>' . "\n"; } ///PAR TAGS POUR LES LIENS & ARTICLES if (!empty($tab_tags)) { echo '<optgroup label="' . 'Tags' . '">' . "\n"; foreach ($tab_tags as $tag) { echo '<option value="tag.' . $tag['tag'] . '"'; echo $filtre == 'tag.' . $tag['tag'] ? ' selected="selected"' : ''; echo '>' . $tag['tag'] . ' (' . $tag['nb'] . ')</option>' . "\n"; } echo '</optgroup>' . "\n"; } echo '</select> ' . "\n\n"; }
function afficher_calendrier() { // article if (isset($_GET['d']) and preg_match('#^\\d{4}(/\\d{2}){5}#', $_GET['d'])) { $id = substr(str_replace('/', '', $_GET['d']), 0, 14); $date = substr(get_entry($GLOBALS['db_handle'], 'articles', 'bt_date', $id, 'return'), 0, 8); $date = (preg_match('#^\\d{4}(/\\d{2}){5}#', $date) and $date <= date('Y/m/d/H/i/s')) ? $date : date('Ym'); } elseif (isset($_GET['d']) and preg_match('#^\\d{4}/\\d{2}(/\\d{2})?#', $_GET['d'])) { $date = str_replace('/', '', $_GET['d']); $date = preg_match('#^\\d{6}\\d{2}#', $date) ? substr($date, 0, 8) : substr($date, 0, 6); // avec jour ? } elseif (isset($_GET['id']) and preg_match('#^\\d{14}#', $_GET['id'])) { $date = substr($_GET['id'], 0, 8); } else { $date = date('Ym'); } $annee = substr($date, 0, 4); $ce_mois = substr($date, 4, 2); $ce_jour = strlen(substr($date, 6, 2)) == 2 ? substr($date, 6, 2) : ''; $qstring = (isset($_GET['mode']) and !empty($_GET['mode'])) ? 'mode=' . htmlspecialchars($_GET['mode']) . '&' : ''; $jours_semaine = array($GLOBALS['lang']['lu'], $GLOBALS['lang']['ma'], $GLOBALS['lang']['me'], $GLOBALS['lang']['je'], $GLOBALS['lang']['ve'], $GLOBALS['lang']['sa'], $GLOBALS['lang']['di']); $premier_jour = mktime('0', '0', '0', $ce_mois, '1', $annee); $jours_dans_mois = date('t', $premier_jour); $decalage_jour = date('w', $premier_jour - '1'); $prev_mois = basename($_SERVER['PHP_SELF']) . '?' . $qstring . 'd=' . $annee . '/' . str2($ce_mois - 1); if ($prev_mois == basename($_SERVER['PHP_SELF']) . '?' . $qstring . 'd=' . $annee . '/' . '00') { $prev_mois = basename($_SERVER['PHP_SELF']) . '?' . $qstring . 'd=' . ($annee - '1') . '/' . '12'; } $next_mois = basename($_SERVER['PHP_SELF']) . '?' . $qstring . 'd=' . $annee . '/' . str2($ce_mois + 1); if ($next_mois == basename($_SERVER['PHP_SELF']) . '?' . $qstring . 'd=' . $annee . '/' . '13') { $next_mois = basename($_SERVER['PHP_SELF']) . '?' . $qstring . 'd=' . ($annee + '1') . '/' . '01'; } // On verifie si il y a un ou des articles/liens/commentaire du jour dans le mois courant $tableau = array(); $mode = !empty($_GET['mode']) ? $_GET['mode'] : 'blog'; switch ($mode) { case 'comments': $where = 'commentaires'; break; case 'links': $where = 'links'; break; case 'blog': default: $where = 'articles'; break; } $tableau = table_list_date($annee . $ce_mois, 1, $where); $html = '<table id="calendrier">' . "\n"; $html .= '<caption>'; if ($annee . $ce_mois > $GLOBALS['date_premier_message_blog']) { $html .= '<a href="' . $prev_mois . '">«</a> '; } // Si on affiche un jour on ajoute le lien sur le mois $html .= '<a href="' . basename($_SERVER['PHP_SELF']) . '?' . $qstring . 'd=' . $annee . '/' . $ce_mois . '">' . mois_en_lettres($ce_mois) . ' ' . $annee . '</a>'; // On ne peut pas aller dans le futur if ($ce_mois != date('m') || $annee != date('Y')) { $html .= ' <a href="' . $next_mois . '">»</a>'; } $html .= '</caption>' . "\n" . '<tr>' . "\n"; if ($decalage_jour > 0) { for ($i = 0; $i < $decalage_jour; $i++) { $html .= '<td></td>'; } } // Indique le jour consulte for ($jour = 1; $jour <= $jours_dans_mois; $jour++) { if ($jour == $ce_jour) { $class = ' class="active"'; } else { $class = ''; } if (in_array($jour, $tableau)) { $lien = '<a href="' . basename($_SERVER['PHP_SELF']) . '?' . $qstring . 'd=' . $annee . '/' . $ce_mois . '/' . str2($jour) . '">' . $jour . '</a>'; } else { $lien = $jour; } $html .= '<td' . $class . '>'; $html .= $lien; $html .= '</td>'; $decalage_jour++; if ($decalage_jour == 7) { $decalage_jour = 0; $html .= '</tr>'; if ($jour < $jours_dans_mois) { $html .= '<tr>'; } } } if ($decalage_jour > 0) { for ($i = $decalage_jour; $i < 7; $i++) { $html .= '<td> </td>'; } $html .= '</tr>' . "\n"; } $html .= '</table>' . "\n"; return $html; }
function date_formate($id, $format_force = '') { $retour = ''; $date = decode_id($id); $time_article = mktime(0, 0, 0, $date['mois'], $date['jour'], $date['annee']); $auj = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $hier = mktime(0, 0, 0, date('m'), date('d') - '1', date('Y')); $jour_l = jour_en_lettres($date['jour'], $date['mois'], $date['annee']); $mois_l = mois_en_lettres($date['mois']); $format = array('0' => $date['jour'] . '/' . $date['mois'] . '/' . $date['annee'], '1' => $date['mois'] . '/' . $date['jour'] . '/' . $date['annee'], '2' => $date['jour'] . ' ' . $mois_l . ' ' . $date['annee'], '3' => $jour_l . ' ' . $date['jour'] . ' ' . $mois_l . ' ' . $date['annee'], '4' => $jour_l . ' ' . $date['jour'] . ' ' . $mois_l, '5' => $mois_l . ' ' . $date['jour'] . ', ' . $date['annee'], '6' => $jour_l . ', ' . $mois_l . ' ' . $date['jour'] . ', ' . $date['annee'], '7' => $date['annee'] . '-' . $date['mois'] . '-' . $date['jour'], '8' => substr($jour_l, 0, 3) . '. ' . $date['jour'] . ' ' . $mois_l); if ($format_force != '') { $retour = $format[$format_force]; } else { $retour = $format[$GLOBALS['format_date']]; if ($time_article == $auj) { $retour = $GLOBALS['lang']['aujourdhui'] . ', ' . $retour; } elseif ($time_article == $hier) { $retour = $GLOBALS['lang']['hier'] . ', ' . $retour; } } return ucfirst($retour); }
echo '<div class="graphique" id="commentaires"><h3>' . ucfirst($GLOBALS['lang']['label_commentaires']) . ' :</h3>' . "\n"; $table = scaled_size(get_tableau_date('commentaires'), 50); foreach ($table as $month => $data) { echo '<div class="month"><div class="month-bar" style="height: ' . $data['nb_scale'] . 'px; margin-top:' . max(20 - $data['nb_scale'], 0) . 'px"></div><a href="commentaires.php?filtre=' . $month . '"><span class="month-name">' . mois_en_lettres(substr($month, 4, 2), 1) . ' ' . substr($month, 0, 4) . ' : </span><span class="month-nb">' . nombre_commentaires($data['nb']) . '</span></a></div>'; } echo '<a href="commentaires.php" class="comm-total">Total : ' . nombre_commentaires($total_comms) . '</a>' . "\n"; echo '</div>' . "\n"; } else { $nothingyet++; } if (!$total_links == 0) { // print sur chaque div pour les liens. echo '<div class="graphique" id="links"><h3>' . ucfirst($GLOBALS['lang']['label_links']) . ' :</h3>' . "\n"; $table = scaled_size(get_tableau_date('links'), 50); foreach ($table as $month => $data) { echo '<div class="month"><div class="month-bar" style="height: ' . $data['nb_scale'] . 'px; margin-top:' . max(20 - $data['nb_scale'], 0) . 'px"></div><a href="links.php?filtre=' . $month . '"><span class="month-name">' . mois_en_lettres(substr($month, 4, 2), 1) . ' ' . substr($month, 0, 4) . ' : </span><span class="month-nb">' . nombre_liens($data['nb']) . '</span></a></div>'; } echo '<a href="links.php" class="links-total">Total : ' . nombre_liens($total_links) . '</a>' . "\n"; echo '</div>' . "\n"; } else { $nothingyet++; } echo '</div>' . "\n"; if ($nothingyet == 3) { echo ' <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADoAAABwAgMAAAAyFouxAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QMFDDAtgYm8UQAAAAxQTFRFGBEPg3ue872G////A0Y42AAAAWNJREFUOMul1KGOXDEMheFDQkLOq4WYDMmrXbIk5L6aSciQv2C222rH2YKafZYly7JsATkxr0gVdirVzk4ANA+OyeIzXTnXc93Ac9amf2jmaLdr7/W4rySfB9M7T4NPzs4N9JO3PCcSB8/Uo0vTB9vT6fmDw7T76GwM4KvfdyMWT3x0PqW9OZo+aT47NRk6OjuS7YOz36kbp2tLd0pi5yxtlAZvdmkZI7UgK2cbkiLahFk5x6BFeLNdeKadEWHmrOy0pQhvXHhLgmcLb7zfnWBSEZ443z2hQxs62CAj5+bk1AX5AUZvTkgJ8q6N1C+/3CvjtPw6rCsrQ5PGT37VR3fhvSdttOH92ud3J5s2Iv7L+oej/eyRZ88vj9I7Ph1ZGjKuDENpRD6uDJMundLDNEnUjlimRYyTH8u0WNfJsUxbGrWbWgxaRLi0JI1ckmbpTmLUf8/z5rUEuRa1U6+n+Nf8f/wL/hlQOQcLWpwAAAAASUVORK5CYII=" style="height:112px; width:58px;display:block;margin:30px auto;"> <div style=" display: inline-block; border: 2px black inset; border-radius: 4px;"><div style="text-align: left;border: 1px white solid; border-radius: 4px;"><div style="border: 1px black inset; padding: 3px 5px; letter-spacing: 2px;">No data yet . . .<br/> Why not write <a href="ecrire.php" style="color: inherit">something</a> ? </div></div></div> ';
echo '<div class="month"><div class="month-bar" style="height: ' . $data['nb_scale'] . 'px; margin-top:' . max(20 - $data['nb_scale'], 0) . 'px"></div><span class="month-nb">' . $data['nb'] . '</span><a href="commentaires.php?filtre=' . $data['date'] . '"><span class="month-name">' . mb_substr(mois_en_lettres(substr($data['date'], 4, 2)), 0, 3) . "\n" . substr($data['date'], 2, 2) . '</span></a></div>'; } echo '</div>' . "\n"; } else { $nothingyet++; } if (!$total_links == 0) { // print sur chaque div pour les liens. echo '<p>' . ucfirst($GLOBALS['lang']['label_links']) . ' :</p>' . "\n"; echo '<div class="graphique" id="links">' . "\n"; $table = scaled_size(get_tableau_date('links'), 150); while ($table[0]['nb'] === 0) { $first = array_shift($table); } foreach ($table as $i => $data) { echo '<div class="month"><div class="month-bar" style="height: ' . $data['nb_scale'] . 'px; margin-top:' . max(20 - $data['nb_scale'], 0) . 'px"></div><span class="month-nb">' . $data['nb'] . '</span><a href="links.php?filtre=' . $data['date'] . '"><span class="month-name">' . mb_substr(mois_en_lettres(substr($data['date'], 4, 2)), 0, 3) . ".\n" . substr($data['date'], 2, 2) . '</span></a></div>'; } echo '</div>' . "\n"; } else { $nothingyet++; } echo '</div>' . "\n"; if ($nothingyet == 3) { echo ' <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADoAAABwAgMAAAAyFouxAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QMFDDAtgYm8UQAAAAxQTFRFGBEPg3ue872G////A0Y42AAAAWNJREFUOMul1KGOXDEMheFDQkLOq4WYDMmrXbIk5L6aSciQv2C222rH2YKafZYly7JsATkxr0gVdirVzk4ANA+OyeIzXTnXc93Ac9amf2jmaLdr7/W4rySfB9M7T4NPzs4N9JO3PCcSB8/Uo0vTB9vT6fmDw7T76GwM4KvfdyMWT3x0PqW9OZo+aT47NRk6OjuS7YOz36kbp2tLd0pi5yxtlAZvdmkZI7UgK2cbkiLahFk5x6BFeLNdeKadEWHmrOy0pQhvXHhLgmcLb7zfnWBSEZ443z2hQxs62CAj5+bk1AX5AUZvTkgJ8q6N1C+/3CvjtPw6rCsrQ5PGT37VR3fhvSdttOH92ud3J5s2Iv7L+oej/eyRZ88vj9I7Ph1ZGjKuDENpRD6uDJMundLDNEnUjlimRYyTH8u0WNfJsUxbGrWbWgxaRLi0JI1ckmbpTmLUf8/z5rUEuRa1U6+n+Nf8f/wL/hlQOQcLWpwAAAAASUVORK5CYII=" style="height:112px; width:58px;display:block;margin:30px auto;"> <div style=" display: inline-block; border: 2px black inset; border-radius: 4px;"><div style="text-align: left;border: 1px white solid; border-radius: 4px;"><div style="border: 1px black inset; padding: 3px 5px; letter-spacing: 2px;">No data yet . . .<br/> Why not write <a href="ecrire.php" style="color: inherit">something</a> ? </div></div></div> '; }