Jump to content

Having problem with a script. I'm not sure what it is...


ricerocket

Recommended Posts

Can someone take a quick look through here and tell me if you see anything?

 

The script is supposed to take ten form imputs which were turned into variables on a previous page which then made the reload to go.php which is this script. It takes the variables from the get, then creates the email account using n1=n1 and p1=p1 then if it's successful it reloads the page with n1=n2 and p1=p2 but I keep getting errors.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Add Cpanel Email Accounts</title>
</head>

<body>

<?php
$n1 = $_GET['n1'];
$p1 = $_GET['p1'];
$n2 = $_GET['n2'];
$p2 = $_GET['p2'];
$n3 = $_GET['n3'];
$p3 = $_GET['p3'];
$n4 = $_GET['n4'];
$p4 = $_GET['p4'];
$n5 = $_GET['n5'];
$p5 = $_GET['p5'];
$n6 = $_GET['n6'];
$p6 = $_GET['p6'];
$n7 = $_GET['n7'];
$p7 = $_GET['p7'];
$n8 = $_GET['n8'];
$p8 = $_GET['p8'];
$n9 = $_GET['n9'];
$p9 = $_GET['p9'];
$n10 = $_GET['n10'];
$p10 = $_GET['p10'];

$task = "
// required cpanel data
define( 'CPEMAIL_DOMAIN', 'example.com'); // Cpanel domain
define( 'CPEMAIL_SSL', 0); // 0 = no SSL, 1 = Uses SSL
define( 'CPEMAIL_PORT', 2082); // usually the port is 2082 withought SSL and 2083 with SSL
define( 'CPEMAIL_THEME', 'bluelagoon'); // x is the default theme, others include: bluelagoon, x2, xmail, xcontroller, monsoon
define( 'CPEMAIL_QUOTA', 10); // email quota in Megabytes

// sensitive cpanel info
define( 'CPEMAIL_USER', 'username'); // Cpanel Username
define( 'CPEMAIL_PASS', 'password'); // Cpanel Password

if (isset($_GET['send'])) {

$username = $_GET['username'];
$password = $_GET['password1'];

$url = 'http'.(CPEMAIL_SSL ? 's' : '').'://'.CPEMAIL_USER.':'.CPEMAIL_PASS.'@'.CPEMAIL_DOMAIN.':'.CPEMAIL_PORT.'/frontend/'.CPEMAIL_THEME.'/mail/doaddpop.html';
$url .= '?email='.$username.'&domain='.CPEMAIL_DOMAIN.'&password='.$password.'&quota='.CPEMAIL_QUOTA;

// make the http request to cpanel, this is where the email is created
// this is just like the browser making the request, only php does it for the user
$txt = http_request( $url );

// in a live situation, you would parse the returned html, and see if the email was successfully created.
// because this is dependent on the Cpanel theme, I didnt put it in. 
// A simple test example would be:
// if (strpos($txt, 'Successful') !== false) { echo 'Your account was created, please log in.'; } 
// the above checks for the occurance of Successful in the returned html, which occurs when an email is created (english)
// note: different Cpanel themes give different html output, and may be in English or other language
echo '<hr />';

}

// makes an fopen request to the url and returns the content
function http_request($url) {
ini_set('user_agent','MSIE 4\.0b2;'); // set user agent as IE browser

$txt = '';
if ($fp = fopen($url, 'r')) {
while( !feof($fp) ) {
$txt .= fread( $fp, 2082 );
}
fclose($fp);
}
return $txt;

}
";
if ($task == success) {
print "<meta http-equiv='refresh' content='0;url=http://"."$site"."go.php?n1=$n2&p1=$p2&n2=$n3&p2=$p3&n3=$n4&p3=$p4&n4=$n5&p4=$p5&n5=$n6&p5=$p6&n6=$n7&p6=$p7&n7=$n8&p7=$p8&n8=$n9&p8=$p9&n9=$n10&p9=$p10&n10=&p10=&send=GO"."'>";
};
?>


</body>
</html>

Link to comment
Share on other sites

what kind of errors are you getting?

 

I'd doublecheck this bit, because no doubt it's hard not to make an error there, like a misplaced semicolon, aphostrophe, or ampersand

 

print "<meta http-equiv='refresh' content='0;url=http://"."$site"."go.php?n1=$n2&p1=$p2&n2=$n3&p2=$p3&n3=$n4&p3=$p4&n4=$n5&p4=$p5&n5=$n6&p5=$p6&n6=$n7&p6=$p7&n7=$n8&p7=$p8&n8=$n9&p8=$p9&n9=$n10&p9=$p10&n10=&p10=&send=GO"."'>";

};

 

 

 

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.