Advertisement
Faguss

Custom Map List Forum Stajnia Ogarów - MakeList

Jan 17th, 2016
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.65 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <HTML>
  3. <HEAD>
  4.     <META charset="UTF-8">
  5. </HEAD>
  6. <BODY>
  7. <PRE>
  8. <?php
  9.  
  10.     // Connect to the database
  11.     $link = mysqli_connect('localhost', 'username', 'password', 'database');
  12.     if (!$link)
  13.         die("Brak połączenia z bazą danych");
  14.  
  15.     mysqli_set_charset($link, 'utf8');
  16.  
  17.  
  18.     // Get number of records
  19.     $query = "
  20.     SELECT
  21.         COUNT(*) as number  
  22.        
  23.     FROM
  24.         StajniaCustom
  25.        
  26.     WHERE
  27.         ID NOT IN (SELECT ID FROM StajniaRemoved)
  28.     ";
  29.    
  30.     $result = mysqli_query($link, $query);
  31.     if (!$result)
  32.     {
  33.         echo mysql_errno($link);
  34.         mysqli_close($link);
  35.         exit;
  36.     };
  37.    
  38.     $row            = mysqli_fetch_assoc($result);
  39.     $numberOfMaps   = $row["number"];
  40.    
  41.     mysqli_free_result($result);
  42.    
  43. echo <<<koniec
  44. Dodatkowych map jest $numberOfMaps i łatwo się pogubić. Celem tej listy jest szybkie przypomnienie co jest czym żeby móc głosować świadomie.
  45.  
  46. [url=http://imgur.com/a/kI28J/layout/horizontal]Alternatywnie album imgur[/url] [size=2](forum ma ograniczenie do 100 obrazków)[/size]
  47.  
  48.  
  49. koniec;
  50.  
  51.  
  52.  
  53.  
  54.  
  55.    
  56.     // Set variables
  57.     $imgShown       = 0;        // how many thumbnails were printed out
  58.     $imgNumber      = 0;        // total number of images pulled from db
  59.     $imgLimit       = 2;        // thumbnail limit per map
  60.     $TitleColors    = array     // colors for given map types
  61.     (
  62.         "koth"  =>  "1ad399",
  63.         "dom"   =>  "ff8c00",
  64.         "ctf"   =>  "dda0dd",
  65.         "cp"    =>  "ff8c00",
  66.         "pl"    =>  "008000"
  67.     );
  68.  
  69.     $lastName   = "";
  70.     $imgCurrent = 0;
  71.  
  72.  
  73.     // Query table
  74.     $query = "
  75.     SELECT
  76.         StajniaCustom.Name,
  77.         StajniaCustom.Description,
  78.         StajniaLinks.Link,
  79.         StajniaLinks.Include
  80.        
  81.     FROM
  82.         StajniaCustom LEFT JOIN StajniaLinks  
  83.         ON
  84.         StajniaCustom.ID = StajniaLinks.ID
  85.        
  86.     WHERE
  87.         StajniaCustom.ID NOT IN (SELECT ID FROM StajniaRemoved)
  88.    
  89.     ORDER BY
  90.         StajniaCustom.Sort ASC
  91.     ";
  92.    
  93.     $result = mysqli_query($link, $query);
  94.     if (!$result)
  95.     {
  96.         echo mysql_errno($link);
  97.         mysqli_close($link);
  98.         exit;
  99.     };
  100.    
  101.  
  102.  
  103.     // Process data
  104.     while($row = mysqli_fetch_assoc($result))
  105.     {
  106.         // Output map title and description
  107.         if ($row["Name"] != $lastName)
  108.         {
  109.             $lastName       = $row["Name"];
  110.             $imgCurrent     = 0;
  111.             $ColorCurrent   = $TitleColors[ substr($row["Name"],0,strpos($row["Name"], "_")) ];
  112.  
  113.             // Unknown map type
  114.             if ($ColorCurrent == NULL)
  115.                 $ColorCurrent = "FFFFFF";
  116.                    
  117.             echo "\n\n[size=6][b][color=#$ColorCurrent]{$row["Name"]}";
  118.             echo "[/color][/b][/size]";        
  119.            
  120.             if ($row["Description"] != "")
  121.             {
  122.                 echo "[size=2] - {$row["Description"]}";
  123.                 echo "[/size]";
  124.             };
  125.            
  126.             echo "\n\n";
  127.         };
  128.        
  129.        
  130.         // Output thumbnail
  131.         if ($row["Link"])
  132.         {
  133.             if ($row["Include"]  &&  $imgCurrent<$imgLimit)
  134.             {
  135.                 echo "[url=http://i.imgur.com/{$row["Link"]}.jpg][img=http://i.imgur.com/{$row["Link"]}b.jpg][/url] ";
  136.                 $imgShown++;
  137.                 $imgCurrent++;
  138.             };
  139.        
  140.             $imgNumber++;
  141.         }
  142.         else
  143.             echo "Jeszcze w nią nie grałem";
  144.     };
  145.    
  146.     //echo "\n\nTotal number of images: $imgNumber\nImages displayed:$imgShown\n\n";
  147.    
  148.     mysqli_free_result($result);
  149.     mysqli_close($link);
  150. ?>
  151.  
  152.  
  153.  
  154. [size=6][b]Moja ocena[/b][/size] [size=2](może ulec zmianie ponieważ w niektóre mapy za mało grałem)[/size]
  155.  
  156. [b]Chętnie zagram:[/b]
  157. [indent=1]croissant, stoneyridge, gydan, biodome, collis, mojave, follower, metalworks, antiquity
  158. angkor, great heights, swiftwater, millstone, boundary, quagmire, manngrove, 5curve
  159. converge, vector, garbage day[/indent]
  160.  
  161. [b]Raczej nie:[/b]
  162. [indent=1]mudwater - labirynt
  163. auriferous - długa, ciasna i pokręcona
  164. syphon - zbyt dużo otwartej przestrzeni
  165. cloudburst - trochę pusta
  166. coalplant - trochę pusto w środku[/indent]
  167.  
  168. Reszta "może być".
  169.  
  170. [url=http://goo.gl/forms/yv26e6mJ2S]Ankieta[/url]
  171. </PRE>
  172. </BODY>
  173. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement