[ROZWIĄZANE] Sockety pokazują, że plik nie...
Best Answer speedkill 27.08.2014 21:13
https://forums.allie...ad.php?t=151401
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <sockets> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "speedkill" #define g_SiteName "/wersja_menu_spara.php" #define g_HostName "szelbi.gameclan.pl" new g_Socket; public plugin_init(){ register_plugin(PLUGIN, VERSION, AUTHOR); new g_SendBuffer[512], g_ErrorMessage; g_Socket = socket_open(g_HostName, 80, SOCKET_TCP, g_ErrorMessage); switch(g_ErrorMessage){ } formatex(g_SendBuffer, charsmax(g_SendBuffer), "GET %s HTTP/1.1^nHost:%s^r^n^r^n", g_SiteName, g_HostName); socket_send(g_Socket, g_SendBuffer, charsmax(g_SendBuffer)); set_task(1.0, "SocketAnswer",.flags = "b"); } public SocketAnswer(){ if(socket_change(g_Socket)){ new g_Data[1024]; socket_recv(g_Socket, g_Data, charsmax(g_Data)); log_amx(g_Data); socket_close(g_Socket); if(task_exists()){ remove_task(); } } }
L 08/27/2014 - 22:10:01: [Test123.amxx] HTTP/1.1 200 OK Date: Wed, 27 Aug 2014 20:09:58 GMT Server: Apache X-Powered-By: PHP/5.4.4-14+deb7u14 Vary: Accept-Encoding Transfer-Encoding: chunked Content-Type: text/html 5 1.0.5 0Go to the full post
szelbi
25.08.2014
#define SITE "/wersja_menu_spara.php" #define HOST "szelbi.gameclan.pl" #define TASK_SOCKET 123
public sprawdz_wersje() { new iError, szSendBuffer[512]; g_sckweb = socket_open(HOST, 80, SOCKET_TCP, iError); switch(iError) { case 1: { server_print("Unable to create socket."); return; } case 2: { server_print("Unable to connect to hostname."); return; } case 3: { server_print("Unable to connect to the HTTP port."); return; } } format(szSendBuffer, charsmax(szSendBuffer), "GET %s^nHost:%s^r^n^r^n", SITE, HOST); socket_send(g_sckweb, szSendBuffer, charsmax(szSendBuffer)); set_task(1.0, "socketAnswer", TASK_SOCKET, .flags="b"); } public socketAnswer() { if (socket_change(g_sckweb)) { new szData[1024]; socket_recv(g_sckweb, szData, charsmax(szData)); log_amx(szData); socket_close(g_sckweb); remove_task(TASK_SOCKET); } }
Powyższy kod po wywołaniu zapisuje do logów błąd 404, a plik istnieje na serwerze, ponieważ w przeglądarce normalnie się otwiera.
L 08/25/2014 - 12:13:48: [menu_spara.amxx] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>404 Not Found</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; background-color:#367E8E; scrollbar-base-color: #005B70; scrollbar-arrow-color: #F3960B; scrollbar-DarkShadow-Color: #000000; color: #FFFFFF; margin:0; } a { color:#021f25; text-decoration:none} h1 { font-size: 18px; color: #FB9802; padding-bottom: 10px; background-image: url(sys_cpanel/images/bottombody.jpg); background-repeat: repeat-x; padding:5px 0 10px 15px; margin:0; } #body-content p { padding-left: 25px; padding-right: 25px; line-height: 18px; padding-
Link do pliku: http://szelbi.gamecl..._menu_spara.php
szelbi
25.08.2014
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>404 Not Found</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; background-color:#367E8E; scrollbar-base-color: #005B70; scrollbar-arrow-color: #F3960B; scrollbar-DarkShadow-Color: #000000; color: #FFFFFF; margin:0; } a { color:#021f25; text-decoration:none} h1 { font-size: 18px; color: #FB9802; padding-bottom: 10px; background-image: url(sys_cpanel/images/bottombody.jpg); background-repeat: repeat-x; padding:5px 0 10px 15px; margin:0; } #body-content p { padding-left: 25px; padding-right: 25px; line-height: 18px; padding-top: 5px; padding-bottom: 5px; } h2 { font-size: 14px; font-weight: bold; color: #FF9900; padding-left: 15px; } </style> </head> <body> <div id="body-content"> <!-- start content--> <!-- instead of REQUEST_URI, we could show absolute URL via: http://HTTP_HOST/REQUEST_URI but what if its https:// or other protocol? SERVER_PORT_SECURE doesn't seem to be used SERVER_PORT logic would break if they use alternate ports --> <h1>404 Not Found</h1> <p>The server can not find the requested page:</p> <blockquote> (none)/wersja_menu_spara.php (port 80) </blockquote> <p> Please forward this error screen to s24.proserwer.pl's <a href="mailto:[email protected]?subject=Error message [404] 404 Not Found for (none)/wersja_menu_spara.php port 80 on Monday, 25-Aug-2014 14:27:43 CEST"> WebMaster</a>. </p> <hr /> <!-- end content --> </div> </body> </html>
Puchate
25.08.2014
<h1>404 Not Found</h1>
<p>The server can not find the requested page:</p>
<blockquote>
(none)/wersja_menu_spara.php (port 80)
</blockquote>
<p>
szelbi
25.08.2014
Super, nie znalazł, ale przecież jest link u góry i jak widać plik znajduje się na serwerze.
GwynBleidD
26.08.2014
Błędne nagłówki. Po 1 brakuje chyba spacji po "Host:", po drugie powinieneś mieć wszędzie takie same znaki końca linii.
szelbi
27.08.2014
O jakich znakach końca linii mowa? Bo nie bardzo rozumiem. Co do spacji po "Host:" to dodałem, ale nic nie zmieniła.
Best Answer
speedkill
27.08.2014
https://forums.allie...ad.php?t=151401
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <sockets> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "speedkill" #define g_SiteName "/wersja_menu_spara.php" #define g_HostName "szelbi.gameclan.pl" new g_Socket; public plugin_init(){ register_plugin(PLUGIN, VERSION, AUTHOR); new g_SendBuffer[512], g_ErrorMessage; g_Socket = socket_open(g_HostName, 80, SOCKET_TCP, g_ErrorMessage); switch(g_ErrorMessage){ } formatex(g_SendBuffer, charsmax(g_SendBuffer), "GET %s HTTP/1.1^nHost:%s^r^n^r^n", g_SiteName, g_HostName); socket_send(g_Socket, g_SendBuffer, charsmax(g_SendBuffer)); set_task(1.0, "SocketAnswer",.flags = "b"); } public SocketAnswer(){ if(socket_change(g_Socket)){ new g_Data[1024]; socket_recv(g_Socket, g_Data, charsmax(g_Data)); log_amx(g_Data); socket_close(g_Socket); if(task_exists()){ remove_task(); } } }
L 08/27/2014 - 22:10:01: [Test123.amxx] HTTP/1.1 200 OK Date: Wed, 27 Aug 2014 20:09:58 GMT Server: Apache X-Powered-By: PHP/5.4.4-14+deb7u14 Vary: Accept-Encoding Transfer-Encoding: chunked Content-Type: text/html 5 1.0.5 0
szelbi
28.08.2014
Czyli z tego co widzę brakowało tam tylko "HTTP/1.1" Zmieniłem sobie rozszerzenie pliku na .txt, aby pozbyć się tych znaków przed numerem wersji i teraz pojawia się pytanie. Jak z poniższego kodu pobrać tylko numer wersji wpisany przeze mnie?
HTTP/1.1 200 OK Date: Thu, 28 Aug 2014 07:45:44 GMT Server: Apache Last-Modified: Thu, 28 Aug 2014 07:44:39 GMT ETag: "34b8b4-5-501abb57607c0" Accept-Ranges: bytes Content-Length: 5 Vary: Accept-Encoding Content-Type: text/plain 1.0.5