Page MenuHomeHEPForge

test2.pl
No OneTemporary

test2.pl

#!/usr/bin/perl
require "subs.pl";
use DBI;
use CGI qw ( param header p );
print header ('text/html');
#$db = 'hepdata_input';
$db = 'hepdatatest';
$server = 'localhost';
$user = 'whalley';
$dbh = DBI->connect("dbi:mysql:$db:$server",$user);
system("cat /home/whalley/resource/header.html");
$text = param("text");
$submit = param("submit");
$npaper = param("npaper");
$nirn = param("nirn");
$nred = param("nred");
#$file = param("uploadedfile");
print "<form enctype='multipart/form-data' action='/resource-cgi/test2.pl' method='POST'>";
print "<input type='hidden' name='MAX_FILE_SIZE' value='10000'/>";
print "Choose a file to upload: <input name='uploadedfile' type='file' size='50' />";
print "<input type='submit' name='submit' value='UploadtheFile' />";
print "</form>";
if($nred ne ""){
&dbase2("select HepdataId from Papers where RedId=$nred");
if($rc ne '0E0'){
foreach $row (@$result){@list = split /\t/,join("\t",@$row);
$npaper=$list[0];
}
}
}
if($nirn ne ""){
&dbase2("select HepdataId from Papers where SpiresId=$nirn");
if($rc ne '0E0'){
foreach $row (@$result){@list = split /\t/,join("\t",@$row);
$npaper=$list[0];
# $npaper=$list[0];
}
}
}
if($submit eq 'GetRec') {
print "getting paper $npaper\n";
$str = "http://hepdata.cedar.ac.uk/h8test/view/p".$npaper."/input";
$text = `/usr/bin/wget -O - $str`;
}
if($submit eq 'GetRec9999') {
print "getting paper 9999\n";
$str = "http://hepdata.cedar.ac.uk/h8test/view/p9999/input";
$text = `/usr/bin/wget -O - $str`;
}
if($submit eq 'bdms2input') {
print "converting from bdms format to input format\n";
$text = `echo '$text' | /home/whalley/resource-cgi/bdms2input`;
}
if($submit eq 'Save') {
print "saving file";
open OUTPUT,">/var/www/plots/filetosave.txt";
print OUTPUT $text;
}
if($submit eq 'Recover_Last_Save') {
print "recovering file";
open INPUT,"</var/www/plots/filetosave.txt";
$text="";
while($line=<INPUT>){
$text .= $line;
}
}
if($submit eq 'UploadtheFile'){
$text = "";
$uploadedfile = param("uploadedfile");
while ($line = <$uploadedfile>){ $text .= $line; }
$last = $uploadedfile;
}
#print "<h2> Coding (cgi) </h2>";
print "<form method='post' action='/resource-cgi/test2.pl'>";
print "<input type='Submit' name='submit' value='Submit9999'/>";
print "-<input type='Submit' name='submit' value='GetRec9999'/>";
print "-<input type='Submit' name='submit' value='Delete9999'/>";
print "-<input type='Submit' name='submit' value='GetRec'/>";
print ":<input type='text' size='4' name='npaper' value='$npaper'/>";
#print "SpiresId<input type='text' size='8' name='nirn' value='$nirn'/>";
print "&nbsp;-&nbsp;Display as:&nbsp;";
print "<a href='http://hepdata.cedar.ac.uk/h8test/view/p9999' target='plots'>[HTML]</a>&nbsp;";
print "<a href='http://hepdata.cedar.ac.uk/h8test/view/p9999/bdms' target='plots'>[BDMS]</a>";
print "-<input type='Submit' name='submit' value='bdms2input'/><br/>";
print "<TEXTAREA cols=150 rows=30 name='text'>$text</textarea><br/>";
print "<input type='Submit' name='submit' value='Save'/>";
print "<input type='Submit' name='submit' value='Recover_Last_Save'/>";
print "<a href='/pdf-plots/filetosave.txt>right-click here and save to download the file....</a><br/>";
print "</form>";
system("cat /home/whalley/resource/footer.html");
if($submit eq 'Delete9999'){
# $npaper=9999;
foreach $npaper (9999...9999){
print "deleting paper $npaper...\n";
&deletePaperId($npaper);
}
}
if($submit eq 'Submit9999'){
$npaper = 9999;
print "adding paper $npaper ...\n";
&deletePaperId($npaper);
$text2 = $text;
if($text=~m/^\s*SC\s*=/){
$text2 = `echo '$text' | /home/whalley/resource-cgi/bdms2input`;
}
&addPaperId($npaper,$text2);
}
###########################################################################################
$dbh -> disconnect;
exit();

File Metadata

Mime Type
text/html
Expires
Sat, Dec 21, 12:56 PM (1 d, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4022847
Default Alt Text
test2.pl (3 KB)

Event Timeline