367c16d9263e5e5be6ef49f198d25f30395e7c69
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Bernd Wurst Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

16) 
17) require_once('inc/base.php');
18) 
19) function create_new_webapp($appname, $directory, $url, $data)
20) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

21)     if (directory_in_use($directory)) {
22)         system_failure('Sie haben erst kürzlich eine Anwendung in diesem Verzeichnis installieren lassen. Aus Sicherheitsgründen können Sie in diesem Verzeichnis am selben Tag nicht schon wieder eine Anwendung installieren.');
23)     }
24)     $args = array(":username" => $_SESSION['userinfo']['username'],
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

25)                 ":appname" => $appname,
26)                 ":dir" => $directory,
27)                 ":url" => $url,
28)                 ":data" => $data);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

29)     db_query("INSERT INTO vhosts.webapp_installer (appname, directory, url, state, username, data) VALUES (:appname, :dir, :url, 'new', :username, :data)", $args);
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

30) }
31) 
32) 
bernd * alle internen Links sinnv...

bernd authored 15 years ago

33) function request_update($appname, $directory, $url)
34) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

35)     if (directory_in_use($directory)) {
36)         system_failure('Sie haben erst kürzlich eine Anwendung in diesem Verzeichnis installieren lassen oder ein Update in diesem Verzeichnis angefordert. Bitte warten Sie bis diese Aktion durchgeführt wurde.');
37)     }
38)     $args = array(":username" => $_SESSION['userinfo']['username'],
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

39)                 ":appname" => $appname,
40)                 ":dir" => $directory,
41)                 ":url" => $url);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

42)     db_query("INSERT INTO vhosts.webapp_installer (appname, directory, url, state, username) VALUES (:appname, :dir, :url, 'old', :username)", $args);
bernd * alle internen Links sinnv...

bernd authored 15 years ago

43) }
44) 
bernd Doppelte webapp-installer-t...

bernd authored 15 years ago

45) function directory_in_use($directory)
46) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

47)     $result = db_query("SELECT id FROM vhosts.webapp_installer WHERE (state IN ('new','old') OR DATE(lastchange)=CURDATE()) AND directory=?", array($directory));
48)     if ($result->rowCount() > 0) {
49)         return true;
50)     }
51)     return false;
bernd Doppelte webapp-installer-t...

bernd authored 15 years ago

52) }
bernd * alle internen Links sinnv...

bernd authored 15 years ago

53) 
54) function upgradeable($appname, $version)
55) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

56)     DEBUG("Is {$appname}-{$version} upgradeable?");
Bernd Wurst do not offer autoupgrade fo...

Bernd Wurst authored 5 years ago

57)     /*if ($appname == 'Drupal7') {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

58)         DEBUG("found Drupal-7.*!");
59)         return 'drupal7';
bernd Drupal-7 kann auch per Auto...

bernd authored 13 years ago

60)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

61)     if ($appname == 'Drupal') {
62)         DEBUG("found Drupal!");
63)         if (substr($version, 0, 2) == '7.') {
64)             DEBUG("found Drupal-7.*!");
65)             return 'drupal7';
66)         }
67)         DEBUG("Version: ".substr($version, 0, 2));
Bernd Wurst do not offer autoupgrade fo...

Bernd Wurst authored 5 years ago

68)     } */
69)     if ($appname == 'MediaWiki') {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

70)         DEBUG("found MediaWiki");
71)         return 'mediawiki';
72)     }
73)     /*elseif ($appname == 'owncloud')
74)     {
75)       DEBUG('found OwnCloud');
76)       return 'owncloud';
77)     }*/
78)     DEBUG("found no upgradeable webapp!");
79)     return null;
bernd * alle internen Links sinnv...

bernd authored 15 years ago

80) }
81) 
82) 
83) function get_url_for_dir($docroot, $cutoff = '')
84) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

85)     if (substr($docroot, -1) == '/') {
86)         $docroot = substr($docroot, 0, -1);
87)     }
88)     $result = db_query("SELECT `ssl`, IF(FIND_IN_SET('aliaswww', options), CONCAT('www.',fqdn), fqdn) AS fqdn FROM vhosts.v_vhost WHERE docroot IN (?, ?)", array($docroot, $docroot.'/'));
89)     if ($result->rowCount() < 1) {
90)         if (!strstr($docroot, '/')) {
91)             return null;
92)         }
93)         return get_url_for_dir(substr($docroot, 0, strrpos($docroot, '/')), substr($docroot, strrpos($docroot, '/')).$cutoff);
94)     }
95)     $tmp = $result->fetch();
96)     $prefix = 'http://';
97)     if ($tmp['ssl'] == 'forward' || $tmp['ssl'] == 'https') {
98)         $prefix = 'https://';
99)     }
Hanno Böck XSS in freewvs dirs

Hanno Böck authored 5 years ago

100)     return $prefix.$tmp['fqdn'].filter_output_html($cutoff);
bernd * alle internen Links sinnv...

bernd authored 15 years ago

101) }
102) 
103) 
bernd Frage Datenbank-Kürzel nich...

bernd authored 15 years ago

104) function create_webapp_mysqldb($application, $sitename)
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

105) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

106)     // dependet auf das mysql-modul
107)     require_once('modules/mysql/include/mysql.php');
Hanno remove whitespace in empty...

Hanno authored 6 years ago

108) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

109)     $username = $_SESSION['userinfo']['username'];
110)     $description = "Automatisch erzeugte Datenbank für {$application} ({$sitename})";
Hanno remove whitespace in empty...

Hanno authored 6 years ago

111) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

112)     // zuerst versuchen wir username_webappname. Wenn das nicht klappt, dann wird hochgezählt
113)     $handle = $username.'_'.$application;
Hanno remove whitespace in empty...

Hanno authored 6 years ago

114) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

115)     if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && ! (has_mysql_user($handle) || has_mysql_database($handle))) {
116)         logger(LOG_INFO, "webapps/include/webapp-installer", "create", "creating db and user »{$handle}«");
117)         create_mysql_database($handle, $description);
118)         create_mysql_account($handle, $description);
119)         set_mysql_access($handle, $handle, true);
120)         $password = random_string(10);
121)         set_mysql_password($handle, $password);
122)         return array('dbuser' => $handle, 'dbname' => $handle, 'dbpass' => $password);
123)     }
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

124) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

125)     for ($i = 0; $i < 100 ; $i++) {
126)         $handle = $username.'_'.$i;
127)         if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && ! (has_mysql_user($handle) || has_mysql_database($handle))) {
128)             logger(LOG_INFO, "webapps/include/webapp-installer", "create", "creating db and user »{$handle}«");
129)             create_mysql_database($handle, $description);
130)             create_mysql_account($handle, $description);
131)             set_mysql_access($handle, $handle, true);
132)             $password = random_string(10);
133)             set_mysql_password($handle, $password);
134)             return array('dbuser' => $handle, 'dbname' => $handle, 'dbpass' => $password);
135)         }
bernd Frage Datenbank-Kürzel nich...

bernd authored 15 years ago

136)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

137)     system_failure('Konnte keine Datenbank erzeugen. Bitte melden Sie diesen Umstand den Administratoren!');