Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2005
    Posts
    2
    Tokens
    0

    Default Whats wrong with this code?

    PHP Code:
    <?php

    $path 
    '../../pages/';


    // Get file
    if (!isset($_GET['file'])) { die('Invalid File'); }
    $file $_GET['file'];

    // Create file path
    $filepath $path $file;



    // Get file extension
    $ext explode('.'$file);
    $extension $ext[count($ext)-1];

    // Is this file editable or not?
    // Check if extension matches an invalid one
    $invalid = array('exe''doc''jpg''gif''');
    if (
    in_array(strtolower($file['extension']), $invalid)) {
        die(
    'Can\'t edit this file. Not suitable for editing. Please go back.');
    }

    // Form submitted?
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        
    // Check if new data has been set
        
    if (!isset($_POST['newfile'])) {
            die(
    'Please enter some new data for this file.');
        }

        
    // Write new data
        
    $f fopen($filepath'w');
        
    fwrite($f$_POST['newfile']);
        
    fclose($f);

        
    // Redirect
        
    header ('Location: index.php');
    } else {
        
    // Get file data
        
    $f fopen($filepath'r');
        
    $data fread($ffilesize($filepath));
        
    fclose($f);

        
    // Show edit form
        
    $title 'Filemanager - Edit File:' htmlentities($file);
        include (
    'header.php');
        
    ?>
        <h2>Edit File: <?php echo htmlentities($file); ?></h2>

        <form method="POST">
            <textarea name="newfile" rows="20" cols="80"><?php echo $data?></textarea>
            <br />
            <input type="submit" name="submit" value="Save File" />
        </form>


        <?php
        
    include ('footer.php');
    }

    ?>
    Thanks before hand. The Problem is that the code adds / on every " every time i open the file how can i stop this?
    Last edited by rlweb; 13-05-2007 at 05:53 PM. Reason: forgot something

  2. #2
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    stripslashes($str);
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

Posting Permissions

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