Exemple #1
0
 }
 echo '</div>';
 if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['csrf']) && check_csrf($_POST['csrf'], 'categories_csrf')) {
     if (isset($_POST['name']) && isset($_POST['text']) && isset($_POST['meta_title']) && isset($_POST['meta_desc'])) {
         $connect = '|';
         $connectids = array();
         if (isset($_POST['category'])) {
             foreach ($_POST['category'] as $index => $val) {
                 $v = intval($val);
                 if ($v > 0) {
                     $connect .= $v . '|';
                     $connectids[] = $v;
                 }
             }
         }
         if ($id = actions::add_category(array('istop' => isset($_GET['subcat']) ? 0 : 1, 'connect' => $connect, 'name' => $_POST['name'], 'description' => $_POST['text'], 'meta_title' => $_POST['meta_title'], 'meta_desc' => $_POST['meta_desc']))) {
             //add new connections
             foreach ($connectids as $connectid) {
                 $info2 = \query\main::category_infos($connectid);
                 $connect = $info2->connect . $id . "|";
                 actions::edit_category($connectid, array('connect' => $connect));
             }
             echo '<div class="a-success">' . $LANG['msg_added'] . '</div>';
         } else {
             echo '<div class="a-error">' . $LANG['msg_error'] . '</div>';
         }
     }
 }
 $csrf = $_SESSION['categories_csrf'] = \site\utils::str_random(10);
 $categories_while = \query\main::while_categories(array('max' => 0, 'show' => 'cats'));
 echo '<script>