Previous Thread
Next Thread
Print Thread
Rate Thread
#101757 11/24/2000 8:12 PM
Joined: Sep 2000
Posts: 138
Em8 Offline
Member
Member
Offline
Joined: Sep 2000
Posts: 138
Instead of making the files your self is there a way to have perl do that? Like I have someone enter a name and its saved as a .txt file automaticly. How is this done?

------------------
*
***
%###*###%
->>>Em8<<<-

Sponsored Links
#101758 11/24/2000 9:09 PM
Joined: Aug 2000
Posts: 3,590
Moderator
Moderator
Offline
Joined: Aug 2000
Posts: 3,590
just write to a file. when writing or appending to a file, the file doesn't have to exist, though the directory does.

my $file_name = param('file_name'); # collected from form

open(FILEWRITE,">/path/to/file/$file_name.txt")or die "Bad file: $!";
print FILEWRITE 'content';
close(FILEWRITE)or die "Bad file: $!";

------------------
Da Wannabe Cannuck

:: Who is Andy?

#101759 11/25/2000 7:37 PM
Joined: May 2000
Posts: 243
Member
Member
Offline
Joined: May 2000
Posts: 243
You forgot some Atom911

open(FILEWRITE,">/path/to/file/$file_name.txt")or die "Bad file: $!";
print FILEWRITE 'content';
close(FILEWRITE)or die "Bad file: $!";

[Linked Image]

------------------
Powered by ZCom Bulletin Boards

#101760 11/25/2000 8:07 PM
Joined: Aug 2000
Posts: 3,590
Moderator
Moderator
Offline
Joined: Aug 2000
Posts: 3,590
My bad, fixed now [Linked Image]

I often forget those...always a pain to find out why.

------------------
Da Wannabe Cannuck

:: Who is Andy?

#101761 11/25/2000 9:40 PM
Joined: Aug 2000
Posts: 335
Member
Member
Offline
Joined: Aug 2000
Posts: 335
If this is for a CGI script, be aware that there are security issues in using user input to form file names.

Sponsored Links
#101762 11/26/2000 1:51 PM
Joined: Aug 2000
Posts: 3,590
Moderator
Moderator
Offline
Joined: Aug 2000
Posts: 3,590
Yes, Dave_L is correct. However, most these dangers can be thwarted by checking the data recieved from the user(as you should be anyway) Here would block all file names with anything but alpha-numeric characters in it:

die 'Bad characters in file name.' unless($file_name =~ /^[A-Za-z0-9]$/);

------------------
Da Wannabe Cannuck

:: Who is Andy?

#101763 11/26/2000 1:58 PM
Joined: Feb 2000
Posts: 4,625
Member
Member
Offline
Joined: Feb 2000
Posts: 4,625
You should check for even more security if your on an NT system, or even a unix system, just incase someone decides to hack you.

Code
code:
and

Code
code:

[Linked Image]

------------------

Hack Developer of the Ultimate Bulletin Board.
Due to time limitation, I do not offer support Via. E-mail or AIM. Please post on the forums.

Regards,
MasterMind

#101764 11/26/2000 2:39 PM
Joined: Aug 2000
Posts: 3,590
Moderator
Moderator
Offline
Joined: Aug 2000
Posts: 3,590
MasterMind -- The coding I had listed above would rule out both of the things that you did [Linked Image]

------------------
Da Wannabe Cannuck

:: Who is Andy?

#101765 11/26/2000 2:47 PM
Joined: Feb 2000
Posts: 4,625
Member
Member
Offline
Joined: Feb 2000
Posts: 4,625
Sorry, i must be very tired i didn't even see it. ::sigh::

------------------

Hack Developer of the Ultimate Bulletin Board.
Due to time limitation, I do not offer support Via. E-mail or AIM. Please post on the forums.

Regards,
MasterMind

#101766 11/26/2000 3:06 PM
Joined: Sep 2000
Posts: 138
Em8 Offline
Member
Member
Offline
Joined: Sep 2000
Posts: 138
Mabey some day I'll be as good as Greg or Andy

------------------
*
***
%###*###%
->>>Em8<<<-

Sponsored Links
#101767 11/26/2000 4:00 PM
Joined: Feb 2000
Posts: 4,625
Member
Member
Offline
Joined: Feb 2000
Posts: 4,625
Well, I am not as good as andy, but i'll tell ya, it takes plenty of practice. I need to thank Mark, Andy and cal for their help...and constant putting up with me. [Linked Image]

------------------

Hack Developer of the Ultimate Bulletin Board.
Due to time limitation, I do not offer support Via. E-mail or AIM. Please post on the forums.

Regards,
MasterMind

#101768 11/26/2000 8:40 PM
Joined: Aug 2000
Posts: 3,590
Moderator
Moderator
Offline
Joined: Aug 2000
Posts: 3,590
Yes, Mark definitely needs to be thanked for many - rather most - of the things I have learned, and the breaking of bad habits and the picking up of new good ones [Linked Image]

------------------
Da Wannabe Cannuck

:: Who is Andy?

#101769 11/26/2000 8:46 PM
Joined: Feb 2000
Posts: 4,625
Member
Member
Offline
Joined: Feb 2000
Posts: 4,625
Here here to that!

------------------

Hack Developer of the Ultimate Bulletin Board.
Due to time limitation, I do not offer support Via. E-mail or AIM. Please post on the forums.

Regards,
MasterMind

#101770 11/26/2000 8:52 PM
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
P.I.T.A. / Programmer
Offline
Joined: Sep 2000
Posts: 755
LOL, thx guys [Linked Image]

To keep up with tradition though, andy...you're about 99% of the way correct with:

die 'Bad characters in file name.' unless($file_name =~ /^[A-Za-z0-9]$/);

however ya made one BIIIIIG blunder. That regex only allows for a one character filename [Linked Image]

and a smaller blunder... it doesn't allow for '.', _ and - which are perfectly valid in filenames.

I would use full on taint checking:

die 'Bad characters in file name.' unless $file_name =~ /^([w.-]+)$/;
$file_name = $1;

--mark

This message has been edited by Mark Badolato on November 26, 2000 at 07:53 PM


"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
#101771 11/26/2000 8:54 PM
Joined: Feb 2000
Posts: 4,625
Member
Member
Offline
Joined: Feb 2000
Posts: 4,625
Your welcome mark.

[Linked Image]

------------------

Hack Developer of the Ultimate Bulletin Board.
Due to time limitation, I do not offer support Via. E-mail or AIM. Please post on the forums.

Regards,
MasterMind

#101772 11/26/2000 9:00 PM
Joined: Aug 2000
Posts: 3,590
Moderator
Moderator
Offline
Joined: Aug 2000
Posts: 3,590
hehe, I can't believe I forgot the plus in the regex.

------------------
Da Wannabe Cannuck

:: Who is Andy?


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)