Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 15th, 2012  |  syntax: PHP  |  size: 1.33 KB  |  views: 1,919  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $controller = $_POST['controller'];
  2. $pieces = explode("~", $controller);
  3. $table = $pieces[0];
  4. $qt =  $pieces[1];
  5. $return =  $pieces[2];
  6. $id =  $pieces[3];
  7. $hack =  $pieces[4];    
  8.  
  9. if ($qt == insert) $qt = 'INSERT INTO';
  10. if ($qt == update) { $qt = 'UPDATE'; $end = "WHERE ID = '$id'"; }
  11. $pre = array_keys( $_POST );
  12.  
  13. //---------------------------------------------------------
  14.  
  15. mysql_query ("CREATE TABLE IF NOT EXISTS `$table` (`ID` INT NOT NULL AUTO_INCREMENT , PRIMARY KEY ( `id` ) )");
  16.  
  17. //---------------------------------------------------------
  18.  
  19. $count = count($pre); $count = $count - 2;
  20. $sql = "$qt $table SET";
  21. for ($i=0; $i < $count; $i++)
  22. {
  23. $x=$i+1;
  24. $y = $_POST[$pre[$x]];
  25. $d = $y;
  26.  
  27.                 $d = htmlentities($d, ENT_QUOTES);
  28.  
  29. mysql_query ("ALTER TABLE `$table` ADD `$pre[$x]` TEXT NOT NULL");
  30. $sql .= " `$pre[$x]` = '$d',";
  31. }
  32. $sql .= " ID = '$id' $end";
  33. $query = mysql_query($sql) or die("$sql_error" . mysql_error());
  34.  
  35. //--------------------------------------------------------- [ TABLE TYPE HACK ]
  36. if (empty($hack)) { } else {
  37. $pieces = explode("/", $hack);
  38. $h0 = $pieces[0];
  39. $h1 = $pieces[1];
  40. $h2 = $pieces[2];
  41. $h3 = $pieces[3];
  42. $h4 = $pieces[4];
  43. $h5 = $pieces[5];
  44.  
  45. mysql_query ("ALTER TABLE `$table` $h0 $h1 $h2 $h3 $h4 $h5");
  46. $query = mysql_query($sql) or die("$sql_error" . mysql_error());