Advertisement
Guest User

Untitled

a guest
Jul 17th, 2015
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.22 KB | None | 0 0
  1. <?php
  2. //Тут задаём пароль
  3. $pass = '154575';
  4.  
  5. if (is_file('base.txt')) $all = json_decode(file_get_contents("base.txt"), 1);
  6. $logg = false;
  7.  
  8. if ($_POST['plus'] > 0) {
  9.     $all['total'] = $all['total'] + $_POST['plus'];
  10. }
  11. if ($_POST['minus'] > 0) {
  12.     $all['total'] = $all['total'] - $_POST['minus'];
  13. }
  14.  
  15. if ($_COOKIE['pass2'] == 'lg') {
  16.     $logg = true;
  17. }elseif ($_POST['pass'] == $pass) {
  18.     setcookie('pass2', 'lg');
  19.     $logg = true;
  20. }
  21.  
  22. ?><!DOCTYPE html>
  23. <html>
  24. <head>
  25.     <title>КАБИНЕТ</title>
  26.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  27. </head>
  28. <body>
  29. <?php
  30. if ($logg) {
  31.     echo '<p>Текущий промежуток длинной: <b>' . $all['total'] . '</b> дн.</p>';
  32.    
  33.     $start = & $all['start'];
  34.     if (!isset($start)) $start = date('Y-m-d H:i');
  35.     $seconds = time() - strtotime($start);
  36.     $dd = floor($seconds / 86400);
  37.     $hh = floor(($seconds - ($dd * 86400)) / 3600);
  38.     $hs = 24 - $hh;
  39.     $ds = $all['total'] - $dd - 1;
  40.  
  41.    
  42.  
  43.         echo 'Держимся от: ' . $start . ' \ ' . $dd . ' дн. ' . $hh . ' час.';
  44.        
  45.             echo ' \ осталось  <b>' . $ds . ' дн. ' . $hs . ' час.</b><br/><br/>';
  46.            
  47.             $dateDo = strtotime($start) + $all['total'] * 86400;
  48.            
  49.             $dayarr = array('понедельника', 'вторника', 'среды', 'четверга', 'пятницы', 'субботы', 'воскресенья');
  50.             $dayarr2 = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun');
  51.            
  52.             echo 'Держимся до: ' . str_replace($dayarr2, $dayarr, date('D, Y-m-d H:i:s', $dateDo)) . '<br><br>';
  53.  
  54.         echo '<b>Добавить</b><br>
  55.             <form method="post">
  56.                 <input name="plus" value="1"><input type="submit" value="OK">
  57.             </form><br>';
  58.  
  59.             echo '<b>Уменьшить</b><br>
  60.                 <form method="post">
  61.                 <input name="minus" value="1"><input type="submit" value="OK">
  62.             </form>';
  63.         file_put_contents("base.txt", json_encode($all));
  64.  
  65.    
  66. }
  67. ELSE {
  68.    
  69.     echo '  <form method="post">
  70.                 <input type="password" name="pass"><input type="submit" value="OK">
  71.             </form>';
  72. }
  73. ?>
  74. </body>
  75. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement