<commit_before><?php

  define('BASEPATH', 'Staff');
  require_once('../applications/wrapper.php');

  if( !$TANGO->perm->check('access_administration') ) { redirect(SITE_URL); }//Checks if user has permission to create a thread.
  require_once('template/top.php');
  $notice = '';

  function allowed_usergroups() {
    global $TANGO, $MYSQL;
    $query  = $MYSQL->get('{prefix}usergroups');
    $return = '<input type="checkbox" name="allowed_ug[]" value="0" CHECKED /> Guest<br />';
    foreach( $query as $u ) {
      $return .= '<input type="checkbox" name="allowed_ug[]" value="' . $u['id'] . '" /> ' . $u['group_name'] . '<br />';
    }
    return $return;
  }

  if( isset($_POST['create']) ) {
      try {

          /*foreach( $_POST as $parent => $child ) {
              $_POST[$parent] = clean($child);
          }*/

          NoCSRF::check( 'csrf_token', $_POST );

          $title = clean($_POST['cat_title']);
          $desc  = (!$_POST['cat_desc'])? '' : clean($_POST['cat_desc']);

          $all_u = (isset($_POST['allowed_ug']))? implode(',', $_POST['allowed_ug']) : '0';

          if( !$title ) {
              throw new Exception ('All fields are required!');
          } else {

              $data = array(
                  'category_title' => $title,
                  'category_desc' => $desc,
                  'allowed_usergroups' => $all_u
              );

              try {
                  $MYSQL->insert('{prefix}forum_category', $data);
                  redirect(SITE_URL . '/admin/manage_category.php/notice/create_success');
              } catch (mysqli_sql_exception $e) {
                  throw new Exception ('Error creating forum category.');
              }

          }

      } catch ( Exception $e ) {
          $notice .= $ADMIN->alert(
              $e->getMessage(),
              'danger'
          );
      }
  }<commit_msg>PDO: PDO added in admin/new_category.php<commit_after><?php

  define('BASEPATH', 'Staff');
  require_once('../applications/wrapper.php');

  if( !$TANGO->perm->check('access_administration') ) { redirect(SITE_URL); }//Checks if user has permission to create a thread.
  require_once('template/top.php');
  $notice = '';

  function allowed_usergroups() {
    global $TANGO, $MYSQL;
    //$query  = $MYSQL->get('{prefix}usergroups');
    $query  = $MYSQL->query('SELECT * FROM {prefix}usergroups');
    $return = '<input type="checkbox" name="allowed_ug[]" value="0" CHECKED /> Guest<br />';
    foreach( $query as $u ) {
      $return .= '<input type="checkbox" name="allowed_ug[]" value="' . $u['id'] . '" /> ' . $u['group_name'] . '<br />';
    }
    return $return;
  }

  if( isset($_POST['create']) ) {
      try {

          /*foreach( $_POST as $parent => $child ) {
              $_POST[$parent] = clean($child);
          }*/

          NoCSRF::check( 'csrf_token', $_POST );

          $title = clean($_POST['cat_title']);
          $desc  = (!$_POST['cat_desc'])? '' : clean($_POST['cat_desc']);

          $all_u = (isset($_POST['allowed_ug']))? implode(',', $_POST['allowed_ug']) : '0';

          if( !$title ) {
              throw new Exception ('All fields are required!');
          } else {

              /*$data = array(
                  'category_title' => $title,
                  'category_desc' => $desc,
                  'allowed_usergroups' => $all_u
              );*/
              $MYSQL->bindMore(array(
                  'category_title' => $title,
                  'category_desc' => $desc,
                  'allowed_usergroups' => $all_u
              ));

              try {
                  //$MYSQL->insert('{prefix}forum_category', $data);
                  $MYSQL->query('INSERT INTO {prefix}forum_category (category_title, category_desc, allowed_usergroups) VALUES (:category_title, :category_desc, :allowed_usergroups)');
                  redirect(SITE_URL . '/admin/manage_category.php/notice/create_success');
              } catch (mysqli_sql_exception $e) {
                  throw new Exception ('Error creating forum category.');
              }

          }

      } catch ( Exception $e ) {
          $notice .= $ADMIN->alert(
              $e->getMessage(),
              'danger'
          );
      }
  }
{'fraction_non_alphanumeric': 0.17796610169491525, 'fraction_numerical': 0.0009416195856873823, 'mean_word_length': 2.0263532763532766, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4000093', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1257, 'n_words': 243}