Web Hosting Talk







View Full Version : PHP HELP!!!


Occonic
02-05-2010, 11:10 PM
hello, am trying to auto create cpanel accounts from a delimited file like this ..
accounts.txt
domain,pass,emails,package

My question is how can i make a php script to auto read the $domain,pass,email,package and auto post it to account.php?domain=$domain&user=$user&password=$password&package=$package

Matt R
02-06-2010, 06:55 AM
//domain,pass,emails,package

$array = file('file.txt');

foreach($array as $key){

$data = explode(',',$key);

$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'file.php?domain={$data[0]}&pass={$data[1]}&email={$data[2]}&package={$data[3]}');
curl_exec($curl_handle);
curl_close($curl_handle);

}



That should do the trick, although it doesn't do any error checking.

Make sure you edit the query string to match exactly what you need it to when it comes to naming conventions.

Also remember that arrays start with a value of 0, not one, so in this case, $data[0] is your domain with $data[3] being your package.

Edit: Also remember to edit the file.php to include a complete URL, not a partial URL as listed above.

Occonic
02-06-2010, 04:52 PM
Thank you so much, i spent half of my day brushing up on php and i had some explode code but it wasnt looping to the next line.

Occonic
02-06-2010, 06:46 PM
//domain,pass,emails,package

$array = file('file.txt');

foreach($array as $key){

$data = explode(',',$key);

$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'file.php?domain={$data[0]}&pass={$data[1]}&email={$data[2]}&package={$data[3]}');
curl_exec($curl_handle);
curl_close($curl_handle);

}



That should do the trick, although it doesn't do any error checking.

Make sure you edit the query string to match exactly what you need it to when it comes to naming conventions.

Also remember that arrays start with a value of 0, not one, so in this case, $data[0] is your domain with $data[3] being your package.

Edit: Also remember to edit the file.php to include a complete URL, not a partial URL as listed above.


Here is what i got workin so far for cpanel.... How can i filter the domain which is $data[0] to remove any period,hyphen and then copy result to 8 character or less username? am tryin to make it as automated as possible.

<?php

//domain,pass,emails,package

/////// YOUR WHM LOGIN DATA
$whm_user = "x"; // reseller username
$whm_pass = "hx"; // the password you use to login to WHM

$array = file('acct');

foreach($array as $key){

$data = explode(',',$key);

$whm_host = $_SERVER['HTTP_HOST'];


// create account on the cPanel server
$script = "htxtp://{$whm_user}:{$whm_pass}@{$whm_host}:2086/scripts/wwwacct";
$params = "?domain={$data[0]}&username={$data[1]}&password={$data[2]}&contactemail={$data[3]}&plan={$data[4]}";
$result = file_get_contents($script.$params);

// output result
echo "RESULT: " . $result;

}

?>

Simpkins
02-08-2010, 06:32 AM
I plan on opening a website, i would like to make the site in german as well as english maybe even in italian, i know how to build a website but i am not a master, someone said i would have to edit the " php.english" and or add a php.german file to the already made template i plan on using.

So my question is, is this hard to do, or is there some place i can get this?

i have tried php.net but i could not understand one thing there. thanks