Hi, I want to create an incentive system for posters, so that when they get xx posts they can download xx file. How could i create such a system using vBulletin 3.6.0. Thanks for any suggestions, Rob
<?php define('MAX_POSTS', 100); define('THIS_SCRIPT', 1); define('LOCATION_BYPASS', 1); include('./global.php'); if ($vbulletin->userinfo['posts'] >= MAX_POSTS) { // Download file } else { echo 'Sorry, you need '. MAX_POSTS .' posts to be able to download this file.'; } ?> Code (markup):
Sorry i forgot the thread. Thanks for the fast reply and code. { // Download file } Code (markup): Do i add my download URL in that line? Rep added. Rob
I would rather not have the source of the download revieled,so i think the php should send the file. Thanks again for the help, Rob
Untested, but give it a try. <?php $filepath = '/path/to/file/file.exe'; define('MIN_POSTS', 100); define('THIS_SCRIPT', 1); define('LOCATION_BYPASS', 1); include('./global.php'); if ($vbulletin->userinfo['posts'] >= MIN_POSTS) { exit('Sorry, you need at least '. MIN_POSTS .' to download this file.'); } if (!file_exists($filepath)) { exit('The file could not be found.'); } ob_end_clean(); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Expires: '. gmdate('D, d M Y H:i:s', mktime(date('H')+2, date('i'), date('s'), date('m'), date('d'), date('Y'))).' GMT'); header('Last-Modified: '. gmdate('D, d M Y H:i:s').' GMT'); header('Content-Type: application/octet-stream'); header('Content-Length: '. filesize($filepath)); header('Content-Disposition: attachment; filename="'. basename($filepath) .'"'); header('Content-Transfer-Encoding: binary'); if (!($file = @fopen($filepath, 'rb'))) { exit(); } while (!feof($file) AND connection_status() == 0) { echo fread($file, 1024 * 8); } flush(); exit(); ?> PHP:
Nice script, but unregistered users can download. I didnt login and i could download the file. Any fix ideas? Rob
Try replacing this. if ($vbulletin->userinfo['posts'] >= MIN_POSTS) PHP: with this. if ($vbulletin->userinfo['userid'] != 0 AND $vbulletin->userinfo['posts'] >= MIN_POSTS) PHP:
Here is the file which i am testing: www.mfa101.com/test.php I have edited that line, and guests can still download, as you can see. It is in the root directory of vBulletin. Thanks for all the help mate, I tryed to add more rep but.. "You need you spread more rep around before giving it to nico_swd again" Rob