protected function main() { // Seuls les membres peuvent créer des brouillons if (!is_logged_in()) { redir(Nw::$lang['common']['need_login'], false, 'users-10.html'); } // Si le paramètre ID manque if (empty($_GET['id']) || !is_numeric($_GET['id'])) { header('Location: ./'); } // Cette news existe vraiment ? inc_lib('news/news_exists'); if (news_exists($_GET['id']) == false) { redir(Nw::$lang['news']['news_not_exist'], false, './'); } // Pour rediriger le visiteur d'où il est venu if (!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], Nw::$site_url) !== false && strpos($_SERVER['HTTP_REFERER'], Nw::$site_url . 'news-26-' . $_GET['id'] . '.html') === false) { $_SESSION['nw_referer_edit'] = $_SERVER['HTTP_REFERER']; } $type_vote = true; // S'il s'agit d'un vote négatif (pour les news en attente) if (isset($_GET['id2']) && $_GET['id2'] == 0) { $type_vote = false; } inc_lib('news/get_info_news'); inc_lib('news/add_vote_news'); $donnees_news = get_info_news($_GET['id']); $response = add_vote_news($_GET['id'], $type_vote); $vote_redir_defaut = $donnees_news['n_etat'] == 2 ? 'news-80.html' : 'news-10-' . intval($_GET['id']) . '.html'; // Vote bien ajouté if ($response[0]) { // On publie la news automatiquement quand le nbr de votes nécessaires a été atteint if ($donnees_news['n_etat'] == 2 && $response[1] >= Nw::$pref['nb_votes_valid_news']) { if ($type_vote) { inc_lib('news/valid_news_direct'); valid_news_direct($_GET['id']); $text_redir = sprintf(Nw::$lang['news']['news_publiee_byvotes'], $response[1]); $vote_redir_defaut = './'; } else { inc_lib('news/archive_news'); archive_news($_GET['id']); $text_redir = sprintf(Nw::$lang['news']['news_archivee_byvotes'], $response[1]); $vote_redir_defaut = './'; } } else { $text_redir = Nw::$lang['news']['vote_news_ok']; } } else { $text_redir = Nw::$lang['news']['vote_news_pasok']; } $link_redir = !empty($_SESSION['nw_referer_edit']) ? $_SESSION['nw_referer_edit'] : $vote_redir_defaut; redir($text_redir, true, $link_redir); }
private function vote() { $id_news = (int) $_GET['id']; // Cette news existe vraiment ? inc_lib('news/news_exists'); if (!news_exists($_GET['id'])) { header('Location: mobile.html'); } $type_vote = True; if (isset($_GET['id2']) and $_GET['id2'] != '') { $type_vote = (int) $_GET['id2'] == 1; } inc_lib('news/add_vote_news'); add_vote_news($id_news, $type_vote); header('Location: mobile-10-' . $id_news . '.html'); }
} elseif ($_GET['act'] == 'vote_attente') { if (!is_logged_in()) { exit; } if ($_POST['type'] == 'moins') { $prefix = 'vote_moins_'; $return_img = 'vote_moins'; $type = false; } else { $prefix = 'vote_plus_'; $return_img = 'vote_plus'; $type = true; } $id_news = explode($prefix, $_POST['id']); inc_lib('news/add_vote_news'); $response = add_vote_news($id_news[1], $type); if ($response[0]) { echo '<img src="themes/1/images/icones/' . $return_img . '.png" alt="" /><span class="already_voted">' . $response[1] . '</a>'; } else { echo '<img src="themes/1/images/icones/' . $return_img . '.png" alt="" /> ' . $response[1]; } } elseif ($_GET['act'] == 'vote_cmt') { if (!is_logged_in()) { exit; } $id_cmt = explode('vote_cmt_', $_POST['id']); inc_lib('news/add_vote_cmt'); $response = add_vote_cmt($id_cmt[1]); $query = Nw::$DB->query('SELECT c_plussoie FROM ' . Nw::$prefix_table . 'news_commentaires WHERE c_id = ' . intval($id_cmt[1])) or Nw::$DB->trigger(__LINE__, __FILE__); $dn = $query->fetch_assoc(); echo $dn['c_plussoie'];