bug 968: Check if directories already exist before creating them bug-968
authorMichael Tänzer <neo@nhng.de>
Wed, 14 Sep 2011 01:43:55 +0000 (03:43 +0200)
committerMichael Tänzer <neo@nhng.de>
Wed, 14 Sep 2011 01:43:55 +0000 (03:43 +0200)
In function generatecertpath()

Signed-off-by: Michael Tänzer <neo@nhng.de>
includes/general.php

index ebdf20e..8481018 100644 (file)
                if($newlayout)
                {
                        $name="../$type/$kind/".intval($id/1000)."/$kind-".intval($id).".$type";
-                       mkdir("../csr/$kind",0777);
-                       mkdir("../crt/$kind",0777);
-                       mkdir("../csr/$kind/".intval($id/1000));
-                       mkdir("../crt/$kind/".intval($id/1000));
+                       if (!is_dir("../csr")) { mkdir("../csr",0777); }
+                       if (!is_dir("../crt")) { mkdir("../crt",0777); }
+                       
+                       if (!is_dir("../csr/$kind")) { mkdir("../csr/$kind",0777); }
+                       if (!is_dir("../crt/$kind")) { mkdir("../crt/$kind",0777); }
+                       if (!is_dir("../csr/$kind/".intval($id/1000))) { mkdir("../csr/$kind/".intval($id/1000)); }
+                       if (!is_dir("../crt/$kind/".intval($id/1000))) { mkdir("../crt/$kind/".intval($id/1000)); }
                }
                return $name;
        }