<?
# @yns - 26 kasim 2005 , 05.26
function uzantiBul($isim) {
    $dizi = explode('.',$isim);
    $eleman = count($dizi) -1;
    $uzanti = $dizi["$eleman"];
    echo $uzanti;
    // return $uzanti;
}
 
uzantiBul("asdsad.asd.php"); # çıktı : php

?>

Dosyalanın uzantısını bulmaya yarayan bir fonksiyon. bu fonksiyonda çok lazım olabilir.

 
<?
// axion
$fp=fopen($dosya,'r');
$canimdoyaicerigim="";
 
while (!feof($fp))
{
$canimdoyaicerigim.=fgets($fp,4096);
}
?>

Dosya içeriğini değişkene aktarabileceğimiz bir fonksiyon.

 
<? 
$server    = 'ftp://ftp.example.com'; 
$u_name    = 'username'; 
$p_word    = 'password'; 
$up_file   = 'file_to_upload.ext'; 
$srvr_path = '/path_to/upload_directory/'; 
$new_name  = 'uploade_file.ext'; 
// Append path & uploaded file name to server name, pass with CURLOPT_URL. 
$url = $server . $srvr_path . $new_name; 
// fopen() upload file for handle to pass with CURLOPT_INFILE. 
$fp = @fopen($up_file, 'r'); 
if (!$fp) { 
    echo 'Failed to open upload file.' . '<br />'; 
    exit; 
} 
if (!($ch = curl_init())) { 
    echo 'Unable to allocate resource.' . '<br />'; 
    exit; 
}      
curl_setopt($ch, CURLOPT_URL, $url);   
curl_setopt($ch, CURLOPT_USERPWD, $u_name . ':' . $p_word); 
// If true w/CURLOPT_RETURNTRANSFER server output returned by curl_exec(). 
// (Usually no output w/FTP, anyway.) 
// If false, curl_exec() will return true on success. 
// Either way curl_exec() returns false on failure. 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   
curl_setopt($ch, CURLOPT_UPLOAD, true);   
curl_setopt($ch, CURLOPT_INFILE, $fp);   
// Pass true w/CURLOPT_TRANSFERTEXT for ascii, false for binary. 
curl_setopt($ch, CURLOPT_TRANSFERTEXT, true);   
// File size w/CURLOPT_INFILESIZE must be accurate for clean transfer. 
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($up_file));   
// Everything's ready, now curl_exec() does it all. 
$curl_return = curl_exec($ch); 
if ($curl_return === false) { 
    // Show failure info. 
    echo 'curl_exec() failed.' . '<br />'; 
    echo 'curl_errno() = ' . curl_errno($ch) . '<br />'; 
    echo 'curl_error() = ' . curl_error($ch) . '<br />'; 
} else {   
    // Show success info. 
    echo 'curl_exec() succeeded.' . '<br />'; 
    echo '<br /><b>curl_getinfo()</b>' . '<br />'; 
    foreach (curl_getinfo($ch) as $key => $value) { 
        echo $tab . $key . ' => ' . $value . '<br />'; 
    } 
} 
curl_close($ch); 
?>

Curl ile FTP upload Fonksiyonu çok güzel ve bana sürekli lazim olan bir fonksiyon

 
<? 
// author: Louai Munajim 
// website: http://elouai.com 
// date: 2004/Apr/18 
function bb2html($text) 
{ 
  $bbcode = array("<", ">", 
                "[list]", "[*]", "[/list]", 
                "[img]", "[/img]", 
                "[b]", "[/b]", 
                "[u]", "[/u]", 
                "[i]", "[/i]", 
                '[color="', "[/color]", 
                "[size=\"", "[/size]", 
                '[url="', "[/url]", 
                "[mail=\"", "[/mail]", 
                "[code]", "[/code]", 
                "[quote]", "[/quote]", 
                '"]'); 
  $htmlcode = array("&lt;", "&gt;", 
                "<ul>", "<li>", "</ul>", 
                "<img src=\"", "\">", 
                "<b>", "</b>", 
                "<u>", "</u>", 
                "<i>", "</i>", 
                "<span style=\"color:", "</span>", 
                "<span style=\"font-size:", "</span>", 
                '<a href="', "</a>", 
                "<a href=\"mailto:", "</a>", 
                "<code>", "</code>", 
                "<table width=100% bgcolor=lightgray><tr><td bgcolor=white>", "</td></tr></table>", 
                '">'); 
  $newtext = str_replace($bbcode, $htmlcode, $text); 
  $newtext = nl2br($newtext);//second pass 
  return $newtext; 
} ?>

Basit bir bbcode fonksiyonu

 
<?
/* 
* CURL Downloader  
* Version 1.0      
* By Hackerdragons 
* Hackerpowers.com a.k.a Turkgate.com 
*/
error_reporting(0);
function utime (){
$time = explode( " ", microtime());
$usec = (double)$time[0];
$sec = (double)$time[1];
return $sec + $usec;
}
if(!function_exists('curl_init')){
die("cURL Extension, PHP'de Yüklü Değildir. Lütfen Yükleyin.");
}
$downloaddir = "./downloaded";
if(!is_dir($downloaddir)){
if(!mkdir( $downloaddir )){
die("Download Dizini Yok ve Oluşturulamıyor. Lütfen Manuel Olarak Oluşturun, ve CHMOD 777 Atın.");
} else {
chmod($downloaddir, "0777") or die("CHMOD 777 Yapılamadı. Manuel Olarak Yapınız!");
}
}
if(isset($_GET['submit'])){
echo"<h3>Turkgate a.k.a HP cURL Dosya İndirici</h3><hr>";
$file = $_POST['file'];
if($file[4] != ":" || $file[5] != "/" || $file[6] != "/" ) {
$file = "http://".$file;
}
if($file[0].$file[1].$file[2].$file[3] == "file"){
die("Bu Script, Local URL'ler İle Çalışmak Üzere Ayarlanmamıştır.");
}
$do = parse_url($file);
$xx = $do['path'];
$xy = pathinfo($xx);
$locfn = $xy['basename'];
$locpth = $downloaddir."/".$locfn;
if(file_exists($locpth)){
unlink($locpth) or die($locpath." Mevcut ve Dosya Overwrite Edilemiyor, Dosya Adını Değiştirin yada Silin.");
echo $locpth."Dosyası Mevcut. Overwrite Ediliyor.<br>";
}
flush();
$start = utime(); 
$curl = curl_init($file);
ob_start();
curl_exec($curl);
$contents = ob_get_contents();
ob_end_clean();
$handle = fopen($locpth, "a+");
fwrite($handle, $contents);
fclose($handle);
$end = utime(); 
$run = $end - $start; 
echo"Dosyanız, Download Başarılı Oldu Ise, ".$locpth." Dosyasına Kayıt Edildi.<br>";
echo round(filesize($locpth), 0)."byte Dosya, " . round($run, 0) . " Saniyede İndirildi(".round(filesize($locpth)/round($run, 0), 0)."bps).<br>";
echo"<hr>By Hackerdragons.[2004]<br>&copy;2004 Coderturk.com.<br>Released Under GNU/GPL.";
} else {
?>
<h3>Turkgate a.k.a. HP cURL Dosya İndirici</h3><hr>
<form action='<? echo $_SERVER['PHP_SELF']; ?>?submit=1' method='post'>
Dosya URL'si Giriniz: <input type='text' name='file'><input type='submit' name='submit' value='Download'><input type='reset' value='Sıfırla'>
</form>
<?
echo"<hr>By Hackerdragons.[2004]<br>&copy;2005 Turkgate.com a.k.a Hackerpowers.com & Coderturk.com.<br>Released Under GNU/GPL.";
}
?>

Basit bir curl ile downloader fonksiyonu çok güzel bir fonksiyon herkese lazim olacaktir

 
<?php
function check_back_link($remote_url, $your_link) {
    $match_pattern = preg_quote(rtrim($your_link, "/"), "/");
    $found = false;
    if ($handle = @fopen($remote_url, "r")) {
        while (!feof($handle)) {
            $part = fread($handle, 1024);
            if (preg_match("/<a(.*)href=[\"']".$match_pattern."(\/?)[\"'](.*)>(.*)<\/a>/", $part)) {
                $found = true;
                break;
            }
        }
        fclose($handle);
    }
    return $found;
}
// örnek:
//if (check_back_link("http://www.hedefsite.com", "http://www.siteniz.com")) echo "Link bulundu.";
?>
<?php
 
 
/* 
     |*****************************************************************************| 
     |    Proje Adi : Multiupload Formu                                            | 
     |    Dosya Adi : index.php                                                    | 
     |    Aciklama  : Kullanım açıklamalarını okuyunuz                             | 
     |                                                                             | 
     |-----------------------------------------------------------------------------| 
     |               Kodlama                                                       | 
     |-----------------------------------------------------------------------------| 
     |        Kodlama (c) 2010 by ksabitk                                          | 
     |                                                                             | 
     |-----------------------------------------------------------------------------| 
     |                                                                             | 
     |       Kullanım:                                                             | 
     |   kodu istediğiniz dizine atın ve bu dizin içinde                           |    
     |   resimler adında klasör açıp, klasöre CHMOD 777 değeri verin               | 
     |                                                                             | 
     |*****************************************************************************| 
*/ 
 
 
if(empty ($_POST['gonder']) ) {
 
?>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" method="post">
 
<input type="file" name="resimler[]"><br>
<input type="file" name="resimler[]"><br>
<input type="file" name="resimler[]"><br>
<input type="file" name="resimler[]"><br>
 
 
 
<input type="submit" name="gonder" value="gonder">
</form>
<p><a href="mailto:ksabitk@hotmail.com">ksabitk@hotmail.com</a> 
 
 
<?php
 
 
 
}else{
 
 
/* resimler klasörüde dahil tam url yi aşağıya yaz */
     $a0 = "resimler";  
 
 
     $a = $_FILES['resimler']['name'][0];
     $b = $_FILES['resimler']['name'][1];
     $c = $_FILES['resimler']['name'][2];
     $d = $_FILES['resimler']['name'][3];
 
 
if($a!=="") { $x=array($a); } 
if($b!=="") { array_push($x,$b); } 
if($c!=="") { array_push($x,$c);} 
if($d!=="") { array_push($x,$d); } 
 
 
 
$a=count($x);
 
 
 
/* yüklenen resimlere 1 arttırarak isim ver ( veritabanı için lazım olabilir)*/
$m=0;
$m=$n+1; 
$n=1;
 
 
$i=0;
 
echo "<a href='index.php'>Yükleme sayfasına dön</a><br><a href='mailto:ksabitk@hotmail.com'>ksabitk@hotmail.com</a>"; 
 
while ($i<$a) {  
 
if(is_uploaded_file($_FILES['resimler']['tmp_name'][$i]))
{
if(move_uploaded_file($_FILES['resimler']['tmp_name'][$i],"resimler/".$x[$i]))
{
 
 
 
$cikti1="<img src='".$a0."/".$x[$i]."' name='".$n++."'><br>";
$cikti2="<input type='text' name='".$n++."' value='".$a0."/".$x[$i]."' size='80' onmouseover='select()'><br>";
 
echo "<hr>\n<center>\n".$cikti1."\n<br>";
echo "\n".$cikti2."\n<hr>\n</center>\n";
 
 
}
else
{
echo "hata!<br><a href='index.php'>Geri Dön</a>";
}
}
$i++;
}
}
?>

Küçük bir örnek scripttir. Çok işe yarayabileceğini düşünüyorum.

 
<?
function file_size($file){ 
$size=filesize($file); 
if($size >= 1073741824){ 
$size=round($size/1073741824)."Gb"; 
} 
elseif($size >= 1048576){ 
$size=round($size/1048576)."Mb"; 
} 
elseif($size >= 1024){ 
$size=round($size/1024)."Kb"; 
}else{ 
$size=$size. "b"; 
} 
echo "File size: <b>$size</b>" ; 
} 
 
file_size($file="index.php");  ?>

Dosyanın Boyutunu hesaplama Fonksiyonu bazen çok işe yarayabiliyor.

 
<?
/*
    |*****************************************************************************|
     |    Proje Adi : Arkadaşa tavsiye et Formu                                    |
     |    Dosya Adi : tavsiye.php                                                  |
     |    Aciklama  : İletisim Formu                                               |
     |                                                                             |
     |-----------------------------------------------------------------------------|
     |               Kodlama                                                       |
     |-----------------------------------------------------------------------------|
     |        Kodlama (c) 2009 by ksabitk                                          |
     |        ksabitk@hotmail.com                                                  |
     |                                                                             |
     |-----------------------------------------------------------------------------|
     |                                                                             |
     |       Kullanım:                                                             |
     |                tavsiye.php adıyla kaydedin                                  |
     |                tavsiye edilmesini istediğiniz sayfalarınıza                 |
     |                <? include('tavsiye.php');?> yazarak çekin                   |
     |                                                                             |
     |                                                                             |
     |       Bilgi:                                                                |
    |                $_SERVER['HTTP_REFERER'] değişkeni sayesinde include         |
     |                ettiğiniz sayfanın kaynak url'sini alır ve gönderilen        |
     |                maile ekler.                                                 |
     |                                                                             |
    |                                                                             |
     |*****************************************************************************|
*/
?>
<form action="?gonder" method="post">
 
<TABLE>
 
<TR>
 
    <TD>Tavsiye Et</TD>
 
    <TD></TD>
 
</TR>
 
<TR>
 
    <TD>Adınız</TD>
 
    <TD><INPUT TYPE="text" NAME="mailfromname" value=""></TD>
 
</TR>
 
<TR>
 
    <TD>e-Mailiniz</TD>
 
    <TD><INPUT TYPE="text" NAME="mailfrom" value=""></TD>
 
</TR>
 
<TR>
 
    <TD>Arkadaş email</TD>
 
    <TD><INPUT TYPE="text" NAME="rcpt"></TD>
 
</TR>
 
<TR>
 
    <TD> </TD>
 
    <TD><input name="send" type="submit" value="Gönder"></TD>
 
</TR>
 
</TABLE>
 
</form>
 
<?
 
set_magic_quotes_runtime(0);
 
if(isset($_GET['gonder'])) {
 
$subject   = "Bir Tavsiyeniz Var";
 
$fromname  = $_POST['mailfromname'];
 
$from      = $_POST['mailfrom'];
 
$to        = $_POST['rcpt'];
 
$data      = "Arkadaşınız ".$_POST['mailfromname']." bunu çok beğendi ve görmenizi istiyor <a target='_blank' href='".$_SERVER['HTTP_REFERER']."'>Tıklayın</a> ve görün...";
 
$data      = stripslashes($data);
 
$eol       = "\nMIME-Version: 1.0\nContent-type: text/html; charset=windows-1254";
 
$headers   = 'From: '.$fromname.'<'.$from.'>'.$eol;
 
// ve mail gider
 
mail($to, $subject, $data, $headers);
 
echo "Bizi tavsiye ettiğiniz için teşekkür ederiz<br>Tavsiye gönderilen mail : $to.";
 
}
 
?>

Örnek bir arkadaşına tavsiye et fonksiyonu

<?php
// Bu bölüm:Çağıralacak olan sayfanın kodlarını içeren bölüm
// Bu sayfayı alt_index.php olarak kaydedelim
 echo "Burası başlık sayfası bölümüdür.<br>";
?> 
<?php
//Bu bölüm de Belirlediğimiz Ana Sayfamız.
//Bu sayfayı index.php olarak kaydedelim.
 echo "<b>Şu an ana sayfadasınız.</b><br>"; 
include ("alt_index.php");
echo "<b>Üstteki veri,Yönlendirmedir:)</b>";
?>

include istediğimiz php sayfada yada bölgede çağırabiliriz reklam olarak vs kullanılabilir.