-
Notifications
You must be signed in to change notification settings - Fork 2
/
runden.xml.php
181 lines (162 loc) · 8.13 KB
/
runden.xml.php
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/*
* RSS-Erweiterung für Skrupel ist ©2006 by JANNiS und bansa.de.
* Alle Rechte vorbehalten (<- was bedeutet dieser Satz eigentlich?)
*
* Verbesserungsvorschläge im Skrupelforum (http://board.skrupel.de)
* oder an [email protected]
*
* Danke für's Downloaden und viel Spass beim Skrupeln ;-)
*/
//////////////////////
// Teil 1: Globales //
//////////////////////
$rss_root = 'http://'.$_SERVER['SERVER_NAME'].substr($_SERVER['SCRIPT_NAME'], 0, -25);
$rss_pubdate = date('D, d M Y H:i:s O');
$rss_name = 'nobody';
//Passwort ausgeklammert weil unnötig.
$rss_gibts = 0;
$rss_user = array();
$rss_error_start = '<html><head><title>Skrupel: RSS-Rundenstatus [[Fehler]]</title></head><body>';
$rss_error_ende = '</body></html>';
include dirname(__FILE__).'/../../inc.conf.php';
include dirname(__FILE__).'/../../inhalt/inc.hilfsfunktionen.php';
$rss_db = open_db();
if ($rss_db) {
// start: if ($rss_db)
if ($_GET['name']) {
$rss_name = $_GET['name'];
} else {
echo "$rss_error_start Kein Name angegeben. (Häng an die URL einfach ein "?name=DeinSkrupelUserName" an. Also: Fragezeichen-name-Gleich-SkrupelName.) $rss_error_ende";
exit;
}
$rss_zeiger = @mysql_query("SELECT * FROM skrupel_user where nick='$rss_name'");
$rss_anz = @mysql_num_rows($rss_zeiger);
$rss_user = @mysql_fetch_array($rss_zeiger);
if ($rss_anz != 1) {
echo "$rss_error_start Name nicht gefunden. Bitte überprüfe nochmal die Schreibweise. $rss_error_ende";
exit;
} else {
header('Content-type:text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
}
$rss_spieler_id = $rss_user['id'];
$rss_zeiger2 = @mysql_query("SELECT * FROM skrupel_spiele where (spieler_1=$rss_spieler_id or spieler_2=$rss_spieler_id or spieler_3=$rss_spieler_id or spieler_4=$rss_spieler_id or spieler_5=$rss_spieler_id or spieler_6=$rss_spieler_id or spieler_7=$rss_spieler_id or spieler_8=$rss_spieler_id or spieler_9=$rss_spieler_id or spieler_10=$rss_spieler_id)");
$rss_anz2 = @mysql_num_rows($rss_zeiger2);
// ende: if ($rss_db)
} else {
echo "$rss_error_start Verbindung zur Datenbank konnte nicht aufgebaut werden. Versuch es später nochmal oder informiere deinen Skrupeladmin. $rss_error_ende";
exit;
}
///////////////////////
// Teil 2: RSS-Start //
///////////////////////
?>
<rss version="2.0">
<channel>
<title>Skrupel - Rundenstatus</title>
<link><?php echo $rss_root; ?></link>
<description>Hier sieht man den Rundenstatus aller Spiele auf Skrupel, an denen <?php echo $rss_user['nick']; ?> teilnimmt.</description>
<language>de-de</language>
<copyright>IceFlame.net | RSS-Extension for Skrupel, Copyright ©2006 by JANNiS and bansa.de</copyright>
<pubDate><?php echo $rss_pubdate; ?></pubDate>
<image>
<url><?php echo $rss_root.'bilder/logo.png'; ?></url>
<title>Spaze</title>
<link><?php echo $rss_root; ?></link>
</image>
<?php
/////////////////////////
// Teil 3: Nachrichten //
/////////////////////////
while ($rss_spiele = @mysql_fetch_array($rss_zeiger2)) {
if ($rss_spiele['spieler_1'] == $rss_user['id']) {
$rss_spieler = 1;
}
if ($rss_spiele['spieler_2'] == $rss_user['id']) {
$rss_spieler = 2;
}
if ($rss_spiele['spieler_3'] == $rss_user['id']) {
$rss_spieler = 3;
}
if ($rss_spiele['spieler_4'] == $rss_user['id']) {
$rss_spieler = 4;
}
if ($rss_spiele['spieler_5'] == $rss_user['id']) {
$rss_spieler = 5;
}
if ($rss_spiele['spieler_6'] == $rss_user['id']) {
$rss_spieler = 6;
}
if ($rss_spiele['spieler_7'] == $rss_user['id']) {
$rss_spieler = 7;
}
if ($rss_spiele['spieler_8'] == $rss_user['id']) {
$rss_spieler = 8;
}
if ($rss_spiele['spieler_9'] == $rss_user['id']) {
$rss_spieler = 9;
}
if ($rss_spiele['spieler_10'] == $rss_user['id']) {
$rss_spieler = 10;
}
$rss_spiel = $rss_spiele['name'];
$rss_fehlt = '';
$rss_fehlt_anz = 0;
$rss_i = 1;
while ($rss_i <= 10) {
if ($rss_i == $rss_spieler) {
} elseif ($rss_spiele['spieler_'.$rss_i.'_zug'] == 0 && $rss_spiele['spieler_'.$rss_i] != 0) {
$rss_zeiger3 = @mysql_query('SELECT * FROM skrupel_user where id='.$rss_spiele['spieler_'.$rss_i]);
$rss_fehlt_user = @mysql_fetch_array($rss_zeiger3);
$rss_fehlt_anz++;
$rss_fehlt .= $rss_fehlt_user['nick'].', ';
}
$rss_i++;
}
if ($rss_fehlt != '') {
$rss_fehlt = substr($rss_fehlt, 0, -2);
}
$rss_autotick = $rss_spiele['lasttick'] + ($rss_spiele['autozug'] * 3600);
$rss_autotick_tag = strftime('%d.%m.%Y', ($rss_spiele['lasttick'] > 0 ? $rss_spiele['lasttick'] + ($rss_spiele['autozug'] * 60 * 60) : $rss_spiele['start'] + ($rss_spiele['autozug'] * 60 * 60)));
$rss_autotick_zeit = strftime('%T', ($rss_spiele['lasttick'] > 0 ? $rss_spiele['lasttick'] + ($rss_spiele['autozug'] * 60 * 60) : $rss_spiele['start'] + ($rss_spiele['autozug'] * 60 * 60)));
if ($rss_spiele['phase'] == 0) {
if ($rss_spiele['spieler_'.$rss_spieler.'_zug'] == 0) {
// if: Zug nicht abgeschlossen
?>
<item>
<title><?php echo $rss_spiel; ?>: Zug noch nicht abgeschlossen!</title>
<description>Im Spiel "<?php echo $rss_spiel; ?>" hast du deinen Zug noch nicht abgeschlossen<?php if ($rss_fehlt_anz >= 2): ?>. Dabei bist du aber nicht der einzige, ausser dir gibt es noch <?php echo $rss_fehlt_anz; ?> weitere User, welche ihren Zug noch nicht gemacht haben: <?php echo $rss_fehlt; ?>.<?php elseif ($rss_fehlt_anz == 1): ?>. Ausser dir fehlt er auch noch von <?php echo $rss_fehlt; ?>.<?php else: ?>, du bist der einzige, von dem er noch fehlt!<?php endif; ?><?php if ($rss_spiele['autozug'] != 0): ?><?php if ($rss_autotick >= time()): ?> Du hast noch Zeit bis zum Autotick am <?php echo $rss_autotick_tag; ?> um <?php echo $rss_autotick_zeit; ?> Uhr.<?php else: ?> Leider liegt die Autotick-Zeit bereits seit dem <?php echo $rss_autotick_tag; ?> um <?php echo $rss_autotick_zeit; ?> in der Vergangenheit, beim Login beginnt also bereits die neue Runde. Dein Zug ist also verloren.<?php endif; ?><?php endif; ?></description>
<link><?php echo $rss_root; ?></link>
<author>Skrupel Tribute-Compilation <<?php echo $absenderemail; ?>></author>
</item>
<?php
} elseif ($rss_spiele['spieler_'.$rss_spieler.'_zug'] == 1 && ($rss_autotick >= time() || $rss_spiele['autotick'] == 0)) {
// if: Zug abgeschlossen, Autotick aus oder in Zukunft
?>
<item>
<title><?php echo $rss_spiel; ?>: Zug abgeschlossen!</title>
<description>Im Spiel "<?php echo $rss_spiel; ?>" hast du deinen Zug bereits abgeschlossen<?php if ($rss_fehlt_anz >= 2): ?>, im Gegensatz zu <?php echo $rss_fehlt_anz; ?> anderen Usern: <?php echo $rss_fehlt; ?>. <?php else: ?>. Allerdings hat <?php echo $rss_fehlt; ?> das noch nicht gemacht.<?php endif; ?><?php if ($rss_spiele['autozug'] != 0): ?> Der Autotick läuft am <?php echo $rss_autotick_tag; ?> um <?php echo $rss_autotick_zeit; ?> Uhr.<?php endif; ?></description>
<link><?php echo $rss_root; ?></link>
<author>Skrupel Tribute-Compilation <<?php echo $absenderemail; ?>></author>
</item>
<?php
} else {
// if: Zug abgeschlossen, Autotick an und in Vergangenheit
?>
<item>
<title><?php echo $rss_spiel; ?>: Autotick aktivierbar!</title>
<description>Im Spiel "<?php echo $rss_spiel; ?>" kannst du den Autotick auslösen. <?php if ($rss_fehlt_anz >= 2): ?>Damit ist dann jedoch der Zug von <?php echo $rss_fehlt_anz; ?> Usern vorloren: <?php echo $rss_fehlt; ?>.<?php else: ?>Damit ist jedoch der Zug von <?php echo $rss_fehlt; ?> verloren.<?php endif; ?>Der Autotick ist seit dem <?php echo $rss_autotick_tag; ?> um <?php echo $rss_autotick_zeit; ?> Uhr bereit zum auslösen.</description>
<link><?php echo $rss_root; ?></link>
<author>Skrupel Tribute-Compilation <<?php echo $absenderemail; ?>></author>
</item>
<?php
}
}
}
///////////////////
// Teil 4: Ende! //
///////////////////
?>
</channel>
</rss>