Commit bfcdef6b authored by tbrehm's avatar tbrehm

Merged revisions 3596-3670 from 3.0.5 stable branch.

parent bf49ff3a

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
......@@ -875,8 +875,15 @@ class installer_dist extends installer_base {
exec("chmod -R 770 $install_dir/server/aps_packages");
//* make sure that the server config file (not the interface one) is only readable by the root user
exec("chmod 600 $install_dir/server/lib/$configfile");
exec("chown root:root $install_dir/server/lib/$configfile");
chmod($install_dir.'/server/lib/config.inc.php', 0600);
chown($install_dir.'/server/lib/config.inc.php', 'root');
chgrp($install_dir.'/server/lib/config.inc.php', 'root');
//* Make sure thet the interface config file is readable by user ispconfig only
chmod($install_dir.'/interface/lib/config.inc.php', 0600);
chown($install_dir.'/interface/lib/config.inc.php', 'ispconfig');
chgrp($install_dir.'/interface/lib/config.inc.php', 'ispconfig');
if(@is_file("$install_dir/server/lib/mysql_clientdb.conf")) {
exec("chmod 600 $install_dir/server/lib/mysql_clientdb.conf");
exec("chown root:root $install_dir/server/lib/mysql_clientdb.conf");
......
......@@ -864,9 +864,14 @@ class installer extends installer_base
exec("chmod -R 770 $install_dir/server/aps_packages");
//* make sure that the server config file (not the interface one) is only readable by the root user
chmod($install_dir.'/server/lib/'.$configfile, 0600);
chown($install_dir.'/server/lib/'.$configfile, 'root');
chgrp($install_dir.'/server/lib/'.$configfile, 'root');
chmod($install_dir.'/server/lib/config.inc.php', 0600);
chown($install_dir.'/server/lib/config.inc.php', 'root');
chgrp($install_dir.'/server/lib/config.inc.php', 'root');
//* Make sure thet the interface config file is readable by user ispconfig only
chmod($install_dir.'/interface/lib/config.inc.php', 0600);
chown($install_dir.'/interface/lib/config.inc.php', 'ispconfig');
chgrp($install_dir.'/interface/lib/config.inc.php', 'ispconfig');
chmod($install_dir.'/server/lib/remote_action.inc.php', 0600);
chown($install_dir.'/server/lib/remote_action.inc.php', 'root');
......
......@@ -914,8 +914,15 @@ class installer_dist extends installer_base {
exec("chmod -R 770 $install_dir/server/aps_packages");
//* make sure that the server config file (not the interface one) is only readable by the root user
exec("chmod 600 $install_dir/server/lib/$configfile");
exec("chown root:root $install_dir/server/lib/$configfile");
chmod($install_dir.'/server/lib/config.inc.php', 0600);
chown($install_dir.'/server/lib/config.inc.php', 'root');
chgrp($install_dir.'/server/lib/config.inc.php', 'root');
//* Make sure thet the interface config file is readable by user ispconfig only
chmod($install_dir.'/interface/lib/config.inc.php', 0600);
chown($install_dir.'/interface/lib/config.inc.php', 'ispconfig');
chgrp($install_dir.'/interface/lib/config.inc.php', 'ispconfig');
if(@is_file("$install_dir/server/lib/mysql_clientdb.conf")) {
exec("chmod 600 $install_dir/server/lib/mysql_clientdb.conf");
exec("chown root:root $install_dir/server/lib/mysql_clientdb.conf");
......
......@@ -757,10 +757,11 @@ function is_ispconfig_ssl_enabled() {
function find_hash_file($hash, $dir, $basedir = '') {
$res = opendir($dir);
if(!$res) return false;
if(substr($basedir, -1) === '/') $basedir = substr($basedir, 0, strlen($basedir) - 1);
if(substr($dir, -1) === '/') $dir = substr($dir, 0, strlen($dir) - 1);
if($basedir === '') $basedir = $dir;
while($cur = readdir($res)) {
if($cur == '.' || $cur == '..') continue;
$entry = $dir.'/'.$cur;
......@@ -768,7 +769,7 @@ function find_hash_file($hash, $dir, $basedir = '') {
$result = find_hash_file($hash, $entry, $basedir);
if($result !== false) return $result;
} elseif(md5_file($entry) === $hash) {
$entry = substr($entry, strlen($basedir));
$entry = substr($entry, strlen($basedir) + 1);
if(substr($entry, 0, 7) === '/posix/') $entry = substr($entry, 7);
return $entry;
}
......@@ -782,23 +783,28 @@ function find_hash_file($hash, $dir, $basedir = '') {
(c) 2012 Marius Cramer, pixcept KG, m.cramer@pixcept.de
*/
function get_system_timezone() {
if(is_link('/etc/localtime')) {
$timezone = readlink('/etc/localtime');
$timezone = str_replace('/usr/share/zoneinfo/', '', $timezone);
if(substr($timezone, 0, 6) === 'posix/') $timezone = substr($timezone, 6);
} else {
$hash = md5_file('/etc/localtime');
$timezone = find_hash_file($hash, '/usr/share/zoneinfo');
}
$timezone = false;
if(file_exists('/etc/timezone') && is_readable('/etc/timezone')) {
$timezone = trim(file_get_contents('/etc/timezone'));
if(file_exists('/usr/share/zoneinfo/' . $timezone) == false) $timezone = false;
}
if(!$timezone && is_link('/etc/localtime')) {
$timezone = readlink('/etc/localtime');
$timezone = str_replace('/usr/share/zoneinfo/', '', $timezone);
if(substr($timezone, 0, 6) === 'posix/') $timezone = substr($timezone, 6);
} elseif(!$timezone) {
$hash = md5_file('/etc/localtime');
$timezone = find_hash_file($hash, '/usr/share/zoneinfo');
}
if(!$timezone) {
exec('date +%Z', $tzinfo);
$timezone = $tzinfo[0];
}
if(!$timezone) {
exec('date +%Z', $tzinfo);
$timezone = $tzinfo[0];
}
return $timezone;
return $timezone;
}
?>
......@@ -423,7 +423,7 @@ class installer_base {
$this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, UPDATE (`ssl_request`, `ssl_cert`, `ssl_action`) ON ".$value['db'].".`web_domain` TO '".$value['user']."'@'".$host."' ";
$query = "GRANT SELECT, UPDATE (`ssl_request`, `ssl_cert`, `ssl_action`, `ssl_key`) ON ".$value['db'].".`web_domain` TO '".$value['user']."'@'".$host."' ";
if ($verbose){
echo $query ."\n";
}
......@@ -1816,9 +1816,14 @@ class installer_base {
exec("chmod -R 770 $install_dir/server/aps_packages");
//* make sure that the server config file (not the interface one) is only readable by the root user
chmod($install_dir.'/server/lib/'.$configfile, 0600);
chown($install_dir.'/server/lib/'.$configfile, 'root');
chgrp($install_dir.'/server/lib/'.$configfile, 'root');
chmod($install_dir.'/server/lib/config.inc.php', 0600);
chown($install_dir.'/server/lib/config.inc.php', 'root');
chgrp($install_dir.'/server/lib/config.inc.php', 'root');
//* Make sure thet the interface config file is readable by user ispconfig only
chmod($install_dir.'/interface/lib/config.inc.php', 0600);
chown($install_dir.'/interface/lib/config.inc.php', 'ispconfig');
chgrp($install_dir.'/interface/lib/config.inc.php', 'ispconfig');
chmod($install_dir.'/server/lib/remote_action.inc.php', 0600);
chown($install_dir.'/server/lib/remote_action.inc.php', 'root');
......
ALTER TABLE `client` ADD `paypal_email` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `bank_account_swift` ;
ALTER TABLE `web_domain` ADD `proxy_directives` MEDIUMTEXT NULL DEFAULT NULL ;
......@@ -166,6 +166,7 @@ CREATE TABLE `client` (
`bank_name` varchar(255) DEFAULT NULL,
`bank_account_iban` varchar(255) DEFAULT NULL,
`bank_account_swift` varchar(255) DEFAULT NULL,
`paypal_email` varchar(255) DEFAULT NULL,
`default_mailserver` int(11) unsigned NOT NULL DEFAULT '1',
`limit_maildomain` int(11) NOT NULL DEFAULT '-1',
`limit_mailbox` int(11) NOT NULL DEFAULT '-1',
......@@ -1750,6 +1751,7 @@ CREATE TABLE `web_domain` (
`active` enum('n','y') NOT NULL default 'y',
`traffic_quota_lock` enum('n','y') NOT NULL default 'n',
`fastcgi_php_version` varchar(255) DEFAULT NULL,
`proxy_directives` mediumtext,
PRIMARY KEY (`domain_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
......
......@@ -10,6 +10,10 @@ NameVirtualHost *:{vhost_port}
<VirtualHost _default_:{vhost_port}>
ServerAdmin webmaster@localhost
<FilesMatch "\.ph(p3?|tml)$">
SetHandler None
</FilesMatch>
<IfModule mod_fcgid.c>
DocumentRoot /var/www/ispconfig/
SuexecUserGroup ispconfig ispconfig
......@@ -23,18 +27,18 @@ NameVirtualHost *:{vhost_port}
</Directory>
</IfModule>
<IfModule mod_php5.c>
DocumentRoot /usr/local/ispconfig/interface/web/
AddType application/x-httpd-php .php
<Directory /usr/local/ispconfig/interface/web>
# php_admin_value open_basedir "/usr/local/ispconfig/interface:/usr/share:/tmp"
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
php_value magic_quotes_gpc 0
</Directory>
</IfModule>
# <IfModule mod_php5.c>
# DocumentRoot /usr/local/ispconfig/interface/web/
# AddType application/x-httpd-php .php
# <Directory /usr/local/ispconfig/interface/web>
# # php_admin_value open_basedir "/usr/local/ispconfig/interface:/usr/share:/tmp"
# Options FollowSymLinks
# AllowOverride None
# Order allow,deny
# Allow from all
# php_value magic_quotes_gpc 0
# </Directory>
# </IfModule>
# ErrorLog /var/log/apache2/error.log
# CustomLog /var/log/apache2/access.log combined
......
......@@ -14,5 +14,8 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
default_pass_scheme = CRYPT
password_query = SELECT password FROM mail_user WHERE login = '%u' AND disable%Ls = 'n'
# user_query = SELECT email AS user, maildir AS home, CONCAT('*:storage=', quota , 'B') AS quota_rule FROM mail_user WHERE login = '%u' AND disable%Ls = 'n'
user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND disable%Ls = 'n'
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
# Do not enable it on Dovecot 1.x servers
# iterate_query = SELECT email as user FROM mail_user
......@@ -121,7 +121,9 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
default_pass_scheme = CRYPT
password_query = SELECT password FROM mail_user WHERE login = '%u' AND disable%Ls = 'n'
# user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage=', floor(quota/1024)) AS quota, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE login = '%u' AND disable%Ls = 'n'
user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND disable%Ls = 'n'
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
# Do not enable it on Dovecot 1.x servers
# iterate_query = SELECT email as user FROM mail_user
......@@ -134,5 +134,8 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
default_pass_scheme = CRYPT
password_query = SELECT password FROM mail_user WHERE login = '%u' AND disable%Ls = 'n'
# user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage=', floor(quota/1024)) AS quota, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE login = '%u' AND disable%Ls = 'n'
user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND disable%Ls = 'n'
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
# Do not enable it on Dovecot 1.x servers
# iterate_query = SELECT email as user FROM mail_user
\ No newline at end of file
......@@ -135,3 +135,7 @@ default_pass_scheme = CRYPT
password_query = SELECT password FROM mail_user WHERE login = '%u' AND disable%Ls = 'n'
user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND disable%Ls = 'n'
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
# Do not enable it on Dovecot 1.x servers
# iterate_query = SELECT email as user FROM mail_user
......@@ -55,7 +55,7 @@ nginx_group=www-data
apps_vhost_port=8081
apps_vhost_ip=_default_
apps_vhost_servername=
php_open_basedir=[website_path]/web:[website_path]/private:[website_path]/tmp:/var/www/[website_domain]/web:/srv/www/[website_domain]/web:/usr/share/php5:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/usr/share/php
php_open_basedir=[website_path]/web:[website_path]/private:[website_path]/tmp:/var/www/[website_domain]/web:/srv/www/[website_domain]/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/usr/share/php
htaccess_allow_override=All
awstats_conf_dir=/etc/awstats
awstats_data_dir=/var/lib/awstats
......
......@@ -213,6 +213,12 @@ class app {
$this->tpl->setVar('app_title', $this->_conf['app_title']);
if(isset($_SESSION['s']['user'])) {
$this->tpl->setVar('app_version', $this->_conf['app_version']);
// get pending datalog changes
$datalog = $this->db->datalogStatus();
$this->tpl->setVar('datalog_changes_txt', $this->lng('datalog_changes_txt'));
$this->tpl->setVar('datalog_changes_end_txt', $this->lng('datalog_changes_end_txt'));
$this->tpl->setVar('datalog_changes_count', $datalog['count']);
$this->tpl->setLoop('datalog_changes', $datalog['entries']);
} else {
$this->tpl->setVar('app_version', '');
}
......
......@@ -43,9 +43,6 @@ define('PACKAGE_ERROR_NOMETA', 4);
class ApsBase
{
protected $app = null;
protected $db = null;
protected $log_prefix = '';
protected $fetch_url = '';
protected $aps_version = '';
......@@ -63,9 +60,6 @@ class ApsBase
*/
public function __construct($app, $log_prefix = 'APS: ', $interface_mode = false)
{
$this->db = $app->db;
$this->app = $app;
$this->log_prefix = $log_prefix;
$this->interface_mode = $interface_mode;
$this->fetch_url = 'apscatalog.com';
......
......@@ -54,6 +54,8 @@ class ApsCrawler extends ApsBase
*/
private function checkRequirements()
{
global $app;
try
{
// Check if allow_url_fopen is enabled
......@@ -77,7 +79,7 @@ class ApsCrawler extends ApsBase
}
catch(Exception $e)
{
$this->app->log($this->log_prefix.'Aborting execution because '.$e->getMessage(), LOGLEVEL_ERROR);
$app->log($this->log_prefix.'Aborting execution because '.$e->getMessage(), LOGLEVEL_ERROR);
return false;
}
}
......@@ -213,6 +215,8 @@ class ApsCrawler extends ApsBase
*/
public function startCrawler()
{
global $app;
try
{
// Make sure the requirements are given so that this script can execute
......@@ -220,7 +224,7 @@ class ApsCrawler extends ApsBase
if(!$req_ret) return false;
// Execute the open task and first fetch all vendors (APS catalog API 1.1, p. 12)
$this->app->log($this->log_prefix.'Fetching data from '.$this->fetch_url);
$app->log($this->log_prefix.'Fetching data from '.$this->fetch_url);
$vendor_page = $this->fetchPage('/all-app/'); //$vendor_page = $this->fetchPage('/'.$this->aps_version.'/');
preg_match_all("/\<a href=\"(.+)\/\" class=\"vendor\"/i", $vendor_page, $matches);
......@@ -242,7 +246,7 @@ class ApsCrawler extends ApsBase
// Get all known apps from the database and the highest known version
// Note: A dirty hack is used for numerical sorting of the VARCHAR field Version: +0 -> cast
// A longer but typesafe way would be: ORDER BY CAST(REPLACE(Version, '.', '') AS UNSIGNED) DESC
$existing_apps = $this->db->queryAllRecords("SELECT * FROM (
$existing_apps = $app->db->queryAllRecords("SELECT * FROM (
SELECT name AS Name, CONCAT(version, '-', CAST(`release` AS CHAR)) AS CurrentVersion
FROM aps_packages ORDER BY REPLACE(version, '.', '')+0 DESC, `release` DESC
) as Versions GROUP BY name");
......@@ -325,14 +329,14 @@ class ApsCrawler extends ApsBase
if(file_exists($old_folder)) $this->removeDirectory($old_folder);
/*
$this->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_OUTDATED."' WHERE name = '".
$this->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
$this->db->quote($ex_ver)."';");
$app->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_OUTDATED."' WHERE name = '".
$app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
$app->db->quote($ex_ver)."';");
*/
$tmp = $this->db->queryOneRecord("SELECT id FROM aps_packages WHERE name = '".
$this->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
$this->db->quote($ex_ver)."';");
$this->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_OUTDATED, 'id', $tmp['id']);
$tmp = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE name = '".
$app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
$app->db->quote($ex_ver)."';");
$app->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_OUTDATED, 'id', $tmp['id']);
unset($tmp);
}
......@@ -446,19 +450,19 @@ class ApsCrawler extends ApsBase
if($apps_to_dl_chunks[$i][$j]['filesize'] != 0 &&
$apps_to_dl_chunks[$i][$j]['filesize'] != filesize($apps_to_dl_chunks[$i][$j]['localtarget']))
{
$this->app->log($this->log_prefix.' The filesize of the package "'.
$app->log($this->log_prefix.' The filesize of the package "'.
$apps_to_dl_chunks[$i][$j]['name'].'" is wrong. Download failure?', LOGLEVEL_WARN);
}
}
}
$this->app->log($this->log_prefix.'Processed '.$apps_in_repo.
$app->log($this->log_prefix.'Processed '.$apps_in_repo.
' apps from the repo. Downloaded '.$apps_updated.
' updates, '.$apps_downloaded.' new apps');
}
catch(Exception $e)
{
$this->app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR);
$app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR);
return false;
}
}
......@@ -472,6 +476,8 @@ class ApsCrawler extends ApsBase
*/
public function parseFolderToDB()
{
global $app;
try
{
// This method must be used in server mode
......@@ -491,14 +497,14 @@ class ApsCrawler extends ApsBase
// Get registered packages and mark non-existant packages with an error code to omit the install
$existing_packages = array();
$path_query = $this->db->queryAllRecords('SELECT path AS Path FROM aps_packages;');
$path_query = $app->db->queryAllRecords('SELECT path AS Path FROM aps_packages;');
foreach($path_query as $path) $existing_packages[] = $path['Path'];
$diff = array_diff($existing_packages, $pkg_list);
foreach($diff as $todelete) {
/*$this->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_ERROR_NOMETA."'
WHERE path = '".$this->db->quote($todelete)."';");*/
$tmp = $this->db->queryOneRecord("SELECT id FROM aps_packages WHERE path = '".$this->db->quote($todelete)."';");
$this->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_ERROR_NOMETA, 'id', $tmp['id']);
/*$app->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_ERROR_NOMETA."'
WHERE path = '".$app->db->quote($todelete)."';");*/
$tmp = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE path = '".$app->db->quote($todelete)."';");
$app->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_ERROR_NOMETA, 'id', $tmp['id']);
unset($tmp);
}
......@@ -510,7 +516,7 @@ class ApsCrawler extends ApsBase
$metafile = $this->interface_pkg_dir.'/'.$pkg.'/APP-META.xml';
if(!file_exists($metafile))
{
$this->app->log($this->log_prefix.'Cannot read metadata from '.$pkg, LOGLEVEL_ERROR);
$app->log($this->log_prefix.'Cannot read metadata from '.$pkg, LOGLEVEL_ERROR);
continue;
}
......@@ -527,25 +533,25 @@ class ApsCrawler extends ApsBase
$pkg_release = parent::getXPathValue($sxe, 'release');
/*
$this->db->query("INSERT INTO `aps_packages`
$app->db->query("INSERT INTO `aps_packages`
(`path`, `name`, `category`, `version`, `release`, `package_status`) VALUES
('".$this->db->quote($pkg)."', '".$this->db->quote($pkg_name)."',
'".$this->db->quote($pkg_category)."', '".$this->db->quote($pkg_version)."',
".$this->db->quote($pkg_release).", ".PACKAGE_ENABLED.");");
('".$app->db->quote($pkg)."', '".$app->db->quote($pkg_name)."',
'".$app->db->quote($pkg_category)."', '".$app->db->quote($pkg_version)."',
".$app->db->quote($pkg_release).", ".PACKAGE_ENABLED.");");
*/
$insert_data = "(`path`, `name`, `category`, `version`, `release`, `package_url`, `package_status`) VALUES
('".$this->db->quote($pkg)."', '".$this->db->quote($pkg_name)."',
'".$this->db->quote($pkg_category)."', '".$this->db->quote($pkg_version)."',
".$this->db->quote($pkg_release).", '".$this->db->quote($this->app_download_url_list[$pkg])."', ".PACKAGE_ENABLED.");";
('".$app->db->quote($pkg)."', '".$app->db->quote($pkg_name)."',
'".$app->db->quote($pkg_category)."', '".$app->db->quote($pkg_version)."',
".$app->db->quote($pkg_release).", '".$app->db->quote($this->app_download_url_list[$pkg])."', ".PACKAGE_ENABLED.");";
$this->app->db->datalogInsert('aps_packages', $insert_data, 'id');
$app->db->datalogInsert('aps_packages', $insert_data, 'id');
}
}
catch(Exception $e)
{
$this->app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR);
$this->app->error($e->getMessage());
$app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR);
$app->error($e->getMessage());
return false;
}
}
......
......@@ -87,11 +87,12 @@ class ApsGUIController extends ApsBase
*/
private function getCustomerIDFromDomain($domain)
{
global $app;
$customerid = 0;
$customerdata = $this->db->queryOneRecord("SELECT client_id FROM sys_group, web_domain
$customerdata = $app->db->queryOneRecord("SELECT client_id FROM sys_group, web_domain
WHERE web_domain.sys_groupid = sys_group.groupid
AND web_domain.domain = '".$this->db->quote($domain)."';");
AND web_domain.domain = '".$app->db->quote($domain)."';");
if(!empty($customerdata)) $customerid = $customerdata['client_id'];
return $customerid;
......@@ -106,18 +107,19 @@ class ApsGUIController extends ApsBase
*/
private function getInstanceDataForDatalog($instanceid)
{
global $app;
$webserver_id = '';
$websrv = $this->db->queryOneRecord("SELECT server_id FROM web_domain
$websrv = $app->db->queryOneRecord("SELECT server_id FROM web_domain
WHERE domain = (SELECT value FROM aps_instances_settings
WHERE name = 'main_domain' AND instance_id = ".$this->db->quote($instanceid).");");
WHERE name = 'main_domain' AND instance_id = ".$app->db->quote($instanceid).");");
// If $websrv is empty, an error has occured. Domain no longer existing? Settings table damaged?
// Anyhow, remove this instance record because it's not useful at all
if(empty($websrv))
{
$this->db->query("DELETE FROM aps_instances WHERE id = ".$this->db->quote($instanceid).";");
$this->db->query("DELETE FROM aps_instances_settings WHERE instance_id = ".$this->db->quote($instanceid).";");
$app->db->query("DELETE FROM aps_instances WHERE id = ".$app->db->quote($instanceid).";");
$app->db->query("DELETE FROM aps_instances_settings WHERE instance_id = ".$app->db->quote($instanceid).";");
}
else $webserver_id = $websrv['server_id'];
......@@ -133,12 +135,14 @@ class ApsGUIController extends ApsBase
*/
public function getNewestPackageID($id)
{
global $app;
if(preg_match('/^[0-9]+$/', $id) != 1) return 0;
$result = $this->db->queryOneRecord("SELECT id, name,
$result = $app->db->queryOneRecord("SELECT id, name,
CONCAT(version, '-', CAST(`release` AS CHAR)) AS current_version
FROM aps_packages
WHERE name = (SELECT name FROM aps_packages WHERE id = ".$this->db->quote($id).")
WHERE name = (SELECT name FROM aps_packages WHERE id = ".$app->db->quote($id).")
ORDER BY REPLACE(version, '.', '')+0 DESC, `release` DESC");
if(!empty($result) && ($id != $result['id'])) return $result['id'];
......@@ -155,13 +159,15 @@ class ApsGUIController extends ApsBase
*/
public function isValidPackageID($id, $is_admin = false)
{
global $app;
if(preg_match('/^[0-9]+$/', $id) != 1) return false;
$sql_ext = (!$is_admin) ?
'package_status = '.PACKAGE_ENABLED.' AND' :
'(package_status = '.PACKAGE_ENABLED.' OR package_status = '.PACKAGE_LOCKED.') AND';
$result = $this->db->queryOneRecord("SELECT id FROM aps_packages WHERE ".$sql_ext." id = ".$this->db->quote($id).";");
$result = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE ".$sql_ext." id = ".$app->db->quote($id).";");
if(!$result) return false;
return true;
......@@ -177,12 +183,14 @@ class ApsGUIController extends ApsBase
*/
public function isValidInstanceID($id, $client_id, $is_admin = false)
{
global $app;
if(preg_match('/^[0-9]+$/', $id) != 1) return false;
// Only filter if not admin
$sql_ext = (!$is_admin) ? 'customer_id = '.$this->db->quote($client_id).' AND' : '';
$sql_ext = (!$is_admin) ? 'customer_id = '.$app->db->quote($client_id).' AND' : '';
$result = $this->db->queryOneRecord('SELECT id FROM aps_instances WHERE '.$sql_ext.' id = '.$this->db->quote($id).';');
$result = $app->db->queryOneRecord('SELECT id FROM aps_instances WHERE '.$sql_ext.' id = '.$app->db->quote($id).';');
if(!$result) return false;
return true;
......@@ -202,15 +210,15 @@ class ApsGUIController extends ApsBase
$app->uses('tools_sites');
$webserver_id = 0;
$websrv = $this->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '".$this->db->quote($settings['main_domain'])."';");
$websrv = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '".$app->db->quote($settings['main_domain'])."';");
if(!empty($websrv)) $webserver_id = $websrv['server_id'];
$customerid = $this->getCustomerIDFromDomain($settings['main_domain']);
if(empty($settings) || empty($webserver_id)) return false;
//* Get server config of the web server
$this->app->uses("getconf");
$web_config = $this->app->getconf->get_server_config($app->functions->intval($websrv["server_id"]),'web');
$app->uses("getconf");
$web_config = $app->getconf->get_server_config($app->functions->intval($websrv["server_id"]),'web');