示例#1
0
function call($command, $user)
{
    \app\log('calling func');
    if (!empty($user)) {
        $command_type = 'receiver';
    } else {
        $command_type = 'sender';
    }
    $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'commands';
    $tpl_path = $path . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $command_type;
    $file = $path . DIRECTORY_SEPARATOR . $command_type . DIRECTORY_SEPARATOR . $command . '.php';
    $template = $tpl_path . DIRECTORY_SEPARATOR . $command . '.phtml';
    \app\log($file);
    if (!file_exists($file)) {
        \app\log('Command ' . $command . ' not implemented for ' . $command_type);
        exit('Command ' . $command . ' not implemented for ' . $command_type);
    }
    include $file;
    \app\log($file);
    $function = "\\command\\" . $command;
    $result = $function();
    \app\log($result);
    if (!empty($result)) {
        \app\log('sending');
        \app\run('email', 'send', array($result, $template));
    } else {
        \app\log('nothing to send');
        exit('nothing to send');
    }
}
示例#2
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)));
}
示例#3
0
function store()
{
    $email = R::dispense('email');
    foreach (\app\run('input', 'keys', 'post') as $key) {
        $element = str_replace('-', '_', $key);
        $email->{$element} = \app\run('input', 'post', $key);
    }
    R::store($email);
    return null;
}
示例#4
0
function status()
{
    $sender = \app\run('input', 'post', 'sender');
    $recipient = \app\run('input', 'post', 'recipient');
    $emails = R::find('email', ' sender = ? or recipient = ? ', [$sender, $recipient]);
    $result = '<dl>';
    foreach ($emails as $email) {
        $result .= '<dt>' . $email->subject . '</dt>';
        $result .= '<dd>' . $email->body_plain . '</dd>';
    }
    $result .= '</dl>';
    return $result;
}
示例#5
0
文件: web.php 项目: draganescu/sibip
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"));
}
示例#6
0
文件: api.php 项目: draganescu/sibip
function verify_signature()
{
    $config = \app\run('configuration', 'load');
    $timestamp = \app\run('input', 'post', 'timestamp');
    $token = \app\run('input', 'post', 'token');
    $signature = \app\run('input', 'post', 'signature');
    if (empty($timestamp) || empty($token) || empty($signature)) {
        \app\log('incomplete');
        exit('incomplete');
    }
    $data = $timestamp . $token;
    $code = hash_hmac('sha256', $data, $config['key']);
    if ($code == $signature) {
        return true;
    }
    \app\log('nope');
    exit('nope');
}
示例#7
0
<?php

require '../vendor/autoload.php';
require '../app/app.php';
\app\run();
示例#8
-2
function check($data)
{
    $recipient = \app\run('input', 'post', 'recipient');
    $user = R::findOne('user', ' email = ?', [$recipient]);
    if (empty($user)) {
        return false;
    }
    return $user;
}