3 include_once('extern/rfc822.php');
5 function warning($text)
8 $ret = '<p class="warn"><img src="'.$cfg['basepath'].
9 'achtung.gif" width="33" height="32" alt="Achtung!"> ';
10 $ret .= $text .'</p>';
14 function information($text)
17 $ret = '<p class="info"><img src="'.$cfg['basepath'].
18 'information.gif" width="31" height="31" alt="Info"> ';
19 $ret .= $text .'</p>';
28 $ret .= '<!DOCTYPE html">';
29 $ret .= '<html lang="de">';
31 if (isset($zlist['newspaper']))
32 $ret .= sprintf('<title>Zeitungsliste: %s</title>', $zlist['newspaper']);
33 elseif (isset($zlist['tag']))
34 $ret .= sprintf('<title>Zeitungsliste: Tag %s</title>', $zlist['tag']);
36 $ret .= '<title>Zeitungsliste</title>';
37 header('Content-Type: text/html; charset=UTF-8');
38 $ret .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
39 $ret .= '<meta name="Author" content="joey@infodrom.org (Joey Schulze)">';
40 $ret .= '<meta name="Language" content="de">';
42 if ($zlist['page'] == 'index') {
43 $ret .= '<meta name="Keywords" content="Zeitung, Zeitungen, Liste, Zeitungsliste, Online-Zeitungen, Zeitungen im Web, Forum, Community, '.
44 'Liste aller Zeitungen">';
45 $ret .= sprintf('<link rel="alternate" type="application/rss+xml" title="Zeitungen" href="%szeitungen.rdf">', $cfg['basepath']);
46 } elseif ($cfg['dir'] == 'zeitung') {
47 $ret .= '<meta name="Keywords" content="Zeitung, Zeitungsliste, Online-Zeitung, Zeitung im Web, Forum, Community, '.
48 $zlist['newspaper'] . ', ' . $zlist['city'] . '">';
52 $ret .= '<meta name="Robots" content="index,follow">';
53 $ret .= '<meta name="Copyright" content="(c) 2008 Information & Consulting">';
54 $ret .= sprintf('<link href="%smain.css" rel="stylesheet" type="text/css">', $cfg['basepath']);
55 $ret .= sprintf('<link rel="icon" href="%sfavicon.ico" type="image/x-icon">', $cfg['basepath']);
56 $ret .= sprintf('<link rel="shortcut icon" href="%sfavicon.ico" type="image/x-icon">', $cfg['basepath']);
58 if (isset($zlist['redirect']))
59 $ret .= sprintf('<meta http-equiv="refresh" content="7; URL=%s%s">',
60 $cfg['home'], $zlist['redirect']);
64 if (javascript_ok()) {
65 $ret .= sprintf('<script type="text/javascript" src="%szlist.js"></script>', $cfg['basepath']);
66 $ret .= sprintf('<script type="text/javascript">var zlist_urlbase = "%s";</script>', $cfg['basepath']);
70 $ret .= '<div class="banner"><h1 class="none"><a href="http://www.debian.org/">Zeitungen online im Netz</a></h1></div>';
72 $ret .= '<div class="status">';
74 $ret .= '<div class="homestatus"><a href="'.$cfg['home'].'">Home</a>';
75 if ($cfg['path'] != 'contact.html')
76 $ret .= sprintf(' <a href="%scontact.html">Kontakt</a>', $cfg['basepath']);
77 if (is_admin() && $cfg['path'] != 'admin.html')
78 $ret .= sprintf(' <a href="%sadmin/index.html">Admin</a>', $cfg['basepath']);
80 $ret .= sprintf(' <a href="%ssitemap.html">Sitemap</a>', $cfg['basepath']);
84 if ($cfg['path'] != "logout.html") {
85 $ret .= '<div class="logstatus">';
86 if ($cfg['path'] != "options.html")
87 $ret .= sprintf('<a href="%soptions.html">Einstellungen</a> ',
89 $ret .= sprintf('<a href="%slogout.html">Abmelden</a>',
94 if (($cfg['path'] != "login.html" && $cfg['path'] != "activate.html") ||
95 ($cfg['path'] == 'login.html' && isset($_POST['sendnew'])))
96 $ret .= sprintf('<div class="logstatus"><a href="%slogin.html">Anmelden</a></div>',
99 $ret .= sprintf('<div class="userstatus">%s</div>', userstatus());
102 $ret .= '<div class="page">';
103 if ($_SERVER['SERVER_NAME'] == 'www.zeitungsliste.de' && javascript_ok())
104 $ret .= "\n" . load_template('addsense.js');
109 function layout_page($body)
113 $ret = '<div class="info">';
114 if (is_array($zlist['info'])) {
115 include_once('info.inc');
116 foreach ($zlist['info'] as $func)
122 $ret .= '<div class="main">';
128 function layout_bookmarks($rel, $title)
132 // Mehr auf http://www.bikeshops.de/Bikeshops/BikeGuide/BikeGuideWertgarantie.asp
134 array('text' => 'Delicious',
135 'icon' => 'link_delicious.gif',
136 'link' => 'http://del.icio.us/post?v=4&noui&url=@url@&title=@title@'),
137 array('text' => 'Digg it',
138 'icon' => 'link_digg.gif',
139 'link' => 'http://digg.com/submit?phase=2&url=@url@&title=@title@'),
140 array('text' => 'folk it',
141 'icon' => 'link_folkd.gif',
142 'link' => 'http://www.folkd.com/submit/@url@'),
143 array('text' => 'Reddit',
144 'icon' => 'link_reddit.gif',
145 'link' => 'http://reddit.com/submit?url=@url@&title=@title@'),
146 array('text' => 'Spurl',
147 'icon' => 'link_spurl.gif',
148 'link' => 'http://www.spurl.net/spurl.php?url=@url@&title=@title@'),
149 array('text' => 'StumbleUpon',
150 'icon' => 'link_stumbleupon.gif',
151 'link' => 'http://www.stumbleupon.com/submit?url=@url@&title=@title@'),
152 array('text' => 'linksilo.de',
153 'icon' => 'link_linksilo.gif',
154 'link' => 'http://www.linksilo.de/index.php?area=bookmarks&func=bookmark_new&addurl=@url@&addtitle=@title@'),
157 $url = $cfg['home'] . $rel;
159 $ret = '<div class="social_bookmarks">Lesezeichen: ';
161 foreach ($bookmarks as $bm) {
162 $ret .= sprintf('<a href="%s" title="%s"><img src="%sbookmarks/%s" width="16" height="16" alt="%s" name="%s" border="0"></a>',
163 str_replace(array('@url@', '@title@'),
164 array(htmlspecialchars($url), htmlspecialchars($title)),
167 $cfg['basepath'], $bm['icon'], $bm['text'], $bm['text']);
176 * Add links to the main page for web spider so that they get the entire database
178 function layout_sitemap()
183 header('Location: ' . $cfg['home']);
185 $ret = '<h1>Sitemap der Zeitungsliste</h1>';
187 $query = 'SELECT tagname FROM tags ORDER BY lower(tagname)';
189 $sth = db_query($query);
191 if ($sth !== false && pg_num_rows($sth) > 0) {
192 $ret .= '<h3>User-Tags (Merkmale)</h3>';
193 $ret .= '<ul class="gold">';
195 for ($i=0; $i < pg_num_rows($sth); $i++) {
196 $row = pg_fetch_array($sth, $i);
198 $ret .= sprintf('<li><a href="%stag/%s.html">%s</a></li>',
199 $cfg['basepath'], urlencode($row['tagname']),
206 $query = 'SELECT id,name,city FROM zeitungen WHERE deleted IS false ORDER BY name';
208 $sth = db_query($query);
210 if ($sth !== false && pg_num_rows($sth) > 0) {
211 $ret .= '<h3>Zeitungen und Magazine</h3>';
212 $ret .= '<ul class="gold">';
213 for ($i=0; $i < pg_num_rows($sth); $i++) {
214 $row = pg_fetch_array($sth, $i);
216 $ret .= sprintf('<li><a href="%szeitung/%d.html">%s</a>, %s</li>',
217 $cfg['basepath'], $row['id'], $row['name'], $row['city']);
222 $query = 'SELECT id,topic FROM topics ORDER BY created';
224 $sth = db_query($query);
226 if ($sth !== false && pg_num_rows($sth) > 0) {
227 $ret .= '<h3>Diskussionen</h3>';
228 $ret .= '<ul class="gold">';
229 for ($i=0; $i < pg_num_rows($sth); $i++) {
230 $row = pg_fetch_array($sth, $i);
232 $ret .= sprintf('<li><a href="%stopic/%d.html">%s</a></li>',
233 $cfg['basepath'], $row['id'], $row['topic']);
241 function layout_showpaper($archived=false)
245 if (!isset($_GET['zeitung']) || !is_numeric($_GET['zeitung']))
246 $ret = warning('Keine Zeitung oder Magazin gefunden.');
248 $zid = $_GET['zeitung'];
249 $details = format_newspaper($zid, true);
250 if ($details === false)
251 $ret .= warning('Keine Zeitung oder Magazin gefunden.');
253 $zlist['zid'] = $zid;
257 $ret .= format_board($zid);
259 $ret .= format_board($zid, $archived);
261 $ret .= layout_bookmarks(sprintf('zeitung/%d.html', $zid), $zlist['newspaper']);
268 function layout_archive()
273 if (!isset($_GET['archiv']) || !is_numeric($_GET['archiv']))
274 $ret = warning('Keine Zeitung oder Magazin gefunden.');
276 $zid = $_GET['archiv'];
277 $details = format_newspaper($zid, true);
278 if ($details === false)
279 $ret .= warning('Keine Zeitung oder Magazin gefunden.');
281 $zlist['zid'] = $zid;
284 $query = sprintf('SELECT id,topic FROM topics ' .
285 'WHERE zeitung = %d ORDER BY created DESC',
288 $sth = db_query($query);
290 if (!$sth || pg_num_rows ($sth) == 0)
291 $ret .= warning('Kein Archiv gefunden.');
293 $ret .= '<p><ul class="gold">';
294 for ($i=0; $i < pg_num_rows ($sth); $i++) {
295 $row = pg_fetch_array($sth, $i);
296 $ret .= sprintf('<li><a href="%stopic/%d.html">%s</a></li>',
297 $cfg['basepath'], $row['id'], $row['topic']);
307 function layout_showtag()
312 if (!isset($_GET['tag']))
313 $ret = warning('Keine derartiges Merkmal gefunden.');
315 $tagname = $_GET['tag'];
316 $ret .= '<h3>Merkmal <span class="tag">' . $tagname . '</span></h3>';
318 $query = sprintf("SELECT zeitungen.id,name,count(uid) AS count FROM zeitungen " .
319 "JOIN zeitung_tags ON zeitung = id " .
320 "JOIN tags ON tag = tags.id " .
321 "WHERE tagname = '%s' " .
322 "GROUP BY zeitungen.id,name ORDER BY count DESC",
323 pg_escape_string($tagname));
325 $sth = db_query($query);
327 $zlist['tag'] = htmlspecialchars($tagname);
328 if (!$sth || pg_num_rows ($sth) == 0) {
329 $ret .= warning('Keine Zeitungen oder Magazine mit diesem Merkmal gefunden.');
330 unset($zlist['newspaper']);
332 $headlines = array('Mäßige','Mittelmäßige','Gute','Häufige','Häufigste');
335 for ($i=0; $i < pg_num_rows ($sth); $i++) {
336 $row = pg_fetch_array ($sth, $i);
337 $tag = tag_class($row['count']);
339 if ($oldtag != $tag) {
342 $ret .= sprintf('<h3 class="tag%d">%s Bewertungen</h3>', $tag, $headlines[$tag]);
343 $ret .= '<ul class="gold">';
347 $ret .= sprintf('<li><a href="%szeitung/%d.html">%s</a></li>',
348 $cfg['basepath'], $row['id'], $row['name'], $row['city']);
352 $ret .= layout_bookmarks(sprintf('tag/%s.html', htmlspecialchars($tagname)), 'Merkmal '.$tagname);
359 function layout_topic()
363 if (!isset($_GET['topic']) || !is_numeric($_GET['topic']))
364 $ret = warning('Keine passende Diskussion gefunden.');
366 $discussion = format_topic($_GET['topic']);
368 if (isset($zlist['zid'])) {
369 $ret .= format_newspaper($zlist['zid'], true);
371 if ($zlist['archived'])
372 $ret .= '<h3>Abgeschlossene Diskussion</h3>';
374 $ret .= '<h3>Diskussion</h3>';
377 if (isset($zlist['zid']))
378 $ret .= layout_bookmarks(sprintf('topic/%d.html', $zlist['zid']), $zlist['topic']);
386 header("HTTP/1.0 404 Not Found");
388 return warning('Diese Seite existiert nicht!');
391 function contact_send($topic, $email, $body)
396 if (!empty($email)) {
397 if (isset($_SESSION['uid']))
398 $header[] = sprintf('Reply-To: %s <%s>',
399 strlen($_SESSION['realname'])?$_SESSION['realname']:$_SESSION['nickname'],
402 $header[] = 'Reply-To: ' . $email;
406 ."HTTP_USER_AGENT: " . $_SERVER['HTTP_USER_AGENT'] . "\n"
407 ."REMOTE_ADDR : " . $_SERVER['REMOTE_ADDR'] . "\n";
409 if (isset($_SESSION['uid']))
410 $body .= "Nickname : " . $_SESSION['nickname'] . "\n";
412 $subject = str_replace(array('<', '>', '(', ')', '$', '/', '%', '\\', '#', ';', '&'), '', $topic);
414 sendmail($cfg['mailto'], '', $subject, $body, $header);
417 function process_contact()
419 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
420 if (empty($_POST['topic']))
421 $ret = warning('Sie haben keinen Titel für die Nachricht angegeben!');
422 elseif (empty($_POST['body']))
423 $ret = warning('Sie haben keinen Text der Nachricht angegeben!');
424 elseif (!empty($_POST['email']) && !is_valid_email_address($_POST['email']))
425 $ret = warning('Die angegebene Mail-Adresse ist ungültig.');
427 contact_send($_POST['topic'], $_POST['email'], $_POST['body']);
428 $ret = information('Die Nachricht wurde an den Chef geschickt.');
429 $ret .= '<p>Die Bearbeitung kann eine Weile dauern. Wenn Sie eine '.
430 'Antwort erwarten, sollte diese in den nächsten Tagen an die von '.
431 'Ihnen angegebene Adresse geschickt werden.</p>';
434 $replace = array('topic' => $_POST['topic'],
435 'email' => $_POST['email'],
436 'body' => $_POST['body']);
437 } elseif ($_SERVER['REQUEST_METHOD'] == 'GET') {
438 if (isset($_SESSION['email']))
439 $replace = array('email' => $_SESSION['email']);
444 return load_javascript('contact.js') . load_template('contact.html', $replace);