Page MenuHomec4science

Get_Sysno.php.wml
No OneTemporary

File Metadata

Created
Sat, Nov 16, 13:38

Get_Sysno.php.wml

## $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_Sysno.php
## Description: function Get_Sysno
## This function retrieves the system number of a document
## given its reference
## Author: T.Baron
## PARAMETERS: -
## OUTPUT: HTML
##
function Get_Sysno($param_array,$MAINPATH)
{
global $doctypes;
// initialize sysno variable
$sysno = "";
// First check if the "SN" file does not already exist
if (is_file("$MAINPATH/SN"))
{
$fp = fopen("$MAINPATH/SN","r");
$sysno = fread($fp,filesize("$MAINPATH/SN"));
fclose($fp);
}
if ($sysno != "")
{
#put result in global variable
$GLOBALS[VARS]->set_sysno($sysno);
}
else
{
$repno = $GLOBALS[VARS]->get_report_number();
$sysno = "";
$res = mysql_query("
SELECT id
FROM bib03x
WHERE value='$repno' and
tag='037__a'");
if ($arr = mysql_fetch_row($res))
{
$res2 = mysql_query("
SELECT id_bibrec
FROM bibrec_bib03x
WHERE id_bibxxx='".$arr[0]."'");
$result = mysql_fetch_row($res2);
$sysno = $result[0];
}
$res = mysql_query("
SELECT id
FROM bib08x
WHERE value='$repno' and
tag='088__a'");
if ($arr = mysql_fetch_row($res))
{
$res2 = mysql_query("
SELECT id_bibrec
FROM bibrec_bib08x
WHERE id_bibxxx='".$arr[0]."'");
$result = mysql_fetch_row($res2);
$sysno = $result[0];
}
if($sysno == "")
{
Request_Print("A", "
<SCRIPT>
document.forms[1].action=\"../Main.php\";
document.forms[1].page.value = 1;
document.forms[1].submit();
alert('The report $repno cannot be found in our database.\\nPerhaps it has not been integrated yet?\\nAnyway, you can choose another report number if you wish.\\n Or retry this action in a few minutes.');
</SCRIPT>");
// THE SCRIPT STOPS EXECUTION AT THIS POINT
exit;
}
#put result in global variable
$GLOBALS[VARS]->set_sysno($sysno);
#save result
$fp = fopen("$MAINPATH/SN","w+");
fwrite($fp,"$sysno");
fclose($fp);
}
}
</protect>
?>

Event Timeline