[Feed-collector-svn] SF.net SVN: feed-collector: [82] trunk
Status: Beta
Brought to you by:
c167
From: <c1...@us...> - 2006-12-30 09:06:45
|
Revision: 82 http://feed-collector.svn.sourceforge.net/feed-collector/?rev=82&view=rev Author: c167 Date: 2006-12-30 01:06:45 -0800 (Sat, 30 Dec 2006) Log Message: ----------- some changes Modified Paths: -------------- trunk/class/User_manager.php trunk/inc/config.php trunk/page_main.php trunk/page_personal.php trunk/page_register.php Modified: trunk/class/User_manager.php =================================================================== --- trunk/class/User_manager.php 2006-12-28 21:20:31 UTC (rev 81) +++ trunk/class/User_manager.php 2006-12-30 09:06:45 UTC (rev 82) @@ -58,6 +58,12 @@ protected $username = null; /** + * The users language + * @access protected + */ + protected $language = null; + + /** * The standard-constructor * * @param Object $db The PEAR::MDB2 @@ -129,14 +135,45 @@ * @return boolean * @access public */ - public function createUser($username, $email, $passwd, $timezone) { - $add = $this->mdb5->query(sprintf("INSERT INTO `users` (`ID`, `name`, `email`, `pass`, `timezone`, `state`) " . - "VALUES (null, `%s`, `%s`, `%s`, `%s`, `regged`);", $username, $email, $passwd, $timezone)); + public function reg_registrateUser($username, $email, $passwd, $language) { + $add = $this->mdb5->query(sprintf("INSERT INTO `users` (`ID`, `name`, `email`, `pass`, `language`, `state`) " . + "VALUES (null, `%s`, `%s`, `%s`, `%s`, `regged`);", $username, $email, $passwd, $language)); if (PEAR :: isError($add)) { return false; } return true; } + + /** + * Checks if the passwords a new user enters are totaly equal + * @param String $passwd1 The first password + * @param String $passwd2 The second password + * @return boolean + * @access public + */ + public function reg_checkPasswordEquality($passwd1, $passwd2) { + if(strlen($passwd1) == strlen($passwd2)) { + if($passwd1 === $passwd2) { + return true; + } + return false; + } else { + return false; + } + } + + /** + * Encryptes the password. if it gets passwords already enrypted, it returns them + * @param String $passwd The password password + * @return Mixed + * @access public + */ + public function reg_encryptPassword ($passwd) { + if(strlen($passwd) == 32) { + return array('pass' => $passwd, 'encrypted' => false); + } + return array('pass' => md5($passwd), 'encrypted' => true); + } /** * Returns the number of users from the db @@ -226,10 +263,22 @@ return false; } if(is_null($this->username)) { - $this->username = $this->mdb2->queryOne("SELECT name FROM users WHERE id = $this->uid"); + $this->username = $this->mdb2->queryOne("SELECT name FROM users WHERE id = ".$this->uid.";"); } return $this->username; } + + /** + * Returns the users language + * @return String + * @access public + */ + public function getUserLanguage() { + if(is_null($this->language)) { + $this->language = $this->mdb->queryOne(sprintf("SELECT language FROM users WHERE id = '%s';", $this->uid)); + } + return $This->language; + } } ?> \ No newline at end of file Modified: trunk/inc/config.php =================================================================== --- trunk/inc/config.php 2006-12-28 21:20:31 UTC (rev 81) +++ trunk/inc/config.php 2006-12-30 09:06:45 UTC (rev 82) @@ -39,10 +39,8 @@ $validPages[] = "page_faq.php"; // Languages -$langs["de_DE"] = "de_DE"; -$langs["de_DE"] = "de"; -$langs["en_EN"] = "en_EN"; -$langs["en_EN"] = "en"; +$langs[] = "de_DE"; +$langs[] = "en_EN"; /* * AUTO-CONFIGURATION Modified: trunk/page_main.php =================================================================== --- trunk/page_main.php 2006-12-28 21:20:31 UTC (rev 81) +++ trunk/page_main.php 2006-12-30 09:06:45 UTC (rev 82) @@ -61,11 +61,10 @@ require_once "class/Feed_manager.php"; $feed = new Feed_manager($db); -############ -# LANGUAGE # -############ +############## +# HTTP-BASIS # +############## require_once "HTTP.php"; -$language = HTTP::negotiateLanguage($langs, "en_EN"); ################ # User-Manager # @@ -73,6 +72,21 @@ require_once "class/User_manager.php"; $user = new User_manager($db); +############ +# LANGUAGE # +############ +if (true === HTTP_Session :: get("logged_in", false)) { + $language = $user->getUserLanguage(); + if(!in_array($language, $langs)) { + $language = "en_EN"; + } +} else { + $language = HTTP :: negotiateLanguage($langs, "en_EN"); +} + +bindtextdomain("page_main", dirname($_SERVER['SCRIPT_FILENAME'])."i18n"); +setlocale(LC_ALL, $language); + $page = "main"; // // Now we're going to replace the placeholders in the template with the important content @@ -111,21 +125,20 @@ // navigation $navigation = sprintf(" <a href=\"./page_main.php\" class=\"highlight\">%s</a> |\n" . - " <a href=\"./page_show_all_feeds.php\">%s</a> |\n" . - " <a href=\"./page_show_feed_tag.php\">%s</a> |\n" . - " <a href=\"./page_add_new_feed.php\">%s</a> |\n" . - " <a href=\"./page_show_all_tags.php\">%s</a> |\n", _("Home"), _("Show Feeds"), _("Feeds by TAG"), _("Add a Feed"), _("Show TAGs")); +" <a href=\"./page_show_all_feeds.php\">%s</a> |\n" . +" <a href=\"./page_show_feed_tag.php\">%s</a> |\n" . +" <a href=\"./page_add_new_feed.php\">%s</a> |\n" . +" <a href=\"./page_show_all_tags.php\">%s</a> |\n", _("Home"), _("Show Feeds"), _("Feeds by TAG"), _("Add a Feed"), _("Show TAGs")); if (false === HTTP_Session :: get("logged_in", false)) { $navigation .= sprintf(" <a href=\"./page_login.php\">%s</a> |\n <a href=\"./page_register.php\">%s</a>", _("Login"), _("Register")); } else { - $navigation .= sprintf(" <a href=\"./page_personal.php\">%s</a> |\n <a href=\"./page_logout.php\">%s</a>", _("Personal Page"), _("LogOut")); + $navigation .= sprintf(" <a href=\"./page_personal.php\">%s</a> |\n <a href=\"./page_logout.php?returnto=page_main.php\">%s</a>", _("Personal Page"), _("LogOut")); } $design = str_replace("<!-- navigation -->", $navigation, $design); # Main copy // main -$main = sprintf(" <h1>%s</h1>\n %s", _("Welcome!"), _( -"<p>This is the home of Feed-Collector, an database-driven news-reader.\n" . +$main = sprintf(" <h1>%s</h1>\n %s", _("Welcome!"), _("<p>This is the home of Feed-Collector, an database-driven news-reader.\n" . " It is written to automaticaly collect news from other websites \n" . " <acronym title=\"Resource Description Framework\">RDF</acronym>-, \n" . " <acronym title=\"Really Simple Syndication\">RSS</acronym>- and \n" . @@ -145,13 +158,13 @@ echo $latestnews->getMessage(); } $latest_news = sprintf(" <h1>%s</h1>\n", _("Latest News")); -while($news = $latestnews->fetchRow()) { -$latest_news .= sprintf(" <a href=\"./page_news.php?newsid=%d\" class=\"newsHeading\">%s</a>\n" . +while ($news = $latestnews->fetchRow()) { + $latest_news .= sprintf(" <a href=\"./page_news.php?newsid=%d\" class=\"newsHeading\">%s</a>\n" . " <p class=\"newsDate\">%s</p>\n" . " <p class=\"newsSummary\">%s</p>\n\n", $news['id'], $news['headline'], date("D, d.m.Y - H:i", $news['published']), $news['summary']); } -$latest_news.= sprintf(" <div class=\"more\"><a href=\"./page_news.php\">%s</a></div>\n\n" . - " <p class=\"filler\"><!-- Filler para to extend left vertical line --></p>", _("More News »")); +$latest_news .= sprintf(" <div class=\"more\"><a href=\"./page_news.php\">%s</a></div>\n\n" . +" <p class=\"filler\"><!-- Filler para to extend left vertical line --></p>", _("More News »")); $design = str_replace("<!-- latest news -->", $latest_news, $design); @@ -166,7 +179,7 @@ foreach ($biggest_feeds as $biggest) { $box_2 .= sprintf(" <li><a href=\"./page_show_feed.php?feed=%s\">%s (%d%s)</a> </li>\n", $biggest['feed_db_name'], $biggest['feed_name'], $biggest['items'], _(" Items")); } -$box_2 .=" </ul>\n"; +$box_2 .= " </ul>\n"; $design = str_replace("<!-- box 2 -->", $box_2, $design); // box 3 Modified: trunk/page_personal.php =================================================================== --- trunk/page_personal.php 2006-12-28 21:20:31 UTC (rev 81) +++ trunk/page_personal.php 2006-12-30 09:06:45 UTC (rev 82) @@ -39,6 +39,11 @@ } $db->setFetchMode(MDB2_FETCHMODE_ASSOC); +######## +# HTTP # +######## +require_once "HTTP.php"; + ########### # SESSION # ########### @@ -53,6 +58,10 @@ HTTP_Session :: setExpire($session['time']['expire']); HTTP_Session :: setIdle($session['time']['idle']); +if(false === HTTP_Session :: get("logged_in", false)) { + HTTP :: redirect("./page_login.php"); +} + ################ # Feed-Manager # ################ @@ -76,7 +85,7 @@ # Header // title $title = "Feed-Collector"; -if (HTTP_Session :: get("personal_page", true)); +//if (HTTP_Session :: get("personal_page", true)); $design = str_replace("<!-- title -->", $title, $design); // related sites @@ -102,11 +111,15 @@ $design = str_replace("<!-- midHeader title right -->", $midHeader_title_right, $design); // navigation -$navigation = sprintf(" <span class=\"doNotDisplay\">Navigation:</span>\n <a href=\"./page_main.php\">%s</a> |\n <a href=\"./page_show_feeds.php\" class=\"highlight\">%s</a> |\n <a href=\"./page_search.php\">%s</a> |\n <a href=\"./index.html\">%s</a> |\n <a href=\"./index.html\">%s</a> |\n", _("Home"), _("Show Feeds"), _("Search"), _("Show TAGs"), _("About")); +$navigation = sprintf(" <a href=\"./page_main.php\">%s</a> |\n" . + " <a href=\"./page_show_all_feeds.php\">%s</a> |\n" . + " <a href=\"./page_show_feed_tag.php\">%s</a> |\n" . + " <a href=\"./page_add_new_feed.php\">%s</a> |\n" . + " <a href=\"./page_show_all_tags.php\">%s</a> |\n", _("Home"), _("Show Feeds"), _("Feeds by TAG"), _("Add a Feed"), _("Show TAGs")); if (false === HTTP_Session :: get("logged_in", false)) { $navigation .= sprintf(" <a href=\"./page_login.php\">%s</a> |\n <a href=\"./page_register.php\">%s</a>", _("Login"), _("Register")); } else { - $navigation .= sprintf(" <a href=\"./page_profile.php\">%s</a>", _("Profile")); + $navigation .= sprintf(" <a href=\"./page_personal.php\" class=\"highlight\">%s</a> |\n <a href=\"./page_logout.php?returnto=page_main.php\">%s</a>", _("Personal Page"), _("LogOut")); } $design = str_replace("<!-- navigation -->", $navigation, $design); Modified: trunk/page_register.php =================================================================== --- trunk/page_register.php 2006-12-28 21:20:31 UTC (rev 81) +++ trunk/page_register.php 2006-12-30 09:06:45 UTC (rev 82) @@ -111,29 +111,27 @@ $main = ""; -if (empty ($_POST['username']) or empty ($_POST['mail']) or empty ($_POST['passwd1']) or empty ($_POST['passwd2'])) { - if (!empty ($_POST['username'])) { - $values['username'] = $_POST['username']; +//if (empty ($_POST['username']) or empty ($_POST['mail']) or empty ($_POST['passwd1']) or empty ($_POST['passwd2'])) { +if (isset ($_POST) and is_array($_POST)) { + if (isset ($_POST['username']) and isset ($_POST['mail']) and isset ($_POST['passwd1']) and isset ($_POST['passwd2']) and isset ($_POST['language'])) { + if (md5($_POST['passwd1']) === md5($_POST['passwd2'])) { + $passwd_checked = checkPassword($_POST['passwd1']); + if ($passwd_checked == FC_PASS_TOO_SHORT) { + buildForm($main, _("Your password is too short, please use min. 7 characters!")); + } else { + + } + } else { + buildForm($main, _("Your passwords are not equal")); + } + if (false === createUser($username, $email, $passwd, $language)) { + + } } else { - $values['username'] = ""; + buildForm($main); } - if (!empty ($_POST['mail'])) { - $values['mail'] = $_POST['mail']; - } else { - $values['mail'] = ""; - } - buildForm($main, $values); - } else { - $username = filterInput($_POST['username'], "username"); - $mail = filterInput($_POST['mail'], "mail"); - if (md5($_POST['passwd1']) === md5($_POST['passwd2'])) { - $passwd_checked = checkPassword($_POST['passwd1']); - if ($passwd_checked == FC_PASS_TOO_SHORT) { - buildForm("too short"); - } - } } $design = str_replace("<!-- main -->", $main, $design); @@ -144,8 +142,11 @@ echo $design; -function buildForm(& $form, $values, $message = null) { +function buildForm(& $form, $message = null) { $form = sprintf(" <h1>%s</h1>\n <p>%s</p>", _("Registration"), _("<b>Why register?</b><br />\n If you register, you'll have a personal page with lots of free space to place your favourite newsfeeds (only limited by your screen)")); + if (!is_null($message)) { + $form .= sprintf(" <h2>%s</h2>\n", $message); + } $form .= sprintf(" <div id=\"registration_form\">\n" . " <form action=\"%s\" method=\"post\" accept-charset=\"UTF-8\">\n" . " <div id=\"formtitle\">%s</div>\n" . @@ -158,8 +159,8 @@ " <div class=\"formElem\">%s</div>\n" . " </div>\n" . " <div id=\"right\">\n" . - " <div class=\"formField\"><input type=\"text\" name=\"username\" size=\"30\" maxlength=\"30\" value=\"%s\" /></div>\n" . - " <div class=\"formField\"><input type=\"text\" name=\"mail\" size=\"30\" maxlength=\"30\" value=\"%s\" /></div>\n" . + " <div class=\"formField\"><input type=\"text\" name=\"username\" size=\"30\" maxlength=\"30\" /></div>\n" . + " <div class=\"formField\"><input type=\"text\" name=\"mail\" size=\"30\" maxlength=\"30\" /></div>\n" . " <div class=\"formField\"><input type=\"text\" name=\"passwd1\" size=\"30\" maxlength=\"30\" /></div>\n" . " <div class=\"formField\"><input type=\"text\" name=\"passwd2\" size=\"30\" maxlength=\"30\" /></div>\n" . " <div class=\"formField\"><input type=\"text\" name=\"option_list1\" size=\"30\" maxlength=\"30\" /></div>\n" . @@ -171,7 +172,7 @@ " </div>\n" . " </form>\n" . " <p id=\"required\">All fields are required</p>\n" . - " </div>\n", $_SERVER['PHP_SELF'], _("Registration information"), _("Username"), _("E-MAIL-address"), _("Password"), _("Repeat password"), _("opt1"), _("opt2"), $values['username'], $values['mail'], _("Submit!"), _("Reset!")); + " </div>\n", $_SERVER['PHP_SELF'], _("Registration information"), _("Username"), _("E-MAIL-address"), _("Password"), _("Repeat password"), _("opt1"), _("opt2"), _("Submit!"), _("Reset!")); } function checkPassword($pass) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |