Example #1
0
function send($result, $template, $subject = 'sibip')
{
    \app\log('sending prep');
    $config = \configuration\load();
    $mailgun = new \Mailgun\Mailgun($config['key']);
    $domain = $config['domain'];
    \app\log('composed');
    $mailgun->sendMessage($domain, array('from' => '*****@*****.**', 'to' => \app\run('input', 'post', 'sender'), 'subject' => $subject, 'text' => \email\composeText($result), 'html' => \email\composeHTML($template, $result)));
}
Example #2
0
function connect()
{
    $config = \configuration\load();
    if (empty($config['dsn']) || empty($config['user']) || empty($config['password'])) {
        die("Please check the configuration\\database.php file");
    }
    R::addDatabase('db', $config['dsn'], $config['user'], $config['password'], $config['frozen']);
    R::selectDatabase('db');
}
Example #3
0
function log($message, $component = "sibip", $program = "app")
{
    $config = \configuration\load();
    if (!$config['log_enabled']) {
        return false;
    }
    $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
    foreach (explode("\n", $message) as $line) {
        $syslog_message = "<22>" . date('M d H:i:s ') . $program . ' ' . $component . ': ' . $line;
        socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, $config['log_domain'], $config['log_port']);
    }
    socket_close($sock);
}
Example #4
0
function index_page()
{
    $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates';
    $tpl_path = $path . DIRECTORY_SEPARATOR . 'email' . DIRECTORY_SEPARATOR;
    $config = \configuration\load();
    $registration = \app\run('input', 'post', 'email');
    if ($registration) {
        $string = \app\run('input', 'generateRandomString', 10);
        $subject = '#' . $string . '#';
        $result = ['code' => '#' . $string . '#'];
        $template = $tpl_path . 'register.phtml';
        \app\run('email', 'send', [$result, $template, $subject]);
    }
    return array('today' => date("Y-m-d"));
}
Example #5
0
function find()
{
    $config = \configuration\load();
    $default = 'store';
    $actions = $config['available_commands'];
    $subject = \app\run('input', 'post', 'subject');
    if (!empty($subject)) {
        foreach ($actions as $command) {
            if ($command == $subject) {
                return $command;
            }
        }
    }
    return $default;
}