|
||
| Tarihçe PHP, ilk olarak 1990’lı yılların ortalarında Rasmus Lerdorf tarafından geliştirilmeye başlanmıştır. Lerdorf’un amacı kişisel bilgilerini internet üzerinden yayınlamaktı. O tarihteki teknolojide, günümüzdeki gibi gelişmiş web tasarım yazılımlarının bulunmamasından dolayı , kişisel web sayfası yapmak çok daha zordu. Buradan yola çıkarak, kişisel web sayfası yapmak için bir yazılım hazırladı ve adına Personal Home Page (PHP) adını verdi. PHP, Perl dili üzerine kurulu bir dil olarak geliştirilmeye başlanmıştır. PHP’ nin çok tutulması üzerine web tasarımcılarının çok ihtiyacı olan, yani form yoluyla ziyaretçiden gelen bilgileri işlemeyi sağlayan eklemeler yapılarak adına PHP/FI (Form Interpreter) adını aldı. Kimileri tarafından programın bu versiyonu PHP2 olarak adlandırıldı. 1995 yılının ortalarında PHP Lerdorf’un kurmuş olduğu bir grup tarafından daha da geliştirildi. Bu sefer Perl dilindeki fonksiyonlardan tamamen arındırılmış ve Object Oriented (Nesneye Dayalı) bir dil haline getirildi. Günümüzde PHP4 versiyonu geliştirilmiş durumdadır. PHP dili Linux gibi Açık Kaynak Kodlu bir dildir ve ücretsiz olarak dağıtılmaktadır ve geliştirilmektedir. Linux, Unix, Windows tabanlı işletim sistemlerinde çalışabilen versiyonları mevcuttur. PHP Nedir ? PHP bir script dilidir ve PHP ile yazılan kodlar bir editörde yazılıp PHP veya (kullanılan sürüme göre) PHP, PHP3 gibi uzantılı dosya olarak kaydedilir. PHP ile yazılan dosyalar derlenmezler (compile edilmezler). Sadece Web Server’da bu dilde yazılmış scriptleri yorumlayabilecek bir PHP yorumlayıcı program mevcuttur. Bu yorumlayıcı yazılmış PHP scriptlerini Web Server’ ın anlayabileceği bir biçime dönüştürür ve yollar. PHP ile yazılmış bir web sayfasına bağlandığınızda temel olarak aşağıdaki işlemler yapılmaktadır. - İstemci(Client) tarafından PHP dosyası bir tarayıcı (browser) ile çağrılır. - Web Server(Web Sunucu) dosya uzantısından bu isteğin bir PHP dosyası olduğunu algılar ve PHP yorumlayıcıya yollar. - PHP yorumlayıcısı ilgili dosya içindeki scriptleri çalıştırarak geriye döndürdüğü sonucu Web Server’ a tekrar gönderir. - Web Server’ a ulaştırılan sonuç İstemci(Client) tarafına HTML dosya olarak yollanır. PHP oyun programı yazmaya kadar bir çok amaca hitap edebilecek nitelikte bir dildir. Fakat konular içerisinde veritabanları üzerinde kayıt ekleme, silme, değiştirme, sorgulama işlemlerine yer verilecektir. Sonuç olarak PHP, HTML dilinin yapamadığı işlemleri yapabilmek, HTML olarak daha işlevsel sayfalar yapabilmek, Web Server’a bir takım işler yaptırmak gibi yararlar sağlayan bir programlama dilidir diyebiliriz. PHP Gereksinimleri PHP kullanabilmeniz için bazı yazılımlara ihtiyacınız vardır. Ders içerisinde PHP dilinin Windows tabanlı işletim sistemlerinde kullanılması anlatılacaktır. Bu yüzden gerekli yazılımların Windows tabanlı işletim sistemlerine nasıl kurulacağından ve çalıştırılacağından bahsedilecektir. - Windows’un bilgisayarınıza kurulu olduğunu varsayıyoruz. - Web Server : Web Server yapmış olduğunuz web sayfalarının internette gösterilebilmesini sağlayan bir yazılımdır. IIS, Apache, Xitami gibi birçok Web Server programı mevcuttur. Fakat biz Apache Server kullanacağız. - PHP4 : İlk başta bahsedildiği gibi PHP scriptlerinizin yorumlanabilmesi ve Web Server tarafından anlaşılabilmesi için, bir PHP yorumlayıcı programa ihtiyacınız olacaktır. PHP4 bu yorumlama işini yapacak programın adıdır. - Veritabanı : PHP dilini bir veritabanına kayıt ekleme, çıkarma, düzeltme ve sorgulama gibi işlemlerde kullanacağımızdan bir veritabanına ihtiyacımız olacaktır. Veritabanı olarak Progress derslerinde görmüş olduğunuz Progress veritabanını kullanacağız. - ODBC Driver : ODBC (Open Database Connectivity) bir veritabanına başka bir uygulamadan bağlanmayı sağlar. Her veritabanının kendine özel bir ODBC Driver’ ı mevcuttur. Bu yüzden Progress veritabanına bağlanmamızı sağlayacak bir ODBC Driver’ ına sahip olmamız gerekir. Klasöredeki Tüm Dosyaların Adını Sıralayın Bazen olurki keşke şu dosyalar 1.jpg 2.jpg (herşey olabilir) olsaydı dediğiniz zamanlar için bir php kodu. <? //Bu kod spy_force tarafından yazılmıştır. $a="a.php";//bu php dosyasının .php ile birlikte adı $klasor="/maillist/5.000.000-TR_rehber/";//resim yerine kendi klasörünüzü yazın $uzantı="txt";//Dosyanızın uzantısını yazın $sayac=1; $path = getcwd(); $dizin=$_SERVER['DOCUMENT_ROOT']; $dosya=$dizin.$klasor; $dh = opendir($path); while (($dir = readdir($dh)) !== false) { if ( $dir != "." && $dir != ".." ){ $file = fopen("$path/$dir", "r"); if ($file){ $dosyaadi=$sayac++.'.'.$uzantı;//Eğer dosyanız 1.uzantı 2.uzantı yerine farklı birşey yazmasını istiyorsanız burayı değiştirin (başına eklemek isterseniz $sayac++ önüne '' içinde arkasında olmasını isterseniz '.' yerine 'yamakistediğiniz.' şeklinde ekleyin if ($dir == $a) { rename($dosya.$dir,$dosya.$a); } else { rename($dosya.$dir,$dosya.$dosyaadi); echo "$dir $dosyaadi olarak değiştirildi. <br />"; } } } } closedir($dh); ?> Google Pagerank Script Google Pagerank Script <?php Class GooglePR { //Public vars var $googleDomains = Array("toolbarqueries.google.com","Linklerin Görülmesine Izin Verilmiyor Linki Görebilmek Için Üye Ol veya Giris Yap","toolbarqueries.google.com.tr","Linklerin Görülmesine Izin Verilmiyor Linki Görebilmek Için Üye Ol veya Giris Yap","toolbarqueries.google.de","Linklerin Görülmesine Izin Verilmiyor Linki Görebilmek Için Üye Ol veya Giris Yap", "64.233.187.99", "72.14.207.99"); var $debugResult = Array(); var $userAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204"; var $cacheDir = ""; var $maxCacheAge = 86400; // = 24h (yes, in seconds) var $useCache = false; var $debug = false; //Private vars var $GOOGLE_MAGIC = 0xE6359A60; var $PageRank = -1; var $cacheExpired = false; function GetPR($url,$forceNoCache = false) { $total_exec_start = $this->microtimeFloat(); $result=array("",-1); if (($url.""!="")&&($url.""!="http://")) { $this->debugRes("url", $url); $this->cacheDir = (strlen($this->cacheDir) > 0)? $this->cacheDir:dirname(__FILE__)."/prcache/"; $this->cacheDir .= (substr($this->cacheDir,-1) != "/")? "/":""; // check for protocol $url_ = "info:".((substr(strtolower($url),0,7)!="http://")? "http://".$url:$url); $host = $this->googleDomains[mt_rand(0,count($this->googleDomains)-1)]; $target = "/search"; $querystring = sprintf("client=navclient-auto&ch=6%u&features=Rank&q=",$this->GoogleCH($this->strord($url_))); $querystring .= urlencode($url_); $contents=""; $this->debugRes("host", $host); $this->debugRes("query_string", $querystring); $this->debugRes("user_agent", $this->userAgent); $query_exec_start = $this->microtimeFloat(); if ($forceNoCache == true) { $this->debugRes("force_no_cache", "true"); } elseif ($contents = $this->readCacheResult($url)) { $this->debugRes("read_from_cache", "true"); } else { $this->cacheExpired = true; } // let's get ranking if (strlen(trim($contents)) == 0) if (@function_exists("curl_init")) { // allways use curl if available for performance issues $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://".$host.$target."?".$querystring); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent); if (!($contents = trim(@curl_exec($ch)))) { $this->debugRes("error","curl_exec failed"); } curl_close ($ch); $this->debugRes("method", "curl"); } else { $this->debugRes("error","curl not installed"); // use fsockopen as secondary method, to submit user agent if ($socket = @fsockopen($host, "80", $errno, $errstr, 30)) { $request = "GET $target?$querystring HTTP/1.0\r\n"; $request .= "Host: $host\r\n"; $request .= "User-Agent: ".$this->userAgent."\r\n"; $request .= "Accept-Language: en-us, en;q=0.50\r\n"; $request .= "Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66\r\n"; $request .= "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1\r\n"; $request .= "Connection: close\r\n"; $request .= "Cache-Control: max-age=0\r\n\r\n"; stream_set_timeout ( $socket,10); fwrite( $socket, $request ); $ret = ''; while (!feof($socket)) { $ret .= fread($socket,4096); } fclose($socket); $contents = trim(substr($ret,strpos($ret,"\r\n\r\n") + 4)); $this->debugRes("method", "fsockopen"); } else { $this->debugRes("error","fsockopen failed"); // this way could cause problems because the Browser Useragent is not set... if ($contents = trim(@file_get_contents("http://".$host.$target."?".$querystring))) { $this->debugRes("method", "file_get_contents"); } else { $this->debugRes("error","file_get_contents failed"); } } } if ($this->cacheExpired == true) $this->updateCacheResult($url,$contents); $this->debugRes("query_exec_time",$this->microtimeFloat() - $query_exec_start); $result[0]=$contents; // Rank_1:1:0 = 0 // Rank_1:1:5 = 5 // Rank_1:1:9 = 9 // Rank_1:2:10 = 10 etc $p=explode(":",$contents); if (isset($p[2])) $result[1]=$p[2]; } if($result[1] == -1) $result[1] = 0; $this->PageRank =(int)$result[1]; $this->debugRes("total_exec_time", $this->microtimeFloat() - $total_exec_start); $this->debugRes("result", $result); return $this->PageRank; } function debugRes($what,$sowhat) { if($this->debug == true) { $debugbt = debug_backtrace(); $what = trim($what); $sowhat = trim($sowhat) . " (Line : ".$debugbt[0]["line"].")"; if ($what == "error") { $this->debugResult[$what][] = $sowhat; } else { $this->debugResult[$what] = $sowhat; } } } function microtimeFloat() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } function readCacheResult($url) { if ($this->useCache != true) { return false; } if (!is_dir($this->cacheDir)) { $this->debugRes("error","please create {$this->cacheDir}"); return false; } $urlp = parse_url($url); $host_ = explode(".",$urlp["host"]); $path_ = (strlen($urlp["query"])>0)? urlencode($urlp["path"].$urlp["query"]):"default"; $cache_file = $this->cacheDir; for ($i = count($host_)-1;$i>=0;$i--) { $cache_file .= $host_[$i]."/"; } $cache_file .= $path_; $this->debugRes("cache_file", $cache_file); if (file_exists($cache_file)) { $mtime = filemtime($cache_file); if (time() - $mtime > $this->maxCacheAge) { $this->debugRes("cache", "expired"); $this->cacheExpired = true; return false; } else { $this->cacheExpired = false; $this->debugRes("cache_age", time() - $mtime); return file_get_contents($cache_file); } } $this->debugRes("error","cache file not exists (reading)"); return false; } function updateCacheResult($url,$content) { if ($this->useCache != true) { return false; } if (!is_dir($this->cacheDir)) { $this->debugRes("error","please create {$this->cacheDir}"); return false; } $urlp = parse_url($url); $host_ = explode(".",$urlp["host"]); $path_ = (strlen($urlp["query"])>0)? urlencode($urlp["path"].$urlp["query"]):"default"; $cache_file = $this->cacheDir; for ($i = count($host_)-1;$i>=0;$i--) { $cache_file .= $host_[$i]."/"; } $cache_file .= $path_; if (!file_exists($cache_file)) { $this->debugRes("error","cache file not exists (writing)"); $cache_file_tmp = substr($cache_file,strlen($this->cacheDir)); $cache_file_tmp = explode("/",$cache_file_tmp); $cache_dir_ = $this->cacheDir; for ($i = 0;$i<count($cache_file_tmp)-1;$i++) { $cache_dir_ .= $cache_file_tmp[$i]."/"; if (!file_exists($cache_dir_)) { if (!@mkdir($cache_dir_,0777)) { $this->debugRes("error","unable to create cache dir: $cache_dir_"); //break; } } } if (!@touch($cache_file)) $this->debugRes("error","unable to create cache file"); if (!@chmod($cache_file,0777)) $this->debugRes("error","unable to chmod cache file"); } if (is_writable($cache_file)) { if (!$handle = fopen($cache_file, 'w')) { $this->debugRes("error", "unable to open $cache_file"); return false; } if (fwrite($handle, $content) === FALSE) { $this->debugRes("error", "unable to write to $cache_file"); return false; } fclose($handle); $this->debugRes("cached", date("Y-m-d H:i:s")); return true; } $this->debugRes("error", "$cache_file is not writable"); return false; } function zeroFill($a, $b) { $z = hexdec(80000000); if ($z & $a) { $a = ($a>>1); $a &= (~$z); $a |= 0x40000000; $a = ($a>>($b-1)); } else { $a = ($a>>$b); } return $a; } function mix($a,$b,$c) { $a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,13)); $b -= $c; $b -= $a; $b ^= ($a<<Karizmatik; $c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,13)); $a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,12)); $b -= $c; $b -= $a; $b ^= ($a<<16); $c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,5)); $a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,3)); $b -= $c; $b -= $a; $b ^= ($a<<10); $c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,15)); return array($a,$b,$c); } function GoogleCH($url, $length=null) { if(is_null($length)) { $length = sizeof($url); } $a = $b = 0x9E3779B9; $c = $this->GOOGLE_MAGIC; $k = 0; $len = $length; while($len >= 12) { $a += ($url[$k+0] +($url[$k+1]<<Karizmatik +($url[$k+2]<<16) +($url[$k+3]<<24)); $b += ($url[$k+4] +($url[$k+5]<<Karizmatik +($url[$k+6]<<16) +($url[$k+7]<<24)); $c += ($url[$k+8] +($url[$k+9]<<Karizmatik +($url[$k+10]<<16)+($url[$k+11]<<24)); $mix = $this->mix($a,$b,$c); $a = $mix[0]; $b = $mix[1]; $c = $mix[2]; $k += 12; $len -= 12; } $c += $length; switch($len) /* all the case statements fall through */ { case 11: $c+=($url[$k+10]<<24); case 10: $c+=($url[$k+9]<<16); case 9 : $c+=($url[$k+8]<<Karizmatik; /* the first byte of c is reserved for the length */ case 8 : $b+=($url[$k+7]<<24); case 7 : $b+=($url[$k+6]<<16); case 6 : $b+=($url[$k+5]<<Karizmatik; case 5 : $b+=($url[$k+4]); case 4 : $a+=($url[$k+3]<<24); case 3 : $a+=($url[$k+2]<<16); case 2 : $a+=($url[$k+1]<<Karizmatik; case 1 : $a+=($url[$k+0]); /* case 0: nothing left to add */ } $mix = $this->mix($a,$b,$c); /*-------------------------------------------- report the result */ return $mix[2]; } //converts a string into an array of integers containing the numeric value of the char function strord($string) { for($i=0;$i<strlen($string);$i++) { $result[$i] = ord($string{$i}); } return $result; } } $gpr = new GooglePR(); echo $gpr->GetPR("Linklerin Görülmesine Izin Verilmiyor Linki Görebilmek Için Üye Ol veya Giris Yap"); ?> |
||
| Dost Sitelerimiz | |
|
|
|
| Dost Sitelerimiz | |
| Arma Dizayn - Dijital Darbe - Z.K.U.D Blogcu - SosyeteForum - SHeZoFReN - SHeZoFReN - Ayna Grubum - Rusça Gülerek - Deliperi - SanalKaos - Mevzu Alemi - kudRet* - PayLaSiM-TuRK - Graphic-Turk.Com - SMF SeO Destek | |