Bu scripti bir sisteme depo olarak kullanmak için kodlamıştım.
Script depo olarak mysql kullanıyor.
Upload edilen dosyaların formdan gelen binary datası Gzdeflate fonksiyonu ile 9 uncu derece sıkıştırılıyor, bu data mysqle kodlanıyor ve Gzinflate ile compresslenmiş veri decode edilip site içinde kullanılıyor (ör: download),
bunlar anasayfada tablolarla listeleniyor ve istendigi an tıklanak indirililebiliyor.
Ve istendiği andada sql phpmyadminden çekilip dosyalar sql olarak yedeklenebiliyoır.
Her hangi bir güvenlik geliştirmesi yapmadım. local kullanım için tasarlamıstım zaten.


Liste olarak script özellikleri:
  • dosya upload işlemi
  • dosya download işlemi
  • dosya silme işlemi
  • dosyaları tabloda ad ve boyuta göre sıralama işlemi.
  • $_GET ile admin login (basitce)
  • Gzdeflate ile presslenip dbye yazma ve daha az mysql alanı kullanma
<?php
// Mr.Kurtbey mysql depo script v1.0 beta2 
// Output Buffering Başlangıcı
ob_start();
/**
 *  Session Başlangıcı
 */
//session_start();
/**
 * Site Sabit Değişkenleri
 */
define("ANASAYFA","index.php");
/**
 * Veritabanı Sabit Değişkenleri
 */
define("DB_HOST","localhost");
define("DB_USER","root");
define("DB_PASS","12345678");
define("DB_NAME","depo");
define("DB_CHAR","latin5");
/**
 * Sayfa sıkıştırma
 */
$compress = TRUE;
/**
 * Admin Login - Logout Kontrol
 */
if($_GET['admin'] == 'login') {
	$adminpass = '12345678';
	if($adminpass == $_GET['pass']) {
		setcookie("admin","login",time()+3600);
		header("location: ".ANASAYFA);
	}
}
elseif($_GET['admin'] == 'logout') {
	setcookie("admin","");
	header("location: ".ANASAYFA);
}
//================== [ Upload Sınıfı ] ==================
class DosyaUpload {
	/**
     * Dosya Adi Fonksiyonu Değişkenleri
     */
	var $ExplodePostValue;
	var $ExplodedPostValue;
	var $CountExplodedPostValue;
	/**
     * Veritabanı Fonksiyonu Değişkeneri
     */
	var $db_host    = DB_HOST;
	var $db_user    = DB_USER;
	var $db_pass    = DB_PASS;
	var $db_name    = DB_NAME;
	var $db_char    = DB_CHAR;
	var $Connection;
	var $DbCharset;
	var $SelectDb;
	/**
     * Veritabanı Bağlantı Fonksiyonu
     */
	function DbConnect($db_host,$db_user,$db_pass,$db_name,$db_char)
	{
		$this->Connection = mysql_connect($this->db_host,$this->db_user,$this->db_pass);
		$this->SelectDb = mysql_select_db($this->db_name);
		$this->DbCharset = mysql_query('SET NAMES '.$this->db_char);
		return $this->Connection;
	}
	/**
     * Veritabanı Bağlantı Kapatma Fonksiyonu
     */
	function DbClose()
	{
		return mysql_close();
	}
	/**
     * Dosya Adı Alma Fonksiyonu
     */
	function Ad($veri_giris)
	{
		$this->ExplodePostValue = explode("\\",$veri_giris);
		$this->CountExplodedPostValue = count($this->ExplodePostValue)-1;
		$this->ExplodedPostValue = $this->ExplodePostValue[$this->CountExplodedPostValue];
		return $this->ExplodedPostValue;
	}
	/**
     * Dosya Adı Düzeltme Fonksiyonu
     */
	function AdEdited($veri_giris)
	{
		$this->AdEditedExplode = explode(".",$this->ad($veri_giris));
		$this->AdEditedExplodeCount = count($this->AdEditedExplode);
		for($i=0;$i<$this->AdEditedExplodeCount-1;$i++){
			$this->AdEditedTotal.= $this->AdEditedExplode[$i].".";
		}
		$this->AdEditedStrlen = strlen($this->AdEditedTotal)-1;
		$this->AdEdited = ucwords(str_replace(array("_","\\","/","<",">",'$'),array(" ","","","","",""),substr($this->AdEditedTotal,0,$this->AdEditedStrlen)));
		return $this->AdEdited;
	}
	/**
     * Dosya Tipi Alma Fonksiyonu
     */
	function Tip($veri_giris)
	{
		$this->DosyaTip = filetype($veri_giris);
		return $this->DosyaTip;
	}
	/**
     * Dosya Boyutu Alma Fonksiyonu
     */
	function Boyut($veri_giris)
	{
		$this->DosyaBoyut = filesize($veri_giris);
		return $this->DosyaBoyut;
	}
	/**
     * Dosya Verisini Alma Fonksiyonu
     */
	function Veri($veri_giris)
	{
		if($GLOBALS['press'] == FALSE) {
			$this->DosyaVeri = addslashes(file_get_contents($veri_giris));
		} else{
			$this->DosyaVeri = $veri_giris;
		}
		return $this->DosyaVeri;
	}
	/**
     * Dosya Silme Fonksiyonu
     */
	function Sil($tablo_adi,$sutun_adi,$veri_giris)
	{
		$this->DosyaSil = mysql_query("Delete From {$tablo_adi} Where {$sutun_adi} = '{$veri_giris}' ");
		return $this->DosyaSil;
	}
	/**
     * Bu Scriptin İsmini Öğrenen Fonksiyon
     */
	function ScriptName()
	{
		$this->ScriptNameExplode = explode("\\",__FILE__);
		$this->ScriptNameExplodeCount = count($this->ScriptNameExplode)-1;
		$this->ScriptName = $this->ScriptNameExplode[$this->ScriptNameExplodeCount];
		return $this->ScriptName;
	}
}
echo'
    <style>a{color:red;font:bold 10px verdana;text-decoration:underline;}a:hover{color:orange}</style>
    <body bgcolor="#eeeeee">
';
//Class Başlangıcı
$dosya = new DosyaUpload;
// Veritabanı Bağlantısı
$dosya->DbConnect("localhost","root","12345678","depo","latin5");
//================== [Download] ==================
if($_GET['download']) {
	$download_sql_betik = "select data from dosya where ad='".$_GET['download']."'";
	$download_sql = mysql_query($download_sql_betik);
	$download_sorgu = mysql_fetch_array($download_sql);
	header("Content-Disposition: attachment; filename=".$_GET['download']);
	if($compress == FALSE) {
		echo $download_sorgu['data'];
	} else{
		echo gzinflate($download_sorgu['data']);
	}
	exit();
}
//================== [Silme İşlemi] ==================
elseif($_GET['Dosya_Sil']) {
	$dosya->Sil("dosya","id",$_GET['Dosya_Sil']);
	header("location: ".ANASAYFA);
}
//================== [Upload] ==================
elseif($_POST['yolla']) {
	if($compress == FALSE) {
		$POST_VERI = $_POST['dosya'];
	} else{
		$dosya_icerik = file_get_contents($_POST['dosya']);
		$presle = addslashes(gzdeflate($dosya_icerik,9));
		$POST_VERI = $presle;
	}
	if( !mysql_query("insert into dosya(ad,boyut,aciklama,data) values('".$dosya->Ad($_POST['dosya'])."','".$dosya->Boyut($_POST['dosya'])."','".$_POST['aciklama']."','".$dosya->Veri($POST_VERI)."')") ) {
		echo"data kaydedilemedi!";
	}
	$permasql_betik = "select id from dosya order by id desc";
	$permasql = mysql_query($permasql_betik);
	$perma = mysql_result($permasql,0);
	header("location: #".$perma);
}
if($_GET['sirala'] == 'AD_ASC') {
	$sira_link_ad = '?sirala=AD_DESC';
}
elseif($_GET['sirala'] == 'AD_DESC'){
	$sira_link_ad = '?sirala=AD_ASC';
}
elseif($_GET['sirala'] == 'BOYUT_ASC'){
	$sira_link_boyut = '?sirala=BOYUT_DESC';
}
elseif($_GET['sirala'] == 'BOYUT_DESC'){
	$sira_link_boyut = '?sirala=BOYUT_ASC';
}
else{
	$sira_link_ad = '?sirala=AD_DESC';
	$sira_link_boyut = '?sirala=BOYUT_DESC';
}
//================== [Tablo] ===================
echo<<<html
    <p align="center"><a href="index.php" >Anasayfa</a></p>
    <table style="border:1px solid gray;" cellpadding="2" cellspacing="0" width="80%" align="center">
    <tr>
    <td style="color:#eeeeee;font:bold 11px tahoma;background:gray;border-left:1px solid black;border-bottom:0px solid black;" align="center" width="30%"><a style="font:bold 11px tahoma;color:#eeeeee;text-decoration:underline" href="{$dosya->ScriptName()}{$sira_link_ad}">Dosya Adı</a></td> 
    <td style="color:#eeeeee;font:bold 11px tahoma;background:gray;border-left:1px solid black;border-bottom:0px solid black;" align="center" width="10%"><a style="font:bold 11px tahoma;color:#eeeeee;text-decoration:underline" href="{$dosya->ScriptName()}{$sira_link_boyut}">Dosya Boyutu</a></td>
    <td style="color:#eeeeee;font:bold 11px tahoma;background:gray;border-left:1px solid black;border-bottom:0px solid black;" align="center" width="55%">Dosya Açiklaması</td>
html;
if(!$_COOKIE['admin'] == NULL) {
    echo '<td style="color:#eeeeee;font:bold 11px tahoma;background:gray;border-right:1px solid black;border-left:1px solid black;border-top:0px solid black;border-bottom:0px solid black;" align="center" width="5%">Sil</td>';
}
echo '</tr>';
if($_GET['sirala'] == 'AD_ASC') {
	$sira = 'ORDER BY ad ASC';
}
elseif($_GET['sirala'] == 'AD_DESC'){
	$sira = 'ORDER BY ad DESC';
}
elseif($_GET['sirala'] == 'BOYUT_ASC'){
	$sira = 'ORDER BY boyut ASC';
}
elseif($_GET['sirala'] == 'BOYUT_DESC'){
	$sira = 'ORDER BY boyut DESC';
}
else{
	$sira = '';
}
$sql_betik = "select id,ad,boyut,aciklama from dosya {$sira}";
$sql = mysql_query($sql_betik);
while( $sorgu = mysql_fetch_object($sql) ) {
    echo'
        <tr>
        <td style="border-top:1px solid gray;border-bottom:0px solid gray;" width="30%">
            <a style="padding-left:10px;" title="'.$sorgu->ad.'" name="'.$sorgu->id.'" href="'.$dosya->ScriptName().'?download='.$sorgu->ad.'">'.$sorgu->ad.'</a>
        </td> 
        <td style="color:teal;font:bold 11px tahoma;text-decoration:none;border-left:1px solid gray;border-top:1px solid gray;border-bottom:0px solid gray;" width="10%">
            <span style="padding-left:10px;">';
            if($sorgu->boyut < 1048576){
                echo substr($sorgu->boyut/1024,0,4) . " KB";
            } else{
                echo substr($sorgu->boyut/1024/1024,0,4) . " MB";
            }
            echo '
            </span>
        </td>
        <td style="color:black;font:normal 11px tahoma;border-left:1px solid gray;border-top:1px solid gray;border-bottom:0px solid gray;" align="center" width="55%">';
        if($sorgu->aciklama == NULL){
            echo "&nbsp;";
        } else {
            echo $sorgu->aciklama;
        }
        echo '</td>';
        if(!$_COOKIE['admin'] == null) {
            echo '
            <td style="color:black;font:bold 11px tahoma;border-left:1px solid gray;border-top:1px solid black;border-bottom:0px solid black;" align="center" width="5%">
            <a href="'.$dosya->ScriptName().'?Dosya_Sil='.$sorgu->id.'">Sil</a>
            </td>
            ';
        }
        echo '</tr>';
}    
    echo '</table><br>';
$dosya->DbClose();
//================== [Form Linki] ==================
if($_GET['dosya_yolla']==='') {
	$link = "";
	$yazi = "Kapat";
} else{
	$link = "{$dosya->ScriptName()}?dosya_yolla";
	$yazi = "Dosya Yolla";
}
//================== [Form] ===================
echo '
    <table style="border:0px solid gray;" cellpadding="2" cellspacing="0" width="80%" align="center">
    <tr><td>
    <a href="'.$link.'">'.$yazi.'</a>
    </td></tr>
    </table>
    <form method="POST" action="">
    <table style="border:1px solid black" bgcolor="#DCDCDC" cellpadding="5" cellspacing="0" width="60%" align="center">
';
if($_GET['dosya_yolla']==='') {
    echo'
        <tr>
        <td style=""><div style="padding-bottom:2px"></div><span style="font:bold 11px tahoma;color:#B22222;margin-left:20px;">Dosyayı Seçin</span><br><center><input style="width:93%;border:1px solid black;" type="file" name="dosya"></center></td>
        </tr>
        <tr>
        <td style="border-top:1px solid black;"><div style="padding-bottom:10px"></div><span style="font:bold 11px tahoma;color:B22222;margin-left:20px;">Dosya Açıklaması</span><br><center><textarea style="margin-left:20px;margin-right:20px;border:1px solid black;width:100%;height:100px" name="aciklama"></textarea></center></td>
        </tr>
        <tr>
        <td align="center" style="" colspan=2>
        <input onmouseover="this.style.font=\'bold 11px tahoma\';this.style.color=\'#B22222\';this.style.background=\'#eeeeee\';this.style.border=\'1px solid gray\';" onmouseout="this.style.font=\'bold 11px tahoma\';this.style.color=\'#B22222\';this.style.background=\'#bbbbbb\';this.style.border=\'1px solid gray\';" style="font:bold 11px tahoma;color:#B22222;background:#bbbbbb;border:1px solid gray" type="submit" name="yolla" value="Gönder">
        </td>
        </tr>
    ';
}
echo '</table>
</form>';
// Output Buffering Sonu
ob_end_flush();
?>
Buda SQL Betiği
CREATE TABLE IF NOT EXISTS `dosya` (
  `id` int(8) NOT NULL auto_increment,
  `ad` varchar(255) character set latin5 NOT NULL,
  `boyut` varchar(100) character set latin5 NOT NULL,
  `data` longblob NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;
Script içindeki db bilgilerini vs değiştirin , Sqlyi upload edin ve kullanın
İyi kullanmalar.