Webapp-Installer, erste Ver...
bernd authored 16 years ago
|
1) <?php
2)
3) require_once('inc/base.php');
4)
5) function create_new_webapp($appname, $directory, $url, $data)
6) {
7) $username = mysql_real_escape_string($_SESSION['userinfo']['username']);
8) $appname = mysql_real_escape_string($appname);
9) $directory = mysql_real_escape_string($directory);
10) $url = mysql_real_escape_string($url);
11) $data = mysql_real_escape_string($data);
12) db_query("INSERT INTO vhosts.webapp_installer VALUES (NULL, '{$appname}', '{$directory}', '{$url}', 'new', '{$username}', '{$data}')");
13) }
14)
15)
|
* alle internen Links sinnv...
bernd authored 16 years ago
|
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)
|
Frage Datenbank-Kürzel nich...
bernd authored 15 years ago
|
64) function create_webapp_mysqldb($application, $sitename)
|
Webapp-Installer, erste Ver...
bernd authored 16 years ago
|
65) {
66) // dependet auf das mysql-modul
67) require_once('modules/mysql/include/mysql.php');
68)
69) $username = mysql_real_escape_string($_SESSION['userinfo']['username']);
|
Frage Datenbank-Kürzel nich...
bernd authored 15 years ago
|
70) $description = "Automatisch erzeugte Datenbank für {$application} ({$sitename})";
|
Webapp-Installer, erste Ver...
bernd authored 16 years ago
|
71)
|
Frage Datenbank-Kürzel nich...
bernd authored 15 years ago
|
72) // zuerst versuchen wir username_webappname. Wenn das nicht klappt, dann wird hochgezählt
73) $handle = $username.'_'.$application;
74)
75) if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && ! (has_mysql_user($handle) || has_mysql_database($handle)))
|
Webapp-Installer, erste Ver...
bernd authored 16 years ago
|
76) {
|
Frage Datenbank-Kürzel nich...
bernd authored 15 years ago
|
77) create_mysql_database($handle, $description);
78) create_mysql_account($handle, $description);
79) set_mysql_access($handle, $handle, true);
80) $password = random_string(10);
81) set_mysql_password($handle, $password);
82) return array('dbuser' => $handle, 'dbname' => $handle, 'dbpass' => $password);
|
Webapp-Installer, erste Ver...
bernd authored 16 years ago
|
83) }
84)
|
Frage Datenbank-Kürzel nich...
bernd authored 15 years ago
|
85) for ($i = 0; $i < 100 ; $i++) {
86) $handle = $username.'_'.$i;
87) if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && ! (has_mysql_user($handle) || has_mysql_database($handle)))
88) {
89) create_mysql_database($handle);
90) create_mysql_account($handle);
91) set_mysql_access($handle, $handle, true);
92) $password = random_string(10);
93) set_mysql_password($handle, $password);
94) return array('dbuser' => $handle, 'dbname' => $handle, 'dbpass' => $password);
95) }
|
Webapp-Installer, erste Ver...
bernd authored 16 years ago
|
96) }
|
Frage Datenbank-Kürzel nich...
bernd authored 15 years ago
|
97) system_failure('Konnte keine Datenbank erzeugen. Bitte melden Sie diesen Umstand den Administratoren!');
|