Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 33.27 KB | None | 0 0
  1. <?php
  2. header('Content-Type: text/html; charset=UTF-8');
  3.  
  4. ini_set('display_errors', 1);
  5.  
  6. require('../../board/lib/common.php');
  7.  
  8. //if (!$log)
  9. //  die('nah lol');
  10.  
  11.  
  12. // kill magic_quotes but alsdjf
  13. if (get_magic_quotes_gpc()) {
  14. foreach ($_GET as $k => $v) $_GET[$k] = stripslashes($v);
  15. foreach ($_POST as $k => $v) $_POST[$k] = stripslashes($v);
  16. }
  17.  
  18. if (isset($_GET['e'])) { $_GET['act'] = 'edit'; $_GET['id'] = $_GET['e']; }
  19.  
  20. // the array of actions we can do, which include listing certain types
  21. $actions = array('list', 'edit', 'modsprite', 'submitsprite', 'listunused', 'listunknown', 'listknown', 'listcomplete');
  22. $action = $_GET['act'];
  23. if (!in_array($action, $actions)) $action = 'list';
  24.    
  25.  
  26. print "
  27. <html>
  28.  <head>
  29.    <meta http-equiv='Content-Type' content='text/html;charset=utf-8'>
  30. <link href=\"icon.png\" rel=\"icon\" type=\"image/png\" />
  31.    <style type='text/css'>
  32.      body { font-family: Arial, sans-serif; font-size: 13px; }
  33.      div.unusedp, div.unknownp, div.knownp, div.completep { border-top: 1px solid #000; border-bottom: 1px solid #000; text-align: center; font-size: 11px; line-height: 16px; float: left; height: 16px; }
  34.      /*div.unusedp { background: #d6c6ff; border-right: 1px solid #000; }*/
  35.      div.unknownp { background: #ffc9cd; border-right: 1px solid #000; }
  36.      div.knownp { background: #ffd696; border-right: 2px solid #000; }
  37.      div.completep { background: #c6ff9b; border-left: 1px solid #000; border-right: 2px solid #000; }
  38.      tr.unknown { background: #ffc9cd; }
  39.      tr.known { background: #ffd696; }
  40.      tr.complete { background: #c6ff9b; }
  41.      td.original { background: #d6c6ff; border: 1px solid #000; }
  42.      table.sprites td { padding: 2px; }
  43.      table.data td { background: #fff; font-size: 12px; }
  44.      table.origdata td { }
  45.      table.origdata tr.datarow td { border-top: 1px solid #000; font-family: monospace; padding: 0px; }
  46.      div.groupbox { border: 1px solid #000; width: 80%; padding: 2px; }
  47.      div.groupbox div.header { background: #d1ecff; padding: 2px; }
  48.      div.groupbox div.content { padding: 6px; }
  49.      div.groupbox form { margin: 0px; }
  50.      div.groupbox input.submit { margin: 6px 4px 0px 4px; }
  51.      div.groupbox input.text, div.groupbox select { border: 1px solid #303030; font-family: Arial, sans-serif; font-size: 12px; }
  52.      hr { color: #000000; background-color: #000000; height: 1px; border: 0; margin: 4px 0px; }
  53.      table.fieldeditor td { padding: 0px; }
  54.      table.fieldeditor tr.header td { font-size: 9px; }
  55.       textarea { resize: none; }
  56.    </style>
  57.  </head>
  58.  <body>
  59.    <h1>NSMBW Sprite Database</h1>
  60.     <br>";
  61.  
  62.   // if we're looking at the entire list
  63.   switch ($action) {
  64.     case 'list':
  65.      
  66.       $gettotal = mysqli_fetch_array(Query('select count(id) from nsmbw_sprites WHERE id BETWEEN 0 AND 723'));
  67.       $getoriginal = mysqli_fetch_array(Query('select count(id) from nsmbw_sprites where orig = 1 AND id BETWEEN 0 AND 723'));
  68.       $getknown = mysqli_fetch_array(Query('select count(id) from nsmbw_sprites where known = 1 AND id BETWEEN 0 AND 723'));
  69.       $getcomplete = mysqli_fetch_array(Query('select count(id) from nsmbw_sprites where complete = 1 AND id BETWEEN 0 AND 723'));
  70.  
  71.       $fields = array();
  72.       $getfields = Query('select * from nsmbw_fields order by CAST(nybble as SIGNED INTEGER) asc');
  73.       while ($row = mysqli_fetch_array($getfields)) {
  74.         $s = $row[1];
  75.         if (!isset($fields[$s])) $fields[$s] = array();
  76.         $fields[$s][] = $row;
  77.       }
  78.  
  79.       // nab our values for complete, original, known, and unknown.
  80.       $c = intval($getcomplete[0]);
  81.       $o = $getoriginal[0];
  82.       $k = $getknown[0] - $c;
  83.       $u = $gettotal[0] - $k - $c;// - $o;
  84.      
  85.       $ct = $c + $k + $u;
  86.      
  87.       // generates a random number inbetween 0, and 723.
  88.       // used for a random sprite chooser
  89.       $takemesomewhere = rand(0, 482);
  90.      
  91.       // calculating percents, basic algebra
  92.       // complete divided by the total, times by 100.
  93.       $cpercent = $c / $ct * 100;
  94.       $kpercent = $k / $ct * 100;
  95.       $upercent = $u / $ct * 100;
  96.      
  97.       print "<title>NSMBW Sprite Database</title>";
  98.      
  99.       $cu = $u - 1;
  100.      
  101.       // we have our marker bar here, along with the amount inside each section, along with a percent complete.
  102.       print "&nbsp;{$gettotal[0]} total, $o unused";
  103.       if ($c > 0) print "<div class='completep' style='width: {$c}px'>$c (" . round($cpercent) . "%)</div>";
  104.       if ($k > 0) print "<div class='knownp' style='width: {$k}px'>$k (" . round($kpercent) . "%)</div>";
  105.       if ($u > 0) print "<div class='unknownp' style='width: {$cu}px'>$cu (" . round($upercent) . "%)</div>";
  106.       //print "<div class='unusedp' style='width: {$o}px'>$o</div>";
  107.       print "<br><br>The above bar needs <i>more green</i>. HELP US MAKE IT HAPPEN!<br>";
  108.      
  109.    
  110.       print "<br><br>Is the data in your Reggie outdated? <a href='spritexml.php'>Click here</a> for an automatically generated version of spritedata.xml which you can put into your Reggie data folder containing all the data listed here!<br>
  111. Here is how the system works. All of the sprites, used and unused, are listed here. You document the data of the sprite, and mark it.<br>
  112. <ul>
  113. <li>Complete (Green) - All of the data is documented. All of the possible nybbles, and the name and description are clear.</li>
  114. <li>Known (Orange) - Sprite's function is known. However, it's nybbles are not known.</li>
  115. <li>Unknown (Red) - Nothing is known about the sprite.</li>
  116. <li>Unused (Purple) - The sprite is not used in the retail game.</li>
  117. </ul>
  118. Please keep this database clean. Any abuse will lead to an entire ban from the server. I can see when somebody is misusing this database.<br><br>
  119. Please, don't mark an object complete when there's missing sprite data. Make sure everything is documented.<br><br>
  120.  
  121. Font colors are allowed in nybble descriptions and sprite notes. Just use this syntax:<br>
  122. &#60;font color=\"COLOR\"&#62;your text here&#60;/font&#62;<br>
  123. You can use these basic colors: purple, red, blue, green, yellow, and many more.
  124. <br><br>
  125.  
  126. Filter Results -- • Regular • <a href='?act=listunknown'>Unknown</a> • <a href='?act=listknown'>Known</a> • <a href='?act=listcomplete'>Complete</a> • <a href='?act=listunused'>Unused</a><br><br>
  127. <a href='spriteDB.php?e=" . $takemesomewhere . "'>Random Sprite</a><br>
  128. ";
  129.  
  130.   if ($loguser['primarygroup'] == -1)
  131.         print "<h1>You can view this database, however, you can't edit it. You are banned.</h1>";
  132.   print "<br><br>";
  133.   // we begin to print out table with entries
  134.   print "<table style='width: 80%' class='sprites'><tr><td style='width: 48px'>ID:</td><td>Name:</td></tr>";
  135.   $getsprites = Query('select * from nsmbw_sprites where id BETWEEN 0 AND 723 order by id');
  136.   while ($row = mysqli_fetch_array($getsprites)) {
  137.     if ($row[2] == 0) {
  138.       $class = 'unknown';
  139.     } else {
  140.       if ($row[3] == 0) {
  141.         $class = 'known';
  142.       } else {
  143.         $class = 'complete';
  144.       }
  145.     }
  146.  
  147.     if ($row[4] == 0) {
  148.       $orig = '';
  149.       $origs = '';
  150.     } else {
  151.       $orig = " class='original'";
  152.       $origs = '*';
  153.     }
  154.  
  155.     print "<tr class='$class'><td{$orig}><a href='spriteDB.php?e=$row[0]'>$row[0]</a>{$origs}</td><td>".htmlspecialchars($row[1]);
  156.  
  157.     if (isset($fields[$row[0]])) {
  158.       print "<table style='width: 100%' class='data'>";
  159.       foreach ($fields[$row[0]] as $field) {
  160.         print "<tr><td>";
  161.         switch ($field[2]) {
  162.           case 'checkbox':
  163.             print "<b>".htmlspecialchars($field[6])."</b>: checkbox on nybble ".htmlspecialchars($field[5])." with mask ".htmlspecialchars($field[4]);
  164.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  165.             break;
  166.           case 'value':
  167.             print "<b>".htmlspecialchars($field[6])."</b>: value at nybble ".htmlspecialchars($field[5]);
  168.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  169.             break;
  170.           case 'index':
  171.             print "<b>".htmlspecialchars($field[6])."</b>: index at nybble ".htmlspecialchars($field[5]);
  172.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  173.             break;
  174.           case 'list':
  175.             //$listentries = str_replace("\n", ', ', $field[4]);
  176.             //$listentries = substr($listentries, 0, -2);
  177.             $listentries = str_replace("\n", ', ', rtrim($field[4]));
  178.             print "<b>".htmlspecialchars($field[6])."</b>: list at nybble ".htmlspecialchars($field[5]).": $listentries";
  179.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  180.             break;
  181.         }
  182.         print "</td></tr>";
  183.       }
  184.       print "</table>";
  185.     }
  186.  
  187.     print "</td></tr>";
  188.   }
  189.   print "</table>";
  190.  
  191.   break;
  192.  
  193. // we list unused stuff here
  194. case 'listunused':
  195. print "<title>NSMBW Sprite Database</title>";
  196.   $fields = array();
  197.   $getfields = Query('select * from nsmbw_fields order by CAST(nybble as SIGNED INTEGER) asc');
  198.   while ($row = mysqli_fetch_array($getfields)) {
  199.     $s = $row[1];
  200.     if (!isset($fields[$s])) $fields[$s] = array();
  201.     $fields[$s][] = $row;
  202.   }
  203.  
  204. print "Filter Results -- • <a href='?act=list'>Regular</a> • <a href='?act=listunknown'>Unknown</a> • <a href='?act=listknown'>Known</a> • <a href='?act=listcomplete'>Complete</a> • Unused<br>";
  205.  
  206.   if ($loguser['primarygroup'] == -1)
  207.         print "<h1>You can view this database, however, you can't edit it. You are banned.</h1>";
  208.   print "<br><br>";
  209.   print "<table style='width: 80%' class='sprites'><tr><td style='width: 48px'>ID:</td><td>Name:</td></tr>";
  210.   $getsprites = Query('SELECT * FROM nsmbw_sprites WHERE orig=1 AND id BETWEEN 0 AND 723');
  211.   while ($row = mysqli_fetch_array($getsprites)) {
  212.     if ($row[2] == 0) {
  213.       $class = 'unknown';
  214.     } else {
  215.       if ($row[3] == 0) {
  216.         $class = 'known';
  217.       } else {
  218.         $class = 'complete';
  219.       }
  220.     }
  221.  
  222.     if ($row[4] == 0) {
  223.       $orig = '';
  224.       $origs = '';
  225.     } else {
  226.       $orig = " class='original'";
  227.       $origs = '*';
  228.     }
  229.  
  230.     if (!$loguserid)
  231.         print "<tr class='$class'><td{$orig}>$row[0]{$origs}</td><td>".htmlspecialchars($row[1]);
  232.     else
  233.         print "<tr class='$class'><td{$orig}><a href='spriteDB.php?e=$row[0]'>$row[0]</a>{$origs}</td><td>".htmlspecialchars($row[1]);
  234.  
  235.     if (isset($fields[$row[0]])) {
  236.       print "<table style='width: 100%' class='data'>";
  237.       foreach ($fields[$row[0]] as $field) {
  238.         print "<tr><td>";
  239.         switch ($field[2]) {
  240.           case 'checkbox':
  241.             print "<b>".htmlspecialchars($field[6])."</b>: checkbox on nybble ".htmlspecialchars($field[5])." with mask ".htmlspecialchars($field[4]);
  242.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]);
  243.             break;
  244.           case 'value':
  245.             print "<b>".htmlspecialchars($field[6])."</b>: value at nybble ".htmlspecialchars($field[5]);
  246.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  247.             break;
  248.           case 'index':
  249.             print "<b>".htmlspecialchars($field[6])."</b>: index at nybble ".htmlspecialchars($field[5]);
  250.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  251.             break;
  252.           case 'list':
  253.             $listentries = str_replace("\n", ', ', rtrim($field[4]));
  254.             print "<b>".htmlspecialchars($field[6])."</b>: list at nybble ".htmlspecialchars($field[5]).": $listentries";
  255.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  256.             break;
  257.         }
  258.         print "</td></tr>";
  259.       }
  260.       print "</table>";
  261.     }
  262.  
  263.     print "</td></tr>";
  264.   }
  265.   print "</table>";
  266.  
  267.   break;   
  268.  
  269. case 'listunknown':
  270.  print "<title>NSMBW Sprite Database</title>";
  271.   $fields = array();
  272.   $getfields = Query('select * from nsmbw_fields order by CAST(nybble as SIGNED INTEGER) asc');
  273.   while ($row = mysqli_fetch_array($getfields)) {
  274.     $s = $row[1];
  275.     if (!isset($fields[$s])) $fields[$s] = array();
  276.     $fields[$s][] = $row;
  277.   }
  278.  
  279. print "Filter Results -- • <a href='?act=list'>Regular</a> • Unknown • <a href='?act=listknown'>Known</a> • <a href='?act=listcomplete'>Complete</a> • <a href='?act=listunused'>Unused</a><br>";
  280.  
  281.   if ($loguser['primarygroup'] == -1)
  282.         print "<h1>You can view this database, however, you can't edit it. You are banned.</h1>";
  283.   print "<br><br>";
  284.   print "<table style='width: 80%' class='sprites'><tr><td style='width: 48px'>ID:</td><td>Name:</td></tr>";
  285.   $getsprites = Query('SELECT * FROM nsmbw_sprites WHERE known=0 AND complete=0 AND id BETWEEN 0 AND 723');
  286.   while ($row = mysqli_fetch_array($getsprites)) {
  287.     if ($row[2] == 0) {
  288.       $class = 'unknown';
  289.     } else {
  290.       if ($row[3] == 0) {
  291.         $class = 'known';
  292.       } else {
  293.         $class = 'complete';
  294.       }
  295.     }
  296.  
  297.     if ($row[4] == 0) {
  298.       $orig = '';
  299.       $origs = '';
  300.     } else {
  301.       $orig = " class='original'";
  302.       $origs = '*';
  303.     }
  304.  
  305.     if (!$loguserid)
  306.         print "<tr class='$class'><td{$orig}>$row[0]{$origs}</td><td>".htmlspecialchars($row[1]);
  307.     else
  308.         print "<tr class='$class'><td{$orig}><a href='spriteDB.php?e=$row[0]'>$row[0]</a>{$origs}</td><td>".htmlspecialchars($row[1]);
  309.  
  310.     if (isset($fields[$row[0]])) {
  311.       print "<table style='width: 100%' class='data'>";
  312.       foreach ($fields[$row[0]] as $field) {
  313.         print "<tr><td>";
  314.         switch ($field[2]) {
  315.           case 'checkbox':
  316.             print "<b>".htmlspecialchars($field[6])."</b>: checkbox on nybble ".htmlspecialchars($field[5])." with mask ".htmlspecialchars($field[4]);
  317.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  318.             break;
  319.           case 'value':
  320.             print "<b>".htmlspecialchars($field[6])."</b>: value at nybble ".htmlspecialchars($field[5]);
  321.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  322.             break;
  323.           case 'index':
  324.             print "<b>".htmlspecialchars($field[6])."</b>: index at nybble ".htmlspecialchars($field[5]);
  325.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  326.             break;
  327.           case 'list':
  328.             //$listentries = str_replace("\n", ', ', $field[4]);
  329.             //$listentries = substr($listentries, 0, -2);
  330.             $listentries = str_replace("\n", ', ', rtrim($field[4]));
  331.             print "<b>".htmlspecialchars($field[6])."</b>: list at nybble ".htmlspecialchars($field[5]).": $listentries";
  332.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  333.             break;
  334.         }
  335.         print "</td></tr>";
  336.       }
  337.       print "</table>";
  338.     }
  339.  
  340.     print "</td></tr>";
  341.   }
  342.   print "</table>";
  343.  
  344.   break;   
  345.  
  346. case 'listknown':
  347.  print "<title>NSMBW Sprite Database</title>";
  348.   $fields = array();
  349.   $getfields = Query('select * from nsmbw_fields order by CAST(nybble as SIGNED INTEGER) asc');
  350.   while ($row = mysqli_fetch_array($getfields)) {
  351.     $s = $row[1];
  352.     if (!isset($fields[$s])) $fields[$s] = array();
  353.     $fields[$s][] = $row;
  354.   }
  355. print "Filter Results -- • <a href='?act=list'>Regular</a> • <a href='?act=listunknown'>Unknown</a> • Known • <a href='?act=listcomplete'>Complete</a> • <a href='?act=listunused'>Unused</a><br>";
  356.  
  357.   if ($loguser['primarygroup'] == -1)
  358.         print "<h1>You can view this database, however, you can't edit it. You are banned.</h1>";
  359.   print "<br><br>";
  360.   print "<table style='width: 80%' class='sprites'><tr><td style='width: 48px'>ID:</td><td>Name:</td></tr>";
  361.   $getsprites = Query('SELECT * FROM nsmbw_sprites WHERE known=1 AND complete=0 AND id BETWEEN 0 AND 723');
  362.   while ($row = mysqli_fetch_array($getsprites)) {
  363.     if ($row[2] == 0) {
  364.       $class = 'unknown';
  365.     } else {
  366.       if ($row[3] == 0) {
  367.         $class = 'known';
  368.       } else {
  369.         $class = 'complete';
  370.       }
  371.     }
  372.  
  373.     if ($row[4] == 0) {
  374.       $orig = '';
  375.       $origs = '';
  376.     } else {
  377.       $orig = " class='original'";
  378.       $origs = '*';
  379.     }
  380.  
  381.     if (!$loguserid)
  382.         print "<tr class='$class'><td{$orig}>$row[0]{$origs}</td><td>".htmlspecialchars($row[1]);
  383.     else
  384.         print "<tr class='$class'><td{$orig}><a href='spriteDB.php?e=$row[0]'>$row[0]</a>{$origs}</td><td>".htmlspecialchars($row[1]);
  385.  
  386.     if (isset($fields[$row[0]])) {
  387.       print "<table style='width: 100%' class='data'>";
  388.       foreach ($fields[$row[0]] as $field) {
  389.         print "<tr><td>";
  390.         switch ($field[2]) {
  391.           case 'checkbox':
  392.             print "<b>".htmlspecialchars($field[6])."</b>: checkbox on nybble ".htmlspecialchars($field[5])." with mask ".htmlspecialchars($field[4]);
  393.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  394.             break;
  395.           case 'value':
  396.             print "<b>".htmlspecialchars($field[6])."</b>: value at nybble ".htmlspecialchars($field[5]);
  397.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  398.             break;
  399.           case 'index':
  400.             print "<b>".htmlspecialchars($field[6])."</b>: index at nybble ".htmlspecialchars($field[5]);
  401.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  402.             break;
  403.           case 'list':
  404.             //$listentries = str_replace("\n", ', ', $field[4]);
  405.             //$listentries = substr($listentries, 0, -2);
  406.             $listentries = str_replace("\n", ', ', rtrim($field[4]));
  407.             print "<b>".htmlspecialchars($field[6])."</b>: list at nybble ".htmlspecialchars($field[5]).": $listentries";
  408.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  409.             break;
  410.         }
  411.         print "</td></tr>";
  412.       }
  413.       print "</table>";
  414.     }
  415.  
  416.     print "</td></tr>";
  417.   }
  418.   print "</table>";
  419.  
  420.   break;         
  421.  
  422. case 'listcomplete':
  423.  print "<title>NSMBW Sprite Database</title>";
  424.   $fields = array();
  425.   $getfields = Query('select * from nsmbw_fields order by CAST(nybble as SIGNED INTEGER) asc');
  426.   while ($row = mysqli_fetch_array($getfields)) {
  427.     $s = $row[1];
  428.     if (!isset($fields[$s])) $fields[$s] = array();
  429.     $fields[$s][] = $row;
  430.   }
  431.  
  432. print "Filter Results -- • <a href='?act=list'>Regular</a> • <a href='?act=listunknown'>Unknown</a> • <a href='?act=listknown'>Known</a> • Complete • <a href='?act=listunused'>Unused</a><br>";
  433.  
  434.   if ($loguser['primarygroup'] == -1)
  435.         print "<h1>You can view this database, however, you can't edit it. You are banned.</h1>";
  436.   print "<br><br>";
  437.   print "<table style='width: 80%' class='sprites'><tr><td style='width: 48px'>ID:</td><td>Name:</td></tr>";
  438.   $getsprites = Query('SELECT * FROM nsmbw_sprites WHERE known=1 AND complete=1 AND id BETWEEN 0 AND 723');
  439.   while ($row = mysqli_fetch_array($getsprites)) {
  440.     if ($row[2] == 0) {
  441.       $class = 'unknown';
  442.     } else {
  443.       if ($row[3] == 0) {
  444.         $class = 'known';
  445.       } else {
  446.         $class = 'complete';
  447.       }
  448.     }
  449.  
  450.     if ($row[4] == 0) {
  451.       $orig = '';
  452.       $origs = '';
  453.     } else {
  454.       $orig = " class='original'";
  455.       $origs = '*';
  456.     }
  457.  
  458.     if (!$loguserid)
  459.         print "<tr class='$class'><td{$orig}>$row[0]{$origs}</td><td>".htmlspecialchars($row[1]);
  460.     else
  461.         print "<tr class='$class'><td{$orig}><a href='spriteDB.php?e=$row[0]'>$row[0]</a>{$origs}</td><td>".htmlspecialchars($row[1]);
  462.  
  463.     if (isset($fields[$row[0]])) {
  464.       print "<table style='width: 100%' class='data'>";
  465.       foreach ($fields[$row[0]] as $field) {
  466.         print "<tr><td>";
  467.         switch ($field[2]) {
  468.           case 'checkbox':
  469.             print "<b>".htmlspecialchars($field[6])."</b>: checkbox on nybble ".htmlspecialchars($field[5])." with mask ".htmlspecialchars($field[4]);
  470.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  471.             break;
  472.           case 'value':
  473.             print "<b>".htmlspecialchars($field[6])."</b>: value at nybble ".htmlspecialchars($field[5]);
  474.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  475.             break;
  476.           case 'index':
  477.             print "<b>".htmlspecialchars($field[6])."</b>: index at nybble ".htmlspecialchars($field[5]);
  478.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  479.             break;
  480.           case 'list':
  481.             //$listentries = str_replace("\n", ', ', $field[4]);
  482.             //$listentries = substr($listentries, 0, -2);
  483.             $listentries = str_replace("\n", ', ', rtrim($field[4]));
  484.             print "<b>".htmlspecialchars($field[6])."</b>: list at nybble ".htmlspecialchars($field[5]).": $listentries";
  485.             if ($field[3] != '') print " (comment: ".htmlspecialchars($field[3]).")";
  486.             break;
  487.         }
  488.         print "</td></tr>";
  489.       }
  490.       print "</table>";
  491.     }
  492.  
  493.     print "</td></tr>";
  494.   }
  495.   print "</table>";
  496.  
  497.   break;         
  498.  
  499. case 'addsprite':
  500.   print "<title>Add Sprite - NSMBW Sprite Database</title>";
  501.  
  502.   print "<div class='groupbox' style='width: 500px'>";
  503.   print "<div class='header'>New Sprite Info:</div>";
  504.   print "<div class='content'>";
  505.   print "<form action='spriteDB.php?act=submitsprite' method='post'>";
  506.  
  507.   print "ID: <input type='text' name='spriteid' value='' class='text'><br>";
  508.   print "Name: <input type='text' name='newspritename' value='' class='text'>";
  509.  
  510.   print "<br>";
  511.   print "<b>Notes:</b><br>";
  512.   $notes = htmlspecialchars($sprite[5]);
  513.   print "<textarea name='newnotes' rows='4' cols='60' style='font-family: Arial,sans-serif'>$notes</textarea>";
  514.   print "<center>";
  515.   print "<input type='submit' name='submitsprite' value='Add Sprite' class='submit'>";
  516.   print "</center>";
  517.   print "</form>";
  518.   print "</div></div>";
  519.   break;
  520.  
  521. case 'edit':
  522.   $id = $_GET['id'];
  523.  
  524.   // stop using strings, jesus
  525.   if (!is_numeric($id)) { die('no'); }
  526.   $id = intval($id);
  527.  
  528.   $getsprite = Query("select * from nsmbw_sprites where id = $id");
  529.   $sprite = mysqli_fetch_array($getsprite);
  530.  
  531.   // ways to generate the link to the previous sprite, and the next
  532.   $prevsprite = $id - 1;
  533.   $nextsprite = $id + 1;
  534.  
  535.   // void
  536.   if ($id <= -1)
  537.     die("*various whooshing sounds, the void has been opened*");
  538.  
  539.   // c:
  540.   if ($id >= 9999)
  541.     die("this is here because RoadrunnerWMC thinks he is smart<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>he really isnt");
  542.  
  543.   // invalid id
  544.   if (numRows($getsprite) == 0) { die("Can't find the sprite ID $id"); }
  545.  
  546.   // redefine this for this function, for some reason it undefines itself once inserted here
  547.   $takemesomewhere = rand(0, 482);
  548.  
  549.   print "<a href='spriteDB.php'>Return to the main sprite list</a><hr>";
  550.   print "<a href='spriteDB.php?e=" . $prevsprite . "'>Previous Sprite</a> -- <a href='spriteDB.php?e=" . $nextsprite . "'>Next Sprite</a><hr>";
  551.   print "<a href='spriteDB.php?e=" . $takemesomewhere . "'>TAKE ME SOMEWHERE RANDOM</a><br>";
  552.   print "<title>".htmlspecialchars($sprite[1])." ($id) — NSMBW Sprite Database</title>";
  553.   print "<h2>Editing sprite ".htmlspecialchars($sprite[1])." ($id):</h2>";
  554.  
  555.   print "<div class='groupbox' style='width: 600px'>";
  556.   print "<div class='header'>Loaded Files:</div>";
  557.   print "<div class='content'>";
  558.   print "<form action='spriteDB.php?act=modsprite&id={$id}&set=flags' method='post'>";
  559.   $loadedfiles = htmlspecialchars($sprite[27]);
  560.   print "<textarea name='loadedfiles' rows='6' cols='60' style='font-family: Arial,sans-serif'>$loadedfiles</textarea><br>";
  561.   print "<input type='submit' name='saveflags' value='Save Info' class='submit'>";
  562.   print "</div></div>";
  563.   print "<br>";  
  564.  
  565.   print "<div class='groupbox' style='width: 500px'>";
  566.   print "<div class='header'>Modify Info:</div>";
  567.   print "<div class='content'>";
  568.   print "<form action='spriteDB.php?act=modsprite&id={$id}&set=flags' method='post'>";
  569.  
  570.   $n = htmlspecialchars($sprite[1]);
  571.   print "Name: <input type='text' name='spritename' value=\"{$n}\" class='text'>";
  572.  
  573.   $known = ($sprite[2] == 1) ? " checked='checked'" : '';
  574.   $complete = ($sprite[3] == 1) ? " checked='checked'" : '';
  575.   $orig = ($sprite[4] == 1) ? " checked='checked'" : '';
  576.  
  577.   print "<br>";
  578.   print "<input type='checkbox' name='known' value='yes'{$known}> This sprite's purpose is known";
  579.   print "<br>";
  580.   print "<input type='checkbox' name='complete' value='yes'{$complete}> This sprite's data is complete";
  581.   print "<br>";
  582.   print "<input type='checkbox' name='orig' value='yes'{$orig}> This sprite does not appear in the standard levels";
  583.   print "<br>";
  584.   print "<b>Notes:</b><br>";
  585.   $notes = htmlspecialchars($sprite[5]);
  586.   print "<textarea name='notes' rows='4' cols='60' style='font-family: Arial,sans-serif'>$notes</textarea>";
  587.   print "<br>";
  588.   print "<center>";
  589.   print "<input type='submit' name='saveflags' value='Save Info' class='submit'>";
  590.   print "<input type='submit' name='saveflagsandreturn' value='Save Info and Go Back' class='submit'>";
  591.   print "</center>";
  592.   print "</form>";
  593.   print "</div></div>";
  594.  
  595.   print "<br>";
  596.  
  597.   // fields
  598.   print "<div class='groupbox' style='width: 1200px'>";
  599.   print "<div class='header'>Modify Fields:</div>";
  600.   print "<div class='content'>";
  601.   print "<form action='spriteDB.php?act=modsprite&id={$id}&set=fields' method='post'>";
  602.  
  603. ?>
  604. <script language='JavaScript'>
  605. function showhidetypeinfo() {
  606.   var elem = document.getElementById('typeinfo');
  607.   if (elem.style.display == 'none') elem.style.display = 'block';
  608.   else if (elem.style.display == 'block') elem.style.display = 'none';
  609.   return false;
  610. }
  611. </script>
  612. <b>Field Types and Descriptions:</b> (<a href='' onclick='showhidetypeinfo(); return false'>Show/Hide Info</a>)<hr>
  613. <div id='typeinfo' style='display: none'><i>Checkbox</i>: Activates/deactivates a specific bit in a nybble. Use this for flags and simple on/off properties. Set the data to the value of the bit that will be activated - for example, if the value needs to be 2 to be on, enter 2 in the data field. More than one checkbox on the same nybble will work if there are several flags, as long as they have different data fields.<hr>
  614. <i>Value</i>: A simple value which shows up as a spinner in Reggie. It can be larger than one nybble - just enter the nybble numbers like this: <i>11-12</i>. The data field is not used.<hr>
  615. <i>List</i>: Lets you choose from a list of values. Enter the values like this into the data field: <i>0=Right, 1=Up+Right, 2=Up, 3=Up+Left</i> - It can use more than one nybble, using the same method as values. Missing values will automatically show up in Reggie as unknown/unused within the list. DO NOT USE COMMAS IN VALUE NAMES. THIS WILL BREAK THE SPRITEDATA.<hr>
  616. <i>Index</i>: Works in the same way as the value field, but is used for indexes that connect different sprites, like the rotation indexes.<hr>
  617. </div>
  618. <?php
  619.   $getfields = Query("select * from nsmbw_fields where sprite = $id order by CAST(nybble as SIGNED INTEGER) asc");
  620.   if (numRows($getfields) == 0) {
  621.     print "This sprite has no fields.";
  622.   } else {
  623.     print "<table class='fieldeditor' style='width: 100%'>";
  624.     print "<tr class='header'><td>Title:</td><td>Nybble:</td><td>Type:</td><td>Data:</td><td>Comment:</td><td></td></tr>";
  625.     $fieldtypes = array('checkbox', 'value', 'list', 'index');
  626.     while ($row = mysqli_fetch_array($getfields)) {
  627.       $i = $row[0];
  628.       $title = htmlspecialchars($row[6]);
  629.       $nybble = htmlspecialchars($row[5]);
  630.       $type = $row[2];
  631.       $data = htmlentities(str_replace("\n", ', ', rtrim($row[4])), 0);
  632.       $comment = htmlentities($row[3]);
  633.       print "<tr>";
  634.       print "<td><input type='text' name='title[$i]' value=\"$title\" size='20' class='text'></td>";
  635.       print "<td><input type='text' name='nybble[$i]' value=\"$nybble\" size='6' class='text'></td>";
  636.       print "<td><select name='type[$i]'>";
  637.       foreach ($fieldtypes as $t) {
  638.         print "<option value='$t'";
  639.         if ($t == $type) print " selected='selected'";
  640.         print ">$t</option>";
  641.       }
  642.       print "</select></td>";
  643.       print "<td><input type='text' name='data[$i]' value=\"$data\" size='65' class='text'></td>";
  644.       print "<td><input type='text' name='comment[$i]' value=\"$comment\" size='50' class='text'></td>";
  645.       print "<td style='font-size: 10px'><a href='spriteDB.php?act=modsprite&id={$id}&field={$i}&set=deleteit'>delete</a></td>";
  646.       print "</tr>";
  647.     }
  648.     print "</table>";
  649.   }
  650.  
  651.   print "<center>";
  652.   print "<input type='submit' name='savefields' value='Save Fields' class='submit'>";
  653.   print "<input type='submit' name='addfield' value='Save and Add New Field' class='submit'>";
  654.   print "</center>";
  655.   print "</form>";
  656.   print "</div></div>";
  657.  
  658.  
  659.   print "<br>";
  660.  
  661.   print "<div class='groupbox' style='width: 700px'>";
  662.   print "<div class='header'>Existing In-Game Sprite Data:</div>";
  663.   print "<div class='content'>";
  664.   print "<form action='spriteDB.php?act=modsprite&id={$id}&set=spritedata' method='post'>";
  665.   $getdata = Query("select * from nsmbw_origdata where sprite = $id");
  666.   if (numRows($getdata) == 0) {
  667.     print "This sprite isn't used in the original game.";
  668.   //print "<center>"; this looks ugly
  669.   //print "<input type='submit' name='savess' value='Save Spritedata Set' class='submit'>";
  670.   //print "<input type='submit' name='saveandaddss' value='Save and Add New Spritedata Set' class='submit'>";
  671.   //print "</center>";     
  672.   } else {
  673.     $datavalues = array();
  674.     print "<table class='origdata'><tr><td style='width: 250px'><b>Data</b></td><td><b>Levels</b>";
  675.     while ($row = mysqli_fetch_array($getdata)) {
  676.       if (!isset($datavalues[$row[2]])) $datavalues[$row[2]] = array();
  677.       $datavalues[$row[2]][] = $row[1];
  678.       //print "<tr><td>$row[1]</td><td>$row[2]</td></tr>";
  679.     }
  680.     foreach ($datavalues as $data => $levels) {
  681.       print "<tr class='datarow'><td valign='top'>$data</td><td>".implode(', ', $levels)."</td>";
  682.       //print "<td style='font-size: 10px'><a href='spriteDB.php?act=modsprite&id={$id}&spritedata={$entrydata}&set=deletedata'>delete</a></td></tr>";
  683.     }
  684.   //print "<center>"; this looks ugly
  685.   //print "<input type='submit' name='savess' value='Save Spritedata Set' class='submit'>";
  686.   //print "<input type='submit' name='saveandaddss' value='Save and Add New Spritedata Set' class='submit'>";
  687.   //print "</center>";
  688.   print "</table>";
  689.   }
  690.   print "</div>";
  691.  
  692.   break;
  693.  
  694. case 'modsprite':
  695.   $id = $_GET['id'];
  696.   if (!is_numeric($id)) { die('Invalid sprite ID'); }
  697.   $id = intval($id);
  698.  
  699.   $getsprite = Query("select * from nsmbw_sprites where id = $id");
  700.   if (numRows($getsprite) == 0) { die("Can't find the sprite ID $id"); }
  701.   $sprite = mysqli_fetch_array($getsprite);
  702.  
  703.   if ($_GET['set'] == 'flags') {
  704.     // SAVE FLAGS
  705.     $type = 0;
  706.     if (strpos($_POST['spritename'], 'script') !== false)
  707.         die('no');
  708.     if (strpos($_POST['notes'], 'script') !== false)
  709.         die('no');
  710.     if (strpos($_POST['loadedfiles'], 'script') !== false)
  711.         die('no');
  712.     if (strpos($_POST['actorname'], 'script') !== false)
  713.         die('no');
  714.     $known = 0; if ($_POST['known'] == 'yes') $known = 1;
  715.     $complete = 0; if ($_POST['complete'] == 'yes') $complete = 1;
  716.     $orig = 0; if ($_POST['orig'] == 'yes') $orig = 1;
  717.     $spritename = mysqli_escape_string($dblink, $_POST['spritename']);
  718.     $notes = mysqli_escape_string($dblink, $_POST['notes']);
  719.     $loadedfiles =  mysqli_escape_string($dblink, $_POST['loadedfiles']);  
  720.  
  721.     $doublederp = Query("update {nsmbw_sprites} set known=$known, complete=$complete, name='$spritename', orig='$orig', notes='$notes' where id=$id");
  722.     //Query("update sprites set known=$known, complete=$complete, name='$spritename', orig='$orig', notes='$notes', actorname='$actorname', enemiesoverworld='$enemiesoverworld', enemiesdesert='$enemiesdesert', enemiesunderground='$enemiesunderground', enemiestowerandcastle='$enemiestowerandcastle', enemiesairship='$enemiesairship', enemieslava='$enemieslava', enemiessnow='$enemiessnow', enemiesjungle='$enemiesjungle', enemiesbig='$enemiesbig', controllers='$controllers', events='$events', platforms='$platforms', bosses='$bosses', rotationcontrolled='$rotationcontrolled', useslines='$useslines', usespaths='$usespaths', items='$items', lightingandeffects='$lightingandeffects', enemiesghost='$enemiesghost', enemiessky='$enemiessky', objfile='$loadedfiles', levelmechs='$levelmechs', enemiesunder='$enemiesunder', gen='$gen', useless='$useless' where id=$id");
  723.  
  724.     if ($known == 1)          
  725.         $knownblarg = "Known";
  726. else
  727.   $knownblarg = "Unknown";
  728.     if ($complete == 1)
  729.         $completeblarg = "complete";
  730. else
  731.   $completeblarg = "incomplete";
  732.     if ($orig == 1)
  733.         $unused = "\x0314, \x0303unused";
  734. else
  735.   $unused = "";
  736.  
  737.   } elseif ($_GET['set'] == 'fields') {
  738.     // SAVE FIELDS
  739.     $type = 1;
  740.  
  741.     if (isset($_POST['title']) && is_array($_POST['title']) && count($_POST['title']) > 0) {
  742.       foreach ($_POST['title'] as $fid => $data) {
  743.         if ($data == 'New Field')
  744.             die('Come up with a better name, please.');
  745.         $iid = intval($fid); $idata = mysqli_escape_string($dblink, $data);
  746.         Query("update {nsmbw_fields} set title = '$idata' WHERE id = $iid");
  747.       }
  748.       foreach ($_POST['nybble'] as $fid => $data) {
  749.         $iid = intval($fid); $idata = mysqli_escape_string($dblink, $data);
  750.         Query("update {nsmbw_fields} set nybble = '$idata' WHERE id = $iid");
  751.       }
  752.       foreach ($_POST['type'] as $fid => $data) {
  753.         $iid = intval($fid); $idata = mysqli_escape_string($dblink, $data);
  754.         Query("update {nsmbw_fields} set type = '$idata' WHERE id = $iid");
  755.       }
  756.       foreach ($_POST['data'] as $fid => $data) {
  757.         $iid = intval($fid); $idata = mysqli_escape_string($dblink, $data);
  758.         Query("update {nsmbw_fields} set data = '$idata' WHERE id = $iid");
  759.       }
  760.       foreach ($_POST['comment'] as $fid => $data) {
  761.         $iid = intval($fid); $idata = mysqli_real_escape_string($dblink, $data);
  762.         Query("update {nsmbw_fields} set comment = '$idata' WHERE id = $iid");
  763.       }
  764.  }
  765.  
  766.     if (isset($_POST['addfield'])) {
  767.       Query("insert into nsmbw_fields (sprite,title,nybble,type,data,comment) values ($id,'New Field','1','value','','')");
  768.     }
  769.  
  770.   } elseif ($_GET['set'] == 'deleteit') {
  771.     $fid = intval($_GET['field']);
  772.     Query("delete from nsmbw_fields where id = $fid");
  773.  
  774.   } elseif ($_GET['set'] == 'deletedata') {
  775.     $entryid = intval($_GET['entryid']);
  776.     Query("delete from nsmbw_origdata where entryid = $entryid");
  777.   }  
  778.  
  779.   if (isset($_POST['saveflagsandreturn'])) {
  780.     header("Location: spriteDB.php");
  781.   } else {
  782.     header("Location: spriteDB.php?e=$id");
  783.   }
  784.  
  785.   if (isset($_POST['savess'])) {
  786.     $type = 2;
  787.     $derp = Query("insert into {nsmbw_origdata} (sprite, level, data, entryid) values ({0}, {1}, {2}, {3})", $id, $_POST['game'] . ' ' . $_POST['levelname'] . ' ' . $_POST['levelnum'], $_POST['nybset1'] . ' ' . $_POST['nybset2'] . ' ' . $_POST['nybset3'] . ' ' . $_POST['nybset4'] . ' ' . $_POST['nybset5'] . ' ' . $_POST['nybset6'], 0);
  788.     }
  789.  
  790.   break;
  791. }
  792. ?></body>
  793. </html><?php ob_end_flush(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement