function sendActivate($id, $hash, $email) { try { $mail = new \FW\MailProxy\MailProxy(true); $mail->Subject = 'Вы зарегистрировались на сайте ' . Core::$DOMAIN; $mail->addAddress($email, $email); $mail->msgHTML('<div>Вы успешно зарегистрировались на сайте.</div><div>Для завершения регистрации пройдите по ссылке:<br><a href="' . Core::$DOMAIN . '/login/activate/' . $id . '/' . $hash . '">' . Core::$DOMAIN . '/login/activate/' . $id . '/' . $hash . '</a></div>'); $mail->send(); unset($mail); } catch (\Exception $e) { trigger_error('Ошибка регистрации: ' . print_r($e, 1)); } return true; }
public static function handler($errno, $errstr, $errfile, $errline) { if (self::$key > 3) { return true; } else { ++self::$key; } $text = (include __DIR__ . '/language/' . Core::$LANGUAGE['lang'] . '.php'); $errors = [1 => 'Error', 2 => 'Warning', 4 => 'Parse', 8 => 'Notice', 16 => 'Core error', 32 => 'Core warning', 64 => 'Complite error', 128 => 'Complite warning', 256 => 'User Error', 512 => 'User Warning', 1024 => 'User Notice', 2048 => 'Strict', 4096 => 'Recoverable error', 8192 => 'Deprecated', 16384 => 'User Deprecated', 32767 => 'All']; $trace = ''; if (Core::$ERRORS['trace']) { $trace = "\r\nTrace:\r\n" . print_r($GLOBALS, 1); } if (Core::$ERRORS['errlvl'] > 1 || Core::$ERRORS['errlvl'] == 1 && !in_array($errno, self::$user_err)) { if (Core::$ERRORS['file']) { file_put_contents('./logs/php.log', date("Y-m-d H:i:s") . ": " . $errors[$errno] . ': [' . $errstr . "]\r\nat file " . $errfile . ' in line ' . $errline . $trace . "\n\r=================================================\n\r\n\r", FILE_APPEND); } if (Core::$ERRORS['email']) { try { $mail = new \FW\MailProxy\MailProxy(true); $mail->Subject = 'На сайте ' . Core::$DOMAIN . ' произошла ошибка'; $mail->addAddress(Core::$ADMIN, Core::$ADMIN); $mail->msgHTML('<div>' . date("Y-m-d H:i:s") . ": " . $errors[$errno] . ': [' . $errstr . '] at file ' . $errfile . ' in line ' . $errline . '.<br>' . htmlspecialchars($trace) . '</div>'); $mail->send(); unset($mail); } catch (\Exception $e) { trigger_error('Ошибка регистрации: ' . print_r($e, 1)); } return true; } if (Core::$ERRORS['mysql']) { q("\n\t\t\t\t\tCREATE TABLE IF NOT EXISTS `fw_php_logs` (\n\t\t\t\t\t `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t\t\t\t `link` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t\t\t `error` text COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t\t\t `trace` longtext COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t\t\t PRIMARY KEY (`id`),\n\t\t\t\t\t KEY `link` (`link`)\n\t\t\t\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1\n\t\t\t\t"); q("\n\t\t\t\t\tINSERT INTO `fw_php_logs` SET\n\t\t\t\t\t`link` = '" . es($_SERVER['REQUEST_URI']) . "',\n\t\t\t\t\t`error` = '" . es($errors[$errno] . ': [' . $errstr . '] в файле ' . $errfile . ' на линии ' . $errline) . "',\n\t\t\t\t\t`trace` = '" . es($trace) . "'\n\t\t\t\t"); } } if (Core::$ERRORS['show']) { $tip = 'main'; preg_match('#^(.*)\\:#iusU', $errstr, $matches); if (!empty($matches[1])) { $matches[1] = trim($matches[1]); if (isset(self::$tips[$matches[1]])) { $tip = self::$tips[$matches[1]]; } } echo '<div style="background-color:white; border:2px dotted red; padding:10px;"> <div style="background-color:#F0D9DA;">' . $errors[$errno] . ': [' . $errstr . '] ' . $text['in_file'] . ' ' . $errfile . ' ' . $text['on_line'] . ' ' . $errline . '</div> <div align="center"> <a href="javascript:void(0)" onclick="document.getElementById(\'randerrorkeyGLOBALS' . ($randomkey = rand(1, 9999)) . '\').style.display=\'block\'; return false;">' . $text['show'] . ' $GLOBALS</a> | <a href="javascript:void(0)" onclick="document.getElementById(\'randerrorkeyDEBUG' . $randomkey . '\').style.display=\'block\'; return false;">' . $text['show'] . ' Debug Backtrace</a> | <a href="javascript:void(0)" onclick="document.getElementById(\'randerrorkeyTIP' . $randomkey . '\').style.display=\'block\'; return false;">' . $text['show_tips'] . '</a> </div> <div style="display:none; padding:5px; border: 1px dotted orange;" id="randerrorkeyGLOBALS' . $randomkey . '"><h1>GLOBALS:</h1><pre>' . htmlspecialchars(print_r($GLOBALS, 1)) . '</pre></div> <div style="display:none; padding:5px; border: 1px dotted orange;" id="randerrorkeyDEBUG' . $randomkey . '"><h1>DEBUG BACKTRACE</h1><pre>'; debug_print_backtrace(); echo '</pre></div> <div style="display:none; padding:5px; border: 1px dotted orange;" id="randerrorkeyTIP' . $randomkey . '"><h1>TIPS</h1>'; include __DIR__ . '/view/' . $tip . '.tpl'; echo '</div> </div>'; } elseif (Core::$ERRORS['redirect']) { if ($errno == E_USER_ERROR) { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); header('Refresh: 3; URL=' . (Core::$LANGUAGE['status'] ? '/' . Core::$LANGUAGE['lang'] : '') . '/404'); } else { header("HTTP/1.1 307 Temporary Redirect"); header('Refresh: 3; URL=' . (Core::$LANGUAGE['status'] ? '/' . Core::$LANGUAGE['lang'] : '') . '/error?error=' . urlencode($text['error_mess'])); } echo '<script>setTimeout(function() {window.location.href="' . (Core::$LANGUAGE['status'] ? '/' . Core::$LANGUAGE['lang'] : '') . '/' . ($errno == E_USER_ERROR ? '404' : 'error?error=' . urlencode($text['error_mess'])) . '";},3000); document.write(\'<div style="border:2px dotted red;">' . $text['redirect_text'] . '</div>\');</script>'; exit; } else { } self::$key = 0; if (Core::$ERRORS['stop']) { exit; } if ($errno == E_USER_ERROR) { exit; } /* Не запускаем внутренний обработчик ошибок PHP return true; */ return null; }