1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| case 'EDIT_DELETE_CAT':
global $connection, $str_cats;
$categories = $connection->variable("cats");
if ($_POST['to_do_cat'] != 'none') {
if ($_POST['do_cat'] == "Supprimer") {
$categories_explode = explode(",", $categories);
for ($i = 0; $i < count($categories_explode); $i++) {
if ($categories_explode[$i] != $_POST['to_do_cat'] && !empty($categories_explode[$i]))
$str_cats .= $categories_explode[$i].',';
}
$str_cats = substr($str_cats, 0, strlen($str_cats) - 1);
$connection->query("UPDATE its_parametres SET valeur = '".$str_cats."' WHERE parametre = 'cats'");
$connection->query("UPDATE its_links SET cat = 'Divers' WHERE cat = '".$_POST['to_do_cat']."'");
}
elseif ($_POST['do_cat'] == "Editer") {
$cat = trim($_POST['name_new_cat']);
$categories_explode = explode(",", $categories);
for ($i = 0; $i < count($categories_explode); $i++) {
if ($categories_explode[$i] != $_POST['to_do_cat'] && !empty($categories_explode[$i]))
$str_cats .= $categories_explode[$i].',';
}
if (!preg_match('/'.$cat.'/', $str_cats)) {
$str_cats .= $cat;
echo 'ok';
$connection->query("UPDATE its_parametres SET valeur = ".quote_smart($str_cats)." WHERE parametre = 'cats'");
}
else {
$_SESSION['erreur'] = "Catégoris déjà existante";
}
}
}
header("Location: account.php?op=liens");
break; |
Partager