Location: PHPKode > projects > PHPEcho CMS > modules/files/index.php
<?php
/*  +--------------------------------------------
*   |
*   |     Product:       PHPEchoCMS
*   |     Author:        Tigran Abrahamyan
*   |     License:       GPL
*   |     Last updated:  15.02.07
*   |     For version:   1.6  
*   |     Desc:          Files module
*   |        
*   +--------------------------------------------
*/

if( !@$BASE_LOAD )
{
    die('Application error.');
}

function generate ()
{
    global $smarty, $core;
    
    $mlang = $core->getlang("files");
           
    if (@$_GET['id'])
    {
        $dticket = query("SELECT * FROM ".PREFIX."files WHERE file_id = '".addslashes($_GET['id'])."'", 4);
        
        if ($dticket)
        {
	     $dticket['file_link'] = "./uploads/".$dticket['file_link'];	

             $content = $mlang['002']."<a href='".$dticket['file_link']."'>".$dticket['file_name']."</a>. ".$mlang['003'];  
             
             query ("UPDATE ".PREFIX."files SET file_downloaded = file_downloaded+1 WHERE file_id = ".addslashes($_GET['id']), 1);
             
	     redirect($dticket['file_link']);
        }
        else
        {
            $content = "<font color='red'>".$mlang['004']."</font>";
        }
    }
    else
    {
        $files = query ("SELECT * FROM ".PREFIX."files", 1);
        
        $content = "<table width='100%'>";
        
        $content .= "
            <tr>
                <td width='10%' class='title'>
                <b>".$mlang['005']."</b>
                </td>
                <td width='80%' class='title'>
                <b>".$mlang['006']."</b>
                </td>
                <td width='20%' class='title'>
                <b>".$mlang['007']."</b>
                </td>
            </tr>
        ";    
        while ($file = mysql_fetch_array($files))
        {
            $filelink = "<a href='?module=files&id=".$file['file_id']."'>".$file['file_name']."</a>";
            $smarty->assign ("fileid", $file['file_id']);
            $smarty->assign ("filelink", $filelink);
            $smarty->assign ("downloaded", $file['file_downloaded']);
            $content .= $smarty->fetch ("modules/files.tpl");
            $i = 1;
        }
        
        $content .= "</table>";
        
        if( !@$i )
        {
            $content = $mlang['001'];
        }
    }
    
    echo $content;
}

generate ();
?>
Return current item: PHPEcho CMS