Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93828490
Get_TFU_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
Sun, Dec 1, 20:23
Size
3 KB
Mime Type
text/html
Expires
Tue, Dec 3, 20:23 (2 d)
Engine
blob
Format
Raw Data
Handle
22710521
Attached To
R3600 invenio-infoscience
Get_TFU_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.
##
## Name: Get_TFU_Files.php
## Description: function Get_TFU_Files
## This function tries to retrieve a list of files from the
## URLS stored into the submission directory
## Author: T.Baron
##
## PARAMETERS: fieldnameTFU: name of the file in which the URLs are
## stored
## OUTPUT: HTML
##
function Get_TFU_Files ($param_array,$MAINPATH)
{
global $doctype,$LYNX,$TMPDIR;
#set local variables
$fieldname = $param_array[fieldnameTFU];
# retrieve URL list
$fp = fopen("$MAINPATH/$fieldname");
$urls = fread($fp,filesize("$MAINPATH/$fieldname"));
fclose($fp);
$pid = getmypid();
$errors = 0;
$count = 0;
#set directories
if (!is_dir("$MAINPATH/files"))
mkdir ("$MAINPATH/files",0777);
if (!is_dir("$MAINPATH/files/MainFile"))
mkdir ("$MAINPATH/files/MainFile",0777);
if (!is_dir("$MAINPATH/files/IncludedFiles"))
mkdir ("$MAINPATH/files/IncludedFiles",0777);
Request_Print("A", "<BR><BR>");
$lines = explode("\015\n",$urls);
while ($lines[$count] != "")
{
`$LYNX -source "$lines[$count]" > $TMPDIR/file.$pid`;
$fp = fopen("$TMPDIR/file.$pid","r");
$filecontent = fread($fp,filesize("$TMPDIR/file.$pid"));
fclose($fp);
$FNF = ereg("File Not Found",$filecontent);
$er = ereg("Error 404",$filecontent);
$er403 = ereg("Error 403",$filecontent);
$er2 = ereg("404 Not Found",$filecontent);
$ONF = ereg("Object Not Found",$filecontent);
$CA = ereg("Can't access",$filecontent);
$Forbidden = ereg("Forbidden",$filecontent);
$name = basename($lines[$count]);
$name = str_replace(".Z","",$name);
$name = str_replace(".gz","",$name);
if ( $FNF || $CA || $Forbidden || $ONF || $er || $er2 || $er403 )
{
#if an error occured while getting the file
$errors++;
unlink("$TMPDIR/file.$pid");
#display an error message and go back to CDS Submit
$page=2;
Request_Print ("A", "
<SCRIPT>
alert('$lines[$count]: Cannot Access file\\nEither the file does not exist or it is protected.\\nPlease correct the corresponding entry.');
document.forms[1].action = \"../Main.php\";
document.forms[1].page.value = $page;
document.forms[1].submit();
</SCRIPT>");
#stop pro.php execution
exit;
}
else
{
#if the file is correct
Request_Print ("S", "<B><LI>The file <FONT color=\"FF0000\">$lines[$count]</FONT>: has been found and saved.<BR></B>");
# additional files
if ( $count != 0 )
rename("$TMPDIR/file.$pid"
, "$MAINPATH/files/IncludedFiles/$name");
else
{
# Main File
rename("$TMPDIR/file.$pid"
, "$MAINPATH/files/MainFile/$name");
$fp = fopen("$MAINPATH/MainFile","w+");
fwrite($fp,"$name");
fclose($fp);
}
}
$count++;
}
}
</protect>
?>
Event Timeline
Log In to Comment