private static function extractPrice($pContent) { preg_match('/<meta itemprop="price" content=\'([^\']+)\'/', $pContent, $matches); $price = trim($matches[1]); trace_r($matches); // preg_match('/(€|£)/', $price, $matches); // trace_r($matches); $matches = explode(' ', $price); $devise = $matches[1]; $price = trim(str_replace($devise, '', $price)); return array("price" => str_replace(',', '.', $price) * 1, "devise" => $devise); }
/** * custom functions to aid in debugging * * @var mixed */ function trace() { $message = ''; for ($i = 0; $i < func_num_args(); $i++) { if (is_array(func_get_arg($i))) { trace_r(func_get_arg($i)); } else { $message .= func_get_arg($i); } if ($i <= func_num_args() - 2) { $message .= ' : '; } } echo "<br><b>\r\r" . $message . "\r\r</b>"; }
* * This program 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 program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @link http://www.buggedcom.co.uk/ * @author Oliver Lillie, buggedcom <publicmail at buggedcom dot co dot uk> * @version 0.2 * @history--------------------------------------------- * see CHANGELOG */ # note this demo file is note yet complete, as there are many more functions # to add... it will be updated when the janitor class is updated. # import db cofigs include_once 'db.config.php'; # import the classes include_once '../shared/class.license.lib.php'; include_once 'class.license.server.php'; include_once 'class.license.janitor.php'; # create the new maintenaince object $janitor = new license_janitor(); # connect to the db $janitor->connect($table, $user, $pass); trace_r($janitor->update_license_date(1, 60 * 60 * 24 * 7 * 52, true)); # disconnect the db $janitor->disconnect();