PDA

View Full Version : Miscellaneous Hacks - oXoXo's VB Amazon S3 Hack


oxoxo
12-20-2011, 11:00 PM
With this Hack you can all Pictures und Downloadable Files, view from your S3 Account.

Step 1. backup your original attachment.php
Step 2. replace attachment.php with new hack version
Step 3. Configure in attachment.php your defines:

define('AWS_KEY', 'your aws key');
define('AWS_SECRET', 'your aws secret key');
define('AWS_Bucket', "your aws bucket");

Step 4. Upload Zend Framework to your Webserver Root Directory
Step 5. Synchronize with Tools like "Transmit" your Webserver Folder store_attachment with your AWS Bucket.

Sample copy this from Webserver:
store_attachment/2/59.attach
store_attachment/3/44.attach
store_attachment/3/44.thumb
...
To your S3 Bucket
YourBucket/2/59.attach
YourBucket/3/44.attach
YourBucket/3/44.thumb

Step 6. After Synchronize you can Remove all or only your big Files in your store_attachment Folder.
Step 7. Synchronize every day or week or not.

The attachment.php download and view your pictures and files from your S3 and when not found on this, download the File from your Webserver.

Its Simple. Its Work.

Alternative:
You can rename my attachment.php to download.php and modifier with Jquery in the headinclude template:
<script type="text/javascript" src="{vb:raw vboptions.bburl}/clientscript/jquery/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var strNewString = $('body').html().replace(/\attachment.php/g,'download.php');
$('body').html(strNewString);
});
</script>
In this Case rename in your new download.php
Row 36: #attachment\.php to #download\.php
Row 189: 'attachment.php?' to 'download.php?'


For more Comfortable Uploads i have create a Java App.
With Java App "VBS3Uploader" you can upload many big Files to your S3 Account. The App Save the File Reference in your VB Board Database. After Upload you can with Data Manager select the File in your Article und Posts. The App is designed for Webmaster and her Mods.

App Features:

-Test your Connections.
-Upload Files with 1GB size and more
-Debug Windows
-Progressbar
-Configure your Properties( AWS Keys, Bucket, VB UserID and DB Password)
-All relevant Keys and Passwords are encrypt saved

Please not forget:
Change your Properties after First Start the App.
Please Change the Database Connection in the hibernate.cfg.xml.

1. Unpack the jasypt-1.8-dist.zip.
2. Go with terminal to jasypt-1.8/bin Folder.
3. Encrypt your Database Password with call enrypt.bat or encrypt.sh
"encrypt.bat input="YOUR-DATABASE-PASSWORD" password=YOUR-ENCRYPTION-PASSWORD algorithm=PBEWithMD5AndDES"
4. Copy the Result in your hibernate.cfg.xml:
<property name="hibernate.connection.password">ENC(your result from encrypt)</property>
5. Change the values
<property name="hibernate.connection.url">jdbc:mysql://your server url:3306/your databasename</property>
<property name="hibernate.connection.username">your databaseuser</property>


Run the App: java -jar VBS3Uploader.jar

It's a First Version. Please contact me when you find Bugs or for support.
oxoxo@gamesattack.me

Donation: Please Register on www.gamesattack.me

I cant upload more as 3 Files in this post.

therefore you must download the following files from my s3 account
http://s3.amazonaws.com/amb_images/VBS3Uploader.zip
http://s3.amazonaws.com/amb_images/jasypt-1.8-dist.zip
http://s3.amazonaws.com/amb_images/Zend.zip

strudinox
12-23-2011, 03:42 PM
Interest concept. I'm running an S3 for all my static content and having it manage attachments would be very ideal. So if I'm reading this correctly, every time someone uploads an attachment, it automatically gets sent to my S3 server?

oxoxo
12-23-2011, 06:11 PM
no it's not a automatic upload to s3 server. You can synchronize with external tools your attachments every night. Or you select your favorit attachments and copy manuell to your s3 server.
The attachment.php take the attachments first from s3 server and when not found, then take the attachment from your webserver.
Best practice, all thumbs leave on your webserver and copy the pictures and attachments to your s3 Server.
Next Version, we should built an configurable cron job, which synchronizes the attachements and after synchron job run, should the job remove all these attachments from webserver.

The VBS3Uploader Tool upload your new Attachments directly to your s3 server and save the Reference in your VB Database. After Upload you can select the Attachment for your Posts in the VB Software. Alltrough the attachment is not on the webserver. Its only on s3 server.

v123shine
12-24-2011, 03:08 AM
can you make this mod for vb 3.8
please!

yahooooh
12-24-2011, 08:48 PM
can not be downloaded ,
http://s3.amazonaws.com/amb_images/VBS3Uploader.zip
http://s3.amazonaws.com/amb_images/jasypt-1.8-dist.zip
http://s3.amazonaws.com/amb_images/Zend.zip

access denied

oxoxo
12-24-2011, 08:59 PM
okay, sorry, i have change the access rights for downloads.

oxoxo
12-24-2011, 09:09 PM
The attachment.php form my 4.17 Version and new version 4.18 or 4.19 Version are the same. The Mod is therefore full compatible.

oxoxo
12-24-2011, 09:46 PM
i have an update of attachment.php Version 1.01 2011/12/24

- better Header Cache Handling for Attachmentfiles
- you can modifier two 2 lines, when you have problems with Timeout errors of big Files.

@ini_set('memory_limit', '800M');
@ini_set('max_execution_time', 0);

kingdruid
01-21-2012, 04:25 PM
So this returns the S3 link to attachments.php then attachments.php serves the file from your S3 account which would save space on your web server.

It would be nice to have something return the S3 link when viewing attachments and posting, then upload to S3 when a user tries to attach a new file. Without that your webserver is still using up your traffic/Resources + S3 traffic because its being outputted from attachment.php.

pelican
06-01-2013, 05:05 AM
The attachment.php form my 4.17 Version and new version 4.18 or 4.19 Version are the same. The Mod is therefore full compatible.

is this mod consider complete?

the idea is good.

i think we need some coding to automatically synchronize (cron job) server attachment to S3 and then remove the attachments in the server.

it is tedious to use 3rd party apps/tools to manually synchronize at regular basis.

furnival
06-21-2013, 01:00 PM
This looks very good, it might be just what I need.

i think we need some coding to automatically synchronize (cron job) server attachment to S3 and then remove the attachments in the server.


These look like good 3rd party (open source) tools for synchronising to S3 through a cron job and I believe one of them can delete files from your server: http://s3tools.org/s3cmd and http://s3tools.org/s3cmd-sync

fly
08-21-2013, 03:11 PM
Does anyone still happen to have the Zend.zip handy? I'd like to try this on vB4.2

hoangserip
08-21-2013, 03:20 PM
What a great idea! Thank you for making this.