Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 31st, 2004, 05:51 PM
movEAX_444's Avatar
movEAX_444 movEAX_444 is offline
Cast down
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Sweden
Posts: 321 movEAX_444 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 56 m 35 sec
Reputation Power: 6
Anti-Leech CGI C script, Is this okay? How do I set default file name?

This will eventually be used for audio files when it's done. I do not want people to link to audio files on a site.

Right now it works (I am trying it with image files) but is there anything seriously wrong with it? I mean is there a way for the user to get the path to the file?
Code:
#include <stdio.h> 

int main(void) { 
	FILE *fp; 
	int i;
	long len; 

	/* First check where the user came from ... etc */ 
	
	/* Check id to see what file the user 
	   requested and send it back to the 
	   client */ 
	fp=fopen("abc.jpeg", "rb"); 
	if (0==fp) {
		fprintf(stderr, "Error opening file!\n"); 
		return 1; 
	}

	fseek(fp, 0, SEEK_END); 
	len=ftell(fp); 
/*	printf("Filesize: %ld\n", len); */ 
	rewind(fp); 


	printf("Content-type:image/jpeg\xC\xA\n"); 

	for (i=0; i<len; ++i)
		putchar(fgetc(fp)); 

	fclose(fp); 
	return 0; 
} 


Two things: where would I store the files so that the program can read them but not the user? I *can* put them in a hard-to-guess named dir but is there a real fix?

and if possible, how do I set the default download name? So if the user does right click > save target as.. it displays the correct filename.

Last edited by movEAX_444 : March 31st, 2004 at 06:28 PM.

Reply With Quote
  #2  
Old April 2nd, 2004, 07:45 AM
movEAX_444's Avatar
movEAX_444 movEAX_444 is offline
Cast down
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Sweden
Posts: 321 movEAX_444 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 56 m 35 sec
Reputation Power: 6
Alright, HTTP_REFERER is useless, it can easily be spoofed and sometimes it is not set.

How would I check where the user is coming from or just if he came from another page on the same server? or just a previous page?

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Anti-Leech CGI C script, Is this okay? How do I set default file name?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway