| 1 | <? |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | require_once("../common/functions_blog.php"); |
|---|
| 20 | |
|---|
| 21 | function show_login_screen() { |
|---|
| 22 | ?> |
|---|
| 23 | <form name="loginform" method="post" action="login.php"> |
|---|
| 24 | <input type="hidden" name="action" value="login" /> |
|---|
| 25 | <div id="if_container"> |
|---|
| 26 | <div id="if_title"></div> |
|---|
| 27 | <div id="if_bar1"></div> |
|---|
| 28 | <div id="if_page_header"> |
|---|
| 29 | <h1 class="page_title">login</h1> |
|---|
| 30 | </div> |
|---|
| 31 | <div id="if_page"> |
|---|
| 32 | <div class="log_post"> |
|---|
| 33 | <table border="0" cellspacing="3" cellpadding="0" align="center"><tr> |
|---|
| 34 | <td align="right">username:</td><td><input type="text" id="loginname" name="login[name]" /></td> |
|---|
| 35 | </tr><tr> |
|---|
| 36 | <td align="right">password:</td><td><input type="password" name="login[password]" /></td> |
|---|
| 37 | </tr><tr> |
|---|
| 38 | <td colspan="2" align="center"><input type="submit" value="login" /></td> |
|---|
| 39 | </tr></table> |
|---|
| 40 | </div> |
|---|
| 41 | </form> |
|---|
| 42 | <script language="Javascript" type="text/javascript"> |
|---|
| 43 | document.loginform.loginname.focus(); |
|---|
| 44 | </script> |
|---|
| 45 | <? |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | function check_login($login) { |
|---|
| 49 | global $db; |
|---|
| 50 | $query = sprintf("SELECT * FROM authors WHERE login = '%s' AND password = '%s' AND active = 1", |
|---|
| 51 | preg_quote($login["name"], "'"), |
|---|
| 52 | preg_quote($login["password"], "'") |
|---|
| 53 | ); |
|---|
| 54 | $res =& $db->query($query); |
|---|
| 55 | if (PEAR::isError($res)) { |
|---|
| 56 | die($res->getUserInfo()); |
|---|
| 57 | } |
|---|
| 58 | if ($res->numRows()) { |
|---|
| 59 | $row = $res->fetchRow(MDB2_FETCHMODE_ASSOC); |
|---|
| 60 | $_SESSION["author_id"] = $row["id"]; |
|---|
| 61 | $_SESSION["author_name"] = $row["login"]; |
|---|
| 62 | $_SESSION["author_fullname"] = $row["fullname"]; |
|---|
| 63 | $_SESSION["author_email"] = $row["email"]; |
|---|
| 64 | $_SESSION["author_website"] = $row["website"]; |
|---|
| 65 | $_SESSION["blog_user"] = 1; |
|---|
| 66 | header("Location: index.php"); |
|---|
| 67 | } else { |
|---|
| 68 | show_login_screen(); |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | function logout() { |
|---|
| 73 | session_destroy(); |
|---|
| 74 | show_login_screen(); |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | function html_header_admin($title="Admin interface") { |
|---|
| 78 | echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; |
|---|
| 79 | echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n"; |
|---|
| 80 | echo "<head>\n"; |
|---|
| 81 | echo "\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-15\" />\n"; |
|---|
| 82 | echo "\t<meta name=\"robots\" content=\"ALL\" />\n"; |
|---|
| 83 | echo "\t<meta name=\"generator\" content=\"MvBlog ".$GLOBALS["version"]."\" />\n"; |
|---|
| 84 | echo "\t<meta name=\"resource-type\" content=\"document\" />\n"; |
|---|
| 85 | echo "\t<meta name=\"audience\" content=\"general\" />\n"; |
|---|
| 86 | echo "\t<meta name=\"web-rev\" content=\"4.0\" />\n"; |
|---|
| 87 | echo "\t<meta name=\"last-modified\" content=\"".date("r")."\" />\n"; |
|---|
| 88 | echo "\t<link rel=\"stylesheet\" href=\"style/index.css\" type=\"text/css\" />\n"; |
|---|
| 89 | echo "\t<link rel=\"alternate\" type=\"application/xml\" title=\"RSS\" href=\"index.php?action=rss\" />\n"; |
|---|
| 90 | echo "\t<link rel=\"icon\" href=\"favicon.ico\" type=\"image/x-icon\" />\n"; |
|---|
| 91 | echo "\t<link rel=\"shortcut icon\" href=\"favicon.ico\" type=\"image/x-icon\" />\n"; |
|---|
| 92 | echo "\t<title>".$title." - MvBlog powered</title>\n"; |
|---|
| 93 | echo "</head>\n"; |
|---|
| 94 | echo "<body>\n"; |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | html_header_admin("Admin Interface", "."); |
|---|
| 99 | switch ($_REQUEST["action"]) { |
|---|
| 100 | case "login" : check_login($_POST["login"]); break; |
|---|
| 101 | case "logout": logout(); break; |
|---|
| 102 | default : show_login_screen(); break; |
|---|
| 103 | } |
|---|
| 104 | html_footer(); |
|---|
| 105 | ?> |
|---|