bernd commited on 2009-03-07 14:48:53
Zeige 14 geänderte Dateien mit 146 Einfügungen und 33 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1301 87cf0b9e-d624-0410-a070-f6ee81989793
| ... | ... |
@@ -75,13 +75,11 @@ function random_string($nc, $a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV |
| 75 | 75 |
|
| 76 | 76 |
function are_you_sure($query_string, $question) |
| 77 | 77 |
{
|
| 78 |
- global $debugmode; |
|
| 79 |
- if ($debugmode) |
|
| 80 |
- $query_string = 'debug&'.$query_string; |
|
| 78 |
+ $query_string = encode_querystring($query_string); |
|
| 81 | 79 |
$token = random_string(20); |
| 82 | 80 |
$_SESSION['are_you_sure_token'] = $token; |
| 83 | 81 |
output("<h3>Sicherheitsabfrage</h3>
|
| 84 |
- <form action=\"?{$query_string}\" method=\"post\">
|
|
| 82 |
+ <form action=\"{$query_string}\" method=\"post\">
|
|
| 85 | 83 |
<div class=\"confirmation\"> |
| 86 | 84 |
<div class=\"question\">{$question}</div>
|
| 87 | 85 |
<p class=\"buttons\"> |
| ... | ... |
@@ -145,31 +143,40 @@ function check_form_token($form_id, $formtoken = NULL) |
| 145 | 143 |
} |
| 146 | 144 |
|
| 147 | 145 |
|
| 148 |
- |
|
| 149 |
-function internal_link($file, $label, $querystring = '', $attribs = '') |
|
| 146 |
+function encode_querystring($querystring) |
|
| 150 | 147 |
{
|
| 151 |
- $debugstr = ''; |
|
| 152 | 148 |
global $debugmode; |
| 153 | 149 |
if ($debugmode) |
| 154 |
- $debugstr = 'debug&'; |
|
| 155 |
- $querystring = str_replace('&', '&', $querystring);
|
|
| 150 |
+ $querystring = 'debug&'.$querystring; |
|
| 151 |
+ $query = explode('&', $querystring);
|
|
| 152 |
+ $new_query = array(); |
|
| 153 |
+ foreach ($query AS $item) |
|
| 154 |
+ if ($item != '') |
|
| 155 |
+ {
|
|
| 156 |
+ list($key, $val) = explode('=', $item, 2);
|
|
| 157 |
+ $new_query[] = $key.'='.($val); |
|
| 158 |
+ } |
|
| 159 |
+ $querystring = implode('&', $new_query);
|
|
| 160 |
+ if ($querystring) |
|
| 161 |
+ $querystring = '?'.$querystring; |
|
| 162 |
+ |
|
| 163 |
+ return $querystring; |
|
| 164 |
+} |
|
| 165 |
+ |
|
| 156 | 166 |
|
| 157 |
- return "<a href=\"{$file}?{$debugstr}${querystring}\" {$attribs} >{$label}</a>";
|
|
| 167 |
+ |
|
| 168 |
+function internal_link($file, $label, $querystring = '', $attribs = '') |
|
| 169 |
+{
|
|
| 170 |
+ $querystring = encode_querystring($querystring); |
|
| 171 |
+ return "<a href=\"{$file}{$querystring}\" {$attribs} >{$label}</a>";
|
|
| 158 | 172 |
} |
| 159 | 173 |
|
| 160 | 174 |
|
| 161 | 175 |
function html_form($form_id, $scriptname, $querystring, $content) |
| 162 | 176 |
{
|
| 163 |
- $debugstr = ''; |
|
| 164 |
- global $debugmode; |
|
| 165 |
- if ($debugmode) |
|
| 166 |
- $debugstr = 'debug&'; |
|
| 167 |
- $querystring = str_replace('&', '&', $querystring);
|
|
| 168 |
- $qmark = '?'; |
|
| 169 |
- if ($debugstr == '' && $querystring == '') |
|
| 170 |
- $qmark = ''; |
|
| 177 |
+ $querystring = encode_querystring($querystring); |
|
| 171 | 178 |
$ret = ''; |
| 172 |
- $ret .= '<form action="'.$scriptname.$qmark.$debugstr.$querystring.'" method="post">'."\n"; |
|
| 179 |
+ $ret .= '<form action="'.$scriptname.$querystring.'" method="post">'."\n"; |
|
| 173 | 180 |
$ret .= '<p style="display: none;"><input type="hidden" name="formtoken" value="'.generate_form_token($form_id).'" /></p>'."\n"; |
| 174 | 181 |
$ret .= $content; |
| 175 | 182 |
$ret .= '</form>'; |
| ... | ... |
@@ -144,6 +144,23 @@ function check_path( $input ) |
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 | 146 |
|
| 147 |
+function in_homedir($path) |
|
| 148 |
+{
|
|
| 149 |
+ DEBUG("Prüfe »{$path}«");
|
|
| 150 |
+ if (! check_path($path)) |
|
| 151 |
+ {
|
|
| 152 |
+ DEBUG('Kein Pfad');
|
|
| 153 |
+ return False; |
|
| 154 |
+ } |
|
| 155 |
+ if (! isset($_SESSION['userinfo']['homedir'])) |
|
| 156 |
+ {
|
|
| 157 |
+ DEBUG("Kann homedir nicht ermitteln");
|
|
| 158 |
+ return False; |
|
| 159 |
+ } |
|
| 160 |
+ return strncmp($_SESSION['userinfo']['homedir'], $path, count($_SESSION['userinfo']['homedir'])) == 0; |
|
| 161 |
+} |
|
| 162 |
+ |
|
| 163 |
+ |
|
| 147 | 164 |
function check_emailaddr( $input ) |
| 148 | 165 |
{
|
| 149 | 166 |
return (bool) filter_var($input, FILTER_VALIDATE_EMAIL) == $input; |
| ... | ... |
@@ -21,7 +21,7 @@ if ($_GET['type'] == 'dyndns') {
|
| 21 | 21 |
$sure = user_is_sure(); |
| 22 | 22 |
if ($sure === NULL) |
| 23 | 23 |
{
|
| 24 |
- are_you_sure("type=dyndns&action=delete&id={$id}", "Möchten Sie den DynDNS-Account wirklich löschen?");
|
|
| 24 |
+ are_you_sure("type=dyndns&action=delete&id={$id}", "Möchten Sie den DynDNS-Account wirklich löschen?");
|
|
| 25 | 25 |
} |
| 26 | 26 |
elseif ($sure === true) |
| 27 | 27 |
{
|
| ... | ... |
@@ -114,7 +114,7 @@ elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['account' |
| 114 | 114 |
$_GET['account'] = (int) $_GET['account']; |
| 115 | 115 |
$account = get_mailaccount($_GET['account']); |
| 116 | 116 |
$enabled = ($account['enabled'] ? 'Ja' : 'Nein'); |
| 117 |
- are_you_sure("action=delete&account={$_GET['account']}", '
|
|
| 117 |
+ are_you_sure("action=delete&account={$_GET['account']}", '
|
|
| 118 | 118 |
<p>Soll der folgende Account wirklich gelöscht werden?</p> |
| 119 | 119 |
<table style="margin-bottom: 1em;"> |
| 120 | 120 |
<tr><td>Benutzername:</td> |
| ... | ... |
@@ -78,7 +78,7 @@ elseif ($_GET['action'] == 'delete') |
| 78 | 78 |
$sure = user_is_sure(); |
| 79 | 79 |
if ($sure === NULL) |
| 80 | 80 |
{
|
| 81 |
- are_you_sure("action=delete&id={$account['id']}", "Möchten Sie die E-Mail-Adresse »{$account_string}« wirklich löschen?");
|
|
| 81 |
+ are_you_sure("action=delete&id={$account['id']}", "Möchten Sie die E-Mail-Adresse »{$account_string}« wirklich löschen?");
|
|
| 82 | 82 |
} |
| 83 | 83 |
elseif ($sure === true) |
| 84 | 84 |
{
|
| ... | ... |
@@ -11,7 +11,7 @@ if ($_GET['action'] == 'delete') |
| 11 | 11 |
$sure = user_is_sure(); |
| 12 | 12 |
if ($sure === NULL) |
| 13 | 13 |
{
|
| 14 |
- are_you_sure("action=delete&id={$entry['id']}", "Möchten Sie die E-Mail-Adresse »{$entry['local']}@{$entry['domain']}« von der Ausnahmeliste entfernen?");
|
|
| 14 |
+ are_you_sure("action=delete&id={$entry['id']}", "Möchten Sie die E-Mail-Adresse »{$entry['local']}@{$entry['domain']}« von der Ausnahmeliste entfernen?");
|
|
| 15 | 15 |
} |
| 16 | 16 |
elseif ($sure === true) |
| 17 | 17 |
{
|
| ... | ... |
@@ -29,7 +29,7 @@ elseif ($_GET['action'] == 'delete') |
| 29 | 29 |
$sure = user_is_sure(); |
| 30 | 30 |
if ($sure === NULL) |
| 31 | 31 |
{
|
| 32 |
- are_you_sure("action=delete&id={$cert['id']}", "Möchten Sie das Zertifikat »{$cert['dn']}« wirklich löschen?");
|
|
| 32 |
+ are_you_sure("action=delete&id={$cert['id']}", "Möchten Sie das Zertifikat »{$cert['dn']}« wirklich löschen?");
|
|
| 33 | 33 |
} |
| 34 | 34 |
elseif ($sure === true) |
| 35 | 35 |
{
|
| ... | ... |
@@ -56,7 +56,7 @@ elseif ($_GET['action'] == 'delete') |
| 56 | 56 |
$sure = user_is_sure(); |
| 57 | 57 |
if ($sure === NULL) |
| 58 | 58 |
{
|
| 59 |
- are_you_sure("action=delete&account={$_GET['account']}", "Möchten Sie den Account »{$account_string}« wirklich löschen?");
|
|
| 59 |
+ are_you_sure("action=delete&account={$_GET['account']}", "Möchten Sie den Account »{$account_string}« wirklich löschen?");
|
|
| 60 | 60 |
} |
| 61 | 61 |
elseif ($sure === true) |
| 62 | 62 |
{
|
| ... | ... |
@@ -19,7 +19,7 @@ if (isset($_GET['action'])) |
| 19 | 19 |
$sure = user_is_sure(); |
| 20 | 20 |
if ($sure === NULL) |
| 21 | 21 |
{
|
| 22 |
- are_you_sure("action=delete_db&db={$_GET['db']}", "Möchten Sie die Datenbank »{$_GET['db']}« wirklich löschen?");
|
|
| 22 |
+ are_you_sure("action=delete_db&db={$_GET['db']}", "Möchten Sie die Datenbank »{$_GET['db']}« wirklich löschen?");
|
|
| 23 | 23 |
$output_something = false; |
| 24 | 24 |
} |
| 25 | 25 |
elseif ($sure === true) |
| ... | ... |
@@ -40,7 +40,7 @@ if (isset($_GET['action'])) |
| 40 | 40 |
$sure = user_is_sure(); |
| 41 | 41 |
if ($sure === NULL) |
| 42 | 42 |
{
|
| 43 |
- are_you_sure("action=delete_user&user={$_GET['user']}", "Möchten Sie den Benutzer »{$_GET['user']}« wirklich löschen?");
|
|
| 43 |
+ are_you_sure("action=delete_user&user={$_GET['user']}", "Möchten Sie den Benutzer »{$_GET['user']}« wirklich löschen?");
|
|
| 44 | 44 |
$output_something = false; |
| 45 | 45 |
} |
| 46 | 46 |
elseif ($sure === true) |
| ... | ... |
@@ -69,7 +69,7 @@ elseif ($_GET['action'] == 'delete') |
| 69 | 69 |
$sure = user_is_sure(); |
| 70 | 70 |
if ($sure === NULL) |
| 71 | 71 |
{
|
| 72 |
- are_you_sure("action=delete&account={$_GET['account']}", "Möchten Sie den Account »{$account_string}« wirklich löschen?");
|
|
| 72 |
+ are_you_sure("action=delete&account={$_GET['account']}", "Möchten Sie den Account »{$account_string}« wirklich löschen?");
|
|
| 73 | 73 |
} |
| 74 | 74 |
elseif ($sure === true) |
| 75 | 75 |
{
|
| ... | ... |
@@ -211,7 +211,7 @@ elseif ($_GET['action'] == 'deletealias') |
| 211 | 211 |
$sure = user_is_sure(); |
| 212 | 212 |
if ($sure === NULL) |
| 213 | 213 |
{
|
| 214 |
- are_you_sure("action=deletealias&alias={$_GET['alias']}", "Möchten Sie das Alias »{$alias_string}« für die Subdomain »{$vhost_string}« wirklich löschen?");
|
|
| 214 |
+ are_you_sure("action=deletealias&alias={$_GET['alias']}", "Möchten Sie das Alias »{$alias_string}« für die Subdomain »{$vhost_string}« wirklich löschen?");
|
|
| 215 | 215 |
} |
| 216 | 216 |
elseif ($sure === true) |
| 217 | 217 |
{
|
| ... | ... |
@@ -236,7 +236,7 @@ elseif ($_GET['action'] == 'delete') |
| 236 | 236 |
$sure = user_is_sure(); |
| 237 | 237 |
if ($sure === NULL) |
| 238 | 238 |
{
|
| 239 |
- are_you_sure("action=delete&vhost={$_GET['vhost']}", "Möchten Sie die Subdomain »{$vhost_string}« wirklich löschen?");
|
|
| 239 |
+ are_you_sure("action=delete&vhost={$_GET['vhost']}", "Möchten Sie die Subdomain »{$vhost_string}« wirklich löschen?");
|
|
| 240 | 240 |
} |
| 241 | 241 |
elseif ($sure === true) |
| 242 | 242 |
{
|
| ... | ... |
@@ -3,6 +3,7 @@ |
| 3 | 3 |
require_once('session/start.php');
|
| 4 | 4 |
|
| 5 | 5 |
require_once('freewvs.php');
|
| 6 |
+require_once('webapp-installer.php');
|
|
| 6 | 7 |
|
| 7 | 8 |
require_role(array(ROLE_SYSTEMUSER)); |
| 8 | 9 |
|
| ... | ... |
@@ -30,11 +31,12 @@ $results = load_results(); |
| 30 | 31 |
output('<h3>Aktuell installierte Web-Anwendungen</h3>
|
| 31 | 32 |
<p>Die folgenden Web-Anwendungen wurden beim letzten Programmdurchlauf gefunden. Diese Liste wird i.d.R. täglich aktualisiert.</p>'); |
| 32 | 33 |
foreach ($results AS $app) {
|
| 34 |
+ $url = get_url_for_dir($app['directory']); |
|
| 33 | 35 |
output("<div class='freewvs freewvs-{$app['state']}'>\n");
|
| 34 | 36 |
if ($app['state'] == 'ok') {
|
| 35 | 37 |
output("<img src='{$prefix}images/ok.png' />\n");
|
| 36 | 38 |
output("<p><strong>{$app['appname']} {$app['version']}</strong></p>\n");
|
| 37 |
- output("<p>Gefunden in {$app['directory']}</p>\n");
|
|
| 39 |
+ output("<p>Gefunden in {$app['directory']} (<a href=\"{$url}\">{$url}</a>)</p>\n");
|
|
| 38 | 40 |
output("<p>Diese Anwendung ist aktuell und hat keine allgemein bekannten Sicherheitsprobleme.</p>\n");
|
| 39 | 41 |
} |
| 40 | 42 |
else {
|
| ... | ... |
@@ -45,7 +47,7 @@ foreach ($results AS $app) {
|
| 45 | 47 |
} |
| 46 | 48 |
output("<img src='{$prefix}images/error.png' />\n");
|
| 47 | 49 |
output("<p><strong>{$app['appname']} {$app['version']}</strong></p>\n");
|
| 48 |
- output("<p>Gefunden in {$app['directory']}</p>\n");
|
|
| 50 |
+ output("<p>Gefunden in {$app['directory']} (<a href=\"{$url}\">{$url}</a>)</p>\n");
|
|
| 49 | 51 |
if ($app['safeversion'] != '') {
|
| 50 | 52 |
output("<p>Diese Anwendung ist von Sicherheits-Problemen betroffen. Ein <strong>Update auf Version {$app['safeversion']}</strong> wird dringend empfohlen. Prüfen Sie anhand der unten genannten Referenz welche Gefahren von dieser Anwendung momentan ausgehen.</p>\n");
|
| 51 | 53 |
} else {
|
| ... | ... |
@@ -53,7 +55,12 @@ foreach ($results AS $app) {
|
| 53 | 55 |
} |
| 54 | 56 |
output("<p><strong>Referenz zu diesem Sicherheitsproblem: <a href='{$vulnlink}'>{$app['vulninfo']}</a></strong></p>");
|
| 55 | 57 |
if ($doclink != NULL) |
| 56 |
- output('<p><strong>Hinweis:</strong> Um Ihnen das Upgrade leichter zu machen, möchten wir Sie auf eine <a href="'.$doclink.'">deutschsprachige Upgrade-Anleitung</a> aufmerksam machen.</p>');
|
|
| 58 |
+ output('<p><strong>Hinweis:</strong> Um Ihnen das Upgrade leichter zu machen, möchten wir Sie auf eine <a href="'.$doclink.'">deutschsprachige Upgrade-Anleitung</a> aufmerksam machen.</p>'."\n");
|
|
| 59 |
+ $up = upgradeable($app['appname'], $app['version']); |
|
| 60 |
+ if ($up) |
|
| 61 |
+ {
|
|
| 62 |
+ output('<p>'.internal_link('requestupdate', 'Update automatisch durchführen', "dir={$app['directory']}&app={$up}")."</p>\n");
|
|
| 63 |
+ } |
|
| 57 | 64 |
} |
| 58 | 65 |
output("</div>\n");
|
| 59 | 66 |
#output("<tr><td>{$app['appname']} ({$app['version']})</td><td>{$app['state']}</td></tr>");
|
| ... | ... |
@@ -13,6 +13,54 @@ function create_new_webapp($appname, $directory, $url, $data) |
| 13 | 13 |
} |
| 14 | 14 |
|
| 15 | 15 |
|
| 16 |
+function request_update($appname, $directory, $url) |
|
| 17 |
+{
|
|
| 18 |
+ $username = mysql_real_escape_string($_SESSION['userinfo']['username']); |
|
| 19 |
+ $appname = mysql_real_escape_string($appname); |
|
| 20 |
+ $directory = mysql_real_escape_string($directory); |
|
| 21 |
+ $url = maybe_null(mysql_real_escape_string($url)); |
|
| 22 |
+ db_query("INSERT INTO vhosts.webapp_installer VALUES (NULL, '{$appname}', '{$directory}', {$url}, 'old', '{$username}', NULL)");
|
|
| 23 |
+} |
|
| 24 |
+ |
|
| 25 |
+ |
|
| 26 |
+function upgradeable($appname, $version) |
|
| 27 |
+{
|
|
| 28 |
+ DEBUG("Is {$appname}-{$version} upgradeable?");
|
|
| 29 |
+ if ($appname == 'Drupal') |
|
| 30 |
+ {
|
|
| 31 |
+ DEBUG("found Drupal!");
|
|
| 32 |
+ if (substr($version, 0, 2) == '6.') |
|
| 33 |
+ {
|
|
| 34 |
+ DEBUG("found Drupal-6.*!");
|
|
| 35 |
+ return 'drupal6'; |
|
| 36 |
+ } |
|
| 37 |
+ DEBUG("Version: ".substr($version, 0, 2));
|
|
| 38 |
+ } |
|
| 39 |
+ DEBUG("found no upgradeable webapp!");
|
|
| 40 |
+ return NULL; |
|
| 41 |
+} |
|
| 42 |
+ |
|
| 43 |
+ |
|
| 44 |
+function get_url_for_dir($docroot, $cutoff = '') |
|
| 45 |
+{
|
|
| 46 |
+ if (substr($docroot, -1) == '/') |
|
| 47 |
+ $docroot = substr($docroot, 0, -1); |
|
| 48 |
+ $docroot = mysql_real_escape_string($docroot); |
|
| 49 |
+ $result = db_query("SELECT `ssl`, IF(FIND_IN_SET('aliaswww', options), CONCAT('www.',fqdn), fqdn) AS fqdn FROM vhosts.v_vhost WHERE docroot IN ('{$docroot}', '{$docroot}/') LIMIT 1");
|
|
| 50 |
+ if (mysql_num_rows($result) < 1) |
|
| 51 |
+ {
|
|
| 52 |
+ if (!strstr($docroot, '/')) |
|
| 53 |
+ return NULL; |
|
| 54 |
+ return get_url_for_dir(substr($docroot, 0, strrpos($docroot, '/')), substr($docroot, strrpos($docroot, '/')).$cutoff); |
|
| 55 |
+ } |
|
| 56 |
+ $tmp = mysql_fetch_assoc($result); |
|
| 57 |
+ $prefix = 'http://'; |
|
| 58 |
+ if ($tmp['ssl'] == 'forward' || $tmp['ssl'] == 'https') |
|
| 59 |
+ $prefix = 'https://'; |
|
| 60 |
+ return $prefix.$tmp['fqdn'].$cutoff; |
|
| 61 |
+} |
|
| 62 |
+ |
|
| 63 |
+ |
|
| 16 | 64 |
function create_webapp_mysqldb($handle) |
| 17 | 65 |
{
|
| 18 | 66 |
// dependet auf das mysql-modul |
| ... | ... |
@@ -0,0 +1,34 @@ |
| 1 |
+<?php |
|
| 2 |
+require_once('session/start.php');
|
|
| 3 |
+require_once('webapp-installer.php');
|
|
| 4 |
+ |
|
| 5 |
+require_role(ROLE_SYSTEMUSER); |
|
| 6 |
+ |
|
| 7 |
+ |
|
| 8 |
+$directory = $_GET['dir']; |
|
| 9 |
+ |
|
| 10 |
+if (! in_homedir($directory)) |
|
| 11 |
+ system_failure('Pfad nicht im Homedir oder ungültige Zeichen im Pfad');
|
|
| 12 |
+ |
|
| 13 |
+$app = $_GET['app']; |
|
| 14 |
+verify_input_general($app); |
|
| 15 |
+ |
|
| 16 |
+ |
|
| 17 |
+$sure = user_is_sure(); |
|
| 18 |
+if ($sure === NULL) |
|
| 19 |
+{
|
|
| 20 |
+ are_you_sure("dir={$directory}&app={$app}", "Möchten Sie ein Update der Anwendung »{$app}« im Verzeichnis »{$directory}« automatisch durchführen lassen?");
|
|
| 21 |
+} |
|
| 22 |
+elseif ($sure === true) |
|
| 23 |
+{
|
|
| 24 |
+ request_update($app, $directory, get_url_for_dir($directory)); |
|
| 25 |
+ if (! $debugmode) |
|
| 26 |
+ header("Location: freewvs");
|
|
| 27 |
+} |
|
| 28 |
+elseif ($sure === false) |
|
| 29 |
+{
|
|
| 30 |
+ if (! $debugmode) |
|
| 31 |
+ header("Location: freewvs");
|
|
| 32 |
+} |
|
| 33 |
+ |
|
| 34 |
+ |
|
| 0 | 35 |