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 4 of 4
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    29
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Question I need a php Class to Edit php files

    I need a php class to edit one php file (english.php) through textarea.

    I failed to find that kind of classes. can you help me please ?

    I think any class to edit flat txt file are fine.

    thanks

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You don't need a class for this. Simple functions will allow you to do this. Here is a very basic example. You need to make it more secure as well as put it in a password protected area.
    PHP Code:
    <?php
    $contents 
    '';
    if(isset(
    $_POST['submit']) && $_POST['submit'] == 'Edit')
    {
        if(
    $_POST['contents'] != '')
        {
            
    $contents $_POST['contents'];
        }
        
    $newfp fopen('english.php','w+');
        
    fwrite($newfp,stripslashes($contents));
        
    fclose($newfp);
    }
    $fp file_get_contents('english.php');
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <textarea cols="40" rows="10" name="contents"><?php echo $fp?></textarea>
    <input type="submit" name="submit" value="Edit" />
    <?php echo  ?>
    </form>
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    Dooq (03-04-2008)

  • #3
    New Coder
    Join Date
    May 2006
    Posts
    29
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Question

    Quote Originally Posted by _Aerospace_Eng_ View Post
    You don't need a class for this. Simple functions will allow you to do this. Here is a very basic example. You need to make it more secure as well as put it in a password protected area.
    PHP Code:
    <?php
    $contents 
    '';
    if(isset(
    $_POST['submit']) && $_POST['submit'] == 'Edit')
    {
        if(
    $_POST['contents'] != '')
        {
            
    $contents $_POST['contents'];
        }
        
    $newfp fopen('english.php','w+');
        
    fwrite($newfp,stripslashes($contents));
        
    fclose($newfp);
    }
    $fp file_get_contents('english.php');
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <textarea cols="40" rows="10" name="contents"><?php echo $fp?></textarea>
    <input type="submit" name="submit" value="Edit" />
    <?php echo  ?>
    </form>
    When I did this, I lost the php layout.

    for example the below code :
    PHP Code:
    <?php

    echo 'foo';

    print 
    "test";


    ?>
    will be saved as :
    PHP Code:
    <?phprnrnecho foo;rnrnprint "test\\";rnrnrn?>
    how can I solve this problem ?

  • #4
    New Coder
    Join Date
    May 2006
    Posts
    29
    Thanks
    10
    Thanked 0 Times in 0 Posts
    problem solved


  •  

    Posting Permissions

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