Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-18-2010, 09:33 AM   PM User | #1
sabak
New to the CF scene

 
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
sabak is an unknown quantity at this point
Question Import and edit file using php

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
sabak is offline   Reply With Quote
Old 11-18-2010, 12:32 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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.


.
mlseim is offline   Reply With Quote
Old 11-18-2010, 01:11 PM   PM User | #3
sabak
New to the CF scene

 
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
sabak is an unknown quantity at this point
Quote:
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?

Quote:
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

Quote:
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.
sabak is offline   Reply With Quote
Old 11-18-2010, 02:22 PM   PM User | #4
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Sorry ... I misunderstood the first post.

I'll let someone else help you out.
mlseim is offline   Reply With Quote
Old 11-23-2010, 03:57 AM   PM User | #5
getbestproduct
Banned

 
Join Date: Aug 2010
Location: everywhere
Posts: 63
Thanks: 2
Thanked 3 Times in 3 Posts
getbestproduct is an unknown quantity at this point
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.
Code:
<?php
  $myfile = 'index.php'
  $file_contents = file_get_contents($myfile);
?>
<textarea name="file_edit"><?php echo $file_contents; ?></textarea>
getbestproduct is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:27 AM.


Advertisement
Log in to turn off these ads.