Page MenuHomec4science

FORMAT_add.php.wml
No OneTemporary

File Metadata

Created
Thu, May 16, 23:26

FORMAT_add.php.wml

<?
/*********************************************************************
This file is part of CDS Invenio.
Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
1211 Geneva 23 - Switzerland
<cds.support@cern.ch>
CDS Invenio 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.
CDS Invenio 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 CDS Invenio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*********************************************************************/
//==========================================================================
// File: FORMAT_add.php (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.php");
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.php");
?>

Event Timeline