گرفتن اطلاعات یک سایت از alexa
alexa.class.php
کد:
<?php
/**
* @author [YS.PRO]
* @copyright Copyright © 2009, [YS.PRO]
* http://ys-pro.com
* @version 0.2
*/
class Alexa {
const CURL_TIMEOUT = 20;
const ALEXA_SITE_INFO_URL = 'http://www.alexa.com/siteinfo/';
private $domain = NULL;
public function __construct($domain = NULL) {
if (!is_null($domain)) {
$this->domain = $domain;
} else {
throw new Exception('You must pass domain name to constructor!');
}
}
public function setDomain($domain) {
$this->domain = $domain;
}
public function getAlexaRank() {
$response = $this->get(self::ALEXA_SITE_INFO_URL . $this->domain);
// parse string with alexa ranking info
$regexp = '#<div class="data .+?">(.*?)</div>#si';
preg_match($regexp, $response, $matches);
if (!isset($matches[1])) {
return FALSE;
}
preg_match('#[\d,]+#s', $matches[1], $m);
if (!isset($m[0])) {
return FALSE;
}
$rank = $m[0];
// delete commas
$rank = str_replace(',', '', $rank);
return (int) $rank;
}
protected function get($url) {
$hCurl = curl_init($url);
curl_setopt($hCurl, CURLOPT_TIMEOUT, self::CURL_TIMEOUT);
curl_setopt($hCurl, CURLOPT_RETURNTRANSFER, TRUE);
return curl_exec($hCurl);
}
}
?>
example.php
کد:
<?php
require 'Alexa.class.php';
$domain = 'microsoft.com';
try {
$Alexa = new Alexa($domain);
$alexa_ranking = $Alexa->getAlexaRank();
if ($alexa_ranking) {
echo '"'.$domain.'" has Alexa ranking: ' . $alexa_ranking;
} else {
echo 'bla bla bla... Goodbye this cruel world!';
}
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage() . "\n";
}
?>
class ساخت ایمیل در cpanel
به وسیله این کلاس میتونید بدون استفاده از cpanel یک اکانت ایمیل بسازید
cpmail_class.php
کد:
<?php
/*
This class is an extension of script made by www.zubrag.com. You can access the original link from here
http://www.zubrag.com/scripts/cpanel-create-email-account.php
Class Name: cpmail
Clas Title: cPanel Mail Accounts Creator
Purpose: Create cPanel email account without loggin in to 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: GPL
You can freely use, modify, distribute this script. But a credit line is appreciated.
Installation:
see example.php for details
*/
//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;
// See following URL to know how to determine your cPanel skin
// http://www.zubrag.com/articles/determine-cpanel-skin.php
}
//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.";
}
}
?>
cpmail_example.php
کد:
<?php
/*
This is the example script for cpmail class
*/
?>
<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
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
*/
$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>