cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Automate Cpanel login using php CURL

From: Richard B <rborg_at_operamail.com>
Date: Mon, 01 Aug 2005 15:53:25 +0100

The whole point is to offer my clients direct access to the web editor within cpanel to edit a specific html page on their domain without giving them the actual cpanel username and pass by creating a custom log in page through which clients log on using a user name and password provided by me and then in turn the script would automatically log them on to the target url this time naturally using the cpanel user pass combination

Testing and outcome so far (attempt 1 using CURL):

If the script (below) is used on the following link I only get as far as the page's text because a login dialog still pops up twice (one for the stylesheet and one for the image if I figured out correctly)
"http://www.manicmalta.com:2082/frontend/x/files/select.html?dir=/home/manicmal/www&file=20050117ira_losco.htm"

Also if you click on a link within the page a login dialog still pops up.

On the other hand if I access the page directly via browser and provide cpanel user and pass the page loads fine and links work well. No further log ins required.

Then I also went one step further and attempted access to the editor directly by using this link "http://www.manicmalta.com:2082/frontend/x/files/htmledit.html?dir=/home/manicmal/www&file=20050117ira_losco.htm"

In this case the page loads and works fine BUT when I try to save the changes I always get a 'page not found' error page.

On the other hand if I access the page directly via browser and provide cpanel user and pass the page works fine and also saves well.

Is there something I am missing or is there something better suited for this than curl perhaps?? Any replies / ideas would be greatly appreciated. Hope that this is useful for other admins too.

The code:

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_URL, "http://www.manicmalta.com:2082/frontend/x/files/select.html?dir=/home/manicmal/www&file=BOV_Opera_Festival_Malta.htm");
curl_setopt($ch, CURLOPT_USERPWD,$dom_u.":".$dom_p);
curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
$data = curl_exec($ch);
curl_close($ch);

-- 
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 8 at http://www.opera.com
Powered by Outblaze
Received on 2005-08-01