【在特定时间后执行PHP代码】教程文章相关的互联网学习教程文章

生成一定数量的不重复随机数的PHP代码

生成一定数量的不重复随机数 /** array unique_rand( int $min, int $max, int $num )* 生成一定数量的不重复随机数* $min 和 $max: 指定随机数的范围* $num: 指定生成数量*/function unique_rand($min, $max, $num) { $count = 0; $return = array(); while ($count $return[] = mt_rand($min, $max); $return = array_flip(array_flip($return)); $count = count($return); } shuffle($ret...

通过站长站获取网站百度权重的PHP代码

通过站长站获取网站百度权重的php代码 function br($s){ $baidu="http://mytool.chinaz.com/baidusort.aspx?host=".$s; $site=file_get_contents($baidu); preg_match("/(.*)<\/font>/i",$site,$count); return $count[1][0];}$br=br("http://xxx.com");echo $br; 站长站, PHP

14行PHP代码获取客户端IP地址经纬度及所在城市

$getIp=$_SERVER["REMOTE_ADDR"]; echo 'IP:',$getIp; echo ''; $content = file_get_contents("http://api.map.baidu.com/location/ip?ak=7IZ6fgGEGohCrRKUE9Rj4TSQ&ip={$getIp}&coor=bd09ll"); $json = json_decode($content); echo 'log:',$json->{'content'}->{'point'}->{'x'};//按层级关系提取经度数据 echo ''; echo 'lat:',$json->{'content'}->{'point'}->{'y'};//按层级关系提取纬度数据 echo ''; print $jso...

php代码的加密解密

php 代码加密类 /* * @auther:wangyaofeng * @time:2014.11.6 * @action:对php项目进行加密处理,注意如果项目中存在框架目录或没有必要加密的目录,请提前移出 * */ class Encryption{ private $c='';//存储密文 private $s='',$q1,$q2,$q3,$q4,$q5,$q6;//存储生成的加密后的文件内容 //如果不设置一个值,isset会表示不存在; private $file=...

PHP过虑禁用字符,入数据库前(PHP代码函数)

//PHP过虑禁用字符,入数据库前(php代码函数) function safe_str($str){ $array=array(receive.php,select,insert,update,delete,union,into,load_file,outfile); if(!is_array($str)){ foreach($array as $v){ $str=preg_replace("#({$v})#i","-\\$小贝-",$str); } //$str=preg_replace("![][xX]([A-Fa-f0-9])!","x \\$小贝",$str); $str=str_replace("",,$str); $str...

Unzip一个Zip文件的PHP代码

function unzip($location,$newLocation){ if(exec("unzip $location",$arr)){ mkdir($newLocation); for($i = 1;$i $file = trim(preg_replace("~inflating: ~","",$arr[$i])); copy($location.'/'.$file,$newLocation.'/'.$file); unlink($location.'/'.$file); } return TRUE; }else{ return FALSE; } }?>//Use the code as following:include 'functions.php';if(unzip('zipedfiles/test.zip','unziped/myNewZip')) echo 'Succ...

取得用户IP地址的PHP代码

function getRealIpAddr() { if (!empty($_SERVER[HTTP_CLIENT_IP])) //check ip from share internet { $ip=$_SERVER[HTTP_CLIENT_IP]; } elseif (!empty($_SERVER[HTTP_X_FORWARDED_FOR])) //to check ip is pass from proxy { $ip=$_SERVER[HTTP_X_FORWARDED_FOR]; } else { $ip=$_SERVER[REMOTE_ADDR]; } return $ip;} PHP

通过IP地址取得所在国家的PHP代码

function getLocationInfoByIp(){ $client = @$_SERVER['HTTP_CLIENT_IP']; $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; $remote = @$_SERVER['REMOTE_ADDR']; $result = array('country'=>'', 'city'=>''); if(filter_var($client, FILTER_VALIDATE_IP)){ $ip = $client; }elseif(filter_var($forward, FILTER_VALIDATE_IP)){ $ip = $forward; }else{ $ip = $remote; } $ip_data = @json_decode(file_get_contents("http://ww...

校验url,email和ip的PHP代码

function is_valid_url($url){ $p1 ='/(http|https|ftp):\/\/[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(\/.*)?$/i'; return preg_match($p1, $url);} function is_valid_email($email){ if (filter_var($email, FILTER_VALIDATE_EMAIL)) return true; else return false;} function is_valid_ip($ip){ if (filter_var($ip, FILTER_VALIDATE_IP)) return true; else return false;} ?> email, url, PHP

验证邮箱地址是否有效的PHP代码

有时候,当在网站填写表单,用户可能会输入错误的邮箱地址,这个函数可以验证邮箱地址是否有效。 function is_validemail($email){$check = 0;if(filter_var($email,FILTER_VALIDATE_EMAIL)){$check = 1;}return $check;}用法: $email = "blog@open.com";$check = is_validemail($email);echo $check;// If the output is 1, then email is valid.?> 邮箱地址, PHP

whois查询的PHP代码

使用下面的函数可以获取任何域名用户的完整细节 function whois_query($domain) { // fix the domain name: $domain = strtolower(trim($domain)); $domain = preg_replace(/^http:\/\//i, , $domain); $domain = preg_replace(/^www\./i, , $domain); $domain = explode(/, $domain); $domain = trim($domain[0]); // split the TLD from domain name $_domain = explode(., $domain); $lst = co...

读取CSV文件的PHP代码

function readCSV($csvFile){ $file_handle = fopen($csvFile, r); while (!feof($file_handle) ) { $line_of_text[] = fgetcsv($file_handle, 1024); } fclose($file_handle); return $line_of_text;}用法: $csvFile = "test.csv";$csv = readCSV($csvFile);$a = csv[0][0]; // This will get value of Column 1 & Row 1?> CSV, PHP

使用IP判断访问用户是在哪个城市的PHP代码

function detect_city($ip) { $default = UNKNOWN; $curlopt_useragent = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729); $url = http://ipinfodb.com/ip_locator.php?ip= . urlencode($ip); $ch = curl_init(); $curl_opt = array( CURLOPT_FOLLOWLOCATION => 1, CURLOP...

使用mandrill发送邮件的PHP代码

Mandrill 是一款强大的 SMTP 提供器。开发者倾向于使用一个第三方 SMTP provider 来获取更好的收件交付。 下面的函数中,你需要把 “Mandrill.php” 放在同一个文件夹,作为 PHP 文件,这样就可以使用TA来发送邮件。 function send_email($to_email,$subject,$message1){require_once Mandrill.php;$apikey = XXXXXXXXXX; //specify your api key here$mandrill = new Mandrill($apikey); $message = new stdClass();$message->...

判断用户是否使用代理的PHP代码

/******************************************************* isProxy* check whether client is under Proxy or not* $_SERVER['HTTP_X_FORWARDED_FOR'] is pivotal here* if client is under Proxy, returns true* if client is not under Proxy, returns false* *****************************************************/function isProxy(){ return (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? true : f...

执行 - 相关标签