Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> I Just Wrote A Script For A Php Text Editor!
coolcat50
post Oct 12 2007, 08:18 PM
Post #1


Super Member
*********

Group: Members
Posts: 290
Joined: 5-October 07
From: Random Places
Member No.: 51,171
Spam Patrol



Yes, I just wrote out a script for a PHP text editing program. It is very basic but I would like to be able to actually use this and update it. First, I need version 0.7 to be proofread. It will be upgraded to 0.8 after closed beta, 0.9 after open beta, 1.0 when ready.

I would love to have some people help with this project. Right now it is a simple PHP script and HTML form. Here is the current script. I would like it to be proofread.

CODE

<?php

$fileName = "$_REQUEST['name']";
$fHandle = fopen($fileName , 'w') or die("Can't write file.");
$fContent = "$_REQUEST['content']";
fwrite($fHandle , &fContent);
fclose($fHandle);
?>
<form method="post">
<input type="text" name="name" value="Filename" /><br />
<textarea cols="30" rows="50" name="content">
Text
</textarea>
</form>


Suggestions for this will be great and I would like to make this be a pretty big project. I think it can be cool and very useful for the travelling programmer or webmaster. Thank you.

P.S.: I would love to have assistants to help with updating it and testing and all of that. Thank you.
Go to the top of the page
 
+Quote Post
Stenno
post Oct 12 2007, 08:54 PM
Post #2


Newbie [Level 1]
*

Group: [HOSTED]
Posts: 21
Joined: 29-September 07
Member No.: 50,836



Ouch, this will get you hacked easily. They create a file x.php and put this in it:

for example:
CODE
<?

$fHandle = fopen($fileName , 'r+');

while (!feof ($handle)) {
    $buffer = fgets($handle, 4096);
    echo $buffer;
}

?>


They just run their script after they created it and it gives them login info from your database and so on. It's very important to built in a safety check, so you can check their code first before they can run it. They could also create a injection bug on purpose in the script:

CODE
<?

$page = $_GET['page'];
include($page);

?>


Makes them able to include every file on your server, even files that aren't in that specific map. So watch out with it wink.gif Make sure only you can run the script, so for instance make a login for it.
Go to the top of the page
 
+Quote Post
coolcat50
post Oct 12 2007, 08:57 PM
Post #3


Super Member
*********

Group: Members
Posts: 290
Joined: 5-October 07
From: Random Places
Member No.: 51,171
Spam Patrol



This is for the public. I guess i could install a member login system. Could you help me out?


Wait, couldn't I just mod the script to only save as .txt files

Such as

CODE

<?php
$fileName="$_REQUEST['fname']" . ".txt";
$fHandle=fopen($fileName , 'w') or die("Can't write file.");
$fContent="$_REQUEST['content']";
fwrite($fHandle,$fContent);
fclose($fHandle);
?>


This post has been edited by coolcat50: Oct 12 2007, 09:02 PM
Go to the top of the page
 
+Quote Post
MotU2510
post Oct 20 2007, 06:00 PM
Post #4


Newbie [Level 2]
**

Group: Members
Posts: 28
Joined: 5-October 07
Member No.: 51,172



Making it a .txt file only would make it a LOT safer. Other than that it seems fine to me.

If you did add a member login then perhaps you could add the abilty to open and edit already existing files. That would be very useful for someone who needs the ability to store and edit files on the web. I'd recommend adding a maximum file length as well, you wouldn't want someone to make a ridiculously long file which uses up all your webhost space.
Go to the top of the page
 
+Quote Post
coolcat50
post Oct 20 2007, 11:16 PM
Post #5


Super Member
*********

Group: Members
Posts: 290
Joined: 5-October 07
From: Random Places
Member No.: 51,171
Spam Patrol



Yeah good point. Prob about 100kb on a 2.5gig host
Go to the top of the page
 
+Quote Post
pop
post Oct 20 2007, 11:22 PM
Post #6


Advanced Member
*******

Group: Members
Posts: 102
Joined: 13-October 07
Member No.: 51,530



many scripts like your is availiable for download, so developing this is point less. you need to learn php much more. i download this script and i have it already, why wait for you to develop your script, and that is also bad code if what stenno said is true. learn php first, and you have time to develop project later.
Go to the top of the page
 
+Quote Post
coolcat50
post Oct 20 2007, 11:56 PM
Post #7


Super Member
*********

Group: Members
Posts: 290
Joined: 5-October 07
From: Random Places
Member No.: 51,171
Spam Patrol



Well, I do know PHP fairly well. Look at my card engine. So, don't be making generalizations like that. kk
Go to the top of the page
 
+Quote Post
MiniK
post Oct 21 2007, 12:44 AM
Post #8


Advanced Member
*******

Group: Members
Posts: 112
Joined: 29-September 07
From: United Kingdom
Member No.: 50,853



I don't understand what the script is or what it does. Could someone expand on "text editor", please?
Go to the top of the page
 
+Quote Post
Fate
post Oct 27 2007, 07:59 PM
Post #9


Newbie
*

Group: Members
Posts: 2
Joined: 27-October 07
Member No.: 52,107



QUOTE(MiniK @ Oct 21 2007, 12:44 AM) *
I don't understand what the script is or what it does. Could someone expand on "text editor", please?

Notice from jlhaslip:
*deleted acronym*

text editor: noun
A program used to.. edit text
Synonym: Notepad
Go to the top of the page