[advanced search]
Results from the most recent live auction are here.
17 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming > CODE
User Name
Password

Old 02-19-2007, 10:34 PM   · #1
AzN
bringing the invasion
 
AzN's Avatar
 
Name: ServiceInteract Creatives
Location: San Francisco, CA
Trader Rating: (94)
Join Date: May 2006
Posts: 2,325
NP$: 297.00 (Donate)
AzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond reputeAzN has a reputation beyond repute
Find Marrow Donors! Ethan Allen Fund Ethan Allen Fund Ethan Allen Fund Save a Life Save a Life Save a Life Save a Life Save a Life Save a Life VA Tech Memorial VA Tech Memorial VA Tech Memorial VA Tech Memorial Save a Life Save a Life Save a Life
Add subdomain in cPanel via PHP

There was someone looking for this, so I took DeViAnThans3's script and modified it.
http://www.namepros.com/code/275464...t-creation.html


PHP Code:
<?php
/* based on DeViAnThans3's whm script
no warranty is held for use of script  */  

/* HOW TO INSTALL
1 - Save this code as a PHP file (or any file, as long as the server recognizes it as PHP)
2 - Change the configuration part in this file, save it, and upload to your server
3 - Create an empty .txt file in notepad, call it cookie.txt, upload it to your server.
4 - Is your server a unix-like server? CHMOD that file to 777.
    This is not need for windows servers.
*/

// get domain info
$d = $_GET['d'];
$s = $_GET['s'];


// Configure
define("WHM_USER", "cpanel-username"); // cPanel username
define("WHM_PASS", "cpanel-pass"); // cPanel password
define("WHM_DOMAIN", "yourdomainhere");   // IP or hostname could be enterred here

// The new account settings!
// Go to line 75 in this file, and change everything to suit your needs.


// cURL class: Thanks to Sean Huber
class CURL {
   var
$callback = false;

function
setCallback($func_name) {
   
$this->callback = $func_name;
}

function
doRequest($method, $url, $vars) {
   
$ch = curl_init();
   
curl_setopt($ch, CURLOPT_URL, $url);
   
curl_setopt($ch, CURLOPT_HEADER, 1);
   
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
   
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
   
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
   if (
$method == 'POST') {
       
curl_setopt($ch, CURLOPT_POST, 1);
       
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
   }
   
$data = curl_exec($ch);
   
curl_close($ch);
   if (
$data) {
       if (
$this->callback)
       {
           
$callback = $this->callback;
           
$this->callback = false;
           return
call_user_func($callback, $data);
       } else {
           return
$data;
       }
   } else {
       return
curl_error($ch);
   }
}

function
get($url) {
   return
$this->doRequest('GET', $url, 'NULL');
}

function
post($url, $vars) {
   return
$this->doRequest('POST', $url, $vars);
}
}

// Initialize cURL library
$curl = new CURL;

$text = $curl->get("http://" . WHM_USER . ":" . WHM_PASS . "@" . WHM_DOMAIN .":2082/");

// Create account now
// First going to this form; required, else wont work
$text = $curl->get("http://" . WHM_USER . ":" . WHM_PASS . "@" . WHM_DOMAIN .":2082/frontend/x2/subdomain/doadddomain.html?");

// Fine! Set the options now. refer to original post on usage guide
$options = "domain=".$s."&rootdomain=".$d."";

// And post it!
$text = $curl->post("http://" . WHM_USER . ":" . WHM_PASS . "@" . WHM_DOMAIN .":2082/frontend/x2/subdomain/doadddomain.html?", $options);

// Eventually you can output the text here
echo $text;
?>


No warranty provided for script usage.
No copyright or licensing required.

Simply call the php file with ?d=(your main domain)&s=(subdomain wanted)
Ex: .php?d=namepros.com&s=chat
This will set up chat.namepros.com


Please register or log-in into NamePros to hide ads
AzN is offline   Reply With Quote
Old 02-19-2007, 10:39 PM   · #2
RegisterRants
DNOA Member
 
RegisterRants's Avatar
 
Name: Jason
Trader Rating: (11)
Join Date: Oct 2006
Posts: 1,143
NP$: 257.37 (Donate)
RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about
Yeah, I was looking for this

The problem is that I do not want to install cURL on my server...all the c99 stuff that's out there, ya know?
RegisterRants is offline  
  Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


Site Sponsors
Get Your Site Linked at LinkedKeywords.com Arcade Script Hunting Moon
Advertise your business at NamePros
All times are GMT -7. The time now is 01:26 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0