My User Defined PHP Functions 7.0 Stable:Yet another release. I've had to do a lot of these lately, because I'm working on other projects, and keep needing functions I haven't yet made.
MUDPF (My User Defined PHP Functions) is an opensource library of user defined PHP functions for GNU/Linux. It's published under the Comprehensible Open License (Release 1.0), a copy of which is included in the downloads. It's meant to be useful for development of Linux PHP tools. I created it to make it easier for me to re-use code within/across projects.
To make use of a function "include", "include_once", or similar the respective PHP file into your script, and then call it. Each function contains comments listing which arguments to include.
Functions:- My User Defined PHP Function 1 = Recursively find all files in a directory, and output the results to a file.
- My User Defined PHP Function 2 = Recursively find all directories in a directory, and output the results to a file.
- My User Defined PHP Function 3 = Extract specified files from a zip archive, retaining paths.
- My User Defined PHP Function 4 = Create a zip archive from specified files, retaining paths.
- My User Defined PHP Function 5 = Create a zip archive from specified files, ignoring paths.
- My User Defined PHP Function 6 = Output an error message.
- My User Defined PHP Function 7 = Create a unique directory.
- My User Defined PHP Function 8 = Return line contents from a file by line number.
- My User Defined PHP Function 9 = Return line contents from a file by line starting contents.
- My User Defined PHP Function 10 = Copy a file, and replace instances of string with string.
- My User Defined PHP Function 11 = Recursively find all files in a directory, and return the results.
- My User Defined PHP Function 12 = Recursively find all files in a directory, and return the results as an array.
- My User Defined PHP Function 13 = Recursively find all directories in a directory, and return results.
- My User Defined PHP Function 14 = Recursively find all directories in a directory, and return the results as an array.
- My User Defined PHP Function 15 = Return line contents from a file by line starting contents, but exclude starting contents and line ending.
- My User Defined PHP Function 16 = Return line contents from a file by line number, but exclude line ending.
- My User Defined PHP Function 17 = Output a file, and optionally replace instances of string with string.
Changelog:- Added My User Defined PHP Function 17.
- Updated comments in My User Defined PHP Function 10.
Downloads:Non-packaged:- ZIP:
https://mega.nz/#!ZhIG2BiK!5mVTghxAB65paSTkvmTvf360K2-Dih4NbPV7XqrL5q4Packaged:- DEB (Ubuntu 16.04 AMD64):
https://mega.nz/#!J0AylAwY!Sh5kWPWoeCNTlL2MYrpwCI53J2QGH0cXC_ELo1xLKV4- DEB (Ubuntu 16.04 AMD64):
https://www.dropbox.com/s/kh29hpk4ngdx1kz/mudpf_7.0-1.deb?dl=0Checksums:Non-packaged:ZIP:- SHA-512: ce131041e79030c460bf0bdcbfab45c4a66d58fa4ba54a7e15a3196c3738990e3dcb0f8232390be7b4e109795a41d5ea2fcc1c81d2afa0b4cad02dbb48791467
Packaged:DEB (Ubuntu 16.04 AMD64):- SHA-512: 984db5d04185edaa7d0f21de5786cb2d92e829b0b26de91de308ec570a37255d356df8458ffe4f6ac4013d4ce241af3ef346c89039fbbeb461569f5ca22af07d
Installation / Uninstallation:MUDPF is provided in both packaged and non-packaged forms. Non-packaged form is the default. Non-packaged is an archive containing the project files. You must install it, and anything it depends on, manually, using the included instructions. If a packaged form is available for your distro, it is recommended you install that, as it's typically easier/quicker.
Ubuntu 16.04 AMD64:
Caution! Please read for more information.
It is worth mentioning that this package installs to "/opt/mudpf". When uninstalling a debian package, package managers typically remove empty directories. If "/opt" is empty (it is by default), when uninstalling MUDPF, "/opt" will be removed. This is not an issue, but if for any reason you wish to avoid this, just put something in "/opt" before uninstalling MUDPF. Alternatively, you can always create a new "/opt" directory after uninstalling MUDPF.
Install:cd ~/Downloads
wget --output-document=mudpf_7.0-1.deb "https://www.dropbox.com/s/kh29hpk4ngdx1kz/mudpf_7.0-1.deb?dl=1"
sudo apt-get update
sudo apt-get install gdebi
if [[ "984db5d04185edaa7d0f21de5786cb2d92e829b0b26de91de308ec570a37255d356df8458ffe4f6ac4013d4ce241af3ef346c89039fbbeb461569f5ca22af07d" == $(sha512sum mudpf_7.0-1.deb | sed 's/ .*//g' | tr -d '\n') ]]; then echo "File is good."; else echo "File is bad."; fi
sudo gdebi mudpf_7.0-1.deb
rm mudpf_7.0-1.deb
cd ~/
Uninstall:sudo apt-get purge mudpf