$liste = isset($_REQUEST['liste']) ? intval($_REQUEST['liste']) : 0; $message = ''; $code = ''; if (empty($action) && preg_match('/([a-z0-9]{20})(?:&|$)/i', $_SERVER['QUERY_STRING'], $match)) { $code = $match[1]; } else { if (!empty($action) && !empty($email) && strlen($code) == 32) { $code = substr($code, 0, 20); } } if (!empty($action) || !empty($code)) { // // Purge des éventuelles inscriptions dépassées // pour parer au cas d'une réinscription // purge_liste(); require WA_ROOTDIR . '/includes/class.form.php'; if (!empty($action)) { if (in_array($action, array('inscription', 'setformat', 'desinscription'))) { $sql = "SELECT liste_id, liste_format, sender_email, liste_alias, limitevalidate,\n\t\t\t\t\tliste_name, form_url, return_email, liste_sig, use_cron, confirm_subscribe\n\t\t\t\tFROM " . LISTE_TABLE . "\n\t\t\t\tWHERE liste_id = " . $liste; if (!($result = $db->query($sql))) { trigger_error('Impossible d\'obtenir les données sur la liste', ERROR); } if ($listdata = $result->fetch()) { $wanewsletter = new Wanewsletter($listdata); $wanewsletter->message =& $message; $wanewsletter->do_action($action, $email, $format); } else { $message = $lang['Message']['Unknown_list']; } } else {
$message .= '<br /><br /><input type="checkbox" id="delete_all" name="delete_all" value="1" /> <label for="delete_all">' . $lang['Delete_abo_logs'] . '</label>'; } else { $output->addHiddenField('delete_all', '1'); $message = $lang['Delete_all']; } $output->addHiddenField('action', 'delete'); $output->addHiddenField('sessid', $session->session_id); $output->page_header(); $output->set_filenames(array('body' => 'confirm_body.tpl')); $output->assign_vars(array('L_CONFIRM' => $lang['Title']['confirm'], 'TEXTE' => $message, 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'S_HIDDEN_FIELDS' => $output->getHiddenFields(), 'U_FORM' => sessid('./view.php?mode=liste'))); $output->pparse('body'); $output->page_footer(); } } else { if ($action == 'purge') { $abo_deleted = purge_liste($listdata['liste_id'], $listdata['limitevalidate'], $listdata['purge_freq']); $output->redirect('./view.php?mode=liste', 4); $message = sprintf($lang['Message']['Success_purge'], $abo_deleted); $message .= '<br /><br />' . sprintf($lang['Click_return_liste'], '<a href="' . sessid('./view.php?mode=liste') . '">', '</a>'); $output->message($message); } } } // // Récupération des nombres d'inscrits // $num_inscrits = 0; $num_temp = 0; $last_log = 0; $sql = "SELECT COUNT(*) AS num_abo, confirmed\n\t\tFROM " . ABO_LISTE_TABLE . "\n\t\tWHERE liste_id = {$listdata['liste_id']}\n\t\tGROUP BY confirmed"; if (!($result = $db->query($sql))) {
/** * purge_liste() * * Fonction de purge de la table des abonn�s * Retourne le nombre d'entr�es supprim�es * Fonction r�cursive * * @param integer $liste_id Liste concern�e * @param integer $limitevalidate Limite de validit� pour confirmer une inscription * @param integer $purge_freq Fr�quence des purges * * @return integer */ function purge_liste($liste_id = 0, $limitevalidate = 0, $purge_freq = 0) { global $db, $nl_config; if (!$liste_id) { $total_entries_deleted = 0; $sql = "SELECT liste_id, limitevalidate, purge_freq \n\t\t\tFROM " . LISTE_TABLE . " \n\t\t\tWHERE purge_next < " . time() . " \n\t\t\t\tAND auto_purge = " . TRUE; if (!($result = $db->query($sql))) { trigger_error('Impossible d\'obtenir les listes de diffusion � purger', ERROR); } while ($row = $result->fetch()) { $total_entries_deleted += purge_liste($row['liste_id'], $row['limitevalidate'], $row['purge_freq']); } // // Optimisation des tables // $db->vacuum(array(ABONNES_TABLE, ABO_LISTE_TABLE)); return $total_entries_deleted; } else { $sql = "SELECT abo_id\n\t\t\tFROM " . ABO_LISTE_TABLE . "\n\t\t\tWHERE liste_id = {$liste_id}\n\t\t\t\tAND confirmed = " . SUBSCRIBE_NOT_CONFIRMED . "\n\t\t\t\tAND register_date < " . (time() - $limitevalidate * 86400); if (!($result = $db->query($sql))) { trigger_error('Impossible d\'obtenir les entr�es � supprimer de la table abo_liste', ERROR); } $abo_ids = array(); while ($abo_id = $result->column('abo_id')) { array_push($abo_ids, $abo_id); } $result->free(); if (($num_abo_deleted = count($abo_ids)) > 0) { $sql_abo_ids = implode(', ', $abo_ids); $db->beginTransaction(); if (!SQL_SUBSELECT_SUPPORTED) { $sql = "SELECT abo_id\n\t\t\t\t\tFROM " . ABO_LISTE_TABLE . "\n\t\t\t\t\tWHERE abo_id IN({$sql_abo_ids})\n\t\t\t\t\tGROUP BY abo_id\n\t\t\t\t\tHAVING COUNT(abo_id) = 1"; if ($result = $db->query($sql)) { $abo_ids = array(); while ($abo_id = $result->column('abo_id')) { array_push($abo_ids, $abo_id); } if (count($abo_ids) > 0) { $sql = "DELETE FROM " . ABONNES_TABLE . " \n\t\t\t\t\t\t\tWHERE abo_id IN(" . implode(', ', $abo_ids) . ")"; if (!$db->query($sql)) { trigger_error('Impossible de supprimer les entr�es inutiles de la table des abonn�s', ERROR); } } } } else { $sql = "DELETE FROM " . ABONNES_TABLE . "\n\t\t\t\t\tWHERE abo_id IN(\n\t\t\t\t\t\tSELECT abo_id\n\t\t\t\t\t\tFROM " . ABO_LISTE_TABLE . "\n\t\t\t\t\t\tWHERE abo_id IN({$sql_abo_ids})\n\t\t\t\t\t\tGROUP BY abo_id\n\t\t\t\t\t\tHAVING COUNT(abo_id) = 1\n\t\t\t\t\t)"; if (!$db->query($sql)) { trigger_error('Impossible de supprimer les entr�es inutiles de la table des abonn�s', ERROR); } } $sql = "DELETE FROM " . ABO_LISTE_TABLE . "\n\t\t\t\tWHERE abo_id IN({$sql_abo_ids})\n\t\t\t\t\tAND liste_id = " . $liste_id; if (!$db->query($sql)) { trigger_error('Impossible de supprimer les entr�es de la table abo_liste', ERROR); } $db->commit(); } $sql = "UPDATE " . LISTE_TABLE . " \n\t\t\tSET purge_next = " . (time() + $purge_freq * 86400) . " \n\t\t\tWHERE liste_id = " . $liste_id; if (!$db->query($sql)) { trigger_error('Impossible de mettre � jour la table liste', ERROR); } return $num_abo_deleted; } }