1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Upload THEN unzip xenforo folder (installation)

Discussion in 'Tips and Guides [Archive]' started by Marc, May 12, 2011.

  1. Marc

    Marc Well-Known Member

    Thought I would post this up here as it is something that I have not long since started doing. I have seen a fair few people do this (myself included). You unzip the package you download from the customer area, and then upload the files from the upload folder, but it takes ages.

    So instead, upload the zip file into the folder you wish to use. Then you need to create a phpfile named unzipxen.php with the following content:

    PHP:
    <?php

    $filename 
    escapeshellarg (dirname(__FILE__)."/YOUR_ZIP_FILE_NAME_HERE.zip");
    $destination_folder escapeshellarg(dirname(__FILE__));

    echo 
    $filename;
    echo 
    "<br />";
    echo 
    $destination_folder;
    echo 
    shell_exec ("unzip -ou $filename -d $destination_folder");

    ?>
    The upload this file to the same folder. Then go to www.yourserver.com/thefolder/unzipxen.php and it will unzip the contents of the zip file for you. All you need to do now is move the stuff out of the upload folder, which you can do on ftp in most ftp clients :)

    PLEASE NOTE: will only work if it is not in safe mode. And please ensure you delete this file and the zip when you have unpacked.
     
  2. EQnoble

    EQnoble Well-Known Member

    Interesting...I would have not even thought of this, I really just assumed this would have to be done from CLI. Thanks for sharing
     
  3. ragtek

    ragtek Guest

    It will only work, if you're allowed to run shell_exec

    BUT AFAIK most of the hosters don't allow this^^

    And if you're doing it from the CLI, then you could create a small shellscript to unzip, create a backup from the old files and owerwrite the old files automatic;)
     
    Marc and EQnoble like this.
  4. EQnoble

    EQnoble Well-Known Member

    As long as you have root access to your machine you can change this ...correct?

    Do you have this documented?...If not I would love to see a link to a site displaying this or the usage behind it (shellscript to unzip).
     
  5. Marc

    Marc Well-Known Member

    Would also be intereted in what other methods there are. I have a dedicated box for my server so havent had the problem of not having access to run shell_exec.
     
    EQnoble likes this.
  6. Rudy

    Rudy Well-Known Member

    At some hosts, unless PHP runs under your own user ID (using suEXEC or cgiwrap on our host, as one example, where the php5.cgi can be run under our user ID), it may write the files as user "nobody" which could be problematic. This script would not work as is at the host I use unless I temporarily enabled suEXEC for my entire site or, at least, the XF directory in order to install the files. Fortunately, two lines in htaccess are all I need to activate it.

    Command line is still preferred (it's all I use--much faster and safer), but in the right circumstances, this script is a handy tool to have on hand.
     
  7. Wuebit

    Wuebit Well-Known Member

    This would take me longer sadly am sure this would of done great 10 years ago when net speed sucked
     
  8. Sniper

    Sniper Active Member

    You could use something like http://www.php.net/manual/en/function.ziparchive-extractto.php instead but not sure if its one of the default PHP extensions, if not I'm sure the host would install it...

    @Vodkaholic even with high speed connections, its faster to upload just one file compared to uploading 1000 files
     
  9. estranged

    estranged Well-Known Member

    I upload the zip file to my ftp space and then unzip it through shell via unzip command, or just click extract in the cpanel file manager and extract the zip, overwriting my xenforo folder.

    I don't understand why would anyone need this?
     
    sylwester likes this.
  10. Rudy

    Rudy Well-Known Member

    Some hosts don't even have a command line shell. I had one or two hosts for clients I had like that, and they were difficult to work with (the hosting account, not the client). I personally will never use a host that doesn't at the bare minimum offer an SSH command line shell and SFTP. I do so much via command line that I can't imagine trying to work with a server without having that kind of access.
     
  11. estranged

    estranged Well-Known Member

    Yes, most shared hosting companies don't allow shell access for security reasons (which I agree) but why would any host disable shell access but enable shell_exec? It is highly unlikely.

    If you have root access you already don't need this script. Just use the unzip command.

    If you don't have shell access, you probably have a hosting control panel. All control panels I have seen have a file manager feature in which you can extract zip files. Here's an example from cpanel.

    Capture.PNG
    If you don't have shell access, and if you don't have a control panel either, then this script may be useful (if shell_exec is enabled) but I can't imagine a hosting account which doesn't have at least one of them.
     
  12. Marc

    Marc Well-Known Member

    Not sure how it would be quicker to log into your cpanel, or log into shell than it would be to upload one php file when you are already uploading the zip anyway. Thats the reason I do it to be honest, as its quicker than me messing about logging into shell expecially since logging into shell isn't something I do very often and I always keep this file in the same directory I download the zip to from here.

    Dont get me wrong, I know there are plenty of other

    You obviously havent used ADSL in the UK lol
     
    EQnoble and Vodkaholic like this.
  13. Wuebit

    Wuebit Well-Known Member

    Good point :p I withdraw my comment :)
     
    EQnoble likes this.

Share This Page