Esempio n. 1
0
            $array = isset($array) ? $array : false;
        } else {
            $tmp = $cache->load();
            foreach ($tmp as $t) {
                if ($t['town'] == $townid) {
                    $array[] = $t;
                }
            }
            $array = isset($array) ? $array : false;
        }
        // Design and present the list
        if ($array) {
            ?>
			<h2>
				<?php 
            echo ucfirst(town_id_to_name($townid));
            ?>
 house list.
			</h2>
			<table id="housesTable" class="table table-striped">
				<tr class="yellow">
					<th>Name:</th>
					<th>Size:</th>
					<th>Doors:</th>
					<th>Beds:</th>
					<th>Price:</th>
					<th>Owner:</th>
					
				</tr>
					<?php 
            foreach ($array as $value) {
Esempio n. 2
0
				<option value="1">Male(boy)</option>
				<option value="0">Female(girl)</option>
				</select>
			</li>
			<li>
				<!-- Available towns to select from when creating character -->
				Town:<br>
				<select name="selected_town">
				<?php 
    foreach ($config['available_towns'] as $tid) {
        ?>
				<option value="<?php 
        echo $tid;
        ?>
"><?php 
        echo town_id_to_name($tid);
        ?>
</option>
				<?php 
    }
    ?>
				</select>
			</li>
			<?php 
    /* Form file */
    Token::create();
    ?>
			<li>
				<input type="submit" value="Create Character">
			</li>
		</ul>
Esempio n. 3
0
function user_character_list($account_id)
{
    //$count = user_character_list_count($account_id);
    $account_id = (int) $account_id;
    if (config('TFSVersion') == 'TFS_10') {
        $characters = mysql_select_multi("SELECT `id`, `name`, `level`, `vocation`, `town_id`, `lastlogin` FROM `players` WHERE `account_id`='{$account_id}' ORDER BY `level` DESC");
        if ($characters !== false) {
            $onlineArray = mysql_select_multi("SELECT `player_id` FROM `players_online`;");
            $onlineIds = array();
            if ($onlineArray !== false) {
                foreach ($onlineArray as $row) {
                    $onlineIds[] = $row['player_id'];
                }
            }
            for ($i = 0; $i < count($characters); $i++) {
                $online = in_array($characters[$i]['id'], $onlineIds);
                if ($online) {
                    $characters[$i]['online'] = 1;
                } else {
                    $characters[$i]['online'] = 0;
                }
                unset($characters[$i]['id']);
            }
        }
    } else {
        $characters = mysql_select_multi("SELECT `name`, `level`, `vocation`, `town_id`, `lastlogin`, `online` FROM `players` WHERE `account_id`='{$account_id}' ORDER BY `level` DESC");
    }
    if ($characters !== false) {
        $count = count($characters);
        for ($i = 0; $i < $count; $i++) {
            $characters[$i]['vocation'] = vocation_id_to_name($characters[$i]['vocation']);
            // Change vocation id to vocation name
            $characters[$i]['town_id'] = town_id_to_name($characters[$i]['town_id']);
            // Change town id to town name
            // Make lastlogin human read-able.
            if ($characters[$i]['lastlogin'] != 0) {
                $characters[$i]['lastlogin'] = getClock($characters[$i]['lastlogin'], true, false);
            } else {
                $characters[$i]['lastlogin'] = '******';
            }
            $characters[$i]['online'] = online_id_to_name($characters[$i]['online']);
            // 0 to "offline", 1 to "ONLINE".
        }
    }
    return $characters;
}
Esempio n. 4
0
 /**
  * Create player.
  *
  * @param  none
  * @access public
  * @return bool $status
  **/
 public function create()
 {
     // If player already have an id, the player already exist.
     if (is_null($this->_playerdata['id']) && is_string($this->_playerdata['name'])) {
         // Confirm player does not exist
         $name = format_character_name($this->_playerdata['name']);
         $name = validate_name($name);
         $name = sanitize($name);
         $exist = mysql_select_single("SELECT `id` FROM `players` WHERE `name`='{$name}' LIMIT 1;");
         if ($exist !== false) {
             $this->errors[] = "A player with the name [{$name}] already exist.";
             return false;
         }
         $config = fullConfig();
         if (user_character_exist($_POST['name']) !== false) {
             $errors[] = 'Sorry, that character name already exist.';
         }
         if (!preg_match("/^[a-zA-Z_ ]+\$/", $_POST['name'])) {
             $errors[] = 'Your name may only contain a-z, A-Z and spaces.';
         }
         if (strlen($_POST['name']) < $config['minL'] || strlen($_POST['name']) > $config['maxL']) {
             $errors[] = 'Your character name must be between ' . $config['minL'] . ' - ' . $config['maxL'] . ' characters long.';
         }
         // name restriction
         $resname = explode(" ", $_POST['name']);
         foreach ($resname as $res) {
             if (in_array(strtolower($res), $config['invalidNameTags'])) {
                 $errors[] = 'Your username contains a restricted word.';
             } else {
                 if (strlen($res) == 1) {
                     $errors[] = 'Too short words in your name.';
                 }
             }
         }
         // Validate vocation id
         if (!in_array((int) $_POST['selected_vocation'], $config['available_vocations'])) {
             $errors[] = 'Permission Denied. Wrong vocation.';
         }
         // Validate town id
         if (!in_array((int) $_POST['selected_town'], $config['available_towns'])) {
             $errors[] = 'Permission Denied. Wrong town.';
         }
         // Validate gender id
         if (!in_array((int) $_POST['selected_gender'], array(0, 1))) {
             $errors[] = 'Permission Denied. Wrong gender.';
         }
         if (vocation_id_to_name($_POST['selected_vocation']) === false) {
             $errors[] = 'Failed to recognize that vocation, does it exist?';
         }
         if (town_id_to_name($_POST['selected_town']) === false) {
             $errors[] = 'Failed to recognize that town, does it exist?';
         }
         if (gender_exist($_POST['selected_gender']) === false) {
             $errors[] = 'Failed to recognize that gender, does it exist?';
         }
         // Char count
         $char_count = user_character_list_count($session_user_id);
         if ($char_count >= $config['max_characters']) {
             $errors[] = 'Your account is not allowed to have more than ' . $config['max_characters'] . ' characters.';
         }
         if (validate_ip(getIP()) === false && $config['validate_IP'] === true) {
             $errors[] = 'Failed to recognize your IP address. (Not a valid IPv4 address).';
         }
         echo "create player";
         // Make sure all neccesary values are set
         //Register
         $character_data = array('name' => format_character_name($_POST['name']), 'account_id' => $session_user_id, 'vocation' => $_POST['selected_vocation'], 'town_id' => $_POST['selected_town'], 'sex' => $_POST['selected_gender'], 'lastip' => ip2long(getIP()), 'created' => time());
         array_walk($character_data, 'array_sanitize');
         $cnf = fullConfig();
         if ($character_data['sex'] == 1) {
             $outfit_type = $cnf['maleOutfitId'];
         } else {
             $outfit_type = $cnf['femaleOutfitId'];
         }
         // Create the player
     } else {
         echo "Player already exist.";
         return false;
     }
 }