diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3d36aa4..8ee0248 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,33 @@
+# Under development: [FlatPress 1.3](https://github.com/flatpressblog/flatpress/releases/tag/1.3)
+## General
+- Added [SECURITY.md](https://github.com/flatpressblog/flatpress/blob/master/SECURITY.md)
+- [README](https://github.com/flatpressblog/flatpress/blob/master/README.md): added "help and support" section
+
+## Plugins
+- Gallery captions plugin added (see [#108](https://github.com/flatpressblog/flatpress/issues/108))
+- PhotoSwipe plugin added (see [#109](https://github.com/flatpressblog/flatpress/issues/109))
+- jQuery plugin: Updated jQuery (3.5.1 => 3.6) and jQueryUI (1.12.1 => 1.13.1)
+- Media Manager plugin shows 50 items per page, not 10
+
+## Themes
+- Leggero theme: Fixed searchbox glitch in FlatMaas revisited style (see [#97](https://github.com/flatpressblog/flatpress/issues/97))
+- Leggero theme: Fixed missing bullets in preview (see [#98](https://github.com/flatpressblog/flatpress/issues/98))
+- Leggero theme: CSS of the Leggero style had some glitches on mobile devices
+- Leggero theme: Invalid HTML output fixed (see [#106](https://github.com/flatpressblog/flatpress/issues/106))
+- Leggero theme: Removed unneccessary external font resource (see [#112](https://github.com/flatpressblog/flatpress/issues/112))
+
+## Bugfixes
+- Comment Center config page threw errors (see [#90](https://github.com/flatpressblog/flatpress/issues/90))
+- Fixed glitches in Spanish an Portuguese language files
+- Plugin management page: Removed empty warning messages box
+- Fixed wrong pt-br country code (see [#100](https://github.com/flatpressblog/flatpress/issues/100))
+- Fixed error at prev link on first / next link on last entry (see [#95](https://github.com/flatpressblog/flatpress/issues/95))
+- LastComments plugin will not even attempt to delete or rebuild LastComments caches if LastComments plugin is not available (see [#43](https://github.com/flatpressblog/flatpress/issues/43))
+
+## Security
+- Fixed security issue reported by huntr.dev: Session cookie missed the "secure" flag
+- Possible path traversal in Media Manager plugin prevented
+
# 2021-06-19: [FlatPress 1.2.1](https://github.com/flatpressblog/flatpress/releases/tag/1.2.1)
## Bugfixes
- BOM in French language files lead to blank page in admin area (see [#82](https://github.com/flatpressblog/flatpress/issues/82))
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index c149894..9681166 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -28,11 +28,12 @@ Since 2018, FlatPress is taken care of by [Arvid Zimmermann](https://github.com/
## Libraries
FlatPress utilizes the following free frameworks and libraries. Thanks to their authors!
-- [jQuery](https://jquery.com/)
-- [jQuery UI](https://jqueryui.com/)
- [Smarty Template Engine](https://www.smarty.net/) by Monte Ohrt and Uwe Tews
- [BBCode Parser](http://christian-seiler.de/projekte/php/bbcode/) by Christian Seiler
+- [jQuery](https://jquery.com/)
+- [jQuery UI](https://jqueryui.com/)
- [SlimBox2](https://www.digitalia.be/software/slimbox2/) by Christophe Beyls
+- [PhotoSwipe](https://photoswipe.com/) by Dmytro Semenov
## Other contributions
- [Julian Rademacher](https://moortaube.de/) generously donated his Twitter account [@FlatPress](https://twitter.com/FlatPress). Also thanks for your useful pull requests!
diff --git a/admin/admin-inline.tpl b/admin/admin-inline.tpl
index 648f24a..926b8e2 100644
--- a/admin/admin-inline.tpl
+++ b/admin/admin-inline.tpl
@@ -1,4 +1,4 @@
-
+
{$flatpress.title}{$pagetitle}
diff --git a/admin/index.php b/admin/index.php
index db0b4f9..eeee52f 100755
--- a/admin/index.php
+++ b/admin/index.php
@@ -1,10 +1,9 @@
-
+
FlatPress
diff --git a/admin/panels/config/admin.config.tpl b/admin/panels/config/admin.config.tpl
index 8424cf5..b9a4db9 100644
--- a/admin/panels/config/admin.config.tpl
+++ b/admin/panels/config/admin.config.tpl
@@ -101,7 +101,10 @@
- {$panelstrings.output}: {$smarty.now|date_format:$fp_config.locale.timeformat}
+ {assign var=currentTime value=$smarty.now}
+ {assign var=timeDiff value=$fp_config.locale.timeoffset}
+ {assign var=TimeDiffUTC value=$currentTime+$timeDiff*3600}
+ {$panelstrings.output}: {$TimeDiffUTC|date_format:$fp_config.locale.timeformat}
diff --git a/admin/panels/entry/admin.entry.commentlist.tpl b/admin/panels/entry/admin.entry.commentlist.tpl
index 7f3f8df..59b54d7 100755
--- a/admin/panels/entry/admin.entry.commentlist.tpl
+++ b/admin/panels/entry/admin.entry.commentlist.tpl
@@ -3,7 +3,7 @@
{entry}
{comment_block}
{html_form}
-
+ * echo '
* ';
*
* }
@@ -105,7 +105,9 @@ class admin_plugin_default extends AdminPanelAction {
function main() {
// $conf = io_load_file(CONFIG_DIR . 'plugins.conf.php');
- $this->smarty->assign('warnings', $this->errors);
+ if (!empty($this->errors)) {
+ $this->smarty->assign('warnings', $this->errors);
+ }
$this->smarty->assign('enabledlist', $this->fp_plugins);
lang_load('admin.plugin');
diff --git a/admin/panels/uploader/admin.uploader.php b/admin/panels/uploader/admin.uploader.php
index 0d16c3a..8cc6ca2 100755
--- a/admin/panels/uploader/admin.uploader.php
+++ b/admin/panels/uploader/admin.uploader.php
@@ -29,8 +29,9 @@ class admin_uploader_default extends AdminPanelAction {
);
function main() {
- if ($f = sess_remove('admin_uploader_files'))
+ if ($f = sess_remove('admin_uploader_files')) {
$this->smarty->assign('uploaded_files', $f);
+ }
}
function onupload() {
@@ -97,6 +98,7 @@ class admin_uploader_default extends AdminPanelAction {
// I've not put BMPs
$uploaded_files = array();
+ $this->smarty->assign('uploaded_files', $uploaded_files);
foreach ($_FILES ["upload"] ["error"] as $key => $error) {
diff --git a/admin/panels/widgets/admin.widgets.default.php b/admin/panels/widgets/admin.widgets.default.php
index d3b60cf..5c58d85 100644
--- a/admin/panels/widgets/admin.widgets.default.php
+++ b/admin/panels/widgets/admin.widgets.default.php
@@ -1,124 +1,107 @@
';
- }
- add_action('wp_footer', 'admin_widgets_head');
-
-
- class admin_widgets_default extends AdminPanelAction {
-
- //var $validators = array(array('content', 'content', 'notEmpty', false, false));
- var $events = array('save');
-
-
- function get_widget_lists($wlist, $wpos, &$widget_list, $registered_w, $add_empties) {
-
- if (!isset($wlist[$wpos]))
- return;
-
- $widget_list[$wpos] = array();
-
- foreach($wlist[$wpos] as $idx => $wdg) {
-
- $widget_list[$wpos][$idx] = array();
-
- $newid = $wdg; # @list($newid, $params) = explode(":", $wdg);
-
- $widget_list[$wpos][$idx]['id'] = $newid;
-
-
- if (isset($registered_w[$newid])){
- $thiswdg = $registered_w[$newid];
-
- $widget_list[$wpos][$idx]['name'] = $thiswdg['name'];
-
- if ($thiswdg['nparams'] > 0) {
- $widget_list[$wpos][$idx]['params'] = $params;
- }
-
- /*
- * here should go the check for
- * limited parameters: parameters limited to a
- * particular set would mean using a control
- * in the template
- *
- */
-
- } else {
- global $lang;
-
- $widget_list[$wpos][$idx]['name'] = $newid;
- $widget_list[$wpos][$idx]['class'] = 'errors';
-
- $errs = sprintf($lang['admin']['widgets']['errors']['generic'], $newid);
- $this->smarty->append('warnings', $errs);
-
- }
+function admin_widgets_head() {
+ echo '';
+}
+add_action('wp_footer', 'admin_widgets_head');
+
+class admin_widgets_default extends AdminPanelAction {
+
+ // var $validators = array(array('content', 'content', 'notEmpty', false, false));
+ var $events = array(
+ 'save'
+ );
+
+ function get_widget_lists($wlist, $wpos, &$widget_list, $registered_w, $add_empties) {
+ if (!isset($wlist [$wpos]))
+ return;
+
+ $widget_list [$wpos] = array();
+
+ foreach ($wlist [$wpos] as $idx => $wdg) {
+
+ $widget_list [$wpos] [$idx] = array();
+
+ $newid = $wdg; // @list($newid, $params) = explode(":", $wdg);
+
+ $widget_list [$wpos] [$idx] ['id'] = $newid;
+
+ if (isset($registered_w [$newid])) {
+ $thiswdg = $registered_w [$newid];
+
+ $widget_list [$wpos] [$idx] ['name'] = $thiswdg ['name'];
+
+ if ($thiswdg ['nparams'] > 0) {
+ $widget_list [$wpos] [$idx] ['params'] = $params;
}
-
-
- if (!$widget_list[$wpos] && !$add_empties)
- unset($widget_list[$wpos]);
-
-
- }
-
- function main() {
-
-
- lang_load('admin.widgets');
- # $this->smarty->assign('warnings', admin_widgets_checkall());
- global $fp_widgets;
-
-
- $registered_w = get_registered_widgets();
- $registered_ws = get_registered_widgetsets(null);
- $this->smarty->assign('fp_registered_widgets', $registered_w);
-
-
- $wlist = $fp_widgets->getList();
- $widget_list = array();
-
- foreach($registered_ws as $wpos) {
-
- $widget_list[$wpos] = array();
-
- $this->get_widget_lists($wlist, $wpos, $widget_list, $registered_w, true);
-
- unset($wlist[$wpos]);
-
+
+ /*
+ * here should go the check for
+ * limited parameters: parameters limited to a
+ * particular set would mean using a control
+ * in the template
+ *
+ */
+ } else {
+
+ global $lang;
+
+ $widget_list [$wpos] [$idx] ['name'] = $newid;
+ $widget_list [$wpos] [$idx] ['class'] = 'errors';
+
+ $errs = sprintf($lang ['admin'] ['widgets'] ['errors'] ['generic'], $newid);
+ $this->smarty->append('warnings', $errs);
}
-
- $oldwidget_list = array();
- foreach($wlist as $wpos => $c){
- $this->get_widget_lists($wlist, $wpos, $oldwidget_list, $registered_w, false);
- }
-
- $this->smarty->assign('widgetlist', $widget_list);
- $this->smarty->assign('oldwidgetlist', $oldwidget_list);
-
-
- $conf = io_load_file(CONFIG_DIR . 'widgets.conf.php');
-
- $this->smarty->assign('pluginconf', $conf);
-
- return 0;
-
-
}
-
- function onsave() {
-
- $fp_widgets = isset($_POST['widgets'])? $_POST['widgets'] : array();
- $success = system_save(CONFIG_DIR . 'widgets.conf.php', compact('fp_widgets'));
-
- $this->smarty->assign('success', ( $success )? 1 : -1 );
-
- return PANEL_REDIRECT_CURRENT;
-
- }
-
+ if (!$widget_list [$wpos] && !$add_empties)
+ unset($widget_list [$wpos]);
}
+
+ function main() {
+ lang_load('admin.widgets');
+ // $this->smarty->assign('warnings', admin_widgets_checkall());
+ global $fp_widgets;
+
+ $registered_w = get_registered_widgets();
+ $registered_ws = get_registered_widgetsets(null);
+ $this->smarty->assign('fp_registered_widgets', $registered_w);
+
+ $wlist = $fp_widgets->getList();
+ $widget_list = array();
+
+ foreach ($registered_ws as $wpos) {
+
+ $widget_list [$wpos] = array();
+
+ $this->get_widget_lists($wlist, $wpos, $widget_list, $registered_w, true);
+
+ unset($wlist [$wpos]);
+ }
+
+ $oldwidget_list = array();
+ foreach ($wlist as $wpos => $c) {
+ $this->get_widget_lists($wlist, $wpos, $oldwidget_list, $registered_w, false);
+ }
+
+ $this->smarty->assign('widgetlist', $widget_list);
+ $this->smarty->assign('oldwidgetlist', $oldwidget_list);
+
+ $conf = io_load_file(CONFIG_DIR . 'widgets.conf.php');
+
+ $this->smarty->assign('pluginconf', $conf);
+
+ return 0;
+ }
+
+ function onsave() {
+ $fp_widgets = isset($_POST ['widgets']) ? $_POST ['widgets'] : array();
+ $success = system_save(CONFIG_DIR . 'widgets.conf.php', compact('fp_widgets'));
+
+ $this->smarty->assign('success', ($success) ? 1 : -1);
+
+ return PANEL_REDIRECT_CURRENT;
+ }
+
+}
?>
diff --git a/contact.php b/contact.php
index 09ee813..c83766d 100755
--- a/contact.php
+++ b/contact.php
@@ -1,70 +1,119 @@
value) - or false
if validation failed
+ *
+ * @return boolean|array
+ */
function contact_form_validate() {
- $arr ['version'] = system_ver();
- $arr ['name'] = $_POST ['name'];
+ global $smarty, $contactform_inputs, $lang;
- if (!empty($_POST ['email']))
- ($arr ['email'] = $_POST ['email']);
- if (!empty($_POST ['url']))
- ($arr ['url'] = $_POST ['url']);
- $arr ['content'] = $_POST ['content'];
+ // if the request does not contain all input fields, it might be forged
+ foreach ($contactform_inputs as $input) {
+ if (!array_key_exists($input, $_POST)) {
+ return false;
+ }
+ }
- $arr ['ip-address'] = utils_ipget();
+ $errors = array();
- if (apply_filters('comment_validate', true, $arr))
- return $arr;
- else
+ $name = trim(htmlspecialchars($_POST ['name']));
+ $email = trim(htmlspecialchars($_POST ['email']));
+ $url = trim(stripslashes(htmlspecialchars($_POST ['url'])));
+ $content = trim(addslashes($_POST ['content']));
+
+ // check name
+ if (empty($name)) {
+ $errors ['name'] = $lang ['contact'] ['error'] ['name'];
+ }
+
+ // check email
+ if (!empty($email) && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
+ $errors ['email'] = $lang ['contact'] ['error'] ['email'];
+ }
+
+ // check url
+ if (!empty($url) && !filter_var($url, FILTER_VALIDATE_URL)) {
+ $errors ['url'] = $lang ['contact'] ['error'] ['www'];
+ }
+
+ // check content
+ if (empty($content)) {
+ $errors ['content'] = $lang ['contact'] ['error'] ['content'];
+ }
+
+ // assign error messages to template
+ if (!empty($errors)) {
+ $smarty->assign('error', $errors);
return false;
+ }
+
+ $arr ['version'] = system_ver();
+ $arr ['name'] = $name;
+
+ if (!empty($email)) {
+ ($arr ['email'] = $email);
+ }
+ if (!empty($url)) {
+ ($arr ['url'] = ($url));
+ }
+ $arr ['content'] = $content;
+
+ if ($v = utils_ipget()) {
+ $arr ['ip-address'] = $v;
+ }
+
+ return $arr;
}
function contact_form() {
- global $smarty, $lang, $fp_config;
+ global $smarty, $lang, $fp_config, $contactform_inputs;
+ // initial call of the contact form
if (empty($_POST)) {
-
$smarty->assign('success', system_geterr('contact'));
$smarty->assign_by_ref('panelstrings', $lang ['contact']);
-
- // new form, we (re)set the session data
- SmartyValidate::connect($smarty, true);
- // register our validators
- SmartyValidate::register_validator('name', 'name', 'notEmpty', false, false, 'trim');
- SmartyValidate::register_validator('email', 'email', 'isEmail', true, false, 'trim');
- SmartyValidate::register_validator('www', 'url', 'isURL', true, false, 'trim');
- SmartyValidate::register_validator('content', 'content', 'notEmpty', false, false);
- } else {
- utils_nocache_headers();
- // validate after a POST
- SmartyValidate::connect($smarty);
-
- // add http to url if not given
- if (!empty($_POST ['url']) && strpos($_POST ['url'], 'http://') === false && strpos($_POST ['url'], 'https://') === false)
- $_POST ['url'] = 'http://' . $_POST ['url'];
-
- // custom hook here!!
- // we'll use comment actions, anyway
- if (SmartyValidate::is_valid($_POST) && $arr = contact_form_validate()) {
-
- $msg = "Name: \n{$arr['name']} \n\n";
-
- if (isset($arr ['email']))
- $msg .= "Email: {$arr['email']}\n\n";
- if (isset($arr ['url']))
- $msg .= "WWW: {$arr['url']}\n\n";
- $msg .= "Content:\n{$arr['content']}\n";
-
- $success = @utils_mail((isset($arr ['email']) ? $arr ['email'] : $fp_config ['general'] ['email']), "Contact sent through {$fp_config['general']['title']} ", $msg);
-
- system_seterr('contact', $success ? 1 : -1);
- utils_redirect(basename(__FILE__));
- } else {
- $smarty->assign('values', $_POST);
- }
+ return;
}
+
+ // new form, we (re)set the session data
+ utils_nocache_headers();
+
+ $validationResult = contact_form_validate();
+
+ // if validation failed
+ if ($validationResult === false) {
+ // assign given input values to the template, so they're prefilled again
+ $smarty->assign('values', $_POST);
+ return;
+ }
+
+ // okay, validation returned validated values
+ // now build the mail content
+ $msg = "Name: \n{$validationResult['name']} \n\n";
+
+ if (isset($validationResult ['email'])) {
+ $msg .= "Email: {$validationResult['email']}\n\n";
+ }
+ if (isset($validationResult ['url'])) {
+ $msg .= "WWW: {$validationResult['url']}\n\n";
+ }
+ $msg .= "Content:\n{$validationResult['content']}\n";
+
+ // send notification mail to site admin
+ $success = @utils_mail((isset($validationResult ['email']) ? $validationResult ['email'] : $fp_config ['general'] ['email']), "Contact sent through {$fp_config['general']['title']} ", $msg);
+ system_seterr('contact', $success ? 1 : -1);
+ utils_redirect(basename(__FILE__));
}
function contact_main() {
@@ -92,6 +141,4 @@ function contact_display() {
}
system_init();
-contact_display();
-
-?>
+contact_display();
\ No newline at end of file
diff --git a/fp-defaults/plugins.conf.php b/fp-defaults/plugins.conf.php
index 01b7891..c17b56a 100755
--- a/fp-defaults/plugins.conf.php
+++ b/fp-defaults/plugins.conf.php
@@ -28,5 +28,7 @@ $fp_plugins = array(
'readmore',
'favicon',
'commentcenter',
- 'mediamanager'
+ 'mediamanager',
+ 'gallerycaptions',
+ 'photoswipe'
);
\ No newline at end of file
diff --git a/fp-includes/core/core.filesystem.php b/fp-includes/core/core.filesystem.php
index 219296d..3df52b4 100755
--- a/fp-includes/core/core.filesystem.php
+++ b/fp-includes/core/core.filesystem.php
@@ -1,293 +1,301 @@
- */
-
- class fs_filelister {
-
- var $_list = array();
- var $_directory = null;
-
-
- //constructor
- function __construct($directory = null) {
- if ($directory) $this->_directory = $directory;
- $this->_listFiles($this->_directory);
- }
-
- function _checkFile($directory, $file) {
- if (!is_dir("$directory/$file"))
- array_push($this->_list, $file);
- return 0;
- }
-
- function _exitingDir($directory, $file) {
-
- }
-
- function _listFiles($directory) {
-
- // Try to open the directory
- if (!file_exists($directory)) return array();
-
- if($dir = opendir($directory)) {
- // Add the files
- while($file = readdir($dir)) {
-
- if ($file != '.' && $file != '..') {
-
- $action = $this->_checkFile($directory,$file);
-
- // $action == 0: ok, go on
- // $action == 1: recurse
- // $action == 2: exit function
-
- switch ($action) {
- case (1): {
+/**
+ * Filesystem lib
+ * provides basic filesystem handling functions.
+ *
+ * @author NoWhereMan
+ */
+class fs_filelister {
+
+ var $_list = array();
+
+ var $_directory = null;
+
+ // constructor
+ function __construct($directory = null) {
+ if ($directory)
+ $this->_directory = $directory;
+ $this->_listFiles($this->_directory);
+ }
+
+ function _checkFile($directory, $file) {
+ if (!is_dir("$directory/$file"))
+ array_push($this->_list, $file);
+ return 0;
+ }
+
+ function _exitingDir($directory, $file) {
+ }
+
+ function _listFiles($directory) {
+
+ // Try to open the directory
+ if (!file_exists($directory))
+ return array();
+
+ if ($dir = opendir($directory)) {
+ // Add the files
+ while ($file = readdir($dir)) {
+ if (!fs_is_directorycomponent($file)) {
+ $action = $this->_checkFile($directory, $file);
+
+ // $action == 0: ok, go on
+ // $action == 1: recurse
+ // $action == 2: exit function
+
+ switch ($action) {
+ case (1):
+ {
$this->_listFiles("$directory/$file");
$this->_exitingDir($directory, $file);
break;
}
- case (2): {
+ case (2):
+ {
return false;
}
- }
}
-
}
-
+ }
+
// Finish off the function
closedir($dir);
return true;
- }
- else return false;
-
- }
-
- function getList() {
- //$this->_listFiles($this->_directory);
- return $this->_list;
- }
-
- function count() {
- if (!isset ($this->count))
- $this->count = count($this->_list);
- return $this->count;
- }
-
- }
-
- class fs_pathlister extends fs_filelister {
- function _checkFile($directory, $file) {
- $f = "$directory/$file";
- if (!is_dir($f))
- array_push($this->_list, $f);
- else
- return 1;
- }
-
- }
-
- // dir list
- function fs_list_dirs($dir) {
- $dh = opendir($dir);
- while (false !== ($filename = readdir($dh))) {
- if ( ($filename[0] != '.') ) {
- // $id = lang_id($filename);
- $files[] = $filename;
- }
-
-
- }
- sort($files);
- return $files;
- }
-
-
- /**
- * function fs_mkdir
- *
- * Function from : {@link http://www.php.net/function.mkdir.php}
- *
- * Recursively creates dirs.
- * Returns true on success, else false
- *
- * @param string $path Directory or directories to create
- * @param int $mode octal mode value; same as UNIX chmod; defaults to 0777 (rwrwrw);
- * @return bool
- *
- * @todo cleanup & check bool return value
- *
- */
- function fs_mkdir($dir, $mode=DIR_PERMISSIONS) {
- if (is_dir($dir) || (@mkdir($dir,$mode))) {@chmod($dir, $mode); return TRUE;}
- if (!fs_mkdir(dirname($dir),$mode)) return FALSE;
- return (@mkdir($dir,$mode) && @chmod($dir, $mode));
- }
-
-
-
- /**
- * function fs_delete
- *
- * Deletes a file and recursively deletes dirs, if they're empty
- *
- */
- function fs_delete($path) {
-
- if (file_exists($path)) {
-
- $fsuccess = unlink($path);
- $dsuccess = true;
-
- while ($dsuccess) {
-
- $path = dirname($path);
- $dsuccess = @rmdir($path);
-
- }
-
- // unlink can return both 0 and false -__-'
- return ($fsuccess);
-
- }
-
- // in our particular implementation
- // you can always delete a non existent file;
- // anyway, we'll return a value != false
- // so that we can anyway track it back
-
- return 2;
-
-
- }
-
- /**
- * function fs_recursive_chmod
- *
- * Perform a recursive reset of file permission in the given $path
- * and its subdirectories to 0777
- *
- * @param $fpath dir path
- * @return bool
- *
- */
-
- class fs_chmodder extends fs_filelister {
-
- var $_chmod_dir;
- var $_chmod_file;
-
- function __construct($directory, $ch_file=FILE_PERMISSIONS, $ch_dir=DIR_PERMISSIONS) {
- $this->_directory = $directory;
- $this->_chmod_file = $ch_file;
- $this->_chmod_dir = $ch_dir;
- parent::__construct();
- }
-
- function _checkFile($directory, $file) {
- $retval = 0;
- $path = "$directory/$file";
- if (is_dir($path))
- $retval = 1;
- if ( !@chmod($path, ($retval? $this->_chmod_dir : $this->_chmod_file ) ) )
- array_push($this->_list, $path);
-
- return $retval;
- }
- }
-
- function fs_chmod_recursive($fpath=FP_CONTENT) {
- $obj = new fs_chmodder($fpath);
- return $obj->getList();
- }
-
-
-
- /**
- * recursive deletion
- * deletes all files and directories recursively in the given $path
- * @param $fpath dir path
- * @return bool
- */
-
- /*class fs_deleter extends fs_filelister {
-
- function fs_deleter($directory) {
- $this->_directory = $directory;
- parent::__construct();
- }
-
- function _checkFile($directory, $file) {
-
- $path = "$directory/$file";
-
- /*
- * open dir handle prevents directory deletion of php5 (and probably win)
- * thanks to cimangi for noticing and
- * giving a possible solution:
- *
- * filenames are cached and then deleted
- //
-
- if ( is_dir($path) ) {
- return 1;
- } elseif ( file_exists($path) ) {
- array_push($this->_list, $path);
- return 0;
- } else {
- return 2;
- }
-
- }
-
- }
-
- */
-
- /*
- * open dir handle prevents directory deletion of php5 (and probably win)
- * thanks to cimangi for noticing and
- * giving a possible solution;
- *
- * paths are now cached and then deleted
- */
-
- function fs_delete_recursive($path) {
- if (file_exists($path)) {
-
- $obj = new fs_pathlister($path);
- $list = ($obj->getList());
-
- unset($obj);
-
- $elem = null;
- while($elem = array_pop($list)) {
- $elem;
- fs_delete($elem);
- }
-
-
-
- }
-
-
- return true;
- }
-
-
-
- function fs_copy($source, $dest) {
- if ($contents = io_load_file($source)) {
- return io_write_file($dest, $contents);
- }
- return false;
+ } else
+ return false;
}
+ function getList() {
+ // $this->_listFiles($this->_directory);
+ return $this->_list;
+ }
+ function count() {
+ if (!isset($this->count))
+ $this->count = count($this->_list);
+ return $this->count;
+ }
+
+}
+
+class fs_pathlister extends fs_filelister {
+
+ function _checkFile($directory, $file) {
+ $f = "$directory/$file";
+ if (!is_dir($f))
+ array_push($this->_list, $f);
+ else
+ return 1;
+ }
+
+}
+
+// dir list
+function fs_list_dirs($dir) {
+ $dh = opendir($dir);
+ while (false !== ($filename = readdir($dh))) {
+ if (($filename [0] != '.')) {
+ // $id = lang_id($filename);
+ $files [] = $filename;
+ }
+ }
+ sort($files);
+ return $files;
+}
+
+/**
+ * function fs_mkdir
+ *
+ * Function from : {@link http://www.php.net/function.mkdir.php}
+ *
+ * Recursively creates dirs.
+ * Returns true on success, else false
+ *
+ * @param string $path
+ * Directory or directories to create
+ * @param int $mode
+ * octal mode value; same as UNIX chmod; defaults to 0777 (rwrwrw);
+ * @return bool
+ *
+ * @todo cleanup & check bool return value
+ *
+ */
+function fs_mkdir($dir, $mode = DIR_PERMISSIONS) {
+ if (is_dir($dir) || (@mkdir($dir, $mode))) {
+ @chmod($dir, $mode);
+ return TRUE;
+ }
+ if (!fs_mkdir(dirname($dir), $mode))
+ return FALSE;
+ return (@mkdir($dir, $mode) && @chmod($dir, $mode));
+}
+
+/**
+ * function fs_delete
+ *
+ * Deletes a file and recursively deletes dirs, if they're empty
+ */
+function fs_delete($path) {
+ if (file_exists($path)) {
+
+ $fsuccess = unlink($path);
+ $dsuccess = true;
+
+ while ($dsuccess) {
+
+ $path = dirname($path);
+ $dsuccess = @rmdir($path);
+ }
+
+ // unlink can return both 0 and false -__-'
+ return ($fsuccess);
+ }
+
+ // in our particular implementation
+ // you can always delete a non existent file;
+ // anyway, we'll return a value != false
+ // so that we can anyway track it back
+
+ return 2;
+}
+
+/**
+ * function fs_recursive_chmod
+ *
+ * Perform a recursive reset of file permission in the given $path
+ * and its subdirectories to 0777
+ *
+ * @param $fpath dir
+ * path
+ * @return bool
+ *
+ */
+class fs_chmodder extends fs_filelister {
+
+ var $_chmod_dir;
+
+ var $_chmod_file;
+
+ function __construct($directory, $ch_file = FILE_PERMISSIONS, $ch_dir = DIR_PERMISSIONS) {
+ $this->_directory = $directory;
+ $this->_chmod_file = $ch_file;
+ $this->_chmod_dir = $ch_dir;
+ parent::__construct();
+ }
+
+ function _checkFile($directory, $file) {
+ $retval = 0;
+ $path = "$directory/$file";
+ if (is_dir($path))
+ $retval = 1;
+ if (!@chmod($path, ($retval ? $this->_chmod_dir : $this->_chmod_file)))
+ array_push($this->_list, $path);
+
+ return $retval;
+ }
+
+}
+
+function fs_chmod_recursive($fpath = FP_CONTENT) {
+ $obj = new fs_chmodder($fpath);
+ return $obj->getList();
+}
+
+/**
+ * recursive deletion
+ * deletes all files and directories recursively in the given $path
+ *
+ * @param $fpath dir
+ * path
+ * @return bool
+ */
+
+/*
+ * class fs_deleter extends fs_filelister {
+ *
+ * function fs_deleter($directory) {
+ * $this->_directory = $directory;
+ * parent::__construct();
+ * }
+ *
+ * function _checkFile($directory, $file) {
+ *
+ * $path = "$directory/$file";
+ *
+ * /*
+ * open dir handle prevents directory deletion of php5 (and probably win)
+ * thanks to cimangi for noticing and
+ * giving a possible solution:
+ *
+ * filenames are cached and then deleted
+ * //
+ *
+ * if ( is_dir($path) ) {
+ * return 1;
+ * } elseif ( file_exists($path) ) {
+ * array_push($this->_list, $path);
+ * return 0;
+ * } else {
+ * return 2;
+ * }
+ *
+ * }
+ *
+ * }
+ *
+ */
+
+/*
+ * open dir handle prevents directory deletion of php5 (and probably win)
+ * thanks to cimangi for noticing and
+ * giving a possible solution;
+ *
+ * paths are now cached and then deleted
+ */
+function fs_delete_recursive($path) {
+ if (file_exists($path)) {
+
+ $obj = new fs_pathlister($path);
+ $list = ($obj->getList());
+
+ unset($obj);
+
+ $elem = null;
+ while ($elem = array_pop($list)) {
+ $elem;
+ fs_delete($elem);
+ }
+ }
+
+ return true;
+}
+
+function fs_copy($source, $dest) {
+ if ($contents = io_load_file($source)) {
+ return io_write_file($dest, $contents);
+ }
+ return false;
+}
+
+/**
+ * Checks if the file with the given name is a directory component ('.' or '..').
+ *
+ * @param string $filename
+ * the file name
+ * @return boolean true
if the file is a directory component; otherwise false
+ */
+function fs_is_directorycomponent($filename) {
+ return $filename === '.' || $filename === '..';
+}
+
+/**
+ * Checks if the file with the given name is a hidden file (i.e., starts with a '.').
+ *
+ * @param string $filename
+ * the file name
+ * @return boolean true
if the file is a hidden file; otherwise false
+ */
+function fs_is_hidden_file($filename) {
+ return strlen($filename) > 0 && substr($filename, 0, 1) === '.';
+}
\ No newline at end of file
diff --git a/fp-includes/core/core.gallery.php b/fp-includes/core/core.gallery.php
new file mode 100644
index 0000000..b7dc21d
--- /dev/null
+++ b/fp-includes/core/core.gallery.php
@@ -0,0 +1,136 @@
+getlist();
+ foreach ($l as $i => $f) {
+ // remove caption files
+ if ($f === GALLERY_CAPTIONS_FILENAME || $f === GALLERY_CAPTIONS_LEGACYFILENAME) {
+ array_splice($l, $i, 1);
+ }
+ }
+ sort($l);
+ return $l;
+}
+
+/**
+ * Reads the captions from the given gallery directory.
+ *
+ * @param string $galleryDir
+ * the gallery dir, e.g. 'images/NameOfTheGallery'
+ * @return array the gallery captions as associative array { filename => caption }
+ */
+function gallery_read_captions($galleryDir) {
+ $captions = array();
+
+ $captionsFileContent = null;
+ $galleryDirPathAbs = ABS_PATH . FP_CONTENT . $galleryDir . '/';
+ // read captions.conf from gallery dir
+ if (file_exists($galleryDirPathAbs . GALLERY_CAPTIONS_FILENAME)) {
+ $captionsFileContent = file($galleryDirPathAbs . GALLERY_CAPTIONS_FILENAME);
+ } //
+ // legacy mode: if captions.conf is not available, check for texte.conf
+ elseif (file_exists($galleryDirPathAbs . GALLERY_CAPTIONS_LEGACYFILENAME)) {
+ $captionsFileContent = file($galleryDirPathAbs . GALLERY_CAPTIONS_LEGACYFILENAME);
+ } //
+ // no caption file available
+ else {
+ return array();
+ }
+
+ // read captions file line by line
+ foreach ($captionsFileContent as $currentline) {
+ // image file name is before of the '=' character, ...
+ $image = trim(substr($currentline, 0, strpos($currentline, '=')));
+ // ... the caption after.
+ $caption = trim(substr($currentline, (strpos($currentline, '=') + 1)));
+ // $captions [$image] = htmlentities($descript);
+ $captions [$image] = $caption;
+ }
+ return $captions;
+}
+
+/**
+ * Stores the given captions for the given gallery
+ *
+ * @param string $galleryName
+ * the gallery dir, e.g. 'NameOfTheGallery'
+ * @param array $captions
+ * the gallery captions as associative array { filename => caption }
+ * @return boolean true
if captions were written successfully; false
otherwise
+ */
+function gallery_write_captions($galleryName, $captions) {
+ $gallerydirPath = IMAGES_DIR . $galleryName;
+ if (!file_exists($gallerydirPath)) {
+ return false;
+ }
+ $captionfilePath = IMAGES_DIR . $galleryName . DIRECTORY_SEPARATOR . GALLERY_CAPTIONS_FILENAME;
+ $captionfileHandle = fopen($captionfilePath, 'w');
+
+ $filecontent = '';
+ foreach ($captions as $filename => $caption) {
+ $filecontent .= $filename . ' = ' . $caption . PHP_EOL;
+ }
+
+ fwrite($captionfileHandle, $filecontent);
+ fclose($captionfileHandle);
+
+ // Updating from legacy versions: If legacy captions fill still exists, delete if
+ $legacyCaptionfilePath = IMAGES_DIR . $galleryName . DIRECTORY_SEPARATOR . GALLERY_CAPTIONS_LEGACYFILENAME;
+ if (file_exists($legacyCaptionfilePath)) {
+ unlink($legacyCaptionfilePath);
+ }
+ return true;
+}
\ No newline at end of file
diff --git a/fp-includes/core/core.theme.php b/fp-includes/core/core.theme.php
index a835e27..2c64c17 100644
--- a/fp-includes/core/core.theme.php
+++ b/fp-includes/core/core.theme.php
@@ -120,7 +120,7 @@ function theme_list() {
$dh = opendir($dir);
$i = 0;
while (false !== ($filename = readdir($dh))) {
- if (($filename != '.') && ($filename != '..')) {
+ if (!fs_is_directorycomponent($filename)) {
$files [$i++] = $filename;
}
}
diff --git a/fp-includes/core/core.wp-pluggable-funcs.php b/fp-includes/core/core.wp-pluggable-funcs.php
index 1e1957e..815e020 100755
--- a/fp-includes/core/core.wp-pluggable-funcs.php
+++ b/fp-includes/core/core.wp-pluggable-funcs.php
@@ -46,7 +46,8 @@ if (!function_exists('get_nextpage_link')) :
$a = _get_nextprev_link('NextPage');
- if ($q->single) {
+ // show next entry link only if there actually is a next entry - and only if one single entry is displayed
+ if (isset($a) && $q->single) {
$a [0] .= ' » ';
}
@@ -62,7 +63,8 @@ if (!function_exists('get_prevpage_link')) :
$a = _get_nextprev_link('PrevPage');
- if ($q->single) {
+ // show previous entry link only if there actually is a previous entry - and only if one single entry is displayed
+ if (isset($a) && $q->single) {
$a [0] = ' « ' . $a [0];
}
diff --git a/fp-includes/core/includes.php b/fp-includes/core/includes.php
index 37cb377..58cd496 100755
--- a/fp-includes/core/includes.php
+++ b/fp-includes/core/includes.php
@@ -1,48 +1,45 @@
diff --git a/fp-includes/smarty/internals/core.rm_auto.php b/fp-includes/smarty/internals/core.rm_auto.php
index b251f64..aca23a1 100644
--- a/fp-includes/smarty/internals/core.rm_auto.php
+++ b/fp-includes/smarty/internals/core.rm_auto.php
@@ -1,6 +1,8 @@
$params ['auto_base'],
+ 'level' => 0,
+ 'exp_time' => $params ['exp_time']
+ );
+ require_once (SMARTY_CORE_DIR . 'core.rmdir.php');
+ $_res = smarty_core_rmdir($_params, $smarty);
+ } else {
+ $_tname = $smarty->_get_auto_filename($params ['auto_base'], $params ['auto_source'], $params ['auto_id']);
- if(!isset($params['auto_id']) && !isset($params['auto_source'])) {
- $_params = array(
- 'dirname' => $params['auto_base'],
- 'level' => 0,
- 'exp_time' => $params['exp_time']
- );
- require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
- $_res = smarty_core_rmdir($_params, $smarty);
- } else {
- $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']);
+ if (isset($params ['auto_source'])) {
+ if (isset($params ['extensions'])) {
+ $_res = false;
+ foreach ((array) $params ['extensions'] as $_extension)
+ $_res |= $smarty->_unlink($_tname . $_extension, $params ['exp_time']);
+ } else {
+ $_res = $smarty->_unlink($_tname, $params ['exp_time']);
+ }
+ } elseif ($smarty->use_sub_dirs) {
+ $_params = array(
+ 'dirname' => $_tname,
+ 'level' => 1,
+ 'exp_time' => $params ['exp_time']
+ );
+ require_once (SMARTY_CORE_DIR . 'core.rmdir.php');
+ $_res = smarty_core_rmdir($_params, $smarty);
+ } else {
+ // remove matching file names
+ $_handle = opendir($params ['auto_base']);
+ $_res = true;
+ while (false !== ($_filename = readdir($_handle))) {
+ if (fs_is_directorycomponent($_filename)) {
+ continue;
+ } elseif (substr($params ['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
+ $_res &= (bool) $smarty->_unlink($params ['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params ['exp_time']);
+ }
+ }
+ }
+ }
- if(isset($params['auto_source'])) {
- if (isset($params['extensions'])) {
- $_res = false;
- foreach ((array)$params['extensions'] as $_extension)
- $_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']);
- } else {
- $_res = $smarty->_unlink($_tname, $params['exp_time']);
- }
- } elseif ($smarty->use_sub_dirs) {
- $_params = array(
- 'dirname' => $_tname,
- 'level' => 1,
- 'exp_time' => $params['exp_time']
- );
- require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
- $_res = smarty_core_rmdir($_params, $smarty);
- } else {
- // remove matching file names
- $_handle = opendir($params['auto_base']);
- $_res = true;
- while (false !== ($_filename = readdir($_handle))) {
- if($_filename == '.' || $_filename == '..') {
- continue;
- } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
- $_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']);
- }
- }
- }
- }
-
- return $_res;
+ return $_res;
}
/* vim: set expandtab: */
diff --git a/fp-includes/smarty/internals/core.rmdir.php b/fp-includes/smarty/internals/core.rmdir.php
index 2166c44..7408317 100644
--- a/fp-includes/smarty/internals/core.rmdir.php
+++ b/fp-includes/smarty/internals/core.rmdir.php
@@ -1,6 +1,8 @@
$params['dirname'] . DIRECTORY_SEPARATOR . $_entry,
- 'level' => $params['level'] + 1,
- 'exp_time' => $params['exp_time']
- );
- smarty_core_rmdir($_params, $smarty);
- }
- else {
- $smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']);
- }
- }
- }
- closedir($_handle);
- }
-
- if ($params['level']) {
- return @rmdir($params['dirname']);
- }
- return (bool)$_handle;
+ while (false !== ($_entry = readdir($_handle))) {
+ if (!fs_is_directorycomponent($_entry)) {
+ if (@is_dir($params ['dirname'] . DIRECTORY_SEPARATOR . $_entry)) {
+ $_params = array(
+ 'dirname' => $params ['dirname'] . DIRECTORY_SEPARATOR . $_entry,
+ 'level' => $params ['level'] + 1,
+ 'exp_time' => $params ['exp_time']
+ );
+ smarty_core_rmdir($_params, $smarty);
+ } else {
+ $smarty->_unlink($params ['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params ['exp_time']);
+ }
+ }
+ }
+ closedir($_handle);
+ }
+ if ($params ['level']) {
+ return @rmdir($params ['dirname']);
+ }
+ return (bool) $_handle;
}
/* vim: set expandtab: */
diff --git a/fp-interface/lang/pt-br/lang.conf.php b/fp-interface/lang/pt-br/lang.conf.php
index 866e3e6..ae0e64d 100644
--- a/fp-interface/lang/pt-br/lang.conf.php
+++ b/fp-interface/lang/pt-br/lang.conf.php
@@ -1,10 +1,9 @@
diff --git a/fp-interface/sharedtpls/contact.tpl b/fp-interface/sharedtpls/contact.tpl
index c894976..8717b63 100755
--- a/fp-interface/sharedtpls/contact.tpl
+++ b/fp-interface/sharedtpls/contact.tpl
@@ -1,10 +1,5 @@
{$lang.contact.descr}
-{validate id="name" message=$lang.contact.error.name append="error"}
-{validate id="email" message=$lang.contact.error.email append="error"}
-{validate id="www" message=$lang.contact.error.www append="error"}
-{validate id="content" message=$lang.contact.error.content append="error"}
-