|
|
|
|
Like this code?
Show the author your appreciation.
|
|
| |
cpsubdomain Class
| <?php
/*
Class Name: cpsubdomain
Clas Title: cPanel Subdomains Creator
Purpose: Create cPanel subdomains without logging into cPanel.
Version: 1.0
Author: Md. Zakir Hossain (Raju)
URL: http://www.rajuru.xenexbd.com
Company: Xenex Web Solutions
URL: http://www.xenexbd.com
License: LGPL
You can freely use, modify, distribute this script. But a credit line is appreciated.
Installation:
see example.php for details
Compatibility: PHP4
*/
//definding main class
class cpsubdomain{
//declare public variables
var $cpuser; // cPanel username
var $cppass; // cPanel password
var $cpdomain; // cPanel domain or IP
var $cpskin; // cPanel skin. Mostly x or x2.
//defining constructor
function cpsubdomain($cpuser,$cppass,$cpdomain,$cpskin='x'){
$this->cpuser=$cpuser;
$this->cppass=$cppass;
$this->cpdomain=$cpdomain;
$this->cpskin=$cpskin;
// See following URL to know how to determine your cPanel skin
// http://www.zubrag.com/articles/determine-cpanel-skin.php
}
//function for creating subdomain
function createSD($esubdomain){
//checking whether the subdomain is exists
$subdomain=$esubdomain.".".$this->cpdomain;
$path="http://".$this->cpuser.":".$this->cppass."@".$this->cpdomain.":2082/frontend/".$this->cpskin."/subdomain/index.html";
$f = fopen($path,"r");
if (!$f) {
return('Can\'t open cPanel');
}
//check if the account exists
while (!feof ($f)) {
$line = fgets ($f, 1024);
if (ereg ($subdomain, $line, $out)) {
return('Such subdomain already exists.');
}
}
fclose($f); //close the file resource
//subdomain does not already exist. So proceed to creating it
$path="http://".$this->cpuser.":".$this->cppass."@".$this->cpdomain.":2082/frontend/".$this->cpskin."/subdomain/doadddomain.html?domain=".$esubdomain."&rootdomain=".$this->cpdomain;
$f = fopen($path,"r");
if (!$f) {
return('Can\'t open cPanel.');
}
//check if the subdomain added
while (!feof ($f)) {
$line = fgets ($f, 1024);
if (ereg ("has been added.", $line, $out)) {
return('Subdomain created successfully');
}
}
fclose($f); //close the file resource
//return success message
return "There may be some error while creating subdomain.";
}
}
?> | |
Usage Example
| <html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>cPanel Subdomain Creator</title>
</head>
<body>
<p><b><font size="5">Cpanel Subdomain Creator</font></b></p>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table border="0" width="52%" style="border-collapse: collapse">
<tr>
<td colspan="2">
<p align="left"><b>Create Sub-domain:</b></td>
</tr>
<tr>
<td width="78" style="text-align: right">
Sub-domain:</td>
<td>
<input type="text" name="esubdomain" size="20" style="width: 166px"></td>
</tr>
<tr>
<td width="78"> </td>
<td>
<input type="submit" value="Create New Subdomain" name="create" style="width: 165px"></td>
</tr>
</table>
</form>
<p> </p>
<?php
if(isset($_POST['create'])){
//include class file
require_once('class.php');
/*
instanceiate class & pass three arguments cpanelusername, cpanelpassword,yourdomainname,cpanelskin
*/
$cpanel=new cpsubdomain("cpusername","cppass","yourname.com","x");
//cpanel username, cpanel password, domain name, cpanel theme
//cpanel theme may be 'x', 'rvblue' etc.
/*
See following URL to know how to determine your cPanel skin
http://www.zubrag.com/articles/determine-cpanel-skin.php
if you don't pass cpanelskin argument, default will be x. Thanks to this website.
*/
//call create function and you have to pass subdomain parameter
echo $cpanel->createSD($_POST['esubdomain']);
}
?>
</body>
</html> | | |
|
| cPanel Email Accounts Creator Categories : PHP, PHP Classes, Email, Form Processing, Web Services | | | Freshmeat.net XML-RPC - This class is meant to query Freshmeat for information about registered projects. Categories : PHP, PHP Classes, XML, Web Services | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | very simple ftp class Categories : PHP, PHP Classes, FTP | | | PHP Paypal IPN Integration Class v1.0.0 Categories : PHP, PHP Classes, Payment Gateways | | | crop and resize image class using gd library function Categories : PHP, PHP Classes, GD image library, Graphics | | | A Timing Class Categories : PHP, PHP Classes, Date Time | | | The class to check load time of your script
VERY usefull for relatively slow applications, but not only.. Categories : PHP, PHP Classes, Debugging | | | Create HTML forms dynamicly using Javascript & PHP Categories : PHP, PHP Classes, Java Script | | | usercounter class Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables | | | RSS parser.
Parses RSS into an array. Quick and nasty but does the job.
No checking is done for correct Tags, only correct XML.
PHP4 needed to display result (uses print_r). Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS) | | | ElfReader: An ELF (Executable and Linking Format) header information in PHP. Shows how to use the UNPACK function to read data. Categories : PHP, Linux, PHP Classes | | | an example of the cyberlib payment class Categories : PHP, PHP Classes, Ecommerce, Credit Cards | | | Power Form Validation Categories : PHP, PHP Classes, Data Validation | | | MySQL Handler Categories : PHP, Databases, MySQL, Classes and Objects, PHP Classes | |
|
|
|