Page MenuHomec4science

editRecordFile.php.wml
No OneTemporary

File Metadata

Created
Thu, Jul 11, 09:51

editRecordFile.php.wml

## $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> &gt; <a class=navtrail href=<WEBURL>/admin/websubmit/><MSG_ADMIN_SUBMIT></a>" \
navbar_name="admin" \
navbar_select="websubmit"
<?
<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($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($file))
{
# The file does not exist. We had better create it...
if(!$filePtr = fopen($file, "w"))
{
# Unable to make the file
print("<SCRIPT TYPE='text/javascript'>\nalert('Error: "
. "The file $file did not exist, nor "
. "could it be created.\\n\\nTry again or inform the "
. "system administrator.');\n</SCRIPT>\n");
# Set an error flag to indicate the failure of this file
# creation.
$file_there = false;
} // END if
else
{
# ok, set file there equal to true, as we have managed to
# create it.
$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)
{
# Cool. Our file lives.
# Cool. Now we must open our file (Possibly again if it
# hadn't already existed!), and read its contents...
if(!$fPtr = fopen($file, "r"))
{
# Great, the damn file did not open...
print("<SCRIPT TYPE='text/javascript'>\nalert('Unable To Open"
. " File.\\nRetry Or Inform System Administrator.');\n"
. "</SCRIPT>\n");
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
{
# Cool. We have opened it just nicely...
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("<SCRIPT TYPE='text/javascript'>\nalert('Unable To Open"
. " File.\\nRetry Or Inform System Administrator.');\n"
. "</SCRIPT>\n");
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()
{
global $doctype,$saveDets,$functionName,$action,$returnTo,$content,$file;
# Now perform tests in order to determine what we want 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($file, "w"))
{
# Oh dear. We could not open this file for writing.
print("<SCRIPT TYPE='text/javascript'>\nalert('Unable To Open"
. " File.\\nRetry Or Inform System Administrator.');\n"
. "</SCRIPT>\n");
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
{
# Let's use ereg_replace to replace any weird MAC \015 (CR)
# (\r) chars with nothing.
$content = stripslashes(ereg_replace("\015","",$content));
# Good. We can open our file.
if(!fwrite($fh, $content, strlen($content)))
{
# Couldn't write to the file.
print("<SCRIPT TYPE='text/javascript'>\nalert('ERROR: "
. "Unable to write details to file.');\n</SCRIPT>\n");
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
{
# We should have by now written our details to the file,
# and so should close it.
fclose($fh);
print("<SCRIPT TYPE='text/javascript'>\nalert('File Update"
. "d');\n</SCRIPT>\n<DIV STYLE=\"color: green; font-size:"
. " medium; text-align: center; font-weight: bold\">File "
. "Updated</DIV>\n");
# Now redisplay the main page.
doBusiness($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($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);
if (!$auth[0])
outWarning($auth[1] . "<br><br>" . "You are not allowed to access WebSubmit Admin for this type of documents");
else
displayPage();
/************************End of main script***************************/
</protect>
?>

Event Timeline