Advertisement
Guest User

Untitled

a guest
May 16th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. <?php
  2. // setlocale ( LC_ALL, 'sv_SE.ISO8859-1');
  3.  
  4. // if ( is_array ( $options['javascripts'] ) )
  5.  
  6. // echo $css . '?' . filemtime ( $css );
  7.  
  8. // first at the page
  9. // require ('includes/data.php');
  10. // $data['title'] = $profil_id . ' - SnackZon';
  11.  
  12. // define ('ROOT', '/home/snackzon/public_html/');
  13. // define ('IMAGE', '/css/gfx/');
  14. // $_SESSION['sess_login'] = time ();
  15.  
  16. function redirect ( $page )
  17. {
  18. if ( headers_sent () )
  19. {
  20. echo '<script type="text/javascript">window.location.href = "' . $page . '";</script>';
  21. exit '<meta http-equiv="refresh" content="0;url=' . $page . '" />';
  22. }
  23. else
  24. {
  25. header ('Location: ' . $page);
  26. exit;
  27. }
  28. }
  29.  
  30. function online_time ()
  31. {
  32. $output = '';
  33. $online_secs = time () - $_SESSION['sess_login'];
  34. $online_days = floor ( $online_secs / 86400 );
  35. $online_hrs = floor (( $online_secs - $online_days * 86400 ) / 3600 );
  36. $online_mins = floor (( $online_secs % 3600 ) / 60 );
  37.  
  38. if ( $online_days == 1 )
  39. {
  40. $output .= 'en dag, ';
  41. }
  42. elseif ( $online_days > 1 )
  43. {
  44. $output .= $online_days . ' dagar ';
  45. }
  46.  
  47. if ( $online_hrs > 0 )
  48. {
  49. $output .= $online_hrs . ' tim, ';
  50. }
  51.  
  52. if ( $online_mins > 0 )
  53. {
  54. $output .= $online_mins . ' min';
  55. }
  56. elseif ( $online_hrs == 0 && $online_days == 0 && $online_mins == 0 )
  57. {
  58. $output .= '0 min';
  59. }
  60.  
  61. return '<span class="online">' . $output . '</span>';
  62. }
  63.  
  64. function report_error ( $text, $type = null, $file = null, $line = null )
  65. {
  66. // $type == "sql"
  67. // mysql_query ( $query ) or report_error ( $query, 'sql', __FILE__, __LINE__ );
  68.  
  69. echo '<h2>Ett fel har inträffat</h2>' . "\n";
  70. echo '<p>' . "\n";
  71.  
  72. echo ( $type == 'sql') ? mysql_error () . "<br /><br />\n" : '';
  73. echo htmlentities ( $text ) . '<br /><br />' . "\n";
  74. echo $file . ' #' . $line . '</p>' . "\n";
  75. echo '<h2>print_r ()</h2>' . "\n";
  76. echo '<pre>' . "\n";
  77. print_r ( $text );
  78. echo '</pre>' . "\n";
  79.  
  80. // logga felet
  81. $handle = fopen (ROOT . 'includes/error.txt', 'a+');
  82. $handle = fwrite ( $handle, $text . " - " . $file . " #" . $line . "\n\n");
  83. $handle = fclose ( $handle );
  84. }
  85.  
  86. function download ( $page )
  87. {
  88. $name = ROOT . $page;
  89.  
  90. if ( strpos ( file_get_contents ( $name ), '// download') !== false)
  91. {
  92. header ('Content-Type: application/octet-stream');
  93. header ('Content-Type: application/force-download');
  94. header ('Content-Disposition: attachment; filename="' . basename ( $name ) . '";');
  95. readfile ( $_GET['download'] );
  96. exit;
  97. }
  98.  
  99. return 'You can\'t download this file';
  100. }
  101.  
  102. function ie_message ()
  103. {
  104. if ( strpos ( $_SERVER['HTTP_USER_AGENT'], 'MSIE') && !strpos ( $_SERVER['HTTP_USER_AGENT'], 'MSIE 7.0'))
  105. {
  106. echo 'You use IE :(';
  107. }
  108. }
  109.  
  110. function last_action ()
  111. {
  112. if ( check_login () )
  113. {
  114. $actions = array ('index.php' => 'Kikar in startsidan',
  115. 'gb.php' => 'Kollar in XXX\'s gästbok',
  116. 'profile.php' => 'Rotar runt på XXX\'s profil',
  117. 'cookies.php' => 'Läser om cookies',
  118. 'news.php' => 'Läser nyheter',
  119. 'blog.php' => 'Läser i XXX\'s underbara blogg');
  120.  
  121. if ( in_array ( $_SERVER['PHP_SELF'], $actions ) )
  122. {
  123. $sql = "UPDATE `members` SET `action` = '" . $_SERVER['PHP_SELF'] . "' ";
  124. $sql .= "WHERE `id` = $_SESSION['sess_id'] LIMIT 1";
  125. }
  126. else
  127. {
  128. $sql = "UPDATE `members` SET `action` = 'Ehm?' ";
  129. $sql .= "WHERE `id` = $_SESSION['sess_id'] LIMIT 1";
  130. }
  131.  
  132. $query = mysql_query ($sql) or
  133. report_error ( $sql, 'sql', __FILE__, __LINE__ );
  134. }
  135. }
  136. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement