Esempio n. 1
0
 private function Post()
 {
     $table = strtolower(htmlspecialchars($_POST['values'][0], ENT_QUOTES));
     $query = "CREATE TABLE `" . DB_PREFIX . $table . "` (";
     $arrayWhat = array();
     $arrayValues = array();
     for ($k = 2; $k < count($_POST['values']); $k += 6) {
         $comment = htmlspecialchars($_POST['values'][$k], ENT_QUOTES);
         $name = htmlspecialchars($_POST['values'][$k + 1], ENT_QUOTES);
         $type = htmlspecialchars($_POST['values'][$k + 2], ENT_QUOTES);
         (int) ($length = htmlspecialchars($_POST['values'][$k + 3], ENT_QUOTES));
         $primary = htmlspecialchars($_POST['values'][$k + 4], ENT_QUOTES);
         $uniq = htmlspecialchars($_POST['values'][$k + 5], ENT_QUOTES);
         array_push($arrayWhat, '`table`,`name`,`title`,`timeSeconds`,`isEnabled`');
         array_push($arrayValues, "'{$table}','{$name}','{$comment}','" . ADMIN_CONFIGURATION::$CONFIG['timeSeconds'] . "','1'");
         $query .= " `{$name}` ";
         if ($type !== 'text' and $type !== 'date') {
             $query .= strtoupper($type) . "({$length}) ";
         } else {
             $query .= strtoupper($type) . ' ';
         }
         if ($primary == 'true') {
             $query .= " AUTO_INCREMENT PRIMARY KEY COMMENT '{$comment}', ";
         }
         if ($primary == 'false' and $uniq == 'true') {
             $query .= "COMMENT '{$comment}', UNIQUE ({$name}), ";
         }
         if ($primary == 'false' and $uniq == 'false') {
             $query .= " COMMENT '{$comment}',";
         }
     }
     $insert = DATABASE::query(mb_substr($query, 0, mb_strlen($query, "UTF-8") - 1, "UTF-8") . ')');
     if (is_bool($insert) && $insert == true) {
         echo '0';
     } else {
         echo $insert;
     }
     $insert2 = DATABASE::insert('admin_tabletitles', $arrayWhat, $arrayValues, 1);
     if (is_bool($insert2) && $insert2 == true or is_array($insert)) {
         echo '';
     }
 }