cf54502a10b16c985ea28db17885d377226b6145
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) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
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) {
bernd Doppelte webapp-installer-t...

bernd authored 14 years ago

21)   if (directory_in_use($directory))
bernd Bugfixes beim Webapp-installer

bernd authored 14 years ago

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.');
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

23)   $args = array(":username" => $_SESSION['userinfo']['username'],
24)                 ":appname" => $appname,
25)                 ":dir" => $directory,
26)                 ":url" => $url,
27)                 ":data" => $data);
28)   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

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

bernd authored 15 years ago

32) function request_update($appname, $directory, $url)
33) {
bernd Doppelte webapp-installer-t...

bernd authored 14 years ago

34)   if (directory_in_use($directory))
35)     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.');
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

36)   $args = array(":username" => $_SESSION['userinfo']['username'],
37)                 ":appname" => $appname,
38)                 ":dir" => $directory,
39)                 ":url" => $url);
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 15 years ago

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

bernd authored 14 years ago

43) function directory_in_use($directory)
44) {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

45)   $result = db_query("SELECT id FROM vhosts.webapp_installer WHERE (state IN ('new','old') OR DATE(lastchange)=CURDATE()) AND directory=?", array($directory));
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

46)   if ($result->rowCount() > 0)
bernd Doppelte webapp-installer-t...

bernd authored 14 years ago

47)     return true;
48)   return false;
49) }
bernd * alle internen Links sinnv...

bernd authored 15 years ago

50) 
51) function upgradeable($appname, $version)
52) {
53)   DEBUG("Is {$appname}-{$version} upgradeable?");
Bernd Wurst Drupal-7 ist auch upgrade-f...

Bernd Wurst authored 11 years ago

54)   if ($appname == 'Drupal7') 
55)   {
56)     DEBUG("found Drupal-7.*!");
57)     return 'drupal7';
58)   }
bernd * alle internen Links sinnv...

bernd authored 15 years ago

59)   if ($appname == 'Drupal')
60)   {
61)     DEBUG("found Drupal!");
bernd Drupal-7 kann auch per Auto...

bernd authored 13 years ago

62)     if (substr($version, 0, 2) == '7.')
63)     {
64)       DEBUG("found Drupal-7.*!");
65)       return 'drupal7';
66)     }
bernd * alle internen Links sinnv...

bernd authored 15 years ago

67)     DEBUG("Version: ".substr($version, 0, 2));
68)   }
bernd Bugfixes beim Webapp-installer

bernd authored 14 years ago

69)   elseif ($appname == 'MediaWiki')
70)   {
71)     DEBUG("found MediaWiki");
72)     return 'mediawiki';
73)   }
Bernd Wurst Auto-updater für OwnCloud e...

Bernd Wurst authored 9 years ago

74)   /*elseif ($appname == 'owncloud') 
Bernd Wurst Es gibt jetzt einen Auto-Up...

Bernd Wurst authored 11 years ago

75)   {
76)     DEBUG('found OwnCloud');
77)     return 'owncloud';
Bernd Wurst Auto-updater für OwnCloud e...

Bernd Wurst authored 9 years ago

78)   }*/
bernd * alle internen Links sinnv...

bernd authored 15 years ago

79)   DEBUG("found no upgradeable webapp!");
80)   return NULL;
81) }
82) 
83) 
84) function get_url_for_dir($docroot, $cutoff = '')
85) {
86)   if (substr($docroot, -1) == '/')
87)     $docroot = substr($docroot, 0, -1);
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

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.'/'));
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

89)   if ($result->rowCount() < 1)
bernd * alle internen Links sinnv...

bernd authored 15 years ago

90)   {
91)     if (!strstr($docroot, '/'))
92)       return NULL;
93)     return get_url_for_dir(substr($docroot, 0, strrpos($docroot, '/')), substr($docroot, strrpos($docroot, '/')).$cutoff);
94)   } 
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

95)   $tmp = $result->fetch();
bernd * alle internen Links sinnv...

bernd authored 15 years ago

96)   $prefix = 'http://';
97)   if ($tmp['ssl'] == 'forward' || $tmp['ssl'] == 'https')
98)     $prefix = 'https://';
99)   return $prefix.$tmp['fqdn'].$cutoff;
100) }
101) 
102) 
bernd Frage Datenbank-Kürzel nich...

bernd authored 15 years ago

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

bernd authored 15 years ago

104) {
105)   // dependet auf das mysql-modul
106)   require_once('modules/mysql/include/mysql.php'); 
107)   
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

108)   $username = $_SESSION['userinfo']['username'];
bernd Frage Datenbank-Kürzel nich...

bernd authored 15 years ago

109)   $description = "Automatisch erzeugte Datenbank für {$application} ({$sitename})";
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

110)   
bernd Frage Datenbank-Kürzel nich...

bernd authored 15 years ago

111)   // zuerst versuchen wir username_webappname. Wenn das nicht klappt, dann wird hochgezählt
112)   $handle = $username.'_'.$application;
113)   
114)   if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && ! (has_mysql_user($handle) || has_mysql_database($handle)))
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

115)   {
bernd stringlänge mit strlen und...

bernd authored 14 years ago

116)     logger(LOG_INFO, "webapps/include/webapp-installer", "create", "creating db and user »{$handle}«");
bernd Frage Datenbank-Kürzel nich...

bernd authored 15 years ago

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);
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

123)   }
124) 
bernd Frage Datenbank-Kürzel nich...

bernd authored 15 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)     {
bernd stringlänge mit strlen und...

bernd authored 14 years ago

129)       logger(LOG_INFO, "webapps/include/webapp-installer", "create", "creating db and user »{$handle}«");
bernd Bugfixes beim Webapp-installer

bernd authored 14 years ago

130)       create_mysql_database($handle, $description);
131)       create_mysql_account($handle, $description);
bernd Frage Datenbank-Kürzel nich...

bernd authored 15 years ago

132)       set_mysql_access($handle, $handle, true);
133)       $password = random_string(10);
134)       set_mysql_password($handle, $password);
135)       return array('dbuser' => $handle, 'dbname' => $handle, 'dbpass' => $password);
136)     }
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

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

bernd authored 15 years ago

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