|
From: <luc...@us...> - 2013-10-04 16:52:02
|
Revision: 12126
http://sourceforge.net/p/xoops/svn/12126
Author: luciorota
Date: 2013-10-04 16:51:59 +0000 (Fri, 04 Oct 2013)
Log Message:
-----------
bug fix
Modified Paths:
--------------
XoopsModules/wfdownloads/trunk/wfdownloads/admin/clone.php
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/admin/clone.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/admin/clone.php 2013-10-04 16:48:46 UTC (rev 12125)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/admin/clone.php 2013-10-04 16:51:59 UTC (rev 12126)
@@ -52,7 +52,7 @@
$message = "";
if (is_dir(XOOPS_ROOT_PATH . '/modules/' . strtolower($cloneDirname))) {
- $message .= sprintf(_AM_WFDOWNLOADS_CLONE_CONGRAT, "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin'>" . ucfirst(strtolower($cloneDirname)) . "</a>") . "<br />\n";
+ $message .= sprintf(_AM_WFDOWNLOADS_CLONE_CONGRAT, "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin&op=installlist'>" . ucfirst(strtolower($cloneDirname)) . "</a>") . "<br />\n";
if (!$logocreated) {
$message .= _AM_WFDOWNLOADS_CLONE_IMAGEFAIL;
}
@@ -131,6 +131,8 @@
function wfdownloads_createLogo($dirname)
{
+ $wfdownloads = WfdownloadsWfdownloads::getInstance();
+ // Check extension/functions
if (!extension_loaded("gd")) {
return false;
} else {
@@ -148,26 +150,27 @@
}
}
}
-
- if (!file_exists($imageBase = XOOPS_ROOT_PATH . "/modules/" . $dirname . "/images/module_logo.png") || !file_exists($font = XOOPS_ROOT_PATH . "/modules/" . $dirname . "/images/VeraBd.ttf")) {
+ // Check original image/font
+ if (!file_exists($imageBase = XOOPS_ROOT_PATH . "/modules/" . $dirname . "/images/module_logo.png")) {
return false;
}
-
+ if (!file_exists($font = XOOPS_ROOT_PATH . "/modules/" . $wfdownloads->getModule()->dirname() . "/images/VeraBd.ttf")) {
+ return false;
+ }
+ // Create image
$imageModule = imagecreatefrompng($imageBase);
-
- //Erase old text
- $grey_color = imagecolorallocate($imageModule, 237, 237, 237);
- imagefilledrectangle($imageModule, 5, 35, 85, 46, $grey_color);
-
+ // Erase old text
+ $greyColor = imagecolorallocate($imageModule, 237, 237, 237);
+ imagefilledrectangle($imageModule, 5, 35, 85, 46, $greyColor);
// Write text
- $text_color = imagecolorallocate($imageModule, 0, 0, 0);
+ $textColor = imagecolorallocate($imageModule, 0, 0, 0);
$space_to_border = (80 - strlen($dirname) * 6.5) / 2;
- imagefttext($imageModule, 8.5, 0, $space_to_border, 45, $text_color, $font, ucfirst($dirname), array());
-
+ imagefttext($imageModule, 8.5, 0, $space_to_border, 45, $textColor, $font, ucfirst($dirname), array());
// Set transparency color
- $white = imagecolorallocatealpha($imageModule, 255, 255, 255, 127);
- imagefill($imageModule, 0, 0, $white);
- imagecolortransparent($imageModule, $white);
+ $whiteColor = imagecolorallocatealpha($imageModule, 255, 255, 255, 127);
+ imagefill($imageModule, 0, 0, $whiteColor);
+ imagecolortransparent($imageModule, $whiteColor);
+ // Save new image
imagepng($imageModule, XOOPS_ROOT_PATH . "/modules/" . $dirname . "/images/module_logo.png");
imagedestroy($imageModule);
return true;
|
|
From: <luc...@us...> - 2013-10-05 13:47:32
|
Revision: 12135
http://sourceforge.net/p/xoops/svn/12135
Author: luciorota
Date: 2013-10-05 13:47:28 +0000 (Sat, 05 Oct 2013)
Log Message:
-----------
removed unused function
Modified Paths:
--------------
XoopsModules/wfdownloads/trunk/wfdownloads/admin/clone.php
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/admin/clone.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/admin/clone.php 2013-10-05 12:52:14 UTC (rev 12134)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/admin/clone.php 2013-10-05 13:47:28 UTC (rev 12135)
@@ -1,165 +1,164 @@
-<?php
-/*
- You may not change or alter any portion of this comment or credits
- of supporting developers from this source code or any supporting source code
- which is considered copyrighted (c) material of the original comment or credit authors.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
-/**
- * Wfdownloads module
- *
- * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
- * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
- * @package wfdownload
- * @since 3.23
- * @author Xoops Development Team
- * @version svn:$id$
- */
-$currentFile = basename(__FILE__);
-include_once dirname(__FILE__) . '/admin_header.php';
-
-if (@$_POST['op'] == 'submit') {
- if (!$GLOBALS['xoopsSecurity']->check()) {
- redirect_header($currentFile, 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()));
- exit();
- }
-
- $cloneDirname = $_POST['clonedirname'];
-
- // Check if name is valid
- if (empty($cloneDirname) || preg_match('/[^a-zA-Z0-9\_\-]/', $cloneDirname)) {
- redirect_header($currentFile, 3, sprintf(_AM_WFDOWNLOADS_CLONE_INVALIDNAME, $cloneDirname));
- exit();
- }
- // Check wether the cloned module exists or not
- if ($cloneDirname && is_dir(XOOPS_ROOT_PATH . '/modules/' . $cloneDirname)) {
- redirect_header($currentFile, 3, sprintf(_AM_WFDOWNLOADS_CLONE_EXISTS, $cloneDirname));
- }
-
- $patterns = array(
- strtolower(WFDOWNLOADS_DIRNAME) => strtolower($cloneDirname),
- strtoupper(WFDOWNLOADS_DIRNAME) => strtoupper($cloneDirname),
- ucfirst(strtolower(WFDOWNLOADS_DIRNAME)) => ucfirst(strtolower($cloneDirname))
- );
-
- $patKeys = array_keys($patterns);
- $patValues = array_values($patterns);
- wfdownloads_cloneFileDir(WFDOWNLOADS_ROOT_PATH);
- $logocreated = wfdownloads_createLogo(strtolower($cloneDirname));
-
- $message = "";
- if (is_dir(XOOPS_ROOT_PATH . '/modules/' . strtolower($cloneDirname))) {
- $message .= sprintf(_AM_WFDOWNLOADS_CLONE_CONGRAT, "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin&op=installlist'>" . ucfirst(strtolower($cloneDirname)) . "</a>") . "<br />\n";
- if (!$logocreated) {
- $message .= _AM_WFDOWNLOADS_CLONE_IMAGEFAIL;
- }
- } else {
- $message .= _AM_WFDOWNLOADS_CLONE_FAIL;
- }
-
- wfdownloads_xoops_cp_header();
- $indexAdmin = new ModuleAdmin();
- echo $indexAdmin->addNavigation($currentFile);
- echo $message;
- include 'admin_footer.php';
- exit();
-
-} else {
- wfdownloads_xoops_cp_header();
- $indexAdmin = new ModuleAdmin();
- echo $indexAdmin->addNavigation($currentFile);
- include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
- $form = new XoopsThemeForm(sprintf(_AM_WFDOWNLOADS_CLONE_TITLE, $wfdownloads->getModule()->getVar('name', 'E')), 'clone', $currentFile, 'post', true);
- $cloneDirname_text = new XoopsFormText(_AM_WFDOWNLOADS_CLONE_NAME, 'clonedirname', 20, 20, '');
- $cloneDirname_text->setDescription(_AM_WFDOWNLOADS_CLONE_NAME_DSC);
- $form->addElement($cloneDirname_text, true);
- $form->addElement(new XoopsFormHidden('op', 'submit'));
- $form->addElement(new XoopsFormButton('', '', _SUBMIT, 'submit'));
- $form->display();
- include 'admin_footer.php';
- exit();
-}
-
-// recursive clonning script
-function wfdownloads_cloneFileDir($path)
-{
- global $patKeys;
- global $patValues;
-
- $newPath = str_replace($patKeys[0], $patValues[0], $path);
-
- if (is_dir($path)) {
- // create new dir
- mkdir($newPath);
- // check all files in dir, and process it
- if ($handle = opendir($path)) {
- while ($file = readdir($handle)) {
- if ($file != '.' && $file != '..' && $file != '.svn') {
- wfdownloads_cloneFileDir("{$path}/{$file}");
- }
- }
- closedir($handle);
- }
- } else {
- if (preg_match('/(.jpg|.gif|.png|.zip|.ttf)$/i', $path)) {
- // image
- copy($path, $newPath);
- } else {
- // file, read it
- $content = file_get_contents($path);
- $content = str_replace($patKeys, $patValues, $content);
- file_put_contents($newPath, $content);
- }
- }
-}
-
-function wfdownloads_createLogo($dirname)
-{
- $wfdownloads = WfdownloadsWfdownloads::getInstance();
- // Check extension/functions
- if (!extension_loaded("gd")) {
- return false;
- } else {
- $required_functions = array(
- "imagecreatetruecolor",
- "imagecolorallocate",
- "imagefilledrectangle",
- "imagejpeg",
- "imagedestroy",
- "imageftbbox"
- );
- foreach ($required_functions as $func) {
- if (!function_exists($func)) {
- return false;
- }
- }
- }
- // Check original image/font
- if (!file_exists($imageBase = XOOPS_ROOT_PATH . "/modules/" . $dirname . "/images/module_logo.png")) {
- return false;
- }
- if (!file_exists($font = XOOPS_ROOT_PATH . "/modules/" . $wfdownloads->getModule()->dirname() . "/images/VeraBd.ttf")) {
- return false;
- }
- // Create image
- $imageModule = imagecreatefrompng($imageBase);
- // Erase old text
- $greyColor = imagecolorallocate($imageModule, 237, 237, 237);
- imagefilledrectangle($imageModule, 5, 35, 85, 46, $greyColor);
- // Write text
- $textColor = imagecolorallocate($imageModule, 0, 0, 0);
- $space_to_border = (80 - strlen($dirname) * 6.5) / 2;
- imagefttext($imageModule, 8.5, 0, $space_to_border, 45, $textColor, $font, ucfirst($dirname), array());
- // Set transparency color
- $whiteColor = imagecolorallocatealpha($imageModule, 255, 255, 255, 127);
- imagefill($imageModule, 0, 0, $whiteColor);
- imagecolortransparent($imageModule, $whiteColor);
- // Save new image
- imagepng($imageModule, XOOPS_ROOT_PATH . "/modules/" . $dirname . "/images/module_logo.png");
- imagedestroy($imageModule);
-
- return true;
-}
+<?php
+/*
+ You may not change or alter any portion of this comment or credits
+ of supporting developers from this source code or any supporting source code
+ which is considered copyrighted (c) material of the original comment or credit authors.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+/**
+ * Wfdownloads module
+ *
+ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
+ * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @package wfdownload
+ * @since 3.23
+ * @author Xoops Development Team
+ * @version svn:$id$
+ */
+$currentFile = basename(__FILE__);
+include_once dirname(__FILE__) . '/admin_header.php';
+
+if (@$_POST['op'] == 'submit') {
+ if (!$GLOBALS['xoopsSecurity']->check()) {
+ redirect_header($currentFile, 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()));
+ exit();
+ }
+
+ $cloneDirname = $_POST['clonedirname'];
+
+ // Check if name is valid
+ if (empty($cloneDirname) || preg_match('/[^a-zA-Z0-9\_\-]/', $cloneDirname)) {
+ redirect_header($currentFile, 3, sprintf(_AM_WFDOWNLOADS_CLONE_INVALIDNAME, $cloneDirname));
+ exit();
+ }
+ // Check wether the cloned module exists or not
+ if ($cloneDirname && is_dir(XOOPS_ROOT_PATH . '/modules/' . $cloneDirname)) {
+ redirect_header($currentFile, 3, sprintf(_AM_WFDOWNLOADS_CLONE_EXISTS, $cloneDirname));
+ }
+
+ $patterns = array(
+ strtolower(WFDOWNLOADS_DIRNAME) => strtolower($cloneDirname),
+ strtoupper(WFDOWNLOADS_DIRNAME) => strtoupper($cloneDirname),
+ ucfirst(strtolower(WFDOWNLOADS_DIRNAME)) => ucfirst(strtolower($cloneDirname))
+ );
+
+ $patKeys = array_keys($patterns);
+ $patValues = array_values($patterns);
+ wfdownloads_cloneFileDir(WFDOWNLOADS_ROOT_PATH);
+ $logocreated = wfdownloads_createLogo(strtolower($cloneDirname));
+
+ $message = "";
+ if (is_dir(XOOPS_ROOT_PATH . '/modules/' . strtolower($cloneDirname))) {
+ $message .= sprintf(_AM_WFDOWNLOADS_CLONE_CONGRAT, "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin&op=installlist'>" . ucfirst(strtolower($cloneDirname)) . "</a>") . "<br />\n";
+ if (!$logocreated) {
+ $message .= _AM_WFDOWNLOADS_CLONE_IMAGEFAIL;
+ }
+ } else {
+ $message .= _AM_WFDOWNLOADS_CLONE_FAIL;
+ }
+
+ wfdownloads_xoops_cp_header();
+ $indexAdmin = new ModuleAdmin();
+ echo $indexAdmin->addNavigation($currentFile);
+ echo $message;
+ include 'admin_footer.php';
+ exit();
+
+} else {
+ wfdownloads_xoops_cp_header();
+ $indexAdmin = new ModuleAdmin();
+ echo $indexAdmin->addNavigation($currentFile);
+ include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
+ $form = new XoopsThemeForm(sprintf(_AM_WFDOWNLOADS_CLONE_TITLE, $wfdownloads->getModule()->getVar('name', 'E')), 'clone', $currentFile, 'post', true);
+ $cloneDirname_text = new XoopsFormText(_AM_WFDOWNLOADS_CLONE_NAME, 'clonedirname', 20, 20, '');
+ $cloneDirname_text->setDescription(_AM_WFDOWNLOADS_CLONE_NAME_DSC);
+ $form->addElement($cloneDirname_text, true);
+ $form->addElement(new XoopsFormHidden('op', 'submit'));
+ $form->addElement(new XoopsFormButton('', '', _SUBMIT, 'submit'));
+ $form->display();
+ include 'admin_footer.php';
+ exit();
+}
+
+// recursive clonning script
+function wfdownloads_cloneFileDir($path)
+{
+ global $patKeys;
+ global $patValues;
+
+ $newPath = str_replace($patKeys[0], $patValues[0], $path);
+
+ if (is_dir($path)) {
+ // create new dir
+ mkdir($newPath);
+ // check all files in dir, and process it
+ if ($handle = opendir($path)) {
+ while ($file = readdir($handle)) {
+ if ($file != '.' && $file != '..' && $file != '.svn') {
+ wfdownloads_cloneFileDir("{$path}/{$file}");
+ }
+ }
+ closedir($handle);
+ }
+ } else {
+ if (preg_match('/(.jpg|.gif|.png|.zip|.ttf)$/i', $path)) {
+ // image
+ copy($path, $newPath);
+ } else {
+ // file, read it
+ $content = file_get_contents($path);
+ $content = str_replace($patKeys, $patValues, $content);
+ file_put_contents($newPath, $content);
+ }
+ }
+}
+
+function wfdownloads_createLogo($dirname)
+{
+ $wfdownloads = WfdownloadsWfdownloads::getInstance();
+ // Check extension/functions
+ if (!extension_loaded("gd")) {
+ return false;
+ } else {
+ $required_functions = array(
+ "imagecreatetruecolor",
+ "imagecolorallocate",
+ "imagefilledrectangle",
+ "imagejpeg",
+ "imagedestroy",
+ "imageftbbox"
+ );
+ foreach ($required_functions as $func) {
+ if (!function_exists($func)) {
+ return false;
+ }
+ }
+ }
+ // Check original image/font
+ if (!file_exists($imageBase = XOOPS_ROOT_PATH . "/modules/" . $dirname . "/images/module_logo.png")) {
+ return false;
+ }
+ if (!file_exists($font = XOOPS_ROOT_PATH . "/modules/" . $wfdownloads->getModule()->dirname() . "/images/VeraBd.ttf")) {
+ return false;
+ }
+ // Create image
+ $imageModule = imagecreatefrompng($imageBase);
+ // Erase old text
+ $greyColor = imagecolorallocate($imageModule, 237, 237, 237);
+ imagefilledrectangle($imageModule, 5, 35, 85, 46, $greyColor);
+ // Write text
+ $textColor = imagecolorallocate($imageModule, 0, 0, 0);
+ $space_to_border = (80 - strlen($dirname) * 6.5) / 2;
+ imagefttext($imageModule, 8.5, 0, $space_to_border, 45, $textColor, $font, ucfirst($dirname), array());
+ // Set transparency color
+ $whiteColor = imagecolorallocatealpha($imageModule, 255, 255, 255, 127);
+ imagefill($imageModule, 0, 0, $whiteColor);
+ imagecolortransparent($imageModule, $whiteColor);
+ // Save new image
+ imagepng($imageModule, XOOPS_ROOT_PATH . "/modules/" . $dirname . "/images/module_logo.png");
+ imagedestroy($imageModule);
+ return true;
+}
|