diff --git a/DB/db_rewrite.sql b/DB/db_rewrite.sql index fa31c6f8..b85f04c9 100644 --- a/DB/db_rewrite.sql +++ b/DB/db_rewrite.sql @@ -3,7 +3,7 @@ -- http://www.phpmyadmin.net -- -- Host: localhost --- Erstellungszeit: 02. Juni 2011 um 23:02 +-- Erstellungszeit: 03. Juni 2011 um 03:12 -- Server Version: 5.1.44 -- PHP-Version: 5.3.1 @@ -71,21 +71,23 @@ CREATE TABLE IF NOT EXISTS `Counter` ( -- INSERT INTO `Counter` (`URL`, `Anz`) VALUES -('news', 80), -('login', 24), +('news', 164), +('login', 26), ('logout', 13), -('start', 25), -('faq', 16), +('start', 26), +('faq', 18), ('credits', 3), ('register', 3), -('admin_rooms', 70), -('admin_angel_types', 69), -('user_settings', 116), -('user_messages', 111), -('admin_groups', 104), -('user_questions', 54), -('admin_questions', 41), -('admin_faq', 53); +('admin_rooms', 75), +('admin_angel_types', 70), +('user_settings', 125), +('user_messages', 112), +('admin_groups', 114), +('user_questions', 55), +('admin_questions', 42), +('admin_faq', 55), +('admin_news', 2), +('news_comments', 144); -- -------------------------------------------------------- @@ -131,25 +133,27 @@ CREATE TABLE IF NOT EXISTS `GroupPrivileges` ( `privilege_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `group_id` (`group_id`,`privilege_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=40 ; +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=51 ; -- -- Daten für Tabelle `GroupPrivileges` -- INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES -(32, -2, 8), +(42, -2, 15), (24, -1, 5), -(31, -2, 11), -(30, -2, 9), +(40, -2, 4), +(41, -2, 3), (23, -1, 2), -(36, -4, 7), -(37, -4, 13), -(29, -2, 3), -(28, -2, 4), +(48, -4, 14), +(46, -4, 7), +(44, -2, 11), +(43, -2, 9), (12, -5, 10), -(38, -4, 12), -(39, -4, 6); +(47, -4, 13), +(49, -4, 12), +(45, -2, 8), +(50, -4, 6); -- -------------------------------------------------------- @@ -210,7 +214,7 @@ INSERT INTO `Messages` (`id`, `Datum`, `SUID`, `RUID`, `isRead`, `Text`) VALUES CREATE TABLE IF NOT EXISTS `News` ( `ID` int(11) NOT NULL AUTO_INCREMENT, - `Datum` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `Datum` int(11) NOT NULL, `Betreff` varchar(150) NOT NULL DEFAULT '', `Text` text NOT NULL, `UID` int(11) NOT NULL DEFAULT '0', @@ -223,9 +227,9 @@ CREATE TABLE IF NOT EXISTS `News` ( -- INSERT INTO `News` (`ID`, `Datum`, `Betreff`, `Text`, `UID`, `Treffen`) VALUES -(1, '2011-06-02 21:35:27', '', '', 1, 0), -(2, '2011-06-02 21:36:57', '', '', 1, 0), -(3, '2011-06-02 21:36:57', '', '', 1, 0); +(1, 1307070566, 'asdf', 'asdf', 1, 0), +(2, 1307070579, 'Achtung, Treffen!', 'Uiuiuiui.', 1, 0), +(3, 1307070686, 'Achtung, Treffen!', 'Jojojo!', 1, 1); -- -------------------------------------------------------- @@ -241,12 +245,16 @@ CREATE TABLE IF NOT EXISTS `news_comments` ( `UID` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`), KEY `Refid` (`Refid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; -- -- Daten für Tabelle `news_comments` -- +INSERT INTO `news_comments` (`ID`, `Refid`, `Datum`, `Text`, `UID`) VALUES +(1, 10, '2011-06-03 04:12:28', 'FOobar :)', 1), +(2, 10, '2011-06-03 04:13:03', 'FOobar :)', 1), +(3, 10, '2011-06-03 04:13:06', 'FOobar :)', 1); -- -------------------------------------------------------- @@ -260,7 +268,7 @@ CREATE TABLE IF NOT EXISTS `Privileges` ( `desc` varchar(1024) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ; +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=16 ; -- -- Daten für Tabelle `Privileges` @@ -279,7 +287,9 @@ INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES (10, 'admin_groups', 'Manage usergroups and their rights'), (11, 'user_questions', 'Let users ask questions'), (12, 'admin_questions', 'Answer user''s questions'), -(13, 'admin_faq', 'Edit FAQs'); +(13, 'admin_faq', 'Edit FAQs'), +(14, 'admin_news', 'Administrate the news section'), +(15, 'news_comments', 'User can comment news'); -- -------------------------------------------------------- @@ -1016,7 +1026,9 @@ INSERT INTO `Sprache` (`TextID`, `Sprache`, `Text`) VALUES ('admin_questions', 'DE', 'Fragen beantworten'), ('admin_questions', 'EN', 'Answer questions'), ('admin_faq', 'DE', 'FAQs bearbeiten'), -('admin_faq', 'EN', 'Edit FAQs'); +('admin_faq', 'EN', 'Edit FAQs'), +('news_comments', 'DE', 'News Kommentare'), +('news_comments', 'EN', 'News comments'); -- -------------------------------------------------------- @@ -1059,7 +1071,7 @@ CREATE TABLE IF NOT EXISTS `User` ( -- INSERT INTO `User` (`UID`, `Nick`, `Name`, `Vorname`, `Alter`, `Telefon`, `DECT`, `Handy`, `email`, `ICQ`, `jabber`, `Size`, `Passwort`, `Gekommen`, `Aktiv`, `Tshirt`, `color`, `Sprache`, `Avatar`, `Menu`, `lastLogIn`, `CreateDate`, `Art`, `kommentar`, `Hometown`) VALUES -(1, 'admin', '', '', 0, '', '', '', '', '', '', 'L', '21232f297a57a5a743894a0e4a801fc3', 0, 0, 0, 10, 'DE', 115, 'L', 1307055685, '0000-00-00 00:00:00', '', '', ''), +(1, 'admin', '', '', 0, '', '', '', '', '', '', 'L', '21232f297a57a5a743894a0e4a801fc3', 0, 0, 0, 10, 'DE', 115, 'L', 1307070695, '0000-00-00 00:00:00', '', '', ''), (147, 'msquare', '', '', 23, '', '', '', 'msquare@notrademark.de', '', '', 'L', 'e10adc3949ba59abbe56e057f20f883e', 0, 0, 0, 6, 'EN', 0, 'L', 1307042703, '2011-06-02 00:55:09', '', '', ''); -- -------------------------------------------------------- diff --git a/includes/pages/user_news.php b/includes/pages/user_news.php index 56c5bb68..34c346dd 100644 --- a/includes/pages/user_news.php +++ b/includes/pages/user_news.php @@ -1,108 +1,139 @@ " . Get_Text(3) . "" . user_news_output(); +function display_news($news) { + global $privileges, $p; + + $html .= ""; + $html .= '
'; + $html .= '
'; + $html .= date("Y-m-d H:i",$news['Datum']) . ', '; + $html .= UID2Nick($news['UID']); + if ($p != "news_comments") + $html .= ', Kommentare (' . sql_num_query("SELECT * FROM `news_comments` WHERE `Refid`='" . sql_escape($news['ID']) . "'") . ') »'; + $html .= '
'; + $html .= '

'.($news['Treffen'] == 1 ? '[Meeting] ' : '') . ReplaceSmilies($news['Betreff']) . '

'; + $html .= '

' . ReplaceSmilies(nl2br($news['Text'])) . '

'; + if (in_array("admin_news", $privileges)) + $html .= "
Edit
\n"; + + $html .= '
'; + return $html; } -function user_news_output() { - global $DISPLAY_NEWS, $privileges; - +function user_news_comments() { + global $user; + $html = ""; + if (isset ($_REQUEST["nid"]) && preg_match("/^[0-9]{1,}$/", $_REQUEST['nid']) && sql_num_query("SELECT * FROM `News` WHERE `ID`=" . sql_escape($_REQUEST['nid']) . " LIMIT 1") > 0) { + $nid = $_REQUEST["nid"]; + list ($news) = sql_select("SELECT * FROM `News` WHERE `ID`=" . sql_escape($_REQUEST['nid']) . " LIMIT 1"); + if (isset ($_REQUEST["text"])) { + $text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['text'])); + sql_query("INSERT INTO `news_comments` (`Refid`, `Datum`, `Text`, `UID`) VALUES ('" . sql_escape($nid) . "', '" . date("Y-m-d H:i:s") . "', '" . sql_escape($text) . "', '" . sql_escape($user["UID"]) . "')"); + $html .= success("Eintrag wurde gespeichert"); + } - if (isset ($_POST["text"]) && isset ($_POST["betreff"]) && IsSet ($_POST["date"])) { - if (!isset ($_POST["treffen"])) - $_POST["treffen"] = 0; - $SQL = "INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) " . - "VALUES ('" . sql_escape($_POST["date"]) . "', '" . sql_escape($_POST["betreff"]) . "', '" . sql_escape($_POST["text"]) . "', '" . sql_escape($_SESSION['uid']) . - "', '" . sql_escape($_POST["treffen"]) . "');"; - $Erg = sql_query($SQL); - if ($Erg == 1) - $html .= Get_Text(4); - } + $html .= '« Back'; + $html .= display_news($news); - if (!IsSet ($_GET["news_begin"])) - $_GET["news_begin"] = 0; + $html .= '

Comments

'; + + $comments = sql_select("SELECT * FROM `news_comments` WHERE `Refid`='" . $nid . "' ORDER BY 'ID'"); + foreach ($comments as $comment) { + $html .= '
'; + $html .= DisplayAvatar($comment['UID']); + $html .= '
'; + $html .= $comment['Datum'] . ', '; + $html .= UID2Nick($comment['UID']); + $html .= '
'; + $html .= '

' . nl2br($comment['Text']) . '

'; + $html .= '
'; + } - if (!IsSet ($_GET["DISPLAY_NEWS"])) - $_GET["DISPLAY_NEWS"] = 5; + $html .= ""; + $html .= ' +
+
+

Neuer Kommentar:

+   + +
+ + + + + + +
Text:
+
+ +
'; + } else { + $html .= "Fehlerhafter Aufruf!"; + } - $SQL = "SELECT * FROM `News` ORDER BY `ID` DESC LIMIT " . intval($_GET["news_begin"]) . ", " . intval($_GET["DISPLAY_NEWS"]); - $Erg = sql_query($SQL); + return $html; +} - // anzahl zeilen - $news_rows = mysql_num_rows($Erg); +function user_news() { + global $DISPLAY_NEWS, $privileges, $user; - for ($n = 0; $n < $news_rows; $n++) { + $html = ""; - if (mysql_result($Erg, $n, "Treffen") == 0) - $html .= "

"; - else - $html .= "

"; - - $html .= "" . ReplaceSmilies(mysql_result($Erg, $n, "Betreff")) . "\n"; - - // Schow Admin Page - if ($_SESSION['CVS']["admin/news.php"] == "Y") - $html .= " [edit]
\n\t\t"; - - $html .= "
   " . mysql_result($Erg, $n, "Datum") . ", "; - $html .= UID2Nick(mysql_result($Erg, $n, "UID")) . ""; - // avatar anzeigen? - $html .= DisplayAvatar(mysql_result($Erg, $n, "UID")); - $html .= "

\n"; - $html .= "

" . ReplaceSmilies(nl2br(mysql_result($Erg, $n, "Text"))) . "

\n"; - $RefID = mysql_result($Erg, $n, "ID"); - $countSQL = "SELECT COUNT(*) FROM `news_comments` WHERE `Refid`='$RefID'"; - $countErg = sql_query($countSQL); - $countcom = mysql_result($countErg, 0, "COUNT(*)"); - $html .= "

$countcom comments

\n\n"; + if (isset ($_POST["text"]) && isset ($_POST["betreff"])) { + if (!isset ($_POST["treffen"]) || !in_array("admin_news", $privileges)) + $_POST["treffen"] = 0; + sql_query("INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) " . + "VALUES ('" . sql_escape(time()) . "', '" . sql_escape($_POST["betreff"]) . "', '" . sql_escape($_POST["text"]) . "', '" . sql_escape($user['UID']) . + "', '" . sql_escape($_POST["treffen"]) . "');"); + $html .= success(Get_Text(4)); } - $html .= "
\n\n"; - $rowerg = sql_query("SELECT * FROM `News`"); - $rows = mysql_num_rows($rowerg); - $dis_rows = round(($rows / $DISPLAY_NEWS) + 0.5); + if (isset ($_REQUEST['page']) && preg_match("/^[0-9]{1,}$/", $_REQUEST['page'])) + $page = $_REQUEST['page']; + else + $page = 0; + + $news = sql_select("SELECT * FROM `News` ORDER BY `ID` DESC LIMIT " . ($page * $DISPLAY_NEWS) . ", " . $DISPLAY_NEWS); + foreach ($news as $entry) + $html .= display_news($entry); + + $html .= "
\n\n"; + $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS); $html .= Get_Text(5); - for ($i = 1; $i <= $dis_rows; $i++) { - if (!((($i * $DISPLAY_NEWS) - $_GET["news_begin"]) == $DISPLAY_NEWS)) { - $html .= '' . $i . '  '; - } else { - $html .= "$i  "; - } + for ($i = 0; $i < $dis_rows; $i++) { + if ($i == $_REQUEST['page']) + $html .= ($i +1) . "  "; + else + $html .= '' . ($i +1) . '  '; } $html .= '
-

-

' . Get_Text(6) . '

-   - -
- - - - - - - - - - - '; - if (in_array('news_add_meeting', $privileges)) { +

+

' . Get_Text(6) . '

+   + + +
' . Get_Text(7) . '
' . Get_Text(8) . '
+ + + + + + + + '; + if (in_array('admin_news', $privileges)) { $html .= ' - - - '; + + + '; } $html .= '
' . Get_Text(7) . '
' . Get_Text(8) . '
' . Get_Text(9) . '
' . Get_Text(9) . '
-
- -
'; +
+ + '; return $html; } ?> \ No newline at end of file diff --git a/includes/sys_user.php b/includes/sys_user.php index 6274003d..5dcf3f1f 100644 --- a/includes/sys_user.php +++ b/includes/sys_user.php @@ -75,9 +75,9 @@ function displayPictur($UID, $height = "30") { global $url, $ENGEL_ROOT; if ($height > 0) - return ("\"picture"); + return ("
\"picture
"); else - return ("\"picture"); + return ("
\"picture
"); } function displayavatar($UID, $height = "30") { @@ -92,7 +92,7 @@ function displayavatar($UID, $height = "30") { if (mysql_num_rows($aerg)) if (mysql_result($aerg, 0, "Avatar") > 0) - return (" "); + return'
'. (" ").'
'; } function UIDgekommen($UID) { diff --git a/txt/TODO b/txt/TODO index cebcb0de..fb1b3098 100644 --- a/txt/TODO +++ b/txt/TODO @@ -10,12 +10,12 @@ jetzt: * weckservice? später: + * Zurück-/Backlinks setzen * MD5-Passwörter mit Salt speichern * Passwort-Mindestanforderungen stellen * User-Avatare (code liegt auskommentiert in user_settings.php) * user_messages schön machen * Formulare weg von Tabellen - * user_news lässt sich nicht bedienen (POST ohne redirects...) * Privilegien korrigieren (an die vom CVS anpassen) * Beim Raum-Management die benötigten Engel anzeigen * Löschen nur mit Rückfrage diff --git a/www-ssl/css/base.css b/www-ssl/css/base.css index 44e1959c..0a137099 100644 --- a/www-ssl/css/base.css +++ b/www-ssl/css/base.css @@ -15,6 +15,12 @@ header { width: 100%; } +article, details { + clear: none; + display: block; + float: none; +} + footer { clear: both; display: block; @@ -64,13 +70,13 @@ dd { margin-left: 20px; } -h1, h4 { +h1, h2, h3, h4 { font-size: 16px; padding: 0 4px; } hr { - margin: 10px 0; + margin: 10px 0; } ul { @@ -81,7 +87,7 @@ nav { margin: 0 10px 10px 0; } -#content article { +#content > article { padding: 10px; } @@ -98,20 +104,28 @@ a.sprache img { } table { - border-collapse: collapse; + border-collapse: collapse; } th { - background: #f0f0f0; + background: #f0f0f0; } td, th { - border: 1px solid #888; + border: 1px solid #888; } textarea { - height: 200px; - width: 300px; + height: 200px; + width: 300px; +} + +.clear { + clear: both; +} + +.pagination { + text-align: center; } .background { @@ -127,20 +141,49 @@ textarea { } .error { - color: #f00; + color: #f00; } .success { - color: #090; + color: #090; } .notice { - background: #f0f0f0; - border: 2px solid #888; - margin: 10px; - padding: 10px; + background: #f0f0f0; + border: 2px solid #888; + margin: 10px; + padding: 10px; } .new_message { - font-weight: bold; + font-weight: bold; +} + +.news_comment, .news { + border: 1px solid #888; + margin: 10px 0; +} + +.news_comment details, .news details { + background: #f0f0f0; + padding: 4px; +} + +.news_comment p, .news p, h3 { + padding: 4px; +} + +.news_comment p, .news_comment details { + margin-left: 72px; +} + +.avatar { + float: left; + margin: 4px; + max-width: 64px; +} + +.news.meeting { + border: 1px solid #000; + box-shadow: 1px 1px 5px #888; } diff --git a/www-ssl/index.php b/www-ssl/index.php index 8ad025aa..9524459a 100644 --- a/www-ssl/index.php +++ b/www-ssl/index.php @@ -36,6 +36,10 @@ if (in_array($p, $privileges)) { require_once ('includes/pages/user_news.php'); $content = user_news(); } + elseif ($p == "news_comments") { + require_once ('includes/pages/user_news.php'); + $content = user_news_comments(); + } elseif ($p == "user_messages") { $content = user_messages(); }