Commit cc65688b authored by hellkat's avatar hellkat
Browse files

Merged revisions 3845-3876 and 3879-3918 from stable branch.

parent 63527811
......@@ -1024,7 +1024,7 @@ class installer_dist extends installer_base {
//copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
//* and create the symlink
if($this->is_update == false) {
//if($this->is_update == false) {
if(@is_link("$vhost_conf_enabled_dir/ispconfig.vhost")) unlink("$vhost_conf_enabled_dir/ispconfig.vhost");
if(!@is_link("$vhost_conf_enabled_dir/000-ispconfig.vhost")) {
exec("ln -s $vhost_conf_dir/ispconfig.vhost $vhost_conf_enabled_dir/000-ispconfig.vhost");
......@@ -1039,17 +1039,17 @@ class installer_dist extends installer_base {
replaceLine('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter','PHPRC=','PHPRC=/etc/',0,0);
*/
if(!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
//if(!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
$content = rf('tpl/apache_ispconfig_fcgi_starter.master');
$content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content);
$content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content);
exec('mkdir -p /var/www/php-fcgi-scripts/ispconfig');
if(!is_dir('/var/www/php-fcgi-scripts/ispconfig')) exec('mkdir -p /var/www/php-fcgi-scripts/ispconfig');
wf('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', $content);
exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
exec('ln -s /usr/local/ispconfig/interface/web /var/www/ispconfig');
if(!is_link('/var/www/ispconfig')) exec('ln -s /usr/local/ispconfig/interface/web /var/www/ispconfig');
exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig');
}
}
//}
//}
}
if($conf['nginx']['installed'] == true && $this->install_ispconfig_interface == true){
......@@ -1228,7 +1228,7 @@ class installer_dist extends installer_base {
$existing_cron_jobs = file('crontab.txt');
$cron_jobs = array(
'*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /var/log/ispconfig/cron.log'
'*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /dev/null'
);
// remove existing ispconfig cronjobs, in case the syntax has changed
......@@ -1247,7 +1247,7 @@ class installer_dist extends installer_base {
}
exec('touch /var/log/ispconfig/cron.log');
exec('chmod 666 /var/log/ispconfig/cron.log');
exec('chmod 660 /var/log/ispconfig/cron.log');
}
}
......
......@@ -610,8 +610,8 @@ class installer extends installer_base
$this->write_config_file("$vhost_conf_dir/apps.vhost", $content);
if ( !is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter') )
{
//if ( !is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter') )
//{
$content = rf('tpl/apache_apps_fcgi_starter.master');
$content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content);
$content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content);
......@@ -621,7 +621,7 @@ class installer extends installer_base
exec('chmod +x '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
exec('chown -R ispapps:ispapps '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
}
//}
}
if($conf['nginx']['installed'] == true){
$apps_vhost_user = escapeshellcmd($conf['web']['apps_vhost_user']);
......@@ -946,11 +946,11 @@ class installer extends installer_base
$content = rf('tpl/apache_ispconfig_fcgi_starter.master');
$content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content);
$content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content);
mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true);
@mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true);
wf('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', $content);
exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
chmod('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', 0755);
symlink($install_dir.'/interface/web','/var/www/ispconfig');
@symlink($install_dir.'/interface/web','/var/www/ispconfig');
exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig');
}
}
......
......@@ -1078,7 +1078,7 @@ class installer_dist extends installer_base {
wf("$vhost_conf_dir/ispconfig.vhost", $content);
if(!is_file('/srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
//if(!is_file('/srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
$content = rf('tpl/apache_ispconfig_fcgi_starter.master');
$content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content);
$content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content);
......@@ -1088,7 +1088,7 @@ class installer_dist extends installer_base {
exec('ln -s /usr/local/ispconfig/interface/web /srv/www/ispconfig');
exec('chown -R ispconfig:ispconfig /srv/www/php-fcgi-scripts/ispconfig');
}
//}
//copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
//* and create the symlink
......@@ -1280,7 +1280,7 @@ class installer_dist extends installer_base {
$existing_cron_jobs = file('crontab.txt');
$cron_jobs = array(
'*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /var/log/ispconfig/cron.log'
'*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /dev/null'
);
// remove existing ispconfig cronjobs, in case the syntax has changed
......@@ -1299,7 +1299,7 @@ class installer_dist extends installer_base {
}
exec('touch /var/log/ispconfig/cron.log');
exec('chmod 666 /var/log/ispconfig/cron.log');
exec('chmod 660 /var/log/ispconfig/cron.log');
}
}
......
......@@ -567,23 +567,6 @@ class installer_base {
}
}
}
$config_dir = $conf['mailman']['config_dir'].'/';
$full_file_name = $config_dir.'virtual_to_transport.sh';
//* Backup exiting virtual_to_transport.sh script
if(is_file($full_file_name)) {
copy($full_file_name, $config_dir.'virtual_to_transport.sh~');
}
copy('tpl/mailman-virtual_to_transport.sh',$full_file_name);
chgrp($full_file_name,'list');
chmod($full_file_name,0750);
if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman');
exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman');
exec('/usr/lib/mailman/bin/genaliases 2>/dev/null');
$virtual_domains = '';
if($status == 'update')
......@@ -608,8 +591,27 @@ class installer_base {
if(!isset($old_options['DEFAULT_SERVER_LANGUAGE'])) $old_options['DEFAULT_SERVER_LANGUAGE'] = '';
$content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content);
$content = str_replace('{virtual_domains}', $virtual_domains, $content);
wf($full_file_name, $content);
//* Write virtual_to_transport.sh script
$config_dir = $conf['mailman']['config_dir'].'/';
$full_file_name = $config_dir.'virtual_to_transport.sh';
//* Backup exiting virtual_to_transport.sh script
if(is_file($full_file_name)) {
copy($full_file_name, $config_dir.'virtual_to_transport.sh~');
}
if(is_dir('/etc/mailman')) {
copy('tpl/mailman-virtual_to_transport.sh',$full_file_name);
chgrp($full_file_name,'list');
chmod($full_file_name,0750);
}
//* Create aliasaes
exec('/usr/lib/mailman/bin/genaliases 2>/dev/null');
}
public function configure_postfix($options = '') {
......@@ -732,11 +734,13 @@ class installer_base {
touch($config_dir.'/body_checks');
//* Create the mailman files
exec('mkdir -p /var/lib/mailman/data');
if(!is_dir('/var/lib/mailman/data')) exec('mkdir -p /var/lib/mailman/data');
if(!is_file('/var/lib/mailman/data/aliases')) touch('/var/lib/mailman/data/aliases');
exec('postalias /var/lib/mailman/data/aliases');
if(!is_file('/var/lib/mailman/data/virtual-mailman')) touch('/var/lib/mailman/data/virtual-mailman');
exec('postmap /var/lib/mailman/data/virtual-mailman');
if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman');
exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman');
//* Make a backup copy of the main.cf file
copy($config_dir.'/main.cf', $config_dir.'/main.cf~');
......@@ -1921,16 +1925,16 @@ class installer_base {
symlink($vhost_conf_dir.'/ispconfig.vhost',$vhost_conf_enabled_dir.'/000-ispconfig.vhost');
}
}
if(!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
//if(!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
$content = rf('tpl/apache_ispconfig_fcgi_starter.master');
$content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content);
$content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content);
mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true);
@mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true);
wf('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', $content);
exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
symlink($install_dir.'/interface/web','/var/www/ispconfig');
@symlink($install_dir.'/interface/web','/var/www/ispconfig');
exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig');
}
//}
}
if($conf['nginx']['installed'] == true && $this->install_ispconfig_interface == true){
......@@ -2116,7 +2120,7 @@ class installer_base {
$existing_cron_jobs = file('crontab.txt');
$cron_jobs = array(
'*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> '.$conf['ispconfig_log_dir'].'/cron.log'
'*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /dev/null'
);
// remove existing ispconfig cronjobs, in case the syntax has changed
......@@ -2135,7 +2139,7 @@ class installer_base {
}
touch($conf['ispconfig_log_dir'].'/cron.log');
chmod($conf['ispconfig_log_dir'].'/cron.log', 0666);
chmod($conf['ispconfig_log_dir'].'/cron.log', 0660);
}
......
......@@ -20,6 +20,6 @@ INSERT INTO `sys_theme` (`var_id`, `tpl_name`, `username`, `logo_url`) VALUES (N
-- --------------------------------------------------------
ALTER TABLE `web_domain` ADD `ssl_key` MEDIUMTEXT NOT NULL AFTER `ssl_bundle`;
ALTER TABLE `mail_user` ADD `disabledoveadm` enum('n','y') NOT NULL default 'n' AFTER `disablelda`
ALTER TABLE `mail_user` ADD `disabledoveadm` enum('n','y') NOT NULL default 'n' AFTER `disablelda`;
......@@ -296,7 +296,7 @@ CREATE TABLE `client_template` (
`limit_shell_user` int(11) NOT NULL default '0',
`ssh_chroot` varchar(255) NOT NULL DEFAULT 'no',
`limit_webdav_user` int(11) NOT NULL default '0',
`limit_aps` int(11) NOT NULL DEFAULT '0',
`limit_aps` int(11) NOT NULL DEFAULT '-1',
`limit_dns_zone` int(11) NOT NULL default '-1',
`limit_dns_slave_zone` int(11) NOT NULL default '-1',
`limit_dns_record` int(11) NOT NULL default '-1',
......@@ -2169,6 +2169,6 @@ INSERT INTO `sys_user` (`userid`, `sys_userid`, `sys_groupid`, `sys_perm_user`,
-- Dumping data for table `sys_config`
--
INSERT INTO sys_config VALUES ('1','db','db_version','3.0.5');
INSERT INTO sys_config VALUES ('1','db','db_version','3.0.5.1');
SET FOREIGN_KEY_CHECKS = 1;
\ No newline at end of file
......@@ -50,3 +50,5 @@ CustomLog "| /usr/local/ispconfig/server/scripts/vlogger -s access.log -t \"%Y%m
Alias /awstats-icon "/usr/share/awstats/icon"
NameVirtualHost *:80
NameVirtualHost *:443
\ No newline at end of file
......@@ -28,18 +28,19 @@ NameVirtualHost *:{vhost_port}
IPCCommTimeout 7200
</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 mpm_itk_module>
DocumentRoot /usr/local/ispconfig/interface/web/
AssignUserId ispconfig ispconfig
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
......
<?php
/*
Copyright (c) 2007 - 2012, Till Brehm, projektfarm Gmbh
Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
......@@ -56,7 +56,7 @@ $revision = str_replace(array('Revision:','$',' '), '', $svn_revision);
//** Application
define('ISPC_APP_TITLE', 'ISPConfig');
define('ISPC_APP_VERSION', '3.0.5');
define('ISPC_APP_VERSION', '3.0.5.1');
define('DEVSYSTEM', 0);
......
......@@ -46,7 +46,7 @@ server {
fastcgi_pass unix:{fpm_socket};
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
#fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
......
......@@ -28,7 +28,7 @@ server {
fastcgi_pass unix:{fpm_socket};
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
#fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
......
......@@ -129,7 +129,7 @@ $do_backup = $inst->simple_query('Shall the script create a ISPConfig backup in
if($do_backup == 'yes') {
//* Create the backup directory
$backup_path = '/var/backup/ispconfig_'.date('Y-m-d_H-i');
$backup_path = '/var/backup/ispconfig_'.@date('Y-m-d_H-i');
$conf['backup_path'] = $backup_path;
exec("mkdir -p $backup_path");
exec("chown root:root $backup_path");
......
......@@ -728,6 +728,9 @@ class ApsGUIController extends ApsBase
// Using parse_url() to filter malformed URLs
$path = dirname(parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH)).'/'.
basename($this->interface_pkg_dir).'/'.$pkg['path'].'/'.basename((string)$icon);
// nginx: if $_SERVER['PHP_SELF'] is doubled, remove /sites/aps_packagedetails_show.php from beginning of path
$path = preg_replace('@^/sites/aps_packagedetails_show.php(.*)@', '$1', $path);
$pkg['Icon'] = $path;
}
else $pkg['Icon'] = '';
......@@ -741,6 +744,8 @@ class ApsGUIController extends ApsBase
// Using parse_url() to filter malformed URLs
$path = dirname(parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH)).'/'.
basename($this->interface_pkg_dir).'/'.$pkg['path'].'/'.basename((string)$screen['path']);
// nginx: if $_SERVER['PHP_SELF'] is doubled, remove /sites/aps_packagedetails_show.php from beginning of path
$path = preg_replace('@^/sites/aps_packagedetails_show.php(.*)@', '$1', $path);
$pkg['Screenshots'][] = array('ScreenPath' => $path,
'ScreenDescription' => htmlspecialchars(trim((string)$screen->description)));
......@@ -838,4 +843,4 @@ class ApsGUIController extends ApsBase
return $pkg;
}
}
?>
\ No newline at end of file
?>
......@@ -44,7 +44,7 @@ class db extends mysqli
private $errorNumber = 0; // last error number
public $errorMessage = ''; // last error message
private $errorLocation = '';// last error location
public $show_error_messages = true; // false in server, true in interface
public $show_error_messages = false; // false in server, true in interface
private $isConnected = false; // needed to know if we have a valid mysqli object from the constructor
// constructor
......@@ -60,7 +60,8 @@ class db extends mysqli
$this->dbClientFlags = $conf[$prefix.'db_client_flags'];
parent::__construct($conf[$prefix.'db_host'], $conf[$prefix.'db_user'],$conf[$prefix.'db_password'],$conf[$prefix.'db_database']);
$try = 0;
while(!is_null($this->connect_error) && $try < 5) {
//while(!is_null($this->connect_error) && $try < 5) {
while(mysqli_connect_error() && $try < 5) {
if($try > 0) sleep(1);
$try++;
......@@ -69,7 +70,9 @@ class db extends mysqli
parent::__construct($conf[$prefix.'db_host'], $conf[$prefix.'db_user'],$conf[$prefix.'db_password'],$conf[$prefix.'db_database']);
}
if(is_null($this->connect_error)) $this->isConnected = true;
//if(is_null($this->connect_error)) $this->isConnected = true;
//else return false;
if(!mysqli_connect_error()) $this->isConnected = true;
else return false;
$this->setCharacterEncoding();
......@@ -81,8 +84,9 @@ class db extends mysqli
// error handler
public function updateError($location) {
global $app;
global $app, $conf;
/*
if(!is_null($this->connect_error)) {
$this->errorNumber = $this->connect_errno;
$this->errorMessage = $this->connect_error;
......@@ -90,15 +94,24 @@ class db extends mysqli
$this->errorNumber = $this->errno;
$this->errorMessage = $this->error;
}
*/
if(mysqli_connect_error()) {
$this->errorNumber = mysqli_connect_errno();
$this->errorMessage = mysqli_connect_error();
} else {
$this->errorNumber = mysqli_errno($this);
$this->errorMessage = mysqli_error($this);
}
$this->errorLocation = $location;
if($this->errorNumber) {
$error_msg = $this->errorLocation .' '. $this->errorMessage;
// This right here will allow us to use the samefile for server & interface
if($this->show_error_messages) {
echo $error_msg;
// This right here will allow us to use the same file for server & interface
if($this->show_error_messages && $conf['demo_mode'] === false) {
echo $error_msg;
} else if(is_object($app) && method_exists($app, 'log')) {
$app->log($error_msg, LOGLEVEL_WARN);
$app->log($error_msg, LOGLEVEL_WARN);
}
}
}
......@@ -110,7 +123,8 @@ class db extends mysqli
}
public function query($queryString) {
if($this->isConnected == false) return false;
global $conf;
if($this->isConnected == false) return false;
$try = 0;
do {
$try++;
......@@ -131,7 +145,7 @@ class db extends mysqli
} while($ok == false);
$this->queryId = parent::query($queryString);
$this->updateError('DB::query('.$queryString.') -> mysqli_query');
if($this->errorNumber) debug_print_backtrace();
if($this->errorNumber && $conf['demo_mode'] === false) debug_print_backtrace();
if(!$this->queryId) {
return false;
}
......@@ -176,11 +190,11 @@ class db extends mysqli
// returns number of rows returned by the last select query
public function numRows() {
return $this->queryId->num_rows;
return intval($this->queryId->num_rows);
}
public function affectedRows() {
return $this->queryId->affected_rows;
return intval($this->queryId->affected_rows);
}
// returns mySQL insert id
......
......@@ -149,7 +149,7 @@ class listform_actions {
if($this->SQLExtWhere != '') {
$sql_where .= ' '.$this->SQLExtWhere.' and';
}
$sql_where = $app->listform->getSearchSQL($sql_where);
$app->tpl->setVar($app->listform->searchValues);
......@@ -171,8 +171,15 @@ class listform_actions {
$order_by_sql = str_replace('client_id','c.contact_name',$order_by_sql);
} elseif($order == 'parent_domain_id'){
$join .= ' LEFT JOIN web_domain as wd ON '.$app->listform->listDef['table'].'.parent_domain_id = wd.domain_id ';
$order_by_sql = str_replace('parent_domain_id','wd.domain',$order_by_sql);
$sql_where = str_replace('type',$app->listform->listDef['table'].'.type',$sql_where);
//$order_by_sql = str_replace(' domain', ' '.$app->listform->listDef['table'].'.domain',$order_by_sql);
//$order_by_sql = str_replace('parent_domain_id','wd.domain',$order_by_sql);
$order_by_sql = preg_replace('@( |,|^)(domain)( |,|$)@', '$1'.$app->listform->listDef['table'].'.$2$3', $order_by_sql);
$order_by_sql = preg_replace('@( |,|^)(parent_domain_id)( |,|$)@', '$1wd.domain$3', $order_by_sql);
//$sql_where = str_replace('type',$app->listform->listDef['table'].'.type',$sql_where);
//$sql_where = str_replace(' domain',' '.$app->listform->listDef['table'].'.domain',$sql_where);
$sql_where = preg_replace('@( |,|^)(type)( |,|$)@', '$1'.$app->listform->listDef['table'].'.$2$3', $sql_where);
$sql_where = preg_replace('@( |,|^)(domain)( |,|$)@', '$1'.$app->listform->listDef['table'].'.$2$3', $sql_where);
} elseif($order == 'sys_groupid'){
$join .= ' LEFT JOIN sys_group as sg ON '.$app->listform->listDef['table'].'.sys_groupid = sg.groupid ';
$order_by_sql = str_replace('sys_groupid','sg.name',$order_by_sql);
......
......@@ -467,7 +467,9 @@ class remoting_lib {
}
break;
case 'UNIQUE':
if($this->action == 'NEW') {
if($validator['allowempty'] != 'y') $validator['allowempty'] = 'n';
if($validator['allowempty'] == 'n' || ($validator['allowempty'] == 'y' && $field_value != '')){
if($this->action == 'NEW') {
$num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM ".$escape.$this->formDef['db_table'].$escape. " WHERE $field_name = '".$app->db->quote($field_value)."'");
if($num_rec["number"] > 0) {
$errmsg = $validator['errmsg'];
......@@ -477,7 +479,7 @@ class remoting_lib {
$this->errorMessage .= $errmsg."<br />\r\n";
}
}
} else {
} else {
$num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM ".$escape.$this->formDef['db_table'].$escape. " WHERE $field_name = '".$app->db->quote($field_value)."' AND ".$this->formDef['db_table_idx']." != ".$this->primary_id);
if($num_rec["number"] > 0) {
$errmsg = $validator['errmsg'];
......@@ -487,7 +489,8 @@ class remoting_lib {
$this->errorMessage .= $errmsg."<br />\r\n";
}
}
}
}
}
break;
case 'NOTEMPTY':
if(empty($field_value)) {
......@@ -571,31 +574,44 @@ class remoting_lib {
}
break;
case 'ISIP':
//* Check if its a IPv4 or IPv6 address
if(function_exists('filter_var')) {
if(!filter_var($field_value,FILTER_VALIDATE_IP)) {
$errmsg = $validator['errmsg'];
if(isset($this->wordbook[$errmsg])) {
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
} else {
$this->errorMessage .= $errmsg."<br />\r\n";
}
}
if($validator['allowempty'] != 'y') $validator['allowempty'] = 'n';
if($validator['allowempty'] == 'y' && $field_value == '') {
//* Do nothing
} else {
//* Check content with regex, if we use php < 5.2
$ip_ok = 0;
if(preg_match("/^(\:\:([a-f0-9]{1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3})?$/i", $field_value)){
$ip_ok = 1;
}
if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
$ip_ok = 1;
//* Check if its a IPv4 or IPv6 address
if(isset($validator['separator']) && $validator['separator'] != '') {
//* When the field may contain several IP addresses, split them by the char defined as separator
$field_value_array = explode($validator['separator'],$field_value);
} else {
$field_value_array[] = $field_value;
}
if($ip_ok == 0) {
$errmsg = $validator['errmsg'];
if(isset($this->wordbook[$errmsg])) {
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
foreach($field_value_array as $field_value) {
if(function_exists('filter_var')) {
if(!filter_var($field_value,FILTER_VALIDATE_IP)) {
$errmsg = $validator['errmsg'];
if(isset($this->wordbook[$errmsg])) {
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
} else {
$this->errorMessage .= $errmsg."<br />\r\n";
}
}
} else {
$this->errorMessage .= $errmsg."<br />\r\n";
//* Check content with regex, if we use php < 5.2
$ip_ok = 0;
if(preg_match("/^(\:\:([a-f0-9]{1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3})?$/i", $field_value)){
$ip_ok = 1;
}
if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
$ip_ok = 1;
}
if($ip_ok == 0) {
$errmsg = $validator['errmsg'];
if(isset($this->wordbook[$errmsg])) {
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
} else {
$this->errorMessage .= $errmsg."<br />\r\n";
}
}
}
}
}
......@@ -802,18 +818,24 @@ class remoting_lib {
$sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id;
return $app->db->queryOneRecord($sql);
} elseif (@is_array($primary_id)) {
$sql_where = '';
$sql_offset = 0;
$sql_limit = 0;
$sql_where = '';
foreach($primary_id as $key => $val) {
$key = $app->db->quote($key);
$val = $app->db->quote($val);
if(stristr($val,'%')) {
if($key == '#OFFSET#') $sql_offset = $app->functions->intval($val);
elseif($key == '#LIMIT#') $sql_limit = $app->functions->intval($val);
elseif(stristr($val,'%')) {
$sql_where .= "$key like '$val' AND ";