LAMP How To – Open Source At Work

Only Passion Matters

Entries for the ‘Think PHP’ Category

bash: passing output from one program to another

sometimes you want to be able to pass output from one program to another, say from bash to php. There is a neat trick to do it. In php, we execute the bash script restartapache.
<?php
$command=”/usr/local/bin/restartapache {$_GET['server']}”;
exec($command, $output); foreach ($output as $v)
{ echo “$v <br/>”; }
?>
then in the bash, we write the output to a [...]

PHP: manual install of pear

Sometimes, certain php apps require certain packages to be installed via pear.
Use yum if given a choice, ie “yum install php-pear”.
If yum is not available or due to whatever reason, We need to manually install a new version from pear website.
elinks -source http://pear.php.net/go-pear | php

// follow thru the prompts. then configure the installation parameters

Below is [...]

Quick script to sort mysql database/tables based on table size

Mysql can show the table status with the row and size for each table but doesn’t do sorting. We can however store each row in an array and sort the array.
I am too lazy to write a script for it. 2 x for loops does the trick. This script is from adamyoung.net. Just run the [...]

Converting idml coordinates to pixels

As of CS4, indesign has the ability to export to idml. idml is indesign’s xml format and is very useful if you want to use it in other applications. The only complicated part is the way it calculates the coordinates. If you are interested, you can look at the official idml doc + the cookbook [...]

linux: clearing routing rules

I am used to the route command but I just realised the ip command is really good as well. Well, I am aware of it but I just didn’t use it because I am so used to the route, ifup and ifdown commands.
If for some reason, I can’t drop the interface,

ip link set [iface] up/down

is [...]