HTTP Problem
#1

Hey,
I want to send variables to php.
So I tried to do this by HTTP and Rcon command.
Here is the filterscript:
Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <a_http>
main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}



public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Blank Script");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerSpawn(playerid)
{

	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/mycommand", cmdtext, true, 10) == 0)
	{
		// Do something here
		return 1;
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
    if(!strcmp(cmd,"test_num",true))
    {
		return HTTP(0, HTTP_POST, "localhost/testve.php", "TNum=4", "MyHttpResponse");
        /*SendClientMessageToAll(0xFFFFFFAA,"Hello World!");
        print("You said hello to the world.");// This will appear to the player who typed the rcon command in the chat in white
        return 1;*/
    }
    return 0;
}
forward MyHttpResponse(index, response_code, data[]);
public MyHttpResponse(index, response_code, data[])
{
    if(response_code == 200) //Did the request succeed?
    {
        //Yes!
        printf("The URL replied: %s", data);
        return 1;
    }
    else
    {
        //No!
        printf("The request failed! The response code was: %d", response_code);
        return 1;
    }
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}
And that is the PHP:
PHP код:
<?php
require_once 'SampRconAPI.php';
$rcon = new SampRconAPI('127.0.0.1'7777'123');
$rcon->Call('test_num');
if(
$_REQUEST['TNum'])
    echo 
'new TestNum = '$_REQUEST['TNum'];
else
    echo 
'failed.';
?>
When I'm refrashing the PHP page, the sa-mp log is:
Quote:

SA-MP Dedicated Server
----------------------
v0.3d-R2, ©2005-2011 SA-MP Team

[12:17:07]
[12:17:07] Server Plugins
[12:17:07] --------------
[12:17:07] Loaded 0 plugins.

[12:17:07]
[12:17:07] Filterscripts
[12:17:07] ---------------
[12:17:07] Loading filterscript 'testrcon.amx'...
[12:17:07] Loaded 1 filterscripts.

[12:17:07] Loaded 3 vehicles from: vehicles/trains.txt
[12:17:07] Loaded 3 vehicles from: vehicles/pilots.txt
[12:17:07] Loaded 15 vehicles from: vehicles/lv_law.txt
[12:17:07] Loaded 39 vehicles from: vehicles/lv_airport.txt
[12:17:07] Loaded 255 vehicles from: vehicles/lv_gen.txt
[12:17:07] Loaded 38 vehicles from: vehicles/sf_law.txt
[12:17:07] Loaded 35 vehicles from: vehicles/sf_airport.txt
[12:17:07] Loaded 353 vehicles from: vehicles/sf_gen.txt
[12:17:07] Loaded 24 vehicles from: vehicles/ls_law.txt
[12:17:07] Loaded 37 vehicles from: vehicles/ls_airport.txt
[12:17:07] Loaded 98 vehicles from: vehicles/ls_gen_inner.txt
[12:17:07] Loaded 389 vehicles from: vehicles/ls_gen_outer.txt
[12:17:07] Loaded 71 vehicles from: vehicles/whetstone.txt
[12:17:07] Loaded 168 vehicles from: vehicles/bone.txt
[12:17:07] Loaded 61 vehicles from: vehicles/flint.txt
[12:17:07] Loaded 96 vehicles from: vehicles/tierra.txt
[12:17:07] Loaded 96 vehicles from: vehicles/red_county.txt
[12:17:07] Total vehicles from files: 1781
[12:17:07]
---------------------------------------
[12:17:07] Running Grand Larceny - by the SA-MP team

[12:17:07] ---------------------------------------

[12:17:07] Number of vehicle models: 173
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:16] The URL replied: 4
[12:17:16] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The URL replied: 4
[12:17:18] The URL replied: 4
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The URL replied: 4
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:18] The URL replied: 4
[12:17:18] The URL replied: 4
[12:17:18] The URL replied: 4
[12:17:18] The URL replied: 4
[12:17:18] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The request failed! The response code was: 6
[12:17:20] The URL replied: 4
[12:17:20] The URL replied: 4
[12:17:22] The URL replied: 4
[12:17:22] The URL replied: 4
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The URL replied: 4
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:22] The request failed! The response code was: 6
[12:17:22] The URL replied: 4
[12:17:23] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:24] The URL replied: 4
[12:17:24] The URL replied: 4
[12:17:24] The request failed! The response code was: 6
[12:17:25] The URL replied: 4
[12:17:26] The URL replied: 4
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The URL replied: 4
[12:17:26] The URL replied: 4
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:26] The URL replied: 4
[12:17:26] The request failed! The response code was: 6
[12:17:27] The URL replied: 4
[12:17:28] The URL replied: 4
[12:17:28] The URL replied: 4
[12:17:28] The request failed! The response code was: 6
[12:17:28] The URL replied: 4
[12:17:28] The request failed! The response code was: 6
[12:17:28] The URL replied: 4

And the Php page:


How can I solve that problem? Thanks.
Reply
#2

bump
Reply
#3

It looks as you make a loop, you call it once with page refresh and it keeps sending requests
put $rcon->Call('test_num'); under if(!$_REQUEST['TNum'])
Reply
#4

Quote:
Originally Posted by ikey07
Посмотреть сообщение
It looks as you make a loop, you call it once with page refresh and it keeps sending requests
put $rcon->Call('test_num'); under if(!$_REQUEST['TNum'])
OK, now the command called only one time without problems.
but the PHP page still doesn't show the $_REQUEST['TNum'].
Here is the page:
PHP код:
<?php
require_once 'SampRconAPI.php';
$rcon = new SampRconAPI('127.0.0.1'7777'123');
if(!isset(
$_REQUEST['TNum']))$rcon->Call('test_num');
if(isset(
$_REQUEST['TNum']))
    echo 
'new TNum = '$_REQUEST['TNum'];
else
    echo 
'failed.';
?>
The site prints 'failed' only, and not 'new TNum = 4' like it should -_-
The rcon command:
PHP код:
public OnRconCommand(cmd[])
{
    if(!
strcmp(cmd,"test_num",true))
    {
        return 
HTTP(0HTTP_POST"localhost/testve.php""TNum=4""MyHttpResponse");
        
/*SendClientMessageToAll(0xFFFFFFAA,"Hello World!");
        print("You said hello to the world.");// This will appear to the player who typed the rcon command in the chat in white
        return 1;*/
    
}
    return 
0;
}
forward MyHttpResponse(indexresponse_codedata[]);
public 
MyHttpResponse(indexresponse_codedata[])
{
    if(
response_code == 200//Did the request succeed?
    
{
        
//Yes!
        
printf("The URL replied: %s"data);
        return 
1;
    }
    else
    {
        
//No!
        
printf("The request failed! The response code was: %d"response_code);
        return 
1;
    }

In the log the command prints:
Quote:

The URL replied: new TNum = 4

So what's the problem in the PHP page, why it isn't printing 'new TNum = 4' ?
Thanks!
Reply
#5

I think the SA-MP server has not sent the request yet.

Can you show SampRconAPI.php ?
Reply
#6

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
I think the SA-MP server has not sent the request yet.

Can you show SampRconAPI.php ?
PHP код:
<?php
/**
 *    This API also connects directly to the server, but instead of using the
 *    query system, depends on the RCON system. 
 *    
 *    This system, unlike the query system (in my opinion) is not able to
 *    handle as many calls, so please use this wisely.
 *
 *    @package sampAPI
 *    @version 1.2
 *    @author David Weston <westie@typefish.co.uk>
 *    @copyright 2010; http://www.typefish.co.uk/licences/nl679...8.56774343
 */
class SampRconAPI
{
    
/**
     *    @ignore
     */
    
private $rSocket false;
    
    
    
/**
     *    @ignore
     */
    
private $aServer = array();
    
    
    
/**
     *    Creation of the RCON class.
     *
     */
    
public function __construct($sServer$iPort$sPassword)
    {
        
/* Fill some arrays. */
        
$this->aServer[0] = $sServer;
        
$this->aServer[1] = $iPort;
        
$this->aServer[2] = $sPassword;
        
        
/* Start the connection. */    
        
$this->rSocket fsockopen('udp://'.$this->aServer[0], $this->aServer[1], $iError$sError2);
        
        if(!
$this->rSocket)
        {
            
$this->aServer[4] = false;
            return;
        }
        
        
socket_set_timeout($this->rSocket2);
        
        
$sPacket 'SAMP';
        
$sPacket .= chr(strtok($this->aServer[0], '.'));
        
$sPacket .= chr(strtok('.'));
        
$sPacket .= chr(strtok('.'));
        
$sPacket .= chr(strtok('.'));
        
$sPacket .= chr($this->aServer[1] & 0xFF);
        
$sPacket .= chr($this->aServer[1] >> 0xFF);
        
$sPacket .= 'p4150';
        
        
fwrite($this->rSocket$sPacket);
        
        if(
fread($this->rSocket10))
        {
            if(
fread($this->rSocket5) == 'p4150')
            {
                
$this->aServer[4] = true;
                return;
            }
        }
        
        
$this->aServer[4] = false;
    }
    
    
    
/**
     *    @ignore
     */
    
public function __destruct()
    {
        @
fclose($this->rSocket);
    }
    
    
    
/**
     *    Used to tell if the server is ready to accept queries.
     *
     *    If false is returned, then it is suggested that you remove the
     *    class from active use, so that you can reload the class if needs
     *    be.
     *
     *    @return bool true if success, false if failure.
     */
    
public function isOnline()
    {
        return 
$this->aServer[4];
    }
    
    
    
/**
     *    Retrieves the command list.
     *
     *    @return array Array of available RCON commands.
     */
    
public function getCommandList()
    {
        
$aCommands $this->packetSend('cmdlist');
        unset(
$aCommands[0]);
        
        foreach(
$aCommands as &$sCommand)
        {
            
$sCommand trim($sCommand);
        }
        
        return 
$aCommands;
    }
    
    
    
/**
     *    Retrieves and parses the server variables.
     *
     *    @return array Array of current server variables.
     */
    
public function getServerVariables()
    {
        
$aVariables $this->packetSend('varlist');
        unset(
$aVariables[0]);
        
$aReturn = array();
        
        foreach(
$aVariables as $sString)
        {
            
preg_match('/(.*)=[\s]+(.*)/'$sString$aMatches);
            
            if(
$aMatches[2][0] == '"')
            {
                
preg_match('/\"(.*)\"[\s]+\(/'$aMatches[2], $aTemp);
                
$aReturn[trim($aMatches[1])] = $aTemp[1];
            }
            else
            {
                
preg_match('/(.*?)\s+\(/'$aMatches[2], $aTemp);
                
$aReturn[trim($aMatches[1])] = $aTemp[1];
            }
        }
        
        return 
$aReturn;
    }
    
    
    
/**
     *    Sets the server's weather to the one specified.
     *
     *    @param integer $iWeatherID Weather ID
     */
    
public function setWeather($iWeatherID)
    {
        
$this->packetSend('weather '.$iWeatherIDfalse);
    }
    
    
    
/**
     *    Sets the server's gravity to the one specified.
     *
     *    @param float $fGravity Gravity amount (0.008 is default)
     */
    
public function setGravity($fGravity)
    {
        
$this->packetSend('gravity '.$fGravityfalse);
    }
    
    
    
/**
     *    Bans a player ID from the server.
     *
     *    @param integer $iPlayerID Player ID
     *    @return array Output from ban.
     */
    
public function playerBan($iPlayerID)
    {
        return 
$this->packetSend('ban '.$iPlayerID);
    }
    
    
    
/**
     *    Kicks a player ID from the server.
     *
     *    @param integer $iPlayerID Player ID
     *    @return array Output from kick.
     */
    
public function playerKick($iPlayerID)
    {
        return 
$this->packetSend('kick '.$iPlayerID);
    }
    
    
    
/**
     *    Bans an IP address from the server.
     *
     *    @param string $sIPAddress IP Address
     *    @return array Output from ban.
     */
    
public function addressBan($sIPAddress)
    {
        return 
$this->packetSend('banip '.$sIPAddress);
    }
    
    
    
/**
     *    Unbans an IP address from the server.
     *
     *    @param string $sIPAddress IP Address
     */
    
public function addressUnban($sIPAddress)
    {
        return 
$this->packetSend('unbanip '.$sIPAddress);
    }
    
    
    
/**
     *    Reloads the log on a server - useful when the log doesn't exist
     *    any more.
     */
    
public function reloadLogs()
    {
        return 
$this->packetSend('reloadlog');
    }
    
    
    
/**
     *    Reloads the ban file on a server.
     *
     */
    
public function reloadBans()
    {
        return 
$this->packetSend('reloadbans');
    }
    
    
    
/**
     *    Send a message as an admin to the players of the server.
     *
     *    @param string $sMessage Message
     */
    
public function adminSay($sMessage)
    {
        
$this->packetSend('say '.$sMessagefalse);
    }
    
    
    
/**
     *    Change the gamemode in the server.
     *
     *    @param string $sGamemode Gamemode
     */
    
public function gameChangeMode($sGamemode)
    {
        
$this->packetSend('changemode '.$sGamemodefalse);
    }
    
    
    
/**
     *    Sends a call to GMX.
     */
    
public function gameNextMode()
    {
        
$this->packetSend('gmx'false);
    }
    
    
    
/**
     *    Executes a file that contains server configuration.
     *
     *    @param string $sConfig Server config name/location.
     */
    
public function gameExec($sConfig)
    {
        return 
$this->packetSend('exec '.$sConfig);
    }
    
    
    
/**
     *    Loads a filterscript.
     *
     *    @param string $sFilterscript Filterscript name/location.
     */
    
public function gameLoadFilterscript($sFilterscript)
    {
        return 
$this->packetSend('loadfs '.$sFilterscript);
    }
    
    
    
/**
     *    Unloads a filterscript.
     *
     *    @param string $sFilterscript Filterscript name/location.
     */
    
public function gameUnloadFilterscript($sFilterscript)
    {
        return 
$this->packetSend('unloadfs '.$sFilterscript);
    }
    
    
    
/**
     *    Reloads a filterscript.
     *
     *    @param string $sFilterscript Filterscript name/location.
     */
    
public function gameReloadFilterscript($sFilterscript)
    {
        return 
$this->packetSend('reloadfs '.$sFilterscript);
    }
    
    
    
/**
     *    Shuts down the server, without any verification.
     */
    
public function gameExit()
    {
        
$this->packetSend('exit'false);
    }
    
    
    
/**
     *    Send an RCON command.
     *
     *    @param string $sCommand Command to send to the server.
     *    @param float $fDelay Seconds to capture data, or false to retrieve no data.
     *    @return array Array of output, in order of receipt.
     */
    
public function Call($sCommand$fDelay 1.0)
    {
        return 
$this->packetSend($sCommand$fDelay);
    }
    
    
    
/**
     *    Send an RCON command.
     *
     *    @ignore
     *    @see SampRconApi::Call()
     */
    
public function packetSend($sCommand$fDelay 1.0)
    {
        
fwrite($this->rSocket$this->packetCreate($sCommand));
        
        if(
$fDelay === false)
        {
            return;
        }
        
        
$aReturn = array();
        
$iMicrotime microtime(true) + $fDelay;
        
        while(
microtime(true) < $iMicrotime)
        {
            
$sTemp substr(fread($this->rSocket128), 13);
            
            if(
strlen($sTemp))
            {
                
$aReturn[] = $sTemp;
            }
            else
            {
                break;
            }
        }
        
        return 
$aReturn;
    }
    
    
    
/**
     *    @ignore
     */
    
private function packetCreate($sCommand)
    {
        
$sPacket 'SAMP';
        
$sPacket .= chr(strtok($this->aServer[0], '.'));
        
$sPacket .= chr(strtok('.'));
        
$sPacket .= chr(strtok('.'));
        
$sPacket .= chr(strtok('.'));
        
$sPacket .= chr($this->aServer[1] & 0xFF);
        
$sPacket .= chr($this->aServer[1] >> 0xFF);
        
$sPacket .= 'x';
        
        
$sPacket .= chr(strlen($this->aServer[2]) & 0xFF);
        
$sPacket .= chr(strlen($this->aServer[2]) >> 0xFF);
        
$sPacket .= $this->aServer[2];
        
$sPacket .= chr(strlen($sCommand) & 0xFF);
        
$sPacket .= chr(strlen($sCommand) >> 0xFF);
        
$sPacket .= $sCommand;
        
        return 
$sPacket;
    }
}
The rcon command sent from the php page to the sa-mp server becasue the sa-mp server log says:
Quote:

[19:13:05] The URL replied: new TNum = 4

Reply
#7

bump
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
Where did you view that error message? It looks like you got it in a browser, in which case you won't be able to see what the SA:MP server sent as it is a different client.
I got that error message in my browser (FireFox).
The php page is sending the rcon command because the sa-mp server log prints what it should.
but the PHP page didn't get the TNum value - $_REQUEST['TNum'] is not exists. :S
How can I fix that problem?
Reply
#9

Quote:
Originally Posted by ******
Посмотреть сообщение
Did you actually correctly POST the data, rather than GET it?
Here is the PHP page, I don't really know if I did it correctly :S
PHP код:
<?php
require_once 'SampRconAPI.php';
$rcon = new SampRconAPI('127.0.0.1'7777'123');
if(!isset(
$_REQUEST['TNum']))$rcon->Call('test_num');
if(isset(
$_REQUEST['TNum']))
    echo 
'new TNum = '$_REQUEST['TNum'];
else
    echo 
'failed.';
?>
Reply
#10

Quote:
Originally Posted by ******
Посмотреть сообщение
Yes, I saw that, that wasn't my question.
So I didn't understand your question :S
Can you ask it in simpler English?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)