X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=inc%2Futils.php;h=a5a1c8be6cf72acbf98f99cccb1aa219766058c5;hp=a55e8794296c3ce6c90c4cc22e649b3a8077fb60;hb=19730f2e2bbf61f389882c646f58349df3bcd848;hpb=9d328be613bc25ef3f19f751bcf4de59343944c6 diff --git a/inc/utils.php b/inc/utils.php index a55e879..a5a1c8b 100644 --- a/inc/utils.php +++ b/inc/utils.php @@ -2,7 +2,9 @@ /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD license. */ -require_once ("inc/settings.php"); +// using include because that file may be sourced even if config file has not +// been created. +@include_once ("inc/settings.php"); function getthumbsdir () { if (THUMBSDIR) { @@ -45,7 +47,7 @@ function unquote($gpc_str) { function thumb_url_from_imgpath ($filename) { if (defined ("THUMBSDIRURL") && (strlen (THUMBSDIRURL) != 0)) { - return rtrim (THUMBSDIRURL, '/') . "/_mini" . rawurlencode ($filename); + return rtrim (THUMBSDIRURL, '/') . "/mini_" . rawurlencode ($filename); } return full_url_from_path (getthumbsdir () . "/mini_" . rawurlencode ($filename)); } @@ -180,39 +182,4 @@ function create_thumbnail ($filename, $destfile) { return true; } - -function safe_create_dir ($dirname) { - if (is_dir ($dirname)) { - return; - } - if (file_exists ($dirname)) { - par_error ($dirname . ": " . trans ('exist but is not a directory')); - } - if (!mkdir ($dirname)) { - par_error ($dirname . ": " . trans ('could not create directory')); - } else { - par_success ($dirname . ": " . trans ('directory created')); - } -} - -function safe_create_writable_dir ($dirname) { - safe_create_dir ($dirname); - if (!is_writeable ($dirname) || !is_executable ($dirname)) { - par_error ($dirname . ": " . trans ('could not write in directory')); - } -} - -function leave () { - exit ("\n"); -} -function par_success ($message) { - printf ("

%s

", $message); -} -function par_error ($message) { - printf ("

%s

", $message); - leave (); -} -function par_warn ($message) { - printf ("

%s

", $message); -} ?>