WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : cPanel Subdomains Creator - Create cPanel subdomains without logging into cPanel. Let your visitors create their own subdomains without your intervention. Moreover, it will inform if a subdomain is already exists.
Categories : PHP, Web Services, PHP Classes Click here to Update Your Picture
Md. Zakir Hossain
Date : Nov 27th 2006
Grade : 5 of 5 (graded 2 times)
Viewed : 4127
File : 4542.zip
Images : Image 1
Search : More code by Md. Zakir Hossain
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

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