Commit bfcdef6b authored by tbrehm's avatar tbrehm
Browse files

Merged revisions 3596-3670 from 3.0.5 stable branch.

parent bf49ff3a
......@@ -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;
}
}
......
......@@ -96,7 +96,8 @@ class db extends mysqli
}
public function query($queryString) {
$this->queryId = parent::query($queryString);
parent::ping();
$this->queryId = parent::query($queryString);
$this->updateError('DB::query('.$queryString.') -> mysqli_query');
if($this->errorNumber) debug_print_backtrace();
if(!$this->queryId) {
......@@ -317,6 +318,28 @@ public function toLower($record) {
return true;
}
//* get the current datalog status for the specified login (or currently logged in user)
public function datalogStatus($login = '') {
global $app;
$return = array('count' => 0, 'entries' => array());
if($_SESSION['s']['user']['typ'] == 'admin') return $return; // these information should not be displayed to admin users
if($login == '' && isset($_SESSION['s']['user'])) {
$login = $_SESSION['s']['user']['username'];
}
$result = $this->queryAllRecords("SELECT COUNT( * ) AS cnt, sys_datalog.action, sys_datalog.dbtable FROM sys_datalog, server WHERE server.server_id = sys_datalog.server_id AND sys_datalog.user = '" . $this->quote($login) . "' AND sys_datalog.datalog_id > server.updated GROUP BY sys_datalog.dbtable, sys_datalog.action");
foreach($result as $row) {
if(!$row['dbtable'] || in_array($row['dbtable'], array('aps_instances', 'aps_instances_settings', 'mail_access', 'mail_content_filter'))) continue; // ignore some entries, maybe more to come
$return['entries'][] = array('table' => $row['dbtable'], 'action' => $row['action'], 'count' => $row['cnt'], 'text' => $app->lng('datalog_status_' . $row['action'] . '_' . $row['dbtable']));
$return['count'] += $row['cnt'];
}
unset($result);
return $return;
}
public function freeResult($query)
......@@ -466,12 +489,21 @@ public function toLower($record) {
if($rows = $app->db->queryAllRecords('SHOW FIELDS FROM '.$table_name)){
foreach($rows as $row) {
/*
$name = $row[0];
$default = $row[4];
$key = $row[3];
$extra = $row[5];
$isnull = $row[2];
$type = $row[1];
*/
$name = $row['Field'];
$default = $row['Default'];
$key = $row['Key'];
$extra = $row['Extra'];
$isnull = $row['Null'];
$type = $row['Type'];
$column = array();
......
......@@ -306,30 +306,52 @@ class remoting {
}
//* dodanie uzytkownika email
//* Add mail domain
public function mail_user_add($session_id, $client_id, $params){
global $app;
if (!$this->checkPerm($session_id, 'mail_user_add')){
$this->server->fault('permission_denied','You do not have the permissions to access this function.');
return false;
}
//* Check if mail domain exists
$email_parts = explode('@',$params['email']);
$tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = '".$app->db->quote($email_parts[1])."'");
if($tmp['domain'] != $email_parts[1]) {
$this->server->fault('mail_domain_does_not_exist','Mail domain - '.$email_parts[1].' - does not exist.');
return false;
}
$affected_rows = $this->insertQuery('../mail/form/mail_user.tform.php', $client_id, $params);
return $affected_rows;
}
//* edycja uzytkownika email
//* Update mail user
public function mail_user_update($session_id, $client_id, $primary_id, $params)
{
global $app;
if (!$this->checkPerm($session_id, 'mail_user_update'))
{
$this->server->fault('permission_denied','You do not have the permissions to access this function.');
return false;
}
//* Check if mail domain exists
$email_parts = explode('@',$params['email']);
$tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = '".$app->db->quote($email_parts[1])."'");
if($tmp['domain'] != $email_parts[1]) {
$this->server->fault('mail_domain_does_not_exist','Mail domain - '.$email_parts[1].' - does not exist.');
return false;
}
$affected_rows = $this->updateQuery('../mail/form/mail_user.tform.php', $client_id, $primary_id, $params);
return $affected_rows;
}
//*usuniecie uzytkownika emial
//* Delete mail user
public function mail_user_delete($session_id, $primary_id)
{
if (!$this->checkPerm($session_id, 'mail_user_delete'))
......@@ -1108,61 +1130,56 @@ class remoting {
public function client_delete_everything($session_id, $client_id)
{
global $app, $conf;
if(!$this->checkPerm($session_id, 'client_delete_everything')) {
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$client_id = $app->functions->intval($client_id);
$client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id");
$tables = 'client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_database_user,web_domain,web_traffic';
$tables_array = explode(',',$tables);
$client_group_id = $app->functions->intval($client_group['groupid']);