<?php if (!defined('PmWiki')) exit();
/*
This file is phpalert.php; you
can redistribute it and/or modify it under the
terms of the GNU General Public License as
published by the Free Software Foundation
http://www.fsf.org either version 2 of the 
License, or (at your option) any later version.

Copyright 2007 GNUZoo (guru@gnuzoo.org)

	http://www.pmwiki.org/wiki/Profiles/GNUZoo

Please donate to the author:

	http://gnuzoo.org/GNUZooPayPal/

*/

$RecipeInfo['PHPAlert']['Version'] = '2.3';

function phpalert($msg) { 
	global $EnableRedirect;

	$EnableRedirect = 0;

	$sqb = strpos($msg, "'");
	$dqb = strpos($msg, '"');
	$s1 = "<script type='text/javascript'>alert(";
	$s2 = ");</script>";

	if ($sqb === false && $dqb === false) {
		# no quotes
		echo $s1.'"'.$msg.'"'.$s2; 
	} else if ($sqb === false) {
		# 1st quote is double quote
		echo $s1."'".$msg."'".$s2;
	} else {
		# 1st quote is single quote
		echo $s1.'"'.$msg.'"'.$s2;
	}
}