function serendipity_fetchTemplates($dir = '') {
global $serendipity;
- $cdir = opendir($serendipity['serendipityPath'] . $serendipity['templatePath'] . $dir);
- $rv = array();
+ $cdir = @opendir($serendipity['serendipityPath'] . $serendipity['templatePath'] . $dir);
+ $rv = array();
+ if (!$cdir) {
+ return $rv;
+ }
while (($file = readdir($cdir)) !== false) {
if (is_dir($serendipity['serendipityPath'] . $serendipity['templatePath'] . $dir . $file) && !ereg('^(\.|CVS)', $file) && !file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $dir . $file . '/inactive.txt')) {
if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $dir . $file . '/info.txt')) {