function traiter_form_rssconf() { $msg_param_to_trim = isset($_GET['msg']) ? '&msg=' . $_GET['msg'] : ''; $query_string = str_replace($msg_param_to_trim, '', $_SERVER['QUERY_STRING']); // traitement $GLOBALS['db_handle']->beginTransaction(); foreach ($GLOBALS['liste_flux'] as $i => $feed) { if (isset($_POST['i_' . $feed['checksum']])) { // feed marked to be removed if ($_POST['k_' . $feed['checksum']] == 0) { unset($GLOBALS['liste_flux'][$i]); try { $req = $GLOBALS['db_handle']->prepare('DELETE FROM rss WHERE bt_feed=?'); $req->execute(array($feed['link'])); } catch (Exception $e) { die('Error : Rss?conf RM-from db: ' . $e->getMessage()); } } else { // title has change $GLOBALS['liste_flux'][$i]['title'] = $_POST['i_' . $feed['checksum']]; // folder has changed : update & change folder where it must be changed if ($GLOBALS['liste_flux'][$i]['folder'] != $_POST['l_' . $feed['checksum']]) { $GLOBALS['liste_flux'][$i]['folder'] = $_POST['l_' . $feed['checksum']]; try { $req = $GLOBALS['db_handle']->prepare('UPDATE rss SET bt_folder=? WHERE bt_feed=?'); $req->execute(array($_POST['l_' . $feed['checksum']], $feed['link'])); } catch (Exception $e) { die('Error : Rss?conf Update-feed db: ' . $e->getMessage()); } } // URL has change if ($_POST['j_' . $feed['checksum']] != $GLOBALS['liste_flux'][$i]['link']) { $a = $GLOBALS['liste_flux'][$i]; $a['link'] = $_POST['j_' . $feed['checksum']]; unset($GLOBALS['liste_flux'][$i]); $GLOBALS['liste_flux'][$a['link']] = $a; try { $req = $GLOBALS['db_handle']->prepare('UPDATE rss SET bt_feed=? WHERE bt_feed=?'); $req->execute(array($_POST['j_' . $feed['checksum']], $feed['link'])); } catch (Exception $e) { die('Error : Rss?conf Update-feed db: ' . $e->getMessage()); } } } } } $GLOBALS['db_handle']->commit(); // sort list with title $GLOBALS['liste_flux'] = array_reverse(tri_selon_sous_cle($GLOBALS['liste_flux'], 'title')); file_put_contents($GLOBALS['fichier_liste_fluxrss'], '<?php /* ' . chunk_split(base64_encode(serialize($GLOBALS['liste_flux']))) . ' */'); $redir = basename($_SERVER['PHP_SELF']) . '?' . $query_string . '&msg=confirm_feeds_edit'; redirection($redir); }
function importer_opml($opml_content) { $GLOBALS['array_new'] = array(); function parseOpmlRecursive($xmlObj) { // si c’est un sous dossier avec d’autres flux à l’intérieur : note le nom du dossier $folder = $xmlObj->attributes()->text; foreach ($xmlObj->children() as $child) { if (!empty($child['xmlUrl'])) { $url = (string) $child['xmlUrl']; $title = !empty($child['text']) ? (string) $child['text'] : (string) $child['title']; $GLOBALS['array_new'][$url] = array('link' => $url, 'title' => ucfirst($title), 'favicon' => 'style/rss-feed-icon.png', 'checksum' => '0', 'time' => '0', 'folder' => (string) $folder, 'iserror' => 0); } parseOpmlRecursive($child); } } $opmlFile = new SimpleXMLElement($opml_content); parseOpmlRecursive($opmlFile->body); $old_len = count($GLOBALS['liste_flux']); $GLOBALS['liste_flux'] = array_reverse(tri_selon_sous_cle($GLOBALS['liste_flux'], 'title')); $GLOBALS['liste_flux'] = array_merge($GLOBALS['array_new'], $GLOBALS['liste_flux']); file_put_contents($GLOBALS['fichier_liste_fluxrss'], '<?php /* ' . chunk_split(base64_encode(serialize($GLOBALS['liste_flux']))) . ' */'); return count($GLOBALS['liste_flux']) - $old_len; }
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; }
function liste_tags($billet, $html_link) { $tags = $billet['bt_type'] == 'article' ? $billet['bt_categories'] : $billet['bt_tags']; $mode = $billet['bt_type'] == 'article' ? '' : '&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; }
if (isset($_POST['add-feed'])) { $erreurs = valider_form_rss(); if (!empty($erreurs)) { echo erreurs($erreurs); die; } $new_feed = trim($_POST['add-feed']); $new_feed_folder = htmlspecialchars(trim($_POST['add-feed-folder'])); $feed_array = get_new_feeds(array($new_feed => array()), ''); if (!($feed_array[$new_feed]['infos']['type'] == 'ATOM' or $feed_array[$new_feed]['infos']['type'] == 'RSS')) { die('Error: Invalid ressource (not an RSS/ATOM feed)'); } // adding to serialized-db $GLOBALS['liste_flux'][$new_feed] = array('link' => $new_feed, 'title' => ucfirst($feed_array[$new_feed]['infos']['title']), 'favicon' => 'style/rss-feed-icon.png', 'checksum' => '42', 'time' => '1', 'folder' => $new_feed_folder); // sort list with title $GLOBALS['liste_flux'] = array_reverse(tri_selon_sous_cle($GLOBALS['liste_flux'], 'title')); // save to file file_put_contents($GLOBALS['fichier_liste_fluxrss'], '<?php /* ' . chunk_split(base64_encode(serialize($GLOBALS['liste_flux']))) . ' */'); // Update DB refresh_rss(array($new_feed => $GLOBALS['liste_flux'][$new_feed])); echo 'Success'; echo new_token(); } // mark some element(s) as read if (isset($_POST['mark-as-read'])) { $erreurs = valider_form_rss(); if (!empty($erreurs)) { echo erreurs($erreurs); die; } $what = $_POST['mark-as-read'];
function afficher_liste_fichiers($tableau) { $dossier = $GLOBALS['racine'] . $GLOBALS['dossier_fichiers']; $out = ''; if (!empty($tableau)) { // affichage sous la forme d’icônes, comme les images. $old_filetype = ''; $tableau = tri_selon_sous_cle($tableau, 'bt_type'); // liste les différents dossiers " logiques " des fichiers. $lstype = array(); foreach ($tableau as $file) { $lstype[$file['bt_type']] = isset($lstype[$file['bt_type']]) ? $lstype[$file['bt_type']] + 1 : 1; } $lstype = array_unique($lstype); $out .= '<div id="files-section">' . "\n"; // buttons if (!empty($lstype)) { $out .= '<div class="list-buttons" id="list-types">' . "\n"; $i = 0; $out .= "\t" . '<button class="current" id="butIdtype' . $i . '" onclick="type_sort(\'\', \'butIdtype' . $i . '\');">' . count($tableau) . ' ' . $GLOBALS['lang']['label_fichiers'] . '</button>' . "\n"; foreach ($lstype as $type => $amount) { if (empty($type)) { break; } $i++; $out .= "\t" . '<button id="butIdtype' . $i . '" onclick="type_sort(\'' . $type . '\', \'butIdtype' . $i . '\');">' . $type . ' (' . $amount . ')</button>' . "\n"; } $out .= '</div>' . "\n"; } $out .= '<div id="files-wall">' . "\n"; // the files foreach ($tableau as $file) { $out .= '<div class="file_bloc" id="bloc_' . $file['bt_id'] . '" data-type="' . $file['bt_type'] . '">' . "\n"; $description = empty($file['bt_content']) ? '' : ' (' . $file['bt_content'] . ')'; $out .= "\t" . '<span class="spantop black">'; $out .= '<a class="lien lien-edit" href="fichiers.php?file_id=' . $file['bt_id'] . '&edit"></a>'; $out .= '<a class="lien lien-supr" href="#" onclick="request_delete_form(\'' . $file['bt_id'] . '\'); return false;" ></a>'; $out .= '</span>' . "\n"; $out .= "\t" . '<a class="lien" href="' . $dossier . '/' . $file['bt_filename'] . '" download><img src="style/filetypes/' . $file['bt_type'] . '.png" id="' . $file['bt_id'] . '" alt="' . $file['bt_filename'] . '" /></a><br/><span class="description">' . $file['bt_filename'] . "</span>\n"; $out .= '</div>' . "\n\n"; } $out .= '</div>' . "\n"; $out .= '</div>' . "\n"; } echo $out; }