Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Download Limiting Script


I am looking to make a script for file downloads. Been having a large problem with web-mirroring programs soaking up huge amounts of bandwith.

the script will have to:
1.) accept input for the file's name in this form ?file=blah.zip
2.) take the user to a screen where they can click a post button to begin downloading the file
3.) after clicking that post button and before sending the file, the script will need to make sre that the user is not currently downlaoding any other files, and that the referer was indeed that same script.

this will probably prevent most spiders from sucking the bandwith and driving up the bills, but even if they don't it will slow them sown quite a bit so that the bandwith is managable.

does any one have any ideas on such a script?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Limiting Input!
I have recently started a project, and I need to limit user input. I need to make it so the user can only make 1 guess per day. It will collect all the users/guesses for one day, then at the end of the day(12 AM) I will drop all the guesses so they can start guessing again. So I just need to know how to make it so they can only make 1 guess. Code:

Limiting No. Charcters
how to limit the number of charcters when displaying something and having the ending as "..." For example displaying news articles and then a link saying Click Here For More Code:

Limiting Words
I am trying to get a list of news stories from a database and list them, limiting them to a just 100 characters, and rounding them off to the nearest whole sentance, with a Read More » link to read in full. I have written the code, but its not working. Code:

Limiting Search
I have a search result page that is meant to limit the results to 5 per page and then you click next to view the next results (and next for more results and previous for the previous page).

The problem is that when you perform the search it works fine but when you want to go to the next page nothing happens. I think the reason is that it looses the search criteria. Code:

PHP, MySQL & Limiting Access
I have a project for work, and I'm not sure how to efficiently do what I
need to do. I'm hoping someone out there can help.

Project is this: I'm creating a web-based interface where people at my
company (operators) can enter data for service calls. All data entered
is run thru one or more PHP scripts for error checking and then stored
in a MySQL database on a server here in the office.

What I'm looking to do is to limit access to certain operators so they
can only do certain functions (ex: add a service call, but not delete
one), whereas admins such as myself would have full access to
everything. Ideally, at some point in the future, we plan to roll this
interface out to our clients so they may do the same features within
their company. Obviously, they would only gain access to data related
to their company, as to protect the privacy of others.

Hierarchy would be something like this:

1. UberAdmins (such as myself)
-Have access to everything and to all commands.

2. Operators
-Have access to everything, but not all commands.

3. Our clients
-Have access to their data only, and to all commands.

4. Our clients' operators
-Have access to their data only, but not all commands.

The difficult thing is that our clients may run several businesses, so
they would have to have access to several groups. In essence, they'd
have multiple groups (their businesses) within a group (their group)
within a group (everything).

What is the easiest and most secure way to do something like this? I'm
not looking for actual code but merely suggestions. Please reply if
there is something I wasn't clear on.

Limiting Simultaneous Logins
What I am trying to do is to limit the number of simultaneous logins of each registered user. Currently each user will be authenticated against a database and a PHP session will be created for him (say $_SESSION['username']). Then we will check for this session in all pages.

Which solution do you recommend to limit the number of simultaneous logins by each user?

Limiting Text Output From DB
I have developed a simple from system that allows users to input some comments. This all works fine, however when I try to retrieve the comments I only want to display 100 characters.

I am new to PHP, but was wondering if there is a string function that will let me take the data from a table in my database and then only display 100 characters followed by "..." afterwards.

Also I have thought of a potential problem... if someone enters less than 100 characters I only want to show the amount they have entered.

Limiting Search Results
I have written a search script for my database but now I want to limit the results to ten a page and then make it possible to see the next (or previous) page. All my attempts so far have failed. Code:

Limiting Charactors Returned.
I'm echoing out table cell kept in an array using: $list['email']
It echos the user's email address. But if i had an email address that was: dwaniodwuaiobwaiubdwauibdvwaijdvwavuwavwad@dwad.com

it would strech the table. I want to limit the amount of charactors. put ...'s inbetween

Limit the output to 10 charactors.

Limiting Character Length
I have a script that pulls latest forum posts with a mysql query.  When I display the list, how do I limit the name of the topics and follow them with "..." if they are too long?  For example, the two latest posts are Hello, everyone, I am new here.  That's sixteen characters.  How would I make that display as say "Hello, Everyone, I am..."

Calculation And Limiting Decimals
I have a greater total of 61 and I score 45

$i= 61;
$y= 45;

$pct = ($i /$y) * 100;

one is tha correct Two how can i limit the number that result diplays (0.987654321 - i just want .987)

and how do i turn off this error message???

Warning: Division by zero in localhostinfo.php on line xxx

Limiting Access To Upload Area
I'm in the process of creating a Linux+Apache+PHP website with a
public area and an admin area for configuration and updates.

The What:
One of the features of the admin area is image-upload, where the
images are subsequently viewably by the general public. Currently
I've created a dedicated "pictures" directory which world-writable
into which the PHP script puts the form-uploaded images. The admin
logging in is done via a database lookup, not .htaccess directives or
OS permissions.

The How:
It seems a bit risky (is it?) to have to directory so open, is there a
way I can allow the script to move files into that directory without
making it a+w?

Limiting User Mysql Entries
I have a script i'm making which is going to be used to search for reciprocal links on different sites and I have user levels such as free, paid, ect... I want to make it so that if the person signs up as a free user they can only add like 2-3 domains to be searched for their links. How would I limit the number of domains allowed to be searched? Would I limit the number of mysql entries allowed in the table for the domains?

Limiting A Query By Number And Date
I run a hockey league and want to post my schedule for the upcoming season.  The problem is that I have 100 games in the season and I want to limit the query to 30 games on the schedule that is posted on my website.

That part was no problem for me but I also would like to have those 30 games be determined by date. So I would like the script to acquire the current date and post the next 30 games that are upcoming. I have a date field in the daatbase that is in the form YYYY-MM-DD. 

Limiting Number Of Characters In A String...
If I have a long string of text in a variable, how can I "trim" the text down to a specific number of characters?

So for example, if I have:

$string = "This is a string";

and I just want the first four characters of the string, so just "This", how would I do that?

Limiting Characters In Textarea Without Php/javascript
I want to create a textarea in which the user can input 100 characters only.he canot able to input more than 100.i want to do this with out using php/javascript.is it possible.

Limiting Results, And Display Page Numbers
How do I make it so only 50 items display per page. And if there's more than 50, it displays a link "page 2", "page 3" and so on? I know how to limit results with MySQL but how do I generate pages for the next 50 within the PHP code?

Limiting The Amount Of Text From A MySQL Call
I have the following code that pulls some information from a database and presents it (obviously), it also has a link to find out more about the presented information.

One of the feilds is called a biography, I want to limit the amount of the field "biography" that is displayed, like the first 200 characters (maybe even ending in a ...) and have the rest of the biography dislay when the person clicks on the corresponding link. Is this possible? Code:


Limiting The Amount Of Text Returned From A Query
What is the best way to display a limited amount of text returned from a MySql query?

I have a News articles table with a headline and text... I query the database and return both, but I only want to display say the first 30 words of the article text and append it with "... MORE" as a link to the complete article.

The last part is easy, it's the limiting of the number of words displayed that has me stumped.

Alphabetical Sorting... Limiting And Paginating On Next Set Of Letter
I have a query where I am getting one column (designers) in a Table, ordered alphabetically. Right now.. this query is displaying EVERY distinct result (45 in total). This result is used for a subcategory menu on a page. I need to shorten this up considerably. PHP Code:

Limiting Number Of Records Stored In Database
Is there a way I can limit the number of records that are stored in a database? I am using a PHP guestbook script for personal use and only want to save say the last 100 messages.

Limiting/Structuring Query Data Output
Let's say I have a table called "customers" which will display many many results.
What I want to be able to do is output their names in a structured table when a query is presented. For example:

Customer 1, Customer 2, Customer 3, Customer 4
Customer 5, Customer 6, Customer 7, Customer 8

... where it will always revert to the next row after every 4 results, continuing as such.

Limiting Allowed File Format For Upload...
I don't really know much about php and needed to make a web contact form for a client where the user can upload images which are then sent as an attachment with the resulting email.

I kind of cheated and bought a bit of software which creates the script for you. This works great, but I am concerned about people uploading things other than images - especially after seeing this thread:

[URL]....

Now, obviously there is a bit of script in one of the replies which addressed my issue, but I don't know enough about php to adapt it for my own script. Therefore, I was wondering if someone would be so kind as to point out where I need to make changes and what those changes would be.

I need to allow only common image files and to disallow any of the nasty stuff described in the above thread.

I have created this stripped down script with my software, which addresses the essentials of uploaded image and resulting email to which it is attached, plus a section which deals with errors, http referers and stop words for security. The actual script includes more fields, but I thought it would take up too much space!

PHP Code: .....

Question Limiting Access To A Php File / HTTP_REFERER Validation.
I'm sure there is a simple solution to this but I've looked around and can't find a answer to fit my problem. I'm a php total newb so this may seem like a stupid question.

I have a php file called out.php and what this does is simply count a click and then redirect the surfer to a defined URL based on a refrence number in my db. Example:

out.php?number=(a number)

Now my problem is I want to limit access to this to only my site so as to keep somone else from say using my out links on thier page by simple adding a link on thier site.

Ordering & Limiting Multiple Table Rows By Date
My goal is to select rows from two tables 'shoot' & 'video' and have mysql order those tables by date and limit the number of rows returned. I want to list the latest 10 rows but am uncertain how many rows from each table will be the latest. I may have more recent shoots than videos or the opposite. How can I use a single ORDER BY and LIMIT statement for both selections? Code:

Ftp Download Using Php
i need to implement a ftp download using php. i am using the ftp_get function to implement it. PHP Code:

Zip Download
please check this code i am trying to give users the ability to download zip
files

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$length);
header("Content-type: multipart/x-zip");
header('Content-Disposition: attachment; filename="'.$filename.'"');
readfile($filename);

but the zip file download and shows size 4 mb but there is no file in the
zip and it does not extract and says its corrupt i know its not corrupt because if i download the same file from ftp it works fine only downloading by using this code gives this error ...

Download Jpg
I need to see how to download a JPG directly without using zip files by example. If you click to donwload pictures you can download directly a JPG. They use PHP to do the trick, so my question is if somebody know how it can be done.

Download
I have a script that download any file to the user according to the
parameters.
I call the script like this:
download.php?file=xxx/myfile.doc&file_short=myfile.doc

My script is working fine except with N4.7
It opens the download box, but the name is download.php instead of
myfile.doc
I found the same bug with N7 on the Net. The workaround is to call the
script with "/" :
download.php/?file=xxx/myfile.doc&file_short=myfile.doc

It solves the problem with N7, but with N4.7, the only difference is with
the name. Now it is :
download_php.htm

If I specify the content type related to the file, it works fine. But I
can't do that because the file type can be anything.
It can be a word, excel or pdf file etc etc
Do you have any idea or a script to automatically set the content-type
according to the file extension ?

here is my script:
Header("Content-Type: application/octet-stream");
Header("Content-Length: ".filesize($_GET['file']));
Header("Content-Disposition: attachment; filename=".$_GET['file_short']);
readfile($_GET['file']);

Download
I need a simple php file that download all files and folders
located in the web directory, it means that with a single file in the
website, with just a click it download all files and folders.
How Can I do that?

Php 6 Where To Download It ?
I just bought the "PHP & MYSQL for dummies" book and it asks me to download php6 from www.php.net ... but when I go to downloads as described there is no php6 for download !!! The most recent version is php5.2 ...

Is php6 taken off the community again ? If not, can someone tell me where I can download it ?

Download
I'm having trouble! What i ultimately want is for each user on my site to be capped with a (maximum) 2Kb per second download transfer rate and only be able to download one file at a time.

Therefore i need to know when a user has a download in progress. So, if they try and download 2 or more files at the same time i can block them.

I don't have much idea of how to achieve this with PHP and Apache!

Can anyone point me in the right direction.

PDF Download
I'm trying to let users download various pdf documents from my site. Everything wokrs ok but when I open the pdf's that have been downloaded they are corrupted & won't open. I'm wondering if the information in the headers is incorrect, here's my code:

Php Download
I have a link to text file which is on my server. When the user clicks on the link the textfile simply displays in a new window. What i want to happen is that the file is able to be downloaded to the users machine.

I can upload with php so can i download? How do i set this up?

How Do You Force A Download?
Hello, how do I force a file to be downloaded instead of displaying it? I have PHP and HTML files that I don't want to be displayed but downloaded. How would I do this?

Download Protection
I have certain files that are to be downloaded.
Now the current system has a few usernames and passwords to access the area where these files can be downloaded from.

- I want to limit the access to this area ( better it from the existing one )
- Should i convert it to a database based user access system.
- There is a requirement that the username and the password should expire after a certain period (say 7 days ).

How can the user name passwords expiry be achieved.

Header + Download
I'm trying to figure out how to get a pdf file to download that isn't in the same directory as the download script.

The script works when I put it in the same directory

example:
http://www.mywebsite/getpdf.php?file=mypdf.pdf

but this doesn't work
http://www.mywebsite/getpdf.php?file=otherdir/mypdf.pdf

<?php
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=$file");
readfile("$file")
?>

.txt File Download - How?
I'd like to get a prompt for a .txt file download instead of displaying it in the browser. The way things are setup now is that when a link in the nav menu is click it's pointed to download.php:

Download Counter Help
I have written a php scipt to take a download path given a keyword from an MySQL database, incriment the counter by one, and then set the header to be the download URL. Everything is working well except that the counter is incrimenting by 2 each time. This problem wont happen if the header("Location....") is comented out, and it will behave like a good counter, but, ofcorse, not start the download. I have tried setting the location to be a call to another script, which istelf contains the:

if ($download_path) {
header("Location: $download_path");
exit;
}

but the problem still persists if it starts the download...

Anyone have a clue what the problem could be?

Download Stats
I have a file on my site, results.doc, anyone can link to it and download the file. Is there a way i can keep track of how many times its been downloaded? If someone can point me in the right direction and tell me what i should search for that'll be great.

Download Once Using Unique ID
I've been asked by a friend to see if I can find a solution for controlling downloads of a song from their site. They're looking to allow people who have purchased a copy of their CD to download an additional track using a unique code thats printed on the CD cover. They want to limit the number of downloads to one per ID to prevent people from just sending the URL around. I usually hunt around the net for things like this and hope to find an open source solution, but I've had no luck on this occasion so was wondering if someone could either point me in the right direction or give me some tips in setting this up on my own. I'm working on apache with all the benefits offered by cpanel.

PHP Download Problems
Well I've been talking to friends and googling all day for an answer to my problems, but noone seems to know what's up with this, and I can't find any answers on the web.

I'm trying to make a simple download.php file, which I can call from anywhere on my website, which then downloads the file specified in the id. For eg: download.php?fileid=12345. They are everywhere, so I'm sure you know what I mean.

I'm doing the method suggested in the php.net docs, and everywhere else; send headers, then use readfile. Except the browsers seem to be allergic to it.

The one that shows the problem best, is Firefox - on a 400Kb ZIP it hung on "starting" in the transfer dialog, then after about 3-5 seconds would jump to 100% and say it was complete. I later tried it on a 4Mb RAR file, and when I requested the download, it sat loading the page for about 10-20 seconds, then brought up the "save download" dialog. I clicked save, and it immediately jumped to 100% and complete. IE and Opera are both doing the same (Opera also says "Error" instead of "Finished" when it is done). I must point out that the content of the downloaded archives is absolutely fine.

In the full blown version of the script (which didn't work), I get the ID, then check the DB for it. Get the filename from the DB, and setup the transfer. For the stripped out version, I commented out all the DB stuff, so I was left with just the transfer.

I can't see anything wrong in the code, and my friend assues me the headers are fine (although the rar mime type isn't correct).

The code:

//Clean the inputs, before using them in any further code.
$cln_fid = cleantxtinput($_GET['fid']);

//Check the database for an artwork with a matching id, and a download filename that is NOT empty.
$get_file = runquery("SELECT download FROM fti_art_artwork WHERE artid = '$cln_fid' AND download!= ''");

if (mysql_num_rows($get_file) == 1) {
while($row = mysql_fetch_array($get_file, MYSQL_ASSOC)) {
$file_name = $row['download'];
}

//Get the file extension.
$ext = explode('.',$file_name);
$ext = $ext[count($ext)-1];

//Specify the mime type, depending on the file extension.
if(preg_match('/rar/i', $ext)) {
$mime = 'application/octet-stream'
} elseif(preg_match('/zip/i', $ext)) {
$mime = 'application/x-zip'
}

header('Content-Type: '.$mime);
header('Content-Disposition: attachment; filename="'.$file_name.'"');
header('Content-Length: '.filesize('files/'.$file_name));
readfile('files/'.$file_name);

} else {
//Log the error.
$level = 4;
$error = "The user '$usersess_name' requested to download the file with id '$cln_fid', except the file didn't exist, or more than one file was found.";
logdata($level,$error,&#391;');

//Display the error.
$tpl_errcode = $errcode;
$tpl_errtxt = 'The file you requested couldn't be found. If you got to this page by following a link on our website, please contact our support desk.'
$tpl_redirect = conf_baseurl.'index'.url_sess;
include('templates/default/error.tpl.php');
exit;
}

I have no idea what is wrong. If it makes a difference, it is currently operating off a Windows PHP installation for offline use only. When it goes live, it will go on to a Linux server.

My only thought, is the file is being downloaded prior to the download dialog. Any other methods of doing the same thing?

Download Monitor
I would like to create a script that can monitor what files are being downloaded from my server. Including information like, what time the download started, ended, name of file and even speed.

I am a complete Newbie to PHP and am currently running PHP-Nuke on Windows XP, with MySql and Apache.

Has anyone here come across such a script or is it possible to create such a script?

Forcing The Download Box
I have a page that generates a text file (but writes the file with
the ".csv" extension) and then I redirect the user so he can save the
file

header("Location: $my_csv_file");

However, the file appears as text in the browser and I would prefer
that the gray "Download this file" box pop up. How could I pull this
off, or is this really more dependent on client browser settings?

Download Pdfs
I'm building a site at the moment (100+ pages) which has a huge amount of PDF files. I am creating the pages using SSI which helps me maintain the pages. On all of my pages, there is a small page pulled in at the bottom, which has a link to that specifc page in PDF. Seeing as every page is 'included', I'm declaring a varibale at the top of each page like so, and then inserting that into the link below -

<? $file = "foo"?>

<a href="/pdf/<? echo $file ?>.pdf">Download PDF!</a>

This works great, although upon clicking the link I would like the user to be taken to a new page - say download.php, where instructions on downloading Acrobat viewer are, AND a link to download the file that they have just clicked on. It seems as though the variable isn't 'carried over' to the next page unfortunately. I'm not using a database, which makes it quite tricky.

Forcing Download
i want users to be able to download files from my site via a download page and id variable
eg.. download.php?file_id=24 BUT i want this to be the only way for my users to access the files, ie they shouldn't be able to type in:

http://www.mysite.com/download/myfile.zip

so ill be storing the files below the viewable area on my site. so to access the files i need a way of making the file download, i tried to look up some cleevr things to do with headers but these seem only to work if youve made a file on the server side, any ideas how i can do this ?

Download Counter?
I'm trying to create a download counter for individual files on a web
site and I'm not sure how to do this. Right now I'm using Webalizer
to just read the log files and see how many times the files I'm
interested in were downloaded. The problem is Webalizer breaks it up
by month and I want a running total. I'd also like to see the counts
without having to log in to Webalizer in the first place. Not that
logging in or adding the results is too difficult, but it would be
nice if I could just put a little number on the web site so when I go
to the site I can imediately see the download counts.

The first thing I thought of was accessing the log files via PHP and
reading the data out of there. However because the log files get
broken up, zipped, and a new one started after they reach a certain
size I'm afraid this will be too complicated and may put too much
extra strain on the server if this is done too often.

Also, what's the best way to read log files with PHP anyway?

Download Track
I have a website support some big files(200-800M) download. I want to control download. I use Php +mysql to control it to prevent other people to link and download. Because my webhost control ftp is difficult. so I use http download.
But I do not know to use php script to detect one user have finish download,I want one user download one file at one time.

Download A File Using Php
An affiliate company i work with has a feed they publish, and I'd like to download and save it as a txt file on my server.

How can I do this using php? I'm assuming I need write a small script that will get the file on their server, save it on my server (and change the extension to txt). Then I'm going to run this script via a cronjob.

Can anyone point me in the right direction to get started on this? I'm not sure which php command I need to use to grab the feed from the other server.


Copyright © 2005-08 www.BigResource.com, All rights reserved