Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    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.


    .

  • #3
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Sorry ... I misunderstood the first post.

    I'll let someone else help you out.

  • #5
    Banned
    Join Date
    Aug 2010
    Location
    everywhere
    Posts
    63
    Thanks
    2
    Thanked 3 Times in 3 Posts
    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •