Creating subdomain using PHP (cpanel environment)

What this snippets do ?
Bypass server cpanel to create each user their subdomain without administrator adding your subdomain manually.

<!--?php
 
// your cPanel username
$cpanel_user = 'username';
 
// your cPanel password
$cpanel_pass = 'password';
 
// your cPanel skin . hover at your cpanel home link button and see the theme name after /frontend/
$cpanel_skin = 'x3';
 
// your cPanel domain
$cpanel_host = 'arif.my';
 
// Replace with your subdomain name e.g: 'blog' for blog.arif.my
$subdomain = 'subdomain';
 
// create the subdomain
 
$sock = fsockopen($cpanel_host,2082);
if(!$sock) {
print('Socket error');
exit();
}
 
$pass = base64_encode("$cpanel_user:$cpanel_pass");
$in = "GET /frontend/$cpanel_skin/subdomain/doadddomain.html?rootdomain=$cpanel_host&amp;domain=$subdomain\r\n";
$in .= "HTTP/1.0\r\n";
$in .= "Host:$cpanel_host\r\n";
$in .= "Authorization: Basic $pass\r\n";
$in .= "\r\n";
 
fputs($sock, $in);
while (!feof($sock)) {
$result .= fgets ($sock,128);
}
fclose($sock);
 
echo $result;

Adding CakePHP as GIT submodule

Why we should apply this in our development environment ? Because it is easier to update CakePHP library used in your application.

Follow this trail below ,  junior programmer should be able to understand it :

cd /var/www/my_cakephp_application

# First, remove the current cake folder

 
rm -rf cake/
 
mkdir core/

# Now add cakephp as your application submodule

git submodule add  git@github.com:arifsanchez/cakephp.git core/
git submodule init
git submodule update

# Okay, now you should see files in core/ directory.
# Set your application to read cakephp library from new directory.
# Open app/webroot/index.php (try line 53)

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'core');
}

So every morning, before you start your code writing again, please run

git submodule init
 
git submodule update