Пример #1
0
function CheckCookies($IsUserChecked)
{
    global $lang, $game_config, $basic_pages;
    getLang('cookies');
    $UserRow = array();
    include ROOT_PATH . 'config' . UNIVERSE . '.php';
    if (isset($_COOKIE[$game_config['COOKIE_NAME']])) {
        $TheCookie = explode("/%/", $_COOKIE[$game_config['COOKIE_NAME']]);
        $UserResult = doquery("SELECT * FROM {{table}} WHERE `username` = '" . cleanstring($TheCookie[1]) . "';", 'users');
        // On verifie s'il y a qu'un seul enregistrement pour ce nom
        if (mysql_num_rows($UserResult) == 0) {
            message(sprintf($lang['cookies']['Error1'], cleanstring($TheCookie[1])));
        }
        $UserRow = FetchArray($UserResult);
        // On teste si on a bien le bon UserID
        if ($UserRow["id"] != $TheCookie[0]) {
            message($lang['cookies']['Error2']);
        }
        // On teste si le mot de passe est correct !
        if (sha($UserRow["password"] . "--" . $dbsettings["secretword"]) !== $TheCookie[2]) {
            message($lang['cookies']['Error3']);
        }
        $NextCookie = implode("/%/", $TheCookie);
        // Au cas ou dans l'ancien cookie il etait question de se souvenir de moi
        // 3600 = 1 Heure // 86400 = 1 Jour // 31536000 = 365 Jours
        // on ajoute au compteur!
        if ($TheCookie[3] == 1) {
            $ExpireTime = time() + 31536000;
        } else {
            $ExpireTime = 0;
        }
        if ($IsUserChecked == false) {
            setcookie($game_config['COOKIE_NAME'], $NextCookie, $ExpireTime, "/", "", 0);
        }
        if (SMALL_LOAD) {
            //Just a small query
            doquery("UPDATE {{table}} SET `onlinetime` = '" . time() . "' WHERE `id` = '" . $TheCookie[0] . "' LIMIT 1;", 'users');
        } else {
            $QryUpdateUser = "******";
            $QryUpdateUser .= "`onlinetime` = '" . time() . "', ";
            $QryUpdateUser .= "`current_page` = '" . mysql_real_escape_string($_GET['page']) . "', ";
            $QryUpdateUser .= "`user_lastip` = '" . mysql_real_escape_string($_SERVER['REMOTE_ADDR']) . "', ";
            $QryUpdateUser .= "`user_agent` = '" . mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']) . "' ";
            $QryUpdateUser .= "WHERE ";
            $QryUpdateUser .= "`id` = '" . $TheCookie[0] . "' LIMIT 1;";
            doquery($QryUpdateUser, 'users');
        }
        $IsUserChecked = true;
    }
    unset($dbsettings);
    $Return['state'] = $IsUserChecked;
    $Return['record'] = $UserRow;
    return $Return;
}
Пример #2
0
function sendpassemail($emailaddress, $password, $username, $code)
{
    global $lang, $game_config;
    $parse = $lang;
    $parse['password'] = $password;
    $parse['username'] = $username;
    $parse['uni'] = UNIVERSE;
    $parse['game'] = $game_config['game_name'];
    $parse['GAMEURL'] = GAMEURL;
    $parse['ADMIN_NAME'] = ADMIN_NAME;
    $parse['validate_url'] = GAMEURL . '/login.php?GET_LOGIN=1&username='******'&password='******'&UNI=' . UNIVERSE . '&go=./?page=validate--code=' . $code;
    $status = mymail($emailaddress, $lang['mail_title'] . $parse['game'], parsetemplate(gettemplate('emails/reg'), $parse));
    return $status;
}
Пример #3
0
 public function __construct()
 {
     $this->cwd = getcwd();
     $this->dom = new DOM();
     $this->uid = 'html_' . sha($_SERVER['PATH_INFO']);
     $this->dir = path_info();
     $this->page = path_info(1);
     $this->url = $this->URL();
     if (!isset($_GET['nocache']) && function_exists('apc_fetch') && ($html = apc_fetch($this->uid))) {
         @$this->dom->loadHTML($html);
         $this->content = $this->dom->query(constant('de_content_xpath'))->item(0);
         return;
     }
     @$this->dom->loadHTMLFile('index.html');
     $this->content = $this->dom->query(constant('de_content_xpath'))->item(0);
     if ($this->dir && is_dir($this->dir)) {
         $links = $this->dom->query('//a[@href="' . constant('de_root_dir') . $this->dir . '/"]');
         foreach ($links as $link) {
             $link->setAttribute('class', 'active');
         }
         if ($this->page && is_file($this->dir . '/' . $this->page . '.html')) {
             $this->Import($this->dir . '/header.html');
             $this->Import($this->dir . '/' . $this->page . '.html');
             $this->Import($this->dir . '/footer.html');
             $this->Description();
         } else {
             $this->Import($this->dir . '/index.html');
         }
         $this->Title();
         $link_tag = $this->dom->query('//link[@rel="canonical"]')->item(0);
         if ($link_tag) {
             $link_tag->setAttribute('href', $this->url);
         }
     }
     if (function_exists('apc_store')) {
         apc_store($this->uid, $this->dom->saveHTML(), constant('de_apc_cache_timeout'));
     }
 }
Пример #4
0
function mr_encrypt($sting)
{
    //MadnessRed function
    return sha($sting);
}
Пример #5
0
     doquery("UPDATE {{table}} SET `ally_web` = '" . mysql_escape_string(strip_tags($_GET['homepage'])) . "', `ally_image` = '" . mysql_escape_string(strip_tags($_GET['logo'])) . "', `ally_request_notallow` = '" . mysql_escape_string(strip_tags($_GET['ally_closed'])) . "' WHERE `id` = '" . $allyrow['id'] . "' LIMIT 1 ;", 'alliance');
     doquery("UPDATE {{table}} SET `ally_rank_name` = '" . mysql_escape_string(strip_tags($_GET['foundername'])) . "' WHERE `id` = '" . $allyrow['ally_owner'] . "' AND `ally_id` = '" . $allyrow['id'] . "' LIMIT 1;", 'users');
     break;
 case "tag":
     //Change name or tag
     if (strlen($_GET['newtag']) > 1) {
         doquery("UPDATE {{table}} SET `ally_tag` = '" . substr(mysql_escape_string(strip_tags($_GET['newtag'])), 0, 8) . "' WHERE `id` = '" . $allyrow['id'] . "' LIMIT 1;", 'alliance');
     }
     if (strlen($_GET['newname']) > 1) {
         doquery("UPDATE {{table}} SET `ally_name` = '" . substr(mysql_escape_string(strip_tags($_GET['newname'])), 0, 32) . "' WHERE `id` = '" . $allyrow['id'] . "' LIMIT 1;", 'alliance');
     }
     break;
 case "delete":
     //Change name or tag
     if ($user['permisions'][256]) {
         if (sha($_GET['confirm']) == $user['password']) {
             //Deal with users
             $members = array();
             $memberquery = doquery("SELECT `id` FROM {{table}} WHERE `ally_id` = '" . $user['ally_id'] . "' ;", 'users', false);
             while ($row = FetchArray($memberquery)) {
                 $members[] = $row['id'];
             }
             //Set the members to have no alliance
             doquery("UPDATE {{table}} SET `ally_id` = '0' , `ally_name` = '' , `ally_register_time` = '0' , `ally_rank` = '0' , `ally_rank_name` = 'Newbie' WHERE `ally_id` = '" . $user['ally_id'] . "' ;", 'users');
             //Delete the alliance
             doquery("DELETE FROM {{table}} WHERE `id` = '" . $user['ally_id'] . "' LIMIT 1", 'alliances');
             //Message everyone
             $message = "On " . date("j[\\s\\up]S[/\\s\\up] F Y \\a\t H:i:s", time()) . " the alliance '" . $user['ally_name'] . "' was disbanded. You can now apply to join another alliance or create your own. This is an automated message. Any replies will be sent to " . $user['username'] . ".";
             GroupPM($members, $user['id'], $message, 'Alliance Disbanded', $allyrow['ally_name'], 1);
             //Back to main page
             header("Location: " . AddUniToString('./?page=network&axah=' . $_GET['axah']));
 function __construct($data = null, $file = null)
 {
     global $l;
     //$l->a('Creating new Csum.<br>');
     if (!is_null($data)) {
         $this->len = strlen($data);
         $this->md5 = amd5($data);
         $this->sha = sha($data);
         $this->s512 = s512($data);
     } else {
         if (is_null($file)) {
             $this->len = null;
             $this->md5 = null;
             $this->sha = null;
             $this->s512 = null;
         } else {
             $this->len = filesize($file);
             $this->md5 = amd5f($file);
             $this->sha = shaf($file);
             $this->s512 = s512f($file);
         }
     }
 }
Пример #7
0
require('../../framework.php');
require('../../oauth2.php');

require('config.php');

session_name('oauth2_example');
session_start();

$GitHubAuth = new GitHub_OAuth2 (GITHUB_APP_ID, GITHUB_APP_SECRET, GITHUB_APP_CALLBACK);

if (!isset($_SESSION['git_access_token'])) {

	if (!count($_GET)) {

		$_SESSION['state'] = sha(uniqid(rand(), true));

		$GitHubAuth->state = $_SESSION['state'];

		$GitHubAuth->authenticate();

	} else {

		if (isset($_SESSION['state'], $_GET['state']) && $_SESSION['state'] == $_GET['state']) {

			unset($_SESSION['state']);

			$GitHubAuth->callback(function ($return) {

				$_SESSION['git_access_token'] = OAuth2::parseToken($return);
Пример #8
0
<?php

/**
 * overviewfunctions.php
 *
 * @version 1
 * @copyright 2008 By MadnessRed for XNova_Redisigned
 */
//This file is to clear out all that complicated mess from overview.php.
//Start any alerts
$alerts = '';
//First if they delete a planet.
if ($_GET['mode'] == "delplanet" && $_GET['planet_id'] == $user['current_planet']) {
    //Check the pass and check they are not deleting homeworld
    if (sha($_GET['password']) == $user['password'] && $user['id_planet'] != $user['current_planet']) {
        DestroyPlanet($user['current_planet'], $user, $planetrow);
        // Tout s'est bien passé ! La colo a été effacée !!
        $alerts .= "<br />" . $lang['deletemessage_ok'];
    } elseif ($user['id_planet'] == $user["current_planet"]) {
        // Et puis quoi encore ??? On ne peut pas effacer la planete mere ..
        // Uniquement les colonies crées apres coup !!!
        $alerts .= "<br />" . $lang['deletemessage_wrong'];
    } else {
        // Erreur de saisie du mot de passe je n'efface pas !!!
        $alerts .= "<br />" . $lang['deletemessage_fail'];
    }
    die($alerts);
}
//Or if they rename a planet.
if ($_GET['mode'] == "renplanet") {
    //Filter the name
Пример #9
0
if ($_POST) {
    $login = doquery("SELECT * FROM {{table}} WHERE `username` = '" . mysql_escape_string($_POST['username']) . "' LIMIT 1", "users", true);
    if ($login) {
        if (!$pw_encrypted) {
            $_POST['password'] = sha($_POST['password']);
        }
        if ($login['password'] == $_POST['password']) {
            if (isset($_POST["rememberme"])) {
                $expiretime = time() + 31536000;
                $rememberme = 1;
            } else {
                $expiretime = 0;
                $rememberme = 0;
            }
            @(include 'config' . UNIVERSE . '.php');
            $cookie = $login["id"] . "/%/" . $login["username"] . "/%/" . sha($login["password"] . "--" . $dbsettings["secretword"]) . "/%/" . $rememberme;
            setcookie($game_config['COOKIE_NAME'], $cookie, $expiretime, "/", "", 0);
            unset($dbsettings);
            header("Location: " . AddUniToString($redirect));
            exit;
        } else {
            header("Location: " . AddUniToString('./login.php?bad=Password'));
        }
    } else {
        header("Location: " . AddUniToString('./login.php?bad=Username'));
    }
} elseif ($old) {
    $Count = doquery('SELECT COUNT(*) as `players` FROM {{table}} WHERE 1', 'users', true);
    $LastPlayer = doquery('SELECT `username` FROM {{table}} ORDER BY `register_time` DESC', 'users', true);
    $parse['last_user'] = $LastPlayer['username'];
    $PlayersOnline = doquery("SELECT COUNT(DISTINCT(id)) as `onlinenow` FROM {{table}} WHERE `onlinetime` > '" . (time() - 900) . "';", 'users', true);