Your Ad Here

Posted By

tuffo19 on 02/22/11


Tagged

php header lib


Versions (?)

Iniziare un file php - Intestazione


 / Published in: PHP
 

Intestazione per un qlsiasi file php che voglio fare (per non scordare i pezzetti)

  1. <?php
  2.  
  3. //impedire accesso diretto
  4. if (eregi("YOUR_INCLUDED_PHP_FILE_NAME", $_SERVER['PHP_SELF'])) {
  5. die("<h4>You don't have right permission to access this file directly.</h4>");
  6. }
  7.  
  8.  
  9. //vogliamo solo https
  10. //if($_SERVER['SERVER_PORT'] != 443) {
  11. // $url = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
  12. // header("location: $url");
  13. //}
  14.  
  15. //errori
  16. error_reporting( E_ALL );
  17. ini_set( 'display_errors', 1);
  18.  
  19. //imposto la modalita
  20. $debug = false;
  21.  
  22. if ((isset($_GET['debug']) || isset($_POST['debug'])))
  23. $debug = (($_GET['debug'] == '1') || $_POST['debug'] == '1')? true: false;
  24.  
  25. function error_page($user, $error, $error_spec){
  26. global $filetxt;
  27. global $in;
  28. global $SRV;
  29. global $log_conn;
  30. global $service;
  31. global $remote_userid;
  32. global $session_number;
  33.  
  34. $eol=PHP_EOL;
  35. $email_admin="g.delsignore@cineca.it, g.tufano@cineca.it,s.scalise@cineca.it";
  36. if($error_spec==''){
  37. $error_spec=ocierror($conn);
  38. }
  39.  
  40.  
  41. #echo "<hr>$session_number<br/>$service<br/>".$this->str."<hr>";
  42. $today = date("j/m/Y, H:m:s");
  43. $ajax=isset($in['ajax_call'])?"Si":"No";
  44.  
  45. if (is_array($error_spec))
  46. foreach ($error_spec as $key => $val)
  47. $spec.="\n $key : $val";
  48. else
  49. $spec = $error_spec;
  50.  
  51. //$debug_info_str = "<br>".$debug_info_str;
  52. //$debug_info_str = preg_replace("[\n]","<br>",$debug_info_str);
  53. //$debug_info_str = preg_replace("/array/i","<b>Array:</b>",$debug_info_str);
  54. //$debug_info_str = preg_replace("/([0-9]) =>/","<b> \\1 => </b>",$debug_info_str);
  55.  
  56. $alltxt =
  57. "* Data: $today
  58. * Errore: $error
  59.  
  60. * Session Number:$session_number IP richiesta: {$_SERVER['REMOTE_ADDR']}
  61. * URL richiesta: {$_SERVER['REQUEST_URI']}
  62. * Servizio: $service
  63. * Specifiche errore: $spec
  64. * Chiamata ajax: $ajax
  65. * var export (_SERVER): $debug
  66. *DEBUG INFO: ".$debug_info_str;
  67.  
  68.  
  69. $headers = "From: ERROR_".$service."@{$_SERVER['SERVER_NAME']}$eol";
  70. // $headers .= "Content-type: text/html
  71. ";
  72. $headers .= "Content-type: text/plain; charset=utf-8$eol";
  73. // $debug_info=nl2br(var_export( debug_backtrace(), TRUE ) );
  74.  
  75. $prod="";
  76. if(preg_match("/\.agenziafarmaco\./", $_SERVER['HTTP_HOST'])){
  77. if(preg_match("/too large/i",$spec)) {
  78. $edo=substr($spec,strpos($spec,"value too large for column")+28,strlen($spec));
  79. $edo=substr($edo,0,strpos($edo,"(actual:"));
  80. $edo=substr($edo,strrpos($edo,".")+1);
  81.  
  82. $body="<h2 style=\"color:red;\">Valore troppo grande per il campo: ".$edo."</h2>";
  83.  
  84. }
  85. $body.="<h3>Errore del sistema. Contattare il supporto tecnico.</h3>$debug_info";
  86. $prod="_!PRODUZIONE!";
  87. } else {
  88. print_r($error_spec);
  89. $debug = debug_backtrace();
  90. // foreach($debug as $key => $val) {
  91. // foreach($val as $k => $v) {
  92. // $debug_info.=$k." ".$v."<br />";
  93. // }
  94. // }
  95. $body="<h2>ERRORE DEVEL</h2><h3>$error</h3><br />$debug_info";
  96. // print_r($debug[0]);
  97. // $debug_info=var_export($debug,true);
  98. }
  99. mail($email_admin, "Errore[".$in['remote_userid']."]$prod",$alltxt, $headers);
  100. $filetxt=preg_replace("/<!--body-->/", $body, $filetxt);
  101. die($filetxt);
  102. }
  103.  
  104. // --------------- FINE FUNZIONI ---------------------- //

Report this snippet  

You need to login to post a comment.