*jancis38* Posted January 31, 2009 Report Share Posted January 31, 2009 PHP <?php $ip = "cs.gign.lv"; $ports = "27015"; $socket = fsockopen("udp://".$ip, $ports); $cmd = "\xFF\xFF\xFF\xFF\x54Source Engine Query\x00"; $lenght = strlen($cmd); fwrite($socket, $cmd, $lenght); $response = fread($socket, 1); if (empty( $response)) { echo "<center>$ip:$ports: <b>-</b></center>\n"; } else { echo "<center>$ip:$ports: <b>+</b></center>\n"; } ?> Viss kārtībā, tiek izvadīts +. Bet ko darīt tālāk, kā pieņemsim izvadīt servera nosaukumu, mapes nosaukumu, spēlētāju skaitu/max. spēlētāju skaitu? Link to comment Share on other sites More sharing options...
X ID Posted February 1, 2009 Report Share Posted February 1, 2009 (edited) Izmantojot worm'a funckijas būtu ~ tā (+ getstring() ): PHP <? header ("Content-Type: text/plain; charset=utf-8"); // worm'a tūļi function getstring(&$raw){ if(empty( $raw)) return ''; getbyte($raw); $e=strpos($raw,0x00); $string=substr($raw,0,$e); $raw=substr($raw,$e); return $string; } $ip="cs.gign.lv"; $port=27015; if(! $sock=@fsockopen("udp://".$ip,$port,$errno,$errstr,1)){ die( '[ERROR] '.$errno.': '.$errstr); } $data=(object)array(); $response=query("TSource Engine Query\ 0"); // te vēl to sūdu rauj nost, starp \ un 0 nav jābūt atstarpei $type=getbyte($response); if( $type==0x49){ $data->name=getstring($response); $data->map=getstring($response); getstring($response); getstring($response); getshort($response); getbyte($response); $data->players_now=getbyte($response); $data->players_max=getbyte($response); }elseif( $type==0x6D){ getstring($response); $data->name=getstring($response); $data->map=getstring($response); getstring($response); getstring($response); getbyte($response); $data->players_now=getbyte($response); $data->players_max=getbyte($response); }else{ die( 'WTF?!'); } echo " Servera nosaukums: $data->name Karte: $data->map Spēlētāji: $data->players_now/$data->players_max " ; ?> EDIT: Gļukains highlight's. Edited February 1, 2009 by X ID Link to comment Share on other sites More sharing options...
*jancis38* Posted February 1, 2009 Author Report Share Posted February 1, 2009 Sakombinēju visu, un viss strādā, kā nākas. Paldies! Ir vel iespējams izdabūt spēlētāju sarakstu, ar fragiem, un nāvēm? Link to comment Share on other sites More sharing options...
w4p1337 Posted February 1, 2009 Report Share Posted February 1, 2009 X ID , tu tāds labs kodētajs , a kā varētu mapi izvilkt? pēc tam kā dabūt uz bildēm pats uztaisītu! Link to comment Share on other sites More sharing options...
X ID Posted February 1, 2009 Report Share Posted February 1, 2009 *jancis38*, skaties pats, kāds pieprasījums jāsūta, lai iegūtu spēlētāju info un kāda būs atbilde: http://developer.valvesoftware.com/wiki/Se...ries#A2S_PLAYER w4p1337, ja tu paskatītos, ko es iepriekš rakstiju, tad redzētu, ka mape jau tika izvilkta (: Link to comment Share on other sites More sharing options...
*jancis38* Posted February 1, 2009 Author Report Share Posted February 1, 2009 Ok. Paldies, vēlāk pačakarēšos. Man mieru dažreiz neliek šī kļūda: Fatal error: Maximum execution time of 30 seconds exceeded in ..\monitori.php on line 52 Line 52: PHP $packet = fread($sock, 1500); Link to comment Share on other sites More sharing options...
X ID Posted February 1, 2009 Report Share Posted February 1, 2009 Tā mēdz gadīties ar konekcijām un datu apmaiņu. Ja php nav palaists safe mod'ā, tad var izmantot set_time_limit() funkciju. Link to comment Share on other sites More sharing options...
*jancis38* Posted February 1, 2009 Author Report Share Posted February 1, 2009 Vai nav pieejams kāds cits risinājums? Link to comment Share on other sites More sharing options...
X ID Posted February 1, 2009 Report Share Posted February 1, 2009 Ir pieejamas dažādas iespējas skripta izpildes laika pagarināšanai, bet paātrināt datu lasīšanas ātrumu būs pagrūtāk. Link to comment Share on other sites More sharing options...
w4p1337 Posted February 1, 2009 Report Share Posted February 1, 2009 Eh , mana vaina, ka nepamanīju , ka karti jau izvadi :doh: oO Link to comment Share on other sites More sharing options...
w4p1337 Posted February 1, 2009 Report Share Posted February 1, 2009 Kpc , man rādās, <b>Fatal error</b>: Call to undefined function query() in <b>D:\AppServ\www\server.php</b> on line <b>21</b><br /> Kad , es atveru šo failu? Link to comment Share on other sites More sharing options...
*jancis38* Posted February 1, 2009 Author Report Share Posted February 1, 2009 Pārējas f-ijas pievieno (no worm topika). Link to comment Share on other sites More sharing options...
w4p1337 Posted February 1, 2009 Report Share Posted February 1, 2009 (edited) O paldies. piemēram ja gribu atgriezt players vajag? PHP define('A2S_PLAYER','0x44); $respone = query(A2S_PLAYER); Kkā ta? P.s. http://waplet.oo.lv/server.php Kpc diez html nerukā? Tā sataisīju html, ka iet. Talāk kā varētu izdarīt ta ka,ja PHP if (ir mapes bilde){ echo "bilde" ; } else{ echo "tuksha bilde"; } Edited February 1, 2009 by w4p1337 Link to comment Share on other sites More sharing options...
*jancis38* Posted February 1, 2009 Author Report Share Posted February 1, 2009 (edited) PHP $mapes_bilde = "cels/uz/mapes/bildeem/$data->map.jpg"; if (!file_exists($mapes_bilde)) { $mapes_bilde = "ja/bildes/nav/tad/raadiis/shito/nav_bilde_y0!.jpg"; } EDIT: set_time_limit() funkciju. Uzstādīju uz 1, bet vienalga lapu lāde 30 sekundes, ko darīt? Kad parādās kļūda, rāda: Fatal error: Maximum execution time of 1 second exceeded... Tātad viss pareizi. Un kā tikt vaļā no tā die(), vismaz uzrādīt kādu echo tā vietā. Edited February 1, 2009 by *jancis38* Link to comment Share on other sites More sharing options...
*jancis38* Posted February 2, 2009 Author Report Share Posted February 2, 2009 HOPS! Laikam netika izcelts mans EDIT's. Link to comment Share on other sites More sharing options...
X ID Posted February 2, 2009 Report Share Posted February 2, 2009 Tu nomainīji skripta maksimālo izpildes laiku uz 1 sekundi. Pēc idejas tev vajadzētu laiku pagarināt, lai skripts paspētu izpildīties, pirms tas tiek apturēts. Link to comment Share on other sites More sharing options...
*jancis38* Posted February 2, 2009 Author Report Share Posted February 2, 2009 Ā! Nu skaidrs, tagad viss strādā kā nākas, paldies. Tagad tik jāsāk štukot, kā izvilkt spēlētājus... Link to comment Share on other sites More sharing options...
pro Posted February 3, 2009 Report Share Posted February 3, 2009 http://waplet.oo.lv/server.php kāds var man lūdzu iedot šo monitoru? Link to comment Share on other sites More sharing options...
*jancis38* Posted February 3, 2009 Author Report Share Posted February 3, 2009 Tu pasists gadījumā neesi? Link to comment Share on other sites More sharing options...
X ID Posted February 3, 2009 Report Share Posted February 3, 2009 (edited) Klauns. Apskaties pirmo lapu šim topikam. Edited February 3, 2009 by X ID Link to comment Share on other sites More sharing options...
pro Posted February 3, 2009 Report Share Posted February 3, 2009 Klauns. Apskaties pirmo lapu šim topikam. Es jau skatijos man radija kautkadu eror Link to comment Share on other sites More sharing options...
w4p1337 Posted February 3, 2009 Report Share Posted February 3, 2009 Nu tad izlasi pilniigi visu kas shinii topikaa ir mineets,gan jau atradiisi! Link to comment Share on other sites More sharing options...
pro Posted February 3, 2009 Report Share Posted February 3, 2009 Nu tad izlasi pilniigi visu kas shinii topikaa ir mineets,gan jau atradiisi! es jau meginaju no servera monitoriem es neko nesapratu Link to comment Share on other sites More sharing options...
worm Posted February 4, 2009 Report Share Posted February 4, 2009 tad šī sadaļa nav domāta tev... takšto PISSSS NAHUJ p.s. es necienu tādus idiotus kā tu, kas nevis nemāk, bet negrib mācīties un uzskata mūs par gana naiviem, cerībā, ka nekas nebūs jādara un tev viss tiks pasniegts uz paplātes Link to comment Share on other sites More sharing options...
w4p1337 Posted February 5, 2009 Report Share Posted February 5, 2009 (edited) worm kā būs ar tiem playeriem? define('A2S_PLAYER','0x44); $respone = query(A2S_PLAYER); n0r3k : būs tā, ka Tu dabūsi banu, jo es saskaitīju 10 memberus no Tavas IP! 3 no tiem ir waplet, wap1337 un w4p1337. Tu gribi rakstīt to viena acc vai arī nerakstīt vispār, ko ? Edited February 6, 2009 by w4p1337 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now