Advertisement
Jousway

KBO Noteskin Upload System with XML generator

Mar 22nd, 2012
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.40 KB | None | 0 0
  1. // Default.php \\
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  4. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5.  
  6. <html>
  7. <head>
  8. <title>Upload Noteskin</title>
  9.  
  10.  
  11. <script type="text/javascript" language="JavaScript">
  12. function check() {
  13.   var ext = document.f.uploaded.value;
  14.   ext = ext.substring(ext.length-3,ext.length);
  15.   ext = ext.toLowerCase();
  16.   if(ext != 'png') {
  17.     alert('You selected a .'+ext+
  18.           ' file; please select a .png file instead!');
  19.     return false; }
  20.   else
  21.     return true; }
  22. </script>
  23.  
  24. </head>
  25. <body>
  26.  
  27. <form method="post" name=f
  28. enctype="multipart/form-data"
  29. onsubmit="return check();"
  30. action="upload.php">
  31. <p>
  32. Select a PNG pic to upload as noteskin.<br />
  33. All noteskins will be based on this single skin.<br />
  34. And DO NOT UPLOAD ARROWS.<br />
  35. So please upload stuff like this.<br />
  36. <img src="http://jousway.webuda.com/kbonoteskins/no%20arrow.png"><br />
  37. I advice you to upload it in the color gray but its your choice.<br />
  38. Arrows function will be added later.
  39. <br />
  40. <input type="file" name="uploaded" size="40">
  41. <p>
  42. <input type="submit" value="Send">
  43. </form>
  44.  
  45. </body>
  46. </html>
  47.  
  48.  
  49.  
  50.  
  51. // Upload.php \\
  52.  
  53. <?php
  54.  
  55. $randit = rand(100000, 999999);
  56. mkdir($randit."/",0777);
  57. $target = $randit."/";
  58. $target = $target . basename( $_FILES['uploaded']['name']) ;
  59. $ok=1;
  60. if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
  61. {
  62. echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, ";
  63. }
  64. else {
  65. echo "Sorry, there was a problem uploading your file.";
  66. }
  67.  
  68. rename($randit.'/'.basename( $_FILES['uploaded']['name']), $randit.'/skin.png');
  69.  
  70.   $doc = new DOMDocument('1.0', 'utf-8');
  71.   $doc->formatOutput = true;  
  72.      
  73.   $data = $doc->createElementNS('http://www.keybeatonline.com/schema/customnoteskin', 'data');
  74.   $doc->appendChild( $data );
  75.  
  76.   $name = $doc->createElement( 'name' );
  77.   $name->appendChild(
  78.   $doc->createTextNode( 'Noteskin' )
  79.   );  
  80.   $data->appendChild( $name );
  81.  
  82.   $graphics = $doc->createElement( 'graphics' );
  83.   $doc->appendChild( $graphics );
  84.  
  85.   $location = $doc->createElement( 'location' );
  86.   $location->appendChild(
  87.   $doc->createTextNode( 'http://jousway.webuda.com/kbonoteskins/'.$randit.'/' )
  88.   );  
  89.   $graphics->appendChild( $location );
  90.  
  91.   $scale = $doc->createElement( 'scale' );
  92.   $scale->appendChild(
  93.   $doc->createTextNode( '1' )
  94.   );  
  95.   $graphics->appendChild( $scale );
  96.  
  97.  
  98.   $skins = $doc->createElement( 'skins' );
  99.   $a = $doc->createElement( 'upleft' );
  100.    
  101.   $main = $doc->createElement( 'main' );
  102.   $main->appendChild(
  103.   $doc->createTextNode( 'skin.png' )
  104.   );
  105.   $a->appendChild( $main );
  106.  
  107.   $overlay = $doc->createElement( 'overlay' );
  108.   $overlay->appendChild(
  109.   $doc->createTextNode( ' ' )
  110.   );
  111.   $a->appendChild( $overlay );
  112.  
  113.   $skins->appendChild( $a );
  114.  
  115.   $graphics->appendChild( $skins );
  116.  
  117.   $receptors = $doc->createElement( 'receptors' );
  118.   $b = $doc->createElement( 'upleft' );
  119.    
  120.   $main2 = $doc->createElement( 'main' );
  121.   $main2->appendChild(
  122.   $doc->createTextNode( 'skin.png' )
  123.   );
  124.   $b->appendChild( $main2 );
  125.  
  126.   $receptors->appendChild( $b );
  127.  
  128.   $graphics->appendChild( $receptors );
  129.  
  130.   $holds = $doc->createElement( 'holds' );
  131.   $c = $doc->createElement( 'upleft' );
  132.    
  133.   $main3 = $doc->createElement( 'main' );
  134.   $main3->appendChild(
  135.   $doc->createTextNode( 'skin.png' )
  136.   );
  137.   $c->appendChild( $main3 );
  138.  
  139.   $holds->appendChild( $c );
  140.  
  141.   $graphics->appendChild( $holds );
  142.  
  143.   $explosions = $doc->createElement( 'explosions' );
  144.  
  145.   $transition = $doc->createElement('transition');
  146.  
  147.   $scalex = $doc->createAttribute('scalex');
  148.   $scaley = $doc->createAttribute('scaley');
  149.  
  150.   $scalex->appendChild($doc->createTextNode('true'));
  151.   $scaley->appendChild($doc->createTextNode('true'));
  152.  
  153.   $transition->appendChild($scalex);
  154.   $transition->appendChild($scaley);;
  155.  
  156.   $begin = $doc->createElement( 'begin' );
  157.  
  158.   $alpha = $doc->createElement( 'alpha' );
  159.   $alpha->appendChild(
  160.   $doc->createTextNode( '1' )
  161.   );
  162.   $begin->appendChild( $alpha );
  163.  
  164.   $scale2 = $doc->createElement( 'scale' );
  165.   $scale2->appendChild(
  166.   $doc->createTextNode( '1' )
  167.   );
  168.   $begin->appendChild( $scale2 );
  169.  
  170.   $transition->appendChild( $begin );
  171.  
  172.   $transition->appendChild( $begin );
  173.  
  174.   $end = $doc->createElement( 'end' );
  175.  
  176.   $alpha2 = $doc->createElement( 'alpha' );
  177.   $alpha2->appendChild(
  178.   $doc->createTextNode( '0' )
  179.   );
  180.   $end->appendChild( $alpha2 );
  181.  
  182.   $scale3 = $doc->createElement( 'scale' );
  183.   $scale3->appendChild(
  184.   $doc->createTextNode( '2' )
  185.   );
  186.   $end->appendChild( $scale3 );
  187.  
  188.   $transition->appendChild( $end );
  189.  
  190.   $duration = $doc->createElement( 'duration' );
  191.   $duration->appendChild(
  192.   $doc->createTextNode( '0.2' )
  193.   );
  194.   $transition->appendChild( $duration );
  195.  
  196.   $explosions->appendChild( $transition );
  197.  
  198.   $d = $doc->createElement( 'upleft' );
  199.    
  200.   $main4 = $doc->createElement( 'main' );
  201.   $main4->appendChild(
  202.   $doc->createTextNode( 'skin.png' )
  203.   );
  204.   $d->appendChild( $main4 );
  205.  
  206.   $explosions->appendChild( $d );
  207.  
  208.   $graphics->appendChild( $explosions );
  209.   $data->appendChild( $graphics );
  210.    
  211.   echo "to use your noteskin copy and past <font color='blue'>http://jousway.webuda.com/kbonoteskins/".$randit.".xml</font> in to the custom noteskin url in KBO";
  212.   $doc->save($randit.'.xml');
  213.  
  214.  
  215. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement