Web Site Adresine Erişim Kontrol Sınıfı

PHP
38 lines
<?php
class adresTest{
var $vektor = array();
function __construct($time){
set_time_limit($time);
}
function ekle($adres){
$this->vektor[] = $adres;
}
function listele(){
$list = $this->vektor;
for($i = 0; $i < count($list);$i++){
$this->test($list[$i]);
}
}
function test($adres) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $adres);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if(parse_url($adres, PHP_URL_SCHEME) == "https"){
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
$cikti = curl_exec($ch);
$bilgi = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$hatalar = array("0","400", "401", "402", "403", "404", "405", "406", "407", "408", "409", "410", "411", "412", "413", "414", "415", "500", "501", "502", "503", "504", "505");
if(in_array($bilgi, $hatalar)) {
echo "<a href=\"".$adres."\" target=\"_blank\">".$adres."</a> <b>($bilgi) Sayfaya Erişilemiyor!</b><br />";
}else{
echo "<a href=\"".$adres."\" target=\"_blank\">".$adres."</a> <b>($bilgi) Geçerli Sayfa.</b><br />";
}
curl_close($ch);
}
}
$test = new adresTest(0);
$test->ekle('http://www.google.com.tr');
$test->ekle('https://www.ulusanyazilim.com/feed');
$test->listele();
?>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Çıktısı

Markdown
2 lines
http://www.google.com.tr (200) Geçerli Sayfa.
https://www.ulusanyazilim.com/feed (301) Geçerli Sayfa.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

Sayfa Performans Sınıfı

PHP
32 lines
<?php
class performans{
var $basla;
var $bitir;
var $toplam;
function getir(){
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = doubleval($mtime[1]) + doubleval($mtime[0]);
return $mtime;
}
function basla(){
$this->basla = $this->getir();
}
function bitir(){
$this->bitir = $this->getir();
}
function yazdir(){
$basla = $this->basla;
$bitir = $this->bitir;
$toplam = sprintf("%.4f", abs($basla - $bitir));
return $toplam;
}
}
$p = new performans();
$p->basla();
for($x=0;$x<3300000;$x++)if($x%1000000 == 0)echo $x;
$p->bitir();
echo("<br>Sayfa toplam " . $p->yazdir() . " saniyede yüklendi");
?>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Çıktısı

Markdown
2 lines
0100000020000003000000
Sayfa toplam 1.0591 saniyede yüklendi
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX