Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93833315
FORMAT_add.shtml.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, 21:13
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Dec 3, 21:13 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
22711058
Attached To
R3600 invenio-infoscience
FORMAT_add.shtml.wml
View Options
<?
/*********************************************************************
This file is part of the CERN Document Server Software (CDSware).
Copyright (C) 2002 CERN.
1211 Geneva 23 - Switzerland
<cds.support@cern.ch>
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
*********************************************************************/
//==========================================================================
// File: FORMAT_add.shtml (flexElink WI)
// Description: Adds a new format to the DB. It will only add the format if the
// EL code is syntactically correct and it's "interpretable". It serializes
// the EL code into the corresponding semantic structure and stores it
// in the DB for optimization (no need to re-compile afterwards)
// POST parameters:
// fname --> (required) Name (id) of the format to be added
// doc ----> (optional) Description of the purpose of the format
// code ---> (optional) Format's EL code
// Notes: If the format is succesfully added to the DB it redirects the current
// browser to the format display list
// Requires: DB, ERROR, EXECUTOR
// Author: Hector.Sanchez@cern.ch
//==========================================================================
include("localconf.inc.shtml");
include(DB);
include(ERROR);
if( (!isset($fname)) or (trim($fname)=="") )
{
errorpage("<b>Format name</b> hasn't been specified");
exit;
}
if(!isset($doc))
$doc="";
if(!isset($code))
$code="";
else
{
$temp_code=$code;
if(get_magic_quotes_gpc())
$temp_code=stripslashes($temp_code);
include(EXECUTOR);
$a=new AELExecutor();
list($ok, $msg)=$a->checkCode( $temp_code, array($fname) );
if(!$ok)
{
errorpage("Code incorrect: <b>$msg</b>");
exit;
}
$ser=addslashes(serialize($msg));
}
$db=mysql_connect( $DB_HOST, $DB_USER, $DB_PASSWD )
or errormsg("Couldn't connect to mySQL") or exit;
mysql_selectdb( $DB_DB );
$fname=trim(strtoupper($fname));
if(!get_magic_quotes_gpc())
{
$doc=addslashes($doc);
}
$qry="insert into flxFORMATS (name, value, doc, serialized)
values ('$fname', '$code', '$doc', '$ser')";
if(!mysql_query( $qry ))
{
errorpage("Impossible to insert new format:<br> ".mysql_error());
mysql_close( $db );
exit;
}
mysql_close( $db );
header("location: FORMAT_display.shtml");
?>
Event Timeline
Log In to Comment