1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Need help with C++ and WWW POST Method

Discussion in 'C++' started by dnn_gb, Feb 21, 2007.

  1. dnn_gb

    dnn_gb New Member

    Hi all,

    I need urgent help! I write windows service wich communicates with a web server with php.
    I'm using class W3Client ( http://www.codeproject.com/internet/w3client.asp ) for web requests. I have a directory content stored in C++ vector and need to post it to webpage.

    Here is stored file or dir information information:
    class DirectoryElement
                 string Name;
                 string fullPath;
                 int Type;
                 long Size;
                 void setName( string name );
                 string getName();
                 void setFullPath( string name );
                 string getFullPath();
                 void setType( int type );
                 int getType();
                 void setSize( long size );
                 long getSize();
    This is storage for all files and folders in one dir:
    vector<DirectoryElement> Elements;

    And I try to send them with this function:
    void Commandexec::sendDir()
         W3Client w3;
         cout<<"Using server: "<<cmdIng.getCommandingServer()<<" for sending dirs"<<endl;
         if( w3.Connect( cmdIng.getCommandingServer().c_str() ) ){
             w3.AddPostArgument("start_session", 1);
             w3.AddPostArgument("currpath", dirList.GetCurrentPath().c_str());
             if(w3.Request("/commanding/dirs.php", W3Client::reqPost)){
                   for( int j = 0; j<dirList.Elements.size(); j++ ){
                       w3.AddPostArgument("start_session", 0);
                       w3.AddPostArgument("FileNo", j);
                       w3.AddPostArgument("File", dirList.Elements[j].getName().c_str());
                       w3.AddPostArgument("FullPath", dirList.Elements[j].getFullPath().c_str());
                       w3.AddPostArgument("Type", dirList.Elements[j].getType());
                       w3.AddPostArgument("Size", dirList.Elements[j].getSize());
                       if(w3.Request("/commanding/dirs.php", W3Client::reqPost)){
    And this function do not work.... :mad:

    This is php code:
    	$ip = $REMOTE_ADDR;
    	$conn = mysql_connect($host, $user, $pass);
    	if(!$conn) die(0);
    	$dbselect = mysql_select_db($database, $conn);
    	if(!$dbselect) die(0);
    	$dbret = mysql_query("SELECT * FROM command WHERE id=0", $conn);
    	$dbdata = mysql_fetch_array($dbret);
    	if($dbdata[3] == $ip){
    		if($_POST["start_session"] == 1 ){
    			mysql_query("DELETE FROM dirlist", $conn);
    			$query = sprintf("INSERT INTO dirlist(id, Name, FullPath, Type, Size) VALUES(0, '%s', 'currpath', 0, 0)", $_POST["currpath"]);
    			mysql_query($query, $conn);
    			$query = sprintf("INSERT INTO dirlist(id, Name, FullPath, Type, Size) VALUES(%d, '%s', '%s', %d, %d)", $_POST["FileNo"], $_POST["File"], $_POST["FullPath"], $_POST["Type"], $_POST["Size"]);
    			mysql_query($query, $conn);
    All code is dirty, stupid and ... but I have no time! Please help me! I'm hurry!

Share This Page