public static function createDir($strPath, $rights = 0777)
    {
        $folderPath = array($strPath);
        $oldumask = umask(0);

        while (!@is_dir(dirname(end($folderPath)))
            && dirname(end($folderPath)) != "/"
            && dirname(end($folderPath)) != "."
            && dirname(end($folderPath)) != ""
        ) {
            array_push($folderPath, dirname(end($folderPath)));
        }

        while ($parentFolderPath = array_pop($folderPath)) {
            if (!@is_dir($parentFolderPath)) {
                if (!@mkdir($parentFolderPath, $rights)) {
                    throw new \RuntimeException("Runtime Error: Can't create folder: $parentFolderPath");
                }
            }
        }

        umask($oldumask);
    }