function google_api_key ()
{
// please note:
// This key was registered by eXorithm. It might change at any time.
// It cannot be used from a server other than exorithm.com.
// If you are using this function on your server, you may need to get your own
// key from Google.
return "AIzaSyBqKZSzmn_TMnHaIHVyEi3JS8a1mTVOLRE"
}
Category: Algorithm
eXorithm – Execute Algorithm: View / Run Algorithm simple_download
function simple_download ()
{
$data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl'
. 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr'
. 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r'
. '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg=='
$data = base64_decode$data);
return array'extension'=>'png', 'name'=>'phprules', 'data'=>$data);
}
eXorithm – Execute Algorithm: View / Run Algorithm evaluate_equation
function evaluate_equation ($equation, $values
{
if (is_array$equation))
{
$operator = array_shift$equation);
switch ($operator
{
case '+'
return evaluate_equation$equation[0], $values)+evaluate_equation$equation[1], $values);
case '-'
return evaluate_equation$equation[0], $values)-evaluate_equation$equation[1], $values);
case '*'
return evaluate_equation$equation[0], $values)*evaluate_equation$equation[1], $values);
case '/'
return evaluate_equation$equation[0], $values)/evaluate_equation$equation[1], $values);
case '%'
return evaluate_equation$equation[0], $values)%evaluate_equation$equation[1], $values);
case '^'
return powevaluate_equation$equation[0], $values), evaluate_equation$equation[1], $values));
case 'neg'
return evaluate_equation$equation[0], $values)*-1;
case 'abs'
return absevaluate_equation$equation[0], $values));
case 'sqrt'
return sqrtevaluate_equation$equation[0], $values));
case 'log'
return logevaluate_equation$equation[0], $values), evaluate_equation$equation[1], $values));
case 'ln'
return logevaluate_equation$equation[0], $values));
case 'exp'
return expevaluate_equation$equation[0], $values));
case '!'
return 0;
case 'root'
return powevaluate_equation$equation[0], $values), 1/evaluate_equation$equation[1], $values));
// trig
case 'sin'
return sinevaluate_equation$equation[0], $values));
case 'cos'
return cosevaluate_equation$equation[0], $values));
case 'tan'
return tanevaluate_equation$equation[0], $values));
case 'sec'
return 1/cosevaluate_equation$equation[0], $values));
case 'csc'
return 1/sinevaluate_equation$equation[0], $values));
case 'cot'
return 1/tanevaluate_equation$equation[0], $values));
// hyperbolic trig
case 'sinh'
return sinhevaluate_equation$equation[0], $values));
case 'cosh'
return coshevaluate_equation$equation[0], $values));
case 'tanh'
return tanhevaluate_equation$equation[0], $values));
case 'sech'
return 1/coshevaluate_equation$equation[0], $values));
case 'csch'
return 1/sinhevaluate_equation$equation[0], $values));
case 'coth'
return 1/tanhevaluate_equation$equation[0], $values));
// arc trig
case 'arcsin'
return asinevaluate_equation$equation[0], $values));
case 'arccos'
return acosevaluate_equation$equation[0], $values));
case 'arctan'
return atanevaluate_equation$equation[0], $values));
// inverse hyperbolic trig
case 'arsinh'
return asinhevaluate_equation$equation[0], $values));
case 'arcosh'
return acoshevaluate_equation$equation[0], $values));
case 'artanh'
return atanhevaluate_equation$equation[0], $values));
default
throw new Exception'usupported operator '$operator);
}
}
else
{
if (ctype_alpha$equation))
{
if (isset$values$equation]))
{
return $values$equation];
}
else
{
throw new Exception'equation contains an unknown variable ''$equation''!');
}
}
else
{
return $equation
}
}
}
eXorithm – Execute Algorithm: View / Run Algorithm lathe_polygons
function lathe_polygons ($equation, $start_x, $end_x, $detail
{
$degrees = 360/$detail
$step = ($end_x$start_x)/$detail
$max_y = 0;
for ($ii=0;$ii<=$detail$ii++) {
$x = $start_x+($ii$step);
$y0 = evaluate_for_x$equation, $x);
if (!is_nan$y0) && !is_infinite$y0)) {
if ($y0 > $max_y) $max_y = $y0
for ($jj=0;$jj$detail$jj++) {
$y = $y0 * sindeg2rad$degrees$jj));
$z = $y0 * cosdeg2rad$degrees$jj));
// the top of the shape
/*if ($ii==0) {
$sides[-1][] = $x;
$sides[-1][] = $y;
$sides[-1][] = $z;
}*/
// the bottom of the shape
/*if ($ii==$detail) {
$sides[-2][] = $x;
$sides[-2][] = $y;
$sides[-2][] = $z;
}*/
// the sides of the shape
if ($ii$detail) {
$poly = $ii$detail$jj+1;
$sides$poly][6] = $x
$sides$poly][7] = $y
$sides$poly][8] = $z
$poly = $ii$detail+(($jj$detail-1) % $detail)+1;
$sides$poly][9] = $x
$sides$poly][10] = $y
$sides$poly][11] = $z
}
// the sides of the shape
if ($ii>0) {
$poly = ($ii-1)*$detail$jj+1;
$sides$poly][3] = $x
$sides$poly][4] = $y
$sides$poly][5] = $z
$poly = ($ii-1)*$detail+(($jj$detail-1) % $detail)+1;
$sides$poly][0] = $x
$sides$poly][1] = $y
$sides$poly][2] = $z
}
}
}
}
$sides = array_values$sides);
return $sides
}
eXorithm – Execute Algorithm: History For Algorithm validate_domain
validate_domain    version 0.5    validate domain
eXorithm – Execute Algorithm: View / Run Algorithm markup_urls
function markup_urls ($text
{
// split the text into words
$words = preg_split'/([snr]+)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
$text = ""
// iterate through the words
foreach$words as $word) {
// chopword = the portion of the word that will be replaced
$chopword = $word
$chopword = preg_replace'/^[^A-Za-z0-9]*/', '', $chopword);
if ($chopword <> '') {
// linkword = the text that will replace chopword in the word
$linkword''
// does it start with http://abc. ?
if (preg_match'/^(http://)[a-zA-Z0-9_]{2,}.*/', $chopword)) {
$chopword = preg_replace'/[^A-Za-z0-9/]*$/', '', $chopword);
$linkword = '<a href="'$chopword'" target="blank">'$chopword'</a>'
// does it equal abc.def.ghi ?
} else if (preg_match'/^[a-zA-Z]{2,}.([a-zA-Z0-9_]+.)+[a-zA-Z]{2,}(/.*)?/', $chopword)) {
$chopword = preg_replace'/[^A-Za-z0-9/]*$/', '', $chopword);
$linkword = '<a href="http://'$chopword'" target="blank">'$chopword'</a>'
// does it start with [email protected] ?
} else if (preg_match'/^[a-zA-Z0-9_.]+@([a-zA-Z0-9_]{2,}.)+[a-zA-Z]{2,}.*/', $chopword)) {
$chopword = preg_replace'/[^A-Za-z0-9]*$/', '', $chopword);
$linkword = '<a href="mailto:'$chopword'">'$chopword'</a>'
}
// replace chopword with linkword in word (if linkword was set)
if ($linkword <> '') {
$word = str_replace$chopword, $linkword, $word);
}
}
// append the word
$text = $text$word
}
return $text
}
eXorithm – Execute Algorithm: View / Run Algorithm projectile_distance
function projectile_distance ($inital_velocity, $angle, $initial_height, $g
{
$angle = deg2rad$angle);
$distance = ($inital_velocitycos$angle)/$g
* ($inital_velocitysin$angle)
+ sqrtpow$inital_velocitysin$angle),2)+2*$g$initial_height));
return $distance
}
eXorithm – Execute Algorithm: Embed Algorithm simple_sort
Embed This Algorithm
This page will help you embed the algorithm simple_sort on a page on your own website. Just configure the inputs, then click the generate button to get a snippet of code you can paste onto your site. You have two options.
- You can embed the entire form. Users will be able to enter their own arguments, and will need to press the run button to execute the algorithm.
- You can add only the output of the algorithm to your website. There will be no argument inputs or run button.
eXorithm – Execute Algorithm: View / Run Algorithm set_unix_time
function set_unix_time ($year$month$day$hour$minute$second
{
return mktime$hour$minute$second$month$day$year);
}