<?php
/**
* @author Michal Burdziak (ladovnik)
* @copyright 2011
*/
if(!isLogged()) {
redirect('?logIn');
}
if(isset($_POST['delSubmit'])) { $res=dbquery('SELECT f_name FROM `'.DLOAD_TBL.'` WHERE f_id="'.$_POST['id'].'"');
$data=dbrow($res);
if($data[0]) {
}
dbquery('DELETE FROM `'.DLOAD_TBL.'` WHERE f_id="'.$_POST['id'].'"');
redirect('?admFiles&s=del');
}
if(isset($_POST['editSubmit'])) { redirect('?admFiles&edit='.$_POST['id'].'');
}
if(isset($_GET['edit'])) { $res=dbquery('SELECT * FROM `'.DLOAD_TBL.'` WHERE f_id="'.$_GET['edit'].'"');
$eData=dbassoc($res);
}
else {
$eData=false;
}
function tmpTitle($show=1) {
$ed=$eData ? strOutput($eData['f_title']) : '';
$r=isset($_POST['f_title']) ? strOutput
($_POST['f_title']) : $ed; else return $r;
}
function tmpDesc($show=1) {
$ed=$eData ? strOutput($eData['f_desc']) : '';
$r=isset($_POST['f_desc']) ? strOutput
($_POST['f_desc']) : $ed; else return $r;
}
function tmpComlink($show=1) {
$ed=$eData ? strOutput($eData['f_comlink']) : '';
$r=isset($_POST['f_comlink']) ? strOutput
($_POST['f_comlink']) : $ed; else return $r;
}
function tmpFileName($show=1) {
$ed=$eData ? strOutput($eData['f_name']) : '';
$r=$ed;
else return $r;
}
function mkFilesList($postName) {
$post=isset($_GET['edit']) ?
$_GET['edit'] : false; $res=dbquery('SELECT f_id, f_title FROM `'.DLOAD_TBL.'` ORDER BY f_id DESC');
echo "<select name='".$postName."' class='textbox'>\r\n"; while($data=dbrow($res)) {
$sel=$post==$data[0] ? " selected='selected'" : "";
echo "<option value='".$data[0]."'".$sel.">".strOutput
($data[1])."</option>\r\n"; }
}
function mkCatsList($postName) {
$post=$eData ? $eData['f_cat'] : reqPostVar($postName);
echo "<select name='".$postName."' class='textbox'>\r\n"; foreach($CATS as $id => $title) {
$data[0]=$id;
$data[1]=$title;
$sel=$post==$data[0] ? " selected='selected'" : "";
echo "<option value='".$data[0]."'".$sel.">".strOutput
($data[1])."</option>\r\n"; }
}
function getAllowedEx() {
}
function getFormTitle() {
echo isset($_GET['edit']) ?
'Edytuj plik' : 'Dodaj plik'; }
function isEditMode() {
return isset($_GET['edit']) ? 1
: 0; }
function getResult($show=1) {
$s=isset($_GET['s']) ?
$_GET['s'] : false;
if(!$show) {
return $s;
}
switch($s) {
case 'del':
echo "<span class='success'>Plik został usunięty!</span>\r\n"; break;
case 'edit':
echo "<span class='success'>Plik został zmieniony!</span>\r\n"; break;
case 'add':
echo "<span class='success'>Plik został dodany!</span>\r\n"; break;
}
}
function getStatus() {
if(isset($_POST['fileSubmit'])) { $FILE_A=isset($_FILES['file']) ?
$_FILES['file'] : ''; $file=$_POST['file_old'];
$error=false;
if(empty($_POST['f_title'])) { $error=true;
echo "<span class='error'>Musisz podać tytuł pliku!</span><br>\r\n"; }
if(empty($_POST['f_desc'])) { $error=true;
echo "<span class='error'>Musisz podać opis pliku!</span><br>\r\n"; }
if($FILE_A['name']) {
$fDir=FILES;
$fName=getFileName($file);
$fNewName=clearStr($fName);
$fEx=getFileEx($file);
$fMime=$FILE_A['type'];
$fNew=getUniqFileName(FILES, $fNewName.'.'.$fEx);
$fPath=$fDir.$fNew;
chmod($fDir, 0777);
}
if(!in_array($fEx, $settings['allowedFilesEx'])) { $error=true;
echo "<span class='error'>Rozszerzenie <u>".$fEx."</u> jest zabronione!</span><br>\r\n"; }
if(!in_array($fMime, $settings['allowedFilesMime'])) { $error=true;
echo "<span class='error'>Pliki typu <u>".$fMime."</u> są zabronione!</span><br>\r\n"; }
$error=true;
$eId=$FILE_A['error'];
echo "<span class='error'>Wystąpił błąd podczas kopiowania pliku z katalogu tymczasowego (#".$eId.")!</span><br>\r\n"; }
if(!$error) {
chmod($fPath, 0664);
$file=$fNew;
}
}
elseif(!isEditMode()) {
$error=true;
echo "<span class='error'>Musisz wybrać plik do przesłania!</span><br>\r\n"; }
if(!$error) {
if($eData) {
dbquery('UPDATE `'.DLOAD_TBL.'` SET f_name="'.$file.'", f_title="'.$_POST['f_title'].'", f_desc="'.$_POST['f_desc'].'", f_comlink="'.$_POST['f_comlink'].'", f_cat="'.$_POST['f_cat'].'"
WHERE f_id="'.$_GET['edit'].'"');
redirect('?admFiles&s=edit');
}
else {
dbquery('INSERT INTO `'.DLOAD_TBL.'` (f_name, f_title, f_desc, f_comlink, f_time, f_cat)
VALUES ("'.$file.'", "'.$_POST['f_title'].'", "'.$_POST['f_desc'].'", "'.$_POST['f_comlink'].'", "'.time().'", "'.$_POST['f_cat'].'")'); redirect('?admFiles&s=add');
}
}
}
}
?>
To moze byc ten plik?
Pomoże mi ktoś ?