| | |
| | | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | */ |
| | | |
| | | require_once('../../lib/config.inc.php'); |
| | | require_once('../../lib/app.inc.php'); |
| | | require_once '../../lib/config.inc.php'; |
| | | require_once '../../lib/app.inc.php'; |
| | | |
| | | //* Check permissions for module |
| | | $app->auth->check_module_permissions('dashboard'); |
| | |
| | | |
| | | //if($_SESSION["s"]["user"]["typ"] == 'admin') { |
| | | |
| | | |
| | | if($type == 'globalsearch'){ |
| | | $q = $app->db->quote(trim($_GET["q"])); |
| | | $authsql = " AND ".$app->tform->getAuthSQL('r'); |
| | | $modules = explode(',', $_SESSION['s']['user']['modules']); |
| | | |
| | | $result = array(); |
| | | |
| | | // clients |
| | | $result[] = _search('client', 'client', "AND limit_client = 0"); |
| | | |
| | | // resellers |
| | | $result[] = _search('client', 'reseller', "AND limit_client != 0"); |
| | | |
| | | // web sites |
| | | $result[] = _search('sites', 'web_domain'); |
| | | |
| | | // FTP users |
| | | $result[] = _search('sites', 'ftp_user'); |
| | | |
| | | // shell users |
| | | $result[] = _search('sites', 'shell_user'); |
| | | |
| | | // databases |
| | | /* |
| | | $result_databases = array('cheader' => array(), 'cdata' => array()); |
| | | if(in_array('sites', $modules)){ |
| | | $sql = "SELECT * FROM web_database WHERE database_name LIKE '%".$q."%' OR database_user LIKE '%".$q."%' OR remote_ips LIKE '%".$q."%'".$authsql." ORDER BY database_name"; |
| | | $results = $app->db->queryAllRecords($sql); |
| | | /* TODO: change sql queries */ |
| | | if($type == 'globalsearch'){ |
| | | $q = $app->db->quote(trim($_GET["q"])); |
| | | $authsql = " AND ".$app->tform->getAuthSQL('r'); |
| | | $modules = explode(',', $_SESSION['s']['user']['modules']); |
| | | |
| | | if(is_array($results) && !empty($results)){ |
| | | $result_databases['cheader'] = array('title' => 'Databases', |
| | | 'total' => count($results), |
| | | 'limit' => count($results) |
| | | ); |
| | | foreach($results as $result){ |
| | | $description = 'Database User: '.$result['database_user'].' - Remote IPs: '.$result['remote_ips']; |
| | | $result_databases['cdata'][] = array('title' => $result['database_name'], |
| | | 'description' => $description, |
| | | 'onclick' => 'capp(\'sites\',\'sites/database_edit.php?id='.$result['database_id'].'\');', |
| | | 'fill_text' => strtolower($result['database_name']) |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | */ |
| | | $result[] = _search('sites', 'database'); |
| | | |
| | | // email domains |
| | | $result[] = _search('mail', 'mail_domain'); |
| | | |
| | | // email alias domains |
| | | $result[] = _search('mail', 'mail_aliasdomain', "AND type = 'aliasdomain'"); |
| | | |
| | | // email mailboxes |
| | | $result[] = _search('mail', 'mail_user'); |
| | | |
| | | // email aliases |
| | | $result[] = _search('mail', 'mail_alias', "AND type = 'alias'"); |
| | | |
| | | // email forwards |
| | | $result[] = _search('mail', 'mail_forward', "AND type = 'forward'"); |
| | | |
| | | // email catchalls |
| | | $result[] = _search('mail', 'mail_domain_catchall', "AND type = 'catchall'"); |
| | | |
| | | // email transports |
| | | $result[] = _search('mail', 'mail_transport'); |
| | | |
| | | // mailinglists |
| | | $result[] = _search('mail', 'mail_mailinglist'); |
| | | |
| | | // getmails |
| | | $result[] = _search('mail', 'mail_get'); |
| | | |
| | | // dns zones |
| | | $result[] = _search('dns', 'dns_soa'); |
| | | |
| | | // secondary dns zones |
| | | $result[] = _search('dns', 'dns_slave'); |
| | | |
| | | // virtual machines |
| | | $result[] = _search('vm', 'openvz_vm'); |
| | | |
| | | // virtual machines os templates |
| | | $result[] = _search('vm', 'openvz_ostemplate'); |
| | | |
| | | // virtual machines vm templates |
| | | $result[] = _search('vm', 'openvz_template'); |
| | | |
| | | // virtual machines ip addresses |
| | | $result[] = _search('vm', 'openvz_ip'); |
| | | $result = array(); |
| | | |
| | | $json = $app->functions->json_encode($result); |
| | | } |
| | | // clients |
| | | $result[] = _search('client', 'client', "AND limit_client = 0"); |
| | | |
| | | // resellers |
| | | $result[] = _search('client', 'reseller', "AND limit_client != 0"); |
| | | |
| | | // web sites |
| | | $result[] = _search('sites', 'web_vhost_domain', "AND type = 'vhost'"); |
| | | |
| | | // subdomains |
| | | $result[] = _search('sites', 'web_childdomain', "AND type = 'subdomain'", 'type=subdomain'); |
| | | |
| | | // web site aliases |
| | | $result[] = _search('sites', 'web_childdomain', "AND type = 'alias'", 'type=aliasdomain'); |
| | | |
| | | // vhostsubdomains |
| | | $result[] = _search('sites', 'web_vhost_domain', "AND type = 'vhostsubdomain'", 'type=subdomain'); |
| | | |
| | | // vhostaliasdomains |
| | | $result[] = _search('sites', 'web_vhost_domain', "AND type = 'vhostalias'", 'type=aliasdomain'); |
| | | |
| | | // FTP users |
| | | $result[] = _search('sites', 'ftp_user'); |
| | | |
| | | // shell users |
| | | $result[] = _search('sites', 'shell_user'); |
| | | |
| | | // databases |
| | | $result[] = _search('sites', 'database'); |
| | | |
| | | // database users |
| | | $result[] = _search('sites', 'database_user'); |
| | | |
| | | // email domains |
| | | $result[] = _search('mail', 'mail_domain'); |
| | | |
| | | // email alias domains |
| | | $result[] = _search('mail', 'mail_aliasdomain', "AND type = 'aliasdomain'"); |
| | | |
| | | // email mailboxes |
| | | $result[] = _search('mail', 'mail_user'); |
| | | |
| | | // email aliases |
| | | $result[] = _search('mail', 'mail_alias', "AND type = 'alias'"); |
| | | |
| | | // email forwards |
| | | $result[] = _search('mail', 'mail_forward', "AND type = 'forward'"); |
| | | |
| | | // email catchalls |
| | | $result[] = _search('mail', 'mail_domain_catchall', "AND type = 'catchall'"); |
| | | |
| | | // email transports |
| | | $result[] = _search('mail', 'mail_transport'); |
| | | |
| | | // mailinglists |
| | | $result[] = _search('mail', 'mail_mailinglist'); |
| | | |
| | | // getmails |
| | | $result[] = _search('mail', 'mail_get'); |
| | | |
| | | // dns zones |
| | | $result[] = _search('dns', 'dns_soa'); |
| | | |
| | | // secondary dns zones |
| | | $result[] = _search('dns', 'dns_slave'); |
| | | |
| | | // virtual machines |
| | | $result[] = _search('vm', 'openvz_vm'); |
| | | |
| | | // virtual machines os templates |
| | | $result[] = _search('vm', 'openvz_ostemplate'); |
| | | |
| | | // virtual machines vm templates |
| | | $result[] = _search('vm', 'openvz_template'); |
| | | |
| | | // virtual machines ip addresses |
| | | $result[] = _search('vm', 'openvz_ip'); |
| | | |
| | | // directive snippets |
| | | $result[] = _search('admin', 'directive_snippets'); |
| | | |
| | | $json = $app->functions->json_encode($result); |
| | | } |
| | | |
| | | //} |
| | | |
| | | function _search($module, $section, $additional_sql = ''){ |
| | | function _search($module, $section, $additional_sql = '', $params = ''){ |
| | | global $app, $q, $authsql, $modules; |
| | | |
| | | $result_array = array('cheader' => array(), 'cdata' => array()); |
| | |
| | | $search_fields = array(); |
| | | $desc_fields = array(); |
| | | if(is_file('../'.$module.'/form/'.$section.'.tform.php')){ |
| | | include_once('../'.$module.'/form/'.$section.'.tform.php'); |
| | | |
| | | include '../'.$module.'/form/'.$section.'.tform.php'; |
| | | |
| | | $category_title = $form["title"]; |
| | | if($params == 'type=subdomain' && $section == 'web_childdomain') $category_title = 'Subdomain'; |
| | | if($params == 'type=aliasdomain' && $section == 'web_childdomain') $category_title = 'Aliasdomain'; |
| | | if($params == 'type=subdomain' && $section == 'web_vhost_domain') $category_title = 'Subdomain (Vhost)'; |
| | | if($params == 'type=aliasdomain' && $section == 'web_vhost_domain') $category_title = 'Aliasdomain (Vhost)'; |
| | | $form_file = $form["action"]; |
| | | $db_table = $form["db_table"]; |
| | | $db_table_idx = $form["db_table_idx"]; |
| | | $order_by = $db_table_idx; |
| | | |
| | | |
| | | if(is_array($form["tabs"]) && !empty($form["tabs"])){ |
| | | foreach($form["tabs"] as $tab){ |
| | | if(is_array($tab['fields']) && !empty($tab['fields'])){ |
| | |
| | | } |
| | | } |
| | | unset($form); |
| | | |
| | | |
| | | $where_clause = ''; |
| | | if(!empty($search_fields)){ |
| | | $where_clause = implode(' OR ', $search_fields); |
| | |
| | | if($additional_sql != '') $where_clause .= ' '.$additional_sql.' '; |
| | | $order_clause = ''; |
| | | if($order_by != '') $order_clause = ' ORDER BY '.$order_by; |
| | | |
| | | $sql = "SELECT * FROM ".$db_table." WHERE ".$where_clause.$authsql.$order_clause." LIMIT 0,10"; |
| | | $results = $app->db->queryAllRecords($sql); |
| | | |
| | | if(is_array($results) && !empty($results)){ |
| | | |
| | | $sql = "SELECT * FROM ?? WHERE ".$where_clause.$authsql.$order_clause." LIMIT 0,10"; |
| | | $results = $app->db->queryAllRecords($sql, $db_table); |
| | | |
| | | if(is_array($results) && !empty($results)){ |
| | | $lng_file = '../'.$module.'/lib/lang/'.$_SESSION['s']['language'].'_'.$section.'.lng'; |
| | | if(is_file($lng_file)) include($lng_file); |
| | | if(is_file($lng_file)) include $lng_file; |
| | | $result_array['cheader'] = array('title' => $category_title, |
| | | 'total' => count($results), |
| | | 'limit' => count($results) |
| | | ); |
| | | 'total' => count($results), |
| | | 'limit' => count($results) |
| | | ); |
| | | foreach($results as $result){ |
| | | $description = ''; |
| | | if(!empty($desc_fields)){ |
| | |
| | | } |
| | | if(!empty($desc_items)) $description = implode(' - ', $desc_items); |
| | | } |
| | | |
| | | |
| | | $result_array['cdata'][] = array('title' => $wb[$title_key.'_txt'].': '.$result[$title_key], |
| | | 'description' => $description, |
| | | 'onclick' => "capp('".$module."','".$module."/".$form_file."?id=".$result[$db_table_idx]."');", |
| | | 'fill_text' => strtolower($result[$title_key]) |
| | | ); |
| | | } |
| | | 'description' => $description, |
| | | 'onclick' => "ISPConfig.capp('".$module."','".$module."/".$form_file.urlencode("?id=".$result[$db_table_idx]).($params != ''? urlencode('&'.$params) : '')."');", |
| | | 'fill_text' => strtolower($result[$title_key]) |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | return $result_array; |
| | | } |
| | | |
| | | |
| | | header('Content-type: application/json'); |
| | | echo $json; |
| | | ?> |
| | | ?> |