index eb63ea93b86ed2c001add07dee1f46a1ec5b0ce9..7d5582b06223aa3e1516d731c283fc1582978496 100644 (file)
function is_schema_readable($server, $admin, $password)
{
- $ds= ldap_connect ($server);
- if (!$ds) {
- return (false);
- }
- ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
- $r= ldap_bind ($ds, $admin, $password);
-
- /* Get base to look for schema */
- $sr = @ldap_read ($ds, NULL, "objectClass=*", array("subschemaSubentry"));
- $attr= @ldap_get_entries($ds,$sr);
- if (!isset($attr[0]['subschemasubentry'][0])){
- return (false);
- }
+ $ldap = new LDAP($admin,$password,$server);
+ $tmp = $ldap->get_objectclasses();
- $nb= $attr[0]['subschemasubentry'][0];
- $objectclasses= array();
- $sr= ldap_read ($ds, $nb, "objectClass=*", array("objectclasses"));
- $attrs= ldap_get_entries($ds,$sr);
- if (!isset($attrs[0])){
- return (false);
+ if(count($tmp)){
+ return(true);
}
- return(true);
+ return(false);
}
function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false)
@@ -92,35 +77,13 @@ function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false
"goFaxServer" => array("version" => "2.4", "class" => "gofaxAccount","file" => "gofax.schema"),
);
- /* Build LDAP connection */
- $ds= ldap_connect ($server);
- if (!$ds) {
- return (array(array("msg" => _("Can't bind to LDAP. No schema check possible!"), "status" => FALSE)));
- }
- ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
- $r= ldap_bind ($ds, $admin, $password);
-
- /* Get base to look for schema */
- $sr = @ldap_read ($ds, NULL, "objectClass=*", array("subschemaSubentry"));
- $attr= @ldap_get_entries($ds,$sr);
- if (!isset($attr[0]['subschemasubentry'][0])){
+ /* Get objectclasses */
+ $ldap = new LDAP($admin,$password, $server);
+ $objectclasses = $ldap->get_objectclasses();
+ if(count($objectclasses) == 0){
return (array(array("msg" => _("Can't get schema information from server. No schema check possible!"), "status" => FALSE)));
}
- /* Get list of objectclasses */
- $nb= $attr[0]['subschemasubentry'][0];
- $objectclasses= array();
- $sr= ldap_read ($ds, $nb, "objectClass=*", array("objectclasses"));
- $attrs= ldap_get_entries($ds,$sr);
- if (!isset($attrs[0])){
- return (array(array("msg" => _("Can't get schema information from server. No schema check possible!"), "status" => FALSE)));
- }
- foreach ($attrs[0]['objectclasses'] as $val){
- $name= preg_replace("/^.* NAME\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $val);
- if ($name != $val){
- $objectclasses[$name]= $val;
- }
- }
/* Walk through objectclasses and check if they are needed or not */
foreach ($required_classes as $key => $value){
if (isset($value['class'])){
$result= "<a href='http://de.php.net/manual/en/function.";
/* Replace all underscores with hyphens (phpdoc convention) */
+ /* hjb: added alternative check for GraphicsMagick >= 1.1.2 */
$function_name= str_replace("_", "-", $function_name);
/* Append to base URL */
$output= shell_exec ($query);
if ($output != ""){
$lines= split ("\n", $output);
- $version= preg_replace ("/^Version:.+Magick ([^\s]+).*/", "\\1", $lines[0]);
- list($major, $minor)= split("\.", $version);
- $msg.= check ( $faults, _("Checking for ImageMagick (>=5.4.0)"),
- _("ImageMagick is used to convert user supplied images to fit the suggested size and the unified JPEG format."),
- ($major > 5 || ($major == 5 && $minor >= 4)));
+ $version= preg_replace ("/^Version: (.+Magick) ([^\s]+).*/", "\\1 \\2", $lines[0]);
+ list($prog, $version) = split(" ", $version);
+ list($major, $minor,$minor2)= split("\.", $version);
+ if (preg_match('/GraphicsMagick/', $prog)) {
+ $msg.= check ( $faults, _("Checking for GraphicsMagick (>=1.1.2)"),
+ _("GraphicsMagick is used to convert user supplied images to fit the suggested size and the unified JPEG format."),
+ ($major > 1 || ($major == 1 && $minor >= 1) || ($major == 1 && $minor == 1 && $minor2 >= 2) ) );
+ } else {
+ $msg.= check ( $faults, _("Checking for ImageMagick (>=5.4.0)"),
+ _("ImageMagick is used to convert user supplied images to fit the suggested size and the unified JPEG format."),
+ ($major > 5 || ($major == 5 && $minor >= 4)));
+ }
} else {
$msg.= check ( $faults, _("Checking imagick module for PHP"),
_("Imagick is used to convert user supplied images to fit the suggested size and the unified JPEG format from PHP script."), function_exists('imagick_blob2image'), TRUE);
/* Show setup_page 1 */
function show_setup_page1($withoutput = true)
{
- $faults = array();
+ $faults = false;
+ $faults2 = false;
$smarty = get_smarty();
$smarty->assign ("content", get_template_path('setup_introduction.tpl'));
$smarty->assign ("tests", perform_php_checks($faults));
- $smarty->assign ("detailed_tests", perform_additional_function_checks($faults));
+ $smarty->assign ("detailed_tests", perform_additional_function_checks($faults2));
+
+ $faults = $faults || $faults2;
/* This var is true if anything went wrong */
if ($faults){
$smarty->display (get_template_path('setup.tpl'));
}
- return (!$faults);
+ return ($faults);
}
/* Show setup_page 2 */
function show_setup_page2($withoutput = true)
{
- $faults = array();
+ $faults = false;
$smarty = get_smarty();
$smarty->assign ("content", get_template_path('setup_step2.tpl'));
$smarty->assign ("tests", perform_additional_checks($faults));
$smarty->display (get_template_path('setup.tpl'));
}
- return (!$faults);
+ return ($faults);
}
/* No error till now */
$fault = false;
- /* If we pushed the Button continue */
- if(isset($_POST['continue3'])){
- if(!isset($uri)) {
- $fault = true;
-
- /* Output the Error */
- if($withoutput) {
- print_red (_("You've to specify an ldap server before continuing!"));
- $smarty->assign ("content", get_template_path('setup_step3.tpl'));
- }
- }
- } elseif (!$ds = @ldap_connect (validate($uri))) {
+ if (!$ds = @ldap_connect (validate($uri))) {
$fault =true;
/* Output the Error */
$smarty->display (get_template_path('setup.tpl'));
}
- return (!$fault);
+ return ($fault);
}
{
$smarty= get_smarty();
+ /* check POST data */
+ if(isset($_POST['check'])) {
+
+ /* Check if all needed vars are submitted */
+ foreach($checkvars as $key) {
+ if($key == "peopleou"){
+ continue;
+ }
+ if($key == "groupou"){
+ continue;
+ }
+
+ if((isset($_POST[$key]))&&($_POST[$key]!="")) {
+ $_SESSION['ldapconf'][$key] = $_POST[$key];
+ } else {
+ if($withoutput) {
+ print_red(sprintf(_("You're missing the required attribute '%s' from this formular. Please complete!"), $key));
+ }
+ $fault = true;
+ }
+ }
+ }
+
+ /* Transfer base */
+ if(isset($_POST['base'])){
+ $_SESSION['ldapconf']['base']= $_POST['base'];
+ }
+
// ?
if(!isset($_SESSION['ldapconf']['base'])){
$_SESSION['ldapconf']['base']= $base;
/* If there are some empty vars in ldapconnect -
these values also represent out default values */
- if(!$ds = @ldap_connect (validate($uri))){
+ if(!$ds = @ldap_connect (validate($uri))){
$fault = true;
if($withoutput){
print_red (_("Can't connect to the specified LDAP server! Please make sure that is reachable for GOsa."));
} elseif(!@ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)){
$fault = true;
if($withoutput){
- print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
+ print_red (_("Can't set ldap protocol version 3."));
}
} elseif(!$r= @ldap_bind ($ds)){
$fault = true;
if($withoutput){
- print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
+ print_red (_("Could not bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
}
} else {
- $sr= @ldap_search ($ds, NULL, "objectClass=*", array("namingContexts"));
+ $sr= @ldap_search ($r, NULL, "objectClass=*", array("namingContexts"));
$attr= @ldap_get_entries($ds,$sr);
if((empty($attr))) {
- $base= "dc=example,dc=net";
if($withoutput){
- print_red(_("Bind to server successful, but the server seems to be completly empty, please check all information twice"));
+# print_red(_("Bind to server successful, but the server seems to be completly empty, please check all information twice"));
}
} else {
$_SESSION['ldapconf']['arr_crypts'] = $tmp['md5'];
}
- /* check POST data */
- if(isset($_POST['check'])) {
-
- /* Check if all needed vars are submitted */
- foreach($checkvars as $key) {
- if($key == "peopleou"){
- continue;
- }
- if($key == "groupou"){
- continue;
- }
-
- if((isset($_POST[$key]))&&($_POST[$key]!="")) {
- $_SESSION['ldapconf'][$key] = $_POST[$key];
- } else {
- if($withoutput) {
- print_red(sprintf(_("You're missing the required attribute '%s' from this formular. Please complete!"), $key));
- }
- $fault = true;
- }
- }
- }
-
- /* Transfer base */
- if(isset($_POST['base'])){
- $_SESSION['ldapconf']['base']= $_POST['base'];
- }
-
$smarty->assign("arr_cryptkeys",$_SESSION['ldapconf']['arr_cryptkeys']);
$smarty->assign("mail_methods", $_SESSION['ldapconf']['mail_methods']);
$smarty->assign($key,$val);
}
- if(isset($_POST['check'])) {
+ if(isset($_POST['check']) || (isset($_POST['admin'])) && isset($_POST['password'])) {
$ldap= new LDAP($_SESSION['ldapconf']['admin'],
$_SESSION['ldapconf']['password'],
$_SESSION['ldapconf']['uri']);
if($withoutput){
$smarty->display (get_template_path('setup.tpl'));
}
- return (!$fault);
+
+ return ($fault);
}