mcramer
2012-09-13 65ea2ecf27418feaf7681a02d74168d0d82626fb
Fixed/Implemented: replaced intval() by $app->functions->intval() in all interface functions due to big number problem in intval()

110 files modified
1108 ■■■■ changed files
interface/lib/app.inc.php 5 ●●●●● patch | view | raw | blame | history
interface/lib/classes/aps_guicontroller.inc.php 16 ●●●●● patch | view | raw | blame | history
interface/lib/classes/auth.inc.php 10 ●●●● patch | view | raw | blame | history
interface/lib/classes/client_templates.inc.php 8 ●●●● patch | view | raw | blame | history
interface/lib/classes/form.inc.php 5 ●●●●● patch | view | raw | blame | history
interface/lib/classes/functions.inc.php 10 ●●●●● patch | view | raw | blame | history
interface/lib/classes/getconf.inc.php 2 ●●● patch | view | raw | blame | history
interface/lib/classes/listform.inc.php 16 ●●●● patch | view | raw | blame | history
interface/lib/classes/plugin_backuplist.inc.php 2 ●●● patch | view | raw | blame | history
interface/lib/classes/remoting.inc.php 58 ●●●● patch | view | raw | blame | history
interface/lib/classes/remoting_lib.inc.php 161 ●●●●● patch | view | raw | blame | history
interface/lib/classes/searchform.inc.php 7 ●●●●● patch | view | raw | blame | history
interface/lib/classes/sites_database_plugin.inc.php 40 ●●●● patch | view | raw | blame | history
interface/lib/classes/tform.inc.php 27 ●●●● patch | view | raw | blame | history
interface/lib/classes/tform_actions.inc.php 4 ●●●● patch | view | raw | blame | history
interface/lib/classes/tools_sites.inc.php 4 ●●●● patch | view | raw | blame | history
interface/lib/classes/validate_dns.inc.php 4 ●●●● patch | view | raw | blame | history
interface/lib/classes/validate_domain.inc.php 6 ●●●● patch | view | raw | blame | history
interface/lib/plugins/mail_user_filter_plugin.inc.php 4 ●●●● patch | view | raw | blame | history
interface/lib/plugins/sites_web_database_user_plugin.inc.php 6 ●●●● patch | view | raw | blame | history
interface/lib/plugins/sites_web_domain_plugin.inc.php 14 ●●●● patch | view | raw | blame | history
interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php 6 ●●●● patch | view | raw | blame | history
interface/lib/plugins/vm_openvz_plugin.inc.php 8 ●●●● patch | view | raw | blame | history
interface/web/admin/login_as.php 4 ●●●● patch | view | raw | blame | history
interface/web/admin/software_package_del.php 2 ●●● patch | view | raw | blame | history
interface/web/admin/software_package_install.php 2 ●●● patch | view | raw | blame | history
interface/web/admin/software_package_list.php 14 ●●●● patch | view | raw | blame | history
interface/web/admin/software_update_list.php 16 ●●●● patch | view | raw | blame | history
interface/web/client/client_del.php 14 ●●●● patch | view | raw | blame | history
interface/web/client/client_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/client/client_message.php 12 ●●●● patch | view | raw | blame | history
interface/web/client/domain_edit.php 2 ●●● patch | view | raw | blame | history
interface/web/client/reseller_del.php 6 ●●●● patch | view | raw | blame | history
interface/web/client/reseller_edit.php 8 ●●●● patch | view | raw | blame | history
interface/web/dns/ajax_get_json.php 4 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_a_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_aaaa_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_alias_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_cname_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_hinfo_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_import.php 88 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_mx_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_ns_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_ptr_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_rp_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_rr_del.php 4 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_slave_del.php 2 ●●● patch | view | raw | blame | history
interface/web/dns/dns_slave_edit.php 12 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_soa_del.php 2 ●●● patch | view | raw | blame | history
interface/web/dns/dns_soa_edit.php 12 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_srv_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_txt_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_wizard.php 10 ●●●● patch | view | raw | blame | history
interface/web/dns/form/dns_a.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/dns/form/dns_aaaa.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/dns/form/dns_alias.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/dns/form/dns_cname.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/dns/form/dns_hinfo.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/dns/form/dns_mx.tform.php 4 ●●● patch | view | raw | blame | history
interface/web/dns/form/dns_ns.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/dns/form/dns_ptr.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/dns/form/dns_rp.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/dns/form/dns_soa.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/dns/form/dns_srv.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/dns/form/dns_txt.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/mail/form/mail_user.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/mail/form/mail_user_filter.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_domain_edit.php 18 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_mailinglist_edit.php 8 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_spamfilter_edit.php 2 ●●● patch | view | raw | blame | history
interface/web/mail/mail_user_edit.php 8 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_user_filter_edit.php 6 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_user_stats.php 8 ●●●● patch | view | raw | blame | history
interface/web/mail/mailinglist.php 4 ●●●● patch | view | raw | blame | history
interface/web/mail/spamfilter_blacklist_edit.php 2 ●●● patch | view | raw | blame | history
interface/web/mail/spamfilter_whitelist_edit.php 2 ●●● patch | view | raw | blame | history
interface/web/mail/webmailer.php 4 ●●●● patch | view | raw | blame | history
interface/web/mailuser/form/mail_user_filter.tform.php 4 ●●● patch | view | raw | blame | history
interface/web/mailuser/mail_user_filter_edit.php 2 ●●● patch | view | raw | blame | history
interface/web/mailuser/mail_user_spamfilter_edit.php 2 ●●● patch | view | raw | blame | history
interface/web/monitor/log_del.php 2 ●●● patch | view | raw | blame | history
interface/web/monitor/show_log.php 2 ●●● patch | view | raw | blame | history
interface/web/monitor/show_sys_state.php 2 ●●● patch | view | raw | blame | history
interface/web/remote/monitor.php 2 ●●● patch | view | raw | blame | history
interface/web/sites/ajax_get_ip.php 4 ●●●● patch | view | raw | blame | history
interface/web/sites/ajax_get_json.php 8 ●●●● patch | view | raw | blame | history
interface/web/sites/aps_do_operation.php 6 ●●●● patch | view | raw | blame | history
interface/web/sites/cron_edit.php 6 ●●●● patch | view | raw | blame | history
interface/web/sites/database_edit.php 6 ●●●● patch | view | raw | blame | history
interface/web/sites/database_phpmyadmin.php 4 ●●●● patch | view | raw | blame | history
interface/web/sites/database_user_del.php 4 ●●●● patch | view | raw | blame | history
interface/web/sites/database_user_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/sites/ftp_user_edit.php 6 ●●●● patch | view | raw | blame | history
interface/web/sites/shell_user_edit.php 4 ●●●● patch | view | raw | blame | history
interface/web/sites/web_aliasdomain_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/sites/web_domain_del.php 16 ●●●● patch | view | raw | blame | history
interface/web/sites/web_domain_edit.php 58 ●●●● patch | view | raw | blame | history
interface/web/sites/web_folder_del.php 2 ●●● patch | view | raw | blame | history
interface/web/sites/web_folder_edit.php 2 ●●● patch | view | raw | blame | history
interface/web/sites/web_folder_user_edit.php 2 ●●● patch | view | raw | blame | history
interface/web/sites/web_sites_stats.php 8 ●●●● patch | view | raw | blame | history
interface/web/sites/web_subdomain_edit.php 10 ●●●● patch | view | raw | blame | history
interface/web/sites/web_vhost_subdomain_del.php 2 ●●● patch | view | raw | blame | history
interface/web/sites/web_vhost_subdomain_edit.php 40 ●●●● patch | view | raw | blame | history
interface/web/sites/webdav_user_edit.php 6 ●●●● patch | view | raw | blame | history
interface/web/tools/import_ispconfig.php 6 ●●●● patch | view | raw | blame | history
interface/web/tools/import_plesk.php 2 ●●● patch | view | raw | blame | history
interface/web/vm/ajax_get_ip.php 2 ●●● patch | view | raw | blame | history
interface/web/vm/openvz_action.php 2 ●●● patch | view | raw | blame | history
interface/web/vm/openvz_vm_edit.php 4 ●●●● patch | view | raw | blame | history
interface/lib/app.inc.php
@@ -81,7 +81,8 @@
            if(empty($_SESSION['s']['language'])) $_SESSION['s']['language'] = $conf['language'];
        }
        $this->uses('auth,plugin,functions');
        $this->uses('functions'); // we need this before all others!
        $this->uses('auth,plugin');
    }
    
    public function __destruct() {
@@ -119,7 +120,7 @@
        if($priority >= $this->_conf['log_priority']) {
            // $server_id = $conf["server_id"];
            $server_id = 0;
            $priority = intval($priority);
            $priority = $this->functions->intval($priority);
            $tstamp = time();
            $msg = $this->db->quote('[INTERFACE]: '.$msg);
            $this->db->query("INSERT INTO sys_log (server_id,datalog_id,loglevel,tstamp,message) VALUES ($server_id,0,$priority,$tstamp,'$msg')");
interface/lib/classes/aps_guicontroller.inc.php
@@ -210,7 +210,7 @@
        
        //* Get server config of the web server
        $this->app->uses("getconf");
        $web_config = $this->app->getconf->get_server_config(intval($websrv["server_id"]),'web');
        $web_config = $this->app->getconf->get_server_config($app->functions->intval($websrv["server_id"]),'web');
            
        //* Set mysql mode to php-fcgi and enable suexec in website on apache servers
        if($web_config['server_type'] == 'apache') {
@@ -239,7 +239,7 @@
            $client = $app->db->queryOneRecord("SELECT default_dbserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ".$websrv['sys_groupid']);
            if(is_array($client) && $client['default_dbserver'] > 0 && $client['default_dbserver'] != $websrv['server_id']) {
                $mysql_db_server_id =  $client['default_dbserver'];
                $dbserver_config = $web_config = $app->getconf->get_server_config(intval($mysql_db_server_id),'server');
                $dbserver_config = $web_config = $app->getconf->get_server_config($app->functions->intval($mysql_db_server_id),'server');
                $mysql_db_host = $dbserver_config['ip_address'];
                $mysql_db_remote_access = 'y';
                $mysql_db_remote_ips = $dbserver_config['ip_address'];
@@ -322,7 +322,7 @@
        if($tmp['database_id'] > 0) $this->db->datalogDelete('web_database', 'database_id', $tmp['database_id']);
        
        $database_user = $tmp['database_user_id'];
        $tmp = $this->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `database_user_id` = '" . intval($database_user) . "' OR `database_ro_user_id` = '" . intval($database_user) . "'");
        $tmp = $this->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `database_user_id` = '" . $app->functions->intval($database_user) . "' OR `database_ro_user_id` = '" . $app->functions->intval($database_user) . "'");
        if($tmp['cnt'] < 1) $this->db->datalogDelete('web_database_user', 'database_user_id', $database_user);
        
        $this->db->datalogUpdate('aps_instances', "instance_status = ".INSTANCE_REMOVE, 'id', $instanceid);
@@ -449,6 +449,8 @@
     */
    public function validateInstallerInput($postinput, $pkg_details, $domains, $settings = array())
    {
        global $app;
        $ret = array();
        $input = array(); 
        $error = array();
@@ -566,12 +568,12 @@
            {
                if($setting['SettingType'] == 'string' || $setting['SettingType'] == 'password')
                {
                    if(intval($setting['SettingMinLength']) != 0
                    && strlen($postinput[$setting_id]) < intval($setting['SettingMinLength']))
                    if($app->functions->intval($setting['SettingMinLength'], true) != 0
                    && strlen($postinput[$setting_id]) < $app->functions->intval($setting['SettingMinLength'], true))
                        $temp_errstr = sprintf($this->app->lng('error_short_value_for'), $setting['setting_name']);
                        
                    if(intval($setting['SettingMaxLength']) != 0
                    && strlen($postinput[$setting_id]) > intval($setting['SettingMaxLength']))
                    if($app->functions->intval($setting['SettingMaxLength'], true) != 0
                    && strlen($postinput[$setting_id]) > $app->functions->intval($setting['SettingMaxLength'], true))
                        $temp_errstr = sprintf($this->app->lng('error_long_value_for'), $setting['setting_name']);
                    if(isset($setting['SettingRegex'])
interface/lib/classes/auth.inc.php
@@ -47,7 +47,7 @@
    public function has_clients($userid) {
        global $app, $conf;
        
        $userid = intval($userid);
        $userid = $app->functions->intval($userid);
        $client = $app->db->queryOneRecord("SELECT client.limit_client FROM sys_user, client WHERE sys_user.userid = $userid AND sys_user.client_id = client.client_id");
        if($client['limit_client'] > 0) {
            return true;
@@ -60,8 +60,8 @@
    public function add_group_to_user($userid,$groupid) {
        global $app;
        
        $userid = intval($userid);
        $groupid = intval($groupid);
        $userid = $app->functions->intval($userid);
        $groupid = $app->functions->intval($groupid);
        
        if($userid > 0 && $groupid > 0) {
            $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid");
@@ -98,8 +98,8 @@
    public function remove_group_from_user($userid,$groupid) {
        global $app;
        
        $userid = intval($userid);
        $groupid = intval($groupid);
        $userid = $app->functions->intval($userid);
        $groupid = $app->functions->intval($groupid);
        
        if($userid > 0 && $groupid > 0) {
            $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid");
interface/lib/classes/client_templates.inc.php
@@ -15,7 +15,7 @@
        /*
         * Get the master-template for the client
         */
        $sql = "SELECT template_master, template_additional FROM client WHERE client_id = " . intval($clientId);
        $sql = "SELECT template_master, template_additional FROM client WHERE client_id = " . $app->functions->intval($clientId);
        $record = $app->db->queryOneRecord($sql);
        $masterTemplateId = $record['template_master'];
        $additionalTemplateStr = $record['template_additional'];
@@ -24,7 +24,7 @@
         * if the master-Template is custom there is NO changing
         */
        if ($masterTemplateId > 0){
            $sql = "SELECT * FROM client_template WHERE template_id = " . intval($masterTemplateId);
            $sql = "SELECT * FROM client_template WHERE template_id = " . $app->functions->intval($masterTemplateId);
            $limits = $app->db->queryOneRecord($sql);
        } else {
            // if there is no master template it makes NO SENSE adding sub templates.
@@ -40,7 +40,7 @@
        $addTpl = explode('/', $additionalTemplateStr);
        foreach ($addTpl as $item){
            if (trim($item) != ''){
                $sql = "SELECT * FROM client_template WHERE template_id = " . intval($item);
                $sql = "SELECT * FROM client_template WHERE template_id = " . $app->functions->intval($item);
                $addLimits = $app->db->queryOneRecord($sql);
                /* maybe the template is deleted in the meantime */
                if (is_array($addLimits)){
@@ -115,7 +115,7 @@
            }
        }
        if($update != '') {
            $sql = 'UPDATE client SET ' . $update . " WHERE client_id = " . intval($clientId);
            $sql = 'UPDATE client SET ' . $update . " WHERE client_id = " . $app->functions->intval($clientId);
            $app->db->query($sql);
        }
    }
interface/lib/classes/form.inc.php
@@ -140,6 +140,7 @@
    * @return record
    */
    function decode($record) {
        global $app;
        if(is_array($record)) {
            foreach($record as $key => $val) {
                switch ($this->tableDef[$key]['datatype']) {
@@ -154,7 +155,7 @@
                break;
                
                case 'INTEGER':
                    $new_record[$key] = intval($val);
                    $new_record[$key] = $app->functions->intval($val);
                break;
                
                case 'DOUBLE':
@@ -306,7 +307,7 @@
                    }
                break;
                case 'INTEGER':
                    $new_record[$key] = intval($val);
                    $new_record[$key] = $app->functions->intval($val);
                break;
                case 'DOUBLE':
                    $new_record[$key] = $app->db->quote($val);
interface/lib/classes/functions.inc.php
@@ -299,7 +299,15 @@
        return $result_array;
    }
    public function intval($string, $force_numeric = false) {
        if(intval($string) == 2147483647) {
            if($force_numeric == true) return floatval($string);
            elseif(preg_match('/^([-]?)[0]*([1-9][0-9]*)([^0-9].*)*$/', $string, $match)) return $match[1].$match[2];
            else return 0;
        } else {
            return intval($string);
        }
    }
        
}
interface/lib/classes/getconf.inc.php
@@ -37,7 +37,7 @@
        if(!isset($this->config[$server_id])) {
            $app->uses('ini_parser');
            $server_id = intval($server_id);
            $server_id = $app->functions->intval($server_id);
            $server = $app->db->queryOneRecord('SELECT config FROM server WHERE server_id = '.$server_id);
            $this->config[$server_id] = $app->ini_parser->parse_ini_string(stripslashes($server['config']));
        }
interface/lib/classes/listform.inc.php
@@ -194,14 +194,14 @@
        global $app, $conf;
        
        //* Add Global Limit from selectbox
        if(!empty($_POST['search_limit']) AND intval($_POST['search_limit'])){
            $_SESSION['search']['limit'] = intval($_POST['search_limit']);
        if(!empty($_POST['search_limit']) AND $app->functions->intval($_POST['search_limit'])){
            $_SESSION['search']['limit'] = $app->functions->intval($_POST['search_limit']);
        }
        //* Get Config variables
        $list_name          = $this->listDef['name'];
        $search_prefix      = $this->listDef['search_prefix'];
        $records_per_page   = (empty($_SESSION['search']['limit']) ? intval($this->listDef['records_per_page']) : intval($_SESSION['search']['limit'])) ;
        $records_per_page   = (empty($_SESSION['search']['limit']) ? $app->functions->intval($this->listDef['records_per_page']) : $app->functions->intval($_SESSION['search']['limit'])) ;
        $table              = $this->listDef['table'];
        //* set PAGE to zero, if in session not set
@@ -210,14 +210,14 @@
        }
        //* set PAGE to worth request variable "PAGE" - ? setze page auf wert der request variablen "page"
        if(isset($_REQUEST["page"])) $_SESSION["search"][$list_name]["page"] = intval($_REQUEST["page"]);
        if(isset($_REQUEST["page"])) $_SESSION["search"][$list_name]["page"] = $app->functions->intval($_REQUEST["page"]);
        //* PAGE to 0 set, if look for themselves ?  page auf 0 setzen, wenn suche sich ge�ndert hat.
        if($this->searchChanged == 1) $_SESSION['search'][$list_name]['page'] = 0;
        $sql_von = intval($_SESSION['search'][$list_name]['page'] * $records_per_page);
        $sql_von = $app->functions->intval($_SESSION['search'][$list_name]['page'] * $records_per_page);
        $record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM $table WHERE $sql_where");
        $pages = intval(($record_count['anzahl'] - 1) / $records_per_page);
        $pages = $app->functions->intval(($record_count['anzahl'] - 1) / $records_per_page);
        $vars['list_file']      = $_SESSION['s']['module']['name'].'/'.$this->listDef['file'];
@@ -331,7 +331,7 @@
                        break;
                    case 'INTEGER':
                        $record[$key] = intval($record[$key]);
                        $record[$key] = $app->functions->intval($record[$key]);
                        break;
                    case 'DOUBLE':
@@ -387,7 +387,7 @@
                        break;
                    case 'INTEGER':
                        $record[$key] = intval($record[$key]);
                        $record[$key] = $app->functions->intval($record[$key]);
                        break;
                    case 'DOUBLE':
interface/lib/classes/plugin_backuplist.inc.php
@@ -53,7 +53,7 @@
                $error = '';
                
                if(isset($_GET['backup_action'])) {
                    $backup_id = intval($_GET['backup_id']);
                    $backup_id = $app->functions->intval($_GET['backup_id']);
                    
                    if($_GET['backup_action'] == 'download' && $backup_id > 0) {
                        $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_download' AND action_param = '$backup_id'";
interface/lib/classes/remoting.inc.php
@@ -1023,11 +1023,11 @@
            return false;
        }
        
        $sys_userid = intval($sys_userid);
        $sys_userid = $app->functions->intval($sys_userid);
        
        $rec = $app->db->queryOneRecord("SELECT client_id FROM sys_user WHERE userid = ".$sys_userid);
        if(isset($rec['client_id'])) {
            return intval($rec['client_id']);
            return $app->functions->intval($rec['client_id']);
        } else {
            $this->server->fault('no_client_found', 'There is no sysuser account for this client ID.');
            return false;
@@ -1043,11 +1043,11 @@
            return false;
        }
        
        $client_id = intval($client_id);
        $client_id = $app->functions->intval($client_id);
        
        $rec = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client_id);
        if(isset($rec['groupid'])) {
            return intval($rec['groupid']);
            return $app->functions->intval($rec['groupid']);
        } else {
            $this->server->fault('no_group_found', 'There is no group for this client ID.');
            return false;
@@ -1112,12 +1112,12 @@
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        $client_id = intval($client_id);
        $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 = intval($client_group['groupid']);
        $client_group_id = $app->functions->intval($client_group['groupid']);
        
        $table_list = array();
        if($client_group_id > 1) {
@@ -1133,7 +1133,7 @@
    if($client_id > 0) {            
            // remove the group of the client from the resellers group
            $parent_client_id = intval($this->dataRecord['parent_client_id']);
            $parent_client_id = $app->functions->intval($this->dataRecord['parent_client_id']);
            $parent_user = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE client_id = $parent_client_id");
            $client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id");
            $app->auth->remove_group_from_user($parent_user['userid'],$client_group['groupid']);
@@ -1147,7 +1147,7 @@
            // Delete all records (sub-clients, mail, web, etc....)  of this client.
            $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 = intval($client_group['groupid']);
            $client_group_id = $app->functions->intval($client_group['groupid']);
            if($client_group_id > 1) {
                foreach($tables_array as $table) {
                    if($table != '') {
@@ -1507,7 +1507,7 @@
        }
        
        if(!isset($params['client_group_id']) or (isset($params['client_group_id']) && empty($params['client_group_id']))) {
            $rec = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".intval($client_id));
            $rec = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$app->functions->intval($client_id));
            $params['client_group_id'] = $rec['groupid'];
        }
        
@@ -1769,7 +1769,7 @@
        }
        
        // Delete all users that belong to this folder. - taken from web_folder_delete.php
        $records = $app->db->queryAllRecords("SELECT web_folder_user_id FROM web_folder_user WHERE web_folder_id = '".intval($primary_id)."'");
        $records = $app->db->queryAllRecords("SELECT web_folder_user_id FROM web_folder_user WHERE web_folder_id = '".$app->functions->intval($primary_id)."'");
        foreach($records as $rec) {
            $this->deleteQuery('../sites/form/web_folder_user.tform.php',$rec['web_folder_user_id']);
            //$app->db->datalogDelete('web_folder_user','web_folder_user_id',$rec['web_folder_user_id']);
@@ -1874,7 +1874,7 @@
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        $group_id = intval($group_id);
        $group_id = $app->functions->intval($group_id);
        $sql = "SELECT domain_id, domain FROM domain WHERE sys_groupid  = $group_id ";
        $all = $app->db->queryAllRecords($sql);
        return $all;
@@ -1892,7 +1892,7 @@
            return false;
        }
        $client = $app->db->queryOneRecord("SELECT default_dnsserver FROM client WHERE client_id = ".intval($client_id));
        $client = $app->db->queryOneRecord("SELECT default_dnsserver FROM client WHERE client_id = ".$app->functions->intval($client_id));
        $server_id = $client["default_dnsserver"];
        $template_record = $app->db->queryOneRecord("SELECT * FROM dns_template WHERE template_id = '$template_id'");
        $fields = explode(',',$template_record['fields']);
@@ -1959,7 +1959,7 @@
        
        if($error == '') {
            // Insert the soa record
            $tmp = $app->db->queryOneRecord("SELECT userid,default_group FROM sys_user WHERE client_id = ".intval($client_id));
            $tmp = $app->db->queryOneRecord("SELECT userid,default_group FROM sys_user WHERE client_id = ".$app->functions->intval($client_id));
            $sys_userid = $tmp['userid'];
            $sys_groupid = $tmp['default_group'];
            unset($tmp);
@@ -2024,7 +2024,7 @@
        $rec = $app->db->queryOneRecord("SELECT id FROM dns_soa WHERE origin like '".$origin.'%');
        if(isset($rec['id'])) {
            return intval($rec['id']);
            return $app->functions->intval($rec['id']);
        } else {
            $this->server->fault('no_domain_found', 'There is no domain ID with informed domain name.');
            return false;
@@ -2909,11 +2909,11 @@
              $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
              return false;
        }
        $sys_userid  = intval($sys_userid);
        $sys_userid  = $app->functions->intval($sys_userid);
        $sys_groupid = explode(',', $sys_groupid);
        $new_group = array();
        foreach($sys_groupid as $group_id) {
            $new_group[] = intval( $group_id);
            $new_group[] = $app->functions->intval( $group_id);
        }
        $group_list = implode(',', $new_group);
        $sql ="SELECT domain, domain_id, document_root, active FROM web_domain WHERE ( (sys_userid = $sys_userid  AND sys_perm_user LIKE '%r%') OR (sys_groupid IN ($group_list) AND sys_perm_group LIKE '%r%') OR  sys_perm_other LIKE '%r%') AND type = 'vhost'";
@@ -2947,7 +2947,7 @@
            } else {
                $status = 'n';
            }
            $sql = "UPDATE web_domain SET active = '$status' WHERE domain_id = ".intval($primary_id);
            $sql = "UPDATE web_domain SET active = '$status' WHERE domain_id = ".$app->functions->intval($primary_id);
            $app->db->query($sql);
            $result = $app->db->affectedRows();    
             return $result;
@@ -3017,7 +3017,7 @@
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        $client_id = intval($client_id);
        $client_id = $app->functions->intval($client_id);
        $client = $app->db->queryOneRecord("SELECT client_id FROM client WHERE client_id = ".$client_id);
        if($client['client_id'] > 0) {
            $new_password = $app->db->quote($new_password);
@@ -3080,7 +3080,7 @@
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        $client_id = intval($client_id);
        $client_id = $app->functions->intval($client_id);
        $sql = "SELECT d.database_id, d.database_name, d.database_user_id, d.database_ro_user_id, du.database_user, du.database_password FROM web_database d LEFT JOIN web_database_user du ON (du.database_user_id = d.database_user_id) INNER JOIN sys_user s on(d.sys_groupid = s.default_group) WHERE client_id = $client_id";
        $all = $app->db->queryAllRecords($sql);
        return $all;
@@ -3113,8 +3113,8 @@
            return false;
        }        
        if (!empty($client_id) && !empty($server_id)) {
            $server_id      = intval($server_id);
            $client_id      = intval($client_id);
            $server_id      = $app->functions->intval($server_id);
            $client_id      = $app->functions->intval($client_id);
            $sql            = "SELECT id, origin FROM dns_soa d INNER JOIN sys_user s on(d.sys_groupid = s.default_group) WHERE client_id = $client_id AND server_id = $server_id";
            $result         = $app->db->queryAllRecords($sql);
            return          $result;
@@ -3134,7 +3134,7 @@
             $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        $sql    = "SELECT * FROM dns_rr WHERE zone = ".intval($zone_id);;
        $sql    = "SELECT * FROM dns_rr WHERE zone = ".$app->functions->intval($zone_id);;
        $result = $app->db->queryAllRecords($sql);
        return $result;
   }
@@ -3159,7 +3159,7 @@
            } else {
                $status = 'N';
            }
            $sql = "UPDATE dns_soa SET active = '$status' WHERE id = ".intval($primary_id);
            $sql = "UPDATE dns_soa SET active = '$status' WHERE id = ".$app->functions->intval($primary_id);
            $app->db->query($sql);
            $result = $app->db->affectedRows();
            return $result;
@@ -3181,7 +3181,7 @@
            } else {
                $status = 'n';
            }
            $sql = "UPDATE mail_domain SET active = '$status' WHERE domain_id = ".intval($primary_id);
            $sql = "UPDATE mail_domain SET active = '$status' WHERE domain_id = ".$app->functions->intval($primary_id);
            $app->db->query($sql);
            $result = $app->db->affectedRows();
            return $result;
@@ -3308,7 +3308,7 @@
            $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
        }
        $server_id = intval($server_id);
        $server_id = $app->functions->intval($server_id);
        
        if($server_id > 0) {
            $tmp = $app->db->queryOneRecord("SELECT ip_address_id, server_id, ip_address FROM openvz_ip WHERE reserved = 'n' AND vm_id = 0 AND server_id = $server_id LIMIT 0,1");
@@ -3380,9 +3380,9 @@
        }
        
        if (!empty($client_id)) {
            $client_id      = intval($client_id);
            $client_id      = $app->functions->intval($client_id);
            $tmp             = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id");
            $sql            = "SELECT * FROM openvz_vm WHERE sys_groupid = ".intval($tmp['groupid']);
            $sql            = "SELECT * FROM openvz_vm WHERE sys_groupid = ".$app->functions->intval($tmp['groupid']);
            $result         = $app->db->queryAllRecords($sql);
            return          $result;
        }
@@ -3410,8 +3410,8 @@
        }
        
        
        $template_id = intval($template_id);
        $ostemplate_id = intval($ostemplate_id);
        $template_id = $app->functions->intval($template_id);
        $ostemplate_id = $app->functions->intval($ostemplate_id);
        
        //* Verify parameters
        if($template_id == 0) {
interface/lib/classes/remoting_lib.inc.php
@@ -37,39 +37,37 @@
/**
* Formularbehandlung
*
* Funktionen zur Umwandlung von Formulardaten
* sowie zum vorbereiten von HTML und SQL
* Ausgaben
* Functions to validate, display and save form values
*
*        Tabellendefinition
*        Database table field definitions
*
*        Datentypen:
*        - INTEGER (Wandelt Ausdr�cke in Int um)
*        Datatypes:
*        - INTEGER (Converts data to int automatically)
*        - DOUBLE
*        - CURRENCY (Formatiert Zahlen nach W�hrungsnotation)
*        - VARCHAR (kein weiterer Format Check)
*        - DATE (Datumsformat, Timestamp Umwandlung)
*        - CURRENCY (Formats digits in currency notation)
*        - VARCHAR (No format check)
*        - DATE (Date format, converts from and to UNIX timestamps automatically)
*
*        Formtype:
*        - TEXT (normales Textfeld)
*        - PASSWORD (Feldinhalt wird nicht angezeigt)
*        - SELECT (Gibt Werte als option Feld aus)
*        - MULTIPLE (Select-Feld mit nehreren Werten)
*        - TEXT (Normal text field)
*        - PASSWORD (password field, the content will not be displayed again to the user)
*        - SELECT (Option fiield)
*        - MULTIPLE (Allows selection of multiple values)
*
*        VALUE:
*        - Wert oder Array
*        - Value or array
*
*        SEPARATOR
*        - Trennzeichen f�r multiple Felder
*        - separator char used for fileds with multiple values
*
*        Hinweis:
*        Das ID-Feld ist nicht bei den Table Values einzuf�gen.
*        Hint: The auto increment (ID) filed of the table has not be be definied separately.
*
*/
class remoting_lib {
    
        /**
        * Definition of the database atble (array)
        * Definition of the database table (array)
        * @var tableDef
        */
        private $tableDef;
@@ -141,7 +139,7 @@
        function loadUserProfile($client_id = 0) {
            global $app,$conf;
            $client_id = intval($client_id);
            $client_id = $app->functions->intval($client_id);
            
            if($client_id == 0) {
                $this->sys_username         = 'admin';
@@ -176,7 +174,8 @@
        /**
        * Converts data in human readable form
        * Converts the data in the array to human readable format
        * Datatype conversion e.g. to show the data in lists
        *
        * @param record
        * @return record
@@ -208,13 +207,7 @@
                                break;
                                case 'INTEGER':
                                        //* We use + 0 to force the string to be a number as
                                        //* intval return value is too limited on 32bit systems
                                        if(intval($record[$key]) == 2147483647) {
                                            $new_record[$key] = $record[$key] + 0;
                                        } else {
                                            $new_record[$key] = intval($record[$key]);
                                        }
                                        $new_record[$key] = $app->functions->intval($record[$key]);
                                break;
                                case 'DOUBLE':
@@ -222,7 +215,7 @@
                                break;
                                case 'CURRENCY':
                                        $new_record[$key] = number_format($record[$key], 2, ',', '');
                                        $new_record[$key] = $app->functions->currency_format($record[$key]);
                                break;
                                default:
@@ -263,7 +256,7 @@
                        unset($tmp_recordid);
                        
                        $querystring = str_replace("{AUTHSQL}",$this->getAuthSQL('r'),$querystring);
                        // Getting the records
                        $tmp_records = $app->db->queryAllRecords($querystring);
                        if($app->db->errorMessage != '') die($app->db->errorMessage);
@@ -285,7 +278,7 @@
                                $app->uses($datasource_class);
                                $values = $app->$datasource_class->$datasource_function($field, $record);
                        } else {
                                $this->errorMessage .= "Custom datasource class or function is empty<br>\r\n";
                                $this->errorMessage .= "Custom datasource class or function is empty<br />\r\n";
                        }
                }
@@ -294,29 +287,39 @@
        }
        /**
        * Converts the data in a format to store it in the database table
        /**
        * Rewrite the record data to be stored in the database
        * and check values with regular expressions.
        *
        * @param record = Datensatz als Array
        * @return record
        */
        function encode($record) {
        function encode($record,$dbencode = true) {
        global $app;
                if(is_array($record)) {
                        foreach($this->formDef['fields'] as $key => $field) {
                                if(isset($field['validators']) && is_array($field['validators'])) $this->validateField($key, (isset($record[$key]))?$record[$key]:'', $field['validators']);
                                //* Apply filter to record value
                                if(isset($field['filters']) && is_array($field['filters'])) {
                                    $record[$key] = $this->filterField($key, (isset($record[$key]))?$record[$key]:'', $field['filters'], 'SAVE');
                                }
                                //* Validate record value
                                if(isset($field['validators']) && is_array($field['validators'])) {
                                    $this->validateField($key, (isset($record[$key]))?$record[$key]:'', $field['validators']);
                                }
                                switch ($field['datatype']) {
                                case 'VARCHAR':
                                        if(!@is_array($record[$key])) {
                                                $new_record[$key] = (isset($record[$key]))?$app->db->quote($record[$key]):'';
                                                $new_record[$key] = (isset($record[$key]))?$record[$key]:'';
                                        } else {
                                                $new_record[$key] = implode($field['separator'],$record[$key]);
                                        }
                                break;
                                case 'TEXT':
                                        if(!is_array($record[$key])) {
                                                $new_record[$key] = $app->db->quote($record[$key]);
                                                $new_record[$key] = $record[$key];
                                        } else {
                                                $new_record[$key] = implode($field['separator'],$record[$key]);
                                        }
@@ -348,12 +351,12 @@
                                        }
                                break;
                                case 'INTEGER':
                                        $new_record[$key] = (isset($record[$key]))?intval($record[$key]):0;
                                        $new_record[$key] = (isset($record[$key]))?$app->functions->intval($record[$key]):0;
                                        //if($new_record[$key] != $record[$key]) $new_record[$key] = $field['default'];
                                        //if($key == 'refresh') die($record[$key]);
                                break;
                                case 'DOUBLE':
                                        $new_record[$key] = $app->db->quote($record[$key]);
                                        $new_record[$key] = $record[$key];
                                break;
                                case 'CURRENCY':
                                        $new_record[$key] = str_replace(",",".",$record[$key]);
@@ -381,11 +384,61 @@
                                                $this->errorMessage .= $errmsg."\r\n";
                                        }
                                }
                                //* Add slashes to all records, when we encode data which shall be inserted into mysql.
                                if($dbencode == true) $new_record[$key] = $app->db->quote($new_record[$key]);
                        }
                }
                return $new_record;
        }
        /**
        * process the filters for a given field.
        *
        * @param field_name = Name of the field
        * @param field_value = value of the field
        * @param filters = Array of filters
        * @param filter_event = 'SAVE'or 'SHOW'
        * @return record
        */
        function filterField($field_name, $field_value, $filters, $filter_event) {
            global $app;
            $returnval = $field_value;
            //* Loop trough all filters
            foreach($filters as $filter) {
                if($filter['event'] == $filter_event) {
                    switch ($filter['type']) {
                        case 'TOLOWER':
                            $returnval = strtolower($field_value);
                        break;
                        case 'TOUPPER':
                            $returnval = strtoupper($field_value);
                        break;
                        case 'IDNTOASCII':
                            if(function_exists('idn_to_ascii')) {
                                $returnval = idn_to_ascii($field_value);
                            } else {
                                $returnval = $field_value;
                            }
                        break;
                        case 'IDNTOUTF8':
                            if(function_exists('idn_to_utf8')) {
                                $returnval = idn_to_utf8($field_value);
                            } else {
                                $returnval = $field_value;
                            }
                        break;
                        default:
                            $this->errorMessage .= "Unknown Filter: ".$filter['type'];
                        break;
                    }
                }
            }
            return $returnval;
        }
        /**
@@ -453,7 +506,7 @@
                                break;
                                case 'ISEMAIL':
                                    if(function_exists('filter_var')) {
                                        if(!filter_var($field_value, FILTER_VALIDATE_EMAIL)) {
                                        if(filter_var($field_value, FILTER_VALIDATE_EMAIL) === false) {
                                            $errmsg = $validator['errmsg'];
                                            if(isset($this->wordbook[$errmsg])) {
                                                $this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
@@ -474,16 +527,16 @@
                                break;
                                case 'ISINT':
                                    if(function_exists('filter_var')) {
                                        if($vield_value != '' && filter_var($field_value, FILTER_VALIDATE_INT) === false) {
                                        if($field_value != '' && filter_var($field_value, FILTER_VALIDATE_INT) === false) {
                                            $errmsg = $validator['errmsg'];
                                            if(isset($this->wordbook[$errmsg])) {
                                            if(isset($this->wordbook[$errmsg])) {
                                                $this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
                                            } else {
                                                $this->errorMessage .= $errmsg."<br />\r\n";
                                            }
                                        }
                                    } else {
                                        $tmpval = intval($field_value);
                                        $tmpval = $app->functions->intval($field_value);
                                        if($tmpval === 0 and !empty($field_value)) {
                                                $errmsg = $validator['errmsg'];
                                                if(isset($this->wordbook[$errmsg])) {
@@ -610,14 +663,14 @@
                $this->action = $action;
                $this->primary_id = $primary_id;
                $record = $this->encode($record,$tab);
                $record = $this->encode($record,true);
                $sql_insert_key = '';
                $sql_insert_val = '';
                $sql_update = '';
                if(!is_array($this->formDef)) $app->error("No form definition found.");
                if(!is_array($this->formDef)) $app->error("Form definition not found.");
                // gehe durch alle Felder des Tabs
                // go trough all fields of the tab
                if(is_array($record)) {
                foreach($this->formDef['fields'] as $key => $field) {
                                // Wenn es kein leeres Passwortfeld ist
@@ -637,6 +690,7 @@
                                                                $record[$key] = md5(stripslashes($record[$key]));
                                                                $sql_insert_val .= "'".$app->db->quote($record[$key])."', ";
                                                        }
                                                } elseif ($field['formtype'] == 'CHECKBOX') {
                                                        $sql_insert_key .= "`$key`, ";
                                                        if($record[$key] == '') {
@@ -651,7 +705,6 @@
                                                        $sql_insert_val .= "'".$record[$key]."', ";
                                                }
                                        } else {
                                                if($field['formtype'] == 'PASSWORD') {
                                                        if(isset($field['encryption']) && $field['encryption'] == 'CRYPT') {
                                                                $record[$key] = $app->auth->crypt_password(stripslashes($record[$key]));
@@ -664,6 +717,7 @@
                                                                $record[$key] = md5(stripslashes($record[$key]));
                                                                $sql_update .= "`$key` = '".$app->db->quote($record[$key])."', ";
                                                        }
                                                } elseif ($field['formtype'] == 'CHECKBOX') {
                                                        if($record[$key] == '') {
                                                            // if a checkbox is not set, we set it to the unchecked value
@@ -685,7 +739,7 @@
        }
                // Add backticks for incomplete table names
                if(stristr($this->formDef['db_table'],'.')) {
                        $escape = '';
                } else {
@@ -695,7 +749,7 @@
                if($action == "INSERT") {
                        if($this->formDef['auth'] == 'yes') {
                                // Setze User und Gruppe
                                // Set user and group
                                $sql_insert_key .= "`sys_userid`, ";
                                $sql_insert_val .= ($this->formDef["auth_preset"]["userid"] > 0)?"'".$this->formDef["auth_preset"]["userid"]."', ":"'".$this->sys_userid."', ";
                                $sql_insert_key .= "`sys_groupid`, ";
@@ -785,7 +839,7 @@
            $usertheme = $app->db->quote($params["usertheme"]);
            $type = 'user';
            $active = 1;
            $insert_id = intval($insert_id);
            $insert_id = $app->functions->intval($insert_id);
            $language = $app->db->quote($params["language"]);
            $groupid = $app->db->datalogInsert('sys_group', "(name,description,client_id) VALUES ('$username','','$insert_id')", 'groupid');
            $groups = $groupid;
@@ -799,7 +853,7 @@
            global $app;
            $username = $app->db->quote($params["username"]);
            $clear_password = $app->db->quote($params["password"]);
            $client_id = intval($client_id);
            $client_id = $app->functions->intval($client_id);
            $password = $app->auth->crypt_password(stripslashes($clear_password));
            if ($clear_password) $pwstring = ", passwort = '$password'"; else $pwstring ="" ;
            $sql = "UPDATE sys_user set username = '$username' $pwstring WHERE client_id = $client_id";
@@ -808,7 +862,7 @@
        
        function ispconfig_sysuser_delete($client_id){
            global $app;
            $client_id = intval($client_id);
            $client_id = $app->functions->intval($client_id);
            $sql = "DELETE FROM sys_user WHERE client_id = $client_id";
            $app->db->query($sql);
            $sql = "DELETE FROM sys_group WHERE client_id = $client_id";
@@ -820,8 +874,9 @@
                
                $app->db->datalogSave($this->formDef['db_table'], $action, $this->formDef['db_table_idx'], $primary_id, $record_old, $record_new);
                return true;
                /*
                // Add backticks for incomplete table names.
                if(stristr($this->formDef['db_table'],'.')) {
                        $escape = '';
                } else {
interface/lib/classes/searchform.inc.php
@@ -177,7 +177,7 @@
        $sql_von = $_SESSION['search'][$list_name]['page'] * $records_per_page;
        $record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM $table WHERE $sql_where");
        $pages = intval(($record_count['anzahl'] - 1) / $records_per_page);
        $pages = $app->functions->intval(($record_count['anzahl'] - 1) / $records_per_page);
        $vars['list_file']      = $this->listDef['file'];
        $vars['page']           = $_SESSION['search'][$list_name]['page'];
@@ -264,6 +264,7 @@
    public function decode($record)
    {
        global $app;
        if(is_array($record)) {
            foreach($this->listDef['item'] as $field) {
                $key = $field['field'];
@@ -276,7 +277,7 @@
                        break;
    
                    case 'INTEGER':
                        $record[$key] = intval($record[$key]);
                        $record[$key] = $app->functions->intval($record[$key]);
                        break;
    
                    case 'DOUBLE':
@@ -324,7 +325,7 @@
                        break;
                    case 'INTEGER':
                        $record[$key] = intval($record[$key]);
                        $record[$key] = $app->functions->intval($record[$key]);
                        break;
                    case 'DOUBLE':
interface/lib/classes/sites_database_plugin.inc.php
@@ -34,7 +34,7 @@
        global $app;
        
        if($form_page->dataRecord["parent_domain_id"] > 0) {
            $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($form_page->dataRecord["parent_domain_id"]));
            $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($form_page->dataRecord["parent_domain_id"]));
        
            //* The Database user shall be owned by the same group then the website
            $sys_groupid = $web['sys_groupid'];
@@ -45,11 +45,11 @@
        if($form_page->dataRecord['database_user_id']) {
            // check if there has already been a database on this server with that user
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . intval($form_page->dataRecord['database_user_id']) . "' OR `database_ro_user_id` = '" . intval($form_page->dataRecord['database_user_id']) . "') AND `sys_groupid` = '" . intval($sys_groupid) . "'");
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_user_id']) . "') AND `sys_groupid` = '" . $app->functions->intval($sys_groupid) . "'");
            
            if($check && $check['cnt'] < 1) {
                // we need to make a datalog insert for the database users that are connected to this database
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . intval($form_page->dataRecord['database_user_id']) . "' AND `sys_groupid` = '" . intval($sys_groupid) . "'");
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_user_id']) . "' AND `sys_groupid` = '" . $app->functions->intval($sys_groupid) . "'");
                if($db_user) {
                    $db_user['server_id'] = $form_page->dataRecord['server_id'];
                    $app->db->datalogSave('web_database_user', 'INSERT', 'database_user_id', $db_user['database_user_id'], array(), $db_user);
@@ -59,11 +59,11 @@
        if($form_page->dataRecord['database_ro_user_id']) {
            // check if there has already been a database on this server with that user
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . intval($form_page->dataRecord['database_ro_user_id']) . "' OR `database_ro_user_id` = '" . intval($form_page->dataRecord['database_ro_user_id']) . "') AND `sys_groupid` = '" . intval($sys_groupid) . "'");
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_ro_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_ro_user_id']) . "') AND `sys_groupid` = '" . $app->functions->intval($sys_groupid) . "'");
            
            if($check && $check['cnt'] < 1) {
                // we need to make a datalog insert for the database users that are connected to this database
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . intval($form_page->dataRecord['database_ro_user_id']) . "' AND `sys_groupid` = '" . intval($sys_groupid) . "'");
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_ro_user_id']) . "' AND `sys_groupid` = '" . $app->functions->intval($sys_groupid) . "'");
                if($db_user) {
                    $db_user['server_id'] = $form_page->dataRecord['server_id'];
                    $app->db->datalogSave('web_database_user', 'INSERT', 'database_user_id', $db_user['database_user_id'], array(), $db_user);
@@ -75,10 +75,10 @@
    public function processDatabaseUpdate($form_page) {
        global $app;
        
        $old_record = $app->db->queryOneRecord('SELECT * FROM `web_database` WHERE `database_id` = ' . intval($form_page->id));
        $old_record = $app->db->queryOneRecord('SELECT * FROM `web_database` WHERE `database_id` = ' . $app->functions->intval($form_page->id));
        
        if($form_page->dataRecord["parent_domain_id"] > 0) {
            $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($form_page->dataRecord["parent_domain_id"]));
            $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($form_page->dataRecord["parent_domain_id"]));
        
            //* The Database user shall be owned by the same group then the website
            $sys_groupid = $web['sys_groupid'];
@@ -89,10 +89,10 @@
        // check if database user has changed
        if($old_record['database_user_id'] && $old_record['database_user_id'] != $form_page->dataRecord['database_user_id'] && $old_record['database_user_id'] != $form_page->dataRecord['database_ro_user_id']) {
            // check if any database on the server still uses this one
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . intval($old_record['database_user_id']) . "' OR `database_ro_user_id` = '" . intval($old_record['database_user_id']) . "') AND `sys_groupid` = '" . intval($sys_groupid) . "' AND `database_id` != '" . intval($form_page->id) . "'");
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($old_record['database_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($old_record['database_user_id']) . "') AND `sys_groupid` = '" . $app->functions->intval($sys_groupid) . "' AND `database_id` != '" . $app->functions->intval($form_page->id) . "'");
            if($check['cnt'] < 1) {
                // send a datalog delete
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . intval($old_record['database_user_id']) . "' AND `sys_groupid` = '" . intval($sys_groupid) . "'");
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . $app->functions->intval($old_record['database_user_id']) . "' AND `sys_groupid` = '" . $app->functions->intval($sys_groupid) . "'");
                if($db_user) {
                    $db_user['server_id'] = $form_page->dataRecord['server_id'];
                    $app->db->datalogSave('web_database_user', 'DELETE', 'database_user_id', $db_user['database_user_id'], $db_user, array());
@@ -102,10 +102,10 @@
        // check if readonly database user has changed
        if($old_record['database_ro_user_id'] && $old_record['database_ro_user_id'] != $form_page->dataRecord['database_ro_user_id'] && $old_record['database_ro_user_id'] != $form_page->dataRecord['database_user_id']) {
            // check if any database on the server still uses this one
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . intval($old_record['database_ro_user_id']) . "' OR `database_ro_user_id` = '" . intval($old_record['database_ro_user_id']) . "') AND `sys_groupid` = '" . intval($sys_groupid) . "' AND `database_id` != '" . intval($form_page->id) . "'");
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($old_record['database_ro_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($old_record['database_ro_user_id']) . "') AND `sys_groupid` = '" . $app->functions->intval($sys_groupid) . "' AND `database_id` != '" . $app->functions->intval($form_page->id) . "'");
            if($check['cnt'] < 1) {
                // send a datalog delete
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . intval($old_record['database_ro_user_id']) . "' AND `sys_groupid` = '" . intval($sys_groupid) . "'");
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . $app->functions->intval($old_record['database_ro_user_id']) . "' AND `sys_groupid` = '" . $app->functions->intval($sys_groupid) . "'");
                if($db_user) {
                    $db_user['server_id'] = $form_page->dataRecord['server_id'];
                    $app->db->datalogSave('web_database_user', 'DELETE', 'database_user_id', $db_user['database_user_id'], $db_user, array());
@@ -115,11 +115,11 @@
        
        if($form_page->dataRecord['database_user_id']) {
            // check if there has already been a database on this server with that user
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . intval($form_page->dataRecord['database_user_id']) . "' OR `database_ro_user_id` = '" . intval($form_page->dataRecord['database_user_id']) . "') AND `sys_groupid` = '" . intval($sys_groupid) . "'");
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_user_id']) . "') AND `sys_groupid` = '" . $app->functions->intval($sys_groupid) . "'");
            
            if($check && $check['cnt'] < 1) {
                // we need to make a datalog insert for the database users that are connected to this database
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . intval($form_page->dataRecord['database_user_id']) . "' AND `sys_groupid` = '" . intval($sys_groupid) . "'");
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_user_id']) . "' AND `sys_groupid` = '" . $app->functions->intval($sys_groupid) . "'");
                if($db_user) {
                    $db_user['server_id'] = $form_page->dataRecord['server_id'];
                    $app->db->datalogSave('web_database_user', 'INSERT', 'database_user_id', $db_user['database_user_id'], array(), $db_user);
@@ -129,11 +129,11 @@
        if($form_page->dataRecord['database_ro_user_id']) {
            // check if there has already been a database on this server with that user
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . intval($form_page->dataRecord['database_ro_user_id']) . "' OR `database_ro_user_id` = '" . intval($form_page->dataRecord['database_ro_user_id']) . "') AND `sys_groupid` = '" . intval($sys_groupid) . "'");
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_ro_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_ro_user_id']) . "') AND `sys_groupid` = '" . $app->functions->intval($sys_groupid) . "'");
            
            if($check && $check['cnt'] < 1) {
                // we need to make a datalog insert for the database users that are connected to this database
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . intval($form_page->dataRecord['database_ro_user_id']) . "' AND `sys_groupid` = '" . intval($sys_groupid) . "'");
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_ro_user_id']) . "' AND `sys_groupid` = '" . $app->functions->intval($sys_groupid) . "'");
                if($db_user) {
                    $db_user['server_id'] = $form_page->dataRecord['server_id'];
                    $app->db->datalogSave('web_database_user', 'INSERT', 'database_user_id', $db_user['database_user_id'], array(), $db_user);
@@ -146,13 +146,13 @@
    public function processDatabaseDelete($primary_id) {
        global $app;
        
        $old_record = $app->db->queryOneRecord('SELECT * FROM `web_database` WHERE `database_id` = ' . intval($primary_id));
        $old_record = $app->db->queryOneRecord('SELECT * FROM `web_database` WHERE `database_id` = ' . $app->functions->intval($primary_id));
        if($old_record['database_user_id']) {
            // check if any database on the server still uses this one
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . intval($old_record['server_id']) . "' AND (`database_user_id` = '" . intval($old_record['database_user_id']) . "' OR `database_ro_user_id` = '" . intval($old_record['database_user_id']) . "') AND `sys_groupid` = '" . intval($old_record['sys_groupid']) . "' AND `database_id` != '" . intval($primary_id) . "'");
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($old_record['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($old_record['database_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($old_record['database_user_id']) . "') AND `sys_groupid` = '" . $app->functions->intval($old_record['sys_groupid']) . "' AND `database_id` != '" . $app->functions->intval($primary_id) . "'");
            if($check['cnt'] < 1) {
                // send a datalog delete
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . intval($old_record['database_user_id']) . "' AND `sys_groupid` = '" . intval($old_record['sys_groupid']) . "'");
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . $app->functions->intval($old_record['database_user_id']) . "' AND `sys_groupid` = '" . $app->functions->intval($old_record['sys_groupid']) . "'");
                if($db_user) {
                    $db_user['server_id'] = $old_record['server_id'];
                    $app->db->datalogSave('web_database_user', 'DELETE', 'database_user_id', $db_user['database_user_id'], $db_user, array());
@@ -161,10 +161,10 @@
        }
        if($old_record['database_ro_user_id']) {
            // check if any database on the server still uses this one
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . intval($old_record['server_id']) . "' AND (`database_user_id` = '" . intval($old_record['database_ro_user_id']) . "' OR `database_ro_user_id` = '" . intval($old_record['database_ro_user_id']) . "') AND `sys_groupid` = '" . intval($old_record['sys_groupid']) . "' AND `database_id` != '" . intval($primary_id) . "'");
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($old_record['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($old_record['database_ro_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($old_record['database_ro_user_id']) . "') AND `sys_groupid` = '" . $app->functions->intval($old_record['sys_groupid']) . "' AND `database_id` != '" . $app->functions->intval($primary_id) . "'");
            if($check['cnt'] < 1) {
                // send a datalog delete
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . intval($old_record['database_ro_user_id']) . "' AND `sys_groupid` = '" . intval($old_record['sys_groupid']) . "'");
                $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . $app->functions->intval($old_record['database_ro_user_id']) . "' AND `sys_groupid` = '" . $app->functions->intval($old_record['sys_groupid']) . "'");
                if($db_user) {
                    $db_user['server_id'] = $old_record['server_id'];
                    $app->db->datalogSave('web_database_user', 'DELETE', 'database_user_id', $db_user['database_user_id'], $db_user, array());
interface/lib/classes/tform.inc.php
@@ -54,14 +54,14 @@
*        SEPARATOR
*        - separator char used for fileds with multiple values
*
*        Hint: The auto increment (ID) filed of the table has not be be definied eoarately.
*        Hint: The auto increment (ID) filed of the table has not be be definied separately.
*
*/
class tform {
        /**
        * Table definition (array)
        * Definition of the database table (array)
        * @var tableDef
        */
        var $tableDef;
@@ -79,25 +79,25 @@
        var $table_name;
        /**
        * Enable debigging
        * Debug Variable
        * @var debug
        */
        var $debug = 0;
        /**
        * name of the primary field of the datbase table (string)
        * name of the primary field of the database table (string)
        * @var table_index
        */
        var $table_index;
        /**
        * contains the error message
        * contains the error messages
        * @var errorMessage
        */
        var $errorMessage = '';
        var $dateformat = "d.m.Y";
        var $formDef;
        var $formDef = array();
        var $wordbook;
        var $module;
        var $primary_id;
@@ -124,7 +124,7 @@
    function loadFormDef($file,$module = '') {
                global $app,$conf;
                include_once($file);
                include($file);
                $this->formDef = $form;
                $this->module = $module;
@@ -169,7 +169,7 @@
                if(!is_array($this->formDef['tabs'][$tab])) $app->error("Tab does not exist or the tab is empty (TAB: $tab).");
                $new_record = '';
                $table_idx = $this->formDef['db_table_idx'];
                if(isset($record[$table_idx])) $new_record[$table_idx] = intval($record[$table_idx ]);
                if(isset($record[$table_idx])) $new_record[$table_idx] = $app->functions->intval($record[$table_idx ]);
                
                if(is_array($record)) {
                        foreach($this->formDef['tabs'][$tab]['fields'] as $key => $field) {
@@ -202,7 +202,7 @@
                                break;
                                case 'INTEGER':
                                        $new_record[$key] = intval($record[$key]);
                                        $new_record[$key] = $app->functions->intval($record[$key]);
                                break;
                                case 'DOUBLE':
@@ -224,7 +224,7 @@
        }
        /**
        * Get the key => value array of a form filed from a datasource definitiom
        * Get the key => value array of a form filled from a datasource definitiom
        *
        * @param field = array with field definition
        * @param record = Dataset as array
@@ -247,7 +247,6 @@
                        $table_idx = $this->formDef['db_table_idx'];
                        
                        $tmp_recordid = (isset($record[$table_idx]))?$record[$table_idx]:0;
                        //$tmp_recordid = intval($this->primary_id);
                        $querystring = str_replace("{RECORDID}",$tmp_recordid,$querystring);
                        unset($tmp_recordid);
                        
@@ -678,7 +677,7 @@
                                        }
                                break;
                                case 'INTEGER':
                                        $new_record[$key] = (isset($record[$key]))?$record[$key]:0;
                                        $new_record[$key] = (isset($record[$key]))?$app->functions->intval($record[$key]):0;
                                        //if($new_record[$key] != $record[$key]) $new_record[$key] = $field['default'];
                                        //if($key == 'refresh') die($record[$key]);
                                break;
@@ -863,7 +862,7 @@
                                            }
                                        }
                                    } else {
                                        $tmpval = intval($field_value);
                                        $tmpval = $app->functions->intval($field_value);
                                        if($tmpval === 0 and !empty($field_value)) {
                                                $errmsg = $validator['errmsg'];
                                                if(isset($this->wordbook[$errmsg])) {
@@ -976,7 +975,7 @@
        }
        /**
        * Create the SQL staement.
        * Create SQL statement
        *
        * @param record = Datensatz als Array
        * @param action = INSERT oder UPDATE
interface/lib/classes/tform_actions.inc.php
@@ -49,7 +49,7 @@
                $app->tform->loadFormDef($tform_def_file);
                
                // Importing ID
                $this->id = (isset($_REQUEST["id"]))?intval($_REQUEST["id"]):0;
                $this->id = (isset($_REQUEST["id"]))?$app->functions->intval($_REQUEST["id"]):0;
                
                // show print version of the form
                if(isset($_GET["print_form"]) && $_GET["print_form"] == 1) {
@@ -291,7 +291,7 @@
                $app->tform->loadFormDef($tform_def_file);
                // importing ID
                $this->id = intval($_REQUEST["id"]);
                $this->id = $app->functions->intval($_REQUEST["id"]);
                if($this->id > 0) {
interface/lib/classes/tools_sites.inc.php
@@ -74,7 +74,7 @@
            }
        }
        
        $tmp = $app->db->queryOneRecord("SELECT name FROM sys_group WHERE groupid = " . intval($client_group_id));
        $tmp = $app->db->queryOneRecord("SELECT name FROM sys_group WHERE groupid = " . $app->functions->intval($client_group_id));
        $clientName = $tmp['name'];
        if ($clientName == "") $clientName = 'default';
        $clientName = $this->convertClientName($clientName);
@@ -100,7 +100,7 @@
                $client_group_id = 0;
            }
        }
        $tmp = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = " . intval($client_group_id));
        $tmp = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = " . $app->functions->intval($client_group_id));
        $clientID = $tmp['client_id'];
        if ($clientID == '') $clientID = '0';
        return $clientID;
interface/lib/classes/validate_dns.inc.php
@@ -150,7 +150,7 @@
  $error = '';
  if(intval($value) != $value || !is_numeric($value)) $error .= $fieldname." ".$app->tform->wordbook['error_must_be_integer']."<br>\r\n";
  if($app->functions->intval($value, true) != $value || !is_numeric($value)) $error .= $fieldname." ".$app->tform->wordbook['error_must_be_integer']."<br>\r\n";
  if($value > 2147483647) $error .= $fieldname." ".$app->tform->wordbook['error_must_not_be_greater_than_2147483647']."<br>\r\n";
  if(!$zero_allowed){
    if($value <= 0) $error .= $fieldname." ".$app->tform->wordbook['error_must_be_positive']."<br>\r\n";
@@ -268,7 +268,7 @@
  // increase serial
  $serial_date = substr($serial, 0, 8);
  $count = intval(substr($serial, 8, 2));
  $count = $app->functions->intval(substr($serial, 8, 2));
  $current_date = date("Ymd");
  if($serial_date >= $current_date){
    $count += 1;
interface/lib/classes/validate_domain.inc.php
@@ -88,7 +88,7 @@
        $app->uses('ini_parser,getconf');
        $settings = $app->getconf->get_global_config('domains');
        if ($settings['use_domain_module'] == 'y') {
            $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . intval($check_domain);
            $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . $app->functions->intval($check_domain);
            $domain_check = $app->db->queryOneRecord($sql);
            if(!$domain_check) return;
            $check_domain = $domain_check['domain'];
@@ -114,11 +114,11 @@
            $primary_id = $app->tform->primary_id;
        }
        
        $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `domain` = '" . $app->db->quote($domain_name) . "' AND `domain_id` != " . intval($primary_id));
        $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `domain` = '" . $app->db->quote($domain_name) . "' AND `domain_id` != " . $app->functions->intval($primary_id));
        if($check['cnt'] > 0) return false;
        
        if($only_domain == false) {
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE CONCAT(`subdomain`, '.', `domain`) = '" . $app->db->quote($domain_name) . "' AND `domain_id` != " . intval($primary_id));
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE CONCAT(`subdomain`, '.', `domain`) = '" . $app->db->quote($domain_name) . "' AND `domain_id` != " . $app->functions->intval($primary_id));
            if($check['cnt'] > 0) return false;
        }
        
interface/lib/plugins/mail_user_filter_plugin.inc.php
@@ -124,8 +124,8 @@
        global $app,$conf;
        
        $app->uses("getconf");
        $mailuser_rec = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE mailuser_id = ".intval($page_form->dataRecord["mailuser_id"]));
        $mail_config = $app->getconf->get_server_config(intval($mailuser_rec["server_id"]),'mail');
        $mailuser_rec = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE mailuser_id = ".$app->functions->intval($page_form->dataRecord["mailuser_id"]));
        $mail_config = $app->getconf->get_server_config($app->functions->intval($mailuser_rec["server_id"]),'mail');
        
        if($mail_config['mail_filter_syntax'] == 'sieve') {
            
interface/lib/plugins/sites_web_database_user_plugin.inc.php
@@ -29,13 +29,13 @@
        // make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($page_form->dataRecord["client_group_id"])) {
            $client_group_id = intval($page_form->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]);
            $app->db->query("UPDATE web_database_user SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE database_user_id = ".$page_form->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($page_form->dataRecord["client_group_id"])) {
            $client_group_id = intval($page_form->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]);
            $app->db->query("UPDATE web_database_user SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE database_user_id = ".$page_form->id);
        }
        $app->db->query("UPDATE web_database_user SET server_id = '" . intval($conf['server_id']) . "' WHERE database_user_id = ".$page_form->id);
        $app->db->query("UPDATE web_database_user SET server_id = '" . $app->functions->intval($conf['server_id']) . "' WHERE database_user_id = ".$page_form->id);
    }
}                  
interface/lib/plugins/sites_web_domain_plugin.inc.php
@@ -43,16 +43,16 @@
        // make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($page_form->dataRecord["client_group_id"])) {
            $client_group_id = intval($page_form->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]);
            $app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$page_form->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($page_form->dataRecord["client_group_id"])) {
            $client_group_id = intval($page_form->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]);
            $app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$page_form->id);
        }
        // Get configuration for the web system
        $app->uses("getconf");        
        $web_config = $app->getconf->get_server_config(intval($page_form->dataRecord['server_id']),'web');
        $web_config = $app->getconf->get_server_config($app->functions->intval($page_form->dataRecord['server_id']),'web');
        $document_root = str_replace("[website_id]",$page_form->id,$web_config["website_path"]);
        $document_root = str_replace("[website_idhash_1]",$this->id_hash($page_form->id,1),$document_root);
        $document_root = str_replace("[website_idhash_2]",$this->id_hash($page_form->id,1),$document_root);
@@ -63,11 +63,11 @@
        if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {                    
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = $client_group_id");
            $client_id = intval($client["client_id"]);
            $client_id = $app->functions->intval($client["client_id"]);
        } else {                
            //$client_id = intval($this->dataRecord["client_group_id"]);
            $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($page_form->dataRecord["client_group_id"]));
            $client_id = intval($client["client_id"]);
            //$client_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".$app->functions->intval($page_form->dataRecord["client_group_id"]));
            $client_id = $app->functions->intval($client["client_id"]);
        }
        // Set the values for document_root, system_user and system_group
interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php
@@ -47,9 +47,9 @@
        // Get configuration for the web system
        $app->uses("getconf");        
        $web_rec = $app->tform->getDataRecord($page_form->id);
        $web_config = $app->getconf->get_server_config(intval($web_rec['server_id']),'web');
        $web_config = $app->getconf->get_server_config($app->functions->intval($web_rec['server_id']),'web');
        
        $parent_domain = $app->db->queryOneRecord("SELECT * FROM `web_domain` WHERE `domain_id` = '" . intval($web_rec['parent_domain_id']) . "'");
        $parent_domain = $app->db->queryOneRecord("SELECT * FROM `web_domain` WHERE `domain_id` = '" . $app->functions->intval($web_rec['parent_domain_id']) . "'");
        
        // Set the values for document_root, system_user and system_group
        $system_user = $app->db->quote($parent_domain['system_user']);
@@ -61,7 +61,7 @@
        $php_open_basedir = $app->db->quote(str_replace("[website_domain]",$web_rec['domain'],$php_open_basedir));
        $htaccess_allow_override = $app->db->quote($parent_domain['allow_override']);
        $sql = "UPDATE web_domain SET sys_groupid = ".intval($parent_domain['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir'  WHERE domain_id = ".$page_form->id;
        $sql = "UPDATE web_domain SET sys_groupid = ".$app->functions->intval($parent_domain['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir'  WHERE domain_id = ".$page_form->id;
        $app->db->query($sql);
    }
}                  
interface/lib/plugins/vm_openvz_plugin.inc.php
@@ -39,11 +39,11 @@
        // make sure that the record belongs to the clinet group and not the admin group when admin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE openvz_vm SET sys_groupid = $client_group_id WHERE vm_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE openvz_vm SET sys_groupid = $client_group_id WHERE vm_id = ".$this->id);
        }
        
@@ -80,11 +80,11 @@
        // make sure that the record belongs to the clinet group and not the admin group when a admin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE openvz_vm SET sys_groupid = $client_group_id WHERE vm_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE openvz_vm SET sys_groupid = $client_group_id WHERE vm_id = ".$this->id);
        }
        
interface/web/admin/login_as.php
@@ -45,10 +45,10 @@
}
if(isset($_GET['id'])) {
    $userId = intval($_GET['id']);
    $userId = $app->functions->intval($_GET['id']);
    $backlink = 'admin/users_list.php';
} else {
    $client_id = intval($_GET['cid']);
    $client_id = $app->functions->intval($_GET['cid']);
    $tmp_client = $app->db->queryOneRecord("SELECT username FROM client WHERE client_id = $client_id");
    $tmp_sys_user = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE username = '".$app->db->quote($tmp_client['username'])."'");
    $userId = $tmp_sys_user['userid'];
interface/web/admin/software_package_del.php
@@ -35,7 +35,7 @@
$app->auth->check_module_permissions('admin');
if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.');
$software_update_inst_id = intval($_GET['software_update_inst_id']);
$software_update_inst_id = $app->functions->intval($_GET['software_update_inst_id']);
if($software_update_inst_id > 0) {    
    $app->db->datalogDelete('software_update_inst', 'software_update_inst_id', $software_update_inst_id);
interface/web/admin/software_package_install.php
@@ -38,7 +38,7 @@
if(!$app->auth->is_admin()) die('only allowed for administrators.');
$package_name = $app->db->quote($_REQUEST['package']);
$install_server_id = intval($_REQUEST['server_id']);
$install_server_id = $app->functions->intval($_REQUEST['server_id']);
$install_key = $app->db->quote(trim($_REQUEST['install_key']));
$package = $app->db->queryOneRecord("SELECT * FROM software_package WHERE package_name = '$package_name'");
interface/web/admin/software_package_list.php
@@ -53,7 +53,7 @@
                
                $package_title = $app->db->quote($p['title']);
                $package_description = $app->db->quote($p['description']);
                $software_repo_id = intval($repo['software_repo_id']);
                $software_repo_id = $app->functions->intval($repo['software_repo_id']);
                $package_type = $app->db->quote($p['type']);
                $package_installable = $app->db->quote($p['installable']);
                $package_requires_db = $app->db->quote($p['requires_db']);
@@ -86,13 +86,13 @@
                    foreach($updates as $u) {
                        
                        $version_array = explode('.',$u['version']);
                        $v1 = intval($version_array[0]);
                        $v2 = intval($version_array[1]);
                        $v3 = intval($version_array[2]);
                        $v4 = intval($version_array[3]);
                        $v1 = $app->functions->intval($version_array[0]);
                        $v2 = $app->functions->intval($version_array[1]);
                        $v3 = $app->functions->intval($version_array[2]);
                        $v4 = $app->functions->intval($version_array[3]);
                        
                        $package_name = $app->db->quote($u['package_name']);
                        $software_repo_id = intval($repo['software_repo_id']);
                        $software_repo_id = $app->functions->intval($repo['software_repo_id']);
                        $update_url = $app->db->quote($u['url']);
                        $update_md5 = $app->db->quote($u['md5']);
                        $update_dependencies = (isset($u['dependencies']))?$app->db->quote($u['dependencies']):'';
@@ -124,7 +124,7 @@
/*
if(isset($_GET['action']) && $_GET['action'] == 'install' && $_GET['package'] != '' && $_GET['server_id'] > 0) {
    $package_name = $app->db->quote($_GET['package']);
    $server_id = intval($_GET['server_id']);
    $server_id = $app->functions->intval($_GET['server_id']);
    $sql = "SELECT software_update_id, package_name, update_title FROM software_update WHERE type = 'full' AND package_name = '$package_name' ORDER BY v1 DESC, v2 DESC, v3 DESC, v4 DESC LIMIT 0,1";
    $tmp = $app->db->queryOneRecord($sql);
    $software_update_id = $tmp['software_update_id'];
interface/web/admin/software_update_list.php
@@ -66,13 +66,13 @@
                    foreach($updates as $u) {
                        
                        $version_array = explode('.',$u['version']);
                        $v1 = intval($version_array[0]);
                        $v2 = intval($version_array[1]);
                        $v3 = intval($version_array[2]);
                        $v4 = intval($version_array[3]);
                        $v1 = $app->functions->intval($version_array[0]);
                        $v2 = $app->functions->intval($version_array[1]);
                        $v3 = $app->functions->intval($version_array[2]);
                        $v4 = $app->functions->intval($version_array[3]);
                        
                        $package_name = $app->db->quote($u['package_name']);
                        $software_repo_id = intval($repo['software_repo_id']);
                        $software_repo_id = $app->functions->intval($repo['software_repo_id']);
                        $update_url = $app->db->quote($u['url']);
                        $update_md5 = $app->db->quote($u['md5']);
                        $update_dependencies = (isset($u['dependencies']))?$app->db->quote($u['dependencies']):'';
@@ -101,8 +101,8 @@
//* Install packages, if GET Request
if(isset($_GET['action']) && $_GET['action'] == 'install' && $_GET['package'] != '' && $_GET['server_id'] > 0) {
    $package_name = $app->db->quote($_GET['package']);
    $server_id = intval($_GET['server_id']);
    $software_update_id = intval($_GET['id']);
    $server_id = $app->functions->intval($_GET['server_id']);
    $software_update_id = $app->functions->intval($_GET['id']);
    
    $insert_data = "(package_name, server_id, software_update_id, status) VALUES ('$package_name', '$server_id', '$software_update_id','installing')";
    // $insert_data = "(package_name, server_id, software_update_id, status) VALUES ('$package_name', '$server_id', '$software_update_id','installed')";
@@ -130,7 +130,7 @@
if(isset($_POST["server_id"]) && $_POST["server_id"] > 0) {
    $server_id = intval($_POST["server_id"]);
    $server_id = $app->functions->intval($_POST["server_id"]);
} else {
    $server_id = 1;
}
interface/web/client/client_del.php
@@ -70,20 +70,20 @@
        // Load table definition from file
        $app->tform->loadFormDef($tform_def_file);
        
        $this->id = intval($_REQUEST["id"]);
        $this->id = $app->functions->intval($_REQUEST["id"]);
        
        $this->dataRecord = $app->tform->getDataRecord($this->id);
        $client_id = intval($this->dataRecord['client_id']);
        $client_id = $app->functions->intval($this->dataRecord['client_id']);
        
        //$parent_client_id = intval($this->dataRecord['parent_client_id']);
        //$parent_client_id = $app->functions->intval($this->dataRecord['parent_client_id']);
        //$parent_user = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE client_id = $parent_client_id");
        $client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id");
        
        // Get all records (sub-clients, mail, web, etc....)  of this client.
        $tables = 'cron,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_domain';
        $tables_array = explode(',',$tables);
        $client_group_id = intval($client_group['groupid']);
        $client_group_id = $app->functions->intval($client_group['groupid']);
        
        $table_list = array();
        if($client_group_id > 1) {
@@ -115,11 +115,11 @@
    function onAfterDelete() {
        global $app, $conf;
        
        $client_id = intval($this->dataRecord['client_id']);
        $client_id = $app->functions->intval($this->dataRecord['client_id']);
        
        if($client_id > 0) {            
            // remove the group of the client from the resellers group
            $parent_client_id = intval($this->dataRecord['parent_client_id']);
            $parent_client_id = $app->functions->intval($this->dataRecord['parent_client_id']);
            $parent_user = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE client_id = $parent_client_id");
            $client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id");
            $app->auth->remove_group_from_user($parent_user['userid'],$client_group['groupid']);
@@ -133,7 +133,7 @@
            // Delete all records (sub-clients, mail, web, etc....)  of this client.
            $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_domain,web_folder,web_folder_user,domain';
            $tables_array = explode(',',$tables);
            $client_group_id = intval($client_group['groupid']);
            $client_group_id = $app->functions->intval($client_group['groupid']);
            if($client_group_id > 1) {
                foreach($tables_array as $table) {
                    if($table != '') {
interface/web/client/client_edit.php
@@ -164,18 +164,18 @@
        //* to his groups, so he can administrate the records of this client.
        if($_SESSION['s']['user']['typ'] == 'user') {
            $app->auth->add_group_to_user($_SESSION['s']['user']['userid'],$groupid);
            $app->db->query("UPDATE client SET parent_client_id = ".intval($_SESSION['s']['user']['client_id'])." WHERE client_id = ".$this->id);
            $app->db->query("UPDATE client SET parent_client_id = ".$app->functions->intval($_SESSION['s']['user']['client_id'])." WHERE client_id = ".$this->id);
        }
        
        //* Set the default servers
        $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE mail_server = 1 AND mirror_server_id = 0 LIMIT 0,1');
        $default_mailserver = intval($tmp['server_id']);
        $default_mailserver = $app->functions->intval($tmp['server_id']);
        $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE web_server = 1 AND mirror_server_id = 0 LIMIT 0,1');
        $default_webserver = intval($tmp['server_id']);
        $default_webserver = $app->functions->intval($tmp['server_id']);
        $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE dns_server = 1 AND mirror_server_id = 0 LIMIT 0,1');
        $default_dnsserver = intval($tmp['server_id']);
        $default_dnsserver = $app->functions->intval($tmp['server_id']);
        $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE db_server = 1 AND mirror_server_id = 0 LIMIT 0,1');
        $default_dbserver = intval($tmp['server_id']);
        $default_dbserver = $app->functions->intval($tmp['server_id']);
        
        $sql = "UPDATE client SET default_mailserver = $default_mailserver, default_webserver = $default_webserver, default_dnsserver = $default_dnsserver, default_dbserver = $default_dbserver WHERE client_id = ".$this->id;
        $app->db->query($sql);
interface/web/client/client_message.php
@@ -59,8 +59,8 @@
    
    //* Send message
    if($error == '') {
        if(intval($_POST['recipient']) > 0){
            $circle = $app->db->queryOneRecord("SELECT client_ids FROM client_circle WHERE active = 'y' AND circle_id = ".intval($_POST['recipient'])." AND ".$app->tform->getAuthSQL('r'));
        if($app->functions->intval($_POST['recipient']) > 0){
            $circle = $app->db->queryOneRecord("SELECT client_ids FROM client_circle WHERE active = 'y' AND circle_id = ".$app->functions->intval($_POST['recipient'])." AND ".$app->tform->getAuthSQL('r'));
            if(isset($circle['client_ids']) && $circle['client_ids'] != ''){
                $tmp_client_ids = explode(',',$circle['client_ids']);
                $where = array();
@@ -77,7 +77,7 @@
            if($_SESSION["s"]["user"]["typ"] == 'admin'){
                $sql = "SELECT * FROM client WHERE email != ''";
            } else {
                $client_id = intval($_SESSION['s']['user']['client_id']);
                $client_id = $app->functions->intval($_SESSION['s']['user']['client_id']);
                if($client_id == 0) die('Invalid Client ID.');
                $sql = "SELECT * FROM client WHERE email != '' AND parent_client_id = '$client_id'";
            }
@@ -113,7 +113,7 @@
} else {
    // pre-fill Sender field with reseller's email address
    if($_SESSION["s"]["user"]["typ"] != 'admin'){
        $client_id = intval($_SESSION['s']['user']['client_id']);
        $client_id = $app->functions->intval($_SESSION['s']['user']['client_id']);
        if($client_id > 0){
            $sql = "SELECT email FROM client WHERE client_id = ".$client_id;
            $client = $app->db->queryOneRecord($sql);
@@ -123,12 +123,12 @@
}
// Recipient Drop-Down
$recipient = '<option value="0"'.(intval($_POST['recipient']) == 0 ? ' selected="selected"' : '').'>'.($_SESSION["s"]["user"]["typ"] == 'admin'? $wb['all_clients_resellers_txt'] : $wb['all_clients_txt']).'</option>';
$recipient = '<option value="0"'.($app->functions->intval($_POST['recipient']) == 0 ? ' selected="selected"' : '').'>'.($_SESSION["s"]["user"]["typ"] == 'admin'? $wb['all_clients_resellers_txt'] : $wb['all_clients_txt']).'</option>';
$sql = "SELECT * FROM client_circle WHERE active = 'y' AND ".$app->tform->getAuthSQL('r');
$circles = $app->db->queryAllRecords($sql);
if(is_array($circles) && !empty($circles)){
    foreach($circles as $circle){
        $recipient .= '<option value="'.$circle['circle_id'].'"'.(intval($_POST['recipient']) == $circle['circle_id'] ? ' selected="selected"' : '').'>'.$circle['circle_name'].'</option>';
        $recipient .= '<option value="'.$circle['circle_id'].'"'.($app->functions->intval($_POST['recipient']) == $circle['circle_id'] ? ' selected="selected"' : '').'>'.$circle['circle_name'].'</option>';
    }
}
$app->tpl->setVar('recipient',$recipient);
interface/web/client/domain_edit.php
@@ -142,7 +142,7 @@
        // make sure that the record belongs to the client group and not the admin group when admin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
        }
    }
interface/web/client/reseller_del.php
@@ -57,7 +57,7 @@
        
        if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.');
        
        $client_id = intval($this->dataRecord['client_id']);
        $client_id = $app->functions->intval($this->dataRecord['client_id']);
        
        $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE parent_client_id = ".$client_id);
        if($tmp["number"] > 0) $app->error($app->lng('error_has_clients'));
@@ -67,13 +67,13 @@
    function onAfterDelete() {
        global $app, $conf;
        
        $client_id = intval($this->dataRecord['client_id']);
        $client_id = $app->functions->intval($this->dataRecord['client_id']);
        
        if($client_id > 0) {
            // TODO: Delete all records (sub-clients, mail, web, etc....)  of this client.
            
            // remove the group of the client from the resellers group
            $parent_client_id = intval($this->dataRecord['parent_client_id']);
            $parent_client_id = $app->functions->intval($this->dataRecord['parent_client_id']);
            $parent_user = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE client_id = $parent_client_id");
            $client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id");
            $app->auth->remove_group_from_user($parent_user['userid'],$client_group['groupid']);
interface/web/client/reseller_edit.php
@@ -167,13 +167,13 @@
        
        //* Set the default servers
        $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE mail_server = 1 LIMIT 0,1');
        $default_mailserver = intval($tmp['server_id']);
        $default_mailserver = $app->functions->intval($tmp['server_id']);
        $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE web_server = 1 LIMIT 0,1');
        $default_webserver = intval($tmp['server_id']);
        $default_webserver = $app->functions->intval($tmp['server_id']);
        $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE dns_server = 1 LIMIT 0,1');
        $default_dnsserver = intval($tmp['server_id']);
        $default_dnsserver = $app->functions->intval($tmp['server_id']);
        $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE db_server = 1 LIMIT 0,1');
        $default_dbserver = intval($tmp['server_id']);
        $default_dbserver = $app->functions->intval($tmp['server_id']);
        
        $sql = "UPDATE client SET default_mailserver = $default_mailserver, default_webserver = $default_webserver, default_dnsserver = $default_dnsserver, default_dbserver = $default_dbserver WHERE client_id = ".$this->id;
        $app->db->query($sql);
interface/web/dns/ajax_get_json.php
@@ -49,7 +49,7 @@
        $result = array();
        
        // ipv4
        //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".intval($_SESSION['s']['user']['client_id']).")");
        //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")");
        $result[] = $app->functions->suggest_ips('IPv4');
        $json = $app->functions->json_encode($result);
@@ -63,7 +63,7 @@
        $result = array();
        
        // ipv6
        //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".intval($_SESSION['s']['user']['client_id']).")");
        //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")");
        $result[] = $app->functions->suggest_ips('IPv6');
        
        $json = $app->functions->json_encode($result);
interface/web/dns/dns_a_edit.php
@@ -76,7 +76,7 @@
        global $app, $conf;
        
        // Get the parent soa record of the domain
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        // Check if Domain belongs to user
        if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
@@ -117,11 +117,11 @@
        global $app, $conf;
        
        //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
        //* Update the serial number of the SOA record
        $soa_id = intval($_POST["zone"]);
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
@@ -130,8 +130,8 @@
        global $app, $conf;
        
        //* Update the serial number of the SOA record
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = intval($_POST["zone"]);
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
interface/web/dns/dns_aaaa_edit.php
@@ -76,7 +76,7 @@
        global $app, $conf;
        
        // Get the parent soa record of the domain
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        // Check if Domain belongs to user
        if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
@@ -112,11 +112,11 @@
        global $app, $conf;
        
        //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
        //* Update the serial number of the SOA record
        $soa_id = intval($_POST["zone"]);
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
@@ -125,8 +125,8 @@
        global $app, $conf;
        
        //* Update the serial number of the SOA record
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = intval($_POST["zone"]);
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
interface/web/dns/dns_alias_edit.php
@@ -76,7 +76,7 @@
        global $app, $conf;
        
        // Get the parent soa record of the domain
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        // Check if Domain belongs to user
        if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
@@ -112,11 +112,11 @@
        global $app, $conf;
        
        //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
        //* Update the serial number of the SOA record
        $soa_id = intval($_POST["zone"]);
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
@@ -125,8 +125,8 @@
        global $app, $conf;
        
        //* Update the serial number of the SOA record
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = intval($_POST["zone"]);
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
interface/web/dns/dns_cname_edit.php
@@ -76,7 +76,7 @@
        global $app, $conf;
        
        // Get the parent soa record of the domain
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        // Check if Domain belongs to user
        if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
@@ -117,11 +117,11 @@
        global $app, $conf;
        
        //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
        //* Update the serial number of the SOA record
        $soa_id = intval($_POST["zone"]);
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
@@ -130,8 +130,8 @@
        global $app, $conf;
        
        //* Update the serial number of the SOA record
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = intval($_POST["zone"]);
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
interface/web/dns/dns_hinfo_edit.php
@@ -76,7 +76,7 @@
        global $app, $conf;
        
        // Get the parent soa record of the domain
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        // Check if Domain belongs to user
        if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
@@ -112,11 +112,11 @@
        global $app, $conf;
        
        //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
        //* Update the serial number of the SOA record
        $soa_id = intval($_POST["zone"]);
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
@@ -125,8 +125,8 @@
        global $app, $conf;
        
        //* Update the serial number of the SOA record
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = intval($_POST["zone"]);
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
interface/web/dns/dns_import.php
@@ -44,13 +44,13 @@
$app->load_language_file('/web/dns/lib/lang/'.$_SESSION['s']['language'].'_dns_wizard.lng');
// import variables
$template_id = (isset($_POST['template_id']))?intval($_POST['template_id']):0;
$sys_groupid = (isset($_POST['client_group_id']))?intval($_POST['client_group_id']):0;
$template_id = (isset($_POST['template_id']))?$app->functions->intval($_POST['template_id']):0;
$sys_groupid = (isset($_POST['client_group_id']))?$app->functions->intval($_POST['client_group_id']):0;
$domain = (isset($_POST['domain'])&&!empty($_POST['domain']))?$_POST['domain']:NULL;
// get the correct server_id
if($_SESSION['s']['user']['typ'] == 'admin') {
    $server_id = (isset($_POST['server_id']))?intval($_POST['server_id']):1;
    $server_id = (isset($_POST['server_id']))?$app->functions->intval($_POST['server_id']):1;
} else {
    $client_group_id = $_SESSION["s"]["user"]["default_group"];
    $client = $app->db->queryOneRecord("SELECT default_dnsserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
@@ -129,7 +129,7 @@
if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name'])){
    $valid_zone_file = FALSE;
    
    $sql = "SELECT server_name FROM `server` WHERE server_id=".intval($server_id)." OR mirror_server_id=".intval($server_id)." ORDER BY server_name ASC";
    $sql = "SELECT server_name FROM `server` WHERE server_id=".$app->functions->intval($server_id)." OR mirror_server_id=".$app->functions->intval($server_id)." ORDER BY server_name ASC";
    $servers = $app->db->queryAllRecords($sql);
    for ($i=0;$i<count($servers);$i++)
    {
@@ -202,22 +202,22 @@
            $time_format = strtolower(substr($parts[1],-1));
            switch ($time_format) {
                case 's':
                    $soa['ttl'] = intval(substr($parts[1],0,-1));
                    $soa['ttl'] = $app->functions->intval(substr($parts[1],0,-1));
                    break;
                case 'm':
                    $soa['ttl'] = intval(substr($parts[1],0,-1)) * 60;
                    $soa['ttl'] = $app->functions->intval(substr($parts[1],0,-1)) * 60;
                    break;
                case 'h':
                    $soa['ttl'] = intval(substr($parts[1],0,-1)) * 3600;
                    $soa['ttl'] = $app->functions->intval(substr($parts[1],0,-1)) * 3600;
                    break;
                case 'd':
                    $soa['ttl'] = intval(substr($parts[1],0,-1)) * 86400;
                    $soa['ttl'] = $app->functions->intval(substr($parts[1],0,-1)) * 86400;
                    break;
                case 'w':
                    $soa['ttl'] = intval(substr($parts[1],0,-1)) * 604800;
                    $soa['ttl'] = $app->functions->intval(substr($parts[1],0,-1)) * 604800;
                    break;
                default:
                    $soa['ttl'] = intval($parts[1]);
                    $soa['ttl'] = $app->functions->intval($parts[1]);
            }
            unset($time_format);
        }
@@ -234,28 +234,28 @@
            $valid_zone_file = TRUE;
        }
        // SERIAL
        if($i == ($soa_array_key + 1)) $soa['serial'] = intval($parts[0]);
        if($i == ($soa_array_key + 1)) $soa['serial'] = $app->functions->intval($parts[0]);
        // REFRESH
        if($i == ($soa_array_key + 2)){
            $time_format = strtolower(substr($parts[0],-1));
            switch ($time_format) {
                case 's':
                    $soa['refresh'] = intval(substr($parts[0],0,-1));
                    $soa['refresh'] = $app->functions->intval(substr($parts[0],0,-1));
                    break;
                case 'm':
                    $soa['refresh'] = intval(substr($parts[0],0,-1)) * 60;
                    $soa['refresh'] = $app->functions->intval(substr($parts[0],0,-1)) * 60;
                    break;
                case 'h':
                    $soa['refresh'] = intval(substr($parts[0],0,-1)) * 3600;
                    $soa['refresh'] = $app->functions->intval(substr($parts[0],0,-1)) * 3600;
                    break;
                case 'd':
                    $soa['refresh'] = intval(substr($parts[0],0,-1)) * 86400;
                    $soa['refresh'] = $app->functions->intval(substr($parts[0],0,-1)) * 86400;
                    break;
                case 'w':
                    $soa['refresh'] = intval(substr($parts[0],0,-1)) * 604800;
                    $soa['refresh'] = $app->functions->intval(substr($parts[0],0,-1)) * 604800;
                    break;
                default:
                    $soa['refresh'] = intval($parts[0]);
                    $soa['refresh'] = $app->functions->intval($parts[0]);
            }
            unset($time_format);
        }
@@ -264,22 +264,22 @@
            $time_format = strtolower(substr($parts[0],-1));
            switch ($time_format) {
                case 's':
                    $soa['retry'] = intval(substr($parts[0],0,-1));
                    $soa['retry'] = $app->functions->intval(substr($parts[0],0,-1));
                    break;
                case 'm':
                    $soa['retry'] = intval(substr($parts[0],0,-1)) * 60;
                    $soa['retry'] = $app->functions->intval(substr($parts[0],0,-1)) * 60;
                    break;
                case 'h':
                    $soa['retry'] = intval(substr($parts[0],0,-1)) * 3600;
                    $soa['retry'] = $app->functions->intval(substr($parts[0],0,-1)) * 3600;
                    break;
                case 'd':
                    $soa['retry'] = intval(substr($parts[0],0,-1)) * 86400;
                    $soa['retry'] = $app->functions->intval(substr($parts[0],0,-1)) * 86400;
                    break;
                case 'w':
                    $soa['retry'] = intval(substr($parts[0],0,-1)) * 604800;
                    $soa['retry'] = $app->functions->intval(substr($parts[0],0,-1)) * 604800;
                    break;
                default:
                    $soa['retry'] = intval($parts[0]);
                    $soa['retry'] = $app->functions->intval($parts[0]);
            }
            unset($time_format);
        }
@@ -288,22 +288,22 @@
            $time_format = strtolower(substr($parts[0],-1));
            switch ($time_format) {
                case 's':
                    $soa['expire'] = intval(substr($parts[0],0,-1));
                    $soa['expire'] = $app->functions->intval(substr($parts[0],0,-1));
                    break;
                case 'm':
                    $soa['expire'] = intval(substr($parts[0],0,-1)) * 60;
                    $soa['expire'] = $app->functions->intval(substr($parts[0],0,-1)) * 60;
                    break;
                case 'h':
                    $soa['expire'] = intval(substr($parts[0],0,-1)) * 3600;
                    $soa['expire'] = $app->functions->intval(substr($parts[0],0,-1)) * 3600;
                    break;
                case 'd':
                    $soa['expire'] = intval(substr($parts[0],0,-1)) * 86400;
                    $soa['expire'] = $app->functions->intval(substr($parts[0],0,-1)) * 86400;
                    break;
                case 'w':
                    $soa['expire'] = intval(substr($parts[0],0,-1)) * 604800;
                    $soa['expire'] = $app->functions->intval(substr($parts[0],0,-1)) * 604800;
                    break;
                default:
                    $soa['expire'] = intval($parts[0]);
                    $soa['expire'] = $app->functions->intval($parts[0]);
            }
            unset($time_format);
        }
@@ -312,22 +312,22 @@
            $time_format = strtolower(substr($parts[0],-1));
            switch ($time_format) {
                case 's':
                    $soa['minimum'] = intval(substr($parts[0],0,-1));
                    $soa['minimum'] = $app->functions->intval(substr($parts[0],0,-1));
                    break;
                case 'm':
                    $soa['minimum'] = intval(substr($parts[0],0,-1)) * 60;
                    $soa['minimum'] = $app->functions->intval(substr($parts[0],0,-1)) * 60;
                    break;
                case 'h':
                    $soa['minimum'] = intval(substr($parts[0],0,-1)) * 3600;
                    $soa['minimum'] = $app->functions->intval(substr($parts[0],0,-1)) * 3600;
                    break;
                case 'd':
                    $soa['minimum'] = intval(substr($parts[0],0,-1)) * 86400;
                    $soa['minimum'] = $app->functions->intval(substr($parts[0],0,-1)) * 86400;
                    break;
                case 'w':
                    $soa['minimum'] = intval(substr($parts[0],0,-1)) * 604800;
                    $soa['minimum'] = $app->functions->intval(substr($parts[0],0,-1)) * 604800;
                    break;
                default:
                    $soa['minimum'] = intval($parts[0]);
                    $soa['minimum'] = $app->functions->intval($parts[0]);
            }
            unset($time_format);
        }
@@ -358,14 +358,14 @@
                    $dns_rr[$r]['name'] = $parts[0];
                }
                if(is_numeric($parts[1])){
                    $dns_rr[$r]['ttl'] = intval($parts[1]);
                    $dns_rr[$r]['ttl'] = $app->functions->intval($parts[1]);
                } else {
                    $dns_rr[$r]['ttl'] = $soa['ttl'];
                }
                switch ($resource_type) {
                    case 'mx':
                    case 'srv':
                        $dns_rr[$r]['aux'] = intval($parts[$pkey+1]);
                        $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]);
                        $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+2));
                        break;
                    case 'txt':
@@ -385,11 +385,11 @@
                    $pkey = 3;
                    $dns_rr[$r]['type'] = $resource_type;
                    $dns_rr[$r]['name'] = $parts[0];
                    $dns_rr[$r]['ttl'] = intval($parts[1]);
                    $dns_rr[$r]['ttl'] = $app->functions->intval($parts[1]);
                    switch ($resource_type) {
                        case 'mx':
                        case 'srv':
                            $dns_rr[$r]['aux'] = intval($parts[$pkey+1]);
                            $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]);
                            $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+2));
                            break;
                        case 'txt':
@@ -413,7 +413,7 @@
                    switch ($resource_type) {
                        case 'mx':
                        case 'srv':
                            $dns_rr[$r]['aux'] = intval($parts[$pkey+1]);
                            $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]);
                            $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+2));
                            break;
                        case 'txt':
@@ -433,11 +433,11 @@
                    $pkey = 2;
                    $dns_rr[$r]['type'] = $resource_type;
                    $dns_rr[$r]['name'] = $parts[0];
                    $dns_rr[$r]['ttl'] = intval($parts[1]);
                    $dns_rr[$r]['ttl'] = $app->functions->intval($parts[1]);
                    switch ($resource_type) {
                        case 'mx':
                        case 'srv':
                            $dns_rr[$r]['aux'] = intval($parts[$pkey+1]);
                            $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]);
                            $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+2));
                            break;
                        case 'txt':
@@ -463,7 +463,7 @@
                    switch ($resource_type) {
                        case 'mx':
                        case 'srv':
                            $dns_rr[$r]['aux'] = intval($parts[$pkey+1]);
                            $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]);
                            $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+2));
                            break;
                        case 'txt':
@@ -634,7 +634,7 @@
    $minimum = $app->db->quote($soa['minimum']);
    $ttl = $app->db->quote($soa['ttl']);
    $xfer = $app->db->quote('');
    $serial = $app->db->quote(intval($soa['serial'])+1);
    $serial = $app->db->quote($app->functions->intval($soa['serial'])+1);
    //print_r($soa);
    //die();
    if($valid_zone_file){
interface/web/dns/dns_mx_edit.php
@@ -76,7 +76,7 @@
        global $app, $conf;
        
        // Get the parent soa record of the domain
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        // Check if Domain belongs to user
        if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
@@ -112,11 +112,11 @@
        global $app, $conf;
        
        //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
        //* Update the serial number of the SOA record
        $soa_id = intval($_POST["zone"]);
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
@@ -125,8 +125,8 @@
        global $app, $conf;
        
        //* Update the serial number of the SOA record
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = intval($_POST["zone"]);
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
interface/web/dns/dns_ns_edit.php
@@ -76,7 +76,7 @@
        global $app, $conf;
        
        // Get the parent soa record of the domain
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        // Check if Domain belongs to user
        if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
@@ -112,11 +112,11 @@
        global $app, $conf;
        
        //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
        //* Update the serial number of the SOA record
        $soa_id = intval($_POST["zone"]);
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
@@ -125,8 +125,8 @@
        global $app, $conf;
        
        //* Update the serial number of the SOA record
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = intval($_POST["zone"]);
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
interface/web/dns/dns_ptr_edit.php
@@ -76,7 +76,7 @@
        global $app, $conf;
        
        // Get the parent soa record of the domain
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        // Check if Domain belongs to user
        if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
@@ -112,11 +112,11 @@
        global $app, $conf;
        
        //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
        //* Update the serial number of the SOA record
        $soa_id = intval($_POST["zone"]);
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
@@ -125,8 +125,8 @@
        global $app, $conf;
        
        //* Update the serial number of the SOA record
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = intval($_POST["zone"]);
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
interface/web/dns/dns_rp_edit.php
@@ -76,7 +76,7 @@
        global $app, $conf;
        
        // Get the parent soa record of the domain
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        // Check if Domain belongs to user
        if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
@@ -112,11 +112,11 @@
        global $app, $conf;
        
        //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
        //* Update the serial number of the SOA record
        $soa_id = intval($_POST["zone"]);
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
@@ -125,8 +125,8 @@
        global $app, $conf;
        
        //* Update the serial number of the SOA record
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = intval($_POST["zone"]);
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
interface/web/dns/dns_rr_del.php
@@ -54,8 +54,8 @@
        global $app; $conf;
                
        //* Update the serial number of the SOA record
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = intval($this->dataRecord["zone"]);
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = $app->functions->intval($this->dataRecord["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
interface/web/dns/dns_slave_del.php
@@ -56,7 +56,7 @@
        if($app->tform->checkPerm($this->id,'d') == false) $app->error($app->lng('error_no_delete_permission'));
        
        // Delete all records that belog to this zone.
        $records = $app->db->queryAllRecords("SELECT id FROM dns_slave WHERE zone = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT id FROM dns_slave WHERE zone = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('dns_slave','id',$rec['id']);
        }
interface/web/dns/dns_slave_edit.php
@@ -128,7 +128,7 @@
            // When the record is updated
            if($this->id > 0) {
                // restore the server ID if the user is not admin and record is edited
                $tmp = $app->db->queryOneRecord("SELECT server_id FROM dns_slave WHERE id = ".intval($this->id));
                $tmp = $app->db->queryOneRecord("SELECT server_id FROM dns_slave WHERE id = ".$app->functions->intval($this->id));
                $this->dataRecord["server_id"] = $tmp["server_id"];
                unset($tmp);
            // When the record is inserted
@@ -163,11 +163,11 @@
        
        // make sure that the record belongs to the client group and not the admin group when a dmin inserts it
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE dns_slave SET sys_groupid = $client_group_id WHERE id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE dns_slave SET sys_groupid = $client_group_id WHERE id = ".$this->id);
        }
@@ -180,17 +180,17 @@
        // make sure that the record belongs to the client group and not the admin group when a dmin inserts it
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE dns_slave SET sys_groupid = $client_group_id WHERE id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE dns_slave SET sys_groupid = $client_group_id WHERE id = ".$this->id);
        }
        
        //** When the client group has changed, change also the owner of the record if the owner is not the admin user
        if($this->oldDataRecord["client_group_id"] != $this->dataRecord["client_group_id"] && $this->dataRecord["sys_userid"] != 1) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $tmp = $app->db->queryOneREcord("SELECT userid FROM sys_user WHERE default_group = ".$client_group_id);
            if($tmp["userid"] > 0) {
                $app->db->query("UPDATE dns_slave SET sys_userid = ".$tmp["userid"]." WHERE id = ".$this->id);
interface/web/dns/dns_soa_del.php
@@ -56,7 +56,7 @@
        if($app->tform->checkPerm($this->id,'d') == false) $app->error($app->lng('error_no_delete_permission'));
        
        // Delete all records that belog to this zone.
        $records = $app->db->queryAllRecords("SELECT id FROM dns_rr WHERE zone = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT id FROM dns_rr WHERE zone = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('dns_rr','id',$rec['id']);
        }
interface/web/dns/dns_soa_edit.php
@@ -138,7 +138,7 @@
            // When the record is updated
            if($this->id > 0) {
                // restore the server ID if the user is not admin and record is edited
                $tmp = $app->db->queryOneRecord("SELECT server_id FROM dns_soa WHERE id = ".intval($this->id));
                $tmp = $app->db->queryOneRecord("SELECT server_id FROM dns_soa WHERE id = ".$app->functions->intval($this->id));
                $this->dataRecord["server_id"] = $tmp["server_id"];
                unset($tmp);
            // When the record is inserted
@@ -187,13 +187,13 @@
        
        // make sure that the record belongs to the client group and not the admin group when a dmin inserts it
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE id = ".$this->id);
            // And we want to update all rr records too, that belong to this record
            $app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE id = ".$this->id);
            // And we want to update all rr records too, that belong to this record
            $app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
@@ -230,13 +230,13 @@
        
        // make sure that the record belongs to the client group and not the admin group when a dmin inserts it
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE id = ".$this->id);
            // And we want to update all rr records too, that belong to this record
            $app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE id = ".$this->id);
            // And we want to update all rr records too, that belong to this record
            $app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
@@ -244,7 +244,7 @@
        
        //** When the client group has changed, change also the owner of the record if the owner is not the admin user
        if($this->oldDataRecord["client_group_id"] != $this->dataRecord["client_group_id"] && $this->dataRecord["sys_userid"] != 1) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $tmp = $app->db->queryOneREcord("SELECT userid FROM sys_user WHERE default_group = ".$client_group_id);
            if($tmp["userid"] > 0) {
                $app->db->query("UPDATE dns_soa SET sys_userid = ".$tmp["userid"]." WHERE id = ".$this->id);
interface/web/dns/dns_srv_edit.php
@@ -105,7 +105,7 @@
        global $app, $conf;
        // Get the parent soa record of the domain
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        // Check if Domain belongs to user
        if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
@@ -141,11 +141,11 @@
        global $app, $conf;
        //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
        //* Update the serial number of the SOA record
        $soa_id = intval($_POST["zone"]);
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
@@ -154,8 +154,8 @@
        global $app, $conf;
        //* Update the serial number of the SOA record
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = intval($_POST["zone"]);
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
interface/web/dns/dns_txt_edit.php
@@ -76,7 +76,7 @@
        global $app, $conf;
        
        // Get the parent soa record of the domain
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        // Check if Domain belongs to user
        if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"];
@@ -112,11 +112,11 @@
        global $app, $conf;
        
        //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id);
        //* Update the serial number of the SOA record
        $soa_id = intval($_POST["zone"]);
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
@@ -125,8 +125,8 @@
        global $app, $conf;
        
        //* Update the serial number of the SOA record
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = intval($_POST["zone"]);
        $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r'));
        $soa_id = $app->functions->intval($_POST["zone"]);
        $serial = $app->validate_dns->increase_serial($soa["serial"]);
        $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id);
    }
interface/web/dns/dns_wizard.php
@@ -42,12 +42,12 @@
$app->load_language_file('/web/dns/lib/lang/'.$_SESSION['s']['language'].'_dns_wizard.lng');
// import variables
$template_id = (isset($_POST['template_id']))?intval($_POST['template_id']):0;
$sys_groupid = (isset($_POST['client_group_id']))?intval($_POST['client_group_id']):0;
$template_id = (isset($_POST['template_id']))?$app->functions->intval($_POST['template_id']):0;
$sys_groupid = (isset($_POST['client_group_id']))?$app->functions->intval($_POST['client_group_id']):0;
// get the correct server_id
if($_SESSION['s']['user']['typ'] == 'admin') {
    $server_id = (isset($_POST['server_id']))?intval($_POST['server_id']):1;
    $server_id = (isset($_POST['server_id']))?$app->functions->intval($_POST['server_id']):1;
} else {
    $client_group_id = $_SESSION["s"]["user"]["default_group"];
    $client = $app->db->queryOneRecord("SELECT default_dnsserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
@@ -145,9 +145,9 @@
    
    // make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it
    if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($_POST['client_group_id'])) {
        $sys_groupid = intval($_POST['client_group_id']);
        $sys_groupid = $app->functions->intval($_POST['client_group_id']);
    } elseif($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($_POST['client_group_id'])) {
        $sys_groupid = intval($_POST['client_group_id']);
        $sys_groupid = $app->functions->intval($_POST['client_group_id']);
    } else {
        $sys_groupid = $_SESSION["s"]["user"]["default_group"];
    }
interface/web/dns/form/dns_a.tform.php
@@ -32,6 +32,7 @@
*/
global $app;
$form["title"]             = "DNS A";
$form["description"]     = "";
@@ -69,7 +70,7 @@
        'zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["zone"]),
            'default'    => @$app->functions->intval($_REQUEST["zone"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/dns/form/dns_aaaa.tform.php
@@ -32,6 +32,7 @@
*/
global $app;
$form["title"]             = "DNS AAAA";
$form["description"]     = "";
@@ -69,7 +70,7 @@
        'zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["zone"]),
            'default'    => @$app->functions->intval($_REQUEST["zone"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/dns/form/dns_alias.tform.php
@@ -32,6 +32,7 @@
*/
global $app;
$form["title"]             = "DNS ALIAS";
$form["description"]     = "";
@@ -69,7 +70,7 @@
        'zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["zone"]),
            'default'    => @$app->functions->intval($_REQUEST["zone"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/dns/form/dns_cname.tform.php
@@ -32,6 +32,7 @@
*/
global $app;
$form["title"]             = "DNS CNAME";
$form["description"]     = "";
@@ -69,7 +70,7 @@
        'zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["zone"]),
            'default'    => @$app->functions->intval($_REQUEST["zone"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/dns/form/dns_hinfo.tform.php
@@ -32,6 +32,7 @@
*/
global $app;
$form["title"]             = "DNS hinfo";
$form["description"]     = "";
@@ -69,7 +70,7 @@
        'zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["zone"]),
            'default'    => @$app->functions->intval($_REQUEST["zone"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/dns/form/dns_mx.tform.php
@@ -33,6 +33,8 @@
*/
global $app;
$form["title"]             = "DNS mx";
$form["description"]     = "";
$form["name"]             = "dns_mx";
@@ -69,7 +71,7 @@
        'zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["zone"]),
            'default'    => @$app->functions->intval($_REQUEST["zone"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/dns/form/dns_ns.tform.php
@@ -32,6 +32,7 @@
*/
global $app;
$form["title"]             = "DNS ns";
$form["description"]     = "";
@@ -69,7 +70,7 @@
        'zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["zone"]),
            'default'    => @$app->functions->intval($_REQUEST["zone"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/dns/form/dns_ptr.tform.php
@@ -32,6 +32,7 @@
*/
global $app;
$form["title"]             = "DNS ptr";
$form["description"]     = "";
@@ -69,7 +70,7 @@
        'zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["zone"]),
            'default'    => @$app->functions->intval($_REQUEST["zone"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/dns/form/dns_rp.tform.php
@@ -32,6 +32,7 @@
*/
global $app;
$form["title"]             = "DNS RP";
$form["description"]     = "";
@@ -69,7 +70,7 @@
        'zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["zone"]),
            'default'    => @$app->functions->intval($_REQUEST["zone"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/dns/form/dns_soa.tform.php
@@ -37,6 +37,7 @@
*/
global $app;
$form["title"]             = "DNS Zone";
$form["description"]     = "";
@@ -250,7 +251,7 @@
             'class'   => 'plugin_listview',
             'options' => array(
                'listdef' => 'list/dns_a.list.php',
                'sqlextwhere' => "zone = ".@intval(@$_REQUEST['id']),
                'sqlextwhere' => "zone = ".@$app->functions->intval(@$_REQUEST['id']),
                'sql_order_by' => "ORDER BY type, name"
            )
        )
interface/web/dns/form/dns_srv.tform.php
@@ -32,6 +32,7 @@
*/
global $app;
$form["title"]             = "DNS SRV";
$form["description"]     = "";
@@ -69,7 +70,7 @@
        'zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["zone"]),
            'default'    => @$app->functions->intval($_REQUEST["zone"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/dns/form/dns_txt.tform.php
@@ -32,6 +32,7 @@
*/
global $app;
$form["title"]             = "DNS TXT Record";
$form["description"]     = "";
@@ -69,7 +70,7 @@
        'zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["zone"]),
            'default'    => @$app->functions->intval($_REQUEST["zone"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/mail/form/mail_user.tform.php
@@ -37,6 +37,7 @@
*/
global $app;
$form["title"]             = "Mailbox";
$form["description"]     = "";
@@ -280,7 +281,7 @@
             'class'   => 'plugin_listview',
             'options' => array(
                'listdef' => 'list/mail_user_filter.list.php',
                'sqlextwhere' => "mailuser_id = ".@intval(@$_REQUEST['id']),
                'sqlextwhere' => "mailuser_id = ".@$app->functions->intval(@$_REQUEST['id']),
                'sql_order_by' => "ORDER BY rulename"
            )
        )
interface/web/mail/form/mail_user_filter.tform.php
@@ -32,6 +32,7 @@
*/
global $app;
$form["title"]             = "Email filter";
$form["description"]     = "";
@@ -61,7 +62,7 @@
        'mailuser_id' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["mailuser_id"]),
            'default'    => @$app->functions->intval($_REQUEST["mailuser_id"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/mail/mail_domain_edit.php
@@ -189,9 +189,9 @@
        $app->uses('ini_parser,getconf');
        $settings = $app->getconf->get_global_config('domains');
        if ($settings['use_domain_module'] == 'y') {
            $client_group_id = intval($_SESSION["s"]["user"]["default_group"]);
            $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
            
            $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . intval($this->dataRecord['domain']);
            $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . $app->functions->intval($this->dataRecord['domain']);
            if ($_SESSION["s"]["user"]["typ"] != 'admin') {
                $sql .= "AND sys_groupid =" . $client_group_id;
            }
@@ -213,7 +213,7 @@
            // When the record is updated
            if($this->id > 0) {
                // restore the server ID if the user is not admin and record is edited
                $tmp = $app->db->queryOneRecord("SELECT server_id FROM mail_domain WHERE domain_id = ".intval($this->id));
                $tmp = $app->db->queryOneRecord("SELECT server_id FROM mail_domain WHERE domain_id = ".$app->functions->intval($this->id));
                $this->dataRecord["server_id"] = $tmp["server_id"];
                unset($tmp);
                // When the record is inserted
@@ -247,16 +247,16 @@
        // make sure that the record belongs to the client group and not the admin group when a dmin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$this->id);
        }
        // Spamfilter policy
        $policy_id = intval($this->dataRecord["policy"]);
        $policy_id = $app->functions->intval($this->dataRecord["policy"]);
        if($policy_id > 0) {
            $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($this->dataRecord["domain"])."'");
            if($tmp_user["id"] > 0) {
@@ -307,20 +307,20 @@
        // make sure that the record belongs to the client group and not the admin group when admin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $client_group_id");
            $client_user_id = ($tmp['userid'] > 0)?$tmp['userid']:1;
            $app->db->query("UPDATE mail_domain SET sys_userid = $client_user_id, sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $client_group_id");
            $client_user_id = ($tmp['userid'] > 0)?$tmp['userid']:1;
            $app->db->query("UPDATE mail_domain SET sys_userid = $client_user_id, sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$this->id);
        }
        // Spamfilter policy
        $policy_id = intval($this->dataRecord["policy"]);
        $policy_id = $app->functions->intval($this->dataRecord["policy"]);
        $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($this->dataRecord["domain"])."'");
        if($policy_id > 0) {
            if($tmp_user["id"] > 0) {
interface/web/mail/mail_mailinglist_edit.php
@@ -197,11 +197,11 @@
        // make sure that the record belongs to the client group and not the admin group when a dmin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_mailinglist SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE mailinglist_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_mailinglist SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE mailinglist_id = ".$this->id);
        }
    }
@@ -234,11 +234,11 @@
        // make sure that the record belongs to the clinet group and not the admin group when admin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_mailinglist SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE mailinglist_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE mail_mailinglist SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE mailinglist_id = ".$this->id);
        }
    }
interface/web/mail/mail_spamfilter_edit.php
@@ -108,7 +108,7 @@
        $this->dataRecord["spam_delete_score_int"]         = $_POST["spam_delete_score_int"] * 100;
        
        // Changing mailbox_id to maildir
        $sql = "SELECT maildir FROM mail_box WHERE mailbox_id = '".intval($_POST["spam_redirect_maildir"])."' AND ".$app->tform->getAuthSQL('r');
        $sql = "SELECT maildir FROM mail_box WHERE mailbox_id = '".$app->functions->intval($_POST["spam_redirect_maildir"])."' AND ".$app->tform->getAuthSQL('r');
        $mailbox = $app->db->queryOneRecord($sql);
        $this->dataRecord["spam_redirect_maildir"] = $mailbox["maildir"];
        
interface/web/mail/mail_user_edit.php
@@ -159,9 +159,9 @@
            
            // Check the quota and adjust
            if(isset($_POST["quota"]) && $client["limit_mailquota"] >= 0) {
                $tmp = $app->db->queryOneRecord("SELECT sum(quota) as mailquota FROM mail_user WHERE mailuser_id != ".intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                $tmp = $app->db->queryOneRecord("SELECT sum(quota) as mailquota FROM mail_user WHERE mailuser_id != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                $mailquota = $tmp["mailquota"] / 1024 / 1024;
                $new_mailbox_quota = intval($this->dataRecord["quota"]);
                $new_mailbox_quota = $app->functions->intval($this->dataRecord["quota"]);
                if(($mailquota + $new_mailbox_quota > $client["limit_mailquota"]) || ($new_mailbox_quota == 0 && $client["limit_mailquota"] != -1)) {
                    $max_free_quota = $client["limit_mailquota"] - $mailquota;
                    $app->tform->errorMessage .= $app->tform->lng("limit_mailquota_txt").": ".$max_free_quota."<br>";
@@ -229,7 +229,7 @@
        $app->db->query("UPDATE mail_user SET sys_groupid = ".$domain["sys_groupid"]." WHERE mailuser_id = ".$this->id);
        
        // Spamfilter policy
        $policy_id = intval($this->dataRecord["policy"]);
        $policy_id = $app->functions->intval($this->dataRecord["policy"]);
        if($policy_id > 0) {
            $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".$app->db->quote($this->dataRecord["email"])."'");
            if($tmp_user["id"] > 0) {
@@ -265,7 +265,7 @@
            $app->db->query("UPDATE mail_user SET sys_groupid = ".$domain["sys_groupid"]." WHERE mailuser_id = ".$this->id);
        
            // Spamfilter policy
            $policy_id = intval($this->dataRecord["policy"]);
            $policy_id = $app->functions->intval($this->dataRecord["policy"]);
            $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".$app->db->quote($this->dataRecord["email"])."'");
            if($policy_id > 0) {
                if($tmp_user["id"] > 0) {
interface/web/mail/mail_user_filter_edit.php
@@ -70,7 +70,7 @@
        global $app, $conf;
        
        // Get the parent mail_user record
        $mailuser = $app->db->queryOneRecord("SELECT * FROM mail_user WHERE mailuser_id = '".intval($_REQUEST["mailuser_id"])."' AND ".$app->tform->getAuthSQL('r'));
        $mailuser = $app->db->queryOneRecord("SELECT * FROM mail_user WHERE mailuser_id = '".$app->functions->intval($_REQUEST["mailuser_id"])."' AND ".$app->tform->getAuthSQL('r'));
        
        // Check if Domain belongs to user
        if($mailuser["mailuser_id"] != $_POST["mailuser_id"]) $app->tform->errorMessage .= $app->tform->wordbook["no_mailuser_perm"];
@@ -147,8 +147,8 @@
        global $app,$conf;
        
        $app->uses("getconf");
        $mailuser_rec = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE mailuser_id = ".intval($this->dataRecord["mailuser_id"]));
        $mail_config = $app->getconf->get_server_config(intval($mailuser_rec["server_id"]),'mail');
        $mailuser_rec = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE mailuser_id = ".$app->functions->intval($this->dataRecord["mailuser_id"]));
        $mail_config = $app->getconf->get_server_config($app->functions->intval($mailuser_rec["server_id"]),'mail');
        
        if($mail_config['mail_filter_syntax'] == 'sieve') {
            
interface/web/mail/mail_user_stats.php
@@ -33,22 +33,22 @@
        //** Traffic of the current month
        $tmp_date = date('Y-m');
        $tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month = '$tmp_date'");
        $rec['this_month'] = number_format(intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
        $rec['this_month'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
        
        //** Traffic of the current year
        $tmp_date = date('Y');
        $tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month like '$tmp_date%'");
        $rec['this_year'] = number_format(intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
        $rec['this_year'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
        
        //** Traffic of the last month
        $tmp_date = date('Y-m',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
        $tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month = '$tmp_date'");
        $rec['last_month'] = number_format(intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
        $rec['last_month'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
        
        //** Traffic of the last year
        $tmp_date = date('Y',mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
        $tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month like '$tmp_date%'");
        $rec['last_year'] = number_format(intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
        $rec['last_year'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
        
        //* The variable "id" contains always the index variable
        $rec['id'] = $rec[$this->idx_key];
interface/web/mail/mailinglist.php
@@ -38,13 +38,13 @@
if (!isset($_GET['id'])){
    die ("No List selected!");
}
$listId = intval($_GET['id']);
$listId = $app->functions->intval($_GET['id']);
/*
 * Get the data to connect to the database
 */
$dbData = $app->db->queryAllRecords("SELECT server_id, listname FROM mail_mailinglist WHERE mailinglist_id = " . $listId);
$serverId = intval($dbData[0]['server_id']);
$serverId = $app->functions->intval($dbData[0]['server_id']);
if ($serverId == 0){
    die ("No List - Server found!");
}
interface/web/mail/spamfilter_blacklist_edit.php
@@ -103,7 +103,7 @@
        } // end if user is not admin
        
        // Select and set the server_id so it matches the server_id of the spa,filter_users record
        $tmp = $app->db->queryOneRecord("SELECT server_id FROM spamfilter_users WHERE id = ".intval($this->dataRecord["rid"]));
        $tmp = $app->db->queryOneRecord("SELECT server_id FROM spamfilter_users WHERE id = ".$app->functions->intval($this->dataRecord["rid"]));
        $this->dataRecord["server_id"] = $tmp["server_id"];
        unset($tmp);
        
interface/web/mail/spamfilter_whitelist_edit.php
@@ -103,7 +103,7 @@
        } // end if user is not admin
        
        // Select and set the server_id so it matches the server_id of the spa,filter_users record
        $tmp = $app->db->queryOneRecord("SELECT server_id FROM spamfilter_users WHERE id = ".intval($this->dataRecord["rid"]));
        $tmp = $app->db->queryOneRecord("SELECT server_id FROM spamfilter_users WHERE id = ".$app->functions->intval($this->dataRecord["rid"]));
        $this->dataRecord["server_id"] = $tmp["server_id"];
        unset($tmp);
        
interface/web/mail/webmailer.php
@@ -38,13 +38,13 @@
if (!isset($_GET['id'])){
    die ("No E-Mail selected!");
}
$emailId = intval($_GET['id']);
$emailId = $app->functions->intval($_GET['id']);
/*
 * Get the data to connect to the database
 */
$dbData = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE mailuser_id = " . $emailId);
$serverId = intval($dbData['server_id']);
$serverId = $app->functions->intval($dbData['server_id']);
if ($serverId == 0){
    die ("No E-Mail - Server found!");
}
interface/web/mailuser/form/mail_user_filter.tform.php
@@ -33,6 +33,8 @@
*/
global $app;
$form["title"]             = "mailbox_filter_txt";
$form["description"]            = "";
$form["name"]             = "mail_user_filter";
@@ -61,7 +63,7 @@
        'mailuser_id' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'default'    => @intval($_REQUEST["mailuser_id"]),
            'default'    => @$app->functions->intval($_REQUEST["mailuser_id"]),
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
interface/web/mailuser/mail_user_filter_edit.php
@@ -71,7 +71,7 @@
        global $app, $conf;
        
        // Get the parent mail_user record
        $mailuser = $app->db->queryOneRecord("SELECT * FROM mail_user WHERE mailuser_id = '".intval($_SESSION['s']['user']['mailuser_id'])."'");
        $mailuser = $app->db->queryOneRecord("SELECT * FROM mail_user WHERE mailuser_id = '".$app->functions->intval($_SESSION['s']['user']['mailuser_id'])."'");
                
        // Set the mailuser_id
        $this->dataRecord["mailuser_id"] = $mailuser["mailuser_id"];
interface/web/mailuser/mail_user_spamfilter_edit.php
@@ -76,7 +76,7 @@
        $domain = $app->db->queryOneRecord("SELECT sys_userid, sys_groupid, server_id FROM mail_domain WHERE domain = '".$app->db->quote($email_domain)."'");
        
        // Spamfilter policy
        $policy_id = intval($this->dataRecord["policy"]);
        $policy_id = $app->functions->intval($this->dataRecord["policy"]);
        $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".$app->db->quote($rec["email"])."'");
        if($policy_id > 0) {
            if($tmp_user["id"] > 0) {
interface/web/monitor/log_del.php
@@ -34,7 +34,7 @@
//* Check permissions for module
$app->auth->check_module_permissions('monitor');
$syslog_id = intval($_GET['id']);
$syslog_id = $app->functions->intval($_GET['id']);
$app->db->query("UPDATE sys_log SET loglevel = 0 WHERE syslog_id = '$syslog_id'");
header('Location: log_list.php');
interface/web/monitor/show_log.php
@@ -42,7 +42,7 @@
$app->tpl->setInclude('content_tpl','templates/show_log.htm');
// Importing the GET values
$refresh = (isset($_GET["refresh"]))?intval($_GET["refresh"]):0;
$refresh = (isset($_GET["refresh"]))?$app->functions->intval($_GET["refresh"]):0;
$logParam = $_GET["log"];
/* Get some translations */
interface/web/monitor/show_sys_state.php
@@ -76,7 +76,7 @@
 Attention: the core-module ist triggered every 5 minutes,
            so reload every 2 minutes is impossible!
*/
$refresh = (isset($_GET["refresh"]))?intval($_GET["refresh"]):0;
$refresh = (isset($_GET["refresh"]))?$app->functions->intval($_GET["refresh"]):0;
$refresh_values = array('0' => '- '.$app->lng("No Refresh").' -','5' => '5 '.$app->lng("minutes"),'10' => '10 '.$app->lng("minutes"),'15' => '15 '.$app->lng("minutes"),'30' => '30 '.$app->lng("minutes"),'60' => '60 '.$app->lng("minutes"));
$tmp = '';
interface/web/remote/monitor.php
@@ -13,7 +13,7 @@
$type = addslashes($_GET['type']);
$token = addslashes($_GET['token']);
$server_id = intval($_GET['server']);
$server_id = $app->functions->intval($_GET['server']);
$app->uses('getconf');
$interface_config = $app->getconf->get_global_config('misc');
interface/web/sites/ajax_get_ip.php
@@ -35,8 +35,8 @@
$app->auth->check_module_permissions('sites');
$app->uses('getconf');
$server_id = intval($_GET["server_id"]);
$client_group_id = intval($_GET["client_group_id"]);
$server_id = $app->functions->intval($_GET["server_id"]);
$client_group_id = $app->functions->intval($_GET["client_group_id"]);
$ip_type = $app->db->quote($_GET['ip_type']);
if($_SESSION["s"]["user"]["typ"] == 'admin' or $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
interface/web/sites/ajax_get_json.php
@@ -36,8 +36,8 @@
$app->uses('getconf');
$server_id = intval($_GET["server_id"]);
$web_id = intval($_GET["web_id"]);
$server_id = $app->functions->intval($_GET["server_id"]);
$web_id = $app->functions->intval($_GET["web_id"]);
$php_type = $_GET["php_type"];
$type = $_GET["type"];
@@ -104,7 +104,7 @@
        $result = array();
        
        // ipv4
        //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".intval($_SESSION['s']['user']['client_id']).")");
        //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")");
        $result[] = $app->functions->suggest_ips('IPv4');
        $json = $app->functions->json_encode($result);
@@ -114,7 +114,7 @@
        $result = array();
        
        // ipv6
        //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".intval($_SESSION['s']['user']['client_id']).")");
        //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")");
        $result[] = $app->functions->suggest_ips('IPv6');
        
        $json = $app->functions->json_encode($result);
interface/web/sites/aps_do_operation.php
@@ -50,15 +50,15 @@
    if(!$gui->isValidPackageID($_GET['id'], true)) die($app->lng('Invalid ID'));
    
    // Change the existing status to the opposite
    $get_status = $app->db->queryOneRecord("SELECT package_status FROM aps_packages WHERE id = '".intval($_GET['id'])."';");
    $get_status = $app->db->queryOneRecord("SELECT package_status FROM aps_packages WHERE id = '".$app->functions->intval($_GET['id'])."';");
    if($get_status['package_status'] == strval(PACKAGE_LOCKED))
    {
        $app->db->query("UPDATE aps_packages SET package_status = ".PACKAGE_ENABLED." WHERE id = '".intval($_GET['id'])."';");
        $app->db->query("UPDATE aps_packages SET package_status = ".PACKAGE_ENABLED." WHERE id = '".$app->functions->intval($_GET['id'])."';");
        echo '<div class="swap" id="ir-Yes"><span>'.$app->lng('Yes').'</span></div>';
    }
    else
    {
        $app->db->query("UPDATE aps_packages SET Package_status = ".PACKAGE_LOCKED." WHERE id = '".intval($_GET['id'])."';");
        $app->db->query("UPDATE aps_packages SET Package_status = ".PACKAGE_LOCKED." WHERE id = '".$app->functions->intval($_GET['id'])."';");
        echo '<div class="swap" id="ir-No"><span>'.$app->lng('No').'</span></div>';
    }
}
interface/web/sites/cron_edit.php
@@ -104,7 +104,7 @@
        }
        
        // Get the record of the parent domain
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval(@$this->dataRecord["parent_domain_id"]));
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]));
        
        // Set fixed values
        $this->dataRecord["server_id"] = $parent_domain["server_id"];
@@ -114,7 +114,7 @@
        if(preg_match("'^http(s)?:\/\/'i", $command)) {
            $this->dataRecord["type"] = 'url';
        } else {
            $domain_owner = $app->db->queryOneRecord("SELECT limit_cron_type FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ".intval($parent_domain["sys_groupid"]));
            $domain_owner = $app->db->queryOneRecord("SELECT limit_cron_type FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ".$app->functions->intval($parent_domain["sys_groupid"]));
            if($domain_owner["limit_cron_type"] == 'full') $this->dataRecord["type"] = 'full';
            else $this->dataRecord["type"] = 'chrooted';
        }
@@ -176,7 +176,7 @@
    function onAfterInsert() {
        global $app, $conf;
        
        $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"]));
        $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
        $server_id = $web["server_id"];
        
        // The cron shall be owned by the same group then the website
interface/web/sites/database_edit.php
@@ -148,7 +148,7 @@
            // When the record is updated
            if($this->id > 0) {
                // restore the server ID if the user is not admin and record is edited
                $tmp = $app->db->queryOneRecord("SELECT server_id FROM web_database WHERE database_id = ".intval($this->id));
                $tmp = $app->db->queryOneRecord("SELECT server_id FROM web_database WHERE database_id = ".$app->functions->intval($this->id));
                $this->dataRecord["server_id"] = $tmp["server_id"];
                unset($tmp);
                // When the record is inserted
@@ -321,7 +321,7 @@
        global $app, $conf;
        
        if($this->dataRecord["parent_domain_id"] > 0) {
            $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"]));
            $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
        
            //* The Database user shall be owned by the same group then the website
            $sys_groupid = $web['sys_groupid'];
@@ -337,7 +337,7 @@
        global $app, $conf;
        if($this->dataRecord["parent_domain_id"] > 0) {
            $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"]));
            $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
        
            //* The Database user shall be owned by the same group then the website
            $sys_groupid = $web['sys_groupid'];
interface/web/sites/database_phpmyadmin.php
@@ -40,13 +40,13 @@
if (!isset($_GET['id'])){
    die ("No DB selected!");
}
$databaseId = intval($_GET['id']);
$databaseId = $app->functions->intval($_GET['id']);
/*
 * Get the data to connect to the database
 */
$dbData = $app->db->queryOneRecord("SELECT server_id FROM web_database WHERE database_id = " . $databaseId);
$serverId = intval($dbData['server_id']);
$serverId = $app->functions->intval($dbData['server_id']);
if ($serverId == 0){
    die ("No DB-Server found!");
}
interface/web/sites/database_user_del.php
@@ -60,12 +60,12 @@
        global $app; $conf;
        
        //* Update all records that belog to this user
        $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_user_id = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_user_id = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            $app->db->datalogUpdate('web_database','database_user_id=NULL','database_id', $rec['database_id']);
            
        }
        $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_ro_user_id = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_ro_user_id = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            $app->db->datalogUpdate('web_database','database_ro_user_id=NULL','database_id', $rec['database_id']);
        }
interface/web/sites/database_user_edit.php
@@ -184,11 +184,11 @@
        global $app, $conf;
        
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE web_database_user SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE database_user_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE web_database_user SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE database_user_id = ".$this->id);
        }
    }
@@ -197,17 +197,17 @@
        global $app, $conf;
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE web_database_user SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE database_user_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE web_database_user SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE database_user_id = ".$this->id);
        }
        
        $old_rec = $app->db->queryOneRecord("SELECT * FROM web_database_user WHERE database_user_id = '".$this->id."'");
        
        $records = $app->db->queryAllRecords("SELECT DISTINCT server_id FROM web_database WHERE database_user_id = '".intval($this->id)."' UNION SELECT DISTINCT server_id FROM web_database WHERE database_ro_user_id = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT DISTINCT server_id FROM web_database WHERE database_user_id = '".$app->functions->intval($this->id)."' UNION SELECT DISTINCT server_id FROM web_database WHERE database_ro_user_id = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            $new_rec = $this->dataRecord;
            $new_rec['server_id'] = $rec['server_id'];
interface/web/sites/ftp_user_edit.php
@@ -95,7 +95,7 @@
        global $app, $conf;
        
        // Get the record of the parent domain
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval(@$this->dataRecord["parent_domain_id"]));
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]));
        
        // Set a few fixed values
        $this->dataRecord["server_id"] = $parent_domain["server_id"];
@@ -127,7 +127,7 @@
        function onAfterInsert() {
        global $app, $conf;
        
        $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"]));
        $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
        $server_id = $web["server_id"];
        $dir = $web["document_root"];
        $uid = $web["system_user"];
@@ -162,7 +162,7 @@
        
        //* When the site of the FTP user has been changed
        if(isset($this->dataRecord['parent_domain_id']) && $this->oldDataRecord['parent_domain_id'] != $this->dataRecord['parent_domain_id']) {
            $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"]));
            $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
            $server_id = $web["server_id"];
            $dir = $web["document_root"];
            $uid = $web["system_user"];
interface/web/sites/shell_user_edit.php
@@ -102,7 +102,7 @@
        global $app, $conf;
        
        // Get the record of the parent domain
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval(@$this->dataRecord["parent_domain_id"]));
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]));
        
        // Set a few fixed values
        $this->dataRecord["server_id"] = $parent_domain["server_id"];
@@ -147,7 +147,7 @@
    function onAfterInsert() {
        global $app, $conf;
        
        $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"]));
        $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
        $server_id = $web["server_id"];
        $dir = $web["document_root"];
        $puser = $web["system_user"];
interface/web/sites/web_aliasdomain_edit.php
@@ -124,9 +124,9 @@
        $app->uses('ini_parser,getconf');
        $settings = $app->getconf->get_global_config('domains');
        if ($settings['use_domain_module'] == 'y') {
            $client_group_id = intval($_SESSION["s"]["user"]["default_group"]);
            $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
            
            $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . intval($this->dataRecord['domain']);
            $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . $app->functions->intval($this->dataRecord['domain']);
            if ($_SESSION["s"]["user"]["typ"] != 'admin') {
                $sql .= "AND sys_groupid =" . $client_group_id;
            }
@@ -140,7 +140,7 @@
        }
        
        // Get the record of the parent domain
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval(@$this->dataRecord["parent_domain_id"]));
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]));
        
        // Set a few fixed values
        $this->dataRecord["type"] = 'alias';
@@ -158,7 +158,7 @@
    function onAfterInsert() {
        global $app, $conf;
        
        $app->db->query('UPDATE web_domain SET sys_groupid = '.intval($this->parent_domain_record['sys_groupid']).' WHERE domain_id = '.$this->id);
        $app->db->query('UPDATE web_domain SET sys_groupid = '.$app->functions->intval($this->parent_domain_record['sys_groupid']).' WHERE domain_id = '.$this->id);
        
    }
    
@@ -169,7 +169,7 @@
        if($this->dataRecord['parent_domain_id'] != $this->oldDataRecord['parent_domain_id']) {
            
            //* Update the domain owner
            $app->db->query('UPDATE web_domain SET sys_groupid = '.intval($this->parent_domain_record['sys_groupid']).' WHERE domain_id = '.$this->id);
            $app->db->query('UPDATE web_domain SET sys_groupid = '.$app->functions->intval($this->parent_domain_record['sys_groupid']).' WHERE domain_id = '.$this->id);
            
            //* Update the old website, so that the vhost alias gets removed
            //* We force the update by inserting a transaction record without changes manually.
interface/web/sites/web_domain_del.php
@@ -56,49 +56,49 @@
        if($app->tform->checkPerm($this->id,'d') == false) $app->error($app->lng('error_no_delete_permission'));
        
        //* Delete all records that belog to this zone.
        $records = $app->db->queryAllRecords("SELECT domain_id FROM web_domain WHERE parent_domain_id = '".intval($this->id)."' AND type != 'vhost'");
        $records = $app->db->queryAllRecords("SELECT domain_id FROM web_domain WHERE parent_domain_id = '".$app->functions->intval($this->id)."' AND type != 'vhost'");
        foreach($records as $rec) {
            $app->db->datalogDelete('web_domain','domain_id',$rec['domain_id']);
        }
        
        //* Delete all records that belog to this zone.
        $records = $app->db->queryAllRecords("SELECT ftp_user_id FROM ftp_user WHERE parent_domain_id = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT ftp_user_id FROM ftp_user WHERE parent_domain_id = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('ftp_user','ftp_user_id',$rec['ftp_user_id']);
        }
        
        //* Delete all records that belog to this web.
        $records = $app->db->queryAllRecords("SELECT shell_user_id FROM shell_user WHERE parent_domain_id = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT shell_user_id FROM shell_user WHERE parent_domain_id = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('shell_user','shell_user_id',$rec['shell_user_id']);
        }
        
        //* Delete all records that belog to this web.
        $records = $app->db->queryAllRecords("SELECT id FROM cron WHERE parent_domain_id = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT id FROM cron WHERE parent_domain_id = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('cron','id',$rec['id']);
        }
        
        //* Delete all records that belog to this web.
        $records = $app->db->queryAllRecords("SELECT id FROM cron WHERE parent_domain_id = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT id FROM cron WHERE parent_domain_id = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('cron','id',$rec['id']);
        }
        
        //* Delete all records that belog to this web
        $records = $app->db->queryAllRecords("SELECT webdav_user_id FROM webdav_user WHERE parent_domain_id = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT webdav_user_id FROM webdav_user WHERE parent_domain_id = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('webdav_user','webdav_user_id',$rec['webdav_user_id']);
        }
        
        //* Delete all records that belog to this web
        $records = $app->db->queryAllRecords("SELECT backup_id FROM web_backup WHERE parent_domain_id = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT backup_id FROM web_backup WHERE parent_domain_id = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('web_backup','backup_id',$rec['backup_id']);
        }
        
        //* Delete all web folders
        $records = $app->db->queryAllRecords("SELECT web_folder_id FROM web_folder WHERE parent_domain_id = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT web_folder_id FROM web_folder WHERE parent_domain_id = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            //* Delete all web folder users
            $records2 = $app->db->queryAllRecords("SELECT web_folder_user_id FROM web_folder_user WHERE web_folder_id = '".$rec['web_folder_id']."'");
interface/web/sites/web_domain_edit.php
@@ -259,7 +259,7 @@
            // The user is admin, so we fill in all IP addresses of the server
            if($this->id > 0) {
                if(!isset($this->dataRecord["server_id"])){
                    $tmp = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ".intval($this->id));
                    $tmp = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ".$app->functions->intval($this->id));
                    $this->dataRecord["server_id"] = $tmp["server_id"];
                    unset($tmp);
                }
@@ -463,9 +463,9 @@
            $app->uses('ini_parser,getconf');
            $settings = $app->getconf->get_global_config('domains');
            if ($settings['use_domain_module'] == 'y') {
                $client_group_id = intval($_SESSION["s"]["user"]["default_group"]);
                $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
                
                $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . intval($this->dataRecord['domain']);
                $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . $app->functions->intval($this->dataRecord['domain']);
                if ($_SESSION["s"]["user"]["typ"] != 'admin') {
                    $sql .= "AND sys_groupid =" . $client_group_id;
                }
@@ -504,9 +504,9 @@
            
            //* Check the website quota of the client
            if(isset($_POST["hd_quota"]) && $client["limit_web_quota"] >= 0) {
                $tmp = $app->db->queryOneRecord("SELECT sum(hd_quota) as webquota FROM web_domain WHERE domain_id != ".intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                $tmp = $app->db->queryOneRecord("SELECT sum(hd_quota) as webquota FROM web_domain WHERE domain_id != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                $webquota = $tmp["webquota"];
                $new_web_quota = intval($this->dataRecord["hd_quota"]);
                $new_web_quota = $app->functions->intval($this->dataRecord["hd_quota"]);
                if(($webquota + $new_web_quota > $client["limit_web_quota"]) || ($new_web_quota < 0 && $client["limit_web_quota"] >= 0)) {
                    $max_free_quota = floor($client["limit_web_quota"] - $webquota);
                    if($max_free_quota < 0) $max_free_quota = 0;
@@ -520,9 +520,9 @@
            //* Check the traffic quota of the client
            if(isset($_POST["traffic_quota"]) && $client["limit_traffic_quota"] > 0) {
                $tmp = $app->db->queryOneRecord("SELECT sum(traffic_quota) as trafficquota FROM web_domain WHERE domain_id != ".intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                $tmp = $app->db->queryOneRecord("SELECT sum(traffic_quota) as trafficquota FROM web_domain WHERE domain_id != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                $trafficquota = $tmp["trafficquota"];
                $new_traffic_quota = intval($this->dataRecord["traffic_quota"]);
                $new_traffic_quota = $app->functions->intval($this->dataRecord["traffic_quota"]);
                if(($trafficquota + $new_traffic_quota > $client["limit_traffic_quota"]) || ($new_traffic_quota < 0 && $client["limit_traffic_quota"] >= 0)) {
                    $max_free_quota = floor($client["limit_traffic_quota"] - $trafficquota);
                    if($max_free_quota < 0) $max_free_quota = 0;
@@ -540,9 +540,9 @@
                //* Check the website quota of the client
                if(isset($_POST["hd_quota"]) && $reseller["limit_web_quota"] >= 0) {
                    $tmp = $app->db->queryOneRecord("SELECT sum(hd_quota) as webquota FROM web_domain WHERE domain_id != ".intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                    $tmp = $app->db->queryOneRecord("SELECT sum(hd_quota) as webquota FROM web_domain WHERE domain_id != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                    $webquota = $tmp["webquota"];
                    $new_web_quota = intval($this->dataRecord["hd_quota"]);
                    $new_web_quota = $app->functions->intval($this->dataRecord["hd_quota"]);
                    if(($webquota + $new_web_quota > $reseller["limit_web_quota"]) || ($new_web_quota < 0 && $reseller["limit_web_quota"] >= 0)) {
                        $max_free_quota = floor($reseller["limit_web_quota"] - $webquota);
                        if($max_free_quota < 0) $max_free_quota = 0;
@@ -556,9 +556,9 @@
                //* Check the traffic quota of the client
                if(isset($_POST["traffic_quota"]) && $reseller["limit_traffic_quota"] > 0) {
                    $tmp = $app->db->queryOneRecord("SELECT sum(traffic_quota) as trafficquota FROM web_domain WHERE domain_id != ".intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                    $tmp = $app->db->queryOneRecord("SELECT sum(traffic_quota) as trafficquota FROM web_domain WHERE domain_id != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                    $trafficquota = $tmp["trafficquota"];
                    $new_traffic_quota = intval($this->dataRecord["traffic_quota"]);
                    $new_traffic_quota = $app->functions->intval($this->dataRecord["traffic_quota"]);
                    if(($trafficquota + $new_traffic_quota > $reseller["limit_traffic_quota"]) || ($new_traffic_quota < 0 && $reseller["limit_traffic_quota"] >= 0)) {
                        $max_free_quota = floor($reseller["limit_traffic_quota"] - $trafficquota);
                        if($max_free_quota < 0) $max_free_quota = 0;
@@ -574,7 +574,7 @@
            // When the record is updated
            if($this->id > 0) {
                // restore the server ID if the user is not admin and record is edited
                $tmp = $app->db->queryOneRecord("SELECT server_id, `cgi`, `ssi`, `perl`, `ruby`, `python`, `suexec`, `errordocs`, `subdomain`, `ssl` FROM web_domain WHERE domain_id = ".intval($this->id));
                $tmp = $app->db->queryOneRecord("SELECT server_id, `cgi`, `ssi`, `perl`, `ruby`, `python`, `suexec`, `errordocs`, `subdomain`, `ssl` FROM web_domain WHERE domain_id = ".$app->functions->intval($this->id));
                $this->dataRecord["server_id"] = $tmp["server_id"];
                
                // set the settings to current if not provided (or cleared due to limits)
@@ -613,7 +613,7 @@
        
        //* get the server config for this server
        $app->uses("getconf");
        $web_config = $app->getconf->get_server_config(intval(isset($this->dataRecord["server_id"]) ? $this->dataRecord["server_id"] : 0),'web');
        $web_config = $app->getconf->get_server_config($app->functions->intval(isset($this->dataRecord["server_id"]) ? $this->dataRecord["server_id"] : 0),'web');
        //* Check for duplicate ssl certs per IP if SNI is disabled
        if(isset($this->dataRecord['ssl']) && $this->dataRecord['ssl'] == 'y' && $web_config['enable_sni'] != 'y') {
            $sql = "SELECT count(domain_id) as number FROM web_domain WHERE `ssl` = 'y' AND ip_address = '".$app->db->quote($this->dataRecord['ip_address'])."' and domain_id != ".$this->id;
@@ -623,7 +623,7 @@
        
        // Check if pm.max_children >= pm.max_spare_servers >= pm.start_servers >= pm.min_spare_servers > 0
        if(isset($this->dataRecord['pm_max_children']) && $this->dataRecord['pm'] == 'dynamic') {
            if(intval($this->dataRecord['pm_max_children']) >= intval($this->dataRecord['pm_max_spare_servers']) && intval($this->dataRecord['pm_max_spare_servers']) >= intval($this->dataRecord['pm_start_servers']) && intval($this->dataRecord['pm_start_servers']) >= intval($this->dataRecord['pm_min_spare_servers']) && intval($this->dataRecord['pm_min_spare_servers']) > 0){
            if($app->functions->intval($this->dataRecord['pm_max_children'], true) >= $app->functions->intval($this->dataRecord['pm_max_spare_servers'], true) && $app->functions->intval($this->dataRecord['pm_max_spare_servers'], true) >= $app->functions->intval($this->dataRecord['pm_start_servers'], true) && $app->functions->intval($this->dataRecord['pm_start_servers'], true) >= $app->functions->intval($this->dataRecord['pm_min_spare_servers'], true) && $app->functions->intval($this->dataRecord['pm_min_spare_servers'], true) > 0){
        
            } else {
                $app->tform->errorMessage .= $app->tform->lng("error_php_fpm_pm_settings_txt").'<br>';
@@ -639,18 +639,18 @@
        // make sure that the record belongs to the clinet group and not the admin group when admin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$this->id);
        }
        // Get configuration for the web system
        $app->uses("getconf");
        $web_rec = $app->tform->getDataRecord($this->id);
        $web_config = $app->getconf->get_server_config(intval($web_rec["server_id"]),'web');
        $web_config = $app->getconf->get_server_config($app->functions->intval($web_rec["server_id"]),'web');
        $document_root = str_replace("[website_id]",$this->id,$web_config["website_path"]);
        $document_root = str_replace("[website_idhash_1]",$this->id_hash($page_form->id,1),$document_root);
        $document_root = str_replace("[website_idhash_2]",$this->id_hash($page_form->id,1),$document_root);
@@ -661,11 +661,11 @@
        if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = $client_group_id");
            $client_id = intval($client["client_id"]);
            $client_id = $app->functions->intval($client["client_id"]);
        } else {
            //$client_id = intval($this->dataRecord["client_group_id"]);
            $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($this->dataRecord["client_group_id"]));
            $client_id = intval($client["client_id"]);
            //$client_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".$app->functions->intval($this->dataRecord["client_group_id"]));
            $client_id = $app->functions->intval($client["client_id"]);
        }
        // Set the values for document_root, system_user and system_group
@@ -739,18 +739,18 @@
        // make sure that the record belongs to the client group and not the admin group when a admin inserts it
        // also make sure that the user can not delete domain created by a admin
        if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id);
        }
        if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
            $client_group_id = intval($this->dataRecord["client_group_id"]);
            $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]);
            $app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$this->id);
        }
        // Get configuration for the web system
        $app->uses("getconf");
        $web_rec = $app->tform->getDataRecord($this->id);
        $web_config = $app->getconf->get_server_config(intval($web_rec["server_id"]),'web');
        $web_config = $app->getconf->get_server_config($app->functions->intval($web_rec["server_id"]),'web');
        $document_root = str_replace("[website_id]",$this->id,$web_config["website_path"]);
        $page_formid = isset($page_form->id) ? $page_form->id : '';
        $document_root = str_replace("[website_idhash_1]",$this->id_hash($page_formid,1),$document_root);
@@ -762,15 +762,15 @@
        if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
            $client_group_id = $_SESSION["s"]["user"]["default_group"];
            $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = $client_group_id");
            $client_id = intval($client["client_id"]);
            $client_id = $app->functions->intval($client["client_id"]);
        } elseif (isset($this->dataRecord["client_group_id"])) {
            $client_group_id = $this->dataRecord["client_group_id"];
            $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval(@$this->dataRecord["client_group_id"]));
            $client_id = intval($client["client_id"]);
            $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".$app->functions->intval(@$this->dataRecord["client_group_id"]));
            $client_id = $app->functions->intval($client["client_id"]);
        } else {
            $client_group_id = $web_rec['sys_groupid'];
            $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($client_group_id));
            $client_id = intval($client["client_id"]);
            $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".$app->functions->intval($client_group_id));
            $client_id = $app->functions->intval($client["client_id"]);
        }
        if(($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) &&  isset($this->dataRecord["client_group_id"]) && $this->dataRecord["client_group_id"] != $this->oldDataRecord["sys_groupid"]) {
interface/web/sites/web_folder_del.php
@@ -56,7 +56,7 @@
        if($app->tform->checkPerm($this->id,'d') == false) $app->error($app->lng('error_no_delete_permission'));
        
        // Delete all users that belong to this folder.
        $records = $app->db->queryAllRecords("SELECT web_folder_user_id FROM web_folder_user WHERE web_folder_id = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT web_folder_user_id FROM web_folder_user WHERE web_folder_id = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            $app->db->datalogDelete('web_folder_user','web_folder_user_id',$rec['web_folder_user_id']);
        }
interface/web/sites/web_folder_edit.php
@@ -55,7 +55,7 @@
        global $app, $conf;
        
        // Get the record of the parent domain
        $parent_domain = $app->db->queryOneRecord("select server_id FROM web_domain WHERE domain_id = ".intval(@$this->dataRecord["parent_domain_id"]));
        $parent_domain = $app->db->queryOneRecord("select server_id FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]));
        
        // Set a few fixed values
        $this->dataRecord["server_id"] = $parent_domain["server_id"];
interface/web/sites/web_folder_user_edit.php
@@ -55,7 +55,7 @@
        global $app, $conf;
        
        // Get the record of the parent domain
        $folder = $app->db->queryOneRecord("select server_id FROM web_folder WHERE web_folder_id = ".intval(@$this->dataRecord["web_folder_id"]));
        $folder = $app->db->queryOneRecord("select server_id FROM web_folder WHERE web_folder_id = ".$app->functions->intval(@$this->dataRecord["web_folder_id"]));
        
        // Set a few fixed values
        $this->dataRecord["server_id"] = $folder["server_id"];
interface/web/sites/web_sites_stats.php
@@ -70,10 +70,10 @@
    {
        global $app;
        
        $app->tpl->setVar('sum_this_month',number_format(intval($this->sum_this_month), 0, '.', ' '));
        $app->tpl->setVar('sum_this_year',number_format(intval($this->sum_this_year), 0, '.', ' '));
        $app->tpl->setVar('sum_last_month',number_format(intval($this->sum_last_month), 0, '.', ' '));
        $app->tpl->setVar('sum_last_year',number_format(intval($this->sum_last_year), 0, '.', ' '));
        $app->tpl->setVar('sum_this_month',number_format($app->functions->intval($this->sum_this_month), 0, '.', ' '));
        $app->tpl->setVar('sum_this_year',number_format($app->functions->intval($this->sum_this_year), 0, '.', ' '));
        $app->tpl->setVar('sum_last_month',number_format($app->functions->intval($this->sum_last_month), 0, '.', ' '));
        $app->tpl->setVar('sum_last_year',number_format($app->functions->intval($this->sum_last_year), 0, '.', ' '));
        $app->tpl->setVar('sum_txt',$app->listform->lng('sum_txt'));
        
        $app->tpl_defaults();
interface/web/sites/web_subdomain_edit.php
@@ -113,7 +113,7 @@
        } else {
        
            // Get the record of the parent domain
            $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval(@$this->dataRecord["parent_domain_id"]));
            $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]));
            
            // remove the parent domain part of the domain name before we show it in the text field.
            $this->dataRecord["domain"] = str_replace('.'.$parent_domain["domain"],'',$this->dataRecord["domain"]);
@@ -128,13 +128,13 @@
        global $app, $conf;
        
        // Get the record of the parent domain
        $parent_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval(@$this->dataRecord["parent_domain_id"]));
        $parent_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]));
        
        $app->uses('ini_parser,getconf');
        $settings = $app->getconf->get_global_config('domains');
        if ($settings['use_domain_module'] == 'y') {
            // get the record of the domain module domain
            $domain = $app->db->queryOneRecord("SELECT * FROM domain WHERE domain_id = ".intval($this->dataRecord["sel_domain"]));
            $domain = $app->db->queryOneRecord("SELECT * FROM domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["sel_domain"]));
            if(!$domain) {
                $app->tform->errorMessage .= $app->tform->lng("domain_error_empty")."<br />";
            } else {
@@ -159,7 +159,7 @@
    function onAfterInsert() {
        global $app, $conf;
        
        $app->db->query('UPDATE web_domain SET sys_groupid = '.intval($this->parent_domain_record['sys_groupid']).' WHERE domain_id = '.$this->id);
        $app->db->query('UPDATE web_domain SET sys_groupid = '.$app->functions->intval($this->parent_domain_record['sys_groupid']).' WHERE domain_id = '.$this->id);
        
    }
    
@@ -170,7 +170,7 @@
        if($this->dataRecord['parent_domain_id'] != $this->oldDataRecord['parent_domain_id']) {
            
            //* Update the domain owner
            $app->db->query('UPDATE web_domain SET sys_groupid = '.intval($this->parent_domain_record['sys_groupid']).' WHERE domain_id = '.$this->id);
            $app->db->query('UPDATE web_domain SET sys_groupid = '.$app->functions->intval($this->parent_domain_record['sys_groupid']).' WHERE domain_id = '.$this->id);
            
            //* Update the old website, so that the vhost alias gets removed
            //* We force the update by inserting a transaction record without changes manually.
interface/web/sites/web_vhost_subdomain_del.php
@@ -53,7 +53,7 @@
        global $app; $conf;
        
        //* Delete all web folders
        $records = $app->db->queryAllRecords("SELECT web_folder_id FROM web_folder WHERE parent_domain_id = '".intval($this->id)."'");
        $records = $app->db->queryAllRecords("SELECT web_folder_id FROM web_folder WHERE parent_domain_id = '".$app->functions->intval($this->id)."'");
        foreach($records as $rec) {
            //* Delete all web folder users
            $records2 = $app->db->queryAllRecords("SELECT web_folder_user_id FROM web_folder_user WHERE web_folder_id = '".$rec['web_folder_id']."'");
interface/web/sites/web_vhost_subdomain_edit.php
@@ -85,7 +85,7 @@
        $read_limits = array('limit_cgi', 'limit_ssi', 'limit_perl', 'limit_ruby', 'limit_python', 'force_suexec', 'limit_hterror', 'limit_wildcard', 'limit_ssl');
        
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval(@$this->dataRecord["parent_domain_id"]));
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]));
        
        //* Client: If the logged in user is not admin and has no sub clients (no reseller)
        if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
@@ -279,7 +279,7 @@
        global $app, $conf;
        // Get the record of the parent domain
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval(@$this->dataRecord["parent_domain_id"]));
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]));
        // Set a few fixed values
        $this->dataRecord["type"] = 'vhostsubdomain';
@@ -300,9 +300,9 @@
            $app->uses('ini_parser,getconf');
            $settings = $app->getconf->get_global_config('domains');
            if ($settings['use_domain_module'] == 'y') {
                $client_group_id = intval($_SESSION["s"]["user"]["default_group"]);
                $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
                
                $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . intval($this->dataRecord['sel_domain']);
                $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . $app->functions->intval($this->dataRecord['sel_domain']);
                if ($_SESSION["s"]["user"]["typ"] != 'admin') {
                    $sql .= "AND sys_groupid =" . $client_group_id;
                }
@@ -324,7 +324,7 @@
                $app->tform->errorMessage .= $app->tform->lng("web_folder_invalid_txt")."<br>";
            }
            // check for duplicate folder usage
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'vhostsubdomain' AND `parent_domain_id` = '" . intval($this->dataRecord['parent_domain_id']) . "' AND `web_folder` = '" . $app->db->quote($this->dataRecord['web_folder']) . "' AND `domain_id` != '" . intval($this->id) . "'");
            $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'vhostsubdomain' AND `parent_domain_id` = '" . $app->functions->intval($this->dataRecord['parent_domain_id']) . "' AND `web_folder` = '" . $app->db->quote($this->dataRecord['web_folder']) . "' AND `domain_id` != '" . $app->functions->intval($this->id) . "'");
            if($check && $check['cnt'] > 0) {
                $app->tform->errorMessage .= $app->tform->lng("web_folder_unique_txt")."<br>";
            }
@@ -347,9 +347,9 @@
            
            //* Check the website quota of the client
            if(isset($_POST["hd_quota"]) && $client["limit_web_quota"] >= 0) {
                $tmp = $app->db->queryOneRecord("SELECT sum(hd_quota) as webquota FROM web_domain WHERE domain_id != ".intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                $tmp = $app->db->queryOneRecord("SELECT sum(hd_quota) as webquota FROM web_domain WHERE domain_id != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                $webquota = $tmp["webquota"];
                $new_web_quota = intval($this->dataRecord["hd_quota"]);
                $new_web_quota = $app->functions->intval($this->dataRecord["hd_quota"]);
                if(($webquota + $new_web_quota > $client["limit_web_quota"]) || ($new_web_quota < 0 && $client["limit_web_quota"] >= 0)) {
                    $max_free_quota = floor($client["limit_web_quota"] - $webquota);
                    if($max_free_quota < 0) $max_free_quota = 0;
@@ -363,9 +363,9 @@
            //* Check the traffic quota of the client
            if(isset($_POST["traffic_quota"]) && $client["limit_traffic_quota"] > 0) {
                $tmp = $app->db->queryOneRecord("SELECT sum(traffic_quota) as trafficquota FROM web_domain WHERE domain_id != ".intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                $tmp = $app->db->queryOneRecord("SELECT sum(traffic_quota) as trafficquota FROM web_domain WHERE domain_id != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                $trafficquota = $tmp["trafficquota"];
                $new_traffic_quota = intval($this->dataRecord["traffic_quota"]);
                $new_traffic_quota = $app->functions->intval($this->dataRecord["traffic_quota"]);
                if(($trafficquota + $new_traffic_quota > $client["limit_traffic_quota"]) || ($new_traffic_quota < 0 && $client["limit_traffic_quota"] >= 0)) {
                    $max_free_quota = floor($client["limit_traffic_quota"] - $trafficquota);
                    if($max_free_quota < 0) $max_free_quota = 0;
@@ -383,9 +383,9 @@
                //* Check the website quota of the client
                if(isset($_POST["hd_quota"]) && $reseller["limit_web_quota"] >= 0) {
                    $tmp = $app->db->queryOneRecord("SELECT sum(hd_quota) as webquota FROM web_domain WHERE domain_id != ".intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                    $tmp = $app->db->queryOneRecord("SELECT sum(hd_quota) as webquota FROM web_domain WHERE domain_id != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                    $webquota = $tmp["webquota"];
                    $new_web_quota = intval($this->dataRecord["hd_quota"]);
                    $new_web_quota = $app->functions->intval($this->dataRecord["hd_quota"]);
                    if(($webquota + $new_web_quota > $reseller["limit_web_quota"]) || ($new_web_quota < 0 && $reseller["limit_web_quota"] >= 0)) {
                        $max_free_quota = floor($reseller["limit_web_quota"] - $webquota);
                        if($max_free_quota < 0) $max_free_quota = 0;
@@ -399,9 +399,9 @@
                //* Check the traffic quota of the client
                if(isset($_POST["traffic_quota"]) && $reseller["limit_traffic_quota"] > 0) {
                    $tmp = $app->db->queryOneRecord("SELECT sum(traffic_quota) as trafficquota FROM web_domain WHERE domain_id != ".intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                    $tmp = $app->db->queryOneRecord("SELECT sum(traffic_quota) as trafficquota FROM web_domain WHERE domain_id != ".$app->functions->intval($this->id)." AND ".$app->tform->getAuthSQL('u'));
                    $trafficquota = $tmp["trafficquota"];
                    $new_traffic_quota = intval($this->dataRecord["traffic_quota"]);
                    $new_traffic_quota = $app->functions->intval($this->dataRecord["traffic_quota"]);
                    if(($trafficquota + $new_traffic_quota > $reseller["limit_traffic_quota"]) || ($new_traffic_quota < 0 && $reseller["limit_traffic_quota"] >= 0)) {
                        $max_free_quota = floor($reseller["limit_traffic_quota"] - $trafficquota);
                        if($max_free_quota < 0) $max_free_quota = 0;
@@ -417,7 +417,7 @@
            // When the record is updated
            if($this->id > 0) {
                // restore the server ID if the user is not admin and record is edited
                $tmp = $app->db->queryOneRecord("SELECT server_id, `web_folder`, `cgi`, `ssi`, `perl`, `ruby`, `python`, `suexec`, `errordocs`, `subdomain`, `ssl` FROM web_domain WHERE domain_id = ".intval($this->id));
                $tmp = $app->db->queryOneRecord("SELECT server_id, `web_folder`, `cgi`, `ssi`, `perl`, `ruby`, `python`, `suexec`, `errordocs`, `subdomain`, `ssl` FROM web_domain WHERE domain_id = ".$app->functions->intval($this->id));
                $this->dataRecord['web_folder'] = $tmp['web_folder']; // cannot be changed!
                
                // set the settings to current if not provided (or cleared due to limits)
@@ -449,7 +449,7 @@
        
        //* get the server config for this server
        $app->uses("getconf");
        $web_config = $app->getconf->get_server_config(intval(isset($this->dataRecord["server_id"]) ? $this->dataRecord["server_id"] : 0),'web');
        $web_config = $app->getconf->get_server_config($app->functions->intval(isset($this->dataRecord["server_id"]) ? $this->dataRecord["server_id"] : 0),'web');
        //* Check for duplicate ssl certs per IP if SNI is disabled
        if(isset($this->dataRecord['ssl']) && $this->dataRecord['ssl'] == 'y' && $web_config['enable_sni'] != 'y') {
            $sql = "SELECT count(domain_id) as number FROM web_domain WHERE `ssl` = 'y' AND ip_address = '".$app->db->quote($this->dataRecord['ip_address'])."' and domain_id != ".$this->id;
@@ -459,7 +459,7 @@
        
        // Check if pm.max_children >= pm.max_spare_servers >= pm.start_servers >= pm.min_spare_servers > 0
        if(isset($this->dataRecord['pm_max_children']) && $this->dataRecord['pm'] == 'dynamic') {
            if(intval($this->dataRecord['pm_max_children']) >= intval($this->dataRecord['pm_max_spare_servers']) && intval($this->dataRecord['pm_max_spare_servers']) >= intval($this->dataRecord['pm_start_servers']) && intval($this->dataRecord['pm_start_servers']) >= intval($this->dataRecord['pm_min_spare_servers']) && intval($this->dataRecord['pm_min_spare_servers']) > 0){
            if($app->functions->intval($this->dataRecord['pm_max_children'], true) >= $app->functions->intval($this->dataRecord['pm_max_spare_servers'], true) && $app->functions->intval($this->dataRecord['pm_max_spare_servers'], true) >= $app->functions->intval($this->dataRecord['pm_start_servers'], true) && $app->functions->intval($this->dataRecord['pm_start_servers'], true) >= $app->functions->intval($this->dataRecord['pm_min_spare_servers'], true) && $app->functions->intval($this->dataRecord['pm_min_spare_servers'], true) > 0){
        
            } else {
                $app->tform->errorMessage .= $app->tform->lng("error_php_fpm_pm_settings_txt").'<br>';
@@ -475,7 +475,7 @@
        // Get configuration for the web system
        $app->uses("getconf");
        $web_rec = $app->tform->getDataRecord($this->id);
        $web_config = $app->getconf->get_server_config(intval($web_rec["server_id"]),'web');
        $web_config = $app->getconf->get_server_config($app->functions->intval($web_rec["server_id"]),'web');
        var_dump($this->parent_domain_record, $web_rec);
        // Set the values for document_root, system_user and system_group
        $system_user = $app->db->quote($this->parent_domain_record['system_user']);
@@ -487,7 +487,7 @@
        $php_open_basedir = $app->db->quote(str_replace("[website_domain]",$web_rec['domain'],$php_open_basedir));
        $htaccess_allow_override = $app->db->quote($this->parent_domain_record['allow_override']);
        $sql = "UPDATE web_domain SET sys_groupid = ".intval($this->parent_domain_record['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir'  WHERE domain_id = ".$this->id;
        $sql = "UPDATE web_domain SET sys_groupid = ".$app->functions->intval($this->parent_domain_record['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir'  WHERE domain_id = ".$this->id;
        $app->db->query($sql);
    }
@@ -515,7 +515,7 @@
        // Get configuration for the web system
        $app->uses("getconf");
        $web_rec = $app->tform->getDataRecord($this->id);
        $web_config = $app->getconf->get_server_config(intval($web_rec["server_id"]),'web');
        $web_config = $app->getconf->get_server_config($app->functions->intval($web_rec["server_id"]),'web');
        // Set the values for document_root, system_user and system_group
        $system_user = $app->db->quote($this->parent_domain_record['system_user']);
@@ -527,7 +527,7 @@
        $php_open_basedir = $app->db->quote(str_replace("[website_domain]",$web_rec['domain'],$php_open_basedir));
        $htaccess_allow_override = $app->db->quote($this->parent_domain_record['allow_override']);
        $sql = "UPDATE web_domain SET sys_groupid = ".intval($this->parent_domain_record['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir'  WHERE domain_id = ".$this->id;
        $sql = "UPDATE web_domain SET sys_groupid = ".$app->functions->intval($this->parent_domain_record['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir'  WHERE domain_id = ".$this->id;
        $app->db->query($sql);
    }
interface/web/sites/webdav_user_edit.php
@@ -101,7 +101,7 @@
        global $app, $conf;
        /* Get the record of the parent domain */
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".intval(@$this->dataRecord["parent_domain_id"]));
        $parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ".$app->functions->intval(@$this->dataRecord["parent_domain_id"]));
        /*
         * Set a few fixed values
@@ -143,7 +143,7 @@
            /*
            *  Get the data of the domain, owning the webdav user
            */
            $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"]));
            $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->dataRecord["parent_domain_id"]));
            /* The server is the server of the domain */
            $this->dataRecord["server_id"] = $web["server_id"];
            /* The Webdav user shall be owned by the same group then the website */
@@ -164,7 +164,7 @@
         * we can not change the username and the dir, so get the "old" - data from the db
         * and set it
        */
        $data = $app->db->queryOneRecord("SELECT * FROM webdav_user WHERE webdav_user_id = ".intval($this->id));
        $data = $app->db->queryOneRecord("SELECT * FROM webdav_user WHERE webdav_user_id = ".$app->functions->intval($this->id));
        $this->dataRecord["username"] = $data['username'];
        $this->dataRecord["dir"]      = $data['dir'];
        $passwordOld = $data['password'];
interface/web/tools/import_ispconfig.php
@@ -49,7 +49,7 @@
$app->tpl->setVar($wb);
if(isset($_POST['connected'])) {
    $connected = intval($_POST['connected']);
    $connected = $app->functions->intval($_POST['connected']);
    if($connected == 0) {
        //* Try to connect to remote server
@@ -142,9 +142,9 @@
    global $app, $conf, $client, $msg, $error, $remote_session_id;
    
    //* Get the user and groupid for the new records
    $sys_groupid = intval($_POST['client_group_id']);
    $sys_groupid = $app->functions->intval($_POST['client_group_id']);
    $tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $sys_groupid");
    $sys_userid = intval($tmp['userid']);
    $sys_userid = $app->functions->intval($tmp['userid']);
    unset($tmp);
    if($sys_groupid == 0) $error .= 'Inavlid groupid<br />';
    if($sys_userid == 0) $error .= 'Inavlid Userid<br />';
interface/web/tools/import_plesk.php
@@ -269,7 +269,7 @@
                            'web_php_options' => implode(',', $phpopts),
                            'limit_web_aliasdomain' => get_limit($limits, $entry['id'], 'max_dom_aliases', -1),
                            'limit_web_subdomain' => get_limit($limits, $entry['id'], 'max_subdom', -1),
                            'limit_ftp_user' => (string)(intval(get_limit($limits, $entry['id'], 'max_subftp_users', -2)) + 1),
                            'limit_ftp_user' => (string)($app->functions->intval(get_limit($limits, $entry['id'], 'max_subftp_users', -2)) + 1),
                            'limit_shell_user' => 0,
                            'ssh_chroot' => 'no,jailkit',
                            'limit_webdav_user' => get_limit($limits, $entry['id'], 'max_wu', 0),
interface/web/vm/ajax_get_ip.php
@@ -34,7 +34,7 @@
//* Check permissions for module
$app->auth->check_module_permissions('vm');
$server_id = intval($_GET["server_id"]);
$server_id = $app->functions->intval($_GET["server_id"]);
if($_SESSION["s"]["user"]["typ"] == 'admin' or $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
interface/web/vm/openvz_action.php
@@ -11,7 +11,7 @@
$app->auth->check_module_permissions('vm');
$action = (isset($_POST['action']) && $_POST['action'] != '')?$_POST['action']:'show';
$vm_id = intval($_REQUEST['id']);
$vm_id = $app->functions->intval($_REQUEST['id']);
$error_msg = '';
$notify_msg = '';
interface/web/vm/openvz_vm_edit.php
@@ -161,12 +161,12 @@
        //* Fill the IPv4 select field with the IP addresses that are allowed for this client
        //$sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
        if(isset($this->dataRecord["server_id"])) {
            $vm_server_id = intval($this->dataRecord["server_id"]);
            $vm_server_id = $app->functions->intval($this->dataRecord["server_id"]);
        } else {
            $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE vserver_server = 1 AND mirror_server_id = 0 ORDER BY server_name LIMIT 0,1');
            $vm_server_id = $tmp['server_id'];
        }
        $sql = "SELECT ip_address FROM openvz_ip WHERE reserved = 'n' AND (vm_id = 0 or vm_id = '".$this->id."') AND server_id = ".intval($vm_server_id)." ORDER BY ip_address";
        $sql = "SELECT ip_address FROM openvz_ip WHERE reserved = 'n' AND (vm_id = 0 or vm_id = '".$this->id."') AND server_id = ".$app->functions->intval($vm_server_id)." ORDER BY ip_address";
        $ips = $app->db->queryAllRecords($sql);
        $ip_select = "";
        if(is_array($ips)) {