* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* applies an array to a string * * subj: string a string with insertion marks * var: string insertion mark prefix * replace: array array with replacements * * returns the string with all "applys" * * This functions applies the array replace to the string subj using * certain insertion marks. These marks use var as prefix, followed by * a sequential number. So, let's see the following example: * * echo prepareString('Hello $1, what\'s $2?', '$', * array('you', 'cool')); * * This echoes "Hello you, what's cool?". */ function prepareString($subj, $var, $replace) { $i = 0; foreach ($replace as $r) { ++$i; $subj = str_replace($var.$i, $r, $subj); } return $subj; } function ip2int($addr) { $bytes = explode('.', $addr); return pack('C*', $bytes[0], $bytes[1], $bytes[2], $bytes[3]); } ?>