Jump to content

laponac84

Members
  • Posts

    13
  • Joined

  • Last visited

laponac84's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i am new with web socket and in same time I try to make server and client communication for soccer manager application, and for this purpose, i need to create closed "chat rooms" or "games" where two users can watch (read game event) and menage (create) game event (make substitution, formation ... or if you want, to send message to server, that they make changes in formation) this game (room) mast bi secret, and only this two player can use this game for "read" and "write" events in game for example: Game no: 200001 between user A and user B in 14.05. when User A, and User B click on game no. 200001 they can read and write game event. PS: for now, i create basic chat aplication with PHP, jQuery and webSocket and in this app, all user see wath all other user do (public chat) and i want to make secret chat for specific user (already automate subscribed from server) All work with no problem (i work on this example http://www.sanwebe.com/2013/05/chat-using-websocket-php-socket) How i can create chat room(s) and subscribe user to specific chat room? Thanks
  2. maybe'm a little confused, but I need the following: First: 1. the current version of football manager that I made with PHP + MySQL, jQuery ... not contained live online game with two opponents. In this (old version) it was possible to only see the final result (not to be part of live game). 2. i know how to make live game with refreshing page, or div on some "N" second. to read data form Mysql, but this is not ok solution. Second: what is actually needed? For example: i have two player online live in the game, i need 1. one server to create events in the game (attack from the left with a strike from the middle of ... , red card ...) and wait (read) to the client signals (two direct players), or more directly, the changes of formation and the players themselves2. Two (or more) clients for Reading messages from the server (the event that the server will create, change tactics and composition of the teams that will make the other opponent) and send a message to the server (substitutions and tactics)on Google when you type "PHP client server", most links have a socket, so I read about him with PHP + MySQL, jQuery i know how to make this, but with lots of refreshing of content, and if i have 10.000 users, i think that this is not smart solution What is the best solution for me? PS1: i make all code in local server (easy php) I also have a good web hosting, if necessary.
  3. Hallo i start learning Socket and php programming for now successfully manage to make the communication between the client and the server, by sending an automatic message from the system. I am interested in the following: 1. Does the server can send messages to specific client ? or server send to all client, and then client make filter of message (this is for me, this is not)?2. How i can menage number of connection ?3. How i can menage to make live client and server?I make while(true){ // code } part of code for make server live, but this way is not too functional, because the server does not see what was happening, I can see the response message to the client only PS: Is there any bether solution ?
  4. This is what I managed to do it, but not good enough. I made a progress bar on the basis of completed processes. Problem occurs when the file (game) is large, and the progress bar is stationary for a long time until the whole game does not load on server. After that, script continue to load the rest of the process. For the user it is very important to have live information on what is currently happening. For these reasons, is really important to measure copy files from remote server to current server. (all processes other than copying files, are very short and quick, so it is not necessary to show them in progress bar becaose they ending in a split of second) As you can see, I do not have a html form , (Every example I found on the Internet is "Upload form") i have one xml file, which contains url of game. By clicking the install, I pick a game that I copied to current server from remote server. I get with the help jquery games file url, and sent (post) for processing in php file Example Part of index.php file <div class="game"> <div style="float: none; margin: 5px ;" class="button" name="<?php echo $game['uuid']; ?>" id="url value">Install</div> <div id="<?php echo $game['uuid']; ?>"> </div> </div> jqerry file: $(".button").click(function () var value = $(this).attr("id"); $(this).hide(); $.post('process.php',{val: value},function(data){ $("#" + install).html(data); // collecting data }); $.post('process2.php',{val: value},function(data){ $("#" + install).html(data); // copy main file }); // rest call for process file... }); As you can see in my jquery file, I know the exact path of the file to be copied from the remote server ( ID of install div have that value) Process1.php, Process2.php , and rest... are quite the same file, which in the end have a progress bar in percentage How to make progress bar, with this data ?
  5. I try to upload fale(game.swf) from another webserver to my webserver, and that is not problem. Problem is create progress bar to track copying files process, or more precisely, the calculation and display the value in percentage, of file that i currently copied from other webserver to my webserver (alredy have full size of file variable) This is what i do for now. ----------------------------------------------- after clik on install buton (div element) jq.js file $(".button").click(function () { var val = $(this).attr("id"); //id have url value for game i want to install http://www......game.swf $.post('proces.php',{val: val},function(data){ $(".final_data").html(data); }); }); proces.php file $link = $_POST['val']; // ... function remotefileSize($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_MAXREDIRS, 3); curl_exec($ch); $filesize = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); curl_close($ch); if ($filesize) return $filesize; } $b = remotefileSize($igrica_mochi); $mb = $b / 1048576; echo round($mb, 2). " Mb<br>"; //round(1.95583, 2); echo $b. " bytes<br>";// ... if (@copy($game_from_other_server, $game_in_my_server) ) { echo "- Finish!<br>"; }else{ echo "- Error.<br>"; $errors= error_get_last(); echo "- COPY ERROR: ".$errors['type']; echo "<br />\n".$errors['message']; }Formula for calculating procent is progres = (current / full) * 100 And question is value of 'current' Any ideas ?
  6. Code: jQuery code $(document).ready(function(){ setInterval(checkChat, 3000); }); function new_message(){ var val = $(".chat_box").attr('id'); var id_reciver = val.substr(val.indexOf("_") + 1) $(".chat_box").bind('keydown', function(e){ alert(e.keyCode); e.preventDefault(); }); } html code <textarea class='chat_box' id='input_"+chatuser+"' placeholder='type message' onkeyup='new_message()'></textarea> Problem description (time line of problem): 1) The first time when i press any key on the keyboard, i do not have alert(e.keyCode) 2) The second time when i press any key on the keyboard, i have correct alert(e.keyCode) 3) The third time when I press the button on the keyboard, i have correct alert(e.keyCode), but 2 time alert`s 4) ..... i have correct alert(e.keyCode), but 3 time alert`s 5) ... and so on .... Why this happens? Alert instead, there should be standing at the mysql_query("insert into.... posts for inserting message in database, but, this code will be insert message "N" times in row... and that is not ok. PS: You can see the message box on attached picture (i have 2 same message in row) (i try to upgrade chat box application, and i m try to be like chat on Facebook, everything that I had planned I've done, I've just not about sending this message -... i send messages, but the few times one and the same :S)
  7. With the help of code that I listed below, can successfully show ID drag div drag = $('.ui-draggable').attr('id'); alert(drag); But, how to show ID of target(spapped) div (div where drag div is dropped) hiar is all code //<![CDATA[ $(window).load(function(){ jQuery.fn.swap = function(b){ b = jQuery(b)[0]; var a = this[0]; var t = a.parentNode.insertBefore(document.createTextNode(''), a); b.parentNode.insertBefore(a, B); t.parentNode.insertBefore(b, t); t.parentNode.removeChild(t); alert(a); return this; }; $( ".dragdrop" ).draggable({ revert: true, helper: "clone" }); $( ".dragdrop" ).droppable({ accept: ".dragdrop", activeClass: "ui-state-hover", hoverClass: "ui-state-active", drop: function( event, ui ) { var draggable = ui.draggable, droppable = $(this), dragPos = draggable.position(), dropPos = droppable.position(); var drag = $('.ui-draggable').attr('id'); draggable.css({ left: dropPos.left+'px', top: dropPos.top+'px' }); droppable.css({ left: dragPos.left+'px', top: dragPos.top+'px' }); draggable.swap(droppable); } }); });//]]>
  8. I understand and know how to do that, unfortunately, problem was in Easy PhP. When i upload my example on internet server, all css code work ok.
  9. This is basic template for soccer manager http://sportskevesti.co/imege/Screenshot_1.png this is the code ( #telo is white space below the menu, #glavno is left blue part, #desno is right blue part) <div id="telo"> <div id="glavno"> </div> <div id="desno"> </div> </div> #telo{ width: 1000px; overflow: hidden; float: left; } #glavno{ width: 650px; overflow: hidden; height:350px; background-color: #336699; float: left; padding: 0px; margin: 10px 0px 0px 0px; } #desno{ width: 340px; min-width: 340px; min-height: 350px; overflow: hidden; background-color: #336699; float: left; margin: 10px 0px 0px 10px; } And, this is OK for now. But... when i put some code in template for GET session and GET option for dinamic webpage i have problem with empty blu space in #glavno, between the top border, and div inside the #glavno example: http://sportskevesti.co/imege/Screenshot_2.png as you see, i have empty blue space in #glavno, and that is not ok...i nead TIM1 div to bi in line with top border #glavno this is code <div id="glavno"> <?php if(!empty($sessija)){ switch ($opcija) { case "moj-tim": include("modul/mod_moj_tim/index.php"); break; //rest of case.... } } elseif(empty($sessija)){ // no session code... } } ?> </div> file: modul/mod_moj_tim/index.php <div id="liga"> <?php echo strtoupper($naziv); ?> </div> liga{ background-color: #131313; overflow: hidden; float: none; width: 650px; padding:10px; margin-top:0px; color: #ffffff; font-size: 16px; border-style:solid; border-width: 0px 0px 1px 0px; border-color: #a1a1a1; } Where is the problem, and what to do? Thanks
  10. http://sportskevesti.co/balkan.php?zemlja=srbija On this link, on the left side of the page, you can see menu with the flags. hover, active, visited and link is ok... but i want to know, What do I need to add in the CSS code, to see if i read the sport news from Serbia, Serbian flags in flag menu be full color, or if you read Macedonia, Macedonian flag was in full color ... or i mast use php code if(country == "serbia"){ flag meni is like this } else is like this
  11. how to make a:active have protperties like a:hover? i have code below, but ... active link is same as visited or usual link #flag:link and #flag:visited have black and white image #flag:hover have full color image, but #flag:active not <a href="#" id="flag" > link1 </a> #flag:link, #flag:visited{ background-image:url(../imege/flag/flagbw.jpg); display:block; height: 96px; width:128px; text-indent:-9999px; -webkit-opacity: 0.25; -moz-opacity: 0.25; opacity: 0.25; -webkit-transition: all 2s ease; -moz-transition: all 2s ease; -ms-transition: all 2s ease; -o-transition: all 2s ease; transition: all 2s ease; } #flag:hover, #flag:active{ background-image:url(../imege/flag/flag2.jpg); display:block; height: 96px; width:128px; text-indent:-9999px; -webkit-opacity: 1; -moz-opacity: 1; opacity: 1; }
  12. Situation: i have 2 mysql table`s 1. tbl_document (id, number_of_document) 2. tbl_items_of_document (id, name_of_item, document_id, user_id) now, clasic php html form <form action="insert.php?document_id=<?php echo $id; ?>" method="post"> ..... </form> after form we use $document_id = $_GET["document_id"]; $name = $_POST["name_of_item"]; //... mysql_query("INSERT INTO `tbl_items_of_document` SET `name_of_item` = '$name', `document_id` = '$document_id', `user_id` = '$user_id'")or die(mysql_error()); we have all necessary data inserted in the table And the we come to problem if we want to use jquery with code below, i can insert data in one independet mysql table jQuery Basics: POST/GET Data (HTTP Request) index.php [/size][/font][/color] <input type="text" id="name" /> <div id="name_feedback"></div> [color=#000000][font=Tahoma, Verdana, Arial][size=3] jfunc.js [/size][/font][/color] $('#name').keyup(function(){ var name = $('#name').val(); $.post('proces.php'), {name:name}, function(data) { $('#name_feedback').html(data); }); }); [color=#000000][font=Tahoma, Verdana, Arial][size=3] proces.php [/size][/font][/color] <?php if(isset($_POST['name'])){ $name = $_POST['name']; echo $name; //or mysql_query..... [color=#000000][font=Tahoma, Verdana, Arial][size=3] and this code is ok for insert into independent table what if we have relation database, with two tables? 1. tbl_document (id, number_of_document) 2. tbl_items_of_document (id, name_of_item, document_id, user_id) and i want to insert data into tbl_items_of_document, and i nead for that: - value of `id` from tbl_document - and value of `session` how to GET `id` of the document to write in to `tbl_items_of_document` with jQuery, or, how to GET session id with jquery, becose i want to know who create that item or item`s? thanks
  13. Hi, How to get: 1. Part of URL with jquery for example: ..index.php?program_id=1&option=add i wont to get valuer program_id = ? and option= ? 2. How to get value of php session? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.