예제 #1
0
function form_categories_links($where, $tags_post)
{
    $tags = list_all_tags($where, FALSE);
    $html = '';
    if (!empty($tags)) {
        $html = '<datalist id="htmlListTags">' . "\n";
        foreach ($tags as $i => $tag) {
            $html .= "\t" . '<option value="' . addslashes($tag['tag']) . '">' . "\n";
        }
        $html .= '</datalist>' . "\n";
    }
    $html .= '<ul id="selected">' . "\n";
    $list_tags = explode(',', $tags_post);
    // remove diacritics, so that "ééé" does not passe after "zzz" and reindexes
    foreach ($list_tags as $i => $tag) {
        $list_tags[$i] = array('t' => trim($tag), 'tt' => diacritique(trim($tag), FALSE, FALSE));
    }
    $list_tags = array_reverse(tri_selon_sous_cle($list_tags, 'tt'));
    foreach ($list_tags as $i => $tag) {
        $list_tags[$i] = $tag['t'];
    }
    foreach ($list_tags as $mytag => $mtag) {
        if (!empty($mtag)) {
            $html .= "\t" . '<li><span>' . trim($mtag) . '</span><a href="javascript:void(0)" onclick="removeTag(this.parentNode)">×</a></li>' . "\n";
        }
    }
    $html .= '</ul>' . "\n";
    return $html;
}
예제 #2
0
파일: conv.php 프로젝트: CamTosh/blogotext
function titre_url($url)
{
    $url = diacritique($url, 0, 0);
    $url = trim($url, '-');
    return $url;
}
예제 #3
0
파일: html.php 프로젝트: CamTosh/blogotext
function liste_tags($billet, $html_link)
{
    $tags = $billet['bt_type'] == 'article' ? $billet['bt_categories'] : $billet['bt_tags'];
    $mode = $billet['bt_type'] == 'article' ? '' : '&amp;mode=links';
    if (!empty($tags)) {
        $tag_list = explode(', ', $tags);
        // remove diacritics, so that "ééé" does not passe after "zzz" and re-indexes
        foreach ($tag_list as $i => $tag) {
            $tag_list[$i] = array('t' => trim($tag), 'tt' => diacritique(trim($tag), FALSE, FALSE));
        }
        $tag_list = array_reverse(tri_selon_sous_cle($tag_list, 'tt'));
        foreach ($tag_list as $i => $tag) {
            $tag_list[$i] = $tag['t'];
        }
        $nb_tags = sizeof($tag_list);
        $liste = '';
        if ($html_link == 1) {
            foreach ($tag_list as $tag) {
                $tag = trim($tag);
                $tagurl = urlencode($tag);
                $liste .= '<a href="' . basename($_SERVER['PHP_SELF']) . '?tag=' . $tagurl . $mode . '" rel="tag">' . $tag . '</a>';
            }
        } else {
            foreach ($tag_list as $tag) {
                $tag = trim($tag);
                $tag = diacritique($tag, 0, 0);
            }
        }
    } else {
        $liste = '';
    }
    return $liste;
}
예제 #4
0
파일: imgs.php 프로젝트: CamTosh/blogotext
function init_post_fichier()
{
    //no $mode : it's always admin.
    // on edit : get file info from form
    if (isset($_POST['is_it_edit']) and $_POST['is_it_edit'] == 'yes') {
        $file_id = htmlspecialchars($_POST['file_id']);
        $filename = pathinfo(htmlspecialchars($_POST['filename']), PATHINFO_FILENAME);
        $ext = strtolower(pathinfo(htmlspecialchars($_POST['filename']), PATHINFO_EXTENSION));
        $checksum = htmlspecialchars($_POST['sha1_file']);
        $size = htmlspecialchars($_POST['filesize']);
        $type = detection_type_fichier($ext);
        $dossier = htmlspecialchars($_POST['dossier']);
        $path = htmlspecialchars($_POST['path']);
        // on new post, get info from the file itself
    } else {
        $file_id = date('YmdHis');
        $dossier = htmlspecialchars($_POST['dossier']);
        // ajout de fichier par upload
        if (!empty($_FILES['fichier']) and $_FILES['fichier']['error'] == 0) {
            $filename = pathinfo($_FILES['fichier']['name'], PATHINFO_FILENAME);
            $ext = strtolower(pathinfo($_FILES['fichier']['name'], PATHINFO_EXTENSION));
            $checksum = sha1_file($_FILES['fichier']['tmp_name']);
            $size = $_FILES['fichier']['size'];
            $type = detection_type_fichier($ext);
            $path = '';
            // ajout par une URL d’un fichier distant
        } elseif (!empty($_POST['fichier'])) {
            $filename = pathinfo(parse_url($_POST['fichier'], PHP_URL_PATH), PATHINFO_FILENAME);
            $ext = strtolower(pathinfo(parse_url($_POST['fichier'], PHP_URL_PATH), PATHINFO_EXTENSION));
            $checksum = sha1_file($_POST['fichier']);
            // works with URL files
            $size = '';
            // same (even if we could use "filesize" with the URL, it would over-use data-transfer)
            $path = '';
            $type = detection_type_fichier($ext);
        } else {
            // ERROR
            redirection(basename($_SERVER['PHP_SELF']) . '?errmsg=error_image_add');
            return FALSE;
        }
    }
    // nom du fichier : si nom donné, sinon nom du fichier inchangé
    $filename = diacritique(htmlspecialchars(!empty($_POST['nom_entree']) ? $_POST['nom_entree'] : $filename), '', '0') . '.' . $ext;
    $statut = (isset($_POST['statut']) and $_POST['statut'] == 'on') ? '0' : '1';
    $fichier = array('bt_id' => $file_id, 'bt_type' => $type, 'bt_fileext' => $ext, 'bt_filesize' => $size, 'bt_filename' => $filename, 'bt_content' => stripslashes(protect_markup(clean_txt($_POST['description']))), 'bt_wiki_content' => stripslashes(protect_markup(clean_txt($_POST['description']))), 'bt_checksum' => $checksum, 'bt_statut' => $statut, 'bt_dossier' => empty($dossier) ? 'default' : $dossier, 'bt_path' => empty($path) ? '/' . substr($checksum, 0, 2) : $path);
    return $fichier;
}