function wiki_explode_menu(&$content) { $lines = explode("\n", $content); $num_lines = count($lines); $max_level_expected = 2; $list = array(); //We read the text line by line foreach ($lines as $id => &$line) { for ($level = 2; $level <= $max_level_expected; $level++) { $matches = array(); //If the line contains a title if (preg_match('`^(?:<br />)?\\s*[\\-]{' . $level . '}[\\s]+(.+)[\\s]+[\\-]{' . $level . '}(?:<br />)?\\s*$`', $line, $matches)) { $title_name = strip_tags(TextHelper::html_entity_decode($matches[1])); //We add it to the list $list[] = array($level - 1, $title_name); //Now we wait one of its children or its brother $max_level_expected = min($level + 1, WIKI_MENU_MAX_DEPTH + 1); //Réinsertion $class_level = $level - 1; $line = '<h' . $class_level . ' class="wiki_paragraph' . $class_level . '" id="paragraph_' . Url::encode_rewrite($title_name) . '">' . TextHelper::htmlspecialchars($title_name) . '</h' . $class_level . '><br />' . "\n"; } } } $content = implode("\n", $lines); return $list; }
private function update_position($request) { $fields_list = json_decode(TextHelper::html_entity_decode($request->get_value('tree'))); foreach ($fields_list as $position => $tree) { PersistenceContext::get_querier()->inject("UPDATE " . DB_TABLE_MEMBER_EXTENDED_FIELDS_LIST . " SET \r\n\t\t\t\tposition = :position\r\n\t\t\t\tWHERE id = :id", array('position' => $position, 'id' => $tree->id)); } }
public function parse() { $this->content = TextHelper::html_entity_decode($this->content); foreach (static::$parsers as $parser) { $this->content = $parser->unparse($this->content); } }
function Add_msg($idtopic, $idcat, $contents, $title, $last_page, $last_page_rewrite, $new_topic = false) { global $LANG; ##### Insertion message ##### $last_timestamp = time(); $result = PersistenceContext::get_querier()->insert(PREFIX . 'forum_msg', array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id(), 'contents' => FormatingHelper::strparse($contents), 'timestamp' => $last_timestamp, 'timestamp_edit' => 0, 'user_id_edit' => 0, 'user_ip' => AppContext::get_request()->get_ip_address())); $last_msg_id = $result->get_last_inserted_id(); //Topic PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "forum_topics SET " . ($new_topic ? '' : 'nbr_msg = nbr_msg + 1, ') . "last_user_id = '" . AppContext::get_current_user()->get_id() . "', last_msg_id = '" . $last_msg_id . "', last_timestamp = '" . $last_timestamp . "' WHERE id = '" . $idtopic . "'"); //On met à jour le last_topic_id dans la catégorie dans le lequel le message a été posté PersistenceContext::get_querier()->update(ForumSetup::$forum_cats_table, array('last_topic_id' => $idtopic), 'WHERE id = :id', array('id' => $idcat)); //Mise à jour du nombre de messages du membre. PersistenceContext::get_querier()->inject("UPDATE " . DB_TABLE_MEMBER . " SET posted_msg = posted_msg + 1 WHERE user_id = '" . AppContext::get_current_user()->get_id() . "'"); //On marque le topic comme lu. mark_topic_as_read($idtopic, $last_msg_id, $last_timestamp); ##### Gestion suivi du sujet mp/mail ##### if (!$new_topic) { //Message précédent ce nouveau message. $previous_msg_id = 0; try { $previous_msg_id = PersistenceContext::get_querier()->get_column_value(PREFIX . "forum_msg", 'MAX(id)', 'WHERE idtopic = :idtopic AND id < :id', array('idtopic' => $idtopic, 'id' => $last_msg_id)); } catch (RowNotFoundException $e) { } $title_subject = TextHelper::html_entity_decode($title); $title_subject_pm = $title_subject; if (AppContext::get_current_user()->get_id() > 0) { $pseudo = ''; try { $pseudo = PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER, 'display_name', 'WHERE user_id = :id', array('id' => AppContext::get_current_user()->get_id())); } catch (RowNotFoundException $e) { } $pseudo_pm = '<a href="' . UserUrlBuilder::profile(AppContext::get_current_user()->get_id())->rel() . '">' . $pseudo . '</a>'; } else { $pseudo = $LANG['guest']; $pseudo_pm = $LANG['guest']; } $next_msg_link = '/forum/topic' . url('.php?id=' . $idtopic . $last_page, '-' . $idtopic . $last_page_rewrite . '.php') . ($previous_msg_id ? '#m' . $previous_msg_id : ''); $preview_contents = substr($contents, 0, 300); //Récupération des membres suivant le sujet. $max_time = time() - SessionsConfig::load()->get_active_session_duration(); $result = PersistenceContext::get_querier()->select("SELECT m.user_id, m.display_name, m.email, tr.pm, tr.mail, v.last_view_id\n\t\t\tFROM " . PREFIX . "forum_track tr\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = tr.user_id\n\t\t\tLEFT JOIN " . PREFIX . "forum_view v ON v.idtopic = :idtopic AND v.user_id = tr.user_id\n\t\t\tWHERE tr.idtopic = :idtopic AND v.last_view_id IS NOT NULL AND m.user_id != :user_id", array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id())); while ($row = $result->fetch()) { //Envoi un Mail à ceux dont le last_view_id est le message précedent. if ($row['last_view_id'] == $previous_msg_id && $row['mail'] == '1') { AppContext::get_mail_service()->send_from_properties($row['email'], $LANG['forum_mail_title_new_post'], sprintf($LANG['forum_mail_new_post'], $row['display_name'], $title_subject, AppContext::get_current_user()->get_display_name(), $preview_contents, HOST . DIR . $next_msg_link, HOST . DIR . '/forum/action.php?ut=' . $idtopic . '&trt=1', 1)); } //Envoi un MP à ceux dont le last_view_id est le message précedent. if ($row['last_view_id'] == $previous_msg_id && $row['pm'] == '1') { $content = sprintf($LANG['forum_mail_new_post'], $row['display_name'], $title_subject_pm, AppContext::get_current_user()->get_display_name(), $preview_contents, '<a href="' . $next_msg_link . '">' . $next_msg_link . '</a>', '<a href="/forum/action.php?ut=' . $idtopic . '&trt=2">/forum/action.php?ut=' . $idtopic . '&trt=2</a>'); PrivateMsg::start_conversation($row['user_id'], $LANG['forum_mail_title_new_post'], nl2br($content), '-1', PrivateMsg::SYSTEM_PM); } } $result->dispose(); forum_generate_feeds(); //Regénération du flux rss. } return $last_msg_id; }
private function update_position(HTTPRequestCustom $request) { $fields = $this->config->get_fields(); $sorted_fields = array(); $fields_list = json_decode(TextHelper::html_entity_decode($request->get_value('tree'))); foreach ($fields_list as $position => $tree) { $sorted_fields[$position + 1] = $fields[$tree->id]; } $this->config->set_fields($sorted_fields); ContactConfig::save(); }
private function update_positions(HTTPRequestCustom $request) { if ($request->get_postvalue('submit', false)) { $categories = json_decode(TextHelper::html_entity_decode($request->get_value('tree'))); foreach ($categories as $position => $tree) { $id = $tree->id; $children = $tree->children[0]; $category = $this->get_categories_manager()->get_categories_cache()->get_category($id); $this->get_categories_manager()->update_position($category, Category::ROOT_CATEGORY, $position + 1); $this->update_childrens_positions($children, $category->get_id()); } $this->tpl->put('MSG', MessageHelper::display(LangLoader::get_message('message.success.position.update', 'status-messages-common'), MessageHelper::SUCCESS, 5)); } }
/** * @desc Parses the parser content from BBCode to XHTML. * @return void You will find the result by using the get_content method */ public function parse() { $this->content = TextHelper::html_entity_decode($this->content); //On supprime d'abord toutes les occurences de balises CODE que nous réinjecterons à la fin pour ne pas y toucher if (!in_array('code', $this->forbidden_tags)) { $this->pick_up_tag('code', '=[A-Za-z0-9#+-]+(?:,[01]){0,2}'); } //On prélève tout le code HTML afin de ne pas l'altérer if (!in_array('html', $this->forbidden_tags) && AppContext::get_current_user()->check_auth($this->html_auth, 1)) { $this->pick_up_tag('html'); } //Ajout des espaces pour éviter l'absence de parsage lorsqu'un séparateur de mot est éxigé $this->content = ' ' . $this->content . ' '; //Traitement du code HTML $this->protect_content(); //Traitement des smilies $this->parse_smilies(); //Interprétation des sauts de ligne $this->content = nl2br($this->content); // BBCode simple tags $this->parse_simple_tags(); //Tableaux if (!in_array('table', $this->forbidden_tags) && strpos($this->content, '[table') !== false) { $this->parse_table(); } //Listes if (!in_array('list', $this->forbidden_tags) && strpos($this->content, '[list') !== false) { $this->parse_list(); } //On remet le code HTML mis de côté if (!empty($this->array_tags['html'])) { $this->array_tags['html'] = array_map(create_function('$string', 'return str_replace("[html]", "<!-- START HTML -->\\n", str_replace("[/html]", "\\n<!-- END HTML -->", $string));'), $this->array_tags['html']); $this->reimplant_tag('html'); } parent::parse(); //On réinsère les fragments de code qui ont été prévelevés pour ne pas les considérer if (!empty($this->array_tags['code'])) { $this->array_tags['code'] = array_map(create_function('$string', 'return preg_replace(\'`^\\[code(=.+)?\\](.+)\\[/code\\]$`isU\', \'[[CODE$1]]$2[[/CODE]]\', TextHelper::htmlspecialchars($string, ENT_NOQUOTES));'), $this->array_tags['code']); $this->reimplant_tag('code'); } }
/** * @desc Unparses the content of the parser. * Converts it from HTML syntax to BBcode syntax */ public function parse() { //Isolement du code source et du code HTML qui ne sera pas protégé $this->unparse_html(self::PICK_UP); $this->unparse_code(self::PICK_UP); $this->content = TextHelper::html_entity_decode($this->content); //Smilies $this->unparse_smilies(); //Remplacement des balises simples $this->unparse_simple_tags(); //Unparsage de la balise table. if (strpos($this->content, '<table class="formatter-table"') !== false) { $this->unparse_table(); } //Unparsage de la balise table. if (strpos($this->content, '<li class="formatter-li"') !== false) { $this->unparse_list(); } $this->unparse_code(self::REIMPLANT); $this->unparse_html(self::REIMPLANT); }
public function parse() { $this->content = str_replace(array("\r\n", "\r"), "\n", $this->content); $this->content = "\n" . $this->content . "\n"; $this->content = TextHelper::html_entity_decode($this->content); foreach (static::$parsers as $parser) { $this->content = $parser->parse_save_tags($this->content); } $this->protect_content(); foreach (static::$parsers as $parser) { $this->content = $parser->parse($this->content); } $this->parse_paragraphs(); foreach (static::$parsers as $parser) { $this->content = $parser->restaure_tags($this->content); } foreach (static::$parsers as $parser) { if (method_exists($parser, "after_parse")) { $this->content = $parser->after_parse($this->content); } } parent::parse(); }
public function get_feed_data_struct($idcat = 0, $name = '') { $config = ForumConfig::load(); $category = ForumService::get_categories_manager()->get_categories_cache()->get_category($idcat); $data = new FeedData(); $data->set_title(LangLoader::get_message('xml_forum_desc', 'common', 'forum')); $data->set_date(new Date()); $data->set_link(DispatchManager::get_url('/syndication', '/rss/forum/' . $idcat . '/')); $data->set_host(HOST); $data->set_desc(LangLoader::get_message('xml_forum_desc', 'common', 'forum')); $data->set_lang(LangLoader::get_message('xml_lang', 'main')); $data->set_auth_bit(Category::READ_AUTHORIZATIONS); $categories = ForumService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true); $ids_categories = array_keys($categories); $results = PersistenceContext::get_querier()->select('SELECT t.id, t.idcat, t.title, t.last_timestamp, t.last_msg_id, t.display_msg, t.nbr_msg AS t_nbr_msg, msg.id mid, msg.contents FROM ' . PREFIX . 'forum_topics t LEFT JOIN ' . PREFIX . 'forum_msg msg ON msg.id = t.last_msg_id WHERE t.idcat IN :ids_categories ORDER BY t.last_timestamp DESC LIMIT :limit OFFSET 0', array('ids_categories' => $ids_categories, 'limit' => 2 * $config->get_number_messages_per_page())); foreach ($results as $row) { $item = new FeedItem(); //Link $last_page = ceil($row['t_nbr_msg'] / $config->get_number_messages_per_page()); $last_page_rewrite = $last_page > 1 ? '-' . $last_page : ''; $last_page = $last_page > 1 ? 'pt=' . $last_page . '&' : ''; $link = new Url('/forum/topic' . url('.php?' . $last_page . 'id=' . $row['id'], '-' . $row['id'] . $last_page_rewrite . '+' . Url::encode_rewrite($row['title']) . '.php') . '#m' . $row['last_msg_id']); $item->set_title(($config->is_message_before_topic_title_displayed() && !empty($row['display_msg']) ? TextHelper::html_entity_decode($config->get_message_before_topic_title(), ENT_NOQUOTES) . ' ' : '') . stripslashes($row['title'])); $item->set_link($link); $item->set_guid($link); $item->set_desc(FormatingHelper::second_parse($row['contents'])); $item->set_date(new Date($row['last_timestamp'], Timezone::SERVER_TIMEZONE)); $item->set_auth(ForumService::get_categories_manager()->get_heritated_authorizations($row['idcat'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY)); $data->add_item($item); } $results->dispose(); return $data; }
public function execute(HTTPRequestCustom $request) { if ($this->check_authorizations()) { $pseudo = TextHelper::strprotect(utf8_decode($request->get_string('pseudo', ''))); $contents = TextHelper::htmlentities($request->get_string('contents', ''), ENT_COMPAT, 'UTF-8'); $contents = TextHelper::htmlspecialchars_decode(TextHelper::html_entity_decode($contents, ENT_COMPAT, 'windows-1252')); if ($pseudo && $contents) { //Mod anti-flood, autorisé aux membres qui bénificie de l'autorisation de flooder. $check_time = AppContext::get_current_user()->get_id() !== -1 && ContentManagementConfig::load()->is_anti_flood_enabled() ? PersistenceContext::get_querier()->get_column_value(PREFIX . "shoutbox", 'MAX(timestamp)', 'WHERE user_id = :id', array('id' => AppContext::get_current_user()->get_id())) : ''; if (!empty($check_time) && !AppContext::get_current_user()->check_max_value(AUTH_FLOOD)) { if ($check_time >= time() - ContentManagementConfig::load()->get_anti_flood_duration()) { $code = -1; } } //Vérifie que le message ne contient pas du flood de lien. $config_shoutbox = ShoutboxConfig::load(); $contents = FormatingHelper::strparse($contents, $config_shoutbox->get_forbidden_formatting_tags()); if (!TextHelper::check_nbr_links($contents, $config_shoutbox->get_max_links_number_per_message(), true)) { //Nombre de liens max dans le message. $code = -2; } $shoutbox_message = new ShoutboxMessage(); $shoutbox_message->init_default_properties(); $shoutbox_message->set_login($pseudo); $shoutbox_message->set_user_id(AppContext::get_current_user()->get_id()); $shoutbox_message->set_contents($contents); $shoutbox_message->set_creation_date(new Date()); $code = ShoutboxService::add($shoutbox_message); } else { $code = -3; } } else { $code = -4; } return new JSONResponse(array('code' => $code)); }
private function save() { $this->tpl_file->write(TextHelper::html_entity_decode($this->form->get_value('tpl_file'))); $this->tpl_file->close(); }
private function build_view() { global $LANG, $config, $nbr_msg_not_read, $tpl_top, $tpl_bottom; $id_get = retrieve(GET, 'id', 0); try { $this->category = ForumService::get_categories_manager()->get_categories_cache()->get_category($id_get); } catch (CategoryNotFoundException $e) { } require_once PATH_TO_ROOT . '/forum/forum_begin.php'; require_once PATH_TO_ROOT . '/forum/forum_tools.php'; $this->view = new FileTemplate('forum/forum_index.tpl'); //Affichage des sous-catégories de la catégorie. $display_cat = !empty($id_get); //Vérification des autorisations. $authorized_categories = ForumService::get_authorized_categories($id_get); //Calcul du temps de péremption, ou de dernière vue des messages par à rapport à la configuration. $max_time_msg = forum_limit_time_msg(); $is_guest = AppContext::get_current_user()->get_id() == -1; $total_topic = 0; $total_msg = 0; $i = 0; //On liste les catégories et sous-catégories. $result = PersistenceContext::get_querier()->select('SELECT @id_cat:= c.id, c.id AS cid, c.id_parent, c.name, c.rewrited_name, c.description as subname, c.url, c.last_topic_id, t.id AS tid, t.idcat, t.title, t.last_timestamp, t.last_user_id, t.last_msg_id, t.nbr_msg AS t_nbr_msg, t.display_msg, t.status, m.user_id, m.display_name as login, m.level as user_level, m.groups, v.last_view_id, (SELECT COUNT(*) FROM ' . ForumSetup::$forum_topics_table . ' WHERE idcat IN ( @id_cat, (SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . ForumSetup::$forum_cats_table . ' WHERE id_parent = @id_cat), (SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . ForumSetup::$forum_cats_table . ' parents INNER JOIN ' . ForumSetup::$forum_cats_table . ' childs ON parents.id = childs.id_parent WHERE parents.id_parent = @id_cat) ) ) AS nbr_topic, (SELECT COUNT(*) FROM ' . ForumSetup::$forum_message_table . ' WHERE idtopic IN ( (SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . ForumSetup::$forum_topics_table . ' WHERE idcat = @id_cat), (SELECT GROUP_CONCAT(t.id SEPARATOR \',\') FROM ' . ForumSetup::$forum_topics_table . ' t LEFT JOIN ' . ForumSetup::$forum_cats_table . ' c ON t.idcat = c.id WHERE id_parent = @id_cat) ) ) AS nbr_msg FROM ' . ForumSetup::$forum_cats_table . ' c LEFT JOIN ' . ForumSetup::$forum_topics_table . ' t ON t.id = c.last_topic_id LEFT JOIN ' . ForumSetup::$forum_view_table . ' v ON v.user_id = :user_id AND v.idtopic = t.id LEFT JOIN ' . DB_TABLE_MEMBER . ' m ON m.user_id = t.last_user_id WHERE ' . ($display_cat ? 'c.id_parent = :id_cat AND ' : '') . 'c.id IN :authorized_categories ORDER BY c.id, c.id_parent, c.c_order', array('id_cat' => $id_get, 'user_id' => AppContext::get_current_user()->get_id(), 'authorized_categories' => $authorized_categories)); $categories = array(); while ($row = $result->fetch()) { $categories[] = $row; } $result->dispose(); $display_sub_cats = false; $is_sub_forum = array(); foreach ($categories as $row) { $this->view->assign_block_vars('forums_list', array()); if ($row['id_parent'] == Category::ROOT_CATEGORY && $i > 0 && $display_sub_cats) { $this->view->assign_block_vars('forums_list.endcats', array()); } $i++; if ($row['id_parent'] == Category::ROOT_CATEGORY) { $this->view->assign_block_vars('forums_list.cats', array('IDCAT' => $row['cid'], 'NAME' => $row['name'], 'U_FORUM_VARS' => ForumUrlBuilder::display_category($row['cid'], $row['rewrited_name'])->rel())); $display_sub_cats = true; } else { if (in_array($row['id_parent'], $is_sub_forum)) { $is_sub_forum[] = $row['cid']; } if (($display_sub_cats || !empty($id_get)) && !in_array($row['cid'], $is_sub_forum)) { if ($display_cat) { $this->view->assign_block_vars('forums_list.cats', array('IDCAT' => $this->category->get_id(), 'NAME' => $this->category->get_name(), 'U_FORUM_VARS' => PATH_TO_ROOT . '/forum/' . url('index.php?id=' . $this->category->get_id(), 'cat-' . $this->category->get_id() . '+' . $this->category->get_rewrited_name() . '.php'))); $display_cat = false; } $subforums = ''; $this->view->put_all(array('C_FORUM_ROOT_CAT' => false, 'C_FORUM_CHILD_CAT' => true, 'C_END_S_CATS' => false)); $children = ForumService::get_categories_manager()->get_categories_cache()->get_childrens($row['cid']); if ($children) { foreach ($children as $id => $child) { if ($child->get_id_parent() == $row['cid'] && ForumAuthorizationsService::check_authorizations($child->get_id())->read()) { $is_sub_forum[] = $child->get_id(); $link = $child->get_url() ? '<a href="' . $child->get_url() . '" class="small">' : '<a href="forum' . url('.php?id=' . $child->get_id(), '-' . $child->get_id() . '+' . $child->get_rewrited_name() . '.php') . '" class="small">'; $subforums .= !empty($subforums) ? ', ' . $link . $child->get_name() . '</a>' : $link . $child->get_name() . '</a>'; } } $subforums = '<strong>' . $LANG['subforum_s'] . '</strong>: ' . $subforums; } if (!empty($row['last_topic_id'])) { //Si le dernier message lu est présent on redirige vers lui, sinon on redirige vers le dernier posté. if (!empty($row['last_view_id'])) { $last_msg_id = $row['last_view_id']; $last_page = 'idm=' . $row['last_view_id'] . '&'; $last_page_rewrite = '-0-' . $row['last_view_id']; } else { $last_msg_id = $row['last_msg_id']; $last_page = ceil($row['t_nbr_msg'] / $config->get_number_messages_per_page()); $last_page_rewrite = $last_page > 1 ? '-' . $last_page : ''; $last_page = $last_page > 1 ? 'pt=' . $last_page . '&' : ''; } $last_topic_title = ($config->is_message_before_topic_title_displayed() && $row['display_msg'] ? $config->get_message_before_topic_title() : '') . ' ' . $row['title']; $last_topic_title = stripslashes(strlen(TextHelper::html_entity_decode($last_topic_title)) > 20 ? TextHelper::substr_html($last_topic_title, 0, 20) . '...' : $last_topic_title); $row['login'] = !empty($row['login']) ? $row['login'] : $LANG['guest']; $group_color = User::get_group_color($row['groups'], $row['user_level']); $last = '<a href="' . PATH_TO_ROOT . '/forum/topic' . url('.php?id=' . $row['tid'], '-' . $row['tid'] . '+' . Url::encode_rewrite($row['title']) . '.php') . '" class="small">' . $last_topic_title . '</a><br /> <a href="' . PATH_TO_ROOT . '/forum/topic' . url('.php?' . $last_page . 'id=' . $row['tid'], '-' . $row['tid'] . $last_page_rewrite . '+' . Url::encode_rewrite($row['title']) . '.php') . '#m' . $last_msg_id . '"><i class="fa fa-hand-o-right"></i></a> ' . $LANG['on'] . ' ' . Date::to_format($row['last_timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . '<br />' . $LANG['by'] . ' ' . ($row['last_user_id'] != '-1' ? '<a href="' . UserUrlBuilder::profile($row['last_user_id'])->rel() . '" class="small ' . UserService::get_level_class($row['user_level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['login'] . '</a>' : '<em>' . $LANG['guest'] . '</em>'); } else { $row['last_timestamp'] = ''; $last = '<br />' . $LANG['no_message'] . '<br /><br />'; } //Vérifications des topics Lu/non Lus. $img_announce = 'fa-announce'; $blink = false; if (!$is_guest) { if ($row['last_view_id'] != $row['last_msg_id'] && $row['last_timestamp'] >= $max_time_msg) { $img_announce = $img_announce . '-new'; //Image affiché aux visiteurs. $blink = true; } } $img_announce .= $row['status'] == '0' ? '-lock' : ''; $total_topic += $row['nbr_topic']; $total_msg += $row['nbr_msg']; $this->view->assign_block_vars('forums_list.subcats', array('C_BLINK' => $blink, 'IMG_ANNOUNCE' => $img_announce, 'NAME' => $row['name'], 'DESC' => FormatingHelper::second_parse($row['subname']), 'SUBFORUMS' => !empty($subforums) && !empty($row['subname']) ? '<br />' . $subforums : $subforums, 'NBR_TOPIC' => $row['nbr_topic'], 'NBR_MSG' => $row['nbr_msg'], 'U_FORUM_URL' => $row['url'], 'U_FORUM_VARS' => ForumUrlBuilder::display_forum($row['cid'], $row['rewrited_name'])->rel(), 'U_LAST_TOPIC' => $last)); } } } if ($i > 0) { $this->view->assign_block_vars('forums_list', array()); $this->view->assign_block_vars('forums_list.endcats', array()); } $site_path = GeneralConfig::get_default_site_path(); if (GeneralConfig::load()->get_module_home_page() == 'forum') { list($users_list, $total_admin, $total_modo, $total_member, $total_visit, $total_online) = forum_list_user_online("AND s.location_script = '" . $site_path . "/forum/' OR s.location_script = '" . $site_path . "/forum/index.php' OR s.location_script = '" . $site_path . "/index.php' OR s.location_script = '" . $site_path . "/'"); } else { $where = "AND s.location_script LIKE '%" . $site_path . "/forum/%'"; if (!empty($id_get)) { $where = "AND s.location_script LIKE '%" . $site_path . url('/forum/index.php?id=' . $id_get, '/forum/cat-' . $id_get . ($this->category !== false && $id_get != Category::ROOT_CATEGORY ? '+' . $this->category->get_rewrited_name() : '') . '.php') . "'"; } list($users_list, $total_admin, $total_modo, $total_member, $total_visit, $total_online) = forum_list_user_online($where); } //Liste des catégories. $search_category_children_options = new SearchCategoryChildrensOptions(); $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS); $categories_tree = ForumService::get_categories_manager()->get_select_categories_form_field('cats', '', $id_get, $search_category_children_options); $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options'); $method->setAccessible(true); $categories_tree_options = $method->invoke($categories_tree); $cat_list = ''; foreach ($categories_tree_options as $option) { if ($option->get_raw_value()) { $cat = ForumService::get_categories_manager()->get_categories_cache()->get_category($option->get_raw_value()); if (!$cat->get_url()) { $cat_list .= $option->display()->render(); } } } $vars_tpl = array('FORUM_NAME' => $config->get_forum_name(), 'NBR_MSG' => $total_msg, 'NBR_TOPIC' => $total_topic, 'C_USER_CONNECTED' => AppContext::get_current_user()->check_level(User::MEMBER_LEVEL), 'TOTAL_ONLINE' => $total_online, 'USERS_ONLINE' => $total_online - $total_visit == 0 ? '<em>' . $LANG['no_member_online'] . '</em>' : $users_list, 'ADMIN' => $total_admin, 'MODO' => $total_modo, 'MEMBER' => $total_member, 'GUEST' => $total_visit, 'SELECT_CAT' => !empty($id_get) ? $cat_list : '', 'C_TOTAL_POST' => true, 'U_ONCHANGE' => PATH_TO_ROOT . "/forum/" . url("index.php?id=' + this.options[this.selectedIndex].value + '", "forum-' + this.options[this.selectedIndex].value + '.php"), 'U_ONCHANGE_CAT' => PATH_TO_ROOT . "/forum/" . url("/index.php?id=' + this.options[this.selectedIndex].value + '", "cat-' + this.options[this.selectedIndex].value + '.php"), 'L_FORUM_INDEX' => $LANG['forum_index'], 'L_FORUM' => $LANG['forum'], 'L_TOPIC' => $total_topic > 1 ? $LANG['topic_s'] : $LANG['topic'], 'L_MESSAGE' => $total_msg > 1 ? $LANG['message_s'] : $LANG['message'], 'L_LAST_MESSAGE' => $LANG['last_message'], 'L_STATS' => $LANG['stats'], 'L_DISPLAY_UNREAD_MSG' => $LANG['show_not_reads'], 'L_MARK_AS_READ' => $LANG['mark_as_read'], 'L_TOTAL_POST' => $LANG['nbr_message'], 'L_DISTRIBUTED' => strtolower($LANG['distributed']), 'L_AND' => $LANG['and'], 'L_USER' => $total_online > 1 ? $LANG['user_s'] : $LANG['user'], 'L_ADMIN' => $total_admin > 1 ? $LANG['admin_s'] : $LANG['admin'], 'L_MODO' => $total_modo > 1 ? $LANG['modo_s'] : $LANG['modo'], 'L_MEMBER' => $total_member > 1 ? $LANG['member_s'] : $LANG['member'], 'L_GUEST' => $total_visit > 1 ? $LANG['guest_s'] : $LANG['guest'], 'L_AND' => $LANG['and'], 'L_ONLINE' => strtolower($LANG['online'])); $this->view->put_all($vars_tpl); $tpl_top->put_all($vars_tpl); $tpl_bottom->put_all($vars_tpl); $this->view->put('forum_top', $tpl_top); $this->view->put('forum_bottom', $tpl_bottom); return $this->view; }
function save_position($block_position) { $menus = MenuService::get_menu_list(); $menus_tree = json_decode(TextHelper::html_entity_decode(AppContext::get_request()->get_value('menu_tree_' . get_block($block_position)))); foreach ($menus_tree as $position => $tree) { $id = $tree->id; if (array_key_exists($id, $menus)) { $menu = $menus[$id]; $menu->set_block_position($position + 1); MenuService::move($menu, $block_position, $menu->get_block_position()); } } }
* You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ define('PATH_TO_ROOT', '../../..'); include_once PATH_TO_ROOT . '/kernel/begin.php'; AppContext::get_session()->no_session_location(); //Permet de ne pas mettre jour la page dans la session. include_once PATH_TO_ROOT . '/kernel/header_no_display.php'; $page_path_to_root = retrieve(REQUEST, 'path_to_root', ''); $page_path = retrieve(REQUEST, 'page_path', ''); //Quel éditeur utiliser ? Si ce n'est pas précisé on prend celui par défaut de l'utilisateur $editor = retrieve(REQUEST, 'editor', ContentFormattingConfig::load()->get_default_editor()); $contents = TextHelper::htmlentities(retrieve(POST, 'contents', ''), ENT_COMPAT, 'UTF-8'); $contents = TextHelper::htmlspecialchars_decode(stripslashes(TextHelper::html_entity_decode($contents))); $ftags = retrieve(POST, 'ftags', TSTRING_UNCHANGE); $forbidden_tags = explode(',', $ftags); $formatting_factory = AppContext::get_content_formatting_service()->create_factory($editor); //On prend le bon parseur avec la bonne configuration $parser = $formatting_factory->get_parser(); $parser->set_content($contents); $parser->set_path_to_root($page_path_to_root); $parser->set_page_path($page_path); if (!empty($forbidden_tags)) { $parser->set_forbidden_tags($forbidden_tags); } $parser->parse(); //On parse la deuxième couche (code, math etc) pour afficher $second_parser = $formatting_factory->get_second_parser(); $second_parser->set_content($parser->get_content());
function build_menu_children_tree($element) { $menu = array(); if (isset($element->children)) { $children = array(); foreach ($element->children[0] as $p => $t) { $children[$p] = build_menu_children_tree($t); } $menu = array_merge(array('id' => $element->id), $children); } else { $menu = array('id' => $element->id); } return $menu; } $menu_tree = array('id' => $menu_uid); $links_list = json_decode(TextHelper::html_entity_decode(AppContext::get_request()->get_value('menu_tree'))); foreach ($links_list as $position => $tree) { $menu_tree[$position] = build_menu_children_tree($tree); } // We build the menu $menu = build_menu_from_form($menu_tree); $menu->set_type($type); $previous_menu = null; //If we edit the menu if ($menu_id > 0) { // Edit the Menu $menu->id($menu_id); $previous_menu = MenuService::load($menu_id); } //Menu enabled? $menu->enabled(retrieve(POST, 'menu_element_' . $menu_uid . '_enabled', Menu::MENU_NOT_ENABLED));
} $tpl->put_all(array('POPUP' => $popup, 'C_TINYMCE_EDITOR' => AppContext::get_current_user()->get_editor() == 'TinyMCE', 'C_DISPLAY_CLOSE_BUTTON' => $display_close_button, 'FIELD' => $field, 'FOLDER_ID' => !empty($folder) ? $folder : '0', 'USER_ID' => AppContext::get_current_user()->get_id(), 'URL' => $folder > 0 ? Uploads::get_url($folder, '', '&' . $popup) : '', 'L_CONFIRM_DEL_FILE' => $LANG['confim_del_file'], 'L_CONFIRM_DEL_FOLDER' => $LANG['confirm_del_folder'], 'L_CONFIRM_EMPTY_FOLDER' => $LANG['confirm_empty_folder'], 'L_FOLDER_ALREADY_EXIST' => LangLoader::get_message('element.already_exists', 'status-messages-common'), 'L_FOLDER_FORBIDDEN_CHARS' => $LANG['folder_forbidden_chars'], 'L_FILES_MANAGEMENT' => $LANG['files_management'], 'L_FILES_ACTION' => $LANG['files_management'], 'L_CONFIG_FILES' => $LANG['files_config'], 'L_ADD_FILES' => $LANG['file_add'], 'L_ROOT' => $LANG['root'], 'L_NAME' => $LANG['name'], 'L_SIZE' => $LANG['size'], 'L_MOVETO' => $LANG['moveto'], 'L_DATA' => $LANG['data'], 'L_FOLDER_SIZE' => $LANG['folder_size'], 'L_FOLDERS' => $LANG['folders'], 'L_FOLDER_NEW' => $LANG['folder_new'], 'L_FOLDER_CONTENT' => $LANG['folder_content'], 'L_FOLDER_UP' => $LANG['folders_up'], 'L_FILES' => $LANG['files'], 'L_DELETE' => LangLoader::get_message('delete', 'common'), 'L_EMPTY' => $LANG['empty'], 'L_UPLOAD' => $LANG['upload'], 'L_URL' => $LANG['url'], 'U_ROOT' => '<a href="upload.php?' . $popup . '">' . AppContext::get_current_user()->get_display_name() . '</a>/')); list($total_folder_size, $total_files, $total_directories) = array(0, 0, 0); //Affichage des dossiers $result = PersistenceContext::get_querier()->select("SELECT id, name, id_parent, user_id\n\tFROM " . DB_TABLE_UPLOAD_CAT . "\n\tWHERE id_parent = :id_parent AND user_id = :user_id\n\tORDER BY name", array('id_parent' => $folder, 'user_id' => AppContext::get_current_user()->get_id())); while ($row = $result->fetch()) { $name_cut = strlen(TextHelper::html_entity_decode($row['name'])) > 22 ? TextHelper::htmlentities(substr(TextHelper::html_entity_decode($row['name']), 0, 22)) . '...' : $row['name']; $tpl->assign_block_vars('folder', array('ID' => $row['id'], 'NAME' => $name_cut, 'RENAME_FOLDER' => '<span id="fhref' . $row['id'] . '"><a href="javascript:display_rename_folder(\'' . $row['id'] . '\', \'' . addslashes($row['name']) . '\', \'' . addslashes($name_cut) . '\');" title="' . LangLoader::get_message('edit', 'common') . '" class="fa fa-edit"></a></span>', 'MOVE' => '<a href="javascript:upload_display_block(' . $row['id'] . ');" onmouseover="upload_hide_block(' . $row['id'] . ', 1);" onmouseout="upload_hide_block(' . $row['id'] . ', 0);" class="fa fa-move" title="' . $LANG['moveto'] . '"></a>', 'U_MOVE' => url('.php?movefd=' . $row['id'] . '&f=' . $folder . $popup), 'L_TYPE_DEL_FOLDER' => $LANG['del_folder'])); $total_directories++; } $result->dispose(); $now = new Date(); //Affichage des fichiers contenu dans le dossier $result = PersistenceContext::get_querier()->select("SELECT up.id, up.name, up.path, up.size, up.type, up.timestamp, m.user_id\n\tFROM " . DB_TABLE_UPLOAD . " up\n\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = up.user_id\n\tWHERE up.idcat = :idcat AND up.user_id = :user_id\n\tORDER BY up.name", array('idcat' => $folder, 'user_id' => AppContext::get_current_user()->get_id())); while ($row = $result->fetch()) { $name_cut = strlen(TextHelper::html_entity_decode($row['name'])) > 22 ? TextHelper::htmlentities(substr(TextHelper::html_entity_decode($row['name']), 0, 22)) . '...' : $row['name']; $get_img_mimetype = Uploads::get_img_mimetype($row['type']); $size_img = ''; switch ($row['type']) { //Images case 'jpg': case 'png': case 'gif': case 'bmp': list($width_source, $height_source) = @getimagesize(PATH_TO_ROOT . '/upload/' . $row['path']); $size_img = ' (' . $width_source . 'x' . $height_source . ')'; $width_source = !empty($width_source) ? $width_source + 30 : 0; $height_source = !empty($height_source) ? $height_source + 30 : 0; $bbcode = '[img]/upload/' . $row['path'] . '[/img]'; $tinymce = '<img src="' . PATH_TO_ROOT . '/upload/' . $row['path'] . '" alt="' . $row['name'] . '" />'; $link = '/upload/' . $row['path'];
/** * @desc Prepares a string for it to be used in an URL (with only a-z, 0-9 and - characters). * @param string $string String to encode. * @return string The encoded string. */ public static function encode_rewrite($url) { $url = strtolower(TextHelper::html_entity_decode($url)); $url = strtr($url, ' абвгдезийклмнопртуфхцщъыьэя', '-aaaaaaceeeeiiiioooooouuuuyy'); $url = preg_replace('`([^a-z0-9]|[\\s])`', '-', $url); $url = preg_replace('`[-]{2,}`', '-', $url); $url = trim($url, ' -'); return $url; }
} $i++; } } } else { $j = 0; $result = PersistenceContext::get_querier()->select("SELECT g.id, g.idcat, g.name, g.path, g.timestamp, g.aprob, g.width, g.height, m.display_name, m.user_id, m.level, m.groups\n\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\tWHERE g.idcat = :idcat\n\t\t\tORDER BY g.timestamp\n\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('idcat' => $id_category, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())); while ($row = $result->fetch()) { //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle. if (!file_exists('pics/thumbnails/' . $row['path'])) { $Gallery->Resize_pics('pics/' . $row['path']); } //Redimensionnement + création miniature $name_cut = strlen(TextHelper::html_entity_decode($row['name'])) > 22 ? TextHelper::htmlentities(substr(TextHelper::html_entity_decode($row['name']), 0, 22)) . '...' : $row['name']; //On reccourci le nom s'il est trop long pour éviter de déformer l'administration. $name = TextHelper::html_entity_decode($row['name']); $name = strlen($name) > 20 ? substr($name, 0, 20) . '...' : $name; //On genère le tableau pour x colonnes $tr_start = is_int($j / $nbr_column_pics) ? '<tr>' : ''; $j++; $tr_end = is_int($j / $nbr_column_pics) ? '</tr>' : ''; //Affichage de l'image en grand. if ($config->get_pics_enlargement_mode() == GalleryConfig::FULL_SCREEN) { //Ouverture en popup plein écran. $display_link = HOST . DIR . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&cat=' . $row['idcat']); } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::POPUP) { //Ouverture en popup simple. $display_link = 'javascript:display_pics_popup(\'' . HOST . DIR . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&cat=' . $row['idcat']) . '\', \'' . $row['width'] . '\', \'' . $row['height'] . '\')'; } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::RESIZE) { //Ouverture en agrandissement simple. $display_link = 'javascript:display_pics(' . $row['id'] . ', \'' . HOST . DIR . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&cat=' . $row['idcat']) . '\', 0)';
/** * @desc Clean the url, replace special characters with underscore. * @param string The file name. * @return string The cleaned file name. */ private static function clean_filename($string) { $string = strtolower(TextHelper::html_entity_decode($string)); $string = strtr($string, ' ���������������������������', '-aaaaaaceeeeiiiioooooouuuuyy'); $string = preg_replace('`([^a-z0-9-]|[\\s])`', '_', $string); $string = preg_replace('`[_]{2,}`', '_', $string); $string = trim($string, ' _'); return $string; }
public static function Rename_file($id_file, $name, $previous_name, $user_id, $admin = false) { $info_cat = array('idcat' => '', 'user_id' => ''); try { $info_cat = self::$db_querier->select_single_row(PREFIX . "upload", array("idcat", "user_id"), 'WHERE id=:id', array('id' => $id_file)); } catch (RowNotFoundException $e) { } //Vérification de l'unicité du nom du fichier. $check_file = self::$db_querier->count(DB_TABLE_UPLOAD, 'WHERE idcat = :idcat AND name = :name AND id <> :id AND user_id = :user_id', array('idcat' => $info_cat['idcat'], 'name' => $name, 'id' => $id_file, 'user_id' => $user_id)); if ($check_file > 0 || preg_match('`/|\\\\|"|<|>|\\||\\?`', stripslashes($name))) { return '/'; } if ($admin) { self::$db_querier->update(DB_TABLE_UPLOAD, array('name' => $name), 'WHERE id = :id', array('id' => $id_file)); return stripslashes(strlen(TextHelper::html_entity_decode($name)) > 22 ? TextHelper::htmlentities(substr(TextHelper::html_entity_decode($name), 0, 22)) . '...' : $name); } else { if ($user_id == $info_cat['user_id']) { self::$db_querier->update(DB_TABLE_UPLOAD, array('name' => $name), 'WHERE id = :id', array('id' => $id_file)); return stripslashes(strlen(TextHelper::html_entity_decode($name)) > 22 ? TextHelper::htmlentities(substr(TextHelper::html_entity_decode($name), 0, 22)) . '...' : $name); } } return stripslashes(strlen(TextHelper::html_entity_decode($previous_name)) > 22 ? TextHelper::htmlentities(substr(TextHelper::html_entity_decode($previous_name), 0, 22)) . '...' : $previous_name); }
} $user_accounts_config = UserAccountsConfig::load(); //Avatar if (empty($row['user_avatar'])) { $user_avatar = $user_accounts_config->is_default_avatar_enabled() == '1' ? '<img src="../templates/' . AppContext::get_current_user()->get_theme() . '/images/' . $user_accounts_config->get_default_avatar_name() . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" />' : ''; } else { $user_avatar = '<img src="' . Url::to_rel($row['user_avatar']) . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" />'; } //Affichage du nombre de message. if ($row['posted_msg'] >= 1) { $posted_msg = '<a href="' . UserUrlBuilder::messages($row['user_id'])->rel() . '" class="small">' . $LANG['message_s'] . '</a>: ' . $row['posted_msg']; } else { $posted_msg = !$is_guest ? '<a href="' . PATH_TO_ROOT . '/forum/membermsg' . url('.php?id=' . $row['user_id'], '') . '" class="small">' . $LANG['message'] . '</a>: 0' : $LANG['message'] . ': 0'; } $user_sign_field = $extended_fields_cache->get_extended_field_by_field_name('user_sign'); $tpl->assign_block_vars('list', array('C_GROUP_COLOR' => !empty($group_color), 'C_GUEST' => empty($row['display_name']), 'CONTENTS' => FormatingHelper::second_parse($row['contents']), 'DATE' => $LANG['on'] . ' ' . Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'ID' => $row['id'], 'USER_RANK' => $row['warning_percentage'] < '100' || time() - $row['delay_banned'] < 0 ? $user_rank : LangLoader::get_message('banned', 'user-common'), 'USER_IMG_ASSOC' => $user_assoc_img, 'USER_AVATAR' => $user_avatar, 'USER_GROUP' => $user_groups, 'USER_DATE' => !$is_guest ? $LANG['registered_on'] . ': ' . Date::to_format($row['registered'], Date::FORMAT_DAY_MONTH_YEAR) : '', 'USER_MSG' => !$is_guest ? $posted_msg : '', 'USER_MAIL' => !empty($row['email']) && $row['show_email'] == '1' ? '<a href="mailto:' . $row['email'] . '" class="basic-button smaller">Mail</a>' : '', 'USER_SIGN' => !empty($row['user_sign']) && !empty($user_sign_field) && $user_sign_field['display'] ? '____________________<br />' . FormatingHelper::second_parse($row['user_sign']) : '', 'USER_WARNING' => $row['warning_percentage'], 'USER_PM' => !$is_guest && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL) ? '<a href="' . UserUrlBuilder::personnal_message($row['user_id'])->rel() . '" class="basic-button smaller">MP</a>' : '', 'USER_ONLINE' => '<i class="fa ' . (!empty($row['connect']) ? 'fa-online' : 'fa-offline') . '"></i>', 'USER_PSEUDO' => !empty($row['display_name']) ? wordwrap(TextHelper::html_entity_decode($row['display_name']), 13, '<br />', 1) : $LANG['guest'], 'LEVEL_CLASS' => UserService::get_level_class($row['level']), 'GROUP_COLOR' => $group_color, 'U_USER_PROFILE' => UserUrlBuilder::profile($row['user_id'])->rel(), 'U_VARS_ANCRE' => url('.php?id=' . $row['idtopic'], '-' . $row['idtopic'] . $rewrited_title . '.php'), 'U_FORUM_CAT' => '<a class="forum-mbrmsg-links" href="' . PATH_TO_ROOT . '/forum/forum' . url('.php?id=' . $row['idcat'], '-' . $row['idcat'] . $rewrited_cat_title . '.php') . '">' . $row['name'] . '</a>', 'U_TITLE_T' => '<a class="forum-mbrmsg-links" href="' . PATH_TO_ROOT . '/forum/topic' . url('.php?id=' . $row['idtopic'], '-' . $row['idtopic'] . $rewrited_title . '.php') . '">' . stripslashes($row['title']) . '</a>')); foreach ($displayed_extended_fields as $field_type) { $field = $extended_fields_cache->get_extended_field_by_field_name($field_type); if (!empty($row[$field_type]) && !empty($field) && $field['display']) { $button = ''; if ($field['regex'] == 4) { foreach (MemberShortTextExtendedField::$brands_pictures_list as $id => $parameters) { if (strstr($row[$field_type], $id)) { $button = '<a href="mailto:' . $row[$field_type] . '" class="basic-button smaller"><i class="fa ' . $parameters['picture'] . '"></i> ' . $parameters['title'] . '</a>'; } } } else { if ($field['regex'] == 5) { $button = '<a href="' . $row[$field_type] . '" class="basic-button smaller">' . LangLoader::get_message('regex.website', 'admin-user-common') . '</a>'; foreach (MemberShortTextExtendedField::$brands_pictures_list as $id => $parameters) { if (strstr($row[$field_type], $id)) {
} if (!in_array($row['cid'], $is_sub_forum)) { if ($row['nbr_msg'] !== '0') { //Si le dernier message lu est présent on redirige vers lui, sinon on redirige vers le dernier posté. if (!empty($row['last_view_id'])) { $last_msg_id = $row['last_view_id']; $last_page = 'idm=' . $row['last_view_id'] . '&'; $last_page_rewrite = '-0-' . $row['last_view_id']; } else { $last_msg_id = $row['last_msg_id']; $last_page = ceil($row['t_nbr_msg'] / $config->get_number_messages_per_page()); $last_page_rewrite = $last_page > 1 ? '-' . $last_page : ''; $last_page = $last_page > 1 ? 'pt=' . $last_page . '&' : ''; } $last_topic_title = ($config->is_message_before_topic_title_displayed() && $row['display_msg'] ? $config->get_message_before_topic_title() : '') . ' ' . $row['title']; $last_topic_title = stripslashes(strlen(TextHelper::html_entity_decode($last_topic_title)) > 20 ? TextHelper::substr_html($last_topic_title, 0, 20) . '...' : $last_topic_title); $group_color = User::get_group_color($row['groups'], $row['user_level']); $last = '<a href="topic' . url('.php?id=' . $row['tid'], '-' . $row['tid'] . '+' . Url::encode_rewrite($row['title']) . '.php') . '" class="small">' . $last_topic_title . '</a><br /> <a href="topic' . url('.php?' . $last_page . 'id=' . $row['tid'], '-' . $row['tid'] . $last_page_rewrite . '+' . Url::encode_rewrite($row['title']) . '.php') . '#m' . $last_msg_id . '" title=""><i class="fa fa-hand-o-right"></i></a> ' . $LANG['on'] . ' ' . Date::to_format($row['last_timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . '<br /> ' . $LANG['by'] . (!empty($row['display_name']) ? ' <a href="' . UserUrlBuilder::profile($row['last_user_id'])->rel() . '" class="small ' . UserService::get_level_class($row['user_level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . TextHelper::wordwrap_html($row['display_name'], 13) . '</a>' : ' ' . $LANG['guest']); } else { $row['last_timestamp'] = ''; $last = '<br />' . $LANG['no_message'] . '<br /><br />'; } //Vérirication de l'existance de sous forums. $subforums = ''; $children = ForumService::get_categories_manager()->get_categories_cache()->get_childrens($row['cid']); if ($children) { foreach ($children as $id => $child) { if ($child->get_id_parent() == $row['cid'] && ForumAuthorizationsService::check_authorizations($child->get_id())->read()) { $is_sub_forum[] = $child->get_id();
/** * @desc Inserts a carriage return every $lenght characters. It's equivalent to wordwrap PHP function but it can deal with the HTML entities. * An entity is coded on several characters and the wordwrap function counts several characters for an entity whereas it represents only one character. * @param string $str The string to wrap. * @param int $lenght The number of characters you want in a line. * @param string $cut_char The character to insert every $lenght characters. The default value is '<br />', the HTML carriage return tag. * @param bool $cut True if you accept that a word would be broken apart, false if you want to cut only on a blank character. * @return string The wrapped HTML string. */ public static function wordwrap_html($str, $lenght, $cut_char = '<br />', $cut = true) { $str = wordwrap(TextHelper::html_entity_decode($str), $lenght, $cut_char, $cut); return str_replace('<br />', '<br />', self::htmlspecialchars($str, ENT_NOQUOTES)); }
/** * @desc Clears a string of HTML code. * It replaces the paragraphes generated by TinyMCE by the br tag used in the PHPBoost HTML. * @param string[] $var The matched elemets * @return string The clean code. */ private static function clear_html_and_code_tag($var) { $var = preg_replace('`</p>\\s*<p>`i', "\n", $var); $var = str_replace('<br />', "\n", $var); $var = TextHelper::html_entity_decode($var); return $var; }
$nbr_msg_not_read = 0; $result = PersistenceContext::get_querier()->select("SELECT t.id AS tid, t.title, t.last_timestamp, t.last_user_id, t.last_msg_id, t.nbr_msg AS t_nbr_msg, t.display_msg, m.user_id, m.display_name as login, m.level as user_level, m.groups, v.last_view_id\n\t\tFROM " . PREFIX . "forum_topics t\n\t\tLEFT JOIN " . PREFIX . "forum_cats c ON c.id = t.idcat\n\t\tLEFT JOIN " . PREFIX . "forum_view v ON v.idtopic = t.id AND v.user_id = '" . AppContext::get_current_user()->get_id() . "'\n\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = t.last_user_id\n\t\tWHERE t.last_timestamp >= '" . $max_time_msg . "' AND (v.last_view_id != t.last_msg_id OR v.last_view_id IS NULL) AND c.id IN :authorized_categories\n\t\tORDER BY t.last_timestamp DESC", array('authorized_categories' => $authorized_categories)); while ($row = $result->fetch()) { //Si le dernier message lu est présent on redirige vers lui, sinon on redirige vers le dernier posté. if (!empty($row['last_view_id'])) { $last_msg_id = $row['last_view_id']; $last_page = 'idm=' . $row['last_view_id'] . '&'; $last_page_rewrite = '-0-' . $row['last_view_id']; } else { $last_msg_id = $row['last_msg_id']; $last_page = ceil($row['t_nbr_msg'] / $config->get_number_messages_per_page()); $last_page_rewrite = $last_page > 1 ? '-' . $last_page : ''; $last_page = $last_page > 1 ? 'pt=' . $last_page . '&' : ''; } $last_topic_title = ($config->is_message_before_topic_title_displayed() && $row['display_msg'] ? $config->get_message_before_topic_title() : '') . ' ' . $row['title']; $last_topic_title = strlen(TextHelper::html_entity_decode($last_topic_title)) > 25 ? TextHelper::substr_html($last_topic_title, 0, 25) . '...' : $last_topic_title; $last_topic_title = addslashes($last_topic_title); $row['login'] = !empty($row['login']) ? $row['login'] : $LANG['guest']; $group_color = User::get_group_color($row['groups'], $row['user_level']); $contents .= '<tr><td class="forum-notread" style="width:100%"><a href="topic' . url('.php?' . $last_page . 'id=' . $row['tid'], '-' . $row['tid'] . $last_page_rewrite . '+' . addslashes(Url::encode_rewrite($row['title'])) . '.php') . '#m' . $last_msg_id . '"><i class="fa fa-hand-o-right"></i></a> <a href="topic' . url('.php?id=' . $row['tid'], '-' . $row['tid'] . '+' . addslashes(Url::encode_rewrite($row['title'])) . '.php') . '" class="small">' . $last_topic_title . '</a></td><td class="forum-notread" style="white-space:nowrap">' . ($row['last_user_id'] != '-1' ? '<a href="' . UserUrlBuilder::profile($row['last_user_id'])->rel() . '" class="small ' . UserService::get_level_class($row['user_level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . addslashes($row['login']) . '</a>' : '<em>' . addslashes($LANG['guest']) . '</em>') . '</td><td class="forum-notread" style="white-space:nowrap">' . Date::to_format($row['last_timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . '</td></tr>'; $nbr_msg_not_read++; } $result->dispose(); $max_visible_topics = 10; $height_visible_topics = $nbr_msg_not_read < $max_visible_topics ? 23 * $nbr_msg_not_read : 23 * $max_visible_topics; echo "array_unread_topics[0] = '" . $nbr_msg_not_read . "';\n"; echo "array_unread_topics[1] = '" . '<a class="small" href="' . PATH_TO_ROOT . '/forum/unread.php" title="' . addslashes($LANG['show_not_reads']) . '">' . addslashes($LANG['show_not_reads']) . (AppContext::get_current_user()->get_id() !== -1 ? ' (' . $nbr_msg_not_read . ')' : '') . '</a>' . "';\n"; echo "array_unread_topics[2] = '" . '<div style="width:438px;height:' . max($height_visible_topics, 65) . 'px;overflow:auto;padding:0px;" onmouseover="forum_hide_block(\\\'forum_unread\\\', 1);" onmouseout="forum_hide_block(\\\'forum_unread\\\', 0);"><table class="module-table" style="margin:2px;width:99%">' . $contents . "</table></div>';"; } else { echo ''; }
public function Rename_pics($id_pics, $name, $previous_name) { PersistenceContext::get_querier()->update(GallerySetup::$gallery_table, array('name' => $name), 'WHERE id = :id', array('id' => $id_pics)); return stripslashes(strlen(TextHelper::html_entity_decode($name)) > 22 ? TextHelper::htmlentities(substr(TextHelper::html_entity_decode($name), 0, 22)) . PATH_TO_ROOT . '.' : $name); }