Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-31-2008, 08:07 PM POST vars via script
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Okay, so im developing my hosting site more and more and now i want to have a login form which a user can select via a select form if they want to login to cpanel/whm/whmcs (my client system)

well with whmcs the username var is username where as cpanel is user

and obviously the action is differant,

so i want it so it takes the variables and depending on the select, it sends it to which ever action and redirects to it.

does this make sense?

basically i need to know how to (presumably using cURL) to post vars, i can handle the select stuff just this bit i need :S

Thanks,

TP for helpful answers!
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
 
Register now for full access!
Old 05-31-2008, 08:41 PM Re: POST vars via script
PeachyJuice's Avatar
Super Talker

Posts: 116
Name: Michele T.
Location: Ny, Ny
Trades: 1
You need a switch statement. Say, for example your select menu is called 'place' then, in order for you to do what you'd like, you'd need something a switch statement. Here's what you'd do:
PHP Code:
<?php 
$place
=$_POST['place'];
switch(
$place){
case 
'cpanel':
//do the cpanel things here
break;

case 
'whm':
//do the whm stuff here
break;

case 
'whmcs':
//do that stuff here
break;
}
?>
That's it xD
PeachyJuice is offline
Reply With Quote
View Public Profile
 
Old 06-01-2008, 07:16 AM Re: POST vars via script
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Im not sure if i explained it badly, but you just answered the exact thing i said i knew... :|

I need to know how to use cURL to post vars.
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 06-01-2008, 07:37 AM Re: POST vars via script
Extreme Talker

Posts: 189
Trades: 0
I google cURL post vars

and the top one might help you.

Heres the link http://www.askapache.com/htaccess/se...-php-curl.html
simster is offline
Reply With Quote
View Public Profile
 
Old 06-01-2008, 05:37 PM Re: POST vars via script
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Okay thanks Simster that helped.. But.

from that code i knocked up this:
PHP Code:
<?php
switch($_POST['type'])
{
case 
'cpanel':
$action 'http://xdnet.co.uk:2082/login/';
$post_vars 'user='.$_POST['user'].'&pass='.$_POST['pass'].'&login='.$_POST['submit'];  // POST VARIABLES TO BE SENT
break;
case 
'whm':
$action 'http://xdnet.co.uk:2086/login/';
$post_vars 'user='.$_POST['user'].'&pass='.$_POST['pass'].'&login='.$_POST['submit'];  // POST VARIABLES TO BE SENT
break;
case 
'whmcs':
$action 'http://xdnet.co.uk/clients/dologin.php?goto=clientarea';
$post_vars 'username='.$_POST['user'].'&password='.$_POST['pass'].'&submit='.$_POST['submit'];  // POST VARIABLES TO BE SENT
break; 
}
 
 
// INITIALIZE ALL VARS
 
$ch='';
 
$Rec_Data='';
 
$Temp_Output='';
 
# if($_SERVER['REQUEST_METHOD']==='POST') {  // REQUIRE POST OR DIE
 
$ch curl_init($action);
 
curl_setopt($chCURLOPT_POST,1);
 
curl_setopt($chCURLOPT_POSTFIELDS,$post_vars);
 
curl_setopt($chCURLOPT_FOLLOWLOCATION,1); 
 
curl_setopt($chCURLOPT_HEADER,0);  // DO NOT RETURN HTTP HEADERS 
 
curl_setopt($chCURLOPT_RETURNTRANSFER,1);  // RETURN THE CONTENTS OF THE CALL
 
$Rec_Data curl_exec($ch);
 
ob_start();
 
header("Content-Type: text/html");
 
$Temp_Output ltrim(rtrim(trim(strip_tags(trim(preg_replace "/\s\s+/" " " html_entity_decode($Rec_Data)))),"\n\t\r\h\v\0 ")), "%20");
 
$Temp_Output ereg_replace (' +'' 'trim($Temp_Output));
 
$Temp_Output ereg_replace("[\r\t\n]","",$Temp_Output);
 
$Temp_Output substr($Temp_Output,307,200);
 echo 
$Temp_Output;
 
$Final_Out=ob_get_clean();
 echo 
$Final_Out;  
 
curl_close($ch);
#} else die('Hacking attempt Logged!');
 
exit;
?>
but its giving me this error:
Code:
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/USER/public_html/login-changer.php on line 31

Warning: Cannot modify header information - headers already sent by (output started at /home/USER/public_html/login-changer.php:31) in /home/USER/public_html/login-changer.php on line 37
How can i over come this?
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 06-01-2008, 06:28 PM Re: POST vars via script
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
you can't.
At least,not without an action from your hoster:
Quote:
CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set
Your host has set the safe mode to on, and this restrict what you can do with PHP.

The second error is just a side effect of the first.
As the error is displayed on page, the server headers have been sent, thus you cannot do a header() call.
Put the ob_start() before CURL to avoid this.

Are you sure the CURLOPT_FOLLOWLOCATION is needed ?
It's just a flag that tells CURL to follow the redirect the server might send.

If the target page has no redirect [ header('location:somewhere'); ], then you should be ok even without it.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 06-02-2008, 11:59 AM Re: POST vars via script
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
well it would i think :s because once its sent the details it needs to then go to that action?

or am i wrong :s

I will see what happens without if not will see if can get host to do it :s cant wait to get my hands on a dedicated server without destroying my college fund (even though i wouldnt be allowed to... )

Dan
Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 06-02-2008, 12:53 PM Re: POST vars via script
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
okay my host has lifted the open_basedir restriction on my account.

BUT.

the script isnt working properly.

It doesnt seem to login and at most it shows the returned failed login page, and doesnt direct to it..

heres what im working with now:
PHP Code:
<?php
switch($_POST['type'])
{
case 
'cpanel':
$action 'http://xdnet.co.uk:2082/login/';
$post_vars 'user='.$_POST['user'].'&pass='.$_POST['pass'].'&login='.$_POST['submit'];  // POST VARIABLES TO BE SENT
break;
case 
'whm':
$action 'http://xdnet.co.uk:2086/login/';
$post_vars 'user='.$_POST['user'].'&pass='.$_POST['pass'].'&login='.$_POST['submit'];  // POST VARIABLES TO BE SENT
break;
case 
'whmcs':
$action 'http://xdnet.co.uk/clients/dologin.php?goto=clientarea';
$post_vars 'username='.$_POST['user'].'&password='.$_POST['pass'];  // POST VARIABLES TO BE SENT
break; 
}
 
 
// INITIALIZE ALL VARS
 
$ch='';
 
$Rec_Data='';
 
$Temp_Output='';
 
 if(
$_SERVER['REQUEST_METHOD']==='POST') {  // REQUIRE POST OR DIE
 
$ch curl_init();
 
curl_setopt($chCURLOPT_URL$action);
 
curl_setopt($chCURLOPT_POST,1);
 
curl_setopt($chCURLOPT_POSTFIELDS,$post_vars);
 
curl_setopt($chCURLOPT_FOLLOWLOCATION,1); 
 
curl_setopt($chCURLOPT_UNRESTRICTED_AUTH1); //Continue sending user/paas even when differant domain.
 
curl_setopt($chCURLOPT_HEADER,0);  // DO NOT RETURN HTTP HEADERS 
 
curl_setopt($chCURLOPT_RETURNTRANSFER,0);  // RETURN THE CONTENTS OF THE CALL
 
$Rec_Data curl_exec($ch);
 
 
curl_close($ch);
} else die(
'Hacking attempt Logged!');
exit;
?>
help would be greatly apprieciated !
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 06-02-2008, 01:20 PM Re: POST vars via script
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
I don't see no reason why it would not work...
If you try to modify your function to have a var_dump of the result, what would it show:
PHP Code:
$Rec_Data curl_exec($ch);
var_dump($RecData);
die();
curl_close($ch); 
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 06-04-2008, 11:48 AM Re: POST vars via script
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Returns "NULL"

Not sure what that means :s in terms of how it works...

The only anser my host could offer was maybe the scripts required some kind of header to help protect against bruteforce etc...

Does anyone know
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 06-05-2008, 05:32 AM Re: POST vars via script
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Just an idea...
Try to give the url in the curl_init call:
PHP Code:
$ch curl_init($action); 
The php doc says:
Quote:
Description

resource curl_init ([ string $url ] )
Initializes a new session and return a cURL handle for use with the curl_setopt(), curl_exec(), and curl_close() functions.

Maybe this will help...
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 06-05-2008, 01:42 PM Re: POST vars via script
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
it was in it originally, i only added the url setopt to see if it worked the other way

Is there a way to "test" is the login scripts (which im trying tolog into) check for headers to stop curl logins?

How would i add like all the headers IE would do so it appears to come from a browser?

Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 06-09-2008, 12:34 PM Re: POST vars via script
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Okay im bumping this thread in hope someone else can shed some light?...

Please

Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to POST vars via script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.36797 seconds with 12 queries