1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Submit page from skelenton

Discussion in 'PHP' started by paul_so40, Mar 15, 2009.

  1. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #21
    I think this is what he was asking for : (reusing Vooler's code from above)

    
    <?php
        if(empty($_POST)) {
            ?>
            <form method="post">
               File Name <input type="text" name="name"><br>
                Page Title <input type="text" name="title"><br>
                Content <input type="text" name="content"><br>
                <input type="submit" value="Create">
            </form>
    <?php
            die();
        }
    
    $name = $_POST['name'];
    $title = $_POST['title'];
    $content = $_POST['content'];
    
    $sanitized_name = preg_replace('/[^0-9a-z\.\_\-]/i','',$name);
    if ($sanitized_name == $name) {
      
            $data = file_get_contents("templates/file1.html");
            if(get_magic_quotes_gpc())
                $data = stripslashes($data);
            $data = str_replace("{REPLACE_TITLE}",$title,$data);			
            $data = str_replace("{REPLACE_DATA}",$content,$data);
           
            write_file("output/$name.html",$data);
    
    
    
    } else {
      echo "Filename problems.  Try ".$sanitized_name;
      exit;
    }  
    
        function write_file($filename,$data) {
            $f = fopen($filename,"w");
            fwrite($f,$data);
            fclose($f);
        }
    ?>
    
    PHP:
    requires one change to the template file file1.html :
    
    <html>
    <head>
    <title>{REPLACE_TITLE}</title>
    </head>
    <body>
          <b> {REPLACE_DATA} </b>
    </body>
    </html>
    
    PHP:
    Should be a basic page creator from a template. Took the code for the filename check from here :
    http://www.webmaster-talk.com/php-forum/119541-check-if-enterd-name-valid-filename.html
     
    shallowink, Mar 17, 2009 IP
  2. paul_so40

    paul_so40 Peon

    Messages:
    119
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #22
    ok so basicaly, imagine it as a artical submitting script.

    and there being 2 forms, the 1st one is the title of the artical, so text inside this gets submitted to being the title of the page.

    Then the second box becomes the artical, and is submitted in the center of the page
    allong with it at the end of the page goes the author and the text displayed is Author +
    $vbulletin->userinfo['username']
    PHP:
    The page will then be created under the dir, as form1 artical tittle

    dose this make sence?

    also if it could be made to to write over existing files it would be good.
     
    paul_so40, Mar 17, 2009 IP
  3. paul_so40

    paul_so40 Peon

    Messages:
    119
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #23
    any one know what the code would be for this? BTW i am learning allot from this
     
    paul_so40, Mar 18, 2009 IP