Advertisement
Guest User

Untitled

a guest
Jan 7th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 26.90 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $host = "127.0.0.1";
  4. $nome = "root";
  5. $pass = "svtcsm74";
  6. $dbnome = "asd";
  7. $conn = mysql_connect($host,$nome,$pass) or die('Errore di connessione' . mysql_error());
  8. $seldb = mysql_select_db($dbnome,$conn) or die(mysql_error());
  9. function mus($header, $data=''){
  10.         $musData = $header . chr(1) . $data;
  11.         $sock = @socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp'));
  12.         @socket_connect($sock, '127.0.0.1', '30001');
  13.         @socket_send($sock, $musData, strlen($musData), MSG_DONTROUTE);
  14.         @socket_close($sock);  
  15.     }
  16.  
  17. function salva_modello($code)
  18.     {
  19.       $random = "model_".rand(555,999999);
  20.            
  21.             $stmt = mysql_query("INSERT INTO room_models(id,door_x,door_y,door_dir,heightmap)
  22.                                                   VALUES('".$random."', '0', '10', '2', '".$code."')");                                              
  23.                                              
  24.  
  25.             $room = mysql_query("INSERT INTO rooms(caption,owner,model_name) VALUES('Stanza Realizzata con Floor!', '".user('username')."', '".$random."')");
  26.             mus("update_navigator");
  27.             return $stmt;
  28.              
  29.     }
  30. function user($data){
  31.     $utente = mysql_query("SELECT * FROM users WHERE username = '".$_SESSION['username']."' LIMIT 1");
  32.     $info = mysql_fetch_assoc($utente);
  33.     return $info[$data];
  34. }
  35.  
  36.  
  37.  
  38. if(isset($_POST['salva'])){
  39. $code = trim($_POST['export1']);    
  40. if($code == ""){
  41.   echo "<script>alert('Errore Modello non caricato');</script>";
  42. }else if(!strstr($code,'X') && !strstr($code,'0'))
  43. {
  44. echo"<script>alert('Errore Modello non caricato');</script>";
  45. }
  46. else if(user('credits') < 40)
  47. {
  48.     echo"<script>alert('Devi avere almeno 40 Crediti per creare il Modello!');</script>";
  49. }
  50. else{
  51. mysql_query("UPDATE users SET vip_points = vip_points -40 WHERE username = '".$_SESSION['username']."' LIMIT 1");
  52. if(salva_modello($code)){
  53. echo "<script>alert('Modello Creato con successo ! Puoi trovare il nuovo modello nella Stanza *CREATA CON IL FLOOR* del tuo Navigatore se non la vedi rientra in Hotel!');</script>";
  54. }
  55. }  
  56. }
  57.  
  58. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  59. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  60.         <head>
  61.         <title>Room Model</title>
  62.         <script type="text/javascript">
  63.                         var Map;
  64.                         var OffsetX;
  65.                         var OffsetY;
  66.                        
  67.                         var Mouse = false;
  68.                         var MouseMode;
  69.                         var MousedMap;
  70.                        
  71.                         function AddTileArea(C, X, Y)
  72.                         {
  73.                                 var E = document.createElement( "area" );
  74.                                 E.shape = "poly";
  75.                                 E.coords = C;
  76.                                 document.getElementsByTagName("map")[0].appendChild(E);
  77.                                 E.onmouseover = function(){ TileOver(X, Y); };
  78.                                 E.onmouseout = function(){ TileOut(X, Y); };
  79.                                 E.onclick = function(){ TileClick(X, Y); };
  80.                         }
  81.  
  82.                         function PrepareBlankMap(X, Y)
  83.                         {
  84.                                 if(!isInt(X) || !isInt(Y))
  85.                                 {
  86.                                         alert("Invalid Size");
  87.                                         return;
  88.                                 }
  89.                                 Map = new Array();
  90.                                 MousedMap = new Array();
  91.                                 Mouse = false;
  92.                                 OffsetX = ((Y*32)-7);
  93.                                 OffsetY = 25;
  94.                                 document.getElementsByTagName("map")[0].innerHTML = "";
  95.                                
  96.                                 for(var x = 0; x < X; x++)
  97.                                 {
  98.                                         Map[x] = new Array();
  99.                                         MousedMap[x] = new Array();
  100.                                        
  101.                                         for(var y = 0; y < Y; y++)
  102.                                         {
  103.                                                 Map[x][y] = true;
  104.                                                
  105.                                                 var _x = ((x*32)+(y*-32)+OffsetX);
  106.                                                 var _y = ((x*16)+(y*16)+OffsetY);
  107.                                                
  108.                                                 var Coords = "";
  109.                                                 Coords += (_x + 31); // TopX
  110.                                                 Coords += ",";
  111.                                                 Coords += (_y); // TopY
  112.                                                 Coords += ",";
  113.                                                
  114.                                                 Coords += (_x + 63); // RightX
  115.                                                 Coords += ",";
  116.                                                 Coords += (_y + 16); // RightY
  117.                                                 Coords += ",";
  118.                                                
  119.                                                 Coords += (_x + 32); // BottomX
  120.                                                 Coords += ",";
  121.                                                 Coords += (_y + 31); // BottomY
  122.                                                 Coords += ",";
  123.                                                 Coords += (_x + 31); // BottomX
  124.                                                 Coords += ",";
  125.                                                 Coords += (_y + 31); // BottomY
  126.                                                 Coords += ",";
  127.                                                
  128.                                                 Coords += (_x + 0); // LeftX
  129.                                                 Coords += ",";
  130.                                                 Coords += (_y + 16); // LeftY
  131.                                                
  132.                                                 AddTileArea(Coords, x, y);
  133.                                         }
  134.                                 }
  135.                                 DrawMap();
  136.                                 ResetMousedMap();
  137.                         }
  138.                        
  139.                         function DrawMap()
  140.                         {
  141.                                 var X = Map.length;
  142.                                 var Y = Map[0].length;
  143.                                
  144.                                 var Output = "";
  145.                                 for(var x = 0; x < X; x++)
  146.                                 {
  147.                                         for(var y = 0; y < Y; y++)
  148.                                         {
  149.                                                 var _x = ((x*32)+(y*-32)+OffsetX);
  150.                                                 var _y = ((x*16)+(y*16)+OffsetY);
  151.                                                
  152.                                                 if(Map[x][y])
  153.                                                         Output += '<img id="tile'+x+'-'+y+'" class="square" style="top: ' + _y + 'px; left: ' + _x + 'px;" src="/app/funzioni_client/img/attivo.png" />';
  154.                                                 else
  155.                                                         Output += '<img id="tile'+x+'-'+y+'" class="square" style="top: ' + _y + 'px; left: ' + _x + 'px;" src="/app/funzioni_client/img/non.png" />';
  156.                                         }
  157.                                 }
  158.                                
  159.                                 var Preview = document.getElementById('preview');
  160.                                 Preview.style.width = ((X*32)+(Y*+32)+50) + 'px';
  161.                                 Preview.style.height = ((X*16)+(Y*+16)+50+8) + 'px';
  162.                                 Preview.innerHTML = Output;
  163.                                
  164.                                 var MapImg = document.getElementById('mapimg');
  165.                                 MapImg.style.width = ((X*32)+(Y*+32)+50) + 'px';
  166.                                 MapImg.style.height = ((X*16)+(Y*+16)+50+8) + 'px';
  167.                                
  168.                                 RefreshExport();
  169.                         }
  170.                        
  171.                         function RedrawMap()
  172.                         {
  173.                                 var X = Map.length;
  174.                                 var Y = Map[0].length;
  175.                                
  176.                                 for(var x = 0; x < X; x++)
  177.                                 {
  178.                                         for(var y = 0; y < Y; y++)
  179.                                         {
  180.                                                 if(Map[x][y])
  181.                                                         document.getElementById('tile'+x+'-'+y).src = '/app/funzioni_client/img/attivo.png';
  182.                                                 else
  183.                                                         document.getElementById('tile'+x+'-'+y).src = '/app/funzioni_client/img/non.png';
  184.                                         }
  185.                                 }
  186.                                
  187.                                 RefreshExport();
  188.                         }
  189.                        
  190.                         function TileOver(X, Y)
  191.                         {
  192.                                 if(!Mouse)
  193.                                 {
  194.                                         if(Map[X][Y])
  195.                                         {
  196.                                                 document.getElementById('tile'+X+'-'+Y).src = '/app/funzioni_client/img/del.png';
  197.                                         }
  198.                                         else
  199.                                         {
  200.                                                 document.getElementById('tile'+X+'-'+Y).src = '/app/funzioni_client/img/add.png';                                  
  201.                                         }
  202.                                 }
  203.                                 else
  204.                                 {
  205.                                         if(!MousedMap[X][Y] && Map[X][Y] == MouseMode)
  206.                                         {
  207.                                                 MousedMap[X][Y] = true;
  208.                                                 Map[X][Y] = !MouseMode;
  209.                                                 RedrawMap();
  210.                                         }
  211.                                 }
  212.                         }
  213.                         function TileOut(X, Y)
  214.                         {
  215.                                 if(!Mouse)
  216.                                 {
  217.                                         if(Map[X][Y])
  218.                                         {
  219.                                                 document.getElementById('tile'+X+'-'+Y).src = '/app/funzioni_client/img/attivo.png';
  220.                                         }
  221.                                         else
  222.                                         {
  223.                                                 document.getElementById('tile'+X+'-'+Y).src = '/app/funzioni_client/img/non.png';                                  
  224.                                         }
  225.                                 }
  226.                         }                      
  227.                         function TileClick(X, Y)
  228.                         {
  229.                                 if(document.getElementById('toggle').checked)
  230.                                 {
  231.                                         if(!Mouse)
  232.                                         {
  233.                                                 Mouse = true;
  234.                                                 MouseMode = Map[X][Y];
  235.                                                 Map[X][Y] = !Map[X][Y];
  236.                                                 RedrawMap();
  237.                                         }
  238.                                         else
  239.                                         {
  240.                                                 Mouse = false;
  241.                                                 ResetMousedMap();
  242.                                         }
  243.                                 }
  244.                                 else
  245.                                 {
  246.                                         Map[X][Y] = !Map[X][Y];
  247.                                         RedrawMap();
  248.                                 }
  249.                         }
  250.                        
  251.                         function RefreshExport()
  252.                         {
  253.                                 var X = Map.length;
  254.                                 var Y = Map[0].length;
  255.                                
  256.                                 var Export = "";
  257.                                
  258.                                 for(var y = 0; y < Y; y++)
  259.                                 {
  260.                                         for(var x = 0; x < X; x++)
  261.                                         {
  262.                                                 if(Map[x][y])
  263.                                                         Export += '0';
  264.                                                 else
  265.                                                         Export += 'X';
  266.                                         }
  267.                                         Export += '\n';
  268.                                 }
  269.                                                                
  270.                                 document.getElementById('export').value = Export;
  271.                         }
  272.                        
  273.                         function ResetMousedMap()
  274.                         {
  275.                                 var X = Map.length;
  276.                                 var Y = Map[0].length;
  277.                                 for(var x = 0; x < X; x++)
  278.                                 {
  279.                                         for(var y = 0; y < Y; y++)
  280.                                         {
  281.                                                 MousedMap[x][y] = false;
  282.                                         }
  283.                                 }
  284.                         }
  285.                        
  286.                         function isInt(x)
  287.                         {
  288.                                 var y=parseInt(x);
  289.                                 if (isNaN(y)) return false;
  290.                                 return x==y && x.toString()==y.toString();
  291.                         }
  292.                        
  293.                         function ParseMap()
  294.                         {
  295.                                 var MapData = document.getElementById('import').value;
  296.                                 var NewMap = new Array();
  297.                                
  298.                                 var Lines = MapData.split('\n');
  299.                                                                
  300.                                 Mouse = false;
  301.                                 OffsetX = ((Lines[0].length*32)-7);
  302.                                 OffsetY = 25;
  303.                                 document.getElementsByTagName("map")[0].innerHTML = "";
  304.                                
  305.                                
  306.                                
  307.                                 var Rotation = new Array();
  308.                                 for(var Y = 0; Y < Lines[0].length; Y++)
  309.                                 {
  310.                                         Rotation[Y] = new Array();
  311.                                 }
  312.                                 for(var X = 0; X < Lines.length; X++)
  313.                                 {
  314.                                         for(var Y = 0; Y < Lines[X].length; Y++)
  315.                                         {
  316.                                                 Rotation[Y] += Lines[X][Y];
  317.                                         }
  318.                                 }
  319.                                
  320.                                
  321.                                 var Output = "";
  322.                                 MousedMap = new Array();
  323.                                 for(var X = 0; X < Rotation.length; X++)
  324.                                 {
  325.                                         if(Rotation[X].length == 0)
  326.                                                 break;
  327.                                         if(Rotation[X][0] == '\r')
  328.                                                 break;
  329.                                         if(Rotation[X].length != Rotation[0].length)
  330.                                         {
  331.                                                 alert("Invalid map! All lines must be the same size.");
  332.                                                 return;
  333.                                         }
  334.                                        
  335.                                         NewMap[X] = new Array();
  336.                                         MousedMap[X] = new Array();
  337.                                         for(var Y = 0; Y < Rotation[X].length; Y++)
  338.                                         {
  339.                                                 var _x = ((X*32)+(Y*-32)+OffsetX);
  340.                                                 var _y = ((X*16)+(Y*16)+OffsetY);                                                      
  341.                                                        
  342.                                                 if(Rotation[X][Y] == 'X' || Rotation[X][Y] == 'x')
  343.                                                 {
  344.                                                         NewMap[X][Y] = false;
  345.                                                         Output += '<img id="tile'+X+'-'+Y+'" class="square" style="top: ' + _y + 'px; left: ' + _x + 'px;" src="/app/funzioni_client/img/non.png" alt="Click to add" />';
  346.                                                 }
  347.                                                 else if(Rotation[X][Y] == '0')
  348.                                                 {
  349.                                                         NewMap[X][Y] = true;
  350.                                                         Output += '<img id="tile'+X+'-'+Y+'" class="square" style="top: ' + _y + 'px; left: ' + _x + 'px;" src="/app/funzioni_client/img/attivo.png" />';
  351.                                                 }
  352.                                                 else if(Rotation[X][Y] == '\r'){}
  353.                                                 else
  354.                                                 {
  355.                                                         alert("Invalid map! (" + X + "," + Y + " : " + Rotation[X][Y] + ")\n\nNote: This map does not accept stairs.");
  356.                                                         return;
  357.                                                 }
  358.                                                
  359.                                                 var Coords = "";
  360.                                                 Coords += (_x + 31); // TopX
  361.                                                 Coords += ",";
  362.                                                 Coords += (_y); // TopY
  363.                                                 Coords += ",";
  364.                                                
  365.                                                 Coords += (_x + 63); // RightX
  366.                                                 Coords += ",";
  367.                                                 Coords += (_y + 16); // RightY
  368.                                                 Coords += ",";
  369.                                                
  370.                                                 Coords += (_x + 32); // BottomX
  371.                                                 Coords += ",";
  372.                                                 Coords += (_y + 31); // BottomY
  373.                                                 Coords += ",";
  374.                                                 Coords += (_x + 31); // BottomX
  375.                                                 Coords += ",";
  376.                                                 Coords += (_y + 31); // BottomY
  377.                                                 Coords += ",";
  378.                                                
  379.                                                 Coords += (_x + 0); // LeftX
  380.                                                 Coords += ",";
  381.                                                 Coords += (_y + 16); // LeftY
  382.                                                
  383.                                                 AddTileArea(Coords, X, Y);
  384.                                         }
  385.                                 }
  386.                                
  387.                                 var Preview = document.getElementById('preview');
  388.                                 Preview.style.width = ((Rotation.length*32)+(Rotation[0].length*+32)+50) + 'px';
  389.                                 Preview.style.height = ((Rotation.length*16)+(Rotation[0].length*+16)+50+8) + 'px';
  390.                                 Preview.innerHTML = Output;
  391.                                
  392.                                 var MapImg = document.getElementById('mapimg');
  393.                                 MapImg.style.width = ((Rotation.length*32)+(Rotation[0].length*+32)+50) + 'px';
  394.                                 MapImg.style.height = ((Rotation.length*16)+(Rotation[0].length*+16)+50+8) + 'px';
  395.                                                                
  396.                                 Map = NewMap;
  397.                                 ResetMousedMap();
  398.                                 RefreshExport();
  399.                                 document.getElementById('controls').style.width = 180 + 'px';
  400.                         }
  401.                        
  402.                 </script>
  403.                 <style type="text/css">
  404.                         .square
  405.                         {
  406.                                 position: absolute;
  407.                         }
  408.                         a
  409.                         {
  410.                                 color: #FFF;
  411.                         }
  412.                 </style>
  413.         </head>
  414.         <body onload="PrepareBlankMap(15, 15);">
  415.        
  416.        
  417.  
  418. <style>
  419.     .btn {
  420.   background: #8b959c;
  421.   background-image: -webkit-linear-gradient(top, #8b959c, #5a6063);
  422.   background-image: -moz-linear-gradient(top, #8b959c, #5a6063);
  423.   background-image: -ms-linear-gradient(top, #8b959c, #5a6063);
  424.   background-image: -o-linear-gradient(top, #8b959c, #5a6063);
  425.   background-image: linear-gradient(to bottom, #8b959c, #5a6063);
  426.   font-family: Arial;
  427.   color: #ffffff;
  428.  
  429.   padding: 10px 20px 10px 20px;
  430.   text-decoration: none;
  431. }
  432.  
  433. .btn:hover {
  434.   background: #9fa5a8;
  435.   background-image: -webkit-linear-gradient(top, #9fa5a8, #63686b);
  436.   background-image: -moz-linear-gradient(top, #9fa5a8, #63686b);
  437.   background-image: -ms-linear-gradient(top, #9fa5a8, #63686b);
  438.   background-image: -o-linear-gradient(top, #9fa5a8, #63686b);
  439.   background-image: linear-gradient(to bottom, #9fa5a8, #63686b);
  440.   text-decoration: none;
  441. }
  442.  
  443.     #floor {
  444.     position: absolute;
  445.    left: 1%;
  446.     font-family: cursive;
  447.     right: -50%;
  448.         top: 2%;
  449.     cursor: default;
  450.     bottom: -50%;
  451.     /* font-size: 13px; */
  452.         width: 1230px;
  453.     height: 588px;
  454.     border: 1px solid #000;
  455.     border-bottom: 2px solid #000;
  456.     border-radius: 4px;
  457.     font-weight: light;
  458. background: #292626;
  459. }
  460.  
  461.  
  462.     #header {
  463.     background: #367897;
  464.     height: 30px;
  465.     width: auto;
  466.     line-height: 30px;
  467.     color: #FFF;
  468.     text-align: center;
  469.     border-radius: 3px 3px 0px 0px;
  470.     border: 1px solid rgba(255,255,255,0.2);
  471.     border-bottom: 1px solid #000;
  472.     font-size: 14px;
  473. }
  474.  
  475. #headerbg {
  476.     /* background: #367897; */
  477.     height: 46px;
  478.     /* width: 108px; */
  479.     /* margin-left: 1px; */
  480.     background-size: cover;
  481.     background-image: url(https://www.habbobites.com/uploads/157657e8f154bf_kqogfleihnpmj.png);
  482.     /* font-size: 14px; */
  483.     margin-top: 0px;
  484. }
  485.    
  486.    
  487.    
  488.    
  489.     #floor .text {
  490.     /* background: #367897; */
  491.     /* line-height: 30px; */
  492.     color: #333333;
  493.     text-align: center;
  494.     /* border-radius: 3px 3px 0px 0px; */
  495.     /* border: 1px solid rgba(255,255,255,0.2); */
  496.     /* border-bottom: 1px solid #000; */
  497.     font-size: 14px;
  498. }
  499.     #value {
  500.         border: 1px solid rgba(0,0,0,.5);
  501.         outline:none!important;
  502.         height: 30px;
  503.         width: 245px;
  504.         margin-bottom: 10px;
  505.         padding-left: 5px;
  506.         border-radius: 3px;
  507.         box-shadow:none;
  508.     }
  509.     #value:selected
  510.     {
  511.         outline: 0;
  512.     }
  513.     .buttonclose{
  514.             float: right;
  515.     background: url(http://i.imgur.com/NulNxSR.png);
  516.     background-repeat: no-repeat;
  517.     background-position: 50% 50%;
  518.     width: 19px;
  519.     height: 20px;
  520.     cursor: pointer;
  521.     margin-top: 5px;
  522.     margin-right: 5px
  523.     }
  524.    
  525.    
  526. </style>
  527. <main id="floor">
  528.     <div id="header">
  529.        
  530.         Floor Editor BETA
  531.        
  532.     </div>
  533.     <div id="headerbg"></div>
  534.     <div class="text">
  535.  
  536.          <div id="preview" style="position: absolute; top: 52px; left: 200px; "></div>
  537.                 <img id="mapimg"  style="position: absolute; top: 52px; left: 200px;" src="/app/funzioni_client/img/non.png" alt="" usemap="#map" /><map name="map"></map>
  538.               <div id="controls" style="position: absolute;top: 77px;left: 0;width: 224px;height: 511px;background: #929e97;/* border-right: 1px solid #EEE; *//* border-bottom: 1px solid #EEE; */overflow: hidden;/* border-radius:0 0 5px 0; */">      
  539.                         <div style="padding: 6px;w;/* width: 184px; */">
  540.                                 STRUMENTI FLOOR:<br>
  541.                                 <br>
  542.                                 <br>
  543.                                
  544.                                
  545.                                 <a href="/toolfloor.php" class="btn" target="_blank">Crea nuovo Modello</a>
  546.  
  547. <a href="floor.php"  class="btn" style="
  548.     position: absolute;
  549.     margin-top: 57px;
  550.     margin-left: -150px;
  551. ">Resetta Modello</a>
  552.  
  553. <a href="#" class="btn" style="
  554.     position: absolute;
  555.     margin-top: 104px;
  556.     margin-left: -151px;
  557. ">Importa Modello</a>
  558.  
  559.                                 <input id="toggle" type="hidden" onchange="Mouse = false;" />
  560.  
  561.                                  <form method="post">
  562.                                  
  563.                                <textarea id="export"  name="export1" style="visibility: hidden;height: 0px;width: 0px;"></textarea>
  564.                                
  565.                              
  566.                         <input type="submit" name="salva" class="btn" value="Salva Modello corrente" style="
  567.     border: 0px;
  568.     margin-top: 133px;
  569. ">
  570.                         </form>
  571.                         </div>
  572.                        
  573.                        
  574.                        
  575.                 </div>
  576.  
  577.     </div>
  578.         </body>
  579. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement