[Fusionforge-commits] r15705 - in trunk/src: common/include www/account www/themes/funky/images www/themes/gforge/images

Franck VILLAUME nerville at fusionforge.org
Sun Jun 10 14:18:44 CEST 2012


Author: nerville
Date: 2012-06-10 14:18:43 +0200 (Sun, 10 Jun 2012)
New Revision: 15705

Added:
   trunk/src/www/themes/funky/images/waiting.png
   trunk/src/www/themes/gforge/images/waiting.png
Modified:
   trunk/src/common/include/User.class.php
   trunk/src/www/account/index.php
Log:
partial implementation for feature request #382

Modified: trunk/src/common/include/User.class.php
===================================================================
--- trunk/src/common/include/User.class.php	2012-06-10 09:44:10 UTC (rev 15704)
+++ trunk/src/common/include/User.class.php	2012-06-10 12:18:43 UTC (rev 15705)
@@ -1185,6 +1185,38 @@
 		return preg_replace("/###/", "\n", $this->data_array['authorized_keys']);
 	}
 
+	function getArrayAuthorizedKeys() {
+		$arrayKeys = explode("###", $this->data_array['authorized_keys']);
+		$returnArrayKeys = array();
+		$i = 0;
+		foreach ($arrayKeys as $key) {
+			$valuesKey = explode(' ',$key);
+			$tempfile = tempnam("/tmp", "authkey");
+			$ft = fopen($tempfile, 'w');
+			fwrite($ft, $key);
+			fclose($ft);
+			$returnExec = array();
+			exec("/usr/bin/ssh-keygen -lf ".$tempfile, $returnExec);
+			unlink($tempfile);
+			$returnExecExploded = explode(' ', $returnExec[0]);
+			$returnArrayKeys[$i]['fingerprint'] = $returnExecExploded[1];
+			$returnArrayKeys[$i]['uploaded'] = 'tbi';
+			$returnArrayKeys[$i]['name'] = $valuesKey[2];
+			$returnArrayKeys[$i]['algorithm'] = $valuesKey[0];
+			$authorized_keys_file = forge_get_config('homedir_prefix').'/'.$this->getUnixName().'/.ssh/authorized_keys';
+			$fd = fopen($authorized_keys_file,"r");
+			$fs = filesize($authorized_keys_file);
+			$datafile = fread($fd, $fs);
+			if (strpos($datafile, $valuesKey[1]) && strpos($datafile, $valuesKey[2])) {
+				$returnArrayKeys[$i]['ready'] = '1';
+			} else {
+				$returnArrayKeys[$i]['ready'] = '0';
+			}
+			$i++;
+		}
+		return $returnArrayKeys;
+	}
+
 	/**
 	 *	setAuthorizedKeys - set the SSH authorized keys for the user.
 	 *

Modified: trunk/src/www/account/index.php
===================================================================
--- trunk/src/www/account/index.php	2012-06-10 09:44:10 UTC (rev 15704)
+++ trunk/src/www/account/index.php	2012-06-10 12:18:43 UTC (rev 15705)
@@ -5,6 +5,7 @@
  * Copyright 1999-2001 (c) VA Linux Systems
  * Copyright 2010-2011, Franck Villaume - Capgemini
  * Copyright 2011, Alain Peyrat - Alcatel-Lucent
+ * Copyright 2012, Franck Villaume - TrivialDev
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -94,6 +95,7 @@
 	plugin_hook("userisactivecheckboxpost", $hookParams);
 }
 
+use_javascript('/js/sortable.js');
 $title = _('Account Maintenance');
 site_user_header(array('title'=>$title));
 
@@ -274,7 +276,7 @@
 // displays a "Use xxxx Plugin" checkbox
 plugin_hook("userisactivecheckbox", $hookParams);
 ?>
-<tr><td>
+<tr><td colspan="2">
 
 <?php
 echo $HTML->boxBottom();
@@ -286,10 +288,26 @@
 	print ' 
 <br />'._('Shell box').': <strong>'.$u->getUnixBox().'</strong>
 <br />'._('SSH Shared Authorized Keys').': <strong>';
-	// get shared key count from db
-	$expl_keys = explode("\n", $u->getAuthorizedKeys());
-	if ($expl_keys[0]) {
-		print (sizeof($expl_keys));
+	global $HTML;
+	$sshKeysArray = $u->getArrayAuthorizedKeys();
+	if (count($sshKeysArray)) {
+		$tabletop = array(_('Name'), _('Algorithm'), _('Fingerprint'), _('Ready ?'));
+		$classth = array('','','','');
+		echo $HTML->listTableTop($tabletop, false, 'sortable_sshkeys_listlinks', 'sortable', $classth);
+		foreach($sshKeysArray as $sshKey) {
+			echo '<tr>';
+			echo '<td>'.$sshKey['name'].'</td>';
+			echo '<td>'.$sshKey['algorithm'].'</td>';
+			echo '<td>'.$sshKey['fingerprint'].'</td>';
+			if ($sshKey['ready']) {
+				$image = html_image('docman/validate.png', 22, 22, array('alt'=>_('ssh key is deployed.'), 'class'=>'tabtitle', 'title'=>_('ssh key is deployed.')));
+			} else {
+				$image = html_image('waiting.png', 22, 22, array('alt'=>_('ssh key is not deployed yet.'), 'class'=>'tabtitle', 'title'=>_('ssh key is not deployed yet.')));
+			}
+			echo '<td>'.$image.'</td>';
+			echo '</tr>';
+		}
+		echo $HTML->listTableBottom();
 	} else {
 		print '0';
 	}

Added: trunk/src/www/themes/funky/images/waiting.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/funky/images/waiting.png
___________________________________________________________________
Added: svn:mime-type
   + image/png

Added: trunk/src/www/themes/gforge/images/waiting.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/www/themes/gforge/images/waiting.png
___________________________________________________________________
Added: svn:mime-type
   + image/png




More information about the Fusionforge-commits mailing list