Updating your WEBAPP using PHP Functions – uploadapp program

Introduction:

This app download, extract the gunzip, backup the given config folder (single folder only) and replace the existing app file with updated files.

The app is tested on updating wordpress files. You can use if for update of owncloud, piwik, or modify it to upload files to your host server from your client computer. It make use of cURL and phar class of PHP. It works for gunzip update files only. For zip files, you would need to modify code of extr.php.

Main Code:

Important code for this app is:

  1. downloading file to host server
  2. extracting the gunzip
  3. and moving the backup and update files

PHP code for uploading a gunzip file to your host server with progress bar javascript:

PHP code for extracting gunzip file:

PHP code for moving and backup of folder:

 

Installation:

  1.  Download the app from http://enggprog.com/Download/Projects/upload/uploadapp.zip and extract on your computer.
  2.  Edit config.php and change following variables:
    • $remoteFile = url of download package.
    • $webpath = full absolute webpath of the app including the folder.
    • $dstwebpath = full absolute webpath of the owncloud/req app including the folder. Files will be extracted here.
    • $srcfoldername = extracted files will be in this folder. It shall be the name of root folder of update package.
    • $dstfoldername = extracted files will be moved to this folder. This folder must exist on your server.
    • $cfgfolder = single folder (usually config folder) that is inside $dstfoldername folder to backup during update.
    • $cfgfolderbak = name of backup folder
    • $ctimeout = timeout of download time, increase for large files.
  3. Copy the url of index.php file of this app and paste it in your browser.

Download:

Download source code of uploadapp v0.1

Note:

  1.  Incorrect folder/file name can produce error.
  2.  Backup your full app directory before first time use.

References:

  1. stackoverflow.com
  2. php.net

Solver based on Direct Stiffness Method

DSM-SOLVER is based on Direct Stiffness Method.  Direct Stiffness Method is implementation of Finite Element Method. It is available in two flavors. One is octave/matlab while other is scilab script and distributed under GNU/GPL v2.0 license.

GNU Octave is free clone of matlab. It is fully compatible with matlab.

Scilab is an open source, cross-platform numerical computational package and a high-level, numerically oriented programming language. Scilab is alternative to matlab.

You can download the source-code of DSM-OCTAVE-SOLVER or  DSM-SCILAB-SOLVER. To understand how this script works,  read the document provided along with the source files. Consider the following example:

scilab dsm example
Example Problem

The above example can be solved in one of the two scripts explained as under:

For Octave/Matlab example, first define some input variables as:

 

To run the program, you need to update the directory to src folder, then, write following:

Note that truss2d has same code as that of frame 2d. You can get pretty accurate result for trusses by considering it as frame.

 

For SCILAB example, the input matrices and command for making var01.bin as provided in the preproc.sce file are:

To run the program, you need to update the directory to src folder, then, write following: