* 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_manager.php 2969 2021-12-10 19:43:58Z 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']); // Load the contact list $path = $conf->prefs_dir . '/' . preg_replace("/(\\\|\/)/","_",NOCC_Session::getUserKey()) . '.contacts'; $contactlists=array(); $contacts=NOCC_Contacts::loadList($path,$contactlists); $all_lists=array(); $query_str = NOCC_Session::getUrlQuery(); ?> NOCC - Webmail - <?php echo i18n_message($html_contact_list, $_SESSION['nocc_user']); ?> contact_number_max) || $conf->contact_number_max == 0) { ?>

&action=add"> contact_number_max || $_GET['modif']) { ?> '; echo ''; $all_emails=array(); semisplit_address_list($tab[3],$all_emails,$sep=';'); for($j=0;$j'; echo ''; } ?>

contact_number_max) ?>

.

">

0 && isset($_POST['listname']) && strlen($_POST['listname'])>0 ) { $listname=trim($_POST['listname']); } else if( isset($_POST[addlist2]) && strlen($_POST[addlist2])>0 && isset($_POST['listname2']) && strlen($_POST['listname2'])>0 ) { $listname=trim($_POST['listname2']); } $listname=str_replace('\t','',$listname); $listname=stripslashes($listname); $listname=preg_replace('/[\'"<>]/','',$listname); $modify_listids=array(); if( strlen($listname)>0 && isset($_POST['emails4list']) && is_array($_POST['emails4list']) && count($_POST['emails4list'])>0 ) { for( $i=0;$iself.location.href="contacts_manager.php?'.NOCC_Session::getUrlGetSession().'&'.$query_str.'";'; break; case "add": if (!empty($_POST['email'])) { // The following foreach block performs some sanity checking and // cleanup. foreach (array('first', 'last', 'nick', 'email') as $contact_element) { //We should strip slashes here if (get_magic_quotes_gpc()) $_POST[$contact_element] = stripslashes($_POST[$contact_element]); // Strip tabs that COULD be inserted into fields(causing corrupted // DB) $_POST[$contact_element] = str_replace('\t', '', $_POST[$contact_element]); //Maybe more sanity checking needs to be done??? if( ! isset($_POST['isList']) || $contact_element != 'email' ) { //dont allow "<>, as it corrupts html outpout $_POST[$contact_element] = preg_replace('/[\'"<>]/','',$_POST[$contact_element]); } } //email should only be xxx@xxx.xx.xx $isList=0; if( ! isset($_POST['isList']) ) { $matches=array(); if( preg_match("/^.*(\S+?@\S+?).*/U",$_POST['email'],$matches) ) { $_POST['email']=$matches[1]; } } else { $_POST['email']=preg_replace('/\s*\n\s*/','; ',trim($_POST['email'])); $_POST['first']=''; $_POST['nick']=''; $isList=1; } if (count($contacts) < $conf->contact_number_max && empty($_POST['modif'])) { //$line = $_POST['first'] . "\t" . $_POST['last'] . "\t" . $_POST['nick'] . "\t" . $_POST['email']; $line=array($_POST['first'],$_POST['last'],$_POST['nick'],$_POST['email'],'',$isList); array_push($contacts, $line); NOCC_Contacts::saveList($path, $contacts, $conf, $ev); if (NoccException::isException($ev)) { require './html/error.php'; require './html/footer.php'; break; } } if (!empty ($_POST['modif'])) { if( isset($_POST['id']) && isset($contacts[$_POST['id']]) ) { //$line = $_POST['first'] . "\t" . $_POST['last'] . "\t" . $_POST['nick'] . "\t" . $_POST['email']; $line=array($_POST['first'],$_POST['last'],$_POST['nick'],$_POST['email'],'',$isList); $contacts[$_POST['id']] = $line; NOCC_Contacts::saveList($path, $contacts, $conf, $ev); if (NoccException::isException($ev)) { require './html/error.php'; require './html/footer.php'; break; } } } $contacts = NOCC_Contacts::loadList($path); } else { echo ""; echo ""; } ?> 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); } if(count($contacts)<$conf->contact_number_max){ echo '
'; echo ''; echo '
'; echo ''; $header=''. ''. ''. ''. ''. ''. ''. ''; if( count($contacts) <= 10 ) { echo $header; } $ruler_count=0; for ($i = 0; $i < count($contacts); ++$i) { //$tab = array_pad(explode("\t", $contacts[$i]), -4, ""); $tab=$contacts[$i]; $checkbox_value=$tab[3]; if( $tab[5]==0 ) { if( strlen($tab[0])>0 && strlen($tab[1])>0 ) { $checkbox_value='"'.$tab[0].' '.$tab[1].'" <'.$checkbox_value.'>'; } else if( strlen($tab[0])==0 && strlen($tab[1])>0 ) { $checkbox_value='"'.$tab[1].'" <'.$checkbox_value.'>'; } else if( strlen($tab[0])>0 && strlen($tab[1])==0 ) { $checkbox_value='"'.$tab[0].'" <'.$checkbox_value.'>'; } } $checkbox_value=htmlspecialchars($checkbox_value,ENT_COMPAT | ENT_SUBSTITUTE); if( count($contacts) > 10 ) { if( isset($count2list[strval($i)]) ) { echo $all_rulers[$ruler_count]; $ruler_count++; echo $header; } } 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 ? $tab[3]=$all_emails[$j] : $tab[3]=$tab[3].'; '.$all_emails[$j]; } if( count($all_emails)>=3 ) { $tab[3]=$tab[3].'; ...'; } $all_lists[]=htmlspecialchars($tab[1],ENT_COMPAT | ENT_SUBSTITUTE); } if( $tab[5]==1 || ! $show_lists_only ) { ?> ">
'.convertLang2Html($html_contact_first).''.convertLang2Html($html_contact_last).' / '.convertLang2Html($html_contact_listname).''.convertLang2Html($html_contact_nick).''.convertLang2Html($html_contact_mail).' 
'; } echo ($tab[1]) ? htmlspecialchars($tab[1],ENT_COMPAT | ENT_SUBSTITUTE) : " "; if( $tab[5]==1 ) { echo ''; } ?> &action=add_prompt&id=&modif=1'"/>
'; }else{ echo i18n_message($html_contact_err1,$conf->contact_number_max).convertLang2Html($html_contact_err2).'

'; } if(count($contacts)<$conf->contact_number_max){ echo '
'; } echo '













'."\n"; echo '













'."\n"; echo '













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