/** * @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)); } }
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']; }
function ipinga_shutdown() { // v6_debug::dump(); \ipinga\cookie::set(); @ob_end_flush(); $error = error_get_last(); if ($error !== NULL && $error['type'] == 1) { // ob_end_clean(); // silently discard the output buffer contents. // appSendMsgToVern('Error has occurred',$error); // header( 'location:/fatal_error' ); @ob_end_flush(); // output what is stored in the internal buffer (may not want this here in production) \ipinga\log::info(var_export($error, true)); echo '<pre>' . var_export($error, true); // v6_BackTrace(); die('handleShutdown(): Cannot continue!'); } else { @ob_end_flush(); // output what is stored in the internal buffer } }
/** * See if the url can be handled by this route * * @param string $rt * * @return bool */ public function handled($rt = '') { \ipinga\log::debug('(RH1) Route {' . $this->identifier . '} (' . $this->urlToMatch . ') checking to handle ' . $rt); $uriSegmentsInThisRoute = explode('/', $this->urlToMatch); $uriSegmentsInRequestedRoute = explode('/', $rt); \ipinga\log::debug('(RH8) $uriSegmentsInThisRoute == ' . var_export($uriSegmentsInThisRoute, true)); \ipinga\log::debug('(RH9) $uriSegmentsInRequestedRoute == ' . var_export($uriSegmentsInRequestedRoute, true)); if (count($uriSegmentsInRequestedRoute) == count($uriSegmentsInThisRoute)) { $thisUrlUpToFirstDollarSign = explode('/$', $this->urlToMatch)[0]; \ipinga\log::debug('(RH10) $thisUrlUpToFirstDollarSign == ' . var_export($thisUrlUpToFirstDollarSign, true)); $numberOfSegmentsUpToFirstDollarSign = count(explode('/', $thisUrlUpToFirstDollarSign)); \ipinga\log::debug('(RH11) $numberOfSegmentsUpToFirstDollarSign == ' . $numberOfSegmentsUpToFirstDollarSign); $theyMatch = true; for ($i = 0; $i < $numberOfSegmentsUpToFirstDollarSign; $i++) { if (strcmp($uriSegmentsInThisRoute[$i], $uriSegmentsInRequestedRoute[$i]) != 0) { \ipinga\log::debug('(RH2) Segments did not match: ' . $i . ' -- ' . $uriSegmentsInThisRoute[$i] . ' -- ' . $uriSegmentsInRequestedRoute[$i]); $theyMatch = false; break; } } if ($theyMatch) { if ($this->processMiddleWare() == true) { // have to explode these two again, in case middleware changed anything $uriSegmentsInThisRoute = explode('/', $this->urlToMatch); $uriSegmentsInRequestedRoute = explode('/', $rt); $NumberOfParams = count(explode('$', $this->urlToMatch)) - 1; $params = array(); for ($i = count($uriSegmentsInThisRoute) - $NumberOfParams; $i < count($uriSegmentsInThisRoute); $i++) { $params[] = $uriSegmentsInRequestedRoute[$i]; } \ipinga\log::info('(RH3) Route {' . $this->identifier . '} (' . $this->urlToMatch . ') fired!'); self::launchController($this->controller, $this->method, $params); \ipinga\log::debug('(RH4) Route {' . $this->identifier . '} (' . $this->urlToMatch . ') back from controller'); $this->fired = true; return true; } else { \ipinga\log::debug('(RH5) Route {' . $this->identifier . '} middcleware refused'); } } } else { \ipinga\log::debug('(RH6) Route {' . $this->identifier . '} segment counts not the same'); } \ipinga\log::debug('(RH7) Route {' . $this->identifier . '} (' . $this->urlToMatch . ') NOT fired!'); return false; }