+++ /dev/null
-<?php\r
-\r
-/* ==========================================================================================\r
- * Nucleus SkinFiles Plugin\r
- *\r
- * Copyright 2005-2007 by Jeff MacMichael and Niels Leenheer\r
- *\r
- * @version $Id$\r
- * @version $NucleusJP: index.php,v 1.6 2007/03/20 19:32:47 kmorimatsu Exp $\r
- *\r
- * ==========================================================================================\r
- * This program is free software and open source software; you can redistribute\r
- * it and/or modify it under the terms of the GNU General Public License as\r
- * published by the Free Software Foundation; either version 2 of the License,\r
- * or (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful, but WITHOUT\r
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
- * more details.\r
- *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit\r
- * http://www.gnu.org/licenses/gpl.html\r
- * ==========================================================================================\r
- */\r
- $DIR_LIBS = '';\r
- $strRel = '../../../'; \r
- require($strRel . 'config.php');\r
- include_libs('PLUGINADMIN.php');\r
-\r
- $language = preg_replace( '#\\\\|/#', '', getLanguageName());\r
- $langfile = $language.'.php';\r
- if (file_exists($langfile))\r
- include_once($langfile);\r
- else\r
- include_once('english.php');\r
-\r
- /**\r
- * Create admin area\r
- */\r
-\r
- $oPluginAdmin = new PluginAdmin('SkinFiles');\r
-\r
- if (!($member->isLoggedIn() && $member->isAdmin()))\r
- {\r
- /* begin modification by yama.kyms */\r
- $oPluginAdmin->start();\r
- /* end modification */\r
- echo '<p>' . _ERROR_DISALLOWED . '</p>';\r
- $oPluginAdmin->end();\r
- exit;\r
- }\r
-\r
-\r
- \r
- /**\r
- * Setup main variables\r
- */\r
-\r
- $rootDirectory = sfRealPath($DIR_SKINS); \r
- $rootUrl = $CONF['SkinsURL'];\r
- $pluginUrl = $oPluginAdmin->plugin->getAdminURL();\r
-\r
- $filetypes = array (\r
- 'text' => array ('inc', 'txt', 'css', 'js', 'php'),\r
- 'html' => array ('htm', 'html'),\r
- 'img' => array ('png', 'gif', 'jpg', 'jpeg', 'bmp', 'ico', 'swf'),\r
- );\r
- \r
- \r
- /**\r
- * Bypass admin area for downloads\r
- */\r
- \r
- $action = requestVar('action');\r
-\r
- if ($action == 'download') { \r
- _skinfiles_download();\r
- exit;\r
- }\r
-\r
-\r
- /**\r
- * Build admin area\r
- */\r
-\r
- $oPluginAdmin->start();\r
- \r
- echo "<h2>" . _SKINFILES_MANAGEMENT . "</h2>";\r
- \r
- $actions = array (\r
- 'renfile', 'renfile_process', 'delfile', 'delfile_process', \r
- 'editfile', 'editfile_process', 'uploadfile', 'createfile', 'viewfile',\r
- 'rendir', 'rendir_process', 'deldir', 'deldir_process',\r
- 'emptydir', 'emptydir_process', 'createdir'\r
- );\r
- \r
- if (in_array($action, $actions)) \r
- { \r
- if (!$manager->checkTicket())\r
- {\r
- echo '<p class="error">' . _ERROR . ': ' . _ERROR_BADTICKET . '</p>';\r
- sfShowDirectory();\r
- \r
- } \r
- else \r
- {\r
- call_user_func('_skinfiles_' . $action);\r
- }\r
- } \r
- else \r
- {\r
- sfShowDirectory();\r
- }\r
-\r
- $oPluginAdmin->end();\r
- exit;\r
- \r
- \r
-\r
-\r
-\r
-\r
-\r
- /* Helper functions **************************************************************************************************************/\r
-\r
- function sfExpandDirectory ($path) {\r
- /* IN: relative directory\r
- * OUT: full path to directory\r
- */\r
-\r
- global $rootDirectory;\r
- return sfRealPath($rootDirectory . $path);\r
- }\r
- \r
- function sfRealPath ($path) {\r
- /* IN: full path \r
- * OUT: canonicalized absolute pathname\r
- */\r
-\r
- $path = realpath($path);\r
- $path = str_replace('\\', '/', $path); \r
- $path = substr($path, strlen($path) - 1) != '/' ? $path . '/' : $path;\r
- return $path;\r
- }\r
-\r
- function sfFullUrl ($path) {\r
- /* IN: full path including filename\r
- * OUT: url including filename\r
- */\r
-\r
- global $rootDirectory, $rootUrl;\r
- \r
- $path = str_replace($rootDirectory, '', $path);\r
- $path = rawurlencode($path);\r
- $path = str_replace('%2F', '/', $path);\r
- return $rootUrl . $path;\r
- }\r
-\r
- function sfValidPath ($path) {\r
- /* IN: full path excluding or including filename\r
- * OUT: boolean, true if full path is or is within rootDirectory\r
- */\r
-\r
- global $rootDirectory;\r
- return substr($path, 0, strlen($rootDirectory)) == $rootDirectory;\r
- }\r
- \r
- function sfRelativePath ($path) {\r
- /* IN: full path including or excluding filename\r
- * OUT: relative path from rootDirectory\r
- */\r
-\r
- global $rootDirectory;\r
- return str_replace($rootDirectory, '', $path);\r
- }\r
- \r
- function sfIsFileType ($type, $file) {\r
-\r
- global $filetypes;\r
- return isset($filetypes[$type]) && in_array(strtolower(substr(strrchr($file, "."), 1)), $filetypes[$type]);\r
- }\r
-\r
- function sfAllowEditing ($file) {\r
- return sfIsFileType('html', $file) || sfIsFileType('text', $file);\r
- }\r
- \r
- function sfAllowViewing ($file) {\r
- return sfIsFileType('html', $file) || sfIsFileType('text', $file) || sfIsFileType('img', $file);\r
- }\r
-\r
-\r
- function sfDisplayPath ($relative) {\r
- \r
- global $pluginUrl;\r
- \r
- $result = '<a href="' . htmlspecialchars($pluginUrl) . '" title="Go back to «skins»">';\r
- $result .= '<img src="' . htmlspecialchars($pluginUrl . 'home.gif') . '" alt="" /> skins</a> / ';\r
-\r
- $parts = explode('/', $relative);\r
- $part = '';\r
- \r
- while (list(,$v) = each ($parts)) {\r
- if ($v != '') {\r
- $part .= $v . '/';\r
- \r
- $result .= '<a href="' . htmlspecialchars($pluginUrl . '?dir=' . rawurlencode($part)) . '" ';\r
- $result .= 'title="Go back to «' . htmlspecialchars($v) . '»">';\r
- $result .= '<img src="' . htmlspecialchars($pluginUrl . 'dir.gif') . '" alt="" /> ';\r
- $result .= htmlspecialchars($v) . '</a> / ';\r
- }\r
- }\r
- \r
- return $result;\r
- }\r
-\r
- function sfIcon ($file) {\r
- \r
- global $pluginUrl;\r
- \r
- $ext = strtolower(substr(strrchr($file, "."), 1));\r
- \r
- switch ($ext) {\r
- case 'htm':\r
- case 'html':\r
- return $pluginUrl . 'html.gif';\r
- break;\r
-\r
- case 'txt':\r
- case 'js':\r
- case 'css':\r
- case 'inc':\r
- return $pluginUrl . 'text.gif';\r
- break;\r
-\r
- case 'gif':\r
- case 'png':\r
- case 'jpg':\r
- case 'jpeg':\r
- case 'bmp':\r
- case 'xbmp':\r
- case 'ico':\r
- return $pluginUrl . 'image.gif';\r
- break;\r
-\r
- case 'php':\r
- case 'php3':\r
- case 'php4':\r
- return $pluginUrl . 'php.gif';\r
- break;\r
- \r
- default:\r
- return $pluginUrl . 'generic.gif';\r
- break;\r
- }\r
- }\r
-\r
- function sfIllegalFilename($name) {\r
- return preg_match('#[\n\r\\\/\:\*\?\"\<\>\|]#', $name);\r
- }\r
-\r
- function sfDirectoryIsEmpty($dir) {\r
- \r
- $count = 0;\r
- \r
- if ($dh = opendir($dir)) \r
- {\r
- while (($file = readdir($dh)) !== false) \r
- $count++;\r
- \r
- closedir($dh);\r
- }\r
- \r
- // $count must be smaller or equal than 2, because '.' \r
- // and '..' are always returned by readdir().\r
- return $count <= 2;\r
- }\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
- /* Show directory ****************************************************************************************************************/\r
-\r
- function sfShowDirectory($default = '') {\r
-\r
- global $pluginUrl, $rootDirectory, $CONF, $manager;\r
- \r
- $directory = $default != '' ? \r
- $default : \r
- sfExpandDirectory(trim(requestVar('dir')));\r
- \r
- if (!sfValidPath($directory) || !is_dir($directory)) {\r
- $directory = $rootDirectory;\r
- }\r
-\r
- $relative = sfRelativePath ($directory);\r
- \r
- echo '<p class="location">' . _SKINFILES_CURRENT_LOCATION . sfDisplayPath($relative) . '</p>'; \r
-\r
- \r
- $dirs = array();\r
- $files = array();\r
-\r
- if ($dh = @opendir($directory)) { \r
- while (($file = readdir($dh)) !== false) { \r
- if (!preg_match("/^\.{1,2}$/", $file)) {\r
- $fstat = @stat($directory . $file);\r
- \r
- if ($fstat['mode'] & 040000)\r
- $dirs[$file] = $fstat;\r
- else\r
- $files[$file] = $fstat;\r
- }\r
- }\r
- closedir($dh); \r
- } \r
- \r
- ksort($dirs);\r
- ksort($files);\r
- \r
- echo '<table><thead><tr>';\r
- echo '<th>' . _SKINFILES_NAME . '</th><th>' . _SKINFILES_SIZE . '</th><th>' . _SKINFILES_LAST_MODIFIED . '</th><th colspan="4">' . _SKINFILES_ACTIONS . '</th>';\r
- echo '</tr></thead>';\r
-\r
- while (list($name, $stat) = each($dirs)) {\r
- \r
- $dir = sfRelativePath($directory . $name . '/');\r
- \r
- echo '<tr onmouseover="focusRow(this);" onmouseout="blurRow(this);"><td>';\r
- \r
- if (is_readable ($directory . $name)) \r
- {\r
- echo '<a href="' . htmlspecialchars($pluginUrl . '?dir=' . rawurlencode($dir)) . '">';\r
- echo '<img src="' . htmlspecialchars($pluginUrl . 'dir.gif') . '" alt="folder" /> ';\r
- echo htmlspecialchars($name).'</a>'; \r
- }\r
- else\r
- {\r
- echo '<img src="' . htmlspecialchars($pluginUrl . 'dir.gif') . '" alt="folder" /> ';\r
- echo htmlspecialchars($name); \r
- }\r
- \r
- echo '</td>';\r
- \r
- $renUrl = $manager->addTicketToUrl($pluginUrl . '?action=rendir&dir=' . rawurlencode($dir));\r
- $delUrl = $manager->addTicketToUrl($pluginUrl . '?action=deldir&dir=' . rawurlencode($dir));\r
- \r
- echo '<td>–</td>';\r
- echo '<td>' . date(_SKINFILES_DATE_FORMAT, $stat['mtime']);\r
- \r
- \r
- if (is_writable($directory . $name)) {\r
- echo '<td><a href="' . htmlspecialchars($renUrl) . '" title="' . _SKINFILES_RENAME . ' «' . htmlspecialchars($name) . '»">' . _SKINFILES_RENAME . '</a></td>';\r
- } else {\r
- echo '<td> </td>';\r
- }\r
- \r
- if (is_writable($directory . $name) && sfDirectoryIsEmpty($directory . $name)) {\r
- echo '<td><a href="' . htmlspecialchars($delUrl) . '" title="' . _SKINFILES_DELETE . ' «' . htmlspecialchars($name) . '»">' . _SKINFILES_DELETE . '</a></td>';\r
- } else {\r
- echo '<td> </td>';\r
- }\r
- \r
- echo '<td> </td><td> </td>';\r
- echo '</tr>';\r
- }\r
-\r
-\r
- while (list($name, $stat) = each($files)) {\r
-\r
- $file = sfRelativePath($directory . $name);\r
-\r
- $renUrl = $manager->addTicketToUrl($pluginUrl . '?action=renfile&file=' . rawurlencode($file));\r
- $delUrl = $manager->addTicketToUrl($pluginUrl . '?action=delfile&file=' . rawurlencode($file));\r
- $editUrl = $manager->addTicketToUrl($pluginUrl . '?action=editfile&file=' . rawurlencode($file));\r
- $viewUrl = $manager->addTicketToUrl($pluginUrl . '?action=viewfile&file=' . rawurlencode($file));\r
- $dlUrl = $manager->addTicketToUrl($pluginUrl . '?action=download&file=' . rawurlencode($file));\r
-\r
- echo '<tr onmouseover="focusRow(this);" onmouseout="blurRow(this);"><td>';\r
- \r
- if (is_readable ($directory . $name) && sfAllowViewing($name)) \r
- {\r
- echo '<a href="' . htmlspecialchars($viewUrl) . '">';\r
- echo '<img src="' . htmlspecialchars(sfIcon($name)) . '" alt="" /> ';\r
- echo htmlspecialchars($name).'</a>';\r
- }\r
- else\r
- {\r
- echo '<img src="' . htmlspecialchars(sfIcon($name)) . '" alt="" /> ';\r
- echo htmlspecialchars($name);\r
- }\r
-\r
- echo '</td><td>';\r
- echo ceil($stat['size'] / 1024) . ' kB';\r
- echo '</td><td>';\r
- echo date(_SKINFILES_DATE_FORMAT, $stat['mtime']);\r
- echo '</td><td>';\r
- \r
- if (is_writable($directory . $name)) {\r
- echo '<a href="' . htmlspecialchars($renUrl) . '" title="' . _SKINFILES_RENAME . ' «' . htmlspecialchars($name) . '»">' . _SKINFILES_RENAME . '</a>';\r
- } else {\r
- echo ' ';\r
- }\r
- \r
- echo '</td><td>';\r
-\r
- if (is_writable($directory . $name)) {\r
- echo '<a href="' . htmlspecialchars($delUrl) . '" title="' . _SKINFILES_DELETE . ' «' . htmlspecialchars($name) . '»">' . _SKINFILES_DELETE . '</a>';\r
- } else {\r
- echo ' ';\r
- }\r
- \r
- echo '</td><td>';\r
- \r
- if (is_writable($directory . $name) && sfAllowEditing($name))\r
- echo '<a href="'. htmlspecialchars($editUrl) . '" title="' . _SKINFILES_EDIT . ' «' . htmlspecialchars($name) . '»">' . _SKINFILES_EDIT . '</a>';\r
- else\r
- echo ' ';\r
-\r
- echo '</td><td>';\r
- \r
- if (is_readable ($directory . $name))\r
- echo '<a href="' . htmlspecialchars($dlUrl) . '" title="' . _SKINFILES_DOWNLOAD . ' «' . htmlspecialchars($name) . '»">' . _SKINFILES_DOWNLOAD . '</a>';\r
- else\r
- echo ' ';\r
- \r
- echo '</td></tr>';\r
- }\r
-\r
- if (!count($dirs) && !count($files)) {\r
- echo '<tr><td colspan="7">' . _SKINFILES_ERR_DIR_DOES_NOT_CONTAIN . '</td></tr>';\r
- }\r
-\r
- echo '</table>';\r
-\r
- if ($relative != '') {\r
- \r
- if (is_writable($directory)) {\r
- echo '<div class="dialogbox">';\r
- echo '<h4 class="light">' . _SKINFILES_CREATE_NEW_FILE . '</h4><div>';\r
- echo '<form method="post" action="' . htmlspecialchars($pluginUrl) . '">';\r
- $manager->addTicketHidden();\r
- echo '<input type="hidden" name="action" value="createfile" />';\r
- echo '<input type="hidden" name="dir" value="' . htmlspecialchars($relative) . '" />';\r
- echo '<input type="text" name="name" size="40" value="untitled.txt" />';\r
- echo '<p class="buttons"><input type="submit" value="' . _SKINFILES_CREATE_FILE . '" /></p></form>';\r
- echo '</div></div>';\r
- \r
- echo '<div class="dialogbox">';\r
- echo '<h4 class="light">' . _SKINFILES_UPLOAD_NEW_FILE . '</h4><div>';\r
- echo '<form method="post" enctype="multipart/form-data" action="' . htmlspecialchars($pluginUrl) . '">';\r
- $manager->addTicketHidden();\r
- echo '<input type="hidden" name="action" value="uploadfile" />';\r
- echo '<input type="hidden" name="dir" value="' . htmlspecialchars($relative) . '" />';\r
- echo '<input type="hidden" name="MAX_FILE_SIZE" value="' . $CONF['MaxUploadSize'] . '" />';\r
- echo '<input type="file" name="name" size="40" />';\r
- echo '<p class="buttons"><input type="submit" value="' . _SKINFILES_UPLOAD . '" /></p></form>';\r
- echo '</div></div>';\r
- }\r
- \r
- if (count($files)) {\r
- echo '<div class="dialogbox">';\r
- echo '<h4 class="light">' . _SKINFILES_DEL_ALL_FILES . '</h4><div>';\r
- echo '<form method="post" action="' . htmlspecialchars($pluginUrl) . '">';\r
- $manager->addTicketHidden();\r
- echo '<input type="hidden" name="action" value="emptydir" />';\r
- echo '<input type="hidden" name="dir" value="' . htmlspecialchars($relative) . '" />';\r
- echo _SKINFILES_DEL_ALL_FILES_MSG;\r
- echo '<p class="buttons"><input type="submit" value="' . _SKINFILES_DELETE_ALL . '" tabindex="140" onclick="return checkSubmit();" /></p>';\r
- echo '</form>';\r
- echo '</div></div>';\r
- }\r
- }\r
- \r
- if (is_writable($directory)) {\r
- echo '<div class="dialogbox">';\r
- echo '<h4 class="light">' . _SKINFILES_CREATE_NEW_DIR . '</h4><div>';\r
- echo '<form method="post" action="' . htmlspecialchars($pluginUrl) . '">';\r
- $manager->addTicketHidden();\r
- echo '<input type="hidden" name="action" value="createdir" />';\r
- echo '<input type="hidden" name="dir" value="' . htmlspecialchars($relative) . '" />';\r
- echo '<input type="text" name="name" value="untitled" tabindex="90" size="40" />';\r
- echo '<p class="buttons"><input type="submit" value="' . _SKINFILES_CREATE . '" tabindex="140" onclick="return checkSubmit();" /></p>';\r
- echo '</form>';\r
- echo '</div></div>';\r
- }\r
- }\r
- \r
- \r
- \r
-\r
- /* Rename directory **************************************************************************************************************/\r
-\r
- function _skinfiles_rendir($preset = '') {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = trim(_skinfiles_basename(requestVar('dir')));\r
- $directory = trim(dirname(requestVar('dir')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (sfValidPath($directory . $file) && file_exists($directory . $file) && \r
- is_dir($directory . $file) && is_writable($directory . $file)) \r
- {\r
- $relative = sfRelativePath ($directory);\r
- $editUrl = $manager->addTicketToUrl($pluginUrl . '?action=rendir&dir=' . rawurlencode($relative . $file));\r
-\r
- echo '<p class="location">' . _SKINFILES_CURRENT_LOCATION . sfDisplayPath($relative);\r
- echo '<a href="' . htmlspecialchars($editUrl) . '" title="' . _SKINFILES_RENAME . ' «' . $file . '»">';\r
- echo '<img src="' . $pluginUrl . 'dir.gif' . '" alt="" /> ' . $file . '</a></p>';\r
-\r
- echo '<div class="dialogbox">';\r
- echo '<form method="post" action="' . htmlspecialchars($pluginUrl) . '">';\r
- $manager->addTicketHidden();\r
- echo '<input type="hidden" name="action" value="rendir_process" />';\r
- echo '<input type="hidden" name="dir" value="' . htmlspecialchars($relative . $file) . '" />';\r
-\r
- echo '<h4>' . _SKINFILES_RENAME_DIR_MSG . ' «' . htmlspecialchars($file) . '» ' . _SKINFILES_RENAME_DIR_MSG2 . '</h4><div>';\r
- echo '<p><input type="text" name="name" size="40" value="' . htmlspecialchars($preset != '' ? $preset : $file) . '" /></p>';\r
- echo '<p class="buttons">';\r
- echo '<input type="hidden" name="sure" value="yes" />';\r
- echo '<input type="submit" value="' . _SKINFILES_RENAME . '" />';\r
- echo '<input type="button" name="sure" value="' . _SKINFILES_CANCEL . '" onclick="history.back();" />';\r
- echo '</p>';\r
- echo '</div></form></div>';\r
- }\r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_DIR_DOES_NOT_EXIST1 . " «" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_DIR_DOES_NOT_EXIST2;\r
- echo _SKINFILES_ERR_DIR_DOES_NOT_EXIST3 . "</p>";\r
- }\r
- }\r
- \r
- function _skinfiles_rendir_process() {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = trim(_skinfiles_basename(requestVar('dir')));\r
- $directory = trim(dirname(requestVar('dir')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (requestVar('sure') == 'yes')\r
- {\r
- if (sfValidPath($directory . $file) && file_exists($directory . $file) && \r
- is_dir($directory . $file) && is_writable($directory . $file)) \r
- {\r
- $name = requestVar('name');\r
- \r
- if ($name == '') {\r
- echo "<p class='error'>" . _SKINFILES_ERR_COULD_NOT_RENAME_DIR1 . "«" . htmlspecialchars($file) . "» ";\r
- echo _SKINFILES_ERR_COULD_NOT_RENAME_DIR2 . "</p>";\r
- _skinfiles_rendir($name);\r
- return;\r
- }\r
- \r
- if (sfIllegalFilename($name)) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_COULD_NOT_RENAME_DIR3 . "«" . htmlspecialchars($file) . "» ";\r
- echo _SKINFILES_ERR_COULD_NOT_RENAME_DIR4 . "</p>";\r
- _skinfiles_rendir($name);\r
- return;\r
- } \r
- \r
- if ($name == $file) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_COULD_NOT_RENAME_DIR5 . "«" . htmlspecialchars($file) . "» ";\r
- echo _SKINFILES_ERR_COULD_NOT_RENAME_DIR6 . _SKINFILES_ERR_COULD_NOT_RENAME_DIR7 . "</p>";\r
- _skinfiles_rendir($name);\r
- return;\r
- }\r
- \r
- if (file_exists($directory . $name)) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_COULD_NOT_RENAME_DIR8 . "«" . htmlspecialchars($file) . "» ";\r
- echo _SKINFILES_ERR_COULD_NOT_RENAME_DIR9 . _SKINFILES_ERR_COULD_NOT_RENAME_DIR10 . "</p>";\r
- _skinfiles_rendir($name);\r
- return;\r
- }\r
- \r
- if (!@rename($directory . $file, $directory . $name)) \r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_COULD_NOT_RENAME_DIR11 . "«" . htmlspecialchars($file) . "»</p>";\r
- _skinfiles_rendir($name);\r
- return;\r
- }\r
- \r
- echo "<p class='message'>" . _SKINFILES_RENAMED_DIR1 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_RENAMED_DIR2;\r
- echo _SKINFILES_RENAMED_DIR3 . "«" . htmlspecialchars($name) . "»" . _SKINFILES_RENAMED_DIR4 . "</p>";\r
- sfShowDirectory($directory);\r
- } \r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_DIR_DOES_NOT_EXIST1 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_DIR_DOES_NOT_EXIST2;\r
- echo _SKINFILES_ERR_DIR_DOES_NOT_EXIST3 . "</p>";\r
- }\r
- }\r
- else\r
- {\r
- // User cancelled\r
- sfShowDirectory($directory);\r
- }\r
- }\r
-\r
-\r
-\r
-\r
- /* Create directory **************************************************************************************************************/\r
-\r
- function _skinfiles_createdir() {\r
- \r
- $directory = trim(requestVar('dir'));\r
- $directory = sfExpandDirectory($directory);\r
-\r
- if (sfValidPath($directory) && is_dir($directory) && is_writable($directory)) \r
- {\r
- $name = requestVar('name');\r
- \r
- if ($name == '') {\r
- echo "<p class='error'>" . _SKINFILES_ERR_COULD_NOT_CREATE_DIR1 . "</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- }\r
- \r
- if (sfIllegalFilename($name)) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_COULD_NOT_CREATE_DIR2 . "«" . htmlspecialchars($name) . "» ";\r
- echo _SKINFILES_ERR_COULD_NOT_CREATE_DIR3 . "</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- } \r
- \r
- if (file_exists($directory . $name)) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_COULD_NOT_CREATE_DIR4 . "«" . htmlspecialchars($name) . "» ";\r
- echo _SKINFILES_ERR_COULD_NOT_CREATE_DIR5 . _SKINFILES_ERR_COULD_NOT_CREATE_DIR6 . "</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- }\r
- \r
- $mask = @umask(0000);\r
-\r
- if (!@mkdir($directory . $name, 0755)) \r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_COULD_NOT_CREATE_DIR2 . "«" . htmlspecialchars($name) . "»</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- }\r
-\r
- @umask($mask);\r
- \r
- echo "<p class='message'>" . _SKINFILES_ERR_COULD_NOT_CREATE_DIR7 . "«" . htmlspecialchars($name) . "» " . _SKINFILES_ERR_COULD_NOT_CREATE_DIR8 . "</p>";\r
- sfShowDirectory($directory);\r
- } \r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_COULD_NOT_CREATE_DIR9 . "«" . htmlspecialchars(_skinfiles_basename($directory)) . "» " . _SKINFILES_ERR_COULD_NOT_CREATE_DIR10;\r
- echo _SKINFILES_ERR_COULD_NOT_CREATE_DIR11 . "</p>";\r
- }\r
- }\r
- \r
- \r
- \r
-\r
- /* Delete directory **************************************************************************************************************/\r
-\r
- function _skinfiles_deldir() {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = trim(_skinfiles_basename(requestVar('dir')));\r
- $directory = trim(dirname(requestVar('dir')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (sfValidPath($directory . $file) && file_exists($directory . $file) && \r
- is_dir($directory . $file) && is_writable($directory . $file) &&\r
- sfDirectoryIsEmpty($directory . $file)) \r
- {\r
- $relative = sfRelativePath ($directory);\r
- $delUrl = $manager->addTicketToUrl($pluginUrl . '?action=deldir&dir=' . rawurlencode($relative . $file));\r
-\r
- echo '<p class="location">' . _SKINFILES_CURRENT_LOCATION . sfDisplayPath($relative);\r
- echo '<a href="' . htmlspecialchars($delUrl) . '" title="' . _SKINFILES_DELETE . ' «' . $file . '»">';\r
- echo '<img src="' . $pluginUrl . 'dir.gif' . '" alt="" /> ' . $file . '</a></p>';\r
-\r
- echo '<div class="dialogbox">';\r
- echo '<form method="post" action="' . htmlspecialchars($pluginUrl) . '">';\r
- $manager->addTicketHidden();\r
- echo '<input type="hidden" name="action" value="deldir_process" />';\r
- echo '<input type="hidden" name="dir" value="' . htmlspecialchars($relative . $file) . '" />';\r
-\r
- echo '<h4>' . _SKINFILES_DELETE_DIR . ' «' . htmlspecialchars($file) . '» ' . _SKINFILES_DELETE_DIR2 . '</h4><div>';\r
- echo '<p class="buttons">';\r
- echo '<input type="hidden" name="sure" value="yes" />';\r
- echo '<input type="submit" value="' . _SKINFILES_DELETE . '" />';\r
- echo '<input type="button" name="sure" value="' . _SKINFILES_CANCEL . '" onclick="history.back();" />';\r
- echo '</p>';\r
- echo '</div></form></div>';\r
- }\r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_DELETE_DIR1 . " «" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_DELETE_DIR2;\r
- echo _SKINFILES_ERR_DELETE_DIR3 . "</p>";\r
- }\r
- }\r
- \r
- function _skinfiles_deldir_process() {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = trim(_skinfiles_basename(requestVar('dir')));\r
- $directory = trim(dirname(requestVar('dir')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (requestVar('sure') == 'yes')\r
- {\r
- if (sfValidPath($directory . $file) && file_exists($directory . $file) && \r
- is_dir($directory . $file) && is_writable($directory . $file) &&\r
- sfDirectoryIsEmpty($directory . $file)) \r
- {\r
- if (!@rmdir($directory . $file)) \r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_DELETE_DIR4 . "«" . htmlspecialchars($file) . "»</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- }\r
- \r
- echo "<p class='message'>" . _SKINFILES_ERR_DELETE_DIR5 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_DELETE_DIR6 . "</p>";\r
-\r
- /* begin modification by katsumi */\r
- $num=0;\r
- $d = dir($directory);\r
- while (false !== ($entry = $d->read())) {\r
- if ($entry!='.' && $entry!='..') $num++;\r
- }\r
- $d->close();\r
- if ($num==0) _skinfiles_delbutton('dir',dirname(trim(requestVar('dir'))));\r
- /* end modification */\r
-\r
- sfShowDirectory($directory);\r
- } \r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_DELETE_DIR1 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_DELETE_DIR2;\r
- echo _SKINFILES_ERR_DELETE_DIR3 . "</p>";\r
- }\r
- }\r
- else\r
- {\r
- // User cancelled\r
- sfShowDirectory($directory);\r
- }\r
- } \r
- \r
- \r
- \r
- \r
- /* Empty directory ***************************************************************************************************************/\r
-\r
- function _skinfiles_emptydir() {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = trim(_skinfiles_basename(requestVar('dir')));\r
- $directory = trim(dirname(requestVar('dir')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (sfValidPath($directory . $file) && file_exists($directory . $file) && is_dir($directory . $file)) \r
- {\r
- $files = array();\r
- \r
- if ($dh = @opendir($directory . $file)) \r
- { \r
- while (($name = readdir($dh)) !== false) {\r
- if(!preg_match("/^\.{1,2}$/", $name) && \r
- !is_dir($directory . $file . '/' . $name) &&\r
- is_writable($directory . $file . '/' . $name)) \r
- $files[] = $name;\r
- }\r
- \r
- closedir($dh); \r
- sort($files);\r
- }\r
- \r
- $relative = sfRelativePath ($directory);\r
- $emptyUrl = $manager->addTicketToUrl($pluginUrl . '?action=emptydir&dir=' . rawurlencode($relative . $file));\r
-\r
- echo '<p class="location">' . _SKINFILES_CURRENT_LOCATION . sfDisplayPath($relative);\r
- echo '<a href="' . htmlspecialchars($emptyUrl) . '" title="Empty «' . $file . '»">';\r
- echo '<img src="' . $pluginUrl . 'dir.gif' . '" alt="" /> ' . $file . '</a></p>';\r
-\r
- echo '<div class="dialogbox">';\r
- echo '<form method="post" action="' . htmlspecialchars($pluginUrl) . '">';\r
- $manager->addTicketHidden();\r
- echo '<input type="hidden" name="action" value="emptydir_process" />';\r
- echo '<input type="hidden" name="dir" value="' . htmlspecialchars($relative . $file) . '" />';\r
-\r
- echo '<h4>' . _SKINFILES_DELETE_FILE_MSG . ' «' . htmlspecialchars($file) . '»' . _SKINFILES_DELETE_FILE_MSG2 . '</h4><div>';\r
- \r
- if (count($files)) \r
- {\r
- echo '<ul>';\r
- foreach ($files as $name) { echo '<li>' . htmlspecialchars($name) . '</li>'; }\r
- echo '</ul>';\r
- \r
- echo '<p class="buttons">';\r
- echo '<input type="hidden" name="sure" value="yes" />';\r
- echo '<input type="submit" value="' . _SKINFILES_DELETE . '" />';\r
- echo '<input type="button" name="sure" value="' . _SKINFILES_CANCEL . '" onclick="history.back();" />';\r
- echo '</p>';\r
- }\r
- else\r
- {\r
- echo '<p>' . _SKINFILES_ERR_DELETE_DIR7 . '</p>';\r
- echo '<p class="buttons">';\r
- echo '<input type="button" name="sure" value="' . _SKINFILES_CANCEL . '" onclick="history.back();" />';\r
- echo '</p>';\r
- }\r
- \r
- echo '</div></form></div>';\r
- \r
- }\r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_DELETE_DIR1 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_DELETE_DIR2;\r
- echo _SKINFILES_ERR_DELETE_DIR3 . "</p>";\r
- }\r
- }\r
-\r
- function _skinfiles_emptydir_process() {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = trim(_skinfiles_basename(requestVar('dir')));\r
- $directory = trim(dirname(requestVar('dir')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (requestVar('sure') == 'yes')\r
- {\r
- if (sfValidPath($directory . $file) && file_exists($directory . $file) && is_dir($directory . $file)) \r
- {\r
- if ($dh = @opendir($directory . $file)) \r
- { \r
- while (($name = readdir($dh)) !== false) \r
- {\r
- if(!preg_match("/^\.{1,2}$/", $name) && !is_dir($directory . $file . '/' . $name) &&\r
- is_writable($directory . $file . '/' . $name)) \r
- {\r
- if (unlink ($directory .$file . '/' . $name)) \r
- echo "<p class='message'>" . _SKINFILES_ERR_EMPTY_DIR1 . "«" . htmlspecialchars($name) . "» " . _SKINFILES_ERR_EMPTY_DIR2 . "</p>";\r
- else\r
- echo "<p class='error'>" . _SKINFILES_ERR_EMPTY_DIR3 . "«" . htmlspecialchars($name) . "» " . _SKINFILES_ERR_EMPTY_DIR4 . "</p>";\r
- }\r
- }\r
- \r
- closedir($dh); \r
- \r
- sfShowDirectory($directory . $file . '/');\r
- }\r
- }\r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_EMPTY_DIR5 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_EMPTY_DIR6;\r
- echo _SKINFILES_ERR_EMPTY_DIR7 . "</p>";\r
- }\r
- }\r
- else\r
- {\r
- // User cancelled\r
- sfShowDirectory($directory . $file . '/');\r
- }\r
- }\r
-\r
-\r
-\r
-\r
- /* Download file *****************************************************************************************************************/\r
-\r
- function _skinfiles_download() {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = _skinfiles_basename(trim(requestVar('file')));\r
-\r
- $directory = dirname(trim(requestVar('file')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (sfValidPath($directory) && file_exists($directory . $file) && \r
- is_file($directory . $file) && is_readable($directory . $file)) \r
- {\r
- if (strstr(serverVar('HTTP_USER_AGENT'), "MSIE"))\r
- $name = preg_replace('/\./', '%2e', $file, substr_count($file, '.') - 1);\r
- else\r
- $name = $file;\r
- \r
- if ($fp = @fopen($directory . $file, 'r')) {\r
- header("Cache-Control: "); // leave blank to avoid IE errors\r
- header("Pragma: "); // leave blank to avoid IE errors\r
- header("Content-type: application/octet-stream");\r
- header('Content-Disposition: attachment; filename="'.$name.'"');\r
- header("Content-length: ".(string)(filesize($directory . $file)));\r
- sleep(1);\r
- \r
- fpassthru($fp);\r
- fclose($fp);\r
- }\r
- else\r
- {\r
- echo _SKINFILES_ERR_DOWNLOAD_FILE1;\r
- }\r
- }\r
- else\r
- {\r
- echo _SKINFILES_ERR_DOWNLOAD_FILE2;\r
- }\r
-\r
- exit;\r
- }\r
-\r
-\r
-\r
-\r
- /* View file *********************************************************************************************************************/\r
-\r
- function _skinfiles_viewfile() {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = _skinfiles_basename(trim(requestVar('file')));\r
- $directory = dirname(trim(requestVar('file')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (sfValidPath($directory) && file_exists($directory . $file) && \r
- is_file($directory . $file) && is_readable($directory . $file) && sfAllowViewing($file)) \r
- {\r
- $relative = sfRelativePath ($directory);\r
- $viewUrl = $manager->addTicketToUrl($pluginUrl . '?action=viewfile&file=' . rawurlencode(sfRelativePath($directory . $file)));\r
-\r
- echo '<p class="location">' . _SKINFILES_CURRENT_LOCATION . sfDisplayPath($relative);\r
- echo '<a href="' . htmlspecialchars($viewUrl) . '" title="View «' . $file . '»">';\r
- echo '<img src="' . htmlspecialchars(sfIcon($file)) . '" alt="" /> ' . $file . '</a></p>';\r
-\r
- echo '<h4>' . _SKINFILES_VIEW_FILE . '«' . htmlspecialchars($file) . '»</h4>';\r
-\r
- if (sfIsFileType('html', $file))\r
- {\r
- echo '<iframe src="' . sfFullUrl($directory . $file) . '"></iframe>';\r
- }\r
-\r
- if (sfIsFileType('text', $file))\r
- {\r
- $content = implode('', file($directory . $file));\r
-\r
- echo '<pre>';\r
- echo htmlspecialchars($content);\r
- echo '</pre>';\r
- }\r
-\r
- if (sfIsFileType('img', $file))\r
- {\r
- $size = getimagesize($directory . $file, $info);\r
- \r
- switch ($size[2]) {\r
- case IMAGETYPE_GIF: $type = 'GIF document'; break;\r
- case IMAGETYPE_JPEG: $type = 'JPEG photograph'; break;\r
- case IMAGETYPE_PNG: $type = 'PNG document'; break;\r
- case IMAGETYPE_SWF: $type = 'Flash animation'; break;\r
- case IMAGETYPE_PSD: $type = 'Photoshop document'; break;\r
- case IMAGETYPE_BMP: $type = 'BMP document'; break;\r
- case IMAGETYPE_TIFF_II: $type = 'TIFF document (Intel Byte Order)'; break;\r
- case IMAGETYPE_TIFF_MM: $type = 'TIFF document (Motorola Byte Order)'; break;\r
- case IMAGETYPE_JPC: $type = 'JPEG2000 photograph'; break;\r
- case IMAGETYPE_JP2: $type = 'JPEG2000 photograph'; break;\r
- case IMAGETYPE_JPX: $type = 'JPEG2000 photograph'; break;\r
- case IMAGETYPE_JB2: $type = 'Slowview document'; break;\r
- case IMAGETYPE_SWC: $type = 'Flash animation (compressed)'; break;\r
- case IMAGETYPE_IFF: $type = 'IFF document'; break;\r
- case IMAGETYPE_WBMP: $type = 'WBMP document'; break;\r
- case IMAGETYPE_XBM: $type = 'XBM document'; break;\r
- default: $type = 'Unknown document'; break;\r
- }\r
-\r
- if ($size[2] == IMAGETYPE_GIF || $size[2] == IMAGETYPE_JPEG ||\r
- $size[2] == IMAGETYPE_PNG)\r
- {\r
- echo '<p><img src="' . sfFullUrl($directory . $file) . '" alt="" /></p>';\r
- }\r
- \r
- echo '<table>';\r
- echo '<tr><th colspan="2">' . _SKINFILES_VIEW_FILE_IMG_INFO . '</th></tr>';\r
- echo '<tr><td>' . _SKINFILES_VIEW_FILE_TYPE . '</td><td>' . htmlspecialchars($type) . '</td></tr>';\r
- echo '<tr><td>' . _SKINFILES_VIEW_FILE_WIDTH . '</td><td>' . htmlspecialchars($size[0]) . _SKINFILES_VIEW_FILE_PX . '</td></tr>';\r
- echo '<tr><td>' . _SKINFILES_VIEW_FILE_HEIGHT . '</td><td>' . htmlspecialchars($size[1]) . _SKINFILES_VIEW_FILE_PX . '</td></tr>'; \r
- \r
- if (isset($size['channels']) || isset($size['bits'])) \r
- {\r
- $channels = isset($size['channels']) ? $size['channels'] : 3;\r
- $depth = $size[2] == IMAGETYPE_GIF ? $size['bits'] : $size['bits'] * $channels;\r
- echo '<tr><td>' . _SKINFILES_VIEW_FILE_CHANNELS . '</td><td>' . htmlspecialchars($channels) . '</td></tr>';\r
- echo '<tr><td>' . _SKINFILES_VIEW_FILE_COLOR_DEPTH . '</td><td>' . htmlspecialchars($depth) . _SKINFILES_VIEW_FILE_BITS . '</td></tr>';\r
- echo '<tr><td>' . _SKINFILES_VIEW_FILE_COLORS . '</td><td>' . htmlspecialchars(pow(2, $depth)) . _SKINFILES_VIEW_FILE_COLORS2 . '</td></tr>';\r
- }\r
-\r
- \r
- if (function_exists('exif_read_data') && ($size[2] == IMAGETYPE_JPEG || \r
- $size[2] == IMAGETYPE_TIFF_II || $size[2] == IMAGETYPE_TIFF_MM))\r
- {\r
- $exif = exif_read_data($directory . $file, 'EXIF');\r
- \r
- if ($exif) \r
- {\r
- echo '<tr><th colspan="2">Exif information</th></tr>';\r
- \r
- if (isset($exif['Make']) && isset($exif['Model']))\r
- echo '<tr><td>Camera:</td><td>' . htmlspecialchars($exif['Make'] . ' ' . $exif['Model']) . '</td></tr>';\r
- \r
- if (isset($exif['DateTime']))\r
- echo '<tr><td>Created on:</td><td>' . htmlspecialchars($exif['DateTime']) . '</td></tr>';\r
- \r
- if (isset($exif['XResolution']))\r
- echo '<tr><td>Horizontal resolution:</td><td>' . htmlspecialchars(_skinfiles_exif_prepare($exif['XResolution'])) . ' dpi</td></tr>';\r
- \r
- if (isset($exif['YResolution']))\r
- echo '<tr><td>Vertical resolution:</td><td>' . htmlspecialchars(_skinfiles_exif_prepare($exif['YResolution'])) . ' dpi</td></tr>';\r
- \r
- if (isset($exif['FocalLength']))\r
- echo '<tr><td>Focal length:</td><td>' . htmlspecialchars(_skinfiles_exif_prepare($exif['FocalLength'])) . ' mm</td></tr>';\r
- \r
- if (isset($exif['FNumber']))\r
- echo '<tr><td>F-number:</td><td>F/' . htmlspecialchars(_skinfiles_exif_prepare($exif['FNumber'])) . '</td></tr>';\r
- \r
- if (isset($exif['ExposureTime']))\r
- echo '<tr><td>Exposuretime:</td><td>' . htmlspecialchars(_skinfiles_exif_prepare($exif['ExposureTime'])) . ' sec</td></tr>';\r
- \r
- if (isset($exif['ISOSpeedRatings']))\r
- echo '<tr><td>ISO-speed:</td><td>' . htmlspecialchars(_skinfiles_exif_prepare($exif['ISOSpeedRatings'])) . '</td></tr>';\r
- }\r
- }\r
-\r
- echo '</table>';\r
- }\r
- }\r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_VIEW_FILE1 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_VIEW_FILE2;\r
- echo _SKINFILES_ERR_VIEW_FILE3 . "</p>";\r
- }\r
- }\r
-\r
- function _skinfiles_exif_prepare($value) {\r
- if (preg_match('#([0-9]+)/([0-9]+)#', $value, $matches))\r
- if ($matches[1] < $matches[2])\r
- return '1/' . round($matches[2] / $matches[1]);\r
- else\r
- return round($matches[1] / $matches[2]);\r
- else\r
- return $value;\r
- }\r
-\r
-\r
-\r
-\r
- /* Edit file *********************************************************************************************************************/\r
-\r
- function _skinfiles_editfile() {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = _skinfiles_basename(trim(requestVar('file')));\r
- $directory = dirname(trim(requestVar('file')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (sfValidPath($directory) && file_exists($directory . $file) && \r
- is_file($directory . $file) && is_writable($directory . $file) && sfAllowEditing($file)) \r
- {\r
- $relative = sfRelativePath ($directory);\r
- $editUrl = $manager->addTicketToUrl($pluginUrl . '?action=editfile&file=' . rawurlencode(sfRelativePath($directory . $file)));\r
-\r
- echo '<p class="location">' . _SKINFILES_CURRENT_LOCATION . sfDisplayPath($relative);\r
- echo '<a href="' . htmlspecialchars($editUrl) . '" title="Edit «' . $file . '»">';\r
- echo '<img src="' . htmlspecialchars(sfIcon($file)) . '" alt="" /> ' . $file . '</a></p>';\r
-\r
- $content = implode('', file($directory . $file));\r
-\r
- echo '<div class="dialogbox">';\r
- echo '<form method="post" action="' . htmlspecialchars($pluginUrl) . '">';\r
- $manager->addTicketHidden();\r
- echo '<input type="hidden" name="action" value="editfile_process" />';\r
- echo '<input type="hidden" name="file" value="' . htmlspecialchars(sfRelativePath($directory . $file)) . '" />';\r
-\r
- echo '<h4>' . _SKINFILES_EDIT_FILE_MSG . ' «' . htmlspecialchars($file) . '»</h4><div>';\r
- echo '<p><label><textarea class="skinedit" tabindex="8" rows="20" cols="80" name="content">';\r
- echo htmlspecialchars($content);\r
- echo '</textarea></label></p>';\r
- \r
- echo '<p class="buttons">';\r
- echo '<input type="hidden" name="sure" value="yes" /">';\r
- echo '<input type="submit" value="' . _SKINFILES_SAVE_CHANGES . '" />';\r
- echo '<input type="button" name="sure" value="' . _SKINFILES_CANCEL . '" onclick="history.back();" />';\r
- echo '</p>';\r
- echo '</div></form></div>';\r
- }\r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_EDIT_FILE1 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_EDIT_FILE2;\r
- echo _SKINFILES_ERR_EDIT_FILE3 . "</p>";\r
- }\r
- }\r
-\r
- function _skinfiles_editfile_process() {\r
- global $manager;\r
- $skinfiles = $manager->getPlugin('NP_SkinFiles');\r
- $file = _skinfiles_basename(trim(requestVar('file')));\r
- $directory = dirname(trim(requestVar('file')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (requestVar('sure') == 'yes')\r
- {\r
- if (sfValidPath($directory) && file_exists($directory . $file) && \r
- is_file($directory . $file) && is_writable($directory . $file) && sfAllowEditing($file)) \r
- {\r
- if ($skinfiles->getOption('generate_backup') == 'yes')\r
- {\r
- copy($directory . $file, $directory . $skinfiles->getOption('backup_prefix') . $file);\r
- }\r
- $content = postVar('content');\r
- $success = false;\r
- if ($fh = @fopen($directory . $file, 'wb')) { \r
- \r
- if (@fwrite($fh, $content) !== false)\r
- $success = true;\r
- \r
- @fclose($fh);\r
- }\r
- \r
- if ($success)\r
- echo "<p class='message'>" . _SKINFILES_ERR_EDIT_FILE4 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_EDIT_FILE5 . "</p>";\r
- else\r
- echo "<p class='error'>" . _SKINFILES_ERR_EDIT_FILE6 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_EDIT_FILE7 . "</p>";\r
- \r
- /* begin modification by katsumi */\r
- if ($success && strlen($content)==0) {\r
- _skinfiles_delbutton('file',trim(requestVar('file')));\r
- }\r
- /* end modification */\r
- _skinfiles_editfile();\r
- }\r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_EDIT_FILE1 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_EDIT_FILE2;\r
- echo _SKINFILES_ERR_EDIT_FILE3 . "</p>";\r
- }\r
- }\r
- else\r
- {\r
- // User cancelled\r
- sfShowDirectory($directory);\r
- }\r
- }\r
-\r
-\r
-\r
- /* Rename file *******************************************************************************************************************/\r
-\r
- function _skinfiles_renfile($preset = '') {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = _skinfiles_basename(trim(requestVar('file')));\r
- $directory = dirname(trim(requestVar('file')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (sfValidPath($directory) && file_exists($directory . $file) && \r
- is_file($directory . $file) && is_writable($directory . $file)) \r
- {\r
- $relative = sfRelativePath ($directory);\r
- $editUrl = $manager->addTicketToUrl($pluginUrl . '?action=renfile&file=' . rawurlencode(sfRelativePath($directory . $file)));\r
-\r
- echo '<p class="location">' . _SKINFILES_CURRENT_LOCATION . sfDisplayPath($relative);\r
- echo '<a href="' . htmlspecialchars($editUrl) . '" title="' . _SKINFILES_RENAME . ' «' . $file . '»">';\r
- echo '<img src="' . htmlspecialchars(sfIcon($file)) . '" alt="" /> ' . $file . '</a></p>';\r
-\r
- echo '<div class="dialogbox">';\r
- echo '<form method="post" action="' . htmlspecialchars($pluginUrl) . '">';\r
- $manager->addTicketHidden();\r
- echo '<input type="hidden" name="action" value="renfile_process" />';\r
- echo '<input type="hidden" name="file" value="' . htmlspecialchars(sfRelativePath($directory . $file)) . '" />';\r
-\r
- echo '<h4>' . _SKINFILES_RENAME_FILE_MSG . '«' . htmlspecialchars($file) . '» ' . _SKINFILES_RENAME_FILE_MSG2 . '</h4><div>';\r
- echo '<p><input type="text" name="name" size="40" value="' . htmlspecialchars($preset != '' ? $preset : $file) . '" /></p>';\r
- echo '<p class="buttons">';\r
- echo '<input type="hidden" name="sure" value="yes" /">';\r
- echo '<input type="submit" value="' . _SKINFILES_RENAME . '" />';\r
- echo '<input type="button" name="sure" value="' . _SKINFILES_CANCEL . '" onclick="history.back();" />';\r
- echo '</p>';\r
- echo '</div></form></div>';\r
- }\r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_RENAME_FILE1 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_RENAME_FILE2;\r
- echo _SKINFILES_ERR_RENAME_FILE3 . "</p>";\r
- }\r
- }\r
- \r
- function _skinfiles_renfile_process() {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = _skinfiles_basename(trim(requestVar('file')));\r
- $directory = dirname(trim(requestVar('file')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (requestVar('sure') == 'yes')\r
- {\r
- if (sfValidPath($directory) && file_exists($directory . $file) && \r
- is_file($directory . $file) && is_writable($directory . $file)) \r
- {\r
- $name = requestVar('name');\r
-\r
- if ($name == '') {\r
- echo "<p class='error'>" . _SKINFILES_ERR_RENAME_FILE4 . "«" . htmlspecialchars($file) . "» ";\r
- echo _SKINFILES_ERR_RENAME_FILE5 . "</p>";\r
- _skinfiles_renfile($name);\r
- return;\r
- }\r
- \r
- if (sfIllegalFilename($name)) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_RENAME_FILE6 . "«" . htmlspecialchars($file) . "» ";\r
- echo _SKINFILES_ERR_RENAME_FILE7 . "</p>";\r
- _skinfiles_renfile($name);\r
- return;\r
- } \r
- \r
- if ($name == $file) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_RENAME_FILE8 . "«" . htmlspecialchars($file) . "» ";\r
- echo _SKINFILES_ERR_RENAME_FILE9 . "</p>";\r
- _skinfiles_renfile($name);\r
- return;\r
- }\r
- \r
- if (file_exists($directory . $name)) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_RENAME_FILE10 . "«" . htmlspecialchars($file) . "» ";\r
- echo _SKINFILES_ERR_RENAME_FILE11;\r
- echo _SKINFILES_ERR_RENAME_FILE12 . "</p>";\r
- _skinfiles_renfile($name);\r
- return;\r
- }\r
-\r
- if (!@rename($directory . $file, $directory . $name)) \r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_RENAME_FILE13 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_RENAME_FILE14 . "</p>";\r
- _skinfiles_renfile($name);\r
- return;\r
- }\r
- \r
- echo "<p class='message'>" . _SKINFILES_ERR_RENAME_FILE15 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_RENAME_FILE16;\r
- echo _SKINFILES_ERR_RENAME_FILE17 . "«" . htmlspecialchars($name) . "»" . _SKINFILES_ERR_RENAME_FILE18 . "</p>";\r
- sfShowDirectory($directory);\r
- } \r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_RENAME_FILE1 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_RENAME_FILE2;\r
- echo _SKINFILES_ERR_RENAME_FILE3 . "</p>";\r
- }\r
- }\r
- else\r
- {\r
- // User cancelled\r
- sfShowDirectory($directory);\r
- }\r
- }\r
-\r
-\r
-\r
-\r
- /* Create file *******************************************************************************************************************/\r
-\r
- function _skinfiles_createfile() {\r
- \r
- $directory = trim(requestVar('dir'));\r
- $directory = sfExpandDirectory($directory);\r
-\r
- if (sfValidPath($directory) && is_dir($directory) && is_writable($directory)) \r
- {\r
- $name = requestVar('name');\r
- \r
- if ($name == '') {\r
- echo "<p class='error'>" . _SKINFILES_ERR_CREATE_FILE1 . "</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- }\r
- \r
- if (sfIllegalFilename($name)) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_CREATE_FILE2 . "«" . htmlspecialchars($name) . "» ";\r
- echo _SKINFILES_ERR_CREATE_FILE3 . "</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- } \r
- \r
- if (file_exists($directory . $name)) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_CREATE_FILE4 . "«" . htmlspecialchars($name) . "» ";\r
- echo _SKINFILES_ERR_CREATE_FILE5;\r
- echo _SKINFILES_ERR_CREATE_FILE6 . "</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- }\r
- \r
- if (!@touch($directory . $name)) \r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_CREATE_FILE7 . "«" . htmlspecialchars($name) . "» " . _SKINFILES_ERR_CREATE_FILE8 . "</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- }\r
-\r
- $mask = @umask(0000);\r
- @chmod($directory . $name, 0755);\r
- @umask($mask);\r
- \r
- echo "<p class='message'>" . _SKINFILES_ERR_CREATE_FILE9 . "«" . htmlspecialchars($name) . "» " . _SKINFILES_ERR_CREATE_FILE10 . "</p>";\r
- sfShowDirectory($directory);\r
- } \r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_CREATE_FILE11 . "«" . htmlspecialchars(_skinfiles_basename($directory)) . "» " . _SKINFILES_ERR_CREATE_FILE12;\r
- echo _SKINFILES_ERR_CREATE_FILE13 . "</p>";\r
- }\r
- }\r
-\r
-\r
-\r
-\r
- /* Delete file *******************************************************************************************************************/\r
-\r
- function _skinfiles_delfile() {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = _skinfiles_basename(trim(requestVar('file')));\r
- $directory = dirname(trim(requestVar('file')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (sfValidPath($directory) && file_exists($directory . $file) && \r
- is_file($directory . $file) && is_writable($directory . $file)) \r
- {\r
- $relative = sfRelativePath ($directory);\r
- $delUrl = $manager->addTicketToUrl($pluginUrl . '?action=delfile&file=' . rawurlencode(sfRelativePath($directory . $file)));\r
-\r
- echo '<p class="location">' . _SKINFILES_CURRENT_LOCATION . sfDisplayPath($relative);\r
- echo '<a href="' . htmlspecialchars($delUrl) . '" title="' . _SKINFILES_DELETE . ' «' . $file . '»">';\r
- echo '<img src="' . htmlspecialchars(sfIcon($file)) . '" alt="" /> ' . $file . '</a></p>';\r
-\r
- echo '<div class="dialogbox">';\r
- echo '<form method="post" action="' . htmlspecialchars($pluginUrl) . '">';\r
- $manager->addTicketHidden();\r
- echo '<input type="hidden" name="action" value="delfile_process" />';\r
- echo '<input type="hidden" name="file" value="' . htmlspecialchars(sfRelativePath($directory . $file)) . '" />';\r
-\r
- echo '<h4>' . _SKINFILES_DELETE_FILE . ' «' . htmlspecialchars($file) . '» ' . _SKINFILES_DELETE_FILE2 . '</h4><div>';\r
- echo '<p class="buttons">';\r
- echo '<input type="hidden" name="sure" value="yes" />';\r
- echo '<input type="submit" value="' . _SKINFILES_DELETE . '" />';\r
- echo '<input type="button" name="sure" value="' . _SKINFILES_CANCEL . '" onclick="history.back();" />';\r
- echo '</p>';\r
- echo '</div></form></div>';\r
- }\r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_DELETE_FILE1 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_DELETE_FILE2;\r
- echo _SKINFILES_ERR_DELETE_FILE3 . "</p>";\r
- }\r
- }\r
-\r
- function _skinfiles_delfile_process() {\r
-\r
- global $pluginUrl, $manager;\r
- \r
- $file = _skinfiles_basename(trim(requestVar('file')));\r
- $directory = dirname(trim(requestVar('file')));\r
- $directory = sfExpandDirectory ($directory);\r
- \r
- if (requestVar('sure') == 'yes')\r
- {\r
- if (sfValidPath($directory) && file_exists($directory . $file) && \r
- is_file($directory . $file) && is_writable($directory . $file)) \r
- {\r
- if (!@unlink($directory . $file)) \r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_DELETE_FILE4 . "«" . htmlspecialchars($file) . "»</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- }\r
- \r
- echo "<p class='message'>" . _SKINFILES_ERR_DELETE_FILE5 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_DELETE_FILE6 . "</p>";\r
-\r
- /* begin modification by katsumi */\r
- $num=0;\r
- $d = dir($directory);\r
- while (false !== ($entry = $d->read())) {\r
- if ($entry!='.' && $entry!='..') $num++;\r
- }\r
- $d->close();\r
- if ($num==0) _skinfiles_delbutton('dir',dirname(trim(requestVar('file'))));\r
- /* end modification */\r
-\r
- sfShowDirectory($directory);\r
- } \r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_DELETE_FILE1 . "«" . htmlspecialchars($file) . "» " . _SKINFILES_ERR_DELETE_FILE2;\r
- echo _SKINFILES_ERR_DELETE_FILE3 . "</p>";\r
- }\r
- }\r
- else\r
- {\r
- // User cancelled\r
- sfShowDirectory($directory);\r
- }\r
- }\r
-\r
-\r
-\r
- /* Upload file *******************************************************************************************************************/\r
-\r
- function _skinfiles_uploadfile() {\r
-\r
- global $pluginUrl, $manager, $CONF;\r
- \r
- $directory = trim(requestVar('dir'));\r
- $directory = sfExpandDirectory($directory);\r
-\r
- if (sfValidPath($directory) && is_dir($directory) && is_writable($directory)) \r
- {\r
- $file = postFileInfo('name');\r
-\r
- if ($file['size'] > $CONF['MaxUploadSize']) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_UPLOAD_FILE1 . "«" . htmlspecialchars($file['name']) . "» " . _SKINFILES_ERR_UPLOAD_FILE2 . _ERROR_FILE_TOO_BIG . "<br />";\r
- echo _SKINFILES_ERR_UPLOAD_FILE3 . $CONF['MaxUploadSize'] . " / ";\r
- echo $file['size'] . " bytes</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- }\r
-\r
- if (!is_uploaded_file($file['tmp_name'])) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_UPLOAD_FILE1 . "«" . htmlspecialchars($file['name']) . "» " . _SKINFILES_ERR_UPLOAD_FILE2 . _ERROR_BADREQUEST . _SKINFILES_ERR_UPLOAD_FILE4 . "</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- }\r
- \r
- if (sfIllegalFilename($file['name'])) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_UPLOAD_FILE5 . "«" . htmlspecialchars($file['name']) . "» ";\r
- echo _SKINFILES_ERR_UPLOAD_FILE6 . "</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- }\r
- \r
- if (file_exists($directory . $file['name'])) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_UPLOAD_FILE1 . "«" . htmlspecialchars($file['name']) . "» " . _SKINFILES_ERR_UPLOAD_FILE2 . _ERROR_UPLOADDUPLICATE . "</p>";\r
- sfShowDirectory($directory);\r
- return;\r
- }\r
-\r
- if (!@move_uploaded_file($file['tmp_name'], $directory . $file['name'])) {\r
- echo "<p class='error'>" . _SKINFILES_ERR_UPLOAD_FILE1 . "«" . htmlspecialchars($file['name']) . "» " . _SKINFILES_ERR_UPLOAD_FILE2 . _ERROR_UPLOADMOVEP . _SKINFILES_ERR_UPLOAD_FILE4 . "</p>";\r
- sfShowDirectory($directory);\r
- }\r
-\r
- $mask = @umask(0000);\r
- @chmod($directory . $file['name'], 0755);\r
- @umask($mask);\r
-\r
- echo "<p class='message'>" . _SKINFILES_ERR_UPLOAD_FILE7 . "«" . htmlspecialchars($file['name']) . "» " . _SKINFILES_ERR_UPLOAD_FILE8 . "</p>";\r
- sfShowDirectory($directory);\r
- }\r
- else\r
- {\r
- echo "<p class='error'>" . _SKINFILES_ERR_UPLOAD_FILE9 . "«" . htmlspecialchars(_skinfiles_basename($directory)) . "» " . _SKINFILES_ERR_UPLOAD_FILE10;\r
- echo _SKINFILES_ERR_UPLOAD_FILE11 . "</p>";\r
- } \r
- }\r
-\r
-/* begin modification by katsumi */\r
- /* Delete file/directory buttons when empty *******************************************************************************************************************/\r
-\r
- function _skinfiles_delbutton($mode,$path){\r
- global $pluginUrl,$manager;\r
- echo '<p><form method="post" action="' . htmlspecialchars($pluginUrl) . '">';\r
- $manager->addTicketHidden();\r
- switch($mode){\r
- case 'file':\r
- echo _SKINFILES_02;\r
- echo '<input type="hidden" name="action" value="delfile_process" />';\r
- echo '<input type="hidden" name="file" value="'.htmlspecialchars($path).'" />';\r
- break;\r
- case 'dir':\r
- default:\r
- echo 'The directory is empty.';\r
- echo '<input type="hidden" name="action" value="deldir_process" />';\r
- echo '<input type="hidden" name="dir" value="'.htmlspecialchars($path).'" />';\r
- }\r
- echo '<input type="hidden" name="sure" value="yes" />';\r
- echo '<input type="submit" value="'._SKINFILES_DELETE.'" />';\r
- echo "</form></p>\n";\r
- }\r
-/* end modification */\r
-\r
- function _skinfiles_basename($name) {\r
- if ((strtolower(_CHARSET) != 'utf-8') && function_exists('mb_convert_encoding')) {\r
- $name = mb_convert_encoding($name , "UTF-8" , _CHARSET);\r
- }\r
- $name = str_replace('\\','/',$name); // Avoid using "\" in Windows.\r
- $name = rtrim($name, '/'); \r
- $name = (function_exists('mb_split')) ? end(mb_split("/",$name)) : end(explode("/",$name));\r
- if ((strtolower(_CHARSET) != 'utf-8') && function_exists('mb_convert_encoding')) {\r
- $name = mb_convert_encoding($name , _CHARSET , "UTF-8");\r
- }\r
- return $name;\r
- }\r
-?>\r