forked from science-ation/science-ation
Add document manager, and update tableeditor to allow setting of a downloadlink for documents
This commit is contained in:
parent
c92736229c
commit
1cc99b4ef9
34
admin/documentdownloader.php
Normal file
34
admin/documentdownloader.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?
|
||||||
|
/*
|
||||||
|
This file is part of the 'Science Fair In A Box' project
|
||||||
|
SFIAB Website: http://www.sfiab.ca
|
||||||
|
|
||||||
|
Copyright (C) 2007 James Grant <james@lightbox.org>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public
|
||||||
|
License as published by the Free Software Foundation, version 2.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; see the file COPYING. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
<?
|
||||||
|
require("../common.inc.php");
|
||||||
|
auth_required('admin');
|
||||||
|
$q=mysql_query("SELECT * FROM documents WHERE id='".$_GET['id']."'");
|
||||||
|
if($r=mysql_fetch_object($q))
|
||||||
|
{
|
||||||
|
header("Content-type: ".trim(exec("file -bi ../data/documents/$r->filename")));
|
||||||
|
header("Content-disposition: inline; filename=$r->filename");
|
||||||
|
header("Content-length: ".filesize("../data/documents/$r->filename"));
|
||||||
|
readfile("../data/documents/$r->filename");
|
||||||
|
}
|
||||||
|
?>
|
53
admin/documents.php
Normal file
53
admin/documents.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?
|
||||||
|
/*
|
||||||
|
This file is part of the 'Science Fair In A Box' project
|
||||||
|
SFIAB Website: http://www.sfiab.ca
|
||||||
|
|
||||||
|
Copyright (C) 2007 James Grant <james@lightbox.org>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public
|
||||||
|
License as published by the Free Software Foundation, version 2.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; see the file COPYING. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
<?
|
||||||
|
require("../common.inc.php");
|
||||||
|
require("../tableeditor.class.php");
|
||||||
|
|
||||||
|
//make sure storage folder exists
|
||||||
|
if(!file_exists("../data/documents"))
|
||||||
|
mkdir("../data/documents");
|
||||||
|
if(!file_exists("../data/documents/.htaccess"))
|
||||||
|
file_put_contents("../data/documents/.htaccess","Order Deny,Allow\r\nDeny From All\r\n");
|
||||||
|
|
||||||
|
auth_required('admin');
|
||||||
|
send_header("Internal Document Manager");
|
||||||
|
|
||||||
|
$editor=new TableEditor("documents",
|
||||||
|
array("date"=>"Date",
|
||||||
|
"title"=>"Document Title",
|
||||||
|
"sel_category"=>"Category",
|
||||||
|
"filename"=>"Filename",
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$editor->setPrimaryKey("id");
|
||||||
|
$editor->setUploadPath("../data/documents");
|
||||||
|
$editor->setDefaultSortField("sel_category,date");
|
||||||
|
$editor->setRecordType("Document");
|
||||||
|
$editor->setFieldDefaultValue("date",date("Y-m-d"));
|
||||||
|
$editor->setDownloadLink("documentdownloader.php");
|
||||||
|
$editor->execute();
|
||||||
|
|
||||||
|
send_footer();
|
||||||
|
?>
|
@ -39,6 +39,7 @@
|
|||||||
if($config['tours_enable'] == 'yes') {
|
if($config['tours_enable'] == 'yes') {
|
||||||
echo "<a href=\"tours_manager.php\">".i18n("Tour Management")."</a> <br />";
|
echo "<a href=\"tours_manager.php\">".i18n("Tour Management")."</a> <br />";
|
||||||
}
|
}
|
||||||
|
echo "<a href=\"documents.php\">".i18n("Internal Document Management")."</a> <br />";
|
||||||
echo "<hr />";
|
echo "<hr />";
|
||||||
echo "<a href=\"winners.php\">".i18n("Enter Winning Projects")."</a> <br />";
|
echo "<a href=\"winners.php\">".i18n("Enter Winning Projects")."</a> <br />";
|
||||||
echo "<a href=\"cwsfregister.php\">".i18n("One-Click CWSF Registration")."</a> <br />";
|
echo "<a href=\"cwsfregister.php\">".i18n("One-Click CWSF Registration")."</a> <br />";
|
||||||
|
@ -1 +1 @@
|
|||||||
53
|
54
|
||||||
|
8
db/db.update.54.sql
Normal file
8
db/db.update.54.sql
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
CREATE TABLE `documents` (
|
||||||
|
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
|
||||||
|
`date` DATE NOT NULL ,
|
||||||
|
`title` VARCHAR( 128 ) NOT NULL ,
|
||||||
|
`sel_category` VARCHAR( 128 ) NOT NULL ,
|
||||||
|
`filename` VARCHAR( 128 ) DEFAULT NULL ,
|
||||||
|
PRIMARY KEY ( `id` )
|
||||||
|
) TYPE = MYISAM ;
|
@ -302,6 +302,10 @@ class TableEditor
|
|||||||
{
|
{
|
||||||
$this->uploadPath=$p;
|
$this->uploadPath=$p;
|
||||||
}
|
}
|
||||||
|
function setDownloadLink($l)
|
||||||
|
{
|
||||||
|
$this->downloadLink=$l;
|
||||||
|
}
|
||||||
|
|
||||||
function setYearSelectRange($min,$max)
|
function setYearSelectRange($min,$max)
|
||||||
{
|
{
|
||||||
@ -1110,6 +1114,12 @@ class TableEditor
|
|||||||
else if(substr($f,0,8)=="filename" && $this->uploadPath)
|
else if(substr($f,0,8)=="filename" && $this->uploadPath)
|
||||||
{
|
{
|
||||||
echo "<td valign=\"top\">";
|
echo "<td valign=\"top\">";
|
||||||
|
if($this->downloadLink) {
|
||||||
|
$pk=$this->primaryKey;
|
||||||
|
echo "<a href=\"{$this->downloadLink}?{$pk}={$r->$pk}\">{$r->$f}</a>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//only show a link to the file if the upload path is inside the document root
|
//only show a link to the file if the upload path is inside the document root
|
||||||
if(strstr(realpath($this->uploadPath),$_SERVER['DOCUMENT_ROOT']) && file_exists($this->uploadPath."/".$editdata[$f]))
|
if(strstr(realpath($this->uploadPath),$_SERVER['DOCUMENT_ROOT']) && file_exists($this->uploadPath."/".$editdata[$f]))
|
||||||
{
|
{
|
||||||
@ -1119,6 +1129,7 @@ class TableEditor
|
|||||||
{
|
{
|
||||||
echo $r->$f;
|
echo $r->$f;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user