Пример #1
0
 /**
  * @param $recipients array
  * @param $subject string
  * @param $body string
  */
 public static function sendEmail($recipients, $subject, $body)
 {
     \ipinga\email::$host = \ipinga\options::get('email_host');
     \ipinga\email::$port = (int) \ipinga\options::get('email_port');
     \ipinga\log::debug('option email_auth = [' . \ipinga\options::get('email_auth') . ']');
     if (strtolower(\ipinga\options::get('email_auth')) == 'yes') {
         \ipinga\email::$auth = true;
         \ipinga\email::$username = \ipinga\options::get('email_username');
         \ipinga\email::$password = \ipinga\options::get('email_password');
     } else {
         \ipinga\email::$auth = false;
         \ipinga\email::$username = '';
         \ipinga\email::$password = '';
     }
     \ipinga\email::$localhost = \ipinga\options::get('email_localhost');
     \ipinga\email::$timeout = (int) \ipinga\options::get('email_timeout');
     \ipinga\email::$debug = false;
     \ipinga\email::$from = \ipinga\options::get('email_from');
     \ipinga\email::$recipients = $recipients;
     // \ipinga\email::$bcc[] = '*****@*****.**';
     \ipinga\email::$subject = $subject;
     \ipinga\email::$textBody = $body;
     // \ipinga\email::$htmlBody = '';
     $success = \ipinga\email::send();
     if ($success === true) {
         \ipinga\log::info('(services.sendEmail) success!');
     } else {
         \ipinga\log::warning('(services.sendEmail) failed to send email to ' . var_export($recipients, true));
     }
 }
Пример #2
0
 public static function isGoodCaptcha($recaptchaResponse)
 {
     $r = \data::curlPost(\ipinga\options::get('recaptcha_siteverify_url'), array(), array('secret' => \ipinga\options::get('recaptcha_secret_key'), 'response' => $recaptchaResponse, 'remoteip' => $_SERVER['REMOTE_ADDR']));
     \ipinga\log::info('reCaptcha $recaptchaResponse == ' . $recaptchaResponse);
     \ipinga\log::info('reCaptcha remoteip == ' . $_SERVER['REMOTE_ADDR']);
     \ipinga\log::info('reCaptcha siteverify response == ' . var_export($r, true));
     \ipinga\log::notice('reCaptcha ' . ($r['success'] ? ' Success!' : ' Failure'));
     return $r['success'];
 }
Пример #3
0
 public function run()
 {
     $rt = isset($_GET['rt']) ? $_GET['rt'] : '';
     // I use output buffering to make sure any cookies that are set in the code get handled properly.
     // ie: sent in the header instead of inline with the html, etc as they are generated.
     ob_start();
     $routeHandled = false;
     foreach ($this->routes as $route) {
         /* @var $route \ipinga\route */
         if ($route->handled($rt) == true) {
             $routeHandled = true;
             break;
         }
     }
     if ($routeHandled === false) {
         if (count($this->defaultRoute) == 2) {
             \ipinga\log::debug('Firing default route');
             //if (isset($_GET['rt'])==false) {
             \ipinga\route::launchController($this->defaultRoute[0], $this->defaultRoute[1], array());
             //} else {
             //    header('location: /');
             //}
         } else {
             echo 'No route found!' . PHP_EOL;
         }
     }
 }
Пример #4
0
 public static function trySmtp($smtp, $recipients, $mimeHdr, $mimeBody)
 {
     $result = $smtp->send($recipients, $mimeHdr, $mimeBody);
     if (\PEAR::isError($result)) {
         self::$error = true;
         self::$errorMessage = $result->getMessage();
         foreach (self::smtpServerDetailsAsArray() as $k => $v) {
             \ipinga\log::notice('(email) server.' . $k . ' => ' . $v);
         }
         \ipinga\log::notice('(email) ' . sprintf('%s: code="%d"', $result->getType(), $result->getCode()));
         \ipinga\log::notice('(email) ' . sprintf('%s: message="%s"', $result->getType(), $result->getMessage()));
         \ipinga\log::notice('(email) ' . sprintf('%s: info="%s"', $result->getType(), $result->getUserInfo()));
     } else {
         self::$error = false;
         self::$errorMessage = '';
     }
     return $result;
 }
Пример #5
0
define('__VERN', true);
$iPinga = new \ipinga\ipinga(array_merge(array('manager.expired_url' => '/login', 'manager.ip_changed_url' => '/login', 'manager.login_url' => '/login', 'manager.max_minutes' => 10), config()));
if (isset($_SERVER['WEBSITE_ENVIRONMENT']) == true) {
    \ipinga\options::$environment = $_SERVER['WEBSITE_ENVIRONMENT'];
}
// define all the routes...
if (isset($_SERVER['REQUEST_METHOD']) == true && $_SERVER['REQUEST_METHOD'] == 'GET') {
    $iPinga->addRoute('login', 'login', 'index', null, '1');
} else {
    $iPinga->addRoute('login', 'login', 'post', null, '2');
}
if (isset($_SERVER['REQUEST_METHOD']) == true && $_SERVER['REQUEST_METHOD'] == 'GET') {
    $iPinga->addRoute('password/change', 'password', 'change', 'mustBeLoggedIn', '3');
} else {
    $iPinga->addRoute('password/change', 'password', 'post_change', 'mustBeLoggedIn', '4');
}
if (isset($_SERVER['REQUEST_METHOD']) == true && $_SERVER['REQUEST_METHOD'] == 'GET') {
    $iPinga->addRoute('password/forgot', 'password', 'forgot', null, '5');
} else {
    $iPinga->addRoute('password/forgot', 'password', 'post_forgot', null, '6');
}
if (isset($_SERVER['REQUEST_METHOD']) == true && $_SERVER['REQUEST_METHOD'] == 'GET') {
    $iPinga->addRoute('password_reset/$1', 'password', 'reset', null, '7');
} else {
    $iPinga->addRoute('password_reset', 'password', 'reset_new', null, '8');
}
$iPinga->addRoute('logout', 'logout', 'index', null, '9');
$iPinga->addRoute('', 'default', 'index', 'mustBeLoggedIn', '10');
$iPinga->defaultRoute('default', 'error404');
\ipinga\log::setThreshold((int) \ipinga\options::get('log_level'));
$iPinga->run();
Пример #6
0
 private function processMiddleWare()
 {
     $middlewareList = explode('|', $this->middleware);
     $ipinga = \ipinga\ipinga::getInstance();
     $result = true;
     foreach ($middlewareList as $mw) {
         if (empty($mw) == false) {
             $middlewareFile = $ipinga->config('path.middleware') . '/' . $mw . '.middleware.php';
             // include the middleware
             require_once $middlewareFile;
             // a new controller class instance
             $class = $mw . 'Middleware';
             $middleware = new $class();
             $result = call_user_func_array(array($middleware, 'call'), array($ipinga));
             if ($result === false) {
                 break;
             }
         }
     }
     \ipinga\log::debug('middleware ' . $this->middleware . ' is returning ' . $result);
     return $result;
 }
 public function dummy()
 {
     \ipinga\log::emergency(var_export($_POST, true));
 }