<?php
// $Id: xoopscheck.php,v 1.8 2003/03/19 06:58:15 half-dead Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Kazumi Ono
// Author Website : http://www.mywebaddons.com/ , http://www.myweb.ne.jp
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
if (!defined("EXOOPS_XOOPSCHECK_INCLUDED")) {
	define("EXOOPS_XOOPSCHECK_INCLUDED", 1);
// ------------------------------------------------------------------------- //
/**
* Description
*
* @param type $var description
* @return type description
*/
function xoopsfwrite() {
if ( !isPost() ) {
	return false;
	}
if ( !myRefererCheck($errstr) ) {
	return false;
	}
return true;
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function isPost() {
if (_REQUEST_METHOD == "POST") {
	return true;
	} else {
		return false;
	}
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function myRefererCheck(&$errstr) {
if ( strlen(_HTTP_REFERER) == 0 ) {
	return false;
	}
$my_url    = 'http://'._HTTP_HOST._PHP_SELF;
if ( strpos(_HTTP_REFERER, $my_url) != 0 ) {
	return false;
	}
return true;
}
//---------------------------------------------------------------------------------------//
/**
* Takes $url as the input & builds a FORM from the variables in the $url.
* Note: All variables in $url are transformed into POST/GET, like this one can use
* whichever best fits the current situation.
*
* @param type $url URL to parse into form elements
* @param type $caption Caption of the submit button
* @return string Form to display
*/
function myTextForm($url, $caption) {
global $myts;
$parsed = parse_url($myts->undoHtmlSpecialChars($url));
parse_str($parsed['query'], $query);
$result  = "<form action='".$url."' method='post'>";
if ( !empty($query) ) {
	foreach($query as $k=>$v) {
		$result .= "<input type='hidden' name='".$myts->makeTboxData4PreviewInForm($k)."' value='".$myts->makeTboxData4PreviewInForm($v)."' />";
	}
}
$result .= "<input type='submit' class='button' name='submit' value='".$myts->makeTboxData4PreviewInForm($caption)."' />";
$result .= "</form>";
return $result;
}
//---------------------------------------------------------------------------------------//
}
?>
