Skip to content

Commit 094e939

Browse files
committedApr 30, 2013
Added script that call torque's binaries. Minor changes.
1 parent b3ec7c8 commit 094e939

12 files changed

+212
-17
lines changed
 

‎delete.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?
2+
session_start();
3+
4+
include_once('globals.php');
5+
6+
$redirect = "https://".$_SERVER['HTTP_HOST']."/index.php";
7+
if (!isset($_SESSION['username'])) { header("Location:$redirect"); }
8+
if (!isset($_SESSION['password'])) { header("Location:$redirect"); }
9+
if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
10+
11+
// Apre la risorsa SSH
12+
$connection_handler = ssh2_connect($world['sshserver'],$world['sshport']);
13+
if(!$connection_handler) {
14+
die("[delete.php] Connection Failed: ". $world['sshserver']." at ".$world['sshport']);
15+
}
16+
17+
// Esegue la autenticazione in SSH con password plain
18+
$connection = ssh2_auth_password($connection_handler,$_SESSION['username'],$_SESSION['password']);
19+
if (!$connection) {
20+
die("[delete.php] AuthPass Connection Failed!");
21+
}
22+
23+
$sftp = ssh2_sftp($connection_handler);
24+
25+
// Elimino il file, usando le risorse di connessione
26+
$file = $_SESSION['home'].'/'.$_GET['file'];
27+
if (!ssh2_sftp_unlink($sftp,$file)) {
28+
die("[delete.php] Cannot delete file: ".$_GET['file']);
29+
}
30+
$redirect = "https://".$_SERVER['HTTP_HOST']."/jsubmit.php#ReloadExisting";
31+
header('Location:'.$redirect);
32+
?>

‎download.php

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
include_once('globals.php');
55

6+
$redirect = "https://".$_SERVER['HTTP_HOST']."/index.php";
7+
if (!isset($_SESSION['username'])) { header("Location:$redirect"); }
8+
if (!isset($_SESSION['password'])) { header("Location:$redirect"); }
9+
if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
10+
11+
612
// Apre la risorsa SSH
713
$connection_handler = ssh2_connect($world['sshserver'],$world['sshport']);
814
if(!$connection_handler) {

‎globals.php

+19
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,25 @@ function redirectssl() {
7575
}
7676
}
7777

78+
function ssh2_exec3($connection, $command) {
79+
80+
$ssh_stream = ssh2_exec($connection, $command);
81+
if (!$ssh_stream) {
82+
die("[globals.php: line 41] Cannot execute: $command");
83+
}
84+
else {
85+
// Estrai lo stream
86+
stream_set_blocking($ssh_stream, true);
87+
$output = "";
88+
while ($buf = fread($ssh_stream,4096*8)) {
89+
$output .= $buf;
90+
}
91+
fclose($ssh_stream);
92+
}
93+
return $output;
94+
95+
}
96+
7897
function ssh2_sftp_down($username, $password, $abs_path) {
7998

8099
global $world;

‎html_include/header.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</a>
3131
</li>
3232
<li <? if ($active === 'submit') { echo 'class="active"'; } ?>>
33-
<a href="jsubmit.php">
33+
<a href="jsubmit.php#FormCreate">
3434
<i class="icon-download-alt icon-white"></i>
3535
Submit
3636
</a>

‎html_include/qsub_run.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<form class="form-actions">
1+
<form class="form-actions" method="POST" action="job_rerun.php" onSubmit="return popWindow(this.target)" target="Details">
22
<div class="input-prepend input-append">
33
<span class="add-on"><? echo '<strong>' . $_SESSION['username'] . ':~$ qsub</strong> ' . $_SESSION['home'] . '/ '; ?></span>
44
<input align="center" class="input-block-level input-xxlarge" id="job_script_name" type="text" name="relative_path"
@@ -16,9 +16,22 @@ function click_fun2(path) {
1616
$('#job_script_name').val(path);
1717
}
1818

19+
function click_delete(path) {
20+
if(confirm("Are you sure? Delete: "+path)){
21+
location.href = "delete.php?file="+path;
22+
}
23+
}
24+
1925
function Popup(apri) {
2026
window.open(encodeURI(apri), "", "top=10, left=10, width=800, height=600, status=no, menubar=no, toolbar=no scrollbars=no");
2127
}
28+
29+
function popWindow(wName){
30+
features = 'width=400,height=400,toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,copyhistory=no';
31+
pop = window.open('',wName,features);
32+
if(pop.focus){ pop.focus(); }
33+
return true;
34+
}
2235
</script>
2336

2437
<? include('html_include/tree_explorer.php'); ?>

‎html_include/qsubform.php

+15-5
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function stylePreview() {
238238
title="Script Name" data-content="In this field you can insert a name for your script. Remember that if there is already a script with the same name in your home folder, it'll be overwritten.<br /> Interface automatically adds .pbs extension"
239239
data-html="true" data-container="body">Script Name</a>
240240
<input class="input-block-level input-xlarge" id="scriptname appendPrependInput"
241-
type="text" name="scriptname" placeholder="Insert script name" />
241+
type="text" name="scriptname" placeholder="Insert script name" form="form-submit-script" />
242242
<span class="add-on">.pbs</span>
243243
</div>
244244
</div>
@@ -253,7 +253,7 @@ function stylePreview() {
253253
<a id="jobname_ee" href="#" data-toggle="popover" data-title="Error"
254254
data-content="Use only a-z, 0-9, - and _" data-trigger="manual" data-container="body">
255255
<input class="input-block-level input-xlarge" id="jobname prependInput" type="text"
256-
name="jobname" placeholder="Insert job name" onkeypress="compose();"/>
256+
name="jobname" placeholder="Insert job name" onkeypress="compose();" onchange="compose();"/>
257257
</a>
258258
</div>
259259
</div>
@@ -596,7 +596,7 @@ function stylePreview() {
596596
</fieldset>
597597
</form>
598598

599-
<form class="form-actions" method="POST" action="submit_run.php">
599+
<form class="form-actions" method="POST" action="submit_run.php" onSubmit="return popWindow(this.target)" target="Details" id="form-submit-script">
600600
<input id="result_script" type="text" name="result_script" style="display:none;">
601601
<p align="right">
602602
<button type="submit" class="btn btn-primary btn-large"><i class="icon-download-alt icon-white" ></i> Save and submit PBS script</button>
@@ -607,7 +607,7 @@ function stylePreview() {
607607
<div id="envvars-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
608608
<div class="modal-header">
609609
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
610-
<h3 id="myModalLabel">EnvVariables</h3>
610+
<h3 id="myModalLabel">List variables</h3>
611611
</div>
612612
<div class="modal-body">
613613
<p>
@@ -718,4 +718,14 @@ function stylePreview() {
718718
TODO
719719
* Require GPUS sostituire la textbox con una checkbox!
720720
-->
721-
<script> compose(); </script>
721+
<script>
722+
723+
compose();
724+
725+
function popWindow(wName){
726+
features = 'width=400,height=400,toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,copyhistory=no';
727+
pop = window.open('',wName,features);
728+
if(pop.focus){ pop.focus(); }
729+
return true;
730+
}
731+
</script>

‎html_include/tree_explorer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ function tree_xml_decode($xml, $path) {
4444
<i class="icon-circle-arrow-right"></i></a>
4545
' . $file['name'] . '
4646
<small>Last Modified: ' . $file['time'] . ' - Size: ' . $file['size'] . 'B - Path: '. $href .'</small>
47-
<a onclick="click_fun3('."'".$path.$file['name']."'".')" data-toggle="tooltip" title="Put file in launch textbox">
48-
<i class="icon-remove icon-white" style="background-color:red;border-radius:100%" ></i></a></h5>
47+
<a onclick="click_delete('."'".$path.$file['name']."'".')" data-toggle="tooltip" title="Delete file" class="pull-right">
48+
<i class="icon-remove icon-white" style="background-color:red; border-radius:100%" ></i></a></h5>
4949
</li>
5050
';
5151
}

‎job_rerun.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?
2+
session_start();
3+
4+
include_once('globals.php');
5+
6+
$redirect = "https://".$_SERVER['HTTP_HOST']."/index.php";
7+
if (!isset($_SESSION['username'])) { header("Location:$redirect"); }
8+
if (!isset($_SESSION['password'])) { header("Location:$redirect"); }
9+
if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
10+
11+
if($debug) {
12+
$qsub_cmd = 'echo "Result of '.$_POST['relative_path'].'\n" && cat '.$_POST['relative_path'];
13+
} else {
14+
$qsub_cmd = 'qsub '.$_POST['relative_path'];
15+
}
16+
17+
$output = ssh2_exec2($_SESSION['username'],$_SESSION['password'],$qsub_cmd);
18+
19+
?>
20+
<head>
21+
<title>Submission Result</title>
22+
<? include_once('html_include/styles.php'); ?>
23+
</head>
24+
<body>
25+
<div class="navbar navbar-fixed-top navbar-inverse" style="position: absolute;">
26+
<div class="navbar-inner">
27+
<div class="container" style="width: auto; padding: 0 20px;">
28+
<a class="brand" href="#">PBS Response</a>
29+
<ul class="nav pull-right">
30+
<li><a href="javascript:window.close()"><div class="badge badge-important"
31+
style="position:relative; top:-1px;">Close</div>
32+
</a></li>
33+
</ul>
34+
</div>
35+
</div>
36+
</div>
37+
<div class="well" style="padding: 50px;">
38+
39+
<? echo '<pre><code>' . $output . '</code></pre>'; ?>
40+
41+
</div>
42+
</body>

‎jsubmit.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@
3838

3939
<!-- Styles and scripts -->
4040
<? include('html_include/styles.php'); ?>
41-
41+
<script>
42+
$(document).ready( function() {
43+
var tabsel = '#myTab a[href="#' + location.hash.slice(1) + '"]';
44+
$(tabsel).tab('show');
45+
});
46+
</script>
47+
4248
<!-- ###################################### -->
4349
<body>
4450

@@ -49,20 +55,20 @@
4955
<!-- Body -->
5056
<div class="container" id="common-page">
5157
<ul class="nav nav-tabs" id="myTab">
52-
<li class="active">
53-
<a href="#form_create" data-toggle="tab"><h3>Use form to create script</h3></a>
58+
<li>
59+
<a id="qsubForm" href="#FormCreate" data-toggle="tab"><h3>Use form to create script</h3></a>
5460
</li>
5561
<li>
56-
<a href="#UploadFiles" data-toggle="tab"><h3>Upload script or files</h3></a>
62+
<a id="Uploader" href="#UploadFiles" data-toggle="tab"><h3>Upload script or files</h3></a>
5763
</li>
5864
<li>
59-
<a href="#ReloadExisting" data-toggle="tab"><h3>Run script</h3></a>
65+
<a id="Reloader" href="#ReloadExisting" data-toggle="tab"><h3>Run script</h3></a>
6066
</li>
6167
</ul>
6268

6369
<!-- Suddivisione in Tab: Contenuto delle tab -->
6470
<div id="myTabContent" class="tab-content">
65-
<div class="tab-pane active" id="form_create">
71+
<div class="tab-pane" id="FormCreate">
6672
<? include('html_include/qsubform.php'); ?>
6773
</div>
6874
<div class="tab-pane" id="UploadFiles">

‎submit_run.php

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?
2+
session_start();
3+
4+
include_once('globals.php');
5+
6+
$redirect = "https://".$_SERVER['HTTP_HOST']."/index.php";
7+
if (!isset($_SESSION['username'])) { header("Location:$redirect"); }
8+
if (!isset($_SESSION['password'])) { header("Location:$redirect"); }
9+
if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
10+
11+
$tmpfile = '/tmp/'.uniqid('qsub-');
12+
file_put_contents($tmpfile, $_POST['result_script']);
13+
if(!$_POST['scriptname']) { $_POST['scriptname'] = uniqid('qsub-'); }
14+
$file = $_SESSION['home'].'/'.$_POST['scriptname'].'.pbs';
15+
16+
// Apre la risorsa SSH
17+
$connection_handler = ssh2_connect($world['sshserver'],$world['sshport']);
18+
if(!$connection_handler) {
19+
die("[submit_run.php] Connection Failed: ". $world['sshserver']." at ".$world['sshport']);
20+
}
21+
22+
// Esegue la autenticazione in SSH con password plain
23+
$connection = ssh2_auth_password($connection_handler,$_SESSION['username'],$_SESSION['password']);
24+
if (!$connection) {
25+
die("[submit_run.php] AuthPass Connection Failed!");
26+
}
27+
28+
// Invia lo script al nodo master che dovrà avviarlo
29+
if (!ssh2_scp_send($connection_handler, $tmpfile, $file)) {
30+
die("[submit_run.php] SCP not worked for: $name");
31+
}
32+
// Cancella il file sul sistema attuale
33+
unlink($tmpfile);
34+
35+
if($debug) {
36+
$qsub_cmd = 'echo "Result of '.$file.'\n" && cat '.$file;
37+
} else {
38+
$qsub_cmd = 'qsub '.$file;
39+
}
40+
41+
$output = ssh2_exec3($connection_handler, $qsub_cmd);
42+
?>
43+
44+
<head>
45+
<title>Submission Result</title>
46+
<? include_once('html_include/styles.php'); ?>
47+
</head>
48+
<body>
49+
<div class="navbar navbar-fixed-top navbar-inverse" style="position: absolute;">
50+
<div class="navbar-inner">
51+
<div class="container" style="width: auto; padding: 0 20px;">
52+
<a class="brand" href="#">PBS Response</a>
53+
<ul class="nav pull-right">
54+
<li><a href="javascript:window.close()"><div class="badge badge-important"
55+
style="position:relative; top:-1px;">Close</div>
56+
</a></li>
57+
</ul>
58+
</div>
59+
</div>
60+
</div>
61+
<div class="well" style="padding: 50px;">
62+
<?
63+
echo '<pre><code>' . $output . '</code></pre>';
64+
?>
65+
</div>
66+
</body>
67+

‎upload_scp.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
if (!ssh2_scp_send($connection_handler, $source, $destination)) {
3636
die("[upload_scp.php] SCP not worked for: $name");
3737
}
38-
//unlink($source);
38+
unlink($source);
3939
} else {
4040
die("[upload_scp.php] Cannot upload ".$_FILES["filesToUpload"]["name"][$key].": error: ".$error_msg[$error]);
4141
}
4242
}
4343

44-
$redirect = "https://".$_SERVER['HTTP_HOST']."/jsubmit.php";
44+
$redirect = "https://".$_SERVER['HTTP_HOST']."/jsubmit.php#UploadFiles";
4545
header("Location:$redirect");
4646

4747
// Possibili miglioramenti: usare php_session_upload_progress per mostrare le

‎uploads/chromeinstall-7u17.exe

-876 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.