- Joined
- Aug 11, 2008
- Messages
- 2,628
- Solutions
- 2
- Reaction score
- 240
Try this one..
PHP:
<?
/*
Author: Oceanic
Product Name: xCMS
Purpose: To easy manage Opentibia servers, and to be a good CMS
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
session_start();
include "config.php";
error_reporting($error_reporting);
mysql_connect($connection[1], $connection[2], $connection[3]) or die("Could not connect, please check your settings");
mysql_select_db($connection[4]) or die("Database dont exist");
////////////////////////////////////
// Search player
////////////////////////////////////
if(!empty($_POST["search_name"])){
$name = mysql_escape_string($_POST["search_name"]);
$player_check = mysql_query("SELECT * FROM players WHERE name='$name'") or die(mysql_error());
if (mysql_num_rows($player_check) == 0){
$player_dont_exist = "<p>Player dont exist</p>\n";
}else{
header("Location: ?page=Search&name=".preg_replace("/".chr(32)."/", "_", $_POST["search_name"]));
}
}
////////////////////////////////////
// Login
////////////////////////////////////
if(!empty($_POST["login_number"]) && !empty($_POST["login_password"])){
$account_number = mysql_escape_string($_POST["login_number"]);
if($use_md5 == true){
$account_passoword = mysql_escape_string($_POST["login_password"]);
$account_passoword = md5($account_passoword);
}else{
$account_passoword = mysql_escape_string($_POST["login_password"]);
}
if(!empty($_COOKIE["name"]) && !empty($_COOKIE["password"]) && $_POST["remember"] != true){
setcookie("name","");
setcookie("password","");
}
$get_account_data = mysql_query("SELECT * FROM accounts WHERE id='$account_number'") or die(mysql_error());
if (mysql_num_rows($get_account_data) != 0){
$data = mysql_fetch_array( $get_account_data );
if($account_number == $data['id'] && $account_passoword == $data['password']){
if($data['group_id'] > 1){
$_SESSION["logged_in"] = 1;
$_SESSION["admin"] = 1;
$_SESSION["account_number"] = $account_number;
}else{
$_SESSION["logged_in"] = 1;
$_SESSION["account_number"] = $account_number;
}
if($_POST["remember"] == true){
setcookie("name",md5($account_number));
setcookie("password",md5($account_passoword));
}
header("Location: ?page=Account");
}else{
$wrong_password = "<p>Wrong password</p>\n";
}
}else{
$account_dont_exist = "<p>Account dont exist</p>\n";
}
}
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
//Head
echo "<head>\n";
echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\"/>\n";
echo "<meta name=\"description\" content=\"\"/>\n";
echo "<meta name=\"keywords\" content=\"\"/> \n";
echo "<meta name=\"author\" content=\"Oceanic\"/> \n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"skinsstyle.css\" media=\"screen\"/>\n";
echo "<title>".$title."</title>\n";
echo "</head>\n";
echo "<body>\n";
echo "<div id=\"wrapper\">\n";
echo "<div id=\"container\">\n";
echo "<div class=\"title\">\n";
echo " <h1><a href=\"index.php\">".$title."</a></h1>\n";
echo "</div>\n";
echo "<div class=\"header\"></div>\n";
//Menu
echo "<div class=\"navigation\">\n";
echo "<a href=\"?page=Home\">Home</a>\n";
if($_SESSION["logged_in"] == 1){
echo "<a href=\"?page=Account\">Account</a>\n";
if($_SESSION["admin"] == 1){
echo "<a href=\"?page=Admin\">Admin</a>\n";
}
}else{
echo "<a href=\"?page=Login\">Login</a>\n";
}
echo "<a href=\"?page=Search\">Search</a>\n";
echo "<a href=\"?page=Highscore\">Highscore</a>\n";
echo " <div class=\"clearer\"></div>\n";
echo "</div>\n";
//Main
echo "<div class=\"main\">\n";
echo " <div class=\"content\">\n";
switch($_GET["page"]){
default:
include "bin/news.php";
break;
case "Home":
include "bin/news.php";
break;
case "Comments":
include "bin/comments.php";
break;
case "Admin":
include "bin/admin.php";
break;
case "Login":
include "bin/login.php";
break;
case "Register":
include "bin/register.php";
break;
case "Search":
include "bin/search.php";
break;
case "Highscore":
include "bin/highscore.php";
break;
case "Account":
include "bin/account.php";
break;
case "Logout":
session_destroy();
echo "<h3>Logout</h3>\n";
echo "<h3>You was logged out, <a href=\"?page=Home\">Click here to go back</a></h3>\n";
break;
case "Recover":
include "bin/recover.php";
break;
}
echo " </div>\n";
echo " <div class=\"bottom\">\n";
echo " <div class=\"clearer\"></div>\n";
echo "</div>\n";
//Footer
echo " <div class=\"footer\">\n";
echo " <div class=\"left\">\n";
echo " Copyright © 2008 <a href=\"http://kammarfelt.eu\">Oceanic</a>\n";
echo " </div>\n";
echo " <div class=\"right\">\n";
echo " Website template based on by <a href=\"http://arcsin.se\">Arcsin</a>\n";
echo " </div>\n";
echo " <div class=\"clearer\"></div>\n";
echo " </div>\n";
echo "</div>\n";
echo "</div>\n";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
?>