Facebook
From Fargot, 3 Years ago, written in PHP.
Embed
Download Paste or View Raw
Hits: 155
  1. <?php
  2.     session_start();
  3.     unset($_POST['hide_history']);
  4. //    unset($_POST['show_history']);
  5.     echo '<body style="background-color:#282C34; color:#AFB1B3;"></body>';
  6.     if($_SESSION['visits']){
  7.         $visits = &$_SESSION['visits'];
  8.         $visits[] = [time(), $_SERVER['SCRIPT_NAME']];
  9.     }else{
  10.         $_SESSION['visits'] = [[time(), $_SERVER['SCRIPT_NAME']]];
  11.         $visits = &$_SESSION['visits'];
  12.     }
  13.  
  14.     $i = 1;
  15.     echo 'Всего вы посетили наш сайт: '.count($visits).'раз <hr style="width: 340px; margin-left: 0px;"/>';
  16.     foreach($visits as $visit) {
  17.         function dateStr($what_time, $time,$site){
  18.             if (getdate($time)['mon'] == 1) $month = "января ";
  19.             elseif (getdate($time)['mon'] == 2) $month = "февраля ";
  20.             elseif (getdate($time)['mon'] == 3) $month = "марта";
  21.             elseif (getdate($time)['mon'] == 4) $month = "апреля ";
  22.             elseif (getdate($time)['mon'] == 5) $month = "мая ";
  23.             elseif (getdate($time)['mon'] == 6) $month = "июня ";
  24.             elseif (getdate($time)['mon'] == 7) $month = "июля ";
  25.             elseif (getdate($time)['mon'] == 8) $month = "августа";
  26.             elseif (getdate($time)['mon'] == 9) $month = "сентября ";
  27.             elseif (getdate($time)['mon'] == 10) $month = "октября ";
  28.             elseif (getdate($time)['mon'] == 11) $month = "ноября ";
  29.             elseif (getdate($time)['mon'] == 12) $month = "декабря ";
  30.             else $month = false;
  31.             $date = getdate($time);
  32.             echo $what_time.' посещение было '.$date[mday].'го '.$month.$date[year].' года, в '.$date[hours].':'.$date[minutes].':'.$date[seconds].' на сайте '.$site.'<hr style="width: 700px; margin-left: 0px;"/>';
  33.         }
  34.         dateStr('Первое', $visit[0],$visit[1]);
  35.         dateStr('Последнее', $visits[count($visits) - 2][0], $visit[1]);
  36.         echo <<<HTML
  37.         <form method="post">
  38.             <input type="submit" class="button" value="Показать историю посещений" name="show_history">
  39.         </form>
  40.         <form method="post">
  41.             <input type="submit" class="button" value="Скрыть историю посещений" name="hide_history">
  42.         </form>
  43. HTML;
  44.         if($_POST[show_history]){
  45.             foreach($visits as $elem){
  46.                 dateStr($i.'ое', $elem[0], $elem[1]);
  47.             }
  48.             array_pop($visits);
  49.             array_pop($visits);
  50.         }
  51.         elseif($_POST[hide_history]) array_pop($visits);
  52.         $i++;
  53.         echo $visits[9][1].'<br/>';
  54.     }
  55.