Close

Results 1 to 3 of 3
  1. #1
    DF Super Moderator
    DejaVu's Avatar
    Join Date
    Nov 2005
    Location
    Essex
    Posts
    9,107
    Thanks
    1,836
    Thanked:        4,004
    Karma Level
    954

    Help Updating a localhost directory using PHP.

    Trying to implement an automatic update system for MediaFrontPage (from Github) using PHP.
    So far it downloads a Zip file called Update.zip and extracts it to /update

    http://localhost/update

    In this folder is the latest commit from Github for MediaFrontPage. From here we are trying to move all the folders from there to the root folder recursively but the problem is to do with Permissions (although all files are chmodded to 777 on first install).

    Here is the update.php so far.

    https://raw.github.com/DejaVu77/mediafrontpage/master/update.php

    My PHP Skills are crap and the fella that's made this update script is in the process of learning and has done a great job so far, but it's one of those weird problems we cannot solve.
    We cannot use any server side (shell_exec) because the program is cross platform (or so I understand it).

    Has anyone got any suggestions as to how we can edit this update.php file to ensure it overwrites all the files in the root directory without moaning about permissions?

    Or better still, the ability to edit the file so it moves the files or folder to the destination without the CHMOD errors.

    Here's the script it falls over at -
    function moveDownload($src,$dst){
    $dir = opendir($src);
    while(false !== ($file = readdir($dir))){
    if (($file != '.') && ($file != '..') && ($file != 'config.ini') && ($file != 'layout.php') && ($file != 'sbpcache') && ($file !='update')){
    if (is_dir($src.'/'.$file)){
    if(file_exists($dst.'/'.$file)){
    rrmdir($dst.'/'.$file);
    }
    }
    if(@rename($src . '/' . $file, $dst . '/' . $file)){
    echo '<tr><td>'.$file.' moved successfully </td><td><font color="green">OK</font></td></tr>';
    } else {
    if(@chmod($src.'/'.$file, 0777)){
    if(@rename($src . '/' . $file, $dst . '/' . $file)){
    echo '<tr><td>'.$file.' moved successfully </td><td><font color="green">OK</font></td></tr>';
    } else {
    echo '<tr><td>Could not move file '.$file.'</td><td><font color="red">ERROR RENAME</font></td></tr>';
    }
    } else {
    echo '<tr><td>Could not move file '.$file.'</td><td><font color="red">ERROR CHMOD</font></td></tr>';
    }
    }
    }
    }
    closedir($dir);
    }
    Had to quote the code as CODE and PHP Tag kills the formatting!

    This is the visual result of what is happening at the client side -
    error.jpg
    Last edited by DejaVu; 7th August 2011 at 02:39 PM. Reason: CODE & PHP Tag kills the formatting...!!


  2. #2
    DF VIP Member blacksheep's Avatar
    Join Date
    Jun 2006
    Location
    Manchester
    Posts
    3,877
    Thanks
    87
    Thanked:        265
    Karma Level
    546

    Default Re: Updating a localhost directory using PHP.

    if it's meant to be cross platform the root dir is going to be different. Can you not just have a windows batch file and a *nix shell script that is part of the package and does the lifting for you?

  3. #3
    DF Super Moderator
    DejaVu's Avatar
    Join Date
    Nov 2005
    Location
    Essex
    Posts
    9,107
    Thanks
    1,836
    Thanked:        4,004
    Karma Level
    954

    Default Re: Updating a localhost directory using PHP.

    It is cross platform, but everything it does so far is purely via PHP.

    Although I think the problem has been rectified (by a lucky mistake), I will check the changes tomorrow.


Similar Threads

  1. "F" directory
    By McQueen in forum Microsoft Consoles
    Replies: 12
    Last Post: 31st October 2002, 05:32 PM
  2. Replies: 5
    Last Post: 22nd October 2002, 01:13 AM
  3. Panasonic Digibox constantly updating
    By Captain Jack in forum Digital Satellite TV
    Replies: 5
    Last Post: 10th October 2002, 11:32 PM
  4. AR2 Dongle Updating or something?
    By Billy_Wiz in forum Sony Consoles
    Replies: 2
    Last Post: 19th September 2002, 11:10 AM
  5. Windows XP SP1 – Updating Tips ‘n’ Tricks
    By station420 in forum PC Hardware
    Replies: 3
    Last Post: 6th September 2002, 08:49 AM

Social Networking 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
  •