Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ PHP
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:
 
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 15-May-12 5:03am
amarasat1.3K
Comments
Code-o-mat at 15-May-12 12:15pm
   
In what environment? Windows?
amarasat at 15-May-12 12:55pm
   
Yes, i am implementing it in windows, sorry i haven't noticed your comment before.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
amarasat at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,252
1 OriginalGriff 5,498
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web04 | 2.8.140821.2 | Last Updated 15 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100