Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone:

I have 3 files, PHP1.php, PHP2.php and CPP1.cpp. Suppose php file PHP1.php is calling PHP2.php as shown below:

PHP
echo @gzuncompress(file_get_contents("http://$PC/Folder1/PHP2.php?&filename=$FILE&username=$user&cryptpass=$pass&noredir=1"));


This is working fine. Now the question is

1.) How do i call the same PHP2.php file using the same arguments filename, username and password from a C++ file CPP1.cpp? and also

2.) How to encrypt filename, username and password in C++ before calling PHP2.php
Posted
Comments
Code-o-mat 15-May-12 12:15pm    
In what environment? Windows?
amarasat 15-May-12 12:55pm    
Yes, i am implementing it in windows, sorry i haven't noticed your comment before.

I'd look at a couple of libraries to get you going:

- libcurl[^] - a rather excellent little library that can do (almost) anything HTTP for you. And a few other protocols. The library interface is alright for something written in C - it's easy enough to write a C++ wrapper for it

- OpenSSL[^] is - a great library for crypto - or rather the libcrypto bit is. If you build libcurl with it you even get HTTPS out of the box. Really clunky interface so don't use it directly unless you haven't got a lot of option. Again it's fairly easy to wrap in C++ once you've used it for a while

With these two you can grab whatever PHP2.php generates from the web server, and if you're getting back XML may I recommend a 3rd library?

- expat[^] - a lovely little event driven "almost-a-SAX" XML parser

Between that lot you should have enough tools to deal with just any web application that uses XML as it's transport. You can add others that do SOAP or JSON with a couple more libraries.

To encrypt the parameters... Depending on what the encryption is (it is even encryption? Is it just a salted one way hash?) you can do most things crypto with OpenSSL. If it is just a one way hash you want the API's very simple. If it's more complicated it might not be.

Anyway, hope that lot helps!

Happy hunting,

Ash
 
Share this answer
 
Comments
amarasat 15-May-12 12:46pm    
Hello Aescleal,

Thanks for such a great answer, i am looking into everything you specified and will let you know how it goes.
Additionally to the other solution, you could use WinINet[^] to access/execute the PHP script located on a HTTP server and for encrypting you could use Microsoft's Cryptography[^] API.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900