* Copyright 2001 Olivier Cahagne * Copyright 2003 Olivier Jourdat * Copyright 2008-2011 Tim Gerundt * * This file is part of NOCC. NOCC is free software under the terms of the * GNU General Public License. You should have received a copy of the license * along with NOCC. If not, see . * * @package NOCC * @license http://www.gnu.org/licenses/ GNU General Public License * @version SVN: $Id: contacts.php 2681 2016-09-14 14:48:40Z oheil $ */ require_once './common.php'; require_once './classes/nocc_contacts.php'; require_once './utils/proxy.php'; header("Content-type: text/html; Charset=UTF-8"); try { $pop = new nocc_imap(); } catch (Exception $ex) { //TODO: Show error without NoccException! $ev = new NoccException($ex->getMessage()); require './html/header.php'; require './html/error.php'; require './html/footer.php'; exit; } $pop->close(); $theme = new NOCC_Theme($_SESSION['nocc_theme']); $_SESSION['nocc_loggedin'] = 1; ?> NOCC - Webmail - <?php echo i18n_message($html_contact_list, $_SESSION['nocc_user']); ?> contact_number_max) || $conf->contact_number_max == 0) { ?>

contact_ldap === true) { if (empty($_REQUEST['is_ldap'])) { $contacts_ldap = false; } else { $contacts_ldap = true; } ?> contact_ldap_options['search']))) { ?>

'. ''. ''. ''. ''. ''. ''; } else { $header=''. ''. ''. ''. ''. ''. ''; } ?> prefs_dir . '/' . preg_replace("/(\\\|\/)/","_",NOCC_Session::getUserKey()) . '.contacts'; $contacts = NOCC_Contacts::loadList($path); $show_lists_only=false; if( isset($_GET['listonly']) && $_GET['listonly']==1 ) { $show_lists_only=true; } if( count($contacts) <= 10 ) { echo $header; } if( count($contacts) > 10 ) { $count2list=array(); $all_rulers=array(); $ruler_top='  '.convertLang2Html($html_contact_ruler_top).'  -'; if( $show_lists_only ) { $ruler_listonly='-  '.convertLang2Html($html_contact_all).'  '; } else { $ruler_listonly='-  '.convertLang2Html($html_contact_listonly).'  '; } NOCC_Contacts::create_rulers($contacts,$ruler_top,$ruler_listonly,$all_rulers,$count2list,$show_lists_only); } $ruler_count=0; for ($i = 0; $i < count($contacts); ++$i) { //$tab = explode("\t", $contacts[$i]); $tab=$contacts[$i]; if( count($contacts) > 10 ) { if( isset($count2list[strval($i)]) ) { echo $all_rulers[$ruler_count]; $ruler_count++; echo $header; } } if( $tab[5]==1 || ! $show_lists_only ) { $email_show=''; if( $tab[5]==1 ) { //its a list of emails $all_emails=array(); semisplit_address_list($tab[3],$all_emails,$sep=';'); $list_count=min(3,count($all_emails)); for($j=0;$j<$list_count;$j++) { $j==0 ? $email_show=$all_emails[$j] : $email_show=$email_show.'; '.$all_emails[$j]; } if( count($all_emails)>=3 ) { $email_show=$email_show.'; ...'; } $list_string=preg_replace('/"/','\"',$tab[3]); } else { $email_show=$tab[3]; } if ($lang_dir === 'ltr') { ?> "> "> contact_ldap === true) { // First we process our configuration, then we try to connect the LDAP server // and at last we try to fetch our data. // // The script will exit if an error occurs, even before any data will be processed! // Change DSN for SSL support if ($conf->contact_ldap_options['ssl'] === true) { $contact_host = 'ldaps://' . $conf->contact_ldap_options['host']; } else { $contact_host = 'ldap://' . $conf->contact_ldap_options['host']; } // Add different port to host, if available if (!empty($conf->contact_ldap_options['port'])) { $contact_host .= ':' . $conf->contact_ldap_options['port']; } // convert attributes to array, if not already one if (!is_array($conf->contact_ldap_options['attributes'])) { $conf->contact_ldap_options['attributes'] = explode(',', $conf->contact_ldap_options['attributes']); } if (!empty($conf->contact_ldap_options['suffix'])) { $contact_suffix = '@'.$conf->contact_ldap_options['suffix']; } else { $contact_suffix = '@'.$conf->domains[0]->domain; } // get attributes $contact_list_uid = $conf->contact_ldap_options['attributes'][0]; if (empty($conf->contact_ldap_options['attributes'][2])) { $contact_name_split = true; $contact_list_name = $conf->contact_ldap_options['attributes'][1]; } else { $contact_name_split = false; $contact_list_name_first = $conf->contact_ldap_options['attributes'][1]; $contact_list_name_last = $conf->contact_ldap_options['attributes'][2]; } if (!empty($conf->contact_ldap_options['attributes'][3])) { $contact_list_email = $conf->contact_ldap_options['attributes'][3]; } // set filter / search options (does not work, at the moment) $contact_filter = sprintf($conf->contact_ldap_options['filter'], '*'); $contact_filter_suffix = ''; if (!empty($_REQUEST['ldap_filter'])) { if (empty($_REQUEST['search_field'])) { if (preg_match('/([a-zA-Z0-9])/', $_REQUEST['ldap_filter']) && strlen($_REQUEST['ldap_filter']) == 1) { $contact_filter_suffix = '*'; $contact_filter = sprintf($conf->contact_ldap_options['filter'], $_REQUEST['ldap_filter'].$contact_filter_suffix); } } else { if (preg_match('/([a-zA-Z0-9_.-])/', $_REQUEST['search_field'])) { $contact_filter = '(|(' . $_REQUEST['search_field'] . '=*' . $_REQUEST['ldap_filter'] . '*))'; } } } // LDAP connection $contact_connection = ldap_connect($contact_host) or die("{$lang_could_not_connect}: {$conf->contact_ldap_options['host']}"); // LDAP authentication if ($conf->contact_ldap_options['anonymous'] === false) { if (!empty($conf->contact_ldap_options['bind_dn']) && !empty($conf->contact_ldap_options['bind_pass']) ) { $contact_bind = ldap_bind($contact_connection, $conf->contact_ldap_options['bind_dn'], $conf->contact_ldap_options['bind_pass']); } } // LDAP search $contact_search = ldap_search($contact_connection, $conf->contact_ldap_options['dn'], $contact_filter, $conf->contact_ldap_options['attributes']) or die("{$lang_could_not_connect}: {$conf->contact_ldap_options['host']}"); // Sort LDAP search by: if (!empty($conf->contact_ldap_options['search_sortby'])) { ldap_sort($contact_connection, $contact_search, $conf->contact_ldap_options['search_sortby']); } // LDAP get the data $contact_list = ldap_get_entries($contact_connection, $contact_search); $contact_output = ''; $i = 0; foreach ($contact_list AS $list_val) { $_uid = trim($list_val['count']); if ($i === 1) { print('
' . i18n_message($html_contact_count, $contact_list['count']) . '
'); } // filter out hostnames (for windows like hostname$) if ((!empty($_uid)) && (!preg_match('/\$/', $list_val[$contact_list_uid][0]))) { // explode fullname if needed if ($contact_name_split) { $contact_name = explode(" ", $list_val[$contact_list_name][0]); } else { $contact_name[0] = $list_val[$contact_list_name_first][0]; $contact_name[1] = $list_val[$contact_list_name_last][0]; } // check if email is provided in LDAP entry if (isset($contact_list_email)) { $contact_email = $list_val[$contact_list_email][0]; } else { $contact_email = $list_val[$contact_list_uid][0].$contact_suffix; } if ($lang_dir === 'ltr') { ?> "> "> '); } } else { // bye bye!!! print(''. $html_back .''); } } ?>
'.convertLang2Html($html_contact_first).''.convertLang2Html($html_contact_last).''.convertLang2Html($html_contact_nick).''.convertLang2Html($html_contact_mail).'
'.convertLang2Html($html_contact_mail).''.convertLang2Html($html_contact_nick).''.convertLang2Html($html_contact_last).''.convertLang2Html($html_contact_first).'
"),"0||strlen(trim($tab[1]))>0){$out="\\\"".trim(trim($tab[0])." ".trim($tab[1]))."\\\" <".trim($tab[3]).">";}else if(strlen(trim($tab[2]))>0){$out="\\\"".trim($tab[2])."\\\" <".trim($tab[3]).">";}else{$out=trim($tab[3]);}};echo $out; ?>");toggle(document.getElementById(""));' />
"),"0||strlen(trim($tab[1]))>0){$out="\\\"".trim(trim($tab[0])." ".trim($tab[1]))."\\\" <".trim($tab[3]).">";}else if(strlen(trim($tab[2]))>0){$out="\\\"".trim($tab[2])."\\\" <".trim($tab[3]).">";}else{$out=trim($tab[3]);}};echo $out; ?>");toggle(document.getElementById(""));' />
' . $html_contact_none . '











'; echo '











'; echo '











'; echo ''."\n"; ?>