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 { ...@@ -875,8 +875,15 @@ class installer_dist extends installer_base {
exec("chmod -R 770 $install_dir/server/aps_packages"); 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 //* 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"); chmod($install_dir.'/server/lib/config.inc.php', 0600);
exec("chown root:root $install_dir/server/lib/$configfile"); 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")) { if(@is_file("$install_dir/server/lib/mysql_clientdb.conf")) {
exec("chmod 600 $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"); exec("chown root:root $install_dir/server/lib/mysql_clientdb.conf");
......
...@@ -864,9 +864,14 @@ class installer extends installer_base ...@@ -864,9 +864,14 @@ class installer extends installer_base
exec("chmod -R 770 $install_dir/server/aps_packages"); 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 //* 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); chmod($install_dir.'/server/lib/config.inc.php', 0600);
chown($install_dir.'/server/lib/'.$configfile, 'root'); chown($install_dir.'/server/lib/config.inc.php', 'root');
chgrp($install_dir.'/server/lib/'.$configfile, '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); chmod($install_dir.'/server/lib/remote_action.inc.php', 0600);
chown($install_dir.'/server/lib/remote_action.inc.php', 'root'); chown($install_dir.'/server/lib/remote_action.inc.php', 'root');
......
...@@ -914,8 +914,15 @@ class installer_dist extends installer_base { ...@@ -914,8 +914,15 @@ class installer_dist extends installer_base {
exec("chmod -R 770 $install_dir/server/aps_packages"); 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 //* 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"); chmod($install_dir.'/server/lib/config.inc.php', 0600);
exec("chown root:root $install_dir/server/lib/$configfile"); 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")) { if(@is_file("$install_dir/server/lib/mysql_clientdb.conf")) {
exec("chmod 600 $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"); exec("chown root:root $install_dir/server/lib/mysql_clientdb.conf");
......
...@@ -758,6 +758,7 @@ function find_hash_file($hash, $dir, $basedir = '') { ...@@ -758,6 +758,7 @@ function find_hash_file($hash, $dir, $basedir = '') {
$res = opendir($dir); $res = opendir($dir);
if(!$res) return false; 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(substr($dir, -1) === '/') $dir = substr($dir, 0, strlen($dir) - 1);
if($basedir === '') $basedir = $dir; if($basedir === '') $basedir = $dir;
...@@ -768,7 +769,7 @@ function find_hash_file($hash, $dir, $basedir = '') { ...@@ -768,7 +769,7 @@ function find_hash_file($hash, $dir, $basedir = '') {
$result = find_hash_file($hash, $entry, $basedir); $result = find_hash_file($hash, $entry, $basedir);
if($result !== false) return $result; if($result !== false) return $result;
} elseif(md5_file($entry) === $hash) { } 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); if(substr($entry, 0, 7) === '/posix/') $entry = substr($entry, 7);
return $entry; return $entry;
} }
...@@ -782,11 +783,17 @@ function find_hash_file($hash, $dir, $basedir = '') { ...@@ -782,11 +783,17 @@ function find_hash_file($hash, $dir, $basedir = '') {
(c) 2012 Marius Cramer, pixcept KG, m.cramer@pixcept.de (c) 2012 Marius Cramer, pixcept KG, m.cramer@pixcept.de
*/ */
function get_system_timezone() { function get_system_timezone() {
if(is_link('/etc/localtime')) { $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 = readlink('/etc/localtime');
$timezone = str_replace('/usr/share/zoneinfo/', '', $timezone); $timezone = str_replace('/usr/share/zoneinfo/', '', $timezone);
if(substr($timezone, 0, 6) === 'posix/') $timezone = substr($timezone, 6); if(substr($timezone, 0, 6) === 'posix/') $timezone = substr($timezone, 6);
} else { } elseif(!$timezone) {
$hash = md5_file('/etc/localtime'); $hash = md5_file('/etc/localtime');
$timezone = find_hash_file($hash, '/usr/share/zoneinfo'); $timezone = find_hash_file($hash, '/usr/share/zoneinfo');
} }
...@@ -800,5 +807,4 @@ function get_system_timezone() { ...@@ -800,5 +807,4 @@ function get_system_timezone() {
} }
?> ?>
...@@ -423,7 +423,7 @@ class installer_base { ...@@ -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); $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){ if ($verbose){
echo $query ."\n"; echo $query ."\n";
} }
...@@ -1816,9 +1816,14 @@ class installer_base { ...@@ -1816,9 +1816,14 @@ class installer_base {
exec("chmod -R 770 $install_dir/server/aps_packages"); 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 //* 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); chmod($install_dir.'/server/lib/config.inc.php', 0600);
chown($install_dir.'/server/lib/'.$configfile, 'root'); chown($install_dir.'/server/lib/config.inc.php', 'root');
chgrp($install_dir.'/server/lib/'.$configfile, '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); chmod($install_dir.'/server/lib/remote_action.inc.php', 0600);
chown($install_dir.'/server/lib/remote_action.inc.php', 'root'); 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` ( ...@@ -166,6 +166,7 @@ CREATE TABLE `client` (
`bank_name` varchar(255) DEFAULT NULL, `bank_name` varchar(255) DEFAULT NULL,
`bank_account_iban` varchar(255) DEFAULT NULL, `bank_account_iban` varchar(255) DEFAULT NULL,
`bank_account_swift` 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', `default_mailserver` int(11) unsigned NOT NULL DEFAULT '1',
`limit_maildomain` int(11) NOT NULL DEFAULT '-1', `limit_maildomain` int(11) NOT NULL DEFAULT '-1',
`limit_mailbox` int(11) NOT NULL DEFAULT '-1', `limit_mailbox` int(11) NOT NULL DEFAULT '-1',
...@@ -1750,6 +1751,7 @@ CREATE TABLE `web_domain` ( ...@@ -1750,6 +1751,7 @@ CREATE TABLE `web_domain` (
`active` enum('n','y') NOT NULL default 'y', `active` enum('n','y') NOT NULL default 'y',
`traffic_quota_lock` enum('n','y') NOT NULL default 'n', `traffic_quota_lock` enum('n','y') NOT NULL default 'n',
`fastcgi_php_version` varchar(255) DEFAULT NULL, `fastcgi_php_version` varchar(255) DEFAULT NULL,
`proxy_directives` mediumtext,
PRIMARY KEY (`domain_id`) PRIMARY KEY (`domain_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
......
...@@ -10,6 +10,10 @@ NameVirtualHost *:{vhost_port} ...@@ -10,6 +10,10 @@ NameVirtualHost *:{vhost_port}
<VirtualHost _default_:{vhost_port}> <VirtualHost _default_:{vhost_port}>
ServerAdmin webmaster@localhost ServerAdmin webmaster@localhost
<FilesMatch "\.ph(p3?|tml)$">
SetHandler None
</FilesMatch>
<IfModule mod_fcgid.c> <IfModule mod_fcgid.c>
DocumentRoot /var/www/ispconfig/ DocumentRoot /var/www/ispconfig/
SuexecUserGroup ispconfig ispconfig SuexecUserGroup ispconfig ispconfig
...@@ -23,18 +27,18 @@ NameVirtualHost *:{vhost_port} ...@@ -23,18 +27,18 @@ NameVirtualHost *:{vhost_port}
</Directory> </Directory>
</IfModule> </IfModule>
<IfModule mod_php5.c> # <IfModule mod_php5.c>
DocumentRoot /usr/local/ispconfig/interface/web/ # DocumentRoot /usr/local/ispconfig/interface/web/
AddType application/x-httpd-php .php # AddType application/x-httpd-php .php
<Directory /usr/local/ispconfig/interface/web> # <Directory /usr/local/ispconfig/interface/web>
# php_admin_value open_basedir "/usr/local/ispconfig/interface:/usr/share:/tmp" # # php_admin_value open_basedir "/usr/local/ispconfig/interface:/usr/share:/tmp"
Options FollowSymLinks # Options FollowSymLinks
AllowOverride None # AllowOverride None
Order allow,deny # Order allow,deny
Allow from all # Allow from all
php_value magic_quotes_gpc 0 # php_value magic_quotes_gpc 0
</Directory> # </Directory>
</IfModule> # </IfModule>
# ErrorLog /var/log/apache2/error.log # ErrorLog /var/log/apache2/error.log
# CustomLog /var/log/apache2/access.log combined # CustomLog /var/log/apache2/access.log combined
......
...@@ -14,5 +14,8 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se ...@@ -14,5 +14,8 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
default_pass_scheme = CRYPT default_pass_scheme = CRYPT
password_query = SELECT password FROM mail_user WHERE login = '%u' AND disable%Ls = 'n' 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' 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 ...@@ -121,7 +121,9 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
default_pass_scheme = CRYPT default_pass_scheme = CRYPT
password_query = SELECT password FROM mail_user WHERE login = '%u' AND disable%Ls = 'n' 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' 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 ...@@ -134,5 +134,8 @@ connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_se
default_pass_scheme = CRYPT default_pass_scheme = CRYPT
password_query = SELECT password FROM mail_user WHERE login = '%u' AND disable%Ls = 'n' 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' 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 ...@@ -135,3 +135,7 @@ default_pass_scheme = CRYPT
password_query = SELECT password FROM mail_user WHERE login = '%u' AND disable%Ls = 'n' 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' 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 ...@@ -55,7 +55,7 @@ nginx_group=www-data
apps_vhost_port=8081 apps_vhost_port=8081
apps_vhost_ip=_default_ apps_vhost_ip=_default_
apps_vhost_servername= 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 htaccess_allow_override=All
awstats_conf_dir=/etc/awstats awstats_conf_dir=/etc/awstats
awstats_data_dir=/var/lib/awstats awstats_data_dir=/var/lib/awstats
......
...@@ -213,6 +213,12 @@ class app { ...@@ -213,6 +213,12 @@ class app {
$this->tpl->setVar('app_title', $this->_conf['app_title']); $this->tpl->setVar('app_title', $this->_conf['app_title']);
if(isset($_SESSION['s']['user'])) { if(isset($_SESSION['s']['user'])) {
$this->tpl->setVar('app_version', $this->_conf['app_version']); $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 { } else {
$this->tpl->setVar('app_version', ''); $this->tpl->setVar('app_version', '');
} }
......
...@@ -43,9 +43,6 @@ define('PACKAGE_ERROR_NOMETA', 4); ...@@ -43,9 +43,6 @@ define('PACKAGE_ERROR_NOMETA', 4);
class ApsBase class ApsBase
{ {
protected $app = null;
protected $db = null;
protected $log_prefix = ''; protected $log_prefix = '';
protected $fetch_url = ''; protected $fetch_url = '';
protected $aps_version = ''; protected $aps_version = '';
...@@ -63,9 +60,6 @@ class ApsBase ...@@ -63,9 +60,6 @@ class ApsBase
*/ */
public function __construct($app, $log_prefix = 'APS: ', $interface_mode = false) public function __construct($app, $log_prefix = 'APS: ', $interface_mode = false)
{ {
$this->db = $app->db;
$this->app = $app;
$this->log_prefix = $log_prefix; $this->log_prefix = $log_prefix;
$this->interface_mode = $interface_mode; $this->interface_mode = $interface_mode;
$this->fetch_url = 'apscatalog.com'; $this->fetch_url = 'apscatalog.com';
......
...@@ -54,6 +54,8 @@ class ApsCrawler extends ApsBase ...@@ -54,6 +54,8 @@ class ApsCrawler extends ApsBase
*/ */
private function checkRequirements() private function checkRequirements()
{ {
global $app;
try try
{ {
// Check if allow_url_fopen is enabled // Check if allow_url_fopen is enabled
...@@ -77,7 +79,7 @@ class ApsCrawler extends ApsBase ...@@ -77,7 +79,7 @@ class ApsCrawler extends ApsBase
} }
catch(Exception $e) 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; return false;
} }
} }
...@@ -213,6 +215,8 @@ class ApsCrawler extends ApsBase ...@@ -213,6 +215,8 @@ class ApsCrawler extends ApsBase
*/ */
public function startCrawler() public function startCrawler()
{ {
global $app;
try try
{ {
// Make sure the requirements are given so that this script can execute // Make sure the requirements are given so that this script can execute
...@@ -220,7 +224,7 @@ class ApsCrawler extends ApsBase ...@@ -220,7 +224,7 @@ class ApsCrawler extends ApsBase
if(!$req_ret) return false; if(!$req_ret) return false;
// Execute the open task and first fetch all vendors (APS catalog API 1.1, p. 12) // 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.'/'); $vendor_page = $this->fetchPage('/all-app/'); //$vendor_page = $this->fetchPage('/'.$this->aps_version.'/');
preg_match_all("/\<a href=\"(.+)\/\" class=\"vendor\"/i", $vendor_page, $matches); preg_match_all("/\<a href=\"(.+)\/\" class=\"vendor\"/i", $vendor_page, $matches);
...@@ -242,7 +246,7 @@ class ApsCrawler extends ApsBase ...@@ -242,7 +246,7 @@ class ApsCrawler extends ApsBase
// Get all known apps from the database and the highest known version // 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 // 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 // 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 SELECT name AS Name, CONCAT(version, '-', CAST(`release` AS CHAR)) AS CurrentVersion
FROM aps_packages ORDER BY REPLACE(version, '.', '')+0 DESC, `release` DESC FROM aps_packages ORDER BY REPLACE(version, '.', '')+0 DESC, `release` DESC
) as Versions GROUP BY name"); ) as Versions GROUP BY name");
...@@ -325,14 +329,14 @@ class ApsCrawler extends ApsBase ...@@ -325,14 +329,14 @@ class ApsCrawler extends ApsBase
if(file_exists($old_folder)) $this->removeDirectory($old_folder); if(file_exists($old_folder)) $this->removeDirectory($old_folder);
/* /*
$this->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_OUTDATED."' WHERE name = '". $app->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_OUTDATED."' WHERE name = '".
$this->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '". $app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
$this->db->quote($ex_ver)."';"); $app->db->quote($ex_ver)."';");
*/ */
$tmp = $this->db->queryOneRecord("SELECT id FROM aps_packages WHERE name = '". $tmp = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE name = '".
$this->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '". $app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '".
$this->db->quote($ex_ver)."';"); $app->db->quote($ex_ver)."';");
$this->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_OUTDATED, 'id', $tmp['id']); $app->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_OUTDATED, 'id', $tmp['id']);
unset($tmp); unset($tmp);
} }
...@@ -446,19 +450,19 @@ class ApsCrawler extends ApsBase ...@@ -446,19 +450,19 @@ class ApsCrawler extends ApsBase
if($apps_to_dl_chunks[$i][$j]['filesize'] != 0 && if($apps_to_dl_chunks[$i][$j]['filesize'] != 0 &&
$apps_to_dl_chunks[$i][$j]['filesize'] != filesize($apps_to_dl_chunks[$i][$j]['localtarget'])) $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); $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. ' apps from the repo. Downloaded '.$apps_updated.
' updates, '.$apps_downloaded.' new apps'); ' updates, '.$apps_downloaded.' new apps');
} }
catch(Exception $e) catch(Exception $e)
{ {
$this->app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR); $app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR);
return false; return false;
} }
} }
...@@ -472,6 +476,8 @@ class ApsCrawler extends ApsBase ...@@ -472,6 +476,8 @@ class ApsCrawler extends ApsBase
*/ */
public function parseFolderToDB() public function parseFolderToDB()
{ {
global $app;
try try
{ {
// This method must be used in server mode // This method must be used in server mode
...@@ -491,14 +497,14 @@ class ApsCrawler extends ApsBase ...@@ -491,14 +497,14 @@ class ApsCrawler extends ApsBase
// Get registered packages and mark non-existant packages with an error code to omit the install // Get registered packages and mark non-existant packages with an error code to omit the install
$existing_packages = array(); $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']; foreach($path_query as $path) $existing_packages[] = $path['Path'];
$diff = array_diff($existing_packages, $pkg_list); $diff = array_diff($existing_packages, $pkg_list);
foreach($diff as $todelete) { foreach($diff as $todelete) {
/*$this->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_ERROR_NOMETA."' /*$app->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_ERROR_NOMETA."'
WHERE path = '".$this->db->quote($todelete)."';");*/ WHERE path = '".$app->db->quote($todelete)."';");*/
$tmp = $this->db->queryOneRecord("SELECT id FROM aps_packages WHERE path = '".$this->db->quote($todelete)."';"); $tmp = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE path = '".$app->db->quote($todelete)."';");
$this->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_ERROR_NOMETA, 'id', $tmp['id']); $app->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_ERROR_NOMETA, 'id', $tmp['id']);
unset($tmp); unset($tmp);
} }
...@@ -510,7 +516,7 @@ class ApsCrawler extends ApsBase ...@@ -510,7 +516,7 @@ class ApsCrawler extends ApsBase
$metafile = $this->interface_pkg_dir.'/'.$pkg.'/APP-META.xml'; $metafile = $this->interface_pkg_dir.'/'.$pkg.'/APP-META.xml';
if(!file_exists($metafile)) 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; continue;
} }
...@@ -527,25 +533,25 @@ class ApsCrawler extends ApsBase ...@@ -527,25 +533,25 @@ class ApsCrawler extends ApsBase
$pkg_release = parent::getXPathValue($sxe, 'release'); $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 (`path`, `name`, `category`, `version`, `release`, `package_status`) VALUES
('".$this->db->quote($pkg)."', '".$this->db->quote($pkg_name)."', ('".$app->db->quote($pkg)."', '".$app->db->quote($pkg_name)."',
'".$this->db->quote($pkg_category)."', '".$this->db->quote($pkg_version)."', '".$app->db->quote($pkg_category)."', '".$app->db->quote($pkg_version)."',
".$this->db->quote($pkg_release).", ".PACKAGE_ENABLED.");"); ".$app->db->quote($pkg_release).", ".PACKAGE_ENABLED.");");
*/ */