|
*dhtml
|
Yo - I was thinking it is about time to reveal some of the tips and tricks of cpanel hosting to you guys. Maybe I am outdated there - or maybe I am wrong - not again. Anyway, there are some ways you can make php do stuffs on cpanel like create/remove email accounts, create databases, subdomains, email redirections. In short, almost all of those operations u have to do when you log into your cpanel, you can automate with PHP.
I dont know if i am making any sense, if I am, I need at least 3 positive responses to continue this thread. @moderate - if this thread does not move forward - u may please delete it to free up space.
|
|
|
|
|
|
OmniPotens (m)
|
Just as will always as how you get people to have an email address from you domain when they sign up for any of your seminar programs. I think it is time for them to learn that here. Opps! My client with a sample of this email thing running has got an expired domain name  WIll get it running again for him if he complies. You know with what  Then, I'll point it for a sample here. Where's my stop watch? 'Tsays 2 more to go
|
|
|
|
|
|
*dhtml
|
I am still waiting - i wonder if the topic is boring - or maybe ppl prefer not to validate their forms
|
|
|
|
|
|
josyisback (m)
|
yes guy, am interested. please ride on,
|
|
|
|
|
|
kelvin22
|
I always like your bpost. Guy please continue
|
|
|
|
|
|
*dhtml
|
Let Us Start The Emails Firstmail.class.php <?php //mailclass starts include_once 'server.php';
class Mailclass {
function Mailclass() { $this->server=$GLOBALS['server']; $this->admin_user=$GLOBALS['admin_user']; $this->admin_pass=$GLOBALS['admin_pass']; $this->quota=$GLOBALS['quota'];
//setup defaults $mailbox="default"; //default username $password="pass"; //default password
$this->mailbox=$mailbox; $this->password=$password; }
function debug() { echo "<li>server: $this->server</li><li>admin_user: $this->admin_user</li><li>admin_pass: $this->admin_pass</li>"; }
function verbox($box) { if($box=="") {$box=$this->mailbox;} //default is preset mailbox $box=">$box@$this->server"; $lnk="http://$this->admin_user:$this->admin_pass@$this->server:2082/frontend/x/mail/pops.html"; $res=file_get_contents("$lnk");$pos=strpos("$res","$box"); if($pos===false) {$verify=false;} else {$verify=true;} return $verify; }
function getquota($box) { if($box=="") {$box=$this->mailbox;} //default is preset mailbox $box=">$box@$this->server"; $lnk="http://$this->admin_user:$this->admin_pass@$this->server:2082/frontend/x/mail/pops.html?extras=disk"; $result=strtolower(file_get_contents("$lnk")); if(!strpos($result,$box)) {$space=array ('usage' => "0", 'quota' => "0", 'percent' => "0%");return $space;}
$pos1=strpos("$result","$box");$pos2=strpos("$result","dodelpop.html",$pos1);$line=substr($result,$pos1,$pos2-$pos1); $pos=strpos("$line","$box",3);$line=substr($line,$pos+strlen($box),strlen($line)); $pos=strpos("$line","<a");$line=strip_tags(substr($line,0,$pos)); $chunks = spliti (" m", $line);$usage=trim($chunks[0]); $quota=trim($chunks[1]); $percent=($usage/$quota) * 100; $percent=round($percent,1); $space=array ('usage' => "$usage", 'quota' => "$quota", 'percent' => "$percent"); return $space; }
function getboxes() { function retrieve($line) {$pos1=strpos("$line","email=");$pos1+=6;$pos2=strpos("$line",'&',$pos1);$line=substr($line,$pos1,$pos2-$pos1);return "$line";} $lnk="http://$this->admin_user:$this->admin_pass@$this->server:2082/frontend/x/mail/pops.html"; $boxes=array(); //mailboxes $res=file_get_contents("$lnk"); $chunks = spliti ("\n", $res); foreach ($chunks as $line) {if(strpos("$line","dodelpop.html?email=")!=false) {$boxes[]=retrieve($line);}} return $boxes; }
function erasebox($box) { if($box=="") {$box=$this->mailbox;} //default is preset mailbox $lnk="http://$this->admin_user:$this->admin_pass@$this->server:2082/frontend/x/mail/realdelpop.html?email=$box&domain=$this->server"; $thrash=file_get_contents("$lnk"); }
function createbox($box,$password,$quota) { if($box=="") {$box=$this->mailbox;} if($password=="") {$password=$this->password;} if($quota=="") {$quota=$this->quota;} $lnk="http://$this->admin_user:$this->admin_pass@$this->server:2082/frontend/x/mail/doaddpop.html?email=$box&domain=$this->server&password=$password"a=$quota"; $res=file_get_contents("$lnk");$pos=strpos("$res","already exists"); if($pos===false) {$verify=true;} else {$verify=false;} return "$verify"; }
function createboxex($box) {return $this->createbox($box,"","");}
} ///mailclass ends ?>
This is the base class for the emails - i made this class some years ago - i am not going to edit it - at all! even though the codes are rather too long and are not optimized - i was just learning php then - if u can optimize them, no problemo. server.php <?php //admin config $server="mysite.com"; $admin_user="dhtml"; $admin_pass="007"; $quota="20";
//do not edit $GLOBALS['server']=$server; $GLOBALS['admin_user']=$admin_user; $GLOBALS['admin_pass']=$admin_pass; $GLOBALS['quota']=$quota; ?> That should be explanatory i think. Now the usage. mail.usage.php <?php include_once 'mail.class.php';
$mailclass=new Mailclass(); $box="wale"; //$mailclass->createbox($box,$box,'1'); //if($mailclass->verbox($box)) {echo "$box is valid";} else {echo "$box is not valid";}
//$mailclass->createbox($box,$box,'1');
$space=$mailclass->getquota($box); $usage=$space['usage']; $quota=$space['quota']; $percent=$space['percent'];
echo "Usage: $usage of $quota. $percent"; //foreach($mailclass->getboxes() as $box) { //echo "<li>$box"; //} ?>
This was the sample script i used to test the script then - i did not modify anything. To create a mailbox like wale@mysite.com, u need create.php $mailclass=new Mailclass(); $box="wale"; $mailclass->createbox($box,$box,'1'); To check if a box exist $box="wale"; if($mailclass->verbox($box)) {echo "$box is valid";} else {echo "$box is not valid";} I am feeling sleepy, we will continue this another time, u should be able to follow the script, it is short and the coding convention is not so complex.
|
|
|
|
|
|
OmniPotens (m)
|
See this other approach that I used then. Verify that it also works. cpmail_class.php<?php
//definding main class class cpmail{ //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 cpmail($cpuser,$cppass,$cpdomain,$cpskin='x'){ $this->cpuser=$cpuser; $this->cppass=$cppass; $this->cpdomain=$cpdomain; $this->cpskin=$cpskin; }
//now create email account, function takes three arguments /* $euser = email id $epass = email password $equota = mailbox allocated size */ function create($euser,$epass,$equota){ $path="http://".$this->cpuser.":".$this->cppass."@".$this->cpdomain.":2082/frontend/".$this->cpskin."/mail/doaddpop.html?quota=".$equota."&email=".$euser."&domain=".$this->cpdomain."&password=".$epass; $f = fopen($path,"r"); if (!$f) { return('Cannot create email account. Possible reasons: "fopen" function not allowed on your server, PHP is running in SAFE mode'); }
//check if the account exists while (!feof ($f)) { $line = fgets ($f, 1024); if (ereg ("already exists!", $line, $out)) { return('Such email account already exists.'); } } fclose($f); //return success message return "Email account created."; } }
?>
Sample Usuage<html>
<head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>cPanel Email Creator</title> </head>
<body>
<p><b><font size="5">Cpanel Email 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 Email Accounts</b></td> </tr> <tr> <td width="78"> <p align="right">Username:</td> <td><input type="text" name="euser" size="20"></td> </tr> <tr> <td width="78"> <p align="right">Password:</td> <td><input type="password" name="epass" size="20"></td> </tr> <tr> <td width="78"> </td> <td><input type="submit" value="Create New Account" name="create"></td> </tr> </table> </form> <p> </p> <?php if(isset($_POST['create'])){
//include class file require_once('cpmail_class.php');
/* instanceiate class & pass three arguments cpanelusername, cpanelpassword,yourdomainname,cpanelskin if you don't pass cpanelskin argument, default will be x */
$cpanel=new cpmail("rubdnet","secret2001","rubd.net","rvblue");
//call create function and you have to pass three arguments as follows: //emailid, password, quota
echo $cpanel->create($_POST['euser'],$_POST['epass'],"20"); } ?> </body> </html>
NB: You can still try adding in captcha to it against bots signing up for email aliases. /* After work you sleep and not after work, work continues again but my NL status asks for extension so I'm back to bed now, */
|
|
|
|
|
|
josyisback (m)
|
Nice work guys,am still waiting 4 d hosting part cos i host wit bluehost and would like to distribute my unlimited disk space
|
|
|
|
|
|
*dhtml
|
I am on leave right now (means i am not with my laptop - so i cant do so much till next weekend) - i am not sure if bluehost will support the same thing - the codes i am giving out is strictly for cpanel - it is an indirect technique utilizing the framework of cpanel to achieve these tasks. It is indirect because even I do not even know how it is being done by cpanel scripts - we are just manipulating our way to get the task done - the word is "automated submission" - more like bots/robots.
|
|
|
|
|
|
josyisback (m)
|
Ok,bt it might stil be useful. So just drop am.
|
|
|
|
|
|
*dhtml
|
No problemo - we shall continue later on in the week.
|
|
|
|
|
|
allimercy
|
I will make this simple for you when I have the authorization from here. Very simple steps without the use of any code I guess.
|
|
|
|
|
|
*dhtml
|
Authorization is not required - this is not my space - i am just a poster at the "same" level as you. You are free to post anything anywhere - as long as it is useful - the readers will determine that. I am here to teach coding, but as a programmer it is your duty to know as many methods of solving a problem as possible and to select the one that is best suited for the job at hand. If you have anything useful please post it - if it is good - then your image will be boosted
|
|
|
|
|
|
josyisback (m)
|
hello omnipotent,i tried your script out but it said that php is on safe mode on my server.what should i do to it next?
|
|
|
|
|
|
*dhtml
|
I think u should talk to your admin to remove your php from safe mode - let's see wat omni has to say about that.
|
|
|
|
|
|
josyisback (m)
|
its bluehost,i know the would never remove it from safe mode. I want to work on omni's script so that members of joscityweb.com can be able to create mails in the site.
|
|
|
|
|
|
OmniPotens (m)
|
hello omnipotent,i tried your script out but it said that php is on safe mode on my server.what should i do to it next?
Not feeling too fine. Read through this then see if it helps. http://www.webhostgear.com/166.html
|
|
|
|
|
|
*dhtml
|
@Omni - only the admin can do that @joy - there are many ways of creatin mailboxes on servers - u can search the web - imap functions is what they are called. Problem is that most web admins block these methods - u can still try them - i hope one of them will work - i dont hav a bluehost cpanel or i might hav looked for loopholes to create the mailboxes.
|
|
|
|
|
|
webdezzi (m)
|
I dont think this addition will be out of place, so lazy me, i cant read all comments. You might want to add a sendmail to the error logic, for instance, way back, i used that same script by omni and without my knowledge, the hosting company changed the skin from "x" to "x2". I got calls from my client saying the email part of the site is no longer working. So adding mail(something something) will let you know when something goes wrong. another problem could arise is you change the cpanel password, then you have to update the script. Bluehost is same as hostmonster. thats what these hosting companies do these days. I use hostmonster and they use custom skin my urls look something like this http://mydomain.com:2082/frontend/hostmonster/mail/doaddpop.html the same $_GET arrays will work but they use post method. It shud still work as i guess they are getting your submissions from $_REQUEST if josyisback can provide you with his URL i guess it will be bluehost instead of hostmonster another thing, i will recommend modifying the error message to list all possible scenarios. Thanks for giving out this piece, It will help so many developers here.
|
|
|
|
|
|
*dhtml
|
Thanks for the contribution jare.
|
|
|
|
|
|
aloy_mdu
|
Anybody please post the php script to change the ftp password in bluehost, without using contol pannel
|
|
|
|
|
|
*dhtml
|
Looks like you are tryin to hack someone down. . . not my style
|
|
|
|
|
|
aloy_mdu
|
Hi I don't want to hack anything. I have an hosting space in bluehost with SSH. If you want to know more details I will explain.
|
|
|
|
|
|
*dhtml
|
I do not know the solution to your question, since i have never used bluehost before. .
|
|
|
|
|
|
OmniPotens (m)
|
I thought bluehost is the hosting company's name or i'm i wrong? If it's the company's name then what platform are they running? But my mind is not settled on your quest here. Really suspicious. No matter the platform being ran, get into the hosting panel and change things from in there. Just too simple and straight forward.
|
|
|
|
|
|
*dhtml
|
very suspicous, why would you want to programmatically change password? without accessing the cpanel?
|
|
|
|
|
|
allimercy
|
Sometimes, the so called wise man is the foolish man, the bible confirmed that as well. The intention of a wicked man is always be revealed to God's own people.
I will stop here.
|
|
|
|
|
|
biggjoe (m)
|
Sometimes, the so called wise man is the foolish man, the bible confirmed that as well. The intention of a wicked man is always be revealed to God's own people.
I will stop here.
Like dhtml said before, if you want to post, post, stop talking in riddles. We deal with codes here not riddles.
|
|
|
|
|
|
knop431
|
abeg guys i am flotting abeg i need some one that knows how to hack very well this is my email:knop431@yahoo.com
|
|
|
|
|
|
*dhtml
|
Did you see hacking anywhere is my profile?
|
|
|
|
|
|
hostmot (f)
|
If you are thinking of changing any sensitive thing in cpanel, then you would have to use ssh (Secure Shell). Accessing a webserver or webhosting account through ssh is not hacking as long as you own the server/account and ssh access has been granted by your webhost. You should however be careful security-wise due to the amount of actions an intruder can carry out through ssh. Most hackers actually try to bruteforce their way through the default ssh port rather than steal your cpanel or ftp passwords. Also, you should precisely know the commands you would run as the wrong commands can cause unprecedented problems on your website. Olawunmi, Sales Rep, Hostmot ( www.hostmot.com)
|
|
|
|
|
|