<?php
$_ENV = array (
);

$_GET = array (
);

$_POST = array (
  'mailto' => 'fastix',
);

$_COOKIE = array (
);

$_SESSION = array (
  'id' => 'ab3g78908r0ptrft93so3mebno',
  'test' => 'Test',
);

$foo = 'FOO';

$bar = 'BAR';


# All in the next rows the is only a example. Do her, what you have to do!

/*
* Configuration:
*/

$deleteFile = true; #delete the temporary File after execution? Set FALSE for debugging.
$to         = "fastix@localhost"; # Often you want to use the mailaddress from the user, given via formular ($_POST, $_GET).
$subject    = "alone executed";

/*
* This is only a DEMONSTRATION how to handle the data. Show to executeCaller.php how export the vars.
*/

ob_start(); # save all output to a buffer!

error_reporting(E_ALL);
ini_set("display_errors", 1);

#
if ( false === strpos( __FILE__, 'executeAlone.php' ) ) {
    trigger_error ( "Dieses Skript sollte nicht direkt aufgerufen werden!", E_USER_ERROR );
}

echo "Data:\n=====\n\n";

if ( isset( $_SESSION )  ) {
    session_id( $_SESSION['id'] );
    session_start();
    # this is only for the mail:
    echo '$_SESSION = ' . var_export( $_SESSION, true ) . "\n\n";
}

if ( isset( $_ENV )  ) {
    # this is only for the mail:
    echo '$_ENV = ' . var_export( $_ENV, true ) . "\n\n";
}

if ( isset( $_SERVER )  ) {
    # this is only for the mail:
    echo '$_SERVER = ' . var_export( $_SERVER, true ) . "\n\n";
}

if ( isset( $_GET )  ) {
    # this is only for the mail:
    echo '$_GET = ' . var_export( $_GET, true ) . "\n\n";
}

if ( isset( $_POST )  ) {
    # this is only for the mail:
    echo '$_POST = ' . var_export( $_POST,  true) . "\n\n";
}

if ( isset( $_COOKIE )  ) {
    #
    # You have to know, that you DON'T can send cookies to the Browser!
    #
    # this is only for the mail:
    echo '$_COOKIE = ' . var_export( $_COOKIE, true ) . "\n\n";
}

if ( isset( $foo )  ) {
    echo '$foo = ' . var_export($foo, 1) . "\n";
}

if ( isset( $bar )  ) {
    echo '$bar = ' . var_export($bar, 1) . "\n";
}

# Now you can send all output to the given emailaddress:
$message = ob_get_clean();
mb_language( 'uni' );
mb_send_mail ( $to , $subject , $message, '', '' );

# This can delete the file after executing

if ( $deleteFile && ( false === strpos(__FILE__, 'executeAlone.php' ) ) ) {
    unlink (__FILE__);
}