Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F103155001
Upload_Included_Files.php.wml
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Feb 27, 17:45
Size
12 KB
Mime Type
text/html
Expires
Sat, Mar 1, 17:45 (2 d)
Engine
blob
Format
Raw Data
Handle
24500667
Attached To
R3600 invenio-infoscience
Upload_Included_Files.php.wml
View Options
## $Id$
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware 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; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware 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 CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
## Description: function Upload_Included_Files
## This function creates an html interface which allows
## the user to look at the list of files he/she already
## transfered. It also gives the user the opportunity to
## upload additional files
## Author: T.Baron
## PARAMETERS: firstfile: name of the directory in which the main file
## is stored
## secondfile: name of the directory in which the additional
## files are stored
## filetype: one of "picture" or "fulltext"
function Delete_File($doctype,$file_path,$access,$filetype,
$firstfile,$secondfile,$MAINPATH,$userfile_name)
{
global $STORAGE, $IMAGES, $mainmenu;
if ($file_path == $firstfile)
$file_status = $firstfile;
else
$file_status = $secondfile;
if (file_exists("$MAINPATH/files/$file_path/$userfile_name"))
{
unlink ("$MAINPATH/files/$file_path/$userfile_name");
if (file_exists("$MAINPATH/lastuploadedfile"))
unlink ("$MAINPATH/lastuploadedfile");
}
if (file_exists("$MAINPATH/files/icons"))
{
$dir = opendir("$MAINPATH/files/icons");
while ($icon = readdir($dir))
{
if ($icon != "." && $icon != "..")
{
if ($file_status == "$firstfile" && $icon == "icon.gif")
unlink("$MAINPATH/files/icons/$icon");
if ($file_status == "$secondfile" &&
ereg("$userfile_name",$icon))
unlink("$MAINPATH/files/icons/$icon");
}
}
}
Reupload($file_status,$filetype,$firstfile);
}
function Display_Uploaded_Files($doctype,$accessNumber,$filetype,$firstfile,
$secondfile,$MAINPATH)
{
global $STORAGE,$URLPATH,$doctype,$IMAGES,$dir;
$cgi = $GLOBALS[VARS]->get_cgi();
//display uploaded files
chdir("$MAINPATH/");
$icondir = "$MAINPATH/files/icons";
///////////////////////////////////////////////
// Display Main File(s)
///////////////////////////////////////////////
$maindir = "$MAINPATH/files/$firstfile";
Request_Print("A","
<TABLE width=100% border=0>
<TR>
<TD VALIGN=TOP>
<small><DD><B><U>transfered main file:</U></B></small><br>
<DD><TABLE border=0>");
$filename = "";
$dp = opendir($maindir);
while ($file = readdir($dp))
{
if ($file != "." && $file != "..")
{
$filename = $file;
if ($filetype == "picture" && file_exists("$icondir/icon.gif")
&& filesize("$icondir/icon.gif") != 0)
Request_Print("A","\n<TR>\n <TD VALIGN=TOP>\n <small>"
. "<IMG SRC='$URLPATH/storage/$dir/$doctype/$accessNumber/"
. "files/icons/icon.gif' align=center> $filename "
. "(<a href = \"\" onClick=\"document.forms[1].file_path."
. "value='$firstfile';document.forms[1].userfile_name.value"
. "='$filename';document.forms[1].deleted.value='yes';"
. "document.forms[1].submit();return false;\"><STRONG> "
. "delete </STRONG></A>)</small>\n </TD>\n</TR>");
else
Request_Print("A","\n<TR>\n <TD VALIGN=TOP>\n <small>"
. "<IMG SRC=$IMAGES/smallfiles.gif> $filename (<a href "
. "= \"\" onClick=\"document.forms[1].file_path.value="
. "'$firstfile';document.forms[1].userfile_name.value="
. "'$filename';document.forms[1].deleted.value='yes';"
. "document.forms[1].submit();return false;\"><STRONG> "
. "delete </STRONG></A>)</small>\n </TD>\n</TR>");
}
}
closedir($dp);
Request_Print("A","</TABLE>");
Request_Print("A","\n </TD>\n <TD ROWSPAN=2 WIDTH=300 ALIGN=RIGHT "
. "VALIGN=top>\n <small><INPUT TYPE=\"button\" HEIGHT=35 "
. "WIDTH=250 NAME=\"Submit\" VALUE=\"End Submission\" "
. "onClick=\"step2();\"></small>\n </TD>\n</TR>\n<TR>\n <TD>");
// No main file, we go back to the first upload page
if ($filename == "" && $doctype != "BUL")
Reupload($firstfile,$filetype,$firstfile);
///////////////////////////////////////////////
// Display Additional File(s)
///////////////////////////////////////////////
$otherdir = "$MAINPATH/files/$secondfile";
//output the secondfile list header
if (is_dir("$otherdir"))
{
Request_Print("A","<B><BR><DD><U><SMALL>transfered additional files:"
. "</SMALL></U></B><BR>");
Request_Print ("A","\n<DD><TABLE BORDER=0>");
$dp = opendir($otherdir);
while ($file = readdir($dp))
{
if ($file != "." && $file != "..")
{
$filename = $file;
if ($filetype == "picture")
{
$iconname = `ls $icondir | grep icon...$filename.gif`;
$iconname = ereg_replace("\n.*","",$iconname);
if (is_file("$icondir/$iconname")
&& filesize("$icondir/$iconname") != 0)
Request_Print ("A","\n<TR>\n <TD><small>"
. "<IMG SRC='$URLPATH/storage/$dir/$doctype/"
. "$accessNumber/files/icons/$iconname' align=center>"
. " $filename (<a href = \"\" onClick=\"document."
. "forms[1].file_path.value='$secondfile';"
. "document.forms[1].userfile_name.value='$filename';"
. "document.forms[1].deleted.value='yes';"
. "document.forms[1].submit();return false;\"><STRONG>"
. " delete </STRONG></A>)</small></TD>\n</TR>\n");
else
Request_Print ("A","\n<TR>\n <TD><small>"
. "<IMG SRC=$IMAGES/smallfiles.gif> $filename "
. "(<a href = \"\" onClick=\"document.forms[1]."
. "file_path.value='$secondfile';document.forms[1]."
. "userfile_name.value='$filename';document.forms[1]."
. "deleted.value='yes';document.forms[1].submit();"
. "return false;\"><STRONG> delete </STRONG></A>)"
. "</small></TD>\n</TR>\n");
}
else
{
Request_Print ("A","\n<TR>\n <TD><small>"
. "<IMG SRC=$IMAGES/smallfiles.gif> $filename"
. "</small></TD>\n <TD ALIGN = CENTER><small>"
. "(<a href = \"\" onClick=\"document.forms[1].file_path."
. "value='$secondfile';"
. "document.forms[1].userfile_name.value='$filename';"
. "document.forms[1].deleted.value='yes';"
. "document.forms[1].submit();return false;\"><STRONG> "
. "delete </STRONG></A>)</small></TD>\n</TR>\n");
}
}
}
closedir($dp);
Request_Print ("A","</TABLE>");
}
Request_Print ("A","</td></TR></table>");
}
function Upload_Included_Files($param_array,$MAINPATH)
{
global $MAINPATH,$deleted,$file_path,$userfile_name;
$filetype = $param_array[filetype];
$firstfile = $param_array[firstfile];
$secondfile = $param_array[secondfile];
//Get current global objects variables
$doctype = $GLOBALS[VARS]->get_doctype();
//if the access number is not in cgi then get it from the object
$accessNumber = $cgi[access];
if ($accessNumber == "")
$accessNumber = $GLOBALS[VARS]->get_access_number();
if ($deleted == "yes")
Delete_File($doctype,$file_path,$accessNumber,$filetype,$firstfile,
$secondfile,$MAINPATH,$userfile_name);
//display form to upload a new file
Display_Form($filetype,$firstfile,$secondfile);
//display previously uploaded files
Display_Uploaded_Files($doctype,$accessNumber,$filetype,$firstfile,
$secondfile,$MAINPATH);
}
function Reupload($file_status,$filetype,$firstfile)
{
$doc_type = $GLOBALS[VARS]->get_doctype();
$access_number = $GLOBALS[VARS]->get_access_number();
$action = $GLOBALS[VARS]->get_action ();
if($file_status == $firstfile)
Request_Print("A", "\n<BR>\n<SCRIPT LANGUAGE=\"JavaScript1.1\" "
. "TYPE=\"text/javascript\">\n\nfunction reload()\n"
. "{"
. " document.forms[1].action = \"../Main.php\";\n"
. " document.forms[1].page.value = 1;\n"
. " document.forms[1].submit();\n"
. "}\nreload();\n</SCRIPT>\n");
}//end of function
function Display_Form($filetype,$firstfile,$secondfile)
{
//get cgi vars
$cgi = $GLOBALS[VARS]->get_cgi();
$doctype = $GLOBALS[VARS]->get_doctype();
//output the upload included files form.
Request_Print("A","\n<TABLE cellpadding=0 cellspacing=0 border=0 "
. "bgcolor=#dddddd width=80% align=center>\n<TR>\n <TD>\n <SMALL>"
. "If your document has <B>additional files</B>, please complete the"
. " form below:<BR>\nUse \"Click to send file\" to transfer each"
. " file.</SMALL>\n</TD></TR>\n<TR><TD>\n\n<TABLE>\n<TR>"
. " <TD ALIGN=center bgcolor=white width=20>\n"
. " <small><B>1</B></small>\n </TD>\n");
if ($filetype == "picture")
Request_Print("A","\n <TD ALIGN=right>\n <small>Select the"
. " picture format :</small>\n </TD>\n <TD>\n <small><BR>"
. "<SELECT name=PhotoFormat>\n <option selected> Select:\n"
. " <option> JPEG\n <option> GIF\n <option> PDF\n"
. " </SELECT></small>\n </TD>\n");
else
Request_Print("A","\n <TD ALIGN=right>\n <small>Select the"
. " file format :</small>\n </TD>\n <TD>\n <small><BR>"
. "<SELECT name=Format>\n <option selected> Select:\n"
. " <option> Compressed PostScript\n"
. " <option> PostScript\n"
. " <option> PDF\n"
. " <option> WORD\n"
. " </SELECT></small>\n </TD>\n");
Request_Print("A","\n <TD></TD>\n</TR>\n<TR>\n <TD ALIGN=center "
. "bgcolor=white width=20>\n <small><b>2</B></small>\n </TD>\n"
. " <TD ALIGN=right>\n <small>Use the Browse Button to select"
. " the file to transfer:</small>\n </TD>\n <TD>\n <small>"
. "<INPUT NAME=\"$secondfile\" TYPE=\"file\"> </small>\n</TD>\n"
. "</TR>\n");
if ($doctype == "LHI")
Request_Print("A","\n<TR>\n <TD ALIGN=center bgcolor=white "
. "width=20>\n <small><b>2bis</B></small>\n </TD>\n"
. " <TD ALIGN=right>\n <small>Or enter the URL to your "
. "file:</small>\n </TD>\n <TD> <small><INPUT "
. "NAME=\"TFURL2\" size=70> </small>\n </TD>\n</TR>\n");
else
Request_Print("A","<INPUT TYPE=hidden name=TFURL2 value=\"\">");
Request_Print("A","\n<TR>\n <TD ALIGN=center bgcolor=white width=20>"
. " <small><B>3</B></small>\n </TD>\n <TD ALIGN=right>"
. "<SMALL>Press this button:</SMALL></TD>\n <TD ALIGN=LEFT>\n"
. " <small><INPUT TYPE=\"Submit\" WIDTH=150 VALUE=\"Click to"
. " send file\" onClick=\"return validateForm()\"></small>\n"
. " </TD>\n</TR>\n</TABLE>\n</TD></TR></TABLE>\n"
. "<BR><SMALL><U><B>Click the End Submission button when you have"
. " finished.</U></B><BR>If your file is incorrect, use the"
. " \"delete\" link, you will then have the opportunity to transfer"
. " it again.<BR><BR></SMALL>\n\n"
. "<SCRIPT LANGUAGE=\"JavaScript\" TYPE=\"text/javascript\">\n\n"
. "function step2()\n{\n if(confirm(\"You are about to submit the"
. " files and end the upload process.\"))\n {\n document."
. "forms[1].step.value = 2;\n document.forms[1].submit();\n }\n"
. " return true;\n}\n\n"
. "function validateForm()\n{\n");
if ($filetype == "picture")
print "\nif ((document.forms[1].$secondfile.value == \"\" && "
. "document.forms[1].TFURL2.value == \"\")||(document.forms[1]."
. "PhotoFormat[0].selected == true))\n";
else
print "\nif ((document.forms[1].$secondfile.value == \"\" && "
. "document.forms[1].TFURL2.value == \"\")||(document.forms[1]."
. "Format[0].selected == true))\n";
print ("\n{\n alert(\"Please complete all the form fields\");\n "
. "return false;\n}\n\n}\n\n</SCRIPT>\n");
}
</protect>
?>
Event Timeline
Log In to Comment