Advertisement
Al_Faqun

/Phenya/tpl_citations.php

Aug 21st, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.44 KB | None | 0 0
  1. <?php for ($i = 0; $i < $count; $i++):  //для каждой из выбранных цитат ?>
  2. <?php switch ($i): ?>
  3. <?php       case 0:
  4.             //определяем расположение по горизонтали
  5.             $num = 10 + mt_rand(0, 5);
  6.             $left = "left: $num" . '%';
  7.             //по вертикали
  8.             $num = 10 + mt_rand(0, 5);
  9.             $top = "top: $num" . '%';
  10.             //и цвет
  11.             $num = dechex(mt_rand(hexdec('000000'), hexdec('ffffff')));
  12.             $color = 'color: #' . "$num";
  13.             break;
  14.         case 1:
  15.             $num = 10 + mt_rand(0, 5);
  16.             $left = "right: $num" . '%';
  17.            
  18.             $num = 25 + mt_rand(0, 5);
  19.             $top = "top: $num" . '%';
  20.            
  21.             $num = dechex(mt_rand(hexdec('000000'), hexdec('ffffff')));
  22.             $color = 'color: #' . "$num";
  23.             break;
  24.         case 2:
  25.             $num = 10 + mt_rand(0, 5);
  26.             $left = "left: $num" . '%';
  27.            
  28.             $num = 40 + mt_rand(0, 5);
  29.             $top = "top: $num" . '%';  
  30.            
  31.             $num = dechex(mt_rand(hexdec('000000'), hexdec('ffffff')));
  32.             $color = 'color: #' . "$num";
  33.             break;
  34.         case 3:
  35.             $num = 10 + mt_rand(0, 5);
  36.             $left = "right: $num" . '%';
  37.            
  38.             $num = 55 + mt_rand(0, 5);
  39.             $top = "top: $num" . '%';
  40.            
  41.             $num = dechex(mt_rand(hexdec('000000'), hexdec('ffffff')));
  42.             $color = 'color: #' . "$num";
  43.             break;
  44.         case 4:
  45.             $num = 10 + mt_rand(0, 5);
  46.             $left = "left: $num" . '%';
  47.            
  48.             $num = 70 + mt_rand(0, 5);
  49.             $top = "top: $num" . '%';
  50.            
  51.             $num = dechex(mt_rand(hexdec('000000'), hexdec('ffffff')));
  52.             $color = 'color: #' . "$num";
  53.             break;
  54.         case 5:
  55.             $num = 10 + mt_rand(0, 5);
  56.             $left = "right: $num" . '%';
  57.            
  58.             $num = 85 + mt_rand(0, 5);
  59.             $top = "top: $num" . '%';
  60.            
  61.             $num = dechex(mt_rand(hexdec('000000'), hexdec('ffffff')));
  62.             $color = 'color: #' . "$num";
  63.             break;
  64.         default:
  65.             $error = 'Incorrect number of quotes is processed!';
  66.             include $_SERVER['DOCUMENT_ROOT'] . '/error.html.php';
  67.             exit(); ?>
  68. <?php endswitch; ?>
  69.  
  70. <?php if (empty($citations[$i])):               //если список цитат пуст
  71.             $error = 'Invalid quote';
  72.             include $_SERVER['DOCUMENT_ROOT'] . '/error.html.php';
  73.             exit();
  74.         endif; ?>
  75.    
  76.     <!-- постим цитату с нужными стилями -->
  77.     <div style="position: absolute;
  78.                     <?php echo $top; ?>;
  79.                     <?php echo $left; ?>;
  80.                     <?php if ($color_on === true) echo $color; ?>;">
  81.         <p>«<?php echo htmlspecialchars($citations[$i], ENT_QUOTES, 'UTF-8'); ?>»</p>
  82.     </div>
  83. <?php endfor; ?>
  84. <?php ob_end_flush(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement