938f9a07177a01f630752285a0f9c57f3a4104fe
1 <?php
2 /*
3 * This code is part of GOsa (https://gosa.gonicus.de)
4 * Copyright (C) 2003-2006 - Cajus Pollmeier <pollmeier@gonicus.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
21 class config {
23 /* XML parser */
24 var $parser;
25 var $config_found= FALSE;
26 var $tags= array();
27 var $level= 0;
28 var $gpc= 0;
29 var $section= "";
30 var $currentLocation= "";
32 /* Selected connection */
33 var $current= array();
35 /* Link to LDAP-server */
36 var $ldap= NULL;
37 var $referrals= array();
39 /* Configuration data */
40 var $data= array( 'TABS' => array(), 'LOCATIONS' => array(), 'SERVERS' => array(),
41 'MAIN' => array( 'LANGUAGES' => array(), 'FAXFORMATS' => array() ),
42 'MENU' => array(), 'SERVICE' => array());
43 var $basedir= "";
45 /* Keep a copy of the current deparment list */
46 var $departments= array();
47 var $idepartments= array();
48 var $adepartments= array();
49 var $tdepartments= array();
51 function config($filename, $basedir= "")
52 {
53 $this->parser = xml_parser_create();
54 $this->basedir= $basedir;
56 xml_set_object($this->parser, $this);
57 xml_set_element_handler($this->parser, "tag_open", "tag_close");
59 /* Parse config file directly? */
60 if ($filename != ""){
61 $this->parse($filename);
62 }
63 }
65 function parse($filename)
66 {
67 $fh= fopen($filename, "r");
68 $xmldata= fread($fh, 100000);
69 fclose($fh);
70 if(!xml_parse($this->parser, chop($xmldata))){
71 print_red(sprintf(_("XML error in gosa.conf: %s at line %d"),
72 xml_error_string(xml_get_error_code($this->parser)),
73 xml_get_current_line_number($this->parser)));
74 echo $_SESSION['errors'];
75 exit;
76 }
77 }
79 function tag_open($parser, $tag, $attrs)
80 {
81 /* Save last and current tag for reference */
82 $this->tags[$this->level]= $tag;
83 $this->level++;
85 /* Trigger on CONF section */
86 if ($tag == 'CONF'){
87 $this->config_found= TRUE;
88 }
90 /* Return if we're not in config section */
91 if (!$this->config_found){
92 return;
93 }
95 /* yes/no to true/false and upper case TRUE to true and so on*/
96 foreach($attrs as $name => $value){
97 if(preg_match("/^(true|yes)$/i",$value)){
98 $attrs[$name] = "true";
99 }elseif(preg_match("/^(false|no)$/i",$value)){
100 $attrs[$name] = "false";
101 }
102 }
104 /* Look through attributes */
105 switch ($this->tags[$this->level-1]){
107 /* Handle tab section */
108 case 'TAB': $name= $this->tags[$this->level-2];
110 /* Create new array? */
111 if (!isset($this->data['TABS'][$name])){
112 $this->data['TABS'][$name]= array();
113 }
115 /* Add elements */
116 $this->data['TABS'][$name][]= $attrs;
117 break;
119 /* Handle location */
120 case 'LOCATION':
121 if ($this->tags[$this->level-2] == 'MAIN'){
122 $name= $attrs['NAME'];
123 $this->currentLocation= $name;
125 /* Add location elements */
126 $this->data['LOCATIONS'][$name]= $attrs;
127 }
128 break;
130 /* Handle referral tags */
131 case 'REFERRAL':
132 if ($this->tags[$this->level-2] == 'LOCATION'){
133 $url= $attrs['URL'];
134 $server= preg_replace('!^([^:]+://[^/]+)/.*$!', '\\1', $url);
136 /* Add location elements */
137 if (!isset($this->data['LOCATIONS'][$this->currentLocation]['REFERRAL'])){
138 $this->data['LOCATIONS'][$this->currentLocation]['REFERRAL']= array();
139 }
141 $this->data['LOCATIONS'][$this->currentLocation]['REFERRAL'][$server]= $attrs;
142 }
143 break;
145 /* Handle language */
146 case 'LANGUAGE':
147 if ($this->tags[$this->level-2] == 'MAIN'){
148 /* Add languages */
149 $this->data['MAIN']['LANGUAGES'][$attrs['NAME']]=
150 $attrs['TAG'];
151 }
152 break;
154 /* Handle faxformat */
155 case 'FAXFORMAT':
156 if ($this->tags[$this->level-2] == 'MAIN'){
157 /* Add fax formats */
158 $this->data['MAIN']['FAXFORMATS'][]= $attrs['TYPE'];
159 }
160 break;
162 /* Load main parameters */
163 case 'MAIN':
164 $this->data['MAIN']= array_merge ($this->data['MAIN'], $attrs);
165 break;
167 /* Load menu */
168 case 'SECTION':
169 if ($this->tags[$this->level-2] == 'MENU'){
170 $this->section= $attrs['NAME'];
171 $this->data['MENU'][$this->section]= array(); ;
172 }
173 break;
175 /* Inser plugins */
176 case 'PLUGIN':
177 if ($this->tags[$this->level-3] == 'MENU' &&
178 $this->tags[$this->level-2] == 'SECTION'){
180 $this->data['MENU'][$this->section][$this->gpc++]= $attrs;
181 }
182 if ($this->tags[$this->level-2] == 'SERVICEMENU'){
183 $this->data['SERVICE'][$attrs['CLASS']]= $attrs;
184 }
185 break;
186 }
187 }
189 function tag_close($parser, $tag)
190 {
191 /* Close config section */
192 if ($tag == 'CONF'){
193 $this->config_found= FALSE;
194 }
195 $this->level--;
196 }
198 function get_ldap_link($sizelimit= FALSE)
199 {
200 /* Build new connection */
201 $this->ldap= ldap_init ($this->current['SERVER'], $this->current['BASE'],
202 $this->current['ADMIN'], $this->current['PASSWORD']);
204 /* Check for connection */
205 if (is_null($this->ldap) || (is_int($this->ldap) && $this->ldap == 0)){
206 $smarty= get_smarty();
207 print_red (_("Can't bind to LDAP. Please contact the system administrator."));
208 $smarty->display (get_template_path('headers.tpl'));
209 echo '<body style="background-image:none">'.$_SESSION['errors'].'</body></html>';
210 exit();
211 }
213 if (!isset($_SESSION['size_limit'])){
214 $_SESSION['size_limit']= $this->current['SIZELIMIT'];
215 $_SESSION['size_ignore']= $this->current['SIZEIGNORE'];
216 }
218 if ($sizelimit){
219 $this->ldap->set_size_limit($_SESSION['size_limit']);
220 } else {
221 $this->ldap->set_size_limit(0);
222 }
224 /* Move referrals */
225 if (!isset($this->current['REFERRAL'])){
226 $this->ldap->referrals= array();
227 } else {
228 $this->ldap->referrals= $this->current['REFERRAL'];
229 }
231 return ($this->ldap);
232 }
234 function set_current($name)
235 {
236 $this->current= $this->data['LOCATIONS'][$name];
237 if (!isset($this->current['PEOPLE'])){
238 $this->current['PEOPLE']= "ou=people";
239 }
240 if (!isset($this->current['GROUPS'])){
241 $this->current['GROUPS']= "ou=groups";
242 }
244 /* Remove possibly added ',' from end of group and people ou */
245 $this->current['GROUPS'] = preg_replace("/,*$/","",$this->current['GROUPS']);
246 $this->current['PEOPLE'] = preg_replace("/,*$/","",$this->current['PEOPLE']);
248 if (!isset($this->current['WINSTATIONS'])){
249 $this->current['WINSTATIONS']= "ou=winstations,ou=systems";
250 }
251 if (!isset($this->current['HASH'])){
252 $this->current['HASH']= "crypt";
253 }
254 if (!isset($this->current['DNMODE'])){
255 $this->current['DNMODE']= "cn";
256 }
257 if (!isset($this->current['MINID'])){
258 $this->current['MINID']= 100;
259 }
260 if (!isset($this->current['SIZELIMIT'])){
261 $this->current['SIZELIMIT']= 200;
262 }
263 if (!isset($this->current['SIZEINGORE'])){
264 $this->current['SIZEIGNORE']= TRUE;
265 } else {
266 if (preg_match("/true/i", $this->current['SIZEIGNORE'])){
267 $this->current['SIZEIGNORE']= TRUE;
268 } else {
269 $this->current['SIZEIGNORE']= FALSE;
270 }
271 }
273 /* Sort referrals, if present */
274 if (isset ($this->current['REFERRAL'])){
275 $bases= array();
276 $servers= array();
277 foreach ($this->current['REFERRAL'] as $ref){
278 $server= preg_replace('%^(.*)/[^/]+$%', '\\1', $ref['URL']);
279 $base= preg_replace('%^.*/([^/]+)$%', '\\1', $ref['URL']);
280 $bases[$base]= strlen($base);
281 $servers[$base]= $server;
282 }
283 asort($bases);
284 reset($bases);
285 }
287 /* SERVER not defined? Load the one with the shortest base */
288 if (!isset($this->current['SERVER'])){
289 $this->current['SERVER']= $servers[key($bases)];
290 }
292 /* BASE not defined? Load the one with the shortest base */
293 if (!isset($this->current['BASE'])){
294 $this->current['BASE']= key($bases);
295 }
297 /* Convert BASE to have escaped special characters */
298 $this->current['BASE']= @LDAP::convert($this->current['BASE']);
300 /* Parse LDAP referral informations */
301 if (!isset($this->current['ADMIN']) || !isset($this->current['PASSWORD'])){
302 $url= $this->current['SERVER'];
303 $referral= $this->current['REFERRAL'][$url];
304 $this->current['ADMIN']= $referral['ADMIN'];
305 $this->current['PASSWORD']= $referral['PASSWORD'];
306 }
308 /* Possibly load kerberos style */
309 if (isset($this->current['KRBSASL'])){
310 if (preg_match('/^(yes|true)$/i', $this->current['KRBSASL'])){
311 $this->current['KRBSASL']= "sasl";
312 } else {
313 $this->current['KRBSASL']= "kerberos";
314 }
315 } else {
316 $this->current['KRBSASL']= "kerberos";
317 }
319 /* Load server informations */
320 $this->load_servers();
321 }
323 function load_servers ()
324 {
325 /* Only perform actions if current is set */
326 if ($this->current == NULL){
327 return;
328 }
330 /* Fill imap servers */
331 $ldap= $this->get_ldap_link();
332 $ldap->cd ($this->current['BASE']);
333 $ldap->search ("(objectClass=goImapServer)");
335 $this->data['SERVERS']['IMAP']= array();
336 error_reporting(0);
337 while ($attrs= $ldap->fetch()){
338 $name= $attrs['goImapName'][0];
339 $this->data['SERVERS']['IMAP'][$name]= array( "connect" => $attrs['goImapConnect'][0],
340 "admin" => $attrs['goImapAdmin'][0],
341 "password" => $attrs['goImapPassword'][0],
342 "sieve_server" => $attrs['goImapSieveServer'][0],
343 "sieve_port" => $attrs['goImapSievePort'][0]);
344 }
345 error_reporting(E_ALL);
347 /* Get kerberos server. FIXME: only one is supported currently */
348 $ldap->cd ($this->current['BASE']);
349 $ldap->search ("(objectClass=goKrbServer)");
350 if ($ldap->count()){
351 $attrs= $ldap->fetch();
352 $this->data['SERVERS']['KERBEROS']= array( 'SERVER' => $attrs['cn'][0],
353 'REALM' => $attrs['goKrbRealm'][0],
354 'ADMIN' => $attrs['goKrbAdmin'][0],
355 'PASSWORD' => $attrs['goKrbPassword'][0]);
356 }
358 /* Get cups server. FIXME: only one is supported currently */
359 $ldap->cd ($this->current['BASE']);
360 $ldap->search ("(objectClass=goCupsServer)");
361 if ($ldap->count()){
362 $attrs= $ldap->fetch();
363 $this->data['SERVERS']['CUPS']= $attrs['cn'][0];
364 }
366 /* Get fax server. FIXME: only one is supported currently */
367 $ldap->cd ($this->current['BASE']);
368 $ldap->search ("(objectClass=goFaxServer)");
369 if ($ldap->count()){
370 $attrs= $ldap->fetch();
371 $this->data['SERVERS']['FAX']= array( 'SERVER' => $attrs['cn'][0],
372 'LOGIN' => $attrs['goFaxAdmin'][0],
373 'PASSWORD' => $attrs['goFaxPassword'][0]);
374 }
376 /* Get asterisk servers */
377 $ldap->cd ($this->current['BASE']);
378 $ldap->search ("(objectClass=goFonServer)");
379 $this->data['SERVERS']['FON']= array();
380 if ($ldap->count()){
381 while ($attrs= $ldap->fetch()){
382 $this->data['SERVERS']['FON'][]= array(
383 'SERVER' => $attrs['cn'][0],
384 'LOGIN' => $attrs['goFonAdmin'][0],
385 'PASSWORD' => $attrs['goFonPassword'][0],
386 'DB' => "gophone",
387 'SIP_TABLE' => "sip_users",
388 'EXT_TABLE' => "extensions",
389 'VOICE_TABLE' => "voicemail_users",
390 'QUEUE_TABLE' => "queues",
391 'QUEUE_MEMBER_TABLE' => "queue_members");
392 }
393 }
395 /* Get glpi servers */
396 $ldap->cd ($this->current['BASE']);
397 $ldap->search ("(&(objectClass=goGlpiServer)(cn=*)(goGlpiAdmin=*)(goGlpiDatabase=*))",array("cn","goGlpiPassword","goGlpiAdmin","goGlpiDatabase"));
398 if ($ldap->count()){
399 $attrs= $ldap->fetch();
400 if(!isset($attrs['goGlpiPassword'])){
401 $attrs['goGlpiPassword'][0] ="";
402 }
403 $this->data['SERVERS']['GLPI']= array(
404 'SERVER' => $attrs['cn'][0],
405 'LOGIN' => $attrs['goGlpiAdmin'][0],
406 'PASSWORD' => $attrs['goGlpiPassword'][0],
407 'DB' => $attrs['goGlpiDatabase'][0]);
408 }
409 /* Get logdb server */
410 $ldap->cd ($this->current['BASE']);
411 $ldap->search ("(objectClass=goLogDBServer)");
412 if ($ldap->count()){
413 $attrs= $ldap->fetch();
414 $this->data['SERVERS']['LOG']= array( 'SERVER' => $attrs['cn'][0],
415 'LOGIN' => $attrs['goLogAdmin'][0],
416 'PASSWORD' => $attrs['goLogPassword'][0]);
417 }
419 /* Get NFS server lists */
420 $tmp= array("default");
421 $ldap->cd ($this->current['BASE']);
422 $ldap->search ("(&(objectClass=goShareServer)(goExportEntry=*))");
423 while ($attrs= $ldap->fetch()){
424 for ($i= 0; $i<$attrs["goExportEntry"]["count"]; $i++){
425 $path= preg_replace ("/\s.*$/", "", $attrs["goExportEntry"][$i]);
426 $tmp[]= $attrs["cn"][0].":$path";
427 }
428 }
429 $this->data['SERVERS']['NFS']= $tmp;
432 /* Load Terminalservers */
433 $ldap->cd ($this->current['BASE']);
434 $ldap->search ("(objectClass=goTerminalServer)");
435 $this->data['SERVERS']['TERMINAL']= array();
436 $this->data['SERVERS']['TERMINAL'][]= "default";
438 $this->data['SERVERS']['FONT']= array();
439 $this->data['SERVERS']['FONT'][]= "default";
440 while ($attrs= $ldap->fetch()){
441 $this->data['SERVERS']['TERMINAL'][]= $attrs["cn"][0];
442 for ($i= 0; $i<$attrs["goFontPath"]["count"]; $i++){
443 $this->data['SERVERS']['FONT'][]= $attrs["goFontPath"][$i];
444 }
445 }
447 /* Ldap Server */
448 $this->data['SERVERS']['LDAP']= array();
449 $ldap->cd ($this->current['BASE']);
450 $ldap->search ("(objectClass=goLdapServer)");
451 while ($attrs= $ldap->fetch()){
452 if (isset($attrs["goLdapBase"])){
453 for ($i= 0; $i<$attrs["goLdapBase"]["count"]; $i++){
454 $this->data['SERVERS']['LDAP'][]= $attrs["cn"][0].":".$attrs["goLdapBase"][$i];
455 }
456 }
457 }
459 /* Get misc server lists */
460 $this->data['SERVERS']['SYSLOG']= array("default");
461 $this->data['SERVERS']['NTP']= array("default");
462 $ldap->cd ($this->current['BASE']);
463 $ldap->search ("(objectClass=goNtpServer)");
464 while ($attrs= $ldap->fetch()){
465 $this->data['SERVERS']['NTP'][]= $attrs["cn"][0];
466 }
467 $ldap->cd ($this->current['BASE']);
468 $ldap->search ("(objectClass=goSyslogServer)");
469 while ($attrs= $ldap->fetch()){
470 $this->data['SERVERS']['SYSLOG'][]= $attrs["cn"][0];
471 }
473 /* Get samba servers from LDAP, in case of samba3 */
474 if ($this->current['SAMBAVERSION'] == 3){
475 $this->data['SERVERS']['SAMBA']= array();
476 $ldap->cd ($this->current['BASE']);
477 $ldap->search ("(objectClass=sambaDomain)");
478 while ($attrs= $ldap->fetch()){
479 $this->data['SERVERS']['SAMBA'][$attrs['sambaDomainName'][0]]= array(
480 "SID" => $attrs["sambaSID"][0],
481 "RIDBASE" => $attrs["sambaAlgorithmicRidBase"][0]);
482 }
484 /* If no samba servers are found, look for configured sid/ridbase */
485 if (count($this->data['SERVERS']['SAMBA']) == 0){
486 if (!isset($this->current["SID"]) || !isset($this->current["RIDBASE"])){
487 print_red(_("SID and/or RIDBASE missing in your configuration!"));
488 echo $_SESSION['errors'];
489 exit;
490 } else {
491 $this->data['SERVERS']['SAMBA']['DEFAULT']= array(
492 "SID" => $this->current["SID"],
493 "RIDBASE" => $this->current["RIDBASE"]);
494 }
495 }
496 }
497 }
500 function get_departments($ignore_dn= "")
501 {
502 global $config;
504 /* Initialize result hash */
505 $result= array();
506 $administrative= array();
507 $result['/']= $this->current['BASE'];
508 $this->tdepartments= array();
510 /* Get list of department objects */
511 $ldap= $this->get_ldap_link();
512 $ldap->cd ($this->current['BASE']);
513 $ldap->search ("(objectClass=gosaDepartment)", array("ou", "objectClass", "gosaUnitTag"));
514 while ($attrs= $ldap->fetch()){
515 $dn= $ldap->getDN();
516 $this->tdepartments[$dn]= "";
518 /* Save administrative departments */
519 if (in_array_ics("gosaAdministrativeUnit", $attrs['objectClass']) &&
520 isset($attrs['gosaUnitTag'][0])){
521 $administrative[$dn]= $attrs['gosaUnitTag'][0];
522 $this->tdepartments[$dn]= $attrs['gosaUnitTag'][0];
523 }
525 if (in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass']) &&
526 isset($attrs['gosaUnitTag'][0])){
527 $this->tdepartments[$dn]= $attrs['gosaUnitTag'][0];
528 }
530 if ($dn == $ignore_dn){
531 continue;
532 }
534 /* Only assign non-root departments */
535 if ($dn != $result['/']){
536 $result[convert_department_dn($dn)]= $dn;
537 }
538 }
540 $this->adepartments= $administrative;
541 $this->departments= $result;
542 }
545 function make_idepartments($max_size= 28)
546 {
547 global $config;
548 $base = $config->current['BASE'];
550 $arr= array();
551 $ui= get_userinfo();
552 $this->idepartments= array();
554 /* Create multidimensional array, with all departments. */
555 foreach ($this->departments as $key => $val){
557 /* When using strict_units, filter non relevant parts */
558 if (isset($config->current['STRICT_UNITS']) && preg_match('/true/i', $config->current['STRICT_UNITS'])){
559 if ($ui->gosaUnitTag != "" && isset($this->tdepartments[$val]) &&
560 $this->tdepartments[$val] != $ui->gosaUnitTag){
561 continue;
562 }
563 }
565 /* remove base from dn */
566 $val2 = str_replace($base,"",$val);
568 /* Get every single ou */
569 $str = preg_replace("/ou=/","|ou=",$val2);
570 $elements = array_reverse(split("\|",$str));
572 /* Save last array position */
573 $last = &$arr;
575 /* Get array depth */
576 $cnt = count($elements);
578 /* Add last ou element of current dn to our array */
579 foreach($elements as $key => $ele){
581 /* skip enpty */
582 if(empty($ele)) continue;
584 /* Extract department name */
585 $elestr = preg_replace("/^ou=/","", $ele);
586 $elestr = preg_replace("/,$/","",$elestr);
588 /* Add to array */
589 if($key == ($cnt-2)){
590 $last[$elestr]['ENTRY'] = $val;
591 }
593 /* Set next array appending position */
594 $last = &$last[$elestr]['SUB'];
595 }
596 }
598 /* Add base entry */
599 $ret["/"]["ENTRY"] = $base;
600 $ret["/"]["SUB"] = $arr;
602 $this->idepartments= $this->generateDepartmentArray($ret,-1,$max_size);
603 }
606 /* Creates display friendly output from make_idepartments */
607 function generateDepartmentArray($arr,$depth = -1,$max_size){
608 $ret = array();
609 $depth ++;
611 /* Walk through array */
612 foreach($arr as $name => $entries){
614 /* If this department is the last in the current tree position
615 * remove it, to avoid generating output for it */
616 if(count($entries['SUB'])==0){
617 unset($entries['SUB']);
618 }
620 /* Fix name, if it contains a replace tag */
621 $name= @LDAP::fix($name);
623 /* Check if current name is too long, then cut it */
624 if(mb_strlen($name, 'UTF-8')> $max_size){
625 $name = mb_substr($name,0,($max_size-3), 'UTF-8')." ...";
626 }
628 /* Append the name to the list */
629 if(isset($entries['ENTRY'])){
630 $a = "";
631 for($i = 0 ; $i < $depth ; $i ++){
632 $a.=" ";
633 }
634 $ret[$entries['ENTRY']]=$a." ".$name;
635 }
637 /* recursive add of subdepartments */
638 if(isset($entries['SUB'])){
639 $ret = array_merge($ret,$this->generateDepartmentArray($entries['SUB'],$depth,$max_size));
640 }
641 }
643 return($ret);
644 }
646 /* This function returns all available Shares defined in this ldap
647 * There are two ways to call this function, if listboxEntry is true
648 * only name and path are attached to the array, in it is false, the whole
649 * entry will be parsed an atached to the result.
650 */
651 function getShareList($listboxEntry = false)
652 {
653 $ldap= $this->get_ldap_link();
655 /* Set tag attribute if we've tagging activated */
656 $tag= "";
657 $ui= get_userinfo();
658 if ($ui->gosaUnitTag != "" && isset($this->current['STRICT_UNITS']) &&
659 preg_match('/TRUE/i', $this->current['STRICT_UNITS'])){
660 $tag= "(gosaUnitTag=".$ui->gosaUnitTag.")";
661 }
663 $a_res = $ldap->search("(&(objectClass=goShareServer)$tag(objectClass=goServer))",array("goExportEntry","cn"));
664 $return= array();
665 while($entry = $ldap->fetch($a_res)){
666 if(isset($entry['goExportEntry']['count'])){
667 unset($entry['goExportEntry']['count']);
668 }
669 if(isset($entry['goExportEntry'])){
670 foreach($entry['goExportEntry'] as $export){
671 $shareAttrs = split("\|",$export);
672 if($listboxEntry) {
673 $return[$shareAttrs[0]."|".$entry['cn'][0]] = $shareAttrs[0]." - ".$entry['cn'][0];
674 }else{
675 $return[$shareAttrs[0]."|".$entry['cn'][0]]['server'] = $entry['cn'][0];
676 $return[$shareAttrs[0]."|".$entry['cn'][0]]['name'] = $shareAttrs[0];
677 $return[$shareAttrs[0]."|".$entry['cn'][0]]['description'] = $shareAttrs[1];
678 $return[$shareAttrs[0]."|".$entry['cn'][0]]['type'] = $shareAttrs[2];
679 $return[$shareAttrs[0]."|".$entry['cn'][0]]['charset'] = $shareAttrs[3];
680 $return[$shareAttrs[0]."|".$entry['cn'][0]]['path'] = $shareAttrs[4];
681 $return[$shareAttrs[0]."|".$entry['cn'][0]]['option'] = $shareAttrs[5];
682 }
683 }
684 }
685 }
686 return($return);
687 }
689 /* This function returns all available ShareServer */
690 function getShareServerList()
691 {
692 global $config;
693 $return = array();
694 $ui = get_userinfo();
695 $base = $config->current['BASE'];
696 $res = get_list("(&(objectClass=goShareServer)(goExportEntry=*))",$ui->subtreeACL,$base,array("goExportEntry","cn"),GL_SUBSEARCH);
697 foreach($res as $entry){
698 if(isset($entry['goExportEntry']['count'])){
699 unset($entry['goExportEntry']['count']);
700 }
701 foreach($entry['goExportEntry'] as $share){
702 $a_share = split("\|",$share);
703 $sharename = $a_share[0];
704 $return[$entry['cn'][0]."|".$sharename] = $entry['cn'][0]." [".$sharename."]";
705 }
707 }
708 return($return);
709 }
711 /* Check if there's the specified bool value set in the configuration */
712 function boolValueIsTrue($section, $value)
713 {
714 $section= strtoupper($section);
715 $value= strtoupper($value);
716 if (isset($this->data[$section][$value])){
718 $data= $this->data[$section][$value];
719 if (preg_match("/^true$/i", $data) || preg_match("/yes/i", $data)){
720 return TRUE;
721 }
723 }
725 return FALSE;
726 }
728 }
730 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
731 ?>