download scripts for server

Discussion in 'OT Technology' started by StoneCold, Jan 25, 2005.

  1. StoneCold

    StoneCold New Member

    Joined:
    Jun 12, 2004
    Messages:
    3,108
    Likes Received:
    0
    Location:
    Yay Area
    does anyone have an easy to install script for limiting the number of downloads on a certain file? i tried trickle download manager but dont understand how to set it up. i am using dreamhost , it has SQL or whatever it is. thanks.
     
  2. red89gt

    red89gt OT Supporter

    Joined:
    Jun 1, 2004
    Messages:
    1,350
    Likes Received:
    0
    Location:
    Ladner BC Canada
    I use trickle. Its the only type of program like that I know of.. As for setting it up, its not that hard, just takes some time to read through the script to figure out what does what and read the directions.
     
  3. StoneCold

    StoneCold New Member

    Joined:
    Jun 12, 2004
    Messages:
    3,108
    Likes Received:
    0
    Location:
    Yay Area
    can you post your config file so i can use it as an example?
     
  4. red89gt

    red89gt OT Supporter

    Joined:
    Jun 1, 2004
    Messages:
    1,350
    Likes Received:
    0
    Location:
    Ladner BC Canada
    sure

    Code:
    <?
     	/*************************************************************************
     	* Code Fusion - Configuration File									   *
     	*************************************************************************/
     	
     	# Please ensure this file is completed and before launching your website.
     
     	/*************************************************************************
     	* SET DATABASE VARIBLES HERE											 *
     	**************************************************************************
         *																	    *
     	* Explanation of varibles											    *
         *																	    *
     	* $hostname_login - The hostname, or IP, on which your database is	   *
     	* located. For most servers, this can be simply set to 'locathost', but  *
     	* check with your hosting provider to be sure.						   *
         *																	    *
     	* $username_login - The login name you use to login to your database.	*
         *																	    *
     	* $password_login - The password you use to login to your database.	  *
         *																	    *
     	* $database_name - The name of the database on which you install the sql *
     	* tables onto														    *
         *																	    *
     	* If any of these variables are set incorrectly, none of the website	 *
     	* will work and will display an database page. So please ensure all	  *
     	* varibles are set accurately.										   *
         *																	    *
     	*************************************************************************/
     	 
     	$hostname_login = 'localhost';
     	$username_login = '###############';
     	$password_login = '#################';
     	$database_name = '#######_trickle';
     	
     	/*************************************************************************
     	* SET EMAIL VARIBLES HERE											    *
     	**************************************************************************
         *																	    *
     	* Explanation of varibles											    *
         *																	    *
     	* $emailnotifications - if set to 1, Trickle will email you every xx	 *
     	* downloads, as specified in $emailfrequency							 *
         *																	    *
     	* $emailfrequency - how many downloads are required to trigger an email  *
     	* notification														   *
         *																	    *
     	* $email - The email address you want the download notifications to be   *
     	* sent to. (if enabled)												  *
         *																	    *
     	* $server_email - The email address the download notification will be	*
     	* sent from. (if enabled)											    *
         *																	    *
         *																	    *
     	*************************************************************************/
     	
     	$emailnotifications = 0;
     	$emailfrequency = 2;	
     	$email = [email protected]';
     	$server_email = [email protected]';
     	
     	/*************************************************************************
     	* SET PROGRAM VARIABLES HERE										   *
     	**************************************************************************
         *																	    *
     	* Explanation of varibles											    *
         *																	    *
     	* $directory_linux - Linux path to where the files will be stored for	*
     	* download. This path should be OUTSIDE the webroot so it is impossible  *
     	* for users to download the file without going through Trickle.		  *
         *																	    *
     	* $username_ - Username for logon to the download manager			    *
         *																	    *
     	* $password_ - Password for logon to the download manager			    *
         *																	    *
     	* $display_filesize - What you want the filesizes to be displayed in the *
     	* download list table. 1 is bytes, 2 is kilobytes, 3 is megabytes, 4 is  *
     	* gigabytes, 5 is terabytes (good luck if you're serving terabyte files) *
         *																	    *
     	*************************************************************************/
     
     	$directory_linux = '/home/bumpix/external/';
     
     	$username_ = '######';
     	$password_ = '######';
     	$display_filesize = 3;
     
     
     
     
     
     
     
     
     
     	/*************************************************************************
     	* END OF USER-CONFIGURABLE SECTION									   *
     	*************************************************************************/
     
     	/*************************************************************************
     	* Make database connection and select the database					   *
     	*************************************************************************/
     	
     	$dbconnection = @mysql_connect($hostname_login, $username_login, $password_login);
     	$selectdb = @mysql_select_db($database_name);
     	
     	/*************************************************************************
     	* Fail if connection to databse fails or cannot select the database	  *
     	*************************************************************************/
     	
     	if (! $dbconnection) {
     		require('mysqlerror.php');
     		die();
     	}
     	if (! $selectdb) {
     		require('mysqlerror.php');
     		die();
     	}
     	
     	/*************************************************************************
     	* AUTOMATED TASKS													    *
     	*************************************************************************/
     	
     	exec("ls $directory_linux", $files_in_dir);
     	$result['checkfiles'] = @mysql_query("select filename from download_list");
     	
     	# See if any files that are in the database are deleted
     	for($ctr = 0; $ctr < @mysql_num_rows($result['checkfiles']); $ctr++) {
     		$record['checkfiles'] = @mysql_fetch_object($result['checkfiles']);
     		if(! in_array($record['checkfiles']->filename, $files_in_dir))
     		    $result['checkfiles'] = @mysql_query("delete from download_list where filename = '" . $record['checkfiles']->filename . "'");
     	}
     	# END
     	
     	# If filename isnt in database, add it
     	for($ctr = 0; $ctr < count($files_in_dir); $ctr++) {
     		$result['checkfiles'] = @mysql_query("select * from download_list where filename = '" . $files_in_dir[$ctr] . "'");
     		if(@mysql_num_rows($result['checkfiles']) < 1)
     		    $result['checkfiles'] = @mysql_query("insert into download_list ( filename ) values ( '" . $files_in_dir[$ctr] . "' )");
     	}
     	# END
     	
     	# Update time intervals for the clicks per hour
     	$time_hour = (time() - 3600);
     	$result['auto'] = @mysql_query("select * from download_list where time < $time_hour");
     	for($ctr = 0; $ctr < @mysql_num_rows($result['auto']); $ctr++) {
     		$record['auto'] = @mysql_fetch_object($result['auto']);
     		$result['update'] = @mysql_query("update download_list set `time` = '" . time() . "', `clicks` = 0 where `id` = '" . $record['auto']->id . "'");
     	}
     	#END
     ?>
     
  5. StoneCold

    StoneCold New Member

    Joined:
    Jun 12, 2004
    Messages:
    3,108
    Likes Received:
    0
    Location:
    Yay Area
    strange.. my cgi file looks nothing like that. where did you download the trickle download manager?
     
  6. StoneCold

    StoneCold New Member

    Joined:
    Jun 12, 2004
    Messages:
    3,108
    Likes Received:
    0
    Location:
    Yay Area
    nevermind i opened the wrong file =/
     
  7. StoneCold

    StoneCold New Member

    Joined:
    Jun 12, 2004
    Messages:
    3,108
    Likes Received:
    0
    Location:
    Yay Area
    how do i see the "linux path" to a folder is on a ftp?
     
  8. StoneCold

    StoneCold New Member

    Joined:
    Jun 12, 2004
    Messages:
    3,108
    Likes Received:
    0
    Location:
    Yay Area
    well i was able to login to trickle download manager @ index.php but i cannot see any files listed. i am using dreamhost and i've tried /home/external/, /external/ , everything..
     
  9. red89gt

    red89gt OT Supporter

    Joined:
    Jun 1, 2004
    Messages:
    1,350
    Likes Received:
    0
    Location:
    Ladner BC Canada
    did you creat a directory called "external" ? you have to made one (you can call it whatever you like as long as you change it in the config file)

    [​IMG]
     

Share This Page