Ejemplo n.º 1
0
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']) . '&amp;' : '';
    $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 . '">&#171;</a>&nbsp;';
    }
    // 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 .= '&nbsp;<a href="' . $next_mois . '">&#187;</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;
}
Ejemplo n.º 2
0
function form_fuseau_horaire($defaut)
{
    if (version_compare(PHP_VERSION, '5.2.0', '>=')) {
        $all_timezones = timezone_identifiers_list();
        $liste_fuseau = array();
        $cities = array();
        foreach ($all_timezones as $tz) {
            $spos = strpos($tz, '/');
            if ($spos !== FALSE) {
                $continent = substr($tz, 0, $spos);
                $city = substr($tz, $spos + 1);
                $liste_fuseau[$continent][] = array('tz_name' => $tz, 'city' => $city);
            }
            if ($tz == 'UTC') {
                $liste_fuseau['UTC'][] = array('tz_name' => 'UTC', 'city' => 'UTC');
            }
        }
        $form = '<label>' . $GLOBALS['lang']['pref_fuseau_horaire'] . '</label>' . "\n";
        $form .= '<select name="fuseau_horaire">' . "\n";
        foreach ($liste_fuseau as $continent => $zone) {
            $form .= "\t" . '<optgroup label="' . ucfirst(strtolower($continent)) . '">' . "\n";
            foreach ($zone as $fuseau) {
                $form .= "\t\t" . '<option value="' . htmlentities($fuseau['tz_name']) . '"';
                $form .= $defaut == $fuseau['tz_name'] ? ' selected="selected"' : '';
                $timeoffset = date_offset_get(date_create('now', timezone_open($fuseau['tz_name'])));
                $formated_toffset = '(UTC' . ($timeoffset < 0 ? '–' : '+') . str2(floor(abs($timeoffset) / 3600)) . ':' . str2(floor(abs($timeoffset) % 3600 / 60)) . ') ';
                $form .= '>' . $formated_toffset . ' ' . htmlentities($fuseau['city']) . '</option>' . "\n";
            }
            $form .= "\t" . '</optgroup>' . "\n";
        }
        $form .= '</select>' . "\n";
        return $form;
    }
}
Ejemplo n.º 3
0
function init_post_article()
{
    //no $mode : it's always admin.
    $formated_contenu = formatage_wiki(protect_markup(clean_txt($_POST['contenu'])));
    if ($GLOBALS['automatic_keywords'] == '0') {
        $keywords = htmlspecialchars(stripslashes(protect_markup(clean_txt($_POST['mots_cles']))));
    } else {
        $keywords = extraire_mots($_POST['titre'] . ' ' . $formated_contenu);
    }
    $date = str4($_POST['annee']) . str2($_POST['mois']) . str2($_POST['jour']) . str2($_POST['heure']) . str2($_POST['minutes']) . str2($_POST['secondes']);
    $id = (isset($_POST['article_id']) and preg_match('#\\d{14}#', $_POST['article_id'])) ? $_POST['article_id'] : $date;
    $article = array('bt_id' => $id, 'bt_date' => $date, 'bt_title' => htmlspecialchars(stripslashes(protect_markup(clean_txt($_POST['titre'])))), 'bt_abstract' => empty($_POST['chapo']) ? '' : formatage_wiki(protect_markup(clean_txt($_POST['chapo']))), 'bt_notes' => htmlspecialchars(stripslashes(protect_markup(clean_txt($_POST['notes'])))), 'bt_content' => $formated_contenu, 'bt_wiki_content' => stripslashes(protect_markup(clean_txt($_POST['contenu']))), 'bt_link' => '', 'bt_keywords' => $keywords, 'bt_categories' => isset($_POST['categories']) ? htmlspecialchars(traiter_tags($_POST['categories'])) : '', 'bt_statut' => $_POST['statut'], 'bt_allow_comments' => $_POST['allowcomment']);
    if (isset($_POST['ID']) and is_numeric($_POST['ID'])) {
        // ID only added on edit.
        $article['ID'] = $_POST['ID'];
    }
    return $article;
}