include_once('init.php');include_once('header.php');
include_once('Parsedown.php');
$mode=getpar('mode');
$docid=getpar('docid');
$id=getpar('id');
$opt=getpar('opt');
$docoff=getpar('docoff'); if (PM("/^\s*$/",$docoff)) $docoff=0;
if ($mode==='home') {
$_SESSION['currentoffset']=0;
header("Location: /");exit;
}
if (preg_match("/([A-Z,a-z])(\d+)/",$id,$M)) {
$catid=catidfromid(SU($id));
$xid=$id;
}
$page=getpar('page');
if (PM("/^\s*$/",$_SESSION['currentoffset'])) $_SESSION['currentoffset']=0;
if ($page==='NEXT') $_SESSION['currentoffset']+=100;
else if ($page==='PREV') $_SESSION['currentoffset']-=100;
$numrows=0;
if (!isset($_SESSION['currenttype'])) $_SESSION['currenttype']='ALL';
if (!PM("/^\s*$/",getpar('type'))) $_SESSION['currenttype']=SU(getpar('type'));
$TYPE=$_SESSION['currenttype'];
if (!isset($_SESSION['currentproject'])) $_SESSION['currentproject']='ALL';
if (!PM("/^\s*$/",getpar('project'))) $_SESSION['currentproject']=getpar('project');
$PROJECT=$_SESSION['currentproject'];
if (!isset($_SESSION['showhistory'])) $_SESSION['showhistory']=0;
if ($opt==='showhistory') $_SESSION['showhistory']=1;
if ($opt==='hidehistory') $_SESSION['showhistory']=0;
if (!PM("/^\s*$/",$opt)) {
header("Location: /$id");exit;
}
if (getpar('postform')==1) {
header("Location: /");exit;
}
if (PM("/^\d+$/",$catid)) {
$sql="SELECT * FROM cat WHERE catid=$catid AND $ACCESSQL";
$sql=PR("/\s*AND\s*$/","",$sql);
$res=mydo($DB,$sql,1);
$numrows =mysqli_num_rows($res);
if ($numrows==1) $row = mysqli_fetch_assoc($res);
$gen=array();
$sql="SELECT * FROM gen WHERE catid=$catid AND rm=0 ORDER BY gen";
$res=mydo($DB,$sql,1);
while($r = mysqli_fetch_assoc($res)) array_push($gen,$r['parent']);
$par=array();
$sql="SELECT * FROM gen WHERE parent=$catid AND rm=0 ORDER BY gen";
$res=mydo($DB,$sql,1);
while($r = mysqli_fetch_assoc($res)) array_push($par,$r['catid']);
}
?>
///////////////////////////////////////////////////////////////////////////////////// display single entry ?>
if ($numrows==1) { ?>
if ($mode==='print') {
exec("/db/bin/qrlabel $id '".$row['user']."' '".$row['f0']."'");
$connection = ssh2_connect('ripley.rz-berlin.mpg.de', 22,array('hostkey' => 'ssh-rsa'));
ssh2_auth_pubkey_file($connection, 'root','/db/ssh/id_rsa.pub','/db/ssh/id_rsa');
ssh2_scp_send($connection, "/db/tmp/$id.png", "/tmp/$id.png", 0644);
ssh2_exec($connection, "/usr/bin/lp -o fit-to-page -d archivzebra /tmp/$id.png");
ssh2_exec($connection, "/bin/rm /tmp/$id.png");
header("Location: /$id");exit;
}
?>
subheader(); ?>
Metadata
// metedata table ?>
if ($row['rm']==0) { ?>
Action
if (chkeditaccess($row)) { ?>
if (isset($LABELPRINTER)) { ?>
} ?>
} ?>
if ($row['fixed']==1) { ?>
fixed entry
} ?>
} ?>
= $_SESSION['s_ft'] ?>
// ----------------------------------------------------------------------------------------- document table
$fres=mydo($DB,"SELECT count(*) AS c FROM docs WHERE catid=".$row['catid']." AND rm=0",1);
$frow = mysqli_fetch_assoc($fres);
$fnumrows=$frow['c'];
if ($fnumrows>0) {
if ($fnumrows>150) {
if ($docoff>$fnumrows) $docoff=0;
if ($docoff<0) $docoff=0;
$don=$docoff+100;if ($don>$fnumrows) $don=0;
$dop=$docoff-100;if ($dop<0) $dop=0;
$prevlink="";
if ($docoff>0) $prevlink="PREV";
$nextlink="";
if ($docoff+100<$fnumrows) $nextlink="NEXT";
$sql="SELECT * FROM docs WHERE catid=".$row['catid']." AND rm=0 LIMIT $docoff,100";
} else {
$sql="SELECT * FROM docs WHERE catid=".$row['catid']." AND rm=0";
}
$res=mydo($DB,$sql);
echo "
Files
($fnumrows)";
if (!PM("/^\s*$/",$prevlink) || !PM("/^\s*$/",$nextlink)) echo " ";
if (!PM("/^\s*$/",$prevlink)) echo "
$prevlink
";
if (!PM("/^\s*$/",$nextlink)) echo "
$nextlink
";
?>
Id
File
Time
Comment
Size
Action
while($row = mysqli_fetch_assoc($res)) { ?>
if (isset($_SESSION['ftres'][$row['docid']])) {?>}?>
= $row['docid'] ?>
if (isset($_SESSION['ftres'][$row['docid']])) {?>}?>
if (isset($_SESSION['ftres'][$row['docid']])) {?>}?>
= $row['filename'] ?>
if (isset($_SESSION['ftres'][$row['docid']])) {?>}?>
} ?>
// ------------------------------------------------------------------------- show table with linked files
$sql="select * from cat,links where links.catid=$catid and cat.catid=links.link and $ACCESSQL";
$lres=mydo($DB,$sql,1);
$lnumrows =mysqli_num_rows($lres);
if ($lnumrows>0) { ?>
} ?>
///////////////////////////////////////////////////////////////////////////////// display multiple entries ?>
if ($numrows!=1 && isset($_SESSION['username'])) { ?>
$sql="";
if ($mode==='search' || !PM("/^\s*$/",$KEY)) {
if (PM("/^\s*\d+\s*$/",$KEY)) {
$sql.=" AND (catid=$KEY OR typeid=$KEY OR f0 LIKE '%$KEY%')";
} else if (preg_match("/^\s*([A-Z])\s*(\d+)\s*$/",SU($KEY),$M)) {
$sql.=" AND (catid=".catidfromid($M[1].$M[2])." OR f0 LIKE '%$KEY%')";
} else {
$sql.=" AND (f0 LIKE '%$KEY%' OR f1 LIKE '%$KEY%' OR f2 LIKE '%$KEY%' OR f3 LIKE '%$KEY%' OR ".
"f4 LIKE '%$KEY%')";
}
}
if (!PM("/^ALL$/",$TYPE)) $sql.=" AND UPPER(type)='$TYPE'";
if (!PM("/^ALL$/",$PROJECT)) $sql.=" AND project=".$PROJECTNAMES[$PROJECT];
$sql=PR("/\s*WHERE\s*$/","",$sql);
$sql=PR("/\s*AND\s*$/","",$sql);
$sql.=' ORDER BY catid DESC';
$res=mydo($DB,"SELECT count(*) AS c FROM cat WHERE $ACCESSQL $sql",1);
$row = mysqli_fetch_assoc($res);
$numrows=$row['c'];
if ($_SESSION['currentoffset']<0) $_SESSION['currentoffset']=0;
if ($_SESSION['currentoffset']>$numrows) $_SESSION['currentoffset']=0;
$res=mydo($DB,"SELECT * FROM cat WHERE $ACCESSQL $sql LIMIT ".$_SESSION['currentoffset'].",100",1);
$pof=$_SESSION['currentoffset']/100+1;
$nop=0; if ($numrows>0) $nop=intval($numrows/100)+1;
subheader("$numrows Results, Page $pof of $nop");
?>