I went ahead and updated the current attach mod to work with PHPBB 3.1.5. The current method however is still not a PHPBB Extension and requires manual editing of php files, but it does work. You can download version 0.0.4 from
HERE.
What I recommend is to manually do the edits as outlined in the install.xml, which is also shown below:
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="modx.prosilver.en.xsl"?>
<!--NOTICE: Please open this file in your web browser. If presented with a security warning, you may safely tell it to allow the blocked content.-->
<!--For security purposes, please check: http://www.phpbb.com/mods/ for the latest version of this MOD.\nAlthough MODs are checked before being allowed in the MODs Database there is no guarantee that there are no security problems within the MOD.\nNo support will be given for MODs not found within the MODs Database which can be found at http://www.phpbb.com/mods/-->
<mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phpbb.com/mods/xml/modx-1.2.5.xsd">
<header>
<meta name="generator" content="MODX file generated with PP MODX Creator by tumba25 (online version)"/>
<meta name="generator" content="MODX file generated by MODX Generator by tumba25"/>
<license><![CDATA[http://opensource.org/licenses/gpl-license.php GNU General Public License v2]]></license>
<title lang="en"><![CDATA[Attach Mod]]></title>
<description lang="en"><![CDATA[The purpose of this mod is to store attachments at YYYY/MM/DD inside the files folder where attachments are normally stored. This is specially beneficial for sites with a large number of attachments to distribute the number of files into multiple folders for faster retrieval and more efficient storage.]]></description>
<author-notes lang="en"><![CDATA[This ModX Installation Package does not move your existing attachments. You will have to manually move existing attachments to the proper folders. Special thanks to the original creator of this Mod John Z for allowing me to further develop the mod for others to enjoy.]]></author-notes>
<author-group>
<author>
<realname><![CDATA[DigiOz Multimedia]]></realname>
<username><![CDATA[digioz]]></username>
<homepage><![CDATA[http://www.digioz.com]]></homepage>
<email><![CDATA[[email protected]]]></email>
</author>
</author-group>
<mod-version>0.0.4</mod-version>
<installation>
<level>advanced</level>
<time>300</time>
<target-version>3.1.5</target-version>
</installation>
<history>
<entry>
<date>2011-11-12</date>
<rev-version>0.0.1</rev-version>
<changelog lang="en">
<change><![CDATA[Initial Mod Creation]]></change>
</changelog>
</entry>
<entry>
<date>2011-11-15</date>
<rev-version>0.0.2</rev-version>
<changelog lang="en">
<change><![CDATA[Completed the Mod for version 3.0.4]]></change>
</changelog>
</entry>
<entry>
<date>2011-11-22</date>
<rev-version>0.0.3</rev-version>
<changelog lang="en">
<change><![CDATA[Upgraded the Mod for version 3.0.9]]></change>
</changelog>
</entry>
<entry>
<date>2015-08-23</date>
<rev-version>0.0.4</rev-version>
<changelog lang="en">
<change><![CDATA[Upgraded the Mod for version 3.1.5]]></change>
</changelog>
</entry>
</history>
</header>
<action-group>
<open src="download/file.php">
<edit>
<find><![CDATA[ // Determine the 'presenting'-method
if ($download_mode == PHYSICAL_LINK)]]></find>
<action type="before-add"><![CDATA[ // Attachment storage MOD
$date = getdate((int)$attachment['filetime']);
$filepath = $config['upload_path'] . '/' . (string)$date['year'] . '/' . $date['month'] . '/' . (string)$date['mday'];
]]></action>
</edit>
<edit>
<find><![CDATA[ redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']);]]></find>
<action type="replace-with"><![CDATA[ redirect($phpbb_root_path . $filepath . '/' . $attachment['physical_filename']);]]></action>
</edit>
<edit>
<find><![CDATA[ send_file_to_browser($attachment, $config['upload_path'], $display_cat);]]></find>
<action type="replace-with"><![CDATA[ send_file_to_browser($attachment, $filepath, $display_cat);]]></action>
</edit>
</open>
<open src="includes/functions_content.php">
<edit>
<find><![CDATA[ $attachment['extension'] = strtolower(trim($attachment['extension']));]]></find>
<action type="after-add"><![CDATA[ // Attachment storage MOD
$date = getdate((int)$attachment['filetime']);
$filepath = $phpbb_root_path . $config['upload_path'] . '/' . (string)$date['year'] . '/' . $date['month'] . '/' . (string)$date['mday'];
$filename = $filepath . '/' . utf8_basename($attachment['physical_filename']);]]></action>
</edit>
<edit>
<find><![CDATA[ $filename = $phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($attachment['physical_filename']);]]></find>
<action type="replace-with"><![CDATA[ $thumbnail_filename = $filepath . '/thumb_' . utf8_basename($attachment['physical_filename']);
// END Attach storage MOD]]></action>
</edit>
<edit>
<remove><![CDATA[ $thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . utf8_basename($attachment['physical_filename']);]]></remove>
</edit>
</open>
<open src="includes/functions_posting.php">
<edit>
<find><![CDATA[$is_image = (isset($extensions[$file->get('extension')]['display_cat'])) ? $extensions[$file->get('extension')]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE : false;]]></find>
<action type="after-add"><![CDATA[ // Attachment storage MOD
$date = getdate();
$filepath = $phpbb_root_path . $config['upload_path'] . '/' . (string)$date['year'] . '/' . $date['month'] . '/' . (string)$date['mday'] . '/';
if(!is_dir($filepath)) {
$ok = @mkdir($filepath, 0777, true);
}]]></action>
</edit>
<edit>
<find><![CDATA[$file->move_file($config['upload_path'], false, !$is_image);]]></find>
<action type="replace-with"><![CDATA[$file->move_file($filepath, false, !$is_image);
// End Attach storage MOD]]></action>
</edit>
<edit>
<find><![CDATA[$filedata['real_filename'] = $file->get('uploadname');]]></find>
<action type="after-add"><![CDATA[ // Attach storage MOD]]></action>
</edit>
<edit>
<find><![CDATA[$filedata['filetime'] = time();]]></find>
<action type="replace-with"><![CDATA[ $filedata['filetime'] = $date[0];
// End Attach storage MOD]]></action>
</edit>
<edit>
<find><![CDATA[if ($free_space = @disk_free_space($phpbb_root_path . $config['upload_path']))]]></find>
<action type="replace-with"><![CDATA[if ($free_space = @disk_free_space($phpbb_root_path . $filepath))]]></action>
</edit>
<edit>
<find><![CDATA[ // insert attachment into db]]></find>
<action type="after-add"><![CDATA[ // Attachment storage MOD
$date = getdate($attach_row['filetime']);
$filepath = $phpbb_root_path . $config['upload_path'] . "/" . (string)$date['year'] . '/' . $date['month'] . '/' . (string)$date['mday'];
// Below line modified for Attachment storage MOD]]></action>
</edit>
<edit>
<find><![CDATA[ if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename'])))]]></find>
<action type="replace-with"><![CDATA[ if (!@file_exists($filepath . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename'])))]]></action>
</edit>
</open>
<open src="includes/message_parser.php">
<edit>
<find><![CDATA[ 'attach_comment'=> $this->filename_data['filecomment'],]]></find>
<action type="after-add"><![CDATA[ 'filetime' => $filedata['filetime'],]]></action>
</edit>
<edit>
<find><![CDATA[ 'attach_comment'=> $this->filename_data['filecomment'],]]></find>
<action type="after-add"><![CDATA[ 'filetime' => $filedata['filetime'],]]></action>
</edit>
<edit>
<find><![CDATA[ $sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment]]></find>
<inline-edit>
<inline-find><![CDATA[, attach_comment]]></inline-find>
<inline-action type="after-add"><![CDATA[, filetime]]></inline-action>
</inline-edit>
</edit>
<edit>
<find><![CDATA[ $sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment]]></find>
<inline-edit>
<inline-find><![CDATA[, attach_comment]]></inline-find>
<inline-action type="after-add"><![CDATA[, filetime]]></inline-action>
</inline-edit>
</edit>
</open>
</action-group>
</mod>
Hopefully at some point we will be able to add an event trigger to turn this mod into an official extension.
Thanks,
Pete