X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=index.php;h=17240acffdd52721e427600539cb6f852143d700;hb=6a8ca3ee8f7f8807f9bf2119cb7ff687d84dc32c;hp=43ae1b0b47963bf2ec62d151d270dbb336eef8d9;hpb=1e23e9e060bfe8defb501573778210c43752a9ed;p=contagged
diff --git a/index.php b/index.php
index 43ae1b0..17240ac 100644
--- a/index.php
+++ b/index.php
@@ -1,36 +1,31 @@
-
- require_once('init.php');
- ldap_login();
+ display page
- header("Location: entry.php?dn=".$result[0]['dn']);
+ header("Location: entry.php?dn=".rawurlencode($result[0]['dn']));
exit;
}elseif(count($result)){
$keys = array_keys($result);
@@ -43,10 +38,6 @@
//prepare templates
tpl_std();
- tpl_markers(); //FIXME not needed anymore!?
- tpl_categories();
- tpl_timezone();
- tpl_country();
if (empty($_REQUEST['filter'])) $_REQUEST['filter']='';
if (empty($_REQUEST['marker'])) $_REQUEST['marker']='';
if (empty($_REQUEST['search'])) $_REQUEST['search']='';
@@ -54,16 +45,24 @@
$smarty->assign('filter',$_REQUEST['filter']);
$smarty->assign('marker',$_REQUEST['marker']);
$smarty->assign('search',$_REQUEST['search']);
+ $smarty->assign('org',$_REQUEST['org']);
//display templates
- if(!empty($_REQUEST['export']) && $_REQUEST['export'] == 'csv'){
- if ($conf['userlogreq'] == 1 && $user == '')
- {
- header("HTTP/1.1 401 ACCESS DENIED");
+ if(!empty($_REQUEST['export'])){
+ if ($conf['userlogreq'] && $user == ''){
+ header("HTTP/1.1 401 Access Denied");
+ echo '
Access Denied
';
exit();
- } else {
+ }
+
+ if($_REQUEST['export'] == 'csv'){
header("Content-Type: text/csv");
header('Content-Disposition: Attachement; filename="contagged_export.csv"');
- $smarty->display('export_list_csv.tpl');
+ $smarty->display('list_csv.tpl');
+ exit;
+ }elseif($_REQUEST['export'] == 'map'){
+ header('Content-Type: text/html; charset=utf-8');
+ $smarty->display('list_map.tpl');
+ exit;
}
}else{
//save location in session
@@ -95,6 +94,7 @@
*/
function _makeldapfilter(){
global $FIELDS;
+ global $conf;
//handle given filter
@@ -102,6 +102,7 @@
if (empty($_REQUEST['search'])) { $_REQUEST['search']=''; }
if (empty($_REQUEST['org'])) { $_REQUEST['org']=''; }
if (empty($_REQUEST['marker'])) { $_REQUEST['marker']=''; }
+ if(is_numeric($_REQUEST['search'])) $number = $_REQUEST['search'];
$filter = ldap_filterescape($_REQUEST['filter']);
$search = ldap_filterescape($_REQUEST['search']);
$org = ldap_filterescape($_REQUEST['org']);
@@ -115,18 +116,42 @@
$marker = explode(',',$marker);
foreach($marker as $m){
$m = trim($m);
- $ldapfilter .= '('.$FIELDS['*marker'].'='.$m.')';
+ $ldapfilter .= '('.$FIELDS['_marker'].'='.$m.')';
}
$ldapfilter .= ')';
+ }elseif($number){
+ // Search by telephone number
+ $filter = '';
+ // add wildcards between digits to compensate for any formatting
+ $length = strlen($number);
+ for($i=0; $i <$length; $i++){
+ $filter .= '*'.$number{$i};
+ }
+ $filter .= '*';
+ $ldapfilter = '(&'.
+ '(objectClass=inetOrgPerson)'.
+ '(|'.
+ '(|'.
+ '('.$FIELDS['phone'].'='.$filter.')'.
+ '('.$FIELDS['homephone'].'='.$filter.')'.
+ ')'.
+ '('.$FIELDS['mobile'].'='.$filter.')'.
+ ')'.
+ ')';
}elseif(!empty($search)){
// Search name and organization
$search = trim($search);
$words=preg_split('/\s+/',$search);
$filter='';
foreach($words as $word){
- $filter .= '(|(|('.$FIELDS['name'].'=*'.$word.'*)('.
- $FIELDS['givenname'].'=*'.$word.'*))('.
- $FIELDS['organization'].'=*'.$word.'*))';
+ $wordfilter='';
+ foreach($conf['searchfields'] as $field) {
+ $wordfilter .= '('.$field.'=*'.$word.'*)';
+ }
+ for($i=0; $i