Please login with individual username (not the generic 'trd')."; exit(0); } ?> Error with file #$i"; require('gate_footer.php'); exit; } #echo "

File $i: ".$_FILES["attachment_file$i"]['name']."

\n"; } } pg_exec("begin"); $result = pg_query ( "INSERT INTO comment(title,body,person) VALUES ". "('".$_REQUEST["title"]."','".$_REQUEST["body"]. "','".$_SESSION["person"]."');" ) ; if ( ! $result ) { gate_header("Error"); echo "
\n"; echo "
Adding comment failed
\n"; echo "
\n"; gate_footer(); exit; } $result = pg_query("SELECT lastval() AS cmnt_id"); $row = pg_fetch_assoc($result); $cmnt_id = $row['cmnt_id']; #echo "

cmnt_id = $cmnt_id

\n"; if ($_REQUEST["item_type"] == "ori") { $result = pg_query ("INSERT INTO ori_cmnt_link(ori_id,cmnt_id) VALUES ". "(".$_REQUEST["id"].",$cmnt_id);"); $itemhref = "ori.php?id=".$_REQUEST["id"]; } else if ($_REQUEST["item_type"] == 'dcs') { $result = pg_query ("INSERT INTO dcs_cmnt_link(dcs_id,cmnt_id) VALUES ". "(".$_REQUEST["id"].",$cmnt_id);"); #$itemhref = "DCS #". # $_REQUEST["id"].""; $itemhref = "dcs.php?id=".$_REQUEST["id"]; } else if ($_REQUEST["item_type"] == 'rob') { $result = pg_query ("INSERT INTO rob_cmnt_link(rob_id,cmnt_id) VALUES ". "(".$_REQUEST["id"].",$cmnt_id);"); $itemhref = "rob.php?id=".$_REQUEST["id"]; #$itemhref = "DCS #". # $_REQUEST["id"].""; } else if ($_REQUEST["item_type"] == 'roc') { $result = pg_query ("INSERT INTO ". "roc_cmnt_link(roc_type,roc_serial,cmnt_id) VALUES ". "('".$_REQUEST["type"]."',".$_REQUEST["serial"]. ",$cmnt_id);"); $itemhref = "roc.php?name=".$_REQUEST["name"]; #$itemhref = "DCS #". # $_REQUEST["id"].""; } else if ($_REQUEST["item_type"] == 'sm') { $result = pg_query ("INSERT INTO sm_cmnt_link(sm_id,cmnt_id) VALUES ". "(".$_REQUEST["id"].",$cmnt_id);"); $itemhref = "sm.php?id=".$_REQUEST["id"]; } else { gate_header("Error"); echo "
\n"; echo "
HALLO Unknown item type -".$_REQUEST["item_type"]."-. Adding comment failed
\n"; echo "
\n"; gate_footer(); exit; } if ( ! $result ) { gate_header("Error"); echo "
\n"; echo "
Adding comment failed
\n"; echo "
\n"; gate_footer(); exit; } for ($i=0; $i<5; $i++) { if ($_FILES["attachment_file$i"]['error'] == 0) { $fp = fopen($_FILES["attachment_file$i"]['tmp_name'], "r"); if ($fp == false) { gate_header("Error"); echo "
\n"; echo "
Error with file
\n"; echo "
\n"; gate_footer(); exit; } $lo_id = pg_lo_create(); $lo_fp = pg_lo_open($gate_conn,$lo_id, "w"); // for ever 8192 bytes of the uploaded file while($buffer = fread($fp, 8192*16)) { // write to the large object pg_lo_write($lo_fp, $buffer); } pg_loclose($lo_fp); fclose($fp); pg_exec("INSERT INTO file(name,mime_type,loid) VALUES ('". $_REQUEST["attachment_title$i"]."','". $_REQUEST["attachment_mimetype$i"]."',$lo_id)"); pg_exec("UPDATE comment SET attachment$i=lastval() WHERE cmnt_id=$cmnt_id"); } } pg_exec("commit"); gate_redirect_page($itemhref); #echo "
Successfully added comment on $itemhref
\n"; ?>