Results 1 to 11 of 11

 

Thread: looking 4 a php script that edits selected pages of my site

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Mar 2006
    Location
    Preston
    Posts
    243
    Thanks
    6
    Thanked 0 Times in 0 Posts


    Hi the title dont explain it 2 well so here goes:

    i am currently converting my site to php so i can use phpincludes, and have done that ok, the next stage was to make a admin login script which i have done and that works perfect and so leaving me with wanting:

    a script that when i login to my adminarea, a list of all the php include files are shown (or maybe all my php files that make up my site) and i can select a file and then edit it on the fly without having to upload my changes everytime.

    thanks in advance
    Free Sim cards - all UK networks./Cheapest Wii Console for XMAS 2010

  2. #2
    In need of a mentor!

    Status
    Offline
    Join Date
    Mar 2006
    Posts
    297
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's not impossible to do, but a fair amount of unnecessary work I would have thought:

    Anyway you could create a script to read the directory and search for .php files - listing them should be easy enough, then change the attributes of any file you select with the chmod() command this would allow you to read and write to the file, read the contents into a Textarea (fgets() )and then write them back to the file upon editing.

    As I said above a fair amount of work for what I would have thought is little gain, but heyho

    Mark.

  3. #3
    Registered User

    Status
    Offline
    Join Date
    Mar 2006
    Location
    Preston
    Posts
    243
    Thanks
    6
    Thanked 0 Times in 0 Posts
    cheers mate il give it a whirl, but if anybody can write me s acript to do this then name me a price!!!
    Free Sim cards - all UK networks./Cheapest Wii Console for XMAS 2010

  4. #4
    Registered User

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Gillingham
    Posts
    510
    Thanks
    0
    Thanked 4 Times in 1 Post
    Just change the $path to your files directory
    PHP Code:
    <?php 
    $path
    ="your/path/to/files/";
    $dp=opendir($path);
    while(
    $file=readdir($dp)){
    if (
    stristr($file,".php")){
    $filearray[]=$file;
    }
    }
    closedir($dp);
    if(
    $_POST['Submit']=="Get File"){
    $filename=$_POST['selectfile'];
    }
    if(
    $_POST['Submit']=="Submit"){
    $fp=fopen($path.$_POST['filename'],"w");
    fwrite($fp,$_POST['data']);
    fclose($fp);
    }
    ?>
    <form action="" method="post" name="fileform">
    <select name="selectfile">
    <?php 
    foreach ($filearray as $key=>$value){
    ?>
    <option <?php if($filename==$value) echo " selected='selected'"?>><?php echo $value?></option>
    <?php ?>
    </select>
    <input name="Submit" type="submit" value="Get File" />
    </form>
    <?php

    if ($filename){?>
    <form method="post" name="editform"> 
    <textarea name="data" cols="100" rows="20"><?php echo(file_get_contents($path.$filename))?></textarea><br />
    <input name="filename" type="hidden" value="<?php echo $filename ?>" />
    <input name="Submit" type="submit" value="Submit" />
    </form>
    <?php }?>
    Quote Originally Posted by SIMONR85 View Post
    if anybody can write me script to do this then name me a price!!!
    £50
    They came for my 404 and I said nothing

  5. #5
    The New 'Arfur Daley

    Status
    Offline
    Join Date
    Mar 2004
    Location
    Kent UK
    Posts
    3,642
    Thanks
    123
    Thanked 126 Times in 91 Posts
    Bob you're a Bandit.
    Flambi Media Limited - USA/UK/EU Affiliate Management Expertise

  6. #6
    Registered User

    Status
    Offline
    Join Date
    Mar 2006
    Location
    Preston
    Posts
    243
    Thanks
    6
    Thanked 0 Times in 0 Posts
    cheers donk that script is nearly perfect for what i want but it puts these (\\\) in every time i save the file, so if i save twice i get (\\\\\\)

    heres what i mean

    <my original code>

    <a class="navitab" href="index.php">Welcome</a><span class="hide"> | </span>
    <a class="navitab" href="index2.php">Bio</a><span class="hide"> | </span>
    <a class="navitab" href="#">Discography</a><span class="hide"> | </span>
    <a class="navitab" href="#">Downloads</a><span class="hide"> | </span>
    <a class="navitab" href="#">Photos</a><span class="hide"> | </span>
    <a class="navitab" href="#">Tour</a><span class="hide"> | </span>
    <a class="navitab" href="#">Merchandise</a><span class="hide"> | </span>




    <after saving>did this:


    <a class="\\\navitab\\\" href="\\\index.php\\\">Welcome</a><span class=\\\"hide\\\"> | </span>
    <a class="\\\navitab\\\" href="\\\index2.php\\\">Bio</a><span class=\\\"hide\\\"> | </span>
    <a class="\\\navitab\\\" href="#\\\\\\\">Discography</a><span class=\\\\\\\"hide\\\"> | </span>
    <a class=\\\\\\\"navitab\\\\\\\" href=\\\\\\\"#\\\\\\\">Downloads</a><span class=\\\\\\\"hide\\\\\\\"> | </span>
    <a class=\\\\\\\"navitab\\\\\\\" href=\\\\\\\"#\\\\\\\">Photos</a><span class=\\\\\\\"hide\\\\\\\"> | </span>
    <a class=\\\\\\\"navitab\\\\\\\" href=\\\\\\\"#\\\\\\\">Tour</a><span class=\\\\\\\"hide\\\\\\\"> | </span>
    <a class=\\\\\\\"navitab\\\\\\\" href=\\\\\\\"#\\\\\\\">Merchandise</a><span class=\\\\\\\"hide\\\\\\\"> | </span>

    can you see the problem?
    Free Sim cards - all UK networks./Cheapest Wii Console for XMAS 2010

  7. #7
    Keith's Avatar
    Moderator

    Status
    Offline
    Join Date
    Aug 2003
    Location
    Richmond North Yorkshire
    Posts
    2,540
    Thanks
    172
    Thanked 119 Times in 83 Posts
    looks like you need to add the strip slashes function somewhere in your code http://uk.php.net/stripslashes
    Keith ~ My Blog general ramblings. Internet Marketing Blogs UK all the blogs together in one place (pm for inclusion)

  8. #8
    Registered User

    Status
    Offline
    Join Date
    Mar 2006
    Location
    Preston
    Posts
    243
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Keith View Post
    looks like you need to add the strip slashes function somewhere in your code http://uk.php.net/stripslashes
    Will it matter where abouts in the code?
    Free Sim cards - all UK networks./Cheapest Wii Console for XMAS 2010

  9. #9
    Registered User

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Gillingham
    Posts
    510
    Thanks
    0
    Thanked 4 Times in 1 Post
    The problem occurs because your server had "magic_quotes_gpc = on" and mine "magic_quotes_gpc = off"

    Just add stripslashes in the line:

    PHP Code:
    fwrite($fp,stripslashes($_POST['data'])); 
    Regards
    They came for my 404 and I said nothing

  10. #10
    Registered User

    Status
    Offline
    Join Date
    Mar 2006
    Location
    Preston
    Posts
    243
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Donk, u r a star,do you have paypal? if so can i buy you a drink or 2???
    Free Sim cards - all UK networks./Cheapest Wii Console for XMAS 2010

  11. #11
    Registered User

    Status
    Offline
    Join Date
    Feb 2006
    Location
    Gillingham
    Posts
    510
    Thanks
    0
    Thanked 4 Times in 1 Post
    Quote Originally Posted by SIMONR85 View Post
    Donk, u r a star,do you have paypal? if so can i buy you a drink or 2???
    pm sent.

    I've modified the code for use of one of my customer using the TinyMCE wysiwyg text editor.

    To view /play/download go to my testsite and use username testing and password qwerty
    They came for my 404 and I said nothing



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 23-01-07, 12:48 AM
  2. 67 Datafeed website scripts
    By Leeky in forum Programming
    Replies: 0
    Last Post: 28-09-06, 06:56 PM
  3. ARELIS 3 Link Popularity Software
    By Qui Gon Jinn in forum Media Coverage & PR Strategy
    Replies: 4
    Last Post: 05-03-03, 06:34 AM
  4. Found a decent PHP site at last!
    By lowndsy in forum Programming
    Replies: 0
    Last Post: 20-02-03, 10:25 PM
  5. Replies: 1
    Last Post: 16-02-03, 05:36 AM

Bookmarks

Posting Permissions

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

Content Relevant URLs by vBSEO 3.5.0 RC2