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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
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 $ret .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
38 $ret .= '<meta name="Author" content="joey@infodrom.org (Joey Schulze)">';
39 $ret .= '<meta name="Language" content="de">';
41 if ($zlist['page'] == 'index') {
42 $ret .= '<meta name="Keywords" content="Zeitung, Zeitungen, Liste, Zeitungsliste, Online-Zeitungen, Zeitungen im Web, Forum, Community, '.
43 'Liste aller Zeitungen">';
44 $ret .= sprintf('<link rel="alternate" type="application/rss+xml" title="Zeitungen" href="%szeitungen.rdf">', $cfg['basepath']);
45 } elseif ($cfg['dir'] == 'zeitung') {
46 $ret .= '<meta name="Keywords" content="Zeitung, Zeitungsliste, Online-Zeitung, Zeitung im Web, Forum, Community, '.
47 $zlist['newspaper'] . ', ' . $zlist['city'] . '">';
51 $ret .= '<meta name="Robots" content="index,follow">';
52 $ret .= '<meta name="Copyright" content="(c) 2008 Information & Consulting">';
53 $ret .= sprintf('<link href="%smain.css" rel="stylesheet" type="text/css">', $cfg['basepath']);
54 $ret .= sprintf('<link rel="icon" href="%sfavicon.ico" type="image/x-icon">', $cfg['basepath']);
55 $ret .= sprintf('<link rel="shortcut icon" href="%sfavicon.ico" type="image/x-icon">', $cfg['basepath']);
57 if (isset($zlist['redirect']))
58 $ret .= sprintf('<meta http-equiv="refresh" content="7; URL=%s%s">',
59 $cfg['home'], $zlist['redirect']);
63 if (javascript_ok()) {
64 $ret .= sprintf('<script type="text/javascript" src="%szlist.js"></script>', $cfg['basepath']);
65 $ret .= sprintf('<script type="text/javascript">var zlist_urlbase = "%s";</script>', $cfg['basepath']);
69 $ret .= '<div class="banner"><h1 class="none"><a href="http://www.debian.org/">Zeitungen online im Netz</a></h1></div>';
71 $ret .= '<div class="status">';
73 $ret .= '<div class="homestatus"><a href="'.$cfg['home'].'">Home</a>';
74 if ($cfg['path'] != 'contact.html')
75 $ret .= sprintf(' <a href="%scontact.html">Kontakt</a>', $cfg['basepath']);
76 if (is_admin() && $cfg['path'] != 'admin.html')
77 $ret .= sprintf(' <a href="%sadmin/index.html">Admin</a>', $cfg['basepath']);
79 $ret .= sprintf(' <a href="%ssitemap.html">Sitemap</a>', $cfg['basepath']);
83 if ($cfg['path'] != "logout.html") {
84 $ret .= '<div class="logstatus">';
85 if ($cfg['path'] != "options.html")
86 $ret .= sprintf('<a href="%soptions.html">Einstellungen</a> ',
88 $ret .= sprintf('<a href="%slogout.html">Abmelden</a>',
93 if (($cfg['path'] != "login.html" && $cfg['path'] != "activate.html") ||
94 ($cfg['path'] == 'login.html' && isset($_POST['sendnew'])))
95 $ret .= sprintf('<div class="logstatus"><a href="%slogin.html">Anmelden</a></div>',
98 $ret .= sprintf('<div class="userstatus">%s</div>', userstatus());
101 $ret .= '<div class="page">';
102 if ($_SERVER['SERVER_NAME'] == 'www.zeitungsliste.de' && javascript_ok())
103 $ret .= "\n" . load_template('addsense.js');
108 function layout_page($body)
112 $ret = '<div class="info">';
113 if (is_array($zlist['info'])) {
114 include_once('info.inc');
115 foreach ($zlist['info'] as $func)
121 $ret .= '<div class="main">';
127 function layout_bookmarks($rel, $title)
131 // Mehr auf http://www.bikeshops.de/Bikeshops/BikeGuide/BikeGuideWertgarantie.asp
133 array('text' => 'Delicious',
134 'icon' => 'link_delicious.gif',
135 'link' => 'http://del.icio.us/post?v=4&noui&url=@url@&title=@title@'),
136 array('text' => 'Digg it',
137 'icon' => 'link_digg.gif',
138 'link' => 'http://digg.com/submit?phase=2&url=@url@&title=@title@'),
139 array('text' => 'folk it',
140 'icon' => 'link_folkd.gif',
141 'link' => 'http://www.folkd.com/submit/@url@'),
142 array('text' => 'Reddit',
143 'icon' => 'link_reddit.gif',
144 'link' => 'http://reddit.com/submit?url=@url@&title=@title@'),
145 array('text' => 'Spurl',
146 'icon' => 'link_spurl.gif',
147 'link' => 'http://www.spurl.net/spurl.php?url=@url@&title=@title@'),
148 array('text' => 'StumbleUpon',
149 'icon' => 'link_stumbleupon.gif',
150 'link' => 'http://www.stumbleupon.com/submit?url=@url@&title=@title@'),
151 array('text' => 'linksilo.de',
152 'icon' => 'link_linksilo.gif',
153 'link' => 'http://www.linksilo.de/index.php?area=bookmarks&func=bookmark_new&addurl=@url@&addtitle=@title@'),
156 $url = $cfg['home'] . $rel;
158 $ret = '<div class="social_bookmarks">Lesezeichen: ';
160 foreach ($bookmarks as $bm) {
161 $ret .= sprintf('<a href="%s" title="%s"><img src="%sbookmarks/%s" width="16" height="16" alt="%s" name="%s" border="0"></a>',
162 str_replace(array('@url@', '@title@'),
163 array(htmlspecialchars($url), htmlspecialchars($title)),
166 $cfg['basepath'], $bm['icon'], $bm['text'], $bm['text']);
175 * Add links to the main page for web spider so that they get the entire database
177 function layout_sitemap()
182 header('Location: ' . $cfg['home']);
184 $ret = '<h1>Sitemap der Zeitungsliste</h1>';
186 $query = 'SELECT tagname FROM tags ORDER BY lower(tagname)';
188 $sth = db_query($query);
190 if ($sth !== false && pg_num_rows($sth) > 0) {
191 $ret .= '<h3>User-Tags (Merkmale)</h3>';
192 $ret .= '<ul class="gold">';
194 for ($i=0; $i < pg_num_rows($sth); $i++) {
195 $row = pg_fetch_array($sth, $i);
197 $ret .= sprintf('<li><a href="%stag/%s.html">%s</a></li>',
198 $cfg['basepath'], urlencode($row['tagname']),
205 $query = 'SELECT id,name,city FROM zeitungen WHERE deleted IS false ORDER BY name';
207 $sth = db_query($query);
209 if ($sth !== false && pg_num_rows($sth) > 0) {
210 $ret .= '<h3>Zeitungen und Magazine</h3>';
211 $ret .= '<ul class="gold">';
212 for ($i=0; $i < pg_num_rows($sth); $i++) {
213 $row = pg_fetch_array($sth, $i);
215 $ret .= sprintf('<li><a href="%szeitung/%d.html">%s</a>, %s</li>',
216 $cfg['basepath'], $row['id'], $row['name'], $row['city']);
221 $query = 'SELECT id,topic FROM topics ORDER BY created';
223 $sth = db_query($query);
225 if ($sth !== false && pg_num_rows($sth) > 0) {
226 $ret .= '<h3>Diskussionen</h3>';
227 $ret .= '<ul class="gold">';
228 for ($i=0; $i < pg_num_rows($sth); $i++) {
229 $row = pg_fetch_array($sth, $i);
231 $ret .= sprintf('<li><a href="%stopic/%d.html">%s</a></li>',
232 $cfg['basepath'], $row['id'], $row['topic']);
240 function layout_showpaper($archived=false)
244 if (!isset($_GET['zeitung']) || !is_numeric($_GET['zeitung']))
245 $ret = warning('Keine Zeitung oder Magazin gefunden.');
247 $zid = $_GET['zeitung'];
248 $details = format_newspaper($zid, true);
249 if ($details === false)
250 $ret .= warning('Keine Zeitung oder Magazin gefunden.');
252 $zlist['zid'] = $zid;
256 $ret .= format_board($zid);
258 $ret .= format_board($zid, $archived);
260 $ret .= layout_bookmarks(sprintf('zeitung/%d.html', $zid), $zlist['newspaper']);
267 function layout_archive()
272 if (!isset($_GET['archiv']) || !is_numeric($_GET['archiv']))
273 $ret = warning('Keine Zeitung oder Magazin gefunden.');
275 $zid = $_GET['archiv'];
276 $details = format_newspaper($zid, true);
277 if ($details === false)
278 $ret .= warning('Keine Zeitung oder Magazin gefunden.');
280 $zlist['zid'] = $zid;
283 $query = sprintf('SELECT id,topic FROM topics ' .
284 'WHERE zeitung = %d ORDER BY created DESC',
287 $sth = db_query($query);
289 if (!$sth || pg_num_rows ($sth) == 0)
290 $ret .= warning('Kein Archiv gefunden.');
292 $ret .= '<p><ul class="gold">';
293 for ($i=0; $i < pg_num_rows ($sth); $i++) {
294 $row = pg_fetch_array($sth, $i);
295 $ret .= sprintf('<li><a href="%stopic/%d.html">%s</a></li>',
296 $cfg['basepath'], $row['id'], $row['topic']);
306 function layout_showtag()
311 if (!isset($_GET['tag']))
312 $ret = warning('Keine derartiges Merkmal gefunden.');
314 $tagname = $_GET['tag'];
315 $ret .= '<h3>Merkmal <span class="tag">' . $tagname . '</span></h3>';
317 $query = sprintf("SELECT zeitungen.id,name,count(uid) AS count FROM zeitungen " .
318 "JOIN zeitung_tags ON zeitung = id " .
319 "JOIN tags ON tag = tags.id " .
320 "WHERE tagname = '%s' " .
321 "GROUP BY zeitungen.id,name ORDER BY count DESC",
322 pg_escape_string($tagname));
324 $sth = db_query($query);
326 $zlist['tag'] = htmlspecialchars($tagname);
327 if (!$sth || pg_num_rows ($sth) == 0) {
328 $ret .= warning('Keine Zeitungen oder Magazine mit diesem Merkmal gefunden.');
329 unset($zlist['newspaper']);
331 $headlines = array('Mäßige','Mittelmäßige','Gute','Häufige','Häufigste');
334 for ($i=0; $i < pg_num_rows ($sth); $i++) {
335 $row = pg_fetch_array ($sth, $i);
336 $tag = tag_class($row['count']);
338 if ($oldtag != $tag) {
341 $ret .= sprintf('<h3 class="tag%d">%s Bewertungen</h3>', $tag, $headlines[$tag]);
342 $ret .= '<ul class="gold">';
346 $ret .= sprintf('<li><a href="%szeitung/%d.html">%s</a></li>',
347 $cfg['basepath'], $row['id'], $row['name'], $row['city']);
351 $ret .= layout_bookmarks(sprintf('tag/%s.html', htmlspecialchars($tagname)), 'Merkmal '.$tagname);
358 function layout_topic()
362 if (!isset($_GET['topic']) || !is_numeric($_GET['topic']))
363 $ret = warning('Keine passende Diskussion gefunden.');
365 $discussion = format_topic($_GET['topic']);
367 if (isset($zlist['zid'])) {
368 $ret .= format_newspaper($zlist['zid'], true);
370 if ($zlist['archived'])
371 $ret .= '<h3>Abgeschlossene Diskussion</h3>';
373 $ret .= '<h3>Diskussion</h3>';
376 if (isset($zlist['zid']))
377 $ret .= layout_bookmarks(sprintf('topic/%d.html', $zlist['zid']), $zlist['topic']);
385 header("HTTP/1.0 404 Not Found");
387 return warning('Diese Seite existiert nicht!');
390 function contact_send($topic, $email, $body)
395 if (!empty($email)) {
396 if (isset($_SESSION['uid']))
397 $header[] = sprintf('Reply-To: %s <%s>',
398 strlen($_SESSION['realname'])?$_SESSION['realname']:$_SESSION['nickname'],
401 $header[] = 'Reply-To: ' . $email;
405 ."HTTP_USER_AGENT: " . $_SERVER['HTTP_USER_AGENT'] . "\n"
406 ."REMOTE_ADDR : " . $_SERVER['REMOTE_ADDR'] . "\n";
408 if (isset($_SESSION['uid']))
409 $body .= "Nickname : " . $_SESSION['nickname'] . "\n";
411 $subject = str_replace(array('<', '>', '(', ')', '$', '/', '%', '\\', '#', ';', '&'), '', $topic);
413 sendmail($cfg['mailto'], '', $subject, $body, $header);
416 function process_contact()
418 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
419 if (empty($_POST['topic']))
420 $ret = warning('Sie haben keinen Titel für die Nachricht angegeben!');
421 elseif (empty($_POST['body']))
422 $ret = warning('Sie haben keinen Text der Nachricht angegeben!');
423 elseif (!empty($_POST['email']) && !is_valid_email_address($_POST['email']))
424 $ret = warning('Die angegebene Mail-Adresse ist ungültig.');
426 contact_send($_POST['topic'], $_POST['email'], $_POST['body']);
427 $ret = information('Die Nachricht wurde an den Chef geschickt.');
428 $ret .= '<p>Die Bearbeitung kann eine Weile dauern. Wenn Sie eine '.
429 'Antwort erwarten, sollte diese in den nächsten Tagen an die von '.
430 'Ihnen angegebene Adresse geschickt werden.</p>';
433 $replace = array('topic' => $_POST['topic'],
434 'email' => $_POST['email'],
435 'body' => $_POST['body']);
436 } elseif ($_SERVER['REQUEST_METHOD'] == 'GET') {
437 if (isset($_SESSION['email']))
438 $replace = array('email' => $_SESSION['email']);
443 return load_javascript('contact.js') . load_template('contact.html', $replace);