28667e96bdcc072a7485ff50021f54f555c59ea3
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) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

5) Written 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) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

9) This code is published under a 0BSD license.
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

10) 
11) 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.
12) */
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

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

Hanno authored 6 years ago

18)     if (directory_in_use($directory)) {
19)         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.');
20)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

21)     $args = [":username" => $_SESSION['userinfo']['username'],
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

22)                 ":appname" => $appname,
23)                 ":dir" => $directory,
24)                 ":url" => $url,
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

25)                 ":data" => $data, ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

26)     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

27) }
28) 
29) 
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

Hanno authored 6 years ago

32)     if (directory_in_use($directory)) {
33)         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.');
34)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

35)     $args = [":username" => $_SESSION['userinfo']['username'],
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

36)                 ":appname" => $appname,
37)                 ":dir" => $directory,
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

38)                 ":url" => $url, ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

39)     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

40) }
41) 
bernd Doppelte webapp-installer-t...

bernd authored 15 years ago

42) function directory_in_use($directory)
43) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

44)     $result = db_query("SELECT id FROM vhosts.webapp_installer WHERE (state IN ('new','old') OR DATE(lastchange)=CURDATE()) AND directory=?", [$directory]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

45)     if ($result->rowCount() > 0) {
46)         return true;
47)     }
48)     return false;
bernd Doppelte webapp-installer-t...

bernd authored 15 years ago

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

bernd authored 15 years ago

50) 
51) function upgradeable($appname, $version)
52) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Bernd Wurst authored 5 years ago

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

Hanno authored 6 years ago

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

bernd authored 13 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 5 years ago

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

Hanno authored 6 years ago

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

bernd authored 15 years ago

77) }
78) 
79) 
80) function get_url_for_dir($docroot, $cutoff = '')
81) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

82)     if (substr($docroot, -1) == '/') {
83)         $docroot = substr($docroot, 0, -1);
84)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

85)     $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.'/']);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

86)     if ($result->rowCount() < 1) {
87)         if (!strstr($docroot, '/')) {
88)             return null;
89)         }
90)         return get_url_for_dir(substr($docroot, 0, strrpos($docroot, '/')), substr($docroot, strrpos($docroot, '/')).$cutoff);
91)     }
92)     $tmp = $result->fetch();
93)     $prefix = 'http://';
94)     if ($tmp['ssl'] == 'forward' || $tmp['ssl'] == 'https') {
95)         $prefix = 'https://';
96)     }
Hanno Böck XSS in freewvs dirs

Hanno Böck authored 5 years ago

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

bernd authored 15 years ago

98) }
99) 
100) 
bernd Frage Datenbank-Kürzel nich...

bernd authored 15 years ago

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

bernd authored 15 years ago

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

Hanno authored 6 years ago

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

Hanno authored 6 years ago

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

Hanno authored 6 years ago

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

Hanno authored 6 years ago

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

Hanno authored 6 years ago

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

Hanno authored 6 years ago

111) 
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

112)     if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && !(has_mysql_user($handle) || has_mysql_database($handle))) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

113)         logger(LOG_INFO, "webapps/include/webapp-installer", "create", "creating db and user »{$handle}«");
114)         create_mysql_database($handle, $description);
115)         create_mysql_account($handle, $description);
116)         set_mysql_access($handle, $handle, true);
117)         $password = random_string(10);
118)         set_mysql_password($handle, $password);
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

119)         return ['dbuser' => $handle, 'dbname' => $handle, 'dbpass' => $password];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

120)     }
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

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

Hanno authored 6 years ago

122)     for ($i = 0; $i < 100 ; $i++) {
123)         $handle = $username.'_'.$i;
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

124)         if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && !(has_mysql_user($handle) || has_mysql_database($handle))) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

125)             logger(LOG_INFO, "webapps/include/webapp-installer", "create", "creating db and user »{$handle}«");
126)             create_mysql_database($handle, $description);
127)             create_mysql_account($handle, $description);
128)             set_mysql_access($handle, $handle, true);
129)             $password = random_string(10);
130)             set_mysql_password($handle, $password);
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

131)             return ['dbuser' => $handle, 'dbname' => $handle, 'dbpass' => $password];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

132)         }
bernd Frage Datenbank-Kürzel nich...

bernd authored 15 years ago

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

Hanno authored 6 years ago

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