Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $host = "127.0.0.1";
- $nome = "root";
- $pass = "svtcsm74";
- $dbnome = "asd";
- $conn = mysql_connect($host,$nome,$pass) or die('Errore di connessione' . mysql_error());
- $seldb = mysql_select_db($dbnome,$conn) or die(mysql_error());
- function mus($header, $data=''){
- $musData = $header . chr(1) . $data;
- $sock = @socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp'));
- @socket_connect($sock, '127.0.0.1', '30001');
- @socket_send($sock, $musData, strlen($musData), MSG_DONTROUTE);
- @socket_close($sock);
- }
- function salva_modello($code)
- {
- $random = "model_".rand(555,999999);
- $stmt = mysql_query("INSERT INTO room_models(id,door_x,door_y,door_dir,heightmap)
- VALUES('".$random."', '0', '10', '2', '".$code."')");
- $room = mysql_query("INSERT INTO rooms(caption,owner,model_name) VALUES('Stanza Realizzata con Floor!', '".user('username')."', '".$random."')");
- mus("update_navigator");
- return $stmt;
- }
- function user($data){
- $utente = mysql_query("SELECT * FROM users WHERE username = '".$_SESSION['username']."' LIMIT 1");
- $info = mysql_fetch_assoc($utente);
- return $info[$data];
- }
- if(isset($_POST['salva'])){
- $code = trim($_POST['export1']);
- if($code == ""){
- echo "<script>alert('Errore Modello non caricato');</script>";
- }else if(!strstr($code,'X') && !strstr($code,'0'))
- {
- echo"<script>alert('Errore Modello non caricato');</script>";
- }
- else if(user('credits') < 40)
- {
- echo"<script>alert('Devi avere almeno 40 Crediti per creare il Modello!');</script>";
- }
- else{
- mysql_query("UPDATE users SET vip_points = vip_points -40 WHERE username = '".$_SESSION['username']."' LIMIT 1");
- if(salva_modello($code)){
- 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>";
- }
- }
- }
- ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>Room Model</title>
- <script type="text/javascript">
- var Map;
- var OffsetX;
- var OffsetY;
- var Mouse = false;
- var MouseMode;
- var MousedMap;
- function AddTileArea(C, X, Y)
- {
- var E = document.createElement( "area" );
- E.shape = "poly";
- E.coords = C;
- document.getElementsByTagName("map")[0].appendChild(E);
- E.onmouseover = function(){ TileOver(X, Y); };
- E.onmouseout = function(){ TileOut(X, Y); };
- E.onclick = function(){ TileClick(X, Y); };
- }
- function PrepareBlankMap(X, Y)
- {
- if(!isInt(X) || !isInt(Y))
- {
- alert("Invalid Size");
- return;
- }
- Map = new Array();
- MousedMap = new Array();
- Mouse = false;
- OffsetX = ((Y*32)-7);
- OffsetY = 25;
- document.getElementsByTagName("map")[0].innerHTML = "";
- for(var x = 0; x < X; x++)
- {
- Map[x] = new Array();
- MousedMap[x] = new Array();
- for(var y = 0; y < Y; y++)
- {
- Map[x][y] = true;
- var _x = ((x*32)+(y*-32)+OffsetX);
- var _y = ((x*16)+(y*16)+OffsetY);
- var Coords = "";
- Coords += (_x + 31); // TopX
- Coords += ",";
- Coords += (_y); // TopY
- Coords += ",";
- Coords += (_x + 63); // RightX
- Coords += ",";
- Coords += (_y + 16); // RightY
- Coords += ",";
- Coords += (_x + 32); // BottomX
- Coords += ",";
- Coords += (_y + 31); // BottomY
- Coords += ",";
- Coords += (_x + 31); // BottomX
- Coords += ",";
- Coords += (_y + 31); // BottomY
- Coords += ",";
- Coords += (_x + 0); // LeftX
- Coords += ",";
- Coords += (_y + 16); // LeftY
- AddTileArea(Coords, x, y);
- }
- }
- DrawMap();
- ResetMousedMap();
- }
- function DrawMap()
- {
- var X = Map.length;
- var Y = Map[0].length;
- var Output = "";
- for(var x = 0; x < X; x++)
- {
- for(var y = 0; y < Y; y++)
- {
- var _x = ((x*32)+(y*-32)+OffsetX);
- var _y = ((x*16)+(y*16)+OffsetY);
- if(Map[x][y])
- Output += '<img id="tile'+x+'-'+y+'" class="square" style="top: ' + _y + 'px; left: ' + _x + 'px;" src="/app/funzioni_client/img/attivo.png" />';
- else
- Output += '<img id="tile'+x+'-'+y+'" class="square" style="top: ' + _y + 'px; left: ' + _x + 'px;" src="/app/funzioni_client/img/non.png" />';
- }
- }
- var Preview = document.getElementById('preview');
- Preview.style.width = ((X*32)+(Y*+32)+50) + 'px';
- Preview.style.height = ((X*16)+(Y*+16)+50+8) + 'px';
- Preview.innerHTML = Output;
- var MapImg = document.getElementById('mapimg');
- MapImg.style.width = ((X*32)+(Y*+32)+50) + 'px';
- MapImg.style.height = ((X*16)+(Y*+16)+50+8) + 'px';
- RefreshExport();
- }
- function RedrawMap()
- {
- var X = Map.length;
- var Y = Map[0].length;
- for(var x = 0; x < X; x++)
- {
- for(var y = 0; y < Y; y++)
- {
- if(Map[x][y])
- document.getElementById('tile'+x+'-'+y).src = '/app/funzioni_client/img/attivo.png';
- else
- document.getElementById('tile'+x+'-'+y).src = '/app/funzioni_client/img/non.png';
- }
- }
- RefreshExport();
- }
- function TileOver(X, Y)
- {
- if(!Mouse)
- {
- if(Map[X][Y])
- {
- document.getElementById('tile'+X+'-'+Y).src = '/app/funzioni_client/img/del.png';
- }
- else
- {
- document.getElementById('tile'+X+'-'+Y).src = '/app/funzioni_client/img/add.png';
- }
- }
- else
- {
- if(!MousedMap[X][Y] && Map[X][Y] == MouseMode)
- {
- MousedMap[X][Y] = true;
- Map[X][Y] = !MouseMode;
- RedrawMap();
- }
- }
- }
- function TileOut(X, Y)
- {
- if(!Mouse)
- {
- if(Map[X][Y])
- {
- document.getElementById('tile'+X+'-'+Y).src = '/app/funzioni_client/img/attivo.png';
- }
- else
- {
- document.getElementById('tile'+X+'-'+Y).src = '/app/funzioni_client/img/non.png';
- }
- }
- }
- function TileClick(X, Y)
- {
- if(document.getElementById('toggle').checked)
- {
- if(!Mouse)
- {
- Mouse = true;
- MouseMode = Map[X][Y];
- Map[X][Y] = !Map[X][Y];
- RedrawMap();
- }
- else
- {
- Mouse = false;
- ResetMousedMap();
- }
- }
- else
- {
- Map[X][Y] = !Map[X][Y];
- RedrawMap();
- }
- }
- function RefreshExport()
- {
- var X = Map.length;
- var Y = Map[0].length;
- var Export = "";
- for(var y = 0; y < Y; y++)
- {
- for(var x = 0; x < X; x++)
- {
- if(Map[x][y])
- Export += '0';
- else
- Export += 'X';
- }
- Export += '\n';
- }
- document.getElementById('export').value = Export;
- }
- function ResetMousedMap()
- {
- var X = Map.length;
- var Y = Map[0].length;
- for(var x = 0; x < X; x++)
- {
- for(var y = 0; y < Y; y++)
- {
- MousedMap[x][y] = false;
- }
- }
- }
- function isInt(x)
- {
- var y=parseInt(x);
- if (isNaN(y)) return false;
- return x==y && x.toString()==y.toString();
- }
- function ParseMap()
- {
- var MapData = document.getElementById('import').value;
- var NewMap = new Array();
- var Lines = MapData.split('\n');
- Mouse = false;
- OffsetX = ((Lines[0].length*32)-7);
- OffsetY = 25;
- document.getElementsByTagName("map")[0].innerHTML = "";
- var Rotation = new Array();
- for(var Y = 0; Y < Lines[0].length; Y++)
- {
- Rotation[Y] = new Array();
- }
- for(var X = 0; X < Lines.length; X++)
- {
- for(var Y = 0; Y < Lines[X].length; Y++)
- {
- Rotation[Y] += Lines[X][Y];
- }
- }
- var Output = "";
- MousedMap = new Array();
- for(var X = 0; X < Rotation.length; X++)
- {
- if(Rotation[X].length == 0)
- break;
- if(Rotation[X][0] == '\r')
- break;
- if(Rotation[X].length != Rotation[0].length)
- {
- alert("Invalid map! All lines must be the same size.");
- return;
- }
- NewMap[X] = new Array();
- MousedMap[X] = new Array();
- for(var Y = 0; Y < Rotation[X].length; Y++)
- {
- var _x = ((X*32)+(Y*-32)+OffsetX);
- var _y = ((X*16)+(Y*16)+OffsetY);
- if(Rotation[X][Y] == 'X' || Rotation[X][Y] == 'x')
- {
- NewMap[X][Y] = false;
- 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" />';
- }
- else if(Rotation[X][Y] == '0')
- {
- NewMap[X][Y] = true;
- Output += '<img id="tile'+X+'-'+Y+'" class="square" style="top: ' + _y + 'px; left: ' + _x + 'px;" src="/app/funzioni_client/img/attivo.png" />';
- }
- else if(Rotation[X][Y] == '\r'){}
- else
- {
- alert("Invalid map! (" + X + "," + Y + " : " + Rotation[X][Y] + ")\n\nNote: This map does not accept stairs.");
- return;
- }
- var Coords = "";
- Coords += (_x + 31); // TopX
- Coords += ",";
- Coords += (_y); // TopY
- Coords += ",";
- Coords += (_x + 63); // RightX
- Coords += ",";
- Coords += (_y + 16); // RightY
- Coords += ",";
- Coords += (_x + 32); // BottomX
- Coords += ",";
- Coords += (_y + 31); // BottomY
- Coords += ",";
- Coords += (_x + 31); // BottomX
- Coords += ",";
- Coords += (_y + 31); // BottomY
- Coords += ",";
- Coords += (_x + 0); // LeftX
- Coords += ",";
- Coords += (_y + 16); // LeftY
- AddTileArea(Coords, X, Y);
- }
- }
- var Preview = document.getElementById('preview');
- Preview.style.width = ((Rotation.length*32)+(Rotation[0].length*+32)+50) + 'px';
- Preview.style.height = ((Rotation.length*16)+(Rotation[0].length*+16)+50+8) + 'px';
- Preview.innerHTML = Output;
- var MapImg = document.getElementById('mapimg');
- MapImg.style.width = ((Rotation.length*32)+(Rotation[0].length*+32)+50) + 'px';
- MapImg.style.height = ((Rotation.length*16)+(Rotation[0].length*+16)+50+8) + 'px';
- Map = NewMap;
- ResetMousedMap();
- RefreshExport();
- document.getElementById('controls').style.width = 180 + 'px';
- }
- </script>
- <style type="text/css">
- .square
- {
- position: absolute;
- }
- a
- {
- color: #FFF;
- }
- </style>
- </head>
- <body onload="PrepareBlankMap(15, 15);">
- <style>
- .btn {
- background: #8b959c;
- background-image: -webkit-linear-gradient(top, #8b959c, #5a6063);
- background-image: -moz-linear-gradient(top, #8b959c, #5a6063);
- background-image: -ms-linear-gradient(top, #8b959c, #5a6063);
- background-image: -o-linear-gradient(top, #8b959c, #5a6063);
- background-image: linear-gradient(to bottom, #8b959c, #5a6063);
- font-family: Arial;
- color: #ffffff;
- padding: 10px 20px 10px 20px;
- text-decoration: none;
- }
- .btn:hover {
- background: #9fa5a8;
- background-image: -webkit-linear-gradient(top, #9fa5a8, #63686b);
- background-image: -moz-linear-gradient(top, #9fa5a8, #63686b);
- background-image: -ms-linear-gradient(top, #9fa5a8, #63686b);
- background-image: -o-linear-gradient(top, #9fa5a8, #63686b);
- background-image: linear-gradient(to bottom, #9fa5a8, #63686b);
- text-decoration: none;
- }
- #floor {
- position: absolute;
- left: 1%;
- font-family: cursive;
- right: -50%;
- top: 2%;
- cursor: default;
- bottom: -50%;
- /* font-size: 13px; */
- width: 1230px;
- height: 588px;
- border: 1px solid #000;
- border-bottom: 2px solid #000;
- border-radius: 4px;
- font-weight: light;
- background: #292626;
- }
- #header {
- background: #367897;
- height: 30px;
- width: auto;
- line-height: 30px;
- color: #FFF;
- text-align: center;
- border-radius: 3px 3px 0px 0px;
- border: 1px solid rgba(255,255,255,0.2);
- border-bottom: 1px solid #000;
- font-size: 14px;
- }
- #headerbg {
- /* background: #367897; */
- height: 46px;
- /* width: 108px; */
- /* margin-left: 1px; */
- background-size: cover;
- background-image: url(https://www.habbobites.com/uploads/157657e8f154bf_kqogfleihnpmj.png);
- /* font-size: 14px; */
- margin-top: 0px;
- }
- #floor .text {
- /* background: #367897; */
- /* line-height: 30px; */
- color: #333333;
- text-align: center;
- /* border-radius: 3px 3px 0px 0px; */
- /* border: 1px solid rgba(255,255,255,0.2); */
- /* border-bottom: 1px solid #000; */
- font-size: 14px;
- }
- #value {
- border: 1px solid rgba(0,0,0,.5);
- outline:none!important;
- height: 30px;
- width: 245px;
- margin-bottom: 10px;
- padding-left: 5px;
- border-radius: 3px;
- box-shadow:none;
- }
- #value:selected
- {
- outline: 0;
- }
- .buttonclose{
- float: right;
- background: url(http://i.imgur.com/NulNxSR.png);
- background-repeat: no-repeat;
- background-position: 50% 50%;
- width: 19px;
- height: 20px;
- cursor: pointer;
- margin-top: 5px;
- margin-right: 5px
- }
- </style>
- <main id="floor">
- <div id="header">
- Floor Editor BETA
- </div>
- <div id="headerbg"></div>
- <div class="text">
- <div id="preview" style="position: absolute; top: 52px; left: 200px; "></div>
- <img id="mapimg" style="position: absolute; top: 52px; left: 200px;" src="/app/funzioni_client/img/non.png" alt="" usemap="#map" /><map name="map"></map>
- <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; */">
- <div style="padding: 6px;w;/* width: 184px; */">
- STRUMENTI FLOOR:<br>
- <br>
- <br>
- <a href="/toolfloor.php" class="btn" target="_blank">Crea nuovo Modello</a>
- <a href="floor.php" class="btn" style="
- position: absolute;
- margin-top: 57px;
- margin-left: -150px;
- ">Resetta Modello</a>
- <a href="#" class="btn" style="
- position: absolute;
- margin-top: 104px;
- margin-left: -151px;
- ">Importa Modello</a>
- <input id="toggle" type="hidden" onchange="Mouse = false;" />
- <form method="post">
- <textarea id="export" name="export1" style="visibility: hidden;height: 0px;width: 0px;"></textarea>
- <input type="submit" name="salva" class="btn" value="Salva Modello corrente" style="
- border: 0px;
- margin-top: 133px;
- ">
- </form>
- </div>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement