diff --git a/docs/Update.txt b/docs/Update.txt new file mode 100644 index 0000000..13112fa --- /dev/null +++ b/docs/Update.txt @@ -0,0 +1,11 @@ +Important information for updating a version below 2.0 !!! + +Step: + +1. Connect to your site and go to module administration. +2. Delete the folder "modules/TDMDownloads" +3. Copy the "tdmdownloads" folder (version greater than 2) to folder "modules/" +4. Update the "tdmdownloads" module +5. Go into the preferences of the module "tdmdownloads", choose "Max uploaded files size" and validate them. + +tdmdownloads is now up to date. \ No newline at end of file diff --git a/include/onupdate.php b/include/onupdate.php index 56bbb8e..881381c 100644 --- a/include/onupdate.php +++ b/include/onupdate.php @@ -43,12 +43,12 @@ function xoops_module_update_tdmdownloads(&$module, $prev_version = null) */ function update_tdmdownloads_v200(&$module) { + // Update size $db = \XoopsDatabaseFactory::getDatabaseConnection(); $sql = 'SELECT lid, size FROM ' . $db->prefix('tdmdownloads_downloads'); $result = $db->query($sql); $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); $helper->loadLanguage('admin'); - //print_r($result); while (false !== ($myrow = $db->fetchArray($result))) { $size_value_arr = explode(' ', $myrow['size']); switch ($size_value_arr[1]) { @@ -83,6 +83,11 @@ function update_tdmdownloads_v200(&$module) break; } } + // Update folder + rename(XOOPS_ROOT_PATH . '/uploads/TDMDownloads', XOOPS_ROOT_PATH . '/uploads/tdmdownloads'); + // Change TDMDownloads with tdmdownloads + $sql = 'UPDATE `' . $db->prefix('tdmdownloads_downloads') . '` SET `url` = REPLACE(`url`, \'TDMDownloads\', \'tdmdownloads\') WHERE `url` LIKE \'%TDMDownloads%\''; + $result = $db->query($sql); return true; } @@ -110,21 +115,21 @@ function update_tdmdownloads_v167(&$module) // unlink( XOOPS_ROOT_PATH.'/modules/tdmdownloads/admin/admin_header.php' ); // clean template directory - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_brokenfile.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_download.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_index.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_modfile.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_ratefile.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_singlefile.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_submit.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_viewcat.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_liste.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_rss.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_new.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_random.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_rating.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_search.html'); - unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_top.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_brokenfile.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_download.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_index.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_modfile.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_ratefile.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_singlefile.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_submit.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_viewcat.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_liste.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/tdmdownloads_rss.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_new.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_random.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_rating.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_search.html'); + @unlink(XOOPS_ROOT_PATH . '/modules/tdmdownloads/templates/blocks/tdmdownloads_block_top.html'); return true; } diff --git a/include/xoops_version.inc.php b/include/xoops_version.inc.php new file mode 100644 index 0000000..f4f87eb --- /dev/null +++ b/include/xoops_version.inc.php @@ -0,0 +1,36 @@ + 0, ]; -//xoops_load('xoopseditorhandler'); -//$editorHandler = \XoopsEditorHandler::getInstance(); - $modversion['config'][] = [ 'name' => 'editor', 'title' => '_MI_TDMDOWNLOADS_FORM_OPTIONS', @@ -536,8 +533,9 @@ 'default' => 'downloads_', ]; -$iniPostMaxSize = returnBytes(ini_get('post_max_size')); -$iniUploadMaxFileSize = returnBytes(ini_get('upload_max_filesize')); +include_once 'include/xoops_version.inc.php'; +$iniPostMaxSize = tdmdownloadsReturnBytes(ini_get('post_max_size')); +$iniUploadMaxFileSize = tdmdownloadsReturnBytes(ini_get('upload_max_filesize')); $maxSize = min($iniPostMaxSize, $iniUploadMaxFileSize); if ($maxSize > 10000 * 1048576) { $increment = 500; @@ -894,24 +892,3 @@ 'mail_template' => 'file_approve_notify', 'mail_subject' => _MI_TDMDOWNLOADS_FILE_APPROVE_NOTIFYSBJ, ]; - -/** - * @param $val - * @return float|int - */ -function returnBytes($val) -{ - switch (mb_substr($val, -1)) { - case 'K': - case 'k': - return (int)$val * 1024; - case 'M': - case 'm': - return (int)$val * 1048576; - case 'G': - case 'g': - return (int)$val * 1073741824; - default: - return $val; - } -}