aboutsummaryrefslogtreecommitdiff
path: root/quote.php
blob: 8e08a3def9ccd78a64db7db12ae7ecae3229583e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php

/* Copyright Maximilian Möhring, 2013
Licensed under the GPL. Read LICENSE for more Information.*/

include('auth.php');
include("header.php");

$zufall = $_GET["id"];

/*__Datenbank___*/
$db = new SQLite3("../database/jg.db");
$rows = $db->query("SELECT count(*) as count FROM sprueche;");
$row = $rows->fetchArray();
$numRows = $row["count"];

if ($zufall == ""){
	$zufall  = mt_rand(1,$numRows);
}


$safe_zufall = SQLite3::escapeString("$zufall");
$ergebnis = $db->query("SELECT * FROM sprueche where id=$safe_zufall;");

echo"

<div id='content_container' align='center'>
        <br>
        <div class='kleineschrift'>
                <div class='ueberschrift'><p>JUNGE GEMEINDE ADLERSHOF</p></div>
        </div>
        <div id='container' align='center'>

<br><br><br>

<b>Zitat Nummer #$zufall</b><br><br><div id='bgcolor'>";


if (preg_match('/[0-9]/',$zufall)){	// I really need this hack to get the 404 when /[0-9][a-zA-Z]/ is happening. Bad PHP!
	if (preg_match('/[^0-9]/',$zufall)){
		$zufall = 0;
	}
}



if ($zufall > 0 && $zufall <= ($numRows)){
	while($row=$ergebnis->fetchArray()){
        	echo $row["spruch"];
	}
} else {
echo "\"Sorry, can't find the quote, but a cat is fine too, right?\"<br><br>
<pre>
      ,/|         _.--''^``-...___.._.,;
     /, \'.     _-'          ,--,,,--'''
    { \    `_-''       '    /}          
     `;;'            ;   ; ;            
 ._.--''     ._,,, _..'  .;.'           
  (,_....----'''     (,..--''           
</pre><br><br>
<i>404 - Eintrag nicht vorhanden.</i>";
}

echo "</div>

<br><br><br>
   -----------------------------------------------------------------
<div class='kleineschrift'><p>Es sind momentan <b><i>$numRows</i></b> Zitate in der Datenbank enthalten.</p>
Du suchst ein bestimmtes Zitat? Gib hier dessen Nummer ein: <form method='get' action='quote.php' >
    <input name='id' type='text' size='2' maxlength='30'>
    <input type='submit' style='display:none'/>

  </form>
</div>

</div></div></div>
</body></html>";

?>