...

View Full Version : Import and edit file using php



sabak
11-18-2010, 10:33 AM
Hello Everyone..
I have a problem and i hope u will help me..

So lets start..
I need php Code wichs name will be code.php
This code.php will
1. Import file from web, from the same site.. for example index.php
2. search in file, for example it will search the word TTT
3. make correction, for example simple TTT will be TTT
3. show this index.php file from code.php with corrected TTT
4. and finally I dont want that any changes effected in index.php

so when i open code.php file it will be the index.php with TTT
and when i open original index.php file it will be with TTT

I hope its clear...
Waiting For your answers...
With best regards yours Saba

mlseim
11-18-2010, 01:32 PM
This is a very bad thing to do.
You should never open and edit a .php file

With PHP, you have a file like "index.php" that uses a database to display content.
It's that database (of text), not the actual "index.php" file that you edit.

You edit content, not code.

Here's the reason why:
What if I figure out a way to get in and edit your "index.php" file?
I could edit the PHP script to do whatever I want, such as delete your whole website.

You have to re-think your whole idea here ... or re-ask your question if you didn't ask it correctly.


.

sabak
11-18-2010, 02:11 PM
This is a very bad thing to do.
You should never open and edit a .php file
Did I ask its good or its bad?


With PHP, you have a file like "index.php" that uses a database to display content.
It's that database (of text), not the actual "index.php" file that you edit.

I think you didnot read 4 section


Here's the reason why:
What if I figure out a way to get in and edit your "index.php" file?
I could edit the PHP script to do whatever I want, such as delete your whole website.

You Cant.... I can set permissions.

mlseim
11-18-2010, 03:22 PM
Sorry ... I misunderstood the first post.

I'll let someone else help you out.

getbestproduct
11-23-2010, 04:57 AM
You can place that in a form and edit the file to your heart's content and save it as you wish using fopen,fputs and fclose.
<?php
$myfile = 'index.php'
$file_contents = file_get_contents($myfile);
?>
<textarea name="file_edit"><?php echo $file_contents; ?></textarea>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum