Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85684391
editRecordFile.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
Tue, Oct 1, 04:52
Size
10 KB
Mime Type
text/x-c
Expires
Thu, Oct 3, 04:52 (2 d)
Engine
blob
Format
Raw Data
Handle
21242091
Attached To
R3600 invenio-infoscience
editRecordFile.php.wml
View Options
## $Id$
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002, 2003, 2004, 2005 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.
<?
require("commonPhpFunctions.php");
?>
#include "cdspage.wml" \
title="Edit <i>bibconvert</i> configuration for the <I><protect><?print $doctype;?></protect></i> document type" \
navtrail_previous_links="<a class=navtrail href=<WEBURL>/admin/<lang:star: index.*.html>><MSG_ADMIN_AREA></a> > <a class=navtrail href=<WEBURL>/admin/websubmit/><MSG_ADMIN_SUBMIT></a>" \
navbar_name="admin" \
navbar_select="websubmit"
<?
<protect>$uploadTplPath = "</protect><ETCDIR><protect>/bibconvert/config";</protect>
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
/*********************Function Declarations***************************/
function criticalFileFailRedirect($functionName, $doctype, $action,
$returnTo)
{
/*******************************************************************
This function simply redirects
the browser to the func.php page. It is called when the file
cannot be opened for reading/writing.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 01/02/2001
Last Modified: 06/02/2001
*******************************************************************/
# Make the functionality to send the page back home...
print("<FORM ACTION='func.php' METHOD='post' NAME='referForm'"
. ">\n<INPUT TYPE='hidden' NAME='functionName' VALUE='"
. "$functionName'>\n<INPUT TYPE='hidden' NAME='doctype' VALU"
. "E='$doctype'>\n<INPUT TYPE='hidden' NAME='action' VALUE='"
. "$action'>\n<INPUT TYPE='hidden' NAME='returnTo' VALUE='"
. "$returnTo'>\n<TABLE BORDER=0 CELLSPACING=0 "
. "CELLPADDING=0 ALIGN='center'>\n<TR>\n<TD ALIGN='center'>"
. "\n<INPUT TYPE='button' VALUE='OK' onClick=\"submit();\""
. ">\n</TD>\n</TR>\n</TABLE>\n</FORM>\n<SCRIPT TYPE='text/"
. "javascript'>\nsetTimeout(\"document.referForm.submit();"
. "\", 1000);\n</SCRIPT>\n");
} // END function criticalFileFailRedirect()
//**************
function doBusiness($uploadTplPath, $file, $functionName, $doctype, $action, $returnTo)
{
/*******************************************************************
This function has the task of reading from the file, and with
this data, producing the page.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 01/02/2001
Last Modified: 01/02/2001
*******************************************************************/
# Test to see if the file already exists.
if(!is_file("$uploadTplPath/$file"))
{
# The file does not exist. Create it.
if(!$filePtr = fopen("$uploadTplPath/$file", "w"))
{
# Unable to make the file
# Set an error flag to indicate the failure of this file creation.
$file_there = false;
} // END if
else
{
fclose($filePtr);
$file_there = true;
} // END else
} // END if
else
{
# File already exists, so we can set the flag to say so...
$file_there = true;
} // END else
# Now we can see if the file exists or not. If so, we can output
# our form, with its details. If not, we can simply present the
# user with an error message, and redirect the page back to
# "func.php".
if($file_there)
{
# read file contents
if(!$fPtr = fopen("$uploadTplPath/$file", "r"))
{
print("<DIV STYLE=\"color: red; font-size: large; text-align:"
. " center; font-weight: bold\">Unable To Open File."
. "</DIV>\n");
criticalFileFailRedirect($functionName, $doctype, $action,
$returnTo);
} // END if
else
{
print("<SPAN STYLE=\"color: navy; font-size: medium; font-"
. "weight: bold; text-align: center\">Contents of <EM>"
. "$file</EM></SPAN>\n");
#Separate our page out....
drawSeparator();
# Make our text area with all of the files data in it...
print("<FORM ACTION='editRecordFile.php' METHOD='post'>\n"
. "<INPUT TYPE='hidden' NAME='saveDets' VALUE='true'>\n"
. "<INPUT TYPE='hidden' NAME='file' VALUE='$file'>\n"
. "<INPUT TYPE='hidden' NAME='functionName' VALUE='"
. "$functionName'>\n<INPUT TYPE='hidden' NAME='doctype' "
. "VALUE='$doctype'>\n<INPUT TYPE='hidden' NAME='action'"
. " VALUE='$action'>\n<INPUT TYPE='hidden' NAME='returnTo"
. "' VALUE='$returnTo'>\n<TABLE ALIGN='center' BORDER=0 "
. "CELLSPACING=0 CELLPADDING=0>\n<TR>\n<TD ALIGN='center"
. "'>\n<TEXTAREA NAME='content' COLS=100 ROWS=25>");
fpassthru($fPtr);
# fpassthru() will have closed our file pointer for us.
print("</TEXTAREA>\n</TD>\n</TR>\n</TABLE><TABLE BORDER=0"
. " CELLSPACING=2 CELLPADDING=2 ALIGN='center'>\n<TR>\n"
. "<TD ALIGN='center'>\n<INPUT TYPE='button' VALUE='"
. "SAVE CHANGES' onClick=\"submit();\">\n</TD>\n<TD ALIGN"
. "='center'>\n<INPUT TYPE='reset' VALUE='RESET CHANGES'"
. ">\n</TD>\n</FORM>\n<FORM ACTION='func.php' METHOD='pos"
. "t'>\n<INPUT TYPE='hidden' NAME='functionName' VALUE='"
. "$functionName'>\n<INPUT TYPE='hidden' NAME='doctype' "
. "VALUE='$doctype'>\n<INPUT TYPE='hidden' NAME='action"
. "' VALUE='$action'>\n<INPUT TYPE='hidden' NAME='returnT"
. "o' VALUE='$returnTo'>\n<TD ALIGN='center'>\n<INPUT TYP"
. "E='button' VALUE='CANCEL' onClick=\"submit();\">\n<"
. "/TD>\n</FORM>\n</TR>\n</TABLE>\n");
} // END else
} // END if
else
{
# File can't be raised. Better just output error messages,
# and redirect page to "func.php".
print("<DIV STYLE=\"color: red; font-size: large; text-align:"
. " center; font-weight: bold\">Unable To Open File."
. "</DIV>\n");
criticalFileFailRedirect($functionName, $doctype, $action,
$returnTo);
} // END else
} // END function doBusiness()
function displayPage($uploadTplPath)
{
global $doctype,$saveDets,$functionName,$action,$returnTo,$content,$file;
$file=basename($file);
# Now perform tests to determine what to do
if(isset($saveDets))
{
# In this case, this is a self referential call to the form in
# order to update the file.
# Free some wasted space...
unset($saveDets);
if(!$fh = fopen("$uploadTplPath/$file", "w"))
{
# Could not open this file for writing.
print("<DIV STYLE=\"color: red; font-size: large; text-align:"
. " center; font-weight: bold\">Unable To Open File."
. "</DIV>\n");
criticalFileFailRedirect($functionName, $doctype, $action, $returnTo);
} // END if
else
{
# ereg_replace to replace any \015 (CR)
# (\r) chars with nothing.
$content = stripslashes(ereg_replace("\015","",$content));
# Open file for writing
if(!fwrite($fh, $content, strlen($content)))
{
# Couldn't write to the file.
print("<DIV STYLE=\"color: red; font-size: large; text-"
. "align: center; font-weight: bold\">Unable To Open File."
. "</DIV>\n");
fclose($fh);
criticalFileFailRedirect($functionName, $doctype, $action,
$returnTo);
} // END if
else
{
fclose($fh);
print("<DIV STYLE=\"color: green; font-size:"
. " medium; text-align: center; font-weight: bold\">File "
. "Updated</DIV>\n");
# Now redisplay the main page.
doBusiness($uploadTplPath, $file, $functionName, $doctype, $action, $returnTo);
} // END else
} // END else
} // END if
else
{
# This is the first call to this script, and it is simply our
# task to display the files dets in a textarea box, offering
# links to update it, or simply leave this form.
doBusiness($uploadTplPath, $file, $functionName, $doctype, $action, $returnTo);
} // END else
}
/**********************Start of main script***************************/
# Connect to the MySQL server
serverConnect(MYSQLDOCMACHINE, MYSQLDOCUSERID, MYSQLDOCPASSWORD);
# Select the CDS Search database...
dbSelect(DOCS_DATABASE);
$auth = canUseWebSubmitAdmin($uid,$doctype);
$uploadTplPath = "</protect><ETCDIR><protect>/bibconvert/config";
if (!$auth[0])
outWarning($auth[1] . "<br><br>" . "You are not allowed to access WebSubmit Admin for this type of documents");
else
displayPage($uploadTplPath);
/************************End of main script***************************/
</protect>
?>
Event Timeline
Log In to Comment