<?php

	/*
	*	Gekko - Open Source Web Development Framework
	*	------------------------------------------------------------------------
	*	Copyright (C) 2004-2005, J. Carlos Nieto <xiam@users.sourceforge.net>
	*	This program is Free Software.
	*
	*	@package	Gekko
	*	@license	http://www.gnu.org/copyleft/gpl.html GNU/GPL License 2.0
	*	@author		J. Carlos Nieto <xiam@users.sf.net>
	*	@version	CVS: $Id:$
	*	@link		http://www.gekkoware.org
	*/

	if (!defined("IN-GEKKO")) die("Get a life!");

	function antibot_fix_form($buff) {
		$attr = html_split_attributes($buff);

		if (!isset($attr["onsubmit"])) $attr["onsubmit"] = "";

		$attr["onsubmit"] = "antiBot(this);";

		$tag = "";
		foreach ($attr as $n => $v) {
			$tag .= "$n=\"$v\" ";
		}
		return trim($tag);
	}

	function antibot_output(&$buff) {
		// fixing form
		$buff = preg_replace("/<form(.*?)>/e", "'<form '.antibot_fix_form(\"\\1\").'>'", $buff);
		// cleaning auth
		$buff = preg_replace("/<input(.*?)name=\"auth\" value=\".*?\"(.*?)>/", "<input\\1name=\"auth\" value=\"\"\\2>", $buff);
	}
?>