Guest User

/templates/tpl_citations

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