From 9474213e3ea8cb152ac698aaaaccb73a3a456f3b Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Sat, 31 Dec 2005 15:19:48 +0000 Subject: [PATCH] Die on not writable directory. People seem to not get along with the Smarty error "Unable to read resource ''" pretty well. --- include/functions_smarty.inc.php | 69 +++++++++++++++++--------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/include/functions_smarty.inc.php b/include/functions_smarty.inc.php index 224915f..0063013 100644 --- a/include/functions_smarty.inc.php +++ b/include/functions_smarty.inc.php @@ -8,7 +8,7 @@ * @access public * @param int The ID of the entry * @param string How many trackbacks to show - * @param boolean If true, also non-approved trackbacks will be shown + * @param boolean If true, also non-approved trackbacks will be shown * @return */ function serendipity_fetchTrackbacks($id, $limit = null, $showAll = false) { @@ -90,15 +90,15 @@ function serendipity_emptyPrefix($string, $prefix = ': ') { * page: (int) The number of the page for paginating entries * id: (int) The ID of an entry. If given, only a single entry will be fetched. If left empty, multiple entries are fetched. * range: (mixed) Restricts fetching entries to a specific timespan. Behaves differently depending on the type: - * Numeric: - * YYYYMMDD - Shows all entries from YYYY-MM-DD. - * If DD is "00", it will show all entries from that month. + * Numeric: + * YYYYMMDD - Shows all entries from YYYY-MM-DD. + * If DD is "00", it will show all entries from that month. * If DD is any other number, it will show entries of that specific day. * 2-Dimensional Array: * Key #0 - Specifies the start timestamp (unix seconds) * Key #1 - Specifies the end timestamp (unix seconds) * Other (null, 3-dimensional Array, ...): - * Entries newer than $modified_since will be fetched + * Entries newer than $modified_since will be fetched * full (boolean) Indicates if the full entry will be fetched (body+extended: TRUE), or only the body (FALSE). * limit (string) Holds a "Y" or "X, Y" string that tells which entries to fetch. X is the first entry offset, Y is number of entries. If not set, the global fetchLimit will be applied (15 entries by default) * fetchDrafts (boolean) Indicates whether drafts should be fetched (TRUE) or not @@ -107,7 +107,7 @@ function serendipity_emptyPrefix($string, $prefix = ': ') { * filter_sql (string) Can contain any SQL code to inject into the central SQL statement for fetching the entry * noCache (boolean) If set to TRUE, all entries will be fetched from scratch and any caching is ignored * noSticky (boolean) If set to TRUE, all sticky entries will NOT be fetched. - * + * * [PRINTING] * template: (string) Name of the template file to print entries with * preview: (boolean) Indicates if this is a preview @@ -132,7 +132,7 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) { if (empty($params['template'])) { $params['template'] = 'entries.tpl'; } - + if (empty($params['range'])) { $params['range'] = null; } @@ -140,7 +140,7 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) { if (empty($params['full'])) { $params['full'] = true; } - + if (empty($params['fetchDrafts'])) { $params['fetchDrafts'] = false; } @@ -164,7 +164,7 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) { if (empty($params['preview'])) { $params['preview'] = false; } - + if (empty($params['block'])) { $params['block'] = 'smarty_entries_' . $entrycount; } @@ -176,11 +176,11 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) { if (empty($params['use_footer'])) { $params['use_footer'] = false; } - + if (empty($params['groupmode'])) { $params['groupmode'] = 'date'; } - + if (empty($params['skip_smarty_hooks'])) { $params['skip_smarty_hooks'] = true; } @@ -196,7 +196,7 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) { $old_var['short_archives'] = $serendipity['short_archives']; $serendipity['short_archives'] = $params['short_archives']; } - + $old_var['skip_smarty_hooks'] = $serendipity['skip_smarty_hooks']; $serendipity['skip_smarty_hooks'] = $params['skip_smarty_hooks']; @@ -212,29 +212,29 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) { if (!empty($params['id'])) { $entry = serendipity_fetchEntry( - 'id', - (int)$params['id'], - $params['full'], + 'id', + (int)$params['id'], + $params['full'], $params['fetchDrafts']); } else { $entry = serendipity_fetchEntries( - $params['range'], - $params['full'], - $params['limit'], - $params['fetchDrafts'], - $params['modified_since'], - $params['orderby'], - $params['filter_sql'], - $params['noCache'], + $params['range'], + $params['full'], + $params['limit'], + $params['fetchDrafts'], + $params['modified_since'], + $params['orderby'], + $params['filter_sql'], + $params['noCache'], $params['noSticky'] ); - + // Check whether the returned entries shall be grouped specifically switch ($params['groupmode']) { case 'date': // No regrouping required, printEntries() does it for us. break; - + case 'category': // Regroup by primary category @@ -262,12 +262,12 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) { $params['use_footer'], ($params['groupmode'] == 'date' ? true : false) // Grouping of $entry ); - + // Restore the $serendipity array after our modifications. if (isset($old_var['short_archives'])) { $serendipity['short_archives'] = $old_var['short_archives']; } - + if (is_array($old_var['GET'])) { foreach($old_var['GET'] AS $key => $val) { $serendipity['GET'][$key] = $val; @@ -275,7 +275,7 @@ function serendipity_smarty_fetchPrintEntries($params, &$smarty) { } $out = serendipity_smarty_fetch($params['block'], $params['template']); - + $serendipity['skip_smarty_hook'] = $old_var['skip_smarty_hook']; $serendipity['skip_smarty_hooks'] = $old_var['skip_smarty_hooks']; @@ -346,12 +346,12 @@ function serendipity_smarty_hookPlugin($params, &$smarty) { $smarty->trigger_error(__FUNCTION__ .": illegal hook '". $params['hook'] ."'"); return; } - + // Smarty hooks can be bypassed via an internal variable (temporarily) if (isset($serendipity['skip_smarty_hooks']) && $serendipity['skip_smarty_hooks']) { return; } - + // A specific hook can also be bypassed by creating an associative array like this: // $serendipity['skip_smarty_hook'] = array('entries_header'); // That would only skip the entries_header event hook, but allow all others. @@ -487,7 +487,7 @@ function &serendipity_smarty_printComments($params, &$smarty) { } /** - * Smarty Function: Show Trackbacks + * Smarty Function: Show Trackbacks * * @access public * @param array Smarty parameter input array: @@ -539,6 +539,11 @@ function serendipity_smarty_init() { $serendipity['serendipityPath'] . $serendipity['templatePath'] . 'default' ); $serendipity['smarty']->compile_dir = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE; + + if (!is_dir($serendipity['smarty']->compile_dir) || !is_writable($serendipity['smarty']->compile_dir)) { + serendipity_die(sprintf(DIRECTORY_WRITE_ERROR, $serendipity['smarty']->compile_dir)); + } + $serendipity['smarty']->config_dir = &$serendipity['smarty']->template_dir[0]; $serendipity['smarty']->secure_dir = array($serendipity['serendipityPath'] . $serendipity['templatePath']); $serendipity['smarty']->security_settings['MODIFIER_FUNCS'] = array('sprintf', 'sizeof', 'count', 'rand'); @@ -588,7 +593,7 @@ function serendipity_smarty_init() { $category_info = serendipity_fetchCategoryInfo($category); } } - + if (!isset($serendipity['smarty_vars']['head_link_stylesheet'])) { $serendipity['smarty_vars']['head_link_stylesheet'] = serendipity_rewriteURL('serendipity.css'); } -- 2.39.5