<?php
str_replace($search, $replace, $subject);
str_replace($needle, $haystack, $subject);
$Text = str_replace('^0', '', $Text);
$Text = str_replace(
array('^0'),
array(''),
$Text
);
?>
<?php
IS_MTC()->Sound(SND_ERROR)->UCID(255)->Text('Text')->Send();
?>
<?php
public function onPrismError($eNo, $eStr)
{
IS_MTC()->Sound(SND_ERROR)->UCID(255)->Text("^1ERROR: ^7['{$eNo}'] {$eStr}")->Send();
return FALSE;
}
public function onPrismClose()
{
IS_MTC()->Sound(SND_ERROR)->UCID(255)->Text('^1FATAL ERROR. Restarting...')->Send();
Cruise::sqlSaveAll();
}
public function __construct()
{
set_error_handler(array($this, 'onPrismError'));
register_shutdown_function(array($this, 'onPrismClose'));
}
?>
<?php
php
/*# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # *
# #
# This file contains a PHP adaptation of code (imagemap.c) originally #
# written by Brian J. Fox ([email protected]) for MetaHTML 5.01 #
# #
# http://directory.fsf.org/GNU/metahtml.html #
# #
# Draw a horizontal line from $X, $Y extending inf in the positive #
# X-axis. Count the number of times that line crosses the lines created #
# by connecting adjacent vertices of the polygon. If that number is #
# even, then $X, $Y is "outside" of the polygon, if odd, then "inside". #
* # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #*/
class Point
{
public $x;
public $y;
};
function inPoly ($X, $Y, array $points)
{
$min_x = $max_x = $min_y = $max_y = NULL;
# Count vertices
$vertices = count($points);
# Close the polygon if it isn't already closed.
$i = $vertices - 1;
if (($points[$i]->x != $points[0]->x) OR ($points[$i]->y != $points[0]->y))
{
++$i;
++$vertices;
$points[$i] = new Point;
$points[$i]->x = $points[0]->x;
$points[$i]->y = $points[0]->y;
$points[$i + 1] = NULL;
}
# Now check to see if the point falls within the rectangle which encloses the entire polygon.
# If not, it certainly isn't inside.
for ($i = 0; $points[$i] != NULL; ++$i)
{
$min_x = (($min_x === NULL) OR ($points[$i]->x < $min_x)) ? $points[$i]->x : $min_x;
$min_y = (($min_y === NULL) OR ($points[$i]->y < $min_y)) ? $points[$i]->y : $min_y;
$max_x = (($max_x === NULL) OR ($points[$i]->x > $max_x)) ? $points[$i]->x : $max_x;
$max_y = (($max_y === NULL) OR ($points[$i]->y > $max_y)) ? $points[$i]->y : $max_y;
}
# Is $X, $Y within the rectangle defined by $min_x, $max_y, $max_x, $min_y?
if (($X < $min_x) OR ($X > $max_x) OR ($Y < $min_y) OR ($Y > $max_y))
return FALSE;
# The point falls within the polygon. Check adjacent vertices.
$lines_crossed = 0;
for ($i = 1; $points[$i] != NULL; ++$i)
{
$p1 =& $points[$i - 1];
$p2 =& $points[$i];
$min_x = min ($p1->x, $p2->x);
$max_x = max ($p1->x, $p2->x);
$min_y = min ($p1->y, $p2->y);
$max_y = max ($p1->y, $p2->y);
# We need to know if the point falls within the rectangle defined by the maximum vertices of the vector.
if (($X < $min_x) OR ($X > $max_x) OR ($Y < $min_y) OR ($Y > $max_y))
{
# Not within the rectangle. Great!
# If it is to the left of the rectangle and in between the $Y then it crosses the line.
if (($X < $min_x) AND ($Y > $min_y) AND ($Y < $max_y))
++$lines_crossed;
continue;
}
# Find the intersection of the line -inf $Y, +inf, $Y] and $p1-x, $p1-y, $p2-x, $p2-y].
# If the location of the intercept is to the right of $X, then the line will be crossed.
$slope = ($p1->y - $p2->y) / ($p1->x - $p2->x);
if ((($Y - ($p1->y - ($slope * $p1->x))) / $slope) >= $X)
++$lines_crossed;
}
return ($lines_crossed & 1) ? TRUE : FALSE;
}
?>