* 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 -
contact_number_max) || $conf->contact_number_max == 0) {
?>
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 '