Üdv Mindenkinek :-)
Nos mivel lezárult a kör így kiraknám a középdöntős feladatomat amit kreáltam :-)
Aki úgy gondolja használja nyugodtan , kicsit változtatnék a helyébe ha éles szerverre kellene felrakjam mert bárki megtalálhatja és megfelelő authentikáció nélkül elég rossz vége lesz...
Itt a Script :-)
#include <a_samp>
#include <socket>
#define Address \"127.0.0.1\"
#define Ports 80
new Socket:Socket;
public OnFilterScriptInit()
{
Socket = socket_create(TCP);
socket_set_max_connections(Socket, 10);
socket_bind(Socket, Address);
socket_listen(Socket, Ports);
printf(\"The Server Start!\");
return 1;
}
//Website Name[0] - WebSite Answer[1]
new WebSiteList[33][2][] = {
{\"/index.html\",\"\"},
{\"/index2.html\",\"\"},
{\"/servershutdown.html\",\"The server shutdown\"},
{\"/mapname.html\",\"You change mapname\"},
{\"/weather.html\",\"You change weather\"},
{\"/kick.html\",\"You kick the player\"},
{\"/ban.html\",\"You ban the player\"},
{\"/changemode.html\",\"You change gamemode\"},
{\"/gmx.html\",\"You restart to server\"},
{\"/reloadbans.html\",\"You reload Ban List\"},
{\"/reloadlog.html\",\"You reload Server Log\"},
{\"/say.html\",\"You have written to the server\"},
{\"/banip.html\",\"You Banned This IP\"},
{\"/unbanip.html\",\"You Unbanned This IP\"},
{\"/gravity.html\",\"You Change Gravity\"},
{\"/loadfs.html\",\"You Load this FilterScript\"},
{\"/weburl.html\",\"You change WebURL\"},
{\"/unloadfs.html\",\"You Unload this FilterScript\"},
{\"/reloadfs.html\",\"You Reload this FilterScript\"},
{\"/rcon_password.html\",\"You Change Rcon Password\"},
{\"/password.html\",\"You Change Server Password\"},
{\"/messageslimit.html\",\"You Change Messages Limit\"},
{\"/ackslimit.html\",\"You Change Acks Limit\"},
{\"/messageholelimit.html\",\"You Change Message Hole Limit\"},
{\"/playertimeout.html\",\"You Change Player Timeout\"},
{\"/language.html\",\"You Change Server Langueage\"},
{\"/query.html\",\"You Change Query Settings\"},
{\"/announce.html\",\"You Change Announce Settings\"},
{\"/playerlist.html\",\"\"}, //Custom Text
{\"/serverinfo.html\",\"\"}, //Custom Text
{\"/playerlist_online.html\",\"\"}, //Custom Text
{\"/current.html\",\"\"}, //Custom
{\"/worldtime.html\",\"You are Change WorldTime\"}
};
//This is need varlist search...
new messages[32];
new messagesint;
new messagebool;
new messagebooltostring[32];
new finishmessages[32];
//Varname[0] - Type : 1- String 2 -Int 3- Bool 4 Not Working :/ 5 Custom
new varlist[62][2][] = {
{\"Online Players Number\",\"5\"},
{\"ackslimit\",\"2\"},
{\"announce\",\"3\"},
{\"bind\",\"1\"},
{\"chatlogging\",\"2\"},
{\"conncookies\",\"2\"},
{\"connseedtime\",\"2\"},
{\"cookielogging\",\"2\"},
{\"db_log_queries\",\"2\"},
{\"db_logging\",\"2\"},
{\"filterscripts\",\"1\"},
{\"gamemode0\",\"1\"},
{\"gamemode1\",\"1\"},
{\"gamemode10\",\"1\"},
{\"gamemode11\",\"1\"},
{\"gamemode12\",\"1\"},
{\"gamemode13\",\"1\"},
{\"gamemode14\",\"1\"},
{\"gamemode15\",\"1\"},
{\"gamemode2\",\"1\"},
{\"gamemode3\",\"1\"},
{\"gamemode4\",\"1\"},
{\"gamemode5\",\"1\"},
{\"gamemode6\",\"1\"},
{\"gamemode7\",\"1\"},
{\"gamemode8\",\"1\"},
{\"gamemode9\",\"1\"},
{\"gamemodetext\",\"1\"},
{\"gravity\",\"1\"},
{\"hostname\",\"1\"},
{\"incar_rate\",\"2\"},
{\"lagcomp\",\"1\"},
{\"lagcompmode\",\"2\"},
{\"language\",\"1\"},
{\"lanmode\",\"3\"},
{\"logqueries\",\"3\"},
{\"logtimeformat\",\"1\"},
{\"mapname\",\"1\"},
{\"maxnpc\",\"2\"},
{\"maxplayers\",\"2\"},
{\"messageholelimit\",\"2\"},
{\"messagelimit\",\"2\"},
{\"mnconnectiontime\",\"2\"},
{\"myriad\",\"3\"},
{\"nosign\",\"3\"},
{\"onfoot_rate\",\"2\"},
{\"password\",\"1\"},
{\"playertimeout\",\"2\"},
{\"plugins\",\"1\"},
{\"port\",\"2\"},
{\"query\",\"3\"},
{\"rcon\",\"3\"},
{\"rcon_password\",\"1\"},
{\"sleep\",\"2\"},
{\"stream_distance\",\"4\"},
{\"stream_rate\",\"2\"},
{\"timestamp\",\"3\"},
{\"version\",\"1\"},
{\"weapon_rate\",\"2\"},
{\"weather\",\"1\"},
{\"weburl\",\"1\"},
{\"worldtime\",\"1\"}
};
public onSocketReceiveData(Socket:id, remote_clientid, data[], data_len)
{
new oldbuf[3000],File:handle,founds = -1,s= strfind(data,\"HTTP\");
strdel(data,s-1,strlen(data));
strdel(data,0,4);
format(oldbuf,sizeof(oldbuf),\" \");
for(new i=0;i<sizeof(WebSiteList);i++)
{
if(match(data,WebSiteList[0]))
{
founds = 1;
break;
}
}
if(match(data,\"/\") || founds == 1) //Website Opener
{
new websitename[64];
if(match(data,\"/\") || match(data,\"/index.html\"))
{
handle = fopen(\"public_html/index.html\",io_read);
}
else if(match(data,\"/playerlist.html\"))
{
//Desing and CSS and more
format(oldbuf,sizeof(oldbuf),\"<html><center>Online Players<br><br><style>table { text-align: center; border: 2px solid black;}td { border:black 2px solid;vertical-align:top}</style><table width=\"\" align=\"\"center\"\"><meta http-equiv=\"\"refresh\"\" content=\"\"4;url=playerlist.html\"\" /><tbody>\"); //Begin
//Basic Menu
format(oldbuf,sizeof(oldbuf),\"%s<tr><td>Player Name</td><td>Funkcions</td></tr>\",oldbuf);
//Founds
new playername[MAX_PLAYER_NAME];
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i,playername,MAX_PLAYER_NAME);
format(oldbuf,sizeof(oldbuf),\"%s<tr><td colspan=\"\"1\"\" style=\"\"border: 2px solid black; vertical-align: top;\"\">%s[iD %d]</td><td colspan=\"\"1\"\" style=\"\"border: 2px solid black; vertical-align: top;\"\"><a href=\"\"playerlist.html&kick_%s\"\">Kick</a> / <a href=\"\"playerlist.html&ban_%s\"\">Ban</a></td</tr>\",oldbuf,playername,i,playername,playername);
}
}
//Founds
format(oldbuf,sizeof(oldbuf),\"%s</tbody></table><br><br><a href=\"\"index.html\"\">Go Back</a></center></html>\",oldbuf); //End
socket_sendto_remote_client(Socket, remote_clientid, oldbuf);
socket_close_remote_client(Socket,remote_clientid);
}
else if(match(data,\"/current.html\"))
{
format(oldbuf,sizeof(oldbuf),\"<html> </html>\");
socket_sendto_remote_client(Socket, remote_clientid, oldbuf);
socket_close_remote_client(Socket,remote_clientid);
}
else if(match(data,\"/playerlist_online.html\"))
{
//Desing and CSS and more
format(oldbuf,sizeof(oldbuf),\"<html><center>Online Players<br><br><style>table { text-align: center; border: 2px solid black;}td { border:black 2px solid;vertical-align:top}</style><table width=\"\" align=\"\"center\"\"><meta http-equiv=\"\"refresh\"\" content=\"\"4;url=playerlist_online.html\"\" /><tbody>\"); //Begin
//Basic Menu
format(oldbuf,sizeof(oldbuf),\"%s<tr><td>Player Name</td><td>PlayerID</td></tr>\",oldbuf);
//Founds
new playername[MAX_PLAYER_NAME];
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i,playername,MAX_PLAYER_NAME);
format(oldbuf,sizeof(oldbuf),\"%s<tr><td colspan=\"\"1\"\" style=\"\"border: 2px solid black; vertical-align: top;\"\">%s</td><td colspan=\"\"1\"\" style=\"\"border: 2px solid black; vertical-align: top;\"\">%d</td</tr>\",oldbuf,playername,i,playername,playername);
}
}
//Founds
format(oldbuf,sizeof(oldbuf),\"%s</tbody></table></center></html>\",oldbuf); //End
socket_sendto_remote_client(Socket, remote_clientid, oldbuf);
socket_close_remote_client(Socket,remote_clientid);
}
else if(match(data,\"/serverinfo.html\"))
{
format(oldbuf,sizeof(oldbuf),\"<html><style>table {text-align: center; border: 2px solid black;} td {border:black 2px solid;vertical-align:top}</style><center>Current Server Settings!<br><br><table width=\"\" align=\"\"center\"\"><tbody>\");
format(finishmessages,sizeof(finishmessages),\" \");
for(new v=0;v<sizeof(varlist);v++)
{
finishmessages = \"\";
if(match(varlist[v][1],\"1\"))
{
GetConsoleVarAsString(varlist[v][0],messages,sizeof(messages));
if(strlen(messages) < 1)
{
messages = \"Empty String\";
}
format(finishmessages,sizeof(finishmessages),messages);
}
else if(match(varlist[v][1],\"2\"))
{
messagesint = GetConsoleVarAsInt(varlist[v][0]);
format(finishmessages,sizeof(finishmessages),\"%d\",messagesint);
}
else if(match(varlist[v][1],\"3\"))
{
messagebool = GetConsoleVarAsBool(varlist[v][0]);
if(messagebool)
{
format(messagebooltostring,sizeof(messagebooltostring),\"true\");
}
else
{
format(messagebooltostring,sizeof(messagebooltostring),\"false\");
}
format(finishmessages,sizeof(finishmessages),\"%s\",messagebooltostring);
}
else if(match(varlist[v][1],\"4\"))
{
format(finishmessages,sizeof(finishmessages),\"Undefined\");
//samp don\'t have GetConsolveVarAsFloat sry..
}
else if(match(varlist[v][1],\"5\"))
{
new idx = 0;
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
idx++;
}
}
format(finishmessages,sizeof(finishmessages),\"%d\",idx);
}
format(oldbuf,sizeof(oldbuf),\"%s<tr><td>%s</td><td>%s</td></tr>\",oldbuf,varlist[v][0],finishmessages);
}
format(oldbuf,sizeof(oldbuf),\"%s</tbody></table><br><br><a href=\"\"index.html\"\">Go Back</a></center></html>\",oldbuf);
socket_sendto_remote_client(Socket, remote_clientid, oldbuf);
socket_close_remote_client(Socket,remote_clientid);
}
else
{
format(websitename,sizeof(websitename),\"public_html%s\",data);
handle = fopen(websitename,io_read);
}
if(handle)
{
new buf[64];
while(fread(handle, buf))
{
format(oldbuf,sizeof(oldbuf),\"%s%s\",oldbuf,buf);
}
fclose(handle);
}
else
{
format(oldbuf,sizeof(oldbuf),\"<html><center><h1>Ooops</h1><br>%s website file not found, error code: 404</center></html>\",data);
}
}
else
{
strdel(data,0,1); //Unknow Space Delete
for(new i=0;i<sizeof(WebSiteList);i++)
{
if(match(data,WebSiteList[0]))
{
founds = 1;
break;
}
}
if(founds == 1)
{
new websitename[32];
format(websitename,sizeof(websitename),\"public_html%s\",data);
handle = fopen(websitename,io_read);
if(handle)
{
new buf[64];
while(fread(handle, buf))
{
format(oldbuf,sizeof(oldbuf),\"%s%s\",oldbuf,buf);
}
fclose(handle);
}
else
{
format(oldbuf,sizeof(oldbuf),\"<html><center><h1>Ooops</h1><br>%s website file not found, error code: 404</center></html>\",data);
}
}
else //Funkcions
{
new B = strfind(data,\"&\"),html = strfind(data,\".html\");
if(B != -1) //if nothing &
{
new ID = -1,funkcdata[64],lastdata[64],query[64],pdata[64];
format(pdata,64,data); //Target
format(lastdata,64,data); //This index.html
format(funkcdata,64,data); //This apple
new Target = strfind(pdata,\"_\");
if(Target != -1)
{
strdel(pdata,0,Target+1);
strdel(funkcdata,0,B+1);
new NewTarget = strfind(funkcdata,\"_\");
strdel(funkcdata,NewTarget,strlen(funkcdata));
}
else
{
strdel(funkcdata,0,B+1);
}
strdel(lastdata,B,strlen(lastdata));
new search[64];
format(search,64,\"%s\",lastdata);
strins(search,\"/\",0);
for(new i=0;i<sizeof(WebSiteList);i++)
{
if(match(search,WebSiteList[0]))
{
ID = i;
break;
}
}
strdel(lastdata,html,strlen(lastdata));
if(match(lastdata,\"current\"))
{
format(oldbuf,sizeof(oldbuf),\"<html><center><style>table {text-align: center; border: 2px solid black;}td {border:black 2px solid;vertical-align:top}</style>Current Settings <br><br><table width=\"\" align=\"\"center\"\"><tbody><tr><td>Settings</td><td>Value </td></tr>\");
for(new D=0;D<sizeof(varlist)++)
{
if(match(funkcdata,varlist[D][0]))
{
finishmessages = \"\";
if(match(varlist[D][1],\"1\"))
{
GetConsoleVarAsString(varlist[D][0],messages,sizeof(messages));
if(strlen(messages) < 1)
{
messages = \"Empty String\";
}
format(finishmessages,sizeof(finishmessages),messages);
}
else if(match(varlist[D][1],\"2\"))
{
messagesint = GetConsoleVarAsInt(varlist[D][0]);
format(finishmessages,sizeof(finishmessages),\"%d\",messagesint);
}
else if(match(varlist[D][1],\"3\"))
{
messagebool = GetConsoleVarAsBool(varlist[D][0]);
if(messagebool)
{
format(messagebooltostring,sizeof(messagebooltostring),\"true\");
}
else
{
format(messagebooltostring,sizeof(messagebooltostring),\"false\");
}
format(finishmessages,sizeof(finishmessages),\"%s\",messagebooltostring);
}
else if(match(varlist[D][1],\"4\"))
{
format(finishmessages,sizeof(finishmessages),\"Undefined\");
//samp don\'t have GetConsolveVarAsFloat sry..
}
else if(match(varlist[D][1],\"5\"))
{
new idx = 0;
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
idx++;
}
}
format(finishmessages,sizeof(finishmessages),\"%d\",idx);
}
format(oldbuf,sizeof(oldbuf),\"%s<tr><td>%s</td><td>%s</td></tr>\",oldbuf,funkcdata,finishmessages);
break;
}
}
format(oldbuf,sizeof(oldbuf),\"%s </tbody></table></center></html>\",oldbuf);
socket_sendto_remote_client(Socket, remote_clientid, oldbuf);
socket_close_remote_client(Socket,remote_clientid);
}
else if(match(lastdata,\"playerlist\"))
{
if(match(funkcdata,\"kick\"))
{
format(query,64,\"kick %s\",pdata);
}
else if(match(funkcdata,\"ban\"))
{
format(query,64,\"ban %s\",pdata);
}
}
else if(match(lastdata,\"worldtime\"))
{
format(query,64,\"worldtime %s\",funkcdata);
}
else if(match(lastdata,\"gmx\"))
{
format(query,64,\"gmx\");
}
else if(match(lastdata,\"servershutdown\"))
{
format(query,64,\"exit\");
}
else if(match(lastdata,\"reloadbans\"))
{
format(query,64,\"reloadbans\");
}
else if(match(lastdata,\"reloadlog\"))
{
format(query,64,\"reloadlog\");
}
else if(match(lastdata,\"query\"))
{
if(match(funkcdata,\"on\"))
{
format(query,64,\"query 1\");
}
else
{
format(query,64,\"query 0\");
}
}
else if(match(lastdata,\"announce\"))
{
if(match(funkcdata,\"on\"))
{
format(query,64,\"announce 1\");
}
else
{
format(query,64,\"announce 0\");
}
}
else
{
format(query,64,\"%s %s\",lastdata,funkcdata);
}
if(match(lastdata,\"playerlist\"))
{
if(match(funkcdata,\"kick\"))
{
format(oldbuf,sizeof(oldbuf),\"<html><meta http-equiv=\"\"refresh\"\" content=\"\"0;url=%s.html\"\" /><center><h1>SuccessFull<br> You are Kicked the Player!</center>\",lastdata);
}
else if(match(funkcdata,\"ban\"))
{
format(oldbuf,sizeof(oldbuf),\"<html><meta http-equiv=\"\"refresh\"\" content=\"\"0;url=%s.html\"\" /><center><h1>SuccessFull<br> You are Banned the Player!</center>\",lastdata);
}
}
else if(!match(lastdata,\"current\"))
{
format(oldbuf,sizeof(oldbuf),\"<html><meta http-equiv=\"\"refresh\"\" content=\"\"0;url=%s.html\"\" /><center><h1>SuccessFull<br> %s!</center>\",lastdata,WebSiteList[iD][1]);
}
SendRconCommand(query);
}
}
}
if(match(oldbuf,\" \"))
{
format(oldbuf,sizeof(oldbuf),\"<html><center><h1>Ooops</h1><br>%s website not defined my database sorry, error code: 404</center></html>\",data);
}
socket_sendto_remote_client(Socket, remote_clientid, oldbuf);
socket_close_remote_client(Socket,remote_clientid);
return 1;
}
public OnFilterScriptExit()
{
printf(\"The Server Stop!\");
socket_stop_listen(Socket);
socket_destroy(Socket);
return 1;
}
stock match(string1[], string2[])
{
return !strcmp(string1, string2, true);
}
a szükséges fájlok hozzá, a socket plugin.
EzÉs a scriptfiles mappába a public_html és ami benne van fájl mármint
ebbe a zipbe.
és menni fog elérni úgy tudjátok hogy elindítjátok a szervert meg az FS-t és a böngészőben a 127.0.0.1 es címen fog menni.
Üdv. Hiroshi