威尼斯城所有登入网址

威尼斯城所有登入网址 2
PHP脚本执行的顺序有四个步骤,也就是对威尼斯城所有登入网址 PHP 语言本身的性能分析又分为三个方面
图片 19
PHP主要用于服务器端以通过HTTP生成动态网页,然后可以cmd中就可以运行php命令了 

51、威尼斯城所有登入网址:强制下载文件,网上总结出了很多实用的PHP代码片段

正文将介绍19个日常会用到的PHP代码片段,包罗黑名单过滤、随机颜色生成器、从英特网下载文件、亚历克斯a/GooglePage
Rank、免强下载文件、用Email突显顾客的Gravator头像、用cUKoleosL获取途乐SS订阅数、截取图片、检查网址是否宕机。

一、黑名单过滤

     
在PHP的流行广泛中,英特网海市总结出了无数实用的PHP代码片段,这么些代码片段在当您遇见相同的标题时,粘贴过去就能够选用,特其余连忙,特其他省时省力。将这几个程序猿前辈计算出的不错代码放到自个儿的知识库中,是三个专长学习的技术员的好习贯。即使超多内容还不是太知道,可是先搜集整理出来。

  1. 把公文调换来图片

    <?php
    header(“Content-type: image/png”);
    $string = $_GET[‘text’];
    $im = imagecreatefrompng(“images/button.png”);
    $color = imagecolorallocate($im, 255, 255, 255);
    $px = (imagesx($im) – 7.5 * strlen($string)) / 2;
    $py = 9;
    $fontSize = 1;
    imagestring($im, fontSize, $px, $py, $string, $color);
    imagepng($im);
    imagedestroy($im);
    ?>

  2. 赢得远程文件的深浅

    function remote_filesize($url, $user = “”, $pw = “”)
    {

    ob_start();
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_NOBODY, 1);
    if(!empty($user) && !empty($pw))
    {
        $headers = array('Authorization: Basic ' .  base64_encode("$user:$pw"));
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    }
    $ok = curl_exec($ch);
    curl_close($ch);
    $head = ob_get_contents();
    ob_end_clean();
    $regex = '/Content-Length:\s([0-9].+?)\s/';
    $count = preg_match($regex, $head, $matches);
    return isset($matches[1]) ? $matches[1] : "unknown";
    

    }

作为贰个例行的技士,会或多或少种语言是这多少个符合规律的,相信当先二分一技术员也都会编写几句PHP程序,假使是WEB程序猿,PHP一定是必备的,就算你没用它支付过大型软件项目,也必然多少精通它的语法。

威尼斯城所有登入网址 1

function is_spam($text, $file, $split = ‘:‘, $regex = false){ $handle = fopen; $contents = fread($handle, filesize; fclose; $lines = explode; $arr = array(); foreach{ list = explode; if $arr[$word] = $count; else $arr[preg_quote] = $count; } preg_match_all("~".implode)."~", $text, $matches); $temp = array(); foreach($matches[0] as $match){ if(!in_array{ $temp[$match] = $temp[$match] + 1; if($temp[$match] >= $arr[$word]) return true; } } return false; } $file = ‘spam.txt‘; $str = ‘This string has cat, dog word‘; if echo ‘this is spam‘; else echo ‘this is not spam‘; ab:3 dog:3 cat:2 monkey:2 

一、黑名单过滤

function is_spam($text, $file, $split = ':', $regex = false){ 
    $handle = fopen($file, 'rb'); 
    $contents = fread($handle, filesize($file)); 
    fclose($handle); 
    $lines = explode("n", $contents); 
    $arr = array(); 
    foreach($lines as $line){ 
        list($word, $count) = explode($split, $line); 
        if($regex) 
            $arr[$word] = $count; 
        else 
            $arr[preg_quote($word)] = $count; 
    } 
    preg_match_all("~".implode('|', array_keys($arr))."~", $text, $matches); 
    $temp = array(); 
    foreach($matches[0] as $match){ 
        if(!in_array($match, $temp)){ 
            $temp[$match] = $temp[$match] + 1; 
            if($temp[$match] >= $arr[$word]) 
                return true; 
        } 
    } 
    return false; 
} 

$file = 'spam.txt'; 
$str = 'This string has cat, dog word'; 
if(is_spam($str, $file)) 
    echo 'this is spam'; 
else 
    echo 'this is not spam';

ab:3
dog:3
cat:2
monkey:2

语法:

纵然PHP日常被人责骂,被人降级,被人当笑话开,事实注解,PHP是大地网站开拓中使用率最高的编制程序语言。PHP最大的败笔是太轻巧,语法不严刻,框架体系很弱,但那也是它最大的帮助和益处,一个某些编制程序背景的白丁橘花,只须要上学PHP半天时间,就能够上手开首支付web应用了。

一、黑名单过滤

function is_spam($text, $file, $split = ':', $regex = false){ 
    $handle = fopen($file, 'rb'); 
    $contents = fread($handle, filesize($file)); 
    fclose($handle); 
    $lines = explode("n", $contents); 
$arr = array(); 
foreach($lines as $line){ 
list($word, $count) = explode($split, $line); 
if($regex) 
$arr[$word] = $count; 
else 
$arr[preg_quote($word)] = $count; 
} 
preg_match_all("~".implode('|', array_keys($arr))."~", $text, $matches); 
$temp = array(); 
foreach($matches[0] as $match){ 
if(!in_array($match, $temp)){ 
$temp[$match] = $temp[$match] + 1; 
if($temp[$match] >= $arr[$word]) 
return true; 
} 
} 
return false; 
} 

$file = 'spam.txt'; 
$str = 'This string has cat, dog word'; 
if(is_spam($str, $file)) 
echo 'this is spam'; 
else 
echo 'this is not spam'; 

ab:3 
dog:3 
cat:2 
monkey:2

二、随机颜色生成器

二、随机颜色生成器

function randomColor() { 
    $str = '#'; 
    for($i = 0 ; $i < 6 ; $i++) { 
        $randNum = rand(0 , 15); 
        switch ($randNum) { 
            case 10: $randNum = 'A'; break; 
            case 11: $randNum = 'B'; break; 
            case 12: $randNum = 'C'; break; 
            case 13: $randNum = 'D'; break; 
            case 14: $randNum = 'E'; break; 
            case 15: $randNum = 'F'; break; 
        } 
        $str .= $randNum; 
    } 
    return $str; 
} 
$color = randomColor();
&lt;?php
$file = "http://koonk.comlogo.png";
$size = remote_filesize($url);
echo $size;
?&gt;

网络有人计算二种编制程序语言的特色,小编感觉也挺有道理的:

二、随机颜色生成器

function randomColor() { 
    $str = '#'; 
    for($i = 0 ; $i < 6 ; $i++) { 
        $randNum = rand(0 , 15); 
        switch ($randNum) { 
            case 10: $randNum = 'A'; break; 
            case 11: $randNum = 'B'; break; 
            case 12: $randNum = 'C'; break; 
            case 13: $randNum = 'D'; break; 
            case 14: $randNum = 'E'; break; 
            case 15: $randNum = 'F'; break; 
        } 
        $str .= $randNum; 
    } 
    return $str; 
} 
$color = randomColor();
function randomColor() { $str = ‘#‘; for($i = 0 ; $i < 6 ; $i++) { $randNum = rand; switch  { case 10: $randNum = ‘A‘; break; case 11: $randNum = ‘B‘; break; case 12: $randNum = ‘C‘; break; case 13: $randNum = ‘D‘; break; case 14: $randNum = ‘E‘; break; case 15: $randNum = ‘F‘; break; } $str .= $randNum; } return $str; } $color = randomColor(); 

三、从互联网下载文件

set_time_limit(0); 
// Supports all file types 
// URL Here: 
$url = 'http://somsite.com/some_video.flv'; 
$pi = pathinfo($url); 
$ext = $pi['extension']; 
$name = $pi['filename']; 

// create a new cURL resource 
$ch = curl_init(); 

// set URL and other appropriate options 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 
curl_setopt($ch, CURLOPT_AUTOREFERER, true); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

// grab URL and pass it to the browser 
$opt = curl_exec($ch); 

// close cURL resource, and free up system resources 
curl_close($ch); 

$saveFile = $name.'.'.$ext; 
if(preg_match("/[^0-9a-z._-]/i", $saveFile)) 
    $saveFile = md5(microtime(true)).'.'.$ext; 

$handle = fopen($saveFile, 'wb'); 
fwrite($handle, $opt); 
fclose($handle);
  1. 行使 imagebrick 进行 pdf 到图像的转变

    <?php
    $pdf_file = ‘./pdf/demo.pdf’;
    $save_to = ‘./jpg/demo.jpg’; //make sure that apache has permissions to write in this folder! (common problem)
    //execute ImageMagick command ‘convert’ and convert PDF to JPG with applied settings
    exec(‘convert “‘.$pdf_file.'” -colorspace RGB -resize 800 “‘.$save_to.'”‘, $output, $return_var);
    if($return_var == 0) { //if exec successfuly converted pdf to jpg

    print "Conversion OK";
    

    }
    else print “Conversion failed.”.$output;
    ?>

  2. 使用 tinyurl 生成短式网球站

    function get_tiny_url($url)
    {

    $ch = curl_init();  
    $timeout = 5;  
    curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);  
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);  
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);  
    $data = curl_exec($ch);  
    curl_close($ch);  
    return $data;  
    

    }

PHP 就是: Quick and Dirty

三、从网络下载文件

set_time_limit(0); 
// Supports all file types 
// URL Here: 
$url = 'http://somsite.com/some_video.flv'; 
$pi = pathinfo($url); 
$ext = $pi['extension']; 
$name = $pi['filename']; 

// create a new cURL resource 
$ch = curl_init(); 

// set URL and other appropriate options 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 
curl_setopt($ch, CURLOPT_AUTOREFERER, true); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

// grab URL and pass it to the browser 
$opt = curl_exec($ch); 

// close cURL resource, and free up system resources 
curl_close($ch); 

$saveFile = $name.'.'.$ext; 
if(preg_match("/[^0-9a-z._-]/i", $saveFile)) 
$saveFile = md5(microtime(true)).'.'.$ext; 

$handle = fopen($saveFile, 'wb'); 
fwrite($handle, $opt); 
fclose($handle);

三、从网络下载文件

四、Alexa/Google Page Rank

function page_rank($page, $type = 'alexa'){ 
    switch($type){ 
        case 'alexa': 
            $url = 'http://alexa.com/siteinfo/'; 
            $handle = fopen($url.$page, 'r'); 
        break; 
        case 'google': 
            $url = 'http://google.com/search?client=navclient-auto&ch=6-1484155081&features=Rank&q=info:'; 
            $handle = fopen($url.'http://'.$page, 'r'); 
        break; 
    } 
    $content = stream_get_contents($handle); 
    fclose($handle); 
    $content = preg_replace("~(n|t|ss+)~",'', $content); 
    switch($type){ 
        case 'alexa': 
            if(preg_match('~<div class="data (down|up)"><img.+?>(.+?) </div>~im',$content,$matches)){ 
                return $matches[2]; 
            }else{ 
                return FALSE; 
            } 
        break; 
        case 'google': 
            $rank = explode(':',$content); 
            if($rank[2] != '') 
                return $rank[2]; 
            else 
                return FALSE; 
        break; 
        default: 
            return FALSE; 
        break; 
    } 
} 
// Alexa Page Rank: 
echo 'Alexa Rank: '.page_rank('techug.com'); 
echo '
'; 
// Google Page Rank 
echo 'Google Rank: '.page_rank('techug.com', 'google');

语法:

Java 就是: Beauty and Slowly

四、Alexa/Google Page Rank

function page_rank($page, $type = 'alexa'){ 
switch($type){ 
case 'alexa': 
$url = 'http://alexa.com/siteinfo/'; 
$handle = fopen($url.$page, 'r'); 
break; 
case 'google': 
$url = 'http://google.com/search?client=navclient-auto&ch=6-1484155081&features=Rank&q=info:'; 
$handle = fopen($url.'http://'.$page, 'r'); 
break; 
} 
$content = stream_get_contents($handle); 
fclose($handle); 
$content = preg_replace("~(n|t|ss+)~",'', $content); 
switch($type){ 
case 'alexa': 
if(preg_match('~<div class="data (down|up)"><img.+?>(.+?) </div>~im',$content,$matches)){ 
return $matches[2]; 
}else{ 
return FALSE; 
} 
break; 
case 'google': 
$rank = explode(':',$content); 
if($rank[2] != '') 
return $rank[2]; 
else 
return FALSE; 
break; 
default: 
return FALSE; 
break; 
} 
} 
// Alexa Page Rank: 
echo 'Alexa Rank: '.page_rank('techug.com'); 
echo ' '; 
// Google Page Rank 
echo 'Google Rank: '.page_rank('techug.com', 'google');
set_time_limit; // Supports all file types // URL Here: $url = ‘http://somsite.com/some_video.flv‘; $pi = pathinfo; $ext = $pi[‘extension‘]; $name = $pi[‘filename‘]; // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // grab URL and pass it to the browser $opt = curl_exec; // close cURL resource, and free up system resources curl_close; $saveFile = $name.‘.‘.$ext; if(preg_match("/[^0-9a-z._-]/i", $saveFile)) $saveFile = md5.‘.‘.$ext; $handle = fopen; fwrite; fclose;

五、强逼下载文件

$filename = $_GET['file']; //Get the fileid from the URL 
// Query the file ID 
$query = sprintf("SELECT * FROM tableName WHERE id = '%s'",mysql_real_escape_string($filename)); 
$sql = mysql_query($query); 
if(mysql_num_rows($sql) > 0){ 
    $row = mysql_fetch_array($sql); 
    // Set some headers 
    header("Pragma: public"); 
    header("Expires: 0"); 
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
    header("Content-Type: application/force-download"); 
    header("Content-Type: application/octet-stream"); 
    header("Content-Type: application/download"); 
    header("Content-Disposition: attachment; filename=".basename($row['FileName']).";"); 
    header("Content-Transfer-Encoding: binary"); 
    header("Content-Length: ".filesize($row['FileName'])); 

    @readfile($row['FileName']); 
    exit(0); 
}else{ 
    header("Location: /"); 
    exit; 
}
&lt;?php
$url = "http://blog.koonk.com/2015/07/Hello-World";
$tinyurl = get_tiny_url($url);
echo $tinyurl;
?&gt;

Ruby 就是: Quick andBeauty

五、强逼下载文件

$filename = $_GET['file']; //Get the fileid from the URL 
// Query the file ID 
$query = sprintf("SELECT * FROM tableName WHERE id = '%s'",mysql_real_escape_string($filename)); 
$sql = mysql_query($query); 
if(mysql_num_rows($sql) > 0){ 
$row = mysql_fetch_array($sql); 
// Set some headers 
header("Pragma: public"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Content-Type: application/force-download"); 
header("Content-Type: application/octet-stream"); 
header("Content-Type: application/download"); 
header("Content-Disposition: attachment; filename=".basename($row['FileName']).";"); 
header("Content-Transfer-Encoding: binary"); 
header("Content-Length: ".filesize($row['FileName'])); 

@readfile($row['FileName']); 
exit(0); 
}else{ 
header("Location: /"); 
exit; 
}

四、Alexa/Google Page Rank

六、通过Email显示客户的Gravatar头像

 $gravatar_link = 'http://www.gravatar.com/avatar/' . md5($comment_author_email) . '?s=32';
  echo '<img src="'%20.%20$gravatar_link%20.%20'" />';
  1. youtube 下载链接生成器

Python 就是:Quick and Simple

相关文章

No Comments, Be The First!
近期评论
    功能
    网站地图xml地图