PageRenderTime 122ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/helpers/alerts.php

https://github.com/MilkZoft/zan
PHP | 38 lines | 38 code | 0 blank | 0 comment | 1 complexity | f1700e929fff57bbd3539173cfa0a2ff MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. if (!defined("ACCESS")) {
  3. die("Error: You don't have permission to access here...");
  4. }
  5. if (!function_exists("getAlert")) {
  6. function getAlert($message, $type = "error", $URL = null)
  7. {
  8. if (!is_null($URL)) {
  9. $message = a($message, encode($URL), true);
  10. }
  11. if ($type === "error") {
  12. return '<div id="alert-message" class="alert alert-error">'. __($message) .'</div>';
  13. } elseif ($type === "success") {
  14. unset($_POST);
  15. return '<div id="alert-message" class="alert alert-success">'. __($message) .'</div>';
  16. } elseif ($type === "warning") {
  17. return '<div id="alert-message" class="alert alert-warning">'. __($message) .'</div>';
  18. } elseif ($type === "notice") {
  19. return '<div id="alert-message" class="alert alert-info">'. __($message) .'</div>';
  20. }
  21. }
  22. }
  23. if (!function_exists("showAlert")) {
  24. function showAlert($message, $URL = false)
  25. {
  26. echo '<script>alert("'. $message .'");';
  27. if ($URL) {
  28. echo 'window.location.href="'. $URL .'";';
  29. }
  30. echo '</script>';
  31. exit();
  32. }
  33. }