3ef995c2108fe77d22c0b556fb9717cb848bc48f
bernd Webapp-Installer, erste Ver...

bernd authored 17 years ago

1) <?php
Hanno Böck Add newlines before comment...

Hanno Böck authored 1 year ago

2) 
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 14 years ago

3) /*
4) This file belongs to the Webinterface of schokokeks.org Hosting
5) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 3 years ago

6) Written by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 14 years ago

7)   Bernd Wurst <bernd@schokokeks.org>
8)   Hanno Böck <hanno@schokokeks.org>
9) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 14 years ago

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

bernd authored 17 years ago

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

Hanno authored 8 years ago

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

Hanno Böck authored 4 years ago

22)     $args = [":username" => $_SESSION['userinfo']['username'],
Hanno Böck Neue codingstyle-rule array...

Hanno Böck authored 2 years ago

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

Hanno authored 8 years ago

27)     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 17 years ago

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

bernd authored 17 years ago

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

Hanno authored 8 years ago

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

Hanno Böck authored 4 years ago

36)     $args = [":username" => $_SESSION['userinfo']['username'],
Hanno Böck Neue codingstyle-rule array...

Hanno Böck authored 2 years ago

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

Hanno authored 8 years ago

40)     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 17 years ago

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

bernd authored 17 years ago

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

Hanno Böck authored 4 years ago

45)     $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 8 years ago

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

bernd authored 17 years ago

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

bernd authored 17 years ago

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

Hanno authored 8 years ago

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

Bernd Wurst authored 7 years ago

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

Hanno authored 8 years ago

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

bernd authored 15 years ago

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

Hanno authored 8 years ago

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

Bernd Wurst authored 7 years ago

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

Hanno authored 8 years ago

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

bernd authored 17 years ago

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

Hanno authored 8 years ago

83)     if (substr($docroot, -1) == '/') {
84)         $docroot = substr($docroot, 0, -1);
85)     }
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

86)     $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 8 years ago

87)     if ($result->rowCount() < 1) {
88)         if (!strstr($docroot, '/')) {
89)             return null;
90)         }
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

91)         return get_url_for_dir(substr($docroot, 0, strrpos($docroot, '/')), substr($docroot, strrpos($docroot, '/')) . $cutoff);
Hanno Fix coding style with php-c...

Hanno authored 8 years ago

92)     }
93)     $tmp = $result->fetch();
94)     $prefix = 'http://';
95)     if ($tmp['ssl'] == 'forward' || $tmp['ssl'] == 'https') {
96)         $prefix = 'https://';
97)     }
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

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

bernd authored 17 years ago

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

bernd authored 17 years ago

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

bernd authored 17 years ago

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

Hanno authored 8 years ago

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

Hanno authored 8 years ago

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

Hanno authored 8 years ago

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

Hanno authored 8 years ago

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

Hanno authored 8 years ago

110)     // zuerst versuchen wir username_webappname. Wenn das nicht klappt, dann wird hochgezählt
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

111)     $handle = $username . '_' . $application;
Hanno remove whitespace in empty...

Hanno authored 8 years ago

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

Hanno Böck authored 2 years ago

113)     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 8 years ago

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

Hanno Böck authored 4 years ago

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

Hanno authored 8 years ago

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

bernd authored 17 years ago

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

Hanno authored 8 years ago

123)     for ($i = 0; $i < 100 ; $i++) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

124)         $handle = $username . '_' . $i;
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 2 years ago

125)         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 8 years ago

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

Hanno Böck authored 4 years ago

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

Hanno authored 8 years ago

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

bernd authored 17 years ago

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

Hanno authored 8 years ago

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