Skip to content

Commit b3ec7c8

Browse files
committed
testing new upload sys
1 parent 1e11f91 commit b3ec7c8

13 files changed

+80
-39
lines changed

Diff for: download.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
// Apre la risorsa SSH
77
$connection_handler = ssh2_connect($world['sshserver'],$world['sshport']);
88
if(!$connection_handler) {
9-
die("[globals.php] Connection Failed: ". $world['sshserver']." at ".$world['sshport']);
9+
die("[download.php] Connection Failed: ". $world['sshserver']." at ".$world['sshport']);
1010
}
1111

1212
// Esegue la autenticazione in SSH con password plain
1313
$connection = ssh2_auth_password($connection_handler,$_SESSION['username'],$_SESSION['password']);
1414
if (!$connection) {
15-
die("[globals.php] AuthPass Connection Failed!");
15+
die("[download.php] AuthPass Connection Failed!");
1616
}
1717

1818
// Copia il file in un punto raggiungibile dall'interprete

Diff for: globals.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
$world['sshport'] = "22";
1010
$world['queue_list'] = array("batch","Another_queue1","Another_queue2");
1111
$world['upload_temp'] = '/var/www/uploads';
12+
$debug = true;
1213

1314
// Bisogna ricordarsi di settare il parametro di upload_temp_dir
1415

@@ -18,7 +19,7 @@
1819

1920
$world['ClusterLogo2'] = "<img src=\"" . $world['ClusterLogo'] . "\" width=\"150px\">";
2021
$world['UniLogo2'] = "<img src=\"" . $world['UniLogo'] . "\" width=\"150px\">";
21-
$world['GangliaURL2'] = '<a href="' . $world['GangliaURL'] . '"><i class="icon-eye icon-white"></i> Ganglia</a>';
22+
$world['GangliaURL2'] = '<a href="' . $world['GangliaURL'] . '"><i class="icon-eye-open icon-white"></i> Ganglia</a>';
2223
$world['AdminMail2'] = "<a href=\"mailto:" . $world['AdminMail'] . "\">Contact Admin</a>";
2324
$world['AdminMail3'] = "<a href=\"mailto:" . $world['AdminMail'] . "\">here</a>";
2425

Diff for: html_include/qstatxml.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,12 @@ function make_job_table($j) {
284284

285285
<?
286286
// Debug options :: qstat has to be modified before production
287-
$qstat_cmd = 'cat $HOME/qstat.xml';
287+
if($debug) {
288+
$qstat_cmd = 'cat $HOME/qstat.xml';
289+
} else {
290+
$qsta_cmd = 'qstat -X';
291+
}
292+
288293
$qstat_xml = ssh2_exec2($_SESSION['username'], $_SESSION['password'], $qstat_cmd);
289294

290295
$jobout = "";

Diff for: html_include/qsub_run.php

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ function click_fun(obj) {
1212
var path = obj.innerHTML;
1313
$('#job_script_name').val(path);
1414
}
15+
function click_fun2(path) {
16+
$('#job_script_name').val(path);
17+
}
1518

1619
function Popup(apri) {
1720
window.open(encodeURI(apri), "", "top=10, left=10, width=800, height=600, status=no, menubar=no, toolbar=no scrollbars=no");

Diff for: html_include/qsubupload.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
<h1 align="center">Uploader <small>drag and drop</small></h1>
33
<h4>or click to open dialog</h4>
44
<p>Left here to upload in your $HOME directory<br />
5-
<small>$HOME = <? echo $_SESSION['home']; ?></small></p>
5+
<small>$HOME = <? echo $_SESSION['home']; ?>; Max file size = <? echo ini_get('upload_max_filesize') ?>; Max file num = <? echo ini_get('max_file_uploads') ?></small></p>
66
</div>
77
<form class="form-actions" method="post" action="upload_scp.php" enctype="multipart/form-data">
88
<input id="input_file" style="display:none;" type="file" multiple="" name="filesToUpload[]"/>
9-
<input type="hidden" name="<?php echo ini_get("session.upload_progress.name"); ?>" value="demo">
109
<div id="list_file"></div>
1110
<button type="submit" class="btn btn-primary btn-large" value="Send"><i class="icon-white icon-file"></i> Upload files</button>
1211
</form>

Diff for: html_include/tree_explorer.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ function tree_xml_decode($xml, $path) {
3838
<h5>
3939
<a onclick="Popup('."'".'catfile.php?file2cat='.$path.$file['name']."'".')" data-toggle="tooltip" title="Open and show file">
4040
<i class="icon-file"></i></a>
41-
<a onclick="Popup('."'".'download.php?file='.$path.$file['name']."'".')" data-toggle="tooltip" title="Download">
41+
<a href="download.php?file='.$path.$file['name'].'" data-toggle="tooltip" title="Download">
4242
<i class="icon-download-alt"></i></a>
43-
<a onclick="Popup('."'".'download.php?file='.$path.$file['name']."'".')" data-toggle="tooltip" title="Put file in launch textbox">
43+
<a onclick="click_fun2('."'".$path.$file['name']."'".')" data-toggle="tooltip" title="Put file in launch textbox">
4444
<i class="icon-circle-arrow-right"></i></a>
4545
' . $file['name'] . '
46-
<small>Last Modified: ' . $file['time'] . ' - Size: ' . $file['size'] . 'B - Path: '. $href .'</small></h5>
46+
<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>
4749
</li>
4850
';
4951
}

Diff for: index.php

+1-12
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,7 @@
6868
<!-- Fine Body -->
6969

7070
<!-- FOOTER -->
71-
<div id="footer">
72-
<div class="container">
73-
<table width="100%">
74-
<tr><td>
75-
<p class="muted credit"><? echo $world['University']; ?></p>
76-
<p class="author"><a href="mailto:[email protected]">Matteo Ragni</a> - PBSWebUI 2013 - <? echo $VERSION ?></p>
77-
</td><td align="right">
78-
<? echo $world['ClusterLogo2']; ?>
79-
</td></tr>
80-
</table>
81-
</div>
82-
</div>
71+
<? include('html_include/footer.php'); ?>
8372
<!-- FINE FOOTER -->
8473
</body>
8574
</html>

Diff for: login_ssh.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
session_start();
44
include_once("globals.php");
55

6-
$_SESSION['home'] = null;$snip =
6+
$_SESSION['home'] = null;
77

88
$_SESSION['home'] = preg_replace('~[[:cntrl:]]~', '', ssh2_exec2($_POST['username'],$_POST['password'],'echo $HOME'));
99

Diff for: mainmenu.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<div class="span4">
8484
<h2>Ganglia</h2>
8585
<p>Access the monitoring system to keep under control the whole cluster.</p>
86-
<p><a class="btn btn-primary" href=<?echo $world['GangliaURL'];?> ><i class="icon-white"></i> Go to Ganglia...</a></p>
86+
<p><a class="btn btn-primary" href=<?echo $world['GangliaURL'];?> ><i class="icon-eye-open icon-white"></i> Go to Ganglia...</a></p>
8787
</div>
8888
</div>
8989
</div> <!-- /container -->

Diff for: queue_status.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,21 @@
4545
<!-- Fine Header -->
4646

4747
<!-- Body -->
48+
<!-- Suddivisione in Tab: header delle tab -->
4849
<div class="container" id="common-page">
49-
<? include('html_include/qstatxml.php'); ?>
50-
</div> <!-- /container -->
50+
<ul class="nav nav-tabs" id="myTab">
51+
<li class="active">
52+
<a href="#queue_state" data-toggle="tab"><h3>Status Queue</h3></a>
53+
</li>
54+
</ul>
55+
56+
<!-- Suddivisione in Tab: Contenuto delle tab -->
57+
<div id="myTabContent" class="tab-content">
58+
<div class="tab-pane active" id="queue_state">
59+
<? include('html_include/qstatxml.php'); ?>
60+
</div> <!-- /container -->
61+
</div>
62+
</div> <!-- div myTabContent -->
5163
<!-- Fine Body -->
5264

5365
<!-- FOOTER -->

Diff for: sshinterf.php

+14-3
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,21 @@
4545
<!-- Fine Header -->
4646

4747
<!-- Body -->
48+
<!-- Suddivisione in Tab: header delle tab -->
4849
<div class="container" id="common-page">
49-
<h1>Session under development!<h1>
50-
51-
</div> <!-- /container -->
50+
<ul class="nav nav-tabs" id="myTab">
51+
<li class="active">
52+
<a href="#sshinterf" data-toggle="tab"><h3>Status Queue</h3></a>
53+
</li>
54+
</ul>
55+
56+
<!-- Suddivisione in Tab: Contenuto delle tab -->
57+
<div id="myTabContent" class="tab-content">
58+
<div class="tab-pane active" id="sshinterf">
59+
<h3>Under construction!</h3>
60+
</div> <!-- /container -->
61+
</div>
62+
</div> <!-- div myTabContent -->
5263
<!-- Fine Body -->
5364

5465
<!-- FOOTER -->

Diff for: upload_scp.php

+30-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
11
<?php
22
session_start();
3-
43
include_once('globals.php');
5-
$redirect = "https://".$_SERVER['HTTP_HOST']."/index.php";
6-
if (!isset($_SESSION['username'])) { header("Location:$redirect"); }
7-
if (!isset($_SESSION['password'])) { header("Location:$redirect"); }
8-
if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
94

10-
$error_msg = array("OK", "exceed max_file_uppload", "exceed max_file_size", "partial upload", "no file uploaded", "write to disk failed", "temp dir missing", "unknown extension error");
5+
//$redirect = "https://".$_SERVER['HTTP_HOST']."/index.php";
6+
//if (!isset($_SESSION['username'])) { header("Location:$redirect"); }
7+
//if (!isset($_SESSION['password'])) { header("Location:$redirect"); }
8+
//if (!isset($_SESSION['home'])) { header("Location:$redirect"); }
9+
10+
$error_msg = array("OK", "exceed max_file_size - ini", "exceed max_file_size", "partial upload", "no file uploaded", "write to disk failed", "temp dir missing", "unknown extension error");
1111

12-
echo "<h3>Uploading files...</h3>";
12+
// Apre la risorsa SSH
13+
$connection_handler = ssh2_connect($world['sshserver'],$world['sshport']);
14+
if(!$connection_handler) {
15+
die("[upload_scp.php] Connection Failed: ". $world['sshserver']." at ".$world['sshport']);
16+
}
17+
18+
// Esegue la autenticazione in SSH con password plain
19+
$connection = ssh2_auth_password($connection_handler,$_SESSION['username'],$_SESSION['password']);
20+
if (!$connection) {
21+
die("[upload_scp.php] AuthPass Connection Failed!");
22+
}
1323

1424
foreach ($_FILES["filesToUpload"]["error"] as $key => $error) {
1525
if ($error == UPLOAD_ERR_OK) {
1626
$tmp_name = $_FILES["filesToUpload"]["tmp_name"][$key];
1727
$name = $_FILES["filesToUpload"]["name"][$key];
18-
move_uploaded_file($tmp_name, $world['upload_temp'] . "/" . $name);
19-
$cp_string = "cp " . $world['upload_temp'] . "/" . $name . " " . $_SESSION['home'];
20-
ssh2_exec2($_SESSION['username'],$_SESSION['password'], $cp_string);
21-
unlink($world['upload_temp'] . "/" . $name);
28+
29+
$source = $world['upload_temp'] . '/' . $name;
30+
$destination = $_SESSION['home'] . '/' .$name;
31+
32+
// localhost
33+
move_uploaded_file($tmp_name, $source);
34+
// copy to remote host
35+
if (!ssh2_scp_send($connection_handler, $source, $destination)) {
36+
die("[upload_scp.php] SCP not worked for: $name");
37+
}
38+
//unlink($source);
39+
} else {
40+
die("[upload_scp.php] Cannot upload ".$_FILES["filesToUpload"]["name"][$key].": error: ".$error_msg[$error]);
2241
}
2342
}
2443

Diff for: uploads/chromeinstall-7u17.exe

876 KB
Binary file not shown.

0 commit comments

Comments
 (0)