Example #1
0
    // Player info display pieces.
    require_once LIB_ROOT . "control/Skill.php";
    $skillsListObj = new Skill();
    $player = new Player(self_char_id());
    $level = $player->level();
    $class = $player->class_display_name();
    // Just to be displayed in the template.
    $starting_turns = $player->turns();
    $starting_ki = $player->ki();
    $status_list = get_status_list();
    $no_skills = true;
    $stealth = $skillsListObj->hasSkill('Stealth');
    if ($stealth) {
        $no_skills = false;
    }
    $stealth_turn_cost = $skillsListObj->getTurnCost('Stealth');
    $unstealth_turn_cost = $skillsListObj->getTurnCost('Unstealth');
    $chi = $skillsListObj->hasSkill('Chi');
    $speed = $skillsListObj->hasSkill('speed');
    $hidden_resurrect = $skillsListObj->hasSkill('hidden resurrect');
    $midnight_heal = $skillsListObj->hasSkill('midnight heal');
    $kampo_turn_cost = $skillsListObj->getTurnCost('Kampo');
    $kampo = $skillsListObj->hasSkill('kampo');
    $heal = $skillsListObj->hasSkill('heal');
    $heal_turn_cost = $skillsListObj->getTurnCost('heal');
    $clone_kill = $skillsListObj->hasSkill('clone kill');
    $clone_kill_turn_cost = $skillsListObj->getTurnCost('clone kill');
    $wrath = $skillsListObj->hasSkill('wrath');
    $can_harmonize = $starting_ki;
    display_page('skills.tpl', 'Your Skills', get_certain_vars(get_defined_vars(), array('status_list')), array('quickstat' => 'player'));
}
Example #2
0
    	}*/
    $changed = PlayerDAO::saveDetails($char);
    redirect('/stats.php?changed=' . (int) $changed . ($profile_changed ? '&profile_changed=1' : ''));
}
/*
if(false && DEBUG){
	$description = 'This is a description here and all';
	$goals = 'Kill ninja of the ramen clan';
	$beliefs = 'I believe in a one true ninja god';
	$instincts = 'When I hear whistling, I duck';
	$traits = 'Hardy, nervous, meaty, silent';
}
*/
$player = self_info();
//$player['created_date']=$player['created_date']? date("c", strtotime($player['created_date'])) : null;
$class_theme = class_theme($char->class_identity());
$level_category = level_category($player['level']);
$status_list = get_status_list();
$gravatar_url = generate_gravatar_url($player['player_id']);
$gurl = $gravatar_url;
$rank_display = get_rank($char_id);
// rank display.
$profile_editable = $player['messages'];
$parts = get_certain_vars(get_defined_vars(), ['player', 'level_category', 'status_list', 'description', 'goals', 'beliefs', 'instincts', 'traits', 'dev', 'changed']);
// Set the parts array's player clan if any is found.
if ($parts['player_clan'] = get_clan_by_player_id($char_id)) {
    // Set the char clan name and id for later usage.
    $parts['clan_name'] = $parts['player_clan']->getName();
    $parts['clan_id'] = $parts['player_clan']->getID();
}
display_page('stats.tpl', 'Ninja Stats', $parts, array('quickstat' => 'player'));
Example #3
0
    $data = query_row('
	SELECT player_id, uname, accounts.verification_number as verification_number, CASE WHEN active = 1 THEN 1 ELSE 0 END AS active, accounts.active_email, 
	CASE WHEN accounts.confirmed = 1 THEN 1 ELSE 0 END as confirmed, status, member, days, ip, players.created_date 
	FROM accounts JOIN account_players ON _account_id = account_id JOIN players ON _player_id = player_id 
	WHERE account_id = :acctId', array(':acctId' => $aid));
    if (rco($data)) {
        $check = $data['verification_number'];
        $confirmed = $data['confirmed'];
        $active = $data['active'];
        $username = $data['uname'];
    } else {
        $active = $check = $confirmed = $username = null;
    }
    //debug($data, $confirm, $check, $confirmed);
    //debug($check, $confirm);
    $confirmation_confirmed = false;
    if ($confirmed == 1) {
        // Confirmation state from the database is already confirmed.
    } else {
        if ($check && $confirm && $confirm == $check || $acceptable_admin_override) {
            // Confirmation number matches whats in the database and neither is null, or the admin override was met.
            query('UPDATE accounts SET operational = true, confirmed=1 WHERE account_id = :accountID', array(':accountID' => $aid));
            $statement = DatabaseConnection::$pdo->prepare('UPDATE players SET active = 1 WHERE player_id in (SELECT _player_id FROM account_players WHERE _account_id = :accountID)');
            $statement->bindValue(':accountID', $aid);
            $statement->execute();
            // todo - test for success
            $confirmation_confirmed = true;
        }
    }
    display_page('confirm.tpl', 'Game Confirmation', get_certain_vars(get_defined_vars()), array('quickstat' => false));
}
Example #4
0
    $limitvalue = (int) max(0, $page * $record_limit - $record_limit);
    // Get the ninja information to create the lists.
    $sel = "SELECT rank_id, rankings.uname, class.class_name as class, class.identity as class_identity, class.theme as class_theme, rankings.level, rankings.alive, rankings.days, clan_player._clan_id AS clan_id, clan.clan_name, players.player_id\n\tFROM rankings LEFT JOIN clan_player ON player_id = _player_id LEFT JOIN clan ON clan_id = _clan_id JOIN players on rankings.player_id = players.player_id JOIN class on class.class_id = players._class_id " . (count($where_clauses) ? " WHERE active = 1 AND " . implode($where_clauses, ' AND ') : "") . " ORDER BY rank_id ASC, player_id ASC\n\tLIMIT :limit OFFSET :offset";
    $ninja_info = DatabaseConnection::$pdo->prepare($sel);
    for ($i = 0; $i < count($queryParams); $i++) {
        // *** Reformulate if queryParams gets to be more than 3 or for items
        $ninja_info->bindValue(':param' . $i, $queryParams[$i]);
    }
    $ninja_info->bindValue(':limit', $record_limit);
    $ninja_info->bindValue(':offset', $limitvalue);
    $ninja_info->execute();
    $last_page = $totalrows - $record_limit * $page > 0;
    if (!$searched) {
        // Will not display active ninja on a search page.
        $active_ninjas = get_active_players(5, $alive_only);
        // get  the currently active ninjas
    } else {
        $active_ninjas = null;
    }
    // Format each of the player rows, then just pass 'em to the template.
    $ninja_count = 0;
    $player_rows = '';
    $ninja_rows = array();
    while ($a_player = $ninja_info->fetch()) {
        $ninja_rows[] = format_ninja_row($a_player);
        $ninja_rows[$ninja_count]['odd_or_even'] = ($ninja_count + 1) % 2 ? "odd" : "even";
        $ninja_count++;
    }
    $parts = get_certain_vars(get_defined_vars(), $whitelist = array('ninja_rows', 'active_ninjas'));
    display_page('list.tpl', 'Ninja List', $parts, array('quickstat' => false));
}
Example #5
0
    $error = null;
    $sent = null;
    $attemptedToSendEmail = false;
    if (!$email && ($password_request || $confirmation_request)) {
        $error = 'invalidemail';
    } else {
        if ($email) {
            $data = user_having_email($email);
            $username = $data['uname'];
            if (!$data['uname']) {
                $error = 'nouser';
            } elseif ($password_request && $data['active']) {
                $sent = send_account_email($email, $data);
                $attemptedToSendEmail = true;
            } else {
                // Confirmation request.
                if ($data['confirmed']) {
                    $error = 'alreadyconfirmed';
                } else {
                    $attemptedToSendEmail = true;
                    $sent = send_confirmation_email($email, $data);
                }
            }
        }
    }
    if ($attemptedToSendEmail && !$sent) {
        $error = 'emailfail';
    }
    $body_classes = 'account-issues';
    display_page('account_issues.tpl', 'Account Problems', get_certain_vars(get_defined_vars(), array('data')), array('quickstat' => false));
}
Example #6
0
init(true, false);
// Initialize the environment.
// TODO: Protect this file from unlogged-in displaying.
// *** Turning the header variables into variables for this page.
$section_only = in('section_only') === '1';
// Check whether it's an ajax section.
$command = in('command');
$user_id = get_user_id();
$info = self_info();
$health = $user_id ? $info['health'] : 0;
$strength = $user_id ? $info['strength'] : 0;
$gold = $user_id ? $info['gold'] : 0;
$kills = $user_id ? $info['kills'] : 0;
$turns = $user_id ? $info['turns'] : 0;
$level = $user_id ? $info['level'] : 0;
$class = $user_id ? $info['class'] : 0;
$bounty = $user_id ? $info['bounty'] : 0;
$player = new Player($user_id);
$username = $player->vo->uname;
$next_level = $player->vo->level * 5;
// This needs to have a more centralized formula source.
$max_health = max_health_by_level($level);
$progress = $user_id ? min(100, round($kills / $next_level * 100)) : 0;
$health_pct = $user_id ? min(100, round($health / $max_health * 100)) : 0;
$status_list = get_status_list();
$viewinv = $command == 'viewinv';
// *** TODO: switch this to query() when we switch to SMARTY. Templatelite can't handle iterating over the resultset ***
$items = query_array("SELECT item.item_display_name as item, amount FROM inventory join item on item_type = item.item_id WHERE owner = :user ORDER BY item.item_display_name", array(':user' => $user_id));
$parts = get_certain_vars(get_defined_vars(), array('items', 'status_list'));
// Pull current flat vars + the resultset into the template.
display_page('quickstats.tpl', 'Quickstats', $parts, array('quickstat' => false));
Example #7
0
    } else {
        if ($change_pass) {
            if ($change_pass == 2) {
                $verify = is_authentic($username, $passW);
                if ($verify) {
                    if ($in_newPass === $in_confirmPass) {
                        changePassword($user_id, $in_newPass);
                        $change_pass = 0;
                        $successMessage = 'Your password has been updated.';
                    } else {
                        $error = 'Your new passwords did not match.';
                    }
                } else {
                    $error = 'You did not provide the correct current password.';
                }
            }
        }
    }
}
$account_info = self_account_info();
// Get the existing oauth info, if any.
$oauth_provider = $account_info['oauth_provider'];
$oauth = $oauth_provider && $account_info['oauth_id'];
$player = self_info();
$gravatar_url = generate_gravatar_url($player['player_id']);
// TODO: Lock account info behind password or password reset choice wall?
// TODO: Current account's characters list.
// TODO: Create another character interface...
// TODO: Choose next active character interface...
$parts = get_certain_vars(get_defined_vars(), array('player', 'account_info', 'oauth_provider', 'oauth'));
display_page('account.tpl', 'Your Account', $parts, array('quickstat' => 'player'));
Example #8
0
 public function index()
 {
     $target = $player = first_value(in('ninja'), in('player'), in('find'), in('target'));
     $target_id = first_value(in('target_id'), in('player_id'), get_char_id($target));
     // Find target_id if possible.
     $target_player_obj = Player::find($target_id);
     $viewed_name_for_title = null;
     if ($target_player_obj !== null) {
         $viewed_name_for_title = $target_player_obj->name();
     }
     if ($target_player_obj === null) {
         $template = 'no-player.tpl';
         $parts = array();
     } else {
         $player_info = $target_player_obj->as_array();
         // Pull the info out of the object.
         if (!$player_info) {
             $template = 'no-player.tpl';
             $parts = array();
         } else {
             $viewing_player_obj = Player::find(self_char_id());
             $self = self_char_id() && self_char_id() == $player_info['player_id'];
             // Record whether this is a self-viewing.
             if ($viewing_player_obj !== null) {
                 $char_info = $viewing_player_obj->dataWithClan();
                 $char_id = $viewing_player_obj->id();
                 $username = $viewing_player_obj->name();
             } else {
                 $char_info = [];
             }
             $player = $target = $player_info['uname'];
             // reset the target and target_id vars.
             $target_id = $player_info['player_id'];
             // Get the player's kills for this date.
             $kills_today = query_item('select sum(killpoints) from levelling_log where _player_id = :player_id and killsdate = CURRENT_DATE and killpoints > 0', array(':player_id' => $target_id));
             $viewers_clan = $viewing_player_obj !== null ? ClanFactory::clanOfMember($viewing_player_obj) : null;
             // Attack Legal section
             $params = array('required_turns' => 0, 'ignores_stealth' => true);
             // 0 for unstealth.
             $attack_error = 'You must become a ninja first.';
             $attack_allowed = false;
             if (null !== $viewing_player_obj) {
                 $AttackLegal = new AttackLegal($viewing_player_obj, $target_player_obj, $params);
                 $attack_allowed = $AttackLegal->check(false);
                 $attack_error = $AttackLegal->getError();
             }
             $sel_rank_spot = "SELECT rank_id FROM rankings WHERE player_id = :char_id limit 1";
             $rank_spot = query_item($sel_rank_spot, array(':char_id' => $player_info['player_id']));
             // Display the player info.
             $status_list = get_status_list($player);
             $gurl = $gravatar_url = $target_player_obj->avatarUrl();
             if ($viewing_player_obj !== null && !$attack_error && !$self) {
                 // They're not dead or otherwise unattackable.
                 // Attack or Duel
                 $skillDAO = new SkillDAO();
                 $is_admin = false;
                 if ($viewing_player_obj) {
                     $is_admin = $viewing_player_obj->isAdmin();
                 }
                 if (!$is_admin) {
                     $combat_skills = $skillDAO->getSkillsByTypeAndClass($viewing_player_obj->_class_id, 'combat', $viewing_player_obj->level);
                     $targeted_skills = $skillDAO->getSkillsByTypeAndClass($viewing_player_obj->_class_id, 'targeted', $viewing_player_obj->level);
                 } else {
                     $combat_skills = $skillDAO->all('combat');
                     $targeted_skills = $skillDAO->all('targeted');
                 }
                 // Pull the items and some necessary data about them.
                 $items = inventory_counts($char_id);
                 $valid_items = rco($items);
                 // row count
             }
             // End of the there-was-no-attack-error section
             $set_bounty_section = '';
             $communication_section = '';
             $player_clan_section = '';
             $clan = ClanFactory::clanOfMember($player_info['player_id']);
             $same_clan = false;
             // Player clan and clan members
             if ($clan) {
                 $viewer_clan = $viewing_player_obj ? ClanFactory::clanOfMember($viewing_player_obj) : null;
                 $clan_id = $clan->getID();
                 $clan_name = $clan->getName();
                 if ($viewer_clan) {
                     $same_clan = $clan->getID() == $viewer_clan->getID();
                     $display_clan_options = $viewing_player_obj && !$self && $same_clan && $viewing_player_obj->isClanLeader();
                 } else {
                     $same_clan = $display_clan_options = false;
                 }
             }
             // Send the info to the template.
             $template = 'player.tpl';
             $parts = get_certain_vars(get_defined_vars(), array('char_info', 'viewing_player_obj', 'target_player_obj', 'combat_skills', 'targeted_skills', 'player_info', 'self', 'rank_spot', 'kills_today', 'gravatar_url', 'status_list', 'clan', 'items'));
         }
     }
     return ['template' => $template, 'title' => 'Ninja' . ($viewed_name_for_title ? ": {$viewed_name_for_title}" : ' Profile'), 'parts' => $parts, 'options' => ['quickstat' => 'player']];
 }
Example #9
0
<?php

$alive = true;
$private = true;
if ($error = init($private, $alive)) {
    display_error($error);
} else {
    $settings = get_settings();
    //var_dump($settings);
    // TODO: Add a "don't use javascript" setting, mainly for the chat iframe.
    display_page('settings.tpl', 'Settings', get_certain_vars(get_defined_vars(), array()), array('quickstat' => 'player'));
}
Example #10
0
<?php

$private = false;
$alive = false;
if ($error = init($private, $alive)) {
    display_error($error);
} else {
    display_page('staff.tpl', 'Ninjawars Staff', get_certain_vars(get_defined_vars(), array()), array('quickstat' => false));
}
Example #11
0
    $match_string = in('enemy_match', null, 'no filter');
    $add_enemy = in('add_enemy', null, 'toInt');
    $remove_enemy = in('remove_enemy', null, 'toInt');
    $enemy_limit = 20;
    $max_enemies = false;
    $enemy_list = null;
    if ($match_string) {
        $found_enemies = get_enemy_matches($match_string);
    } else {
        $found_enemies = null;
    }
    if (is_numeric($remove_enemy) && $remove_enemy != 0) {
        remove_enemy($remove_enemy);
    }
    if (is_numeric($add_enemy) && $add_enemy != 0) {
        add_enemy($add_enemy);
    }
    if (count($enemy_list) > $enemy_limit - 1) {
        $max_enemies = true;
    }
    $enemy_list = get_current_enemies();
    $enemyCount = $enemy_list->rowCount();
    $enemy_list = $enemy_list->fetchAll();
    $recent_attackers = get_recent_attackers($char)->fetchAll();
    // Add enemies at the bottom of the fight page.
    // Array that simulates database display information for switching out for an npc database solution.
    $npcs = array(array('name' => 'Peasant', 'identity' => 'peasant', 'image' => 'fighter.png'), array('name' => 'Thief', 'identity' => 'thief', 'image' => 'thief.png'), array('name' => 'Merchant', 'identity' => 'merchant', 'image' => 'merchant.png'), array('name' => "Guard", 'identity' => 'guard', 'image' => 'guard.png'), array('name' => 'Samurai', 'identity' => 'samurai', 'image' => 'samurai.png'));
    // Generic/abstracted npcs
    $other_npcs = NpcFactory::npcsData();
    display_page('enemies.tpl', 'Fight', get_certain_vars(get_defined_vars(), array('char_name', 'npcs', 'other_npcs', 'char_info', 'found_enemies', 'active_ninjas', 'recent_attackers', 'enemy_list', 'peers')), array('quickstat' => false));
}
Example #12
0
    $set_bounty_section = '';
    $communication_section = '';
    $clan_options_section = '';
    $player_clan_section = '';
    $player_profile_message = '';
    if ($username && !$self) {
        // Allows the viewer to set bounty on a player.
        ob_start();
        display_set_bounty($player_info);
        // TODO: Move this functionality to the doshin.
        $set_bounty_section = ob_get_contents();
        ob_end_clean();
        $communication_section = render_communication($player_info['uname']);
        ob_start();
        // Clan leader options on players in their clan.
        display_clan_options($player_info, $viewing_player_obj);
        $clan_options_section = ob_get_contents();
        ob_end_clean();
    }
    // Player clan and clan members
    $player_clan_section = render_player_clan($player_info, $viewers_clan);
    // Player profile message
    ob_start();
    display_player_profile($player_info);
    $player_profile_message = ob_get_contents();
    ob_end_clean();
}
// Send the info to the template.
$parts = get_certain_vars(get_defined_vars(), array('skills_available'));
echo render_template('player.tpl', $parts);
include SERVER_ROOT . "interface/footer.php";
Example #13
0
            $same_clan = false;
            $player_info = format_health_percent($player_info);
            // Player clan and clan members
            if ($clan) {
                $viewer_clan = is_logged_in() ? get_clan_by_player_id($viewing_player_obj->vo->player_id) : null;
                $clan_members = get_clan_members($clan->getID())->fetchAll();
                // TODO - When we switch to Smarty 3, remove fetchAll for foreach
                $clan_id = $clan->getID();
                $clan_name = $clan->getName();
                if ($viewer_clan) {
                    $same_clan = $clan->getID() == $viewer_clan->getID();
                    $display_clan_options = $username && !$self && $same_clan && is_clan_leader($viewing_player_obj->vo->player_id);
                } else {
                    $same_clan = $display_clan_options = false;
                }
            }
            // Send the info to the template.
            $template = 'player.tpl';
            $parts = get_certain_vars(get_defined_vars(), array('char_info', 'viewing_player_obj', 'target_player_obj', 'combat_skills', 'targeted_skills', 'player_info', 'self', 'rank_spot', 'kills_today', 'level_category', 'gravatar_url', 'status_list', 'clan', 'clan_members', 'items', 'duel_checked'));
        }
    }
    function getTurnCost($p_params, &$tpl)
    {
        $skillListObj = new Skill();
        return $skillListObj->getTurnCost($p_params['skillName']);
    }
    $template = prep_page($template, 'Ninja' . ($viewed_name_for_title ? ": {$viewed_name_for_title}" : ' Profile'), $parts, array('quickstat' => 'player'));
    $template->registerPlugin("function", "getTurnCost", "getTurnCost");
    $template->fullDisplay();
}
// End of no display_error area.
Example #14
0
<?php

require_once LIB_ROOT . "control/lib_player.php";
$private = false;
$alive = false;
if ($error = init($private, $alive)) {
    redirect('list.php');
} else {
    $stats = membership_and_combat_stats();
    $vicious_killer = $stats['vicious_killer'];
    $duels = query_array("SELECT dueling_log.*, attackers.player_id AS attacker_id, defenders.player_id AS defender_id FROM dueling_log JOIN players AS attackers ON attackers.uname = attacker JOIN players AS defenders ON defender = defenders.uname ORDER BY id DESC LIMIT 500");
    display_page('duel.tpl', 'Bath House', get_certain_vars(get_defined_vars(), array('duels')), array('quickstat' => false));
}
Example #15
0
<?php

$private = false;
$alive = false;
if ($error = init($private, $alive)) {
    display_error($error);
} else {
    display_page('about.tpl', 'About NinjaWars', get_certain_vars(get_defined_vars(), array()), array('quickstat' => false));
}
Example #16
0
$is_not_logged_in = !$is_logged_in;
$username = get_username();
$user_id = get_user_id();
// Player counts.
$stats = membership_and_combat_stats($sql);
$player_count = $stats['player_count'];
$players_online = $stats['players_online'];
$header = render_html_for_header('Live By the Sword', 'main-body', $is_index = true);
// render_html_for_header Writes out the html,head,meta,title,css,js.
$version = 'NW Version 1.7.1 2009.11.22';
// Display main iframe page unless logged in.
$main_src = 'main.php';
if ($is_logged_in) {
    $level = getLevel($username);
    $main_src = 'list_all_players.php';
    if ($level == 1) {
        $main_src = 'tutorial.php';
    } elseif ($level < 6) {
        $main_src = 'attack_player.php';
    }
}
$parts = get_certain_vars(get_defined_vars(), array('vicious_killer'));
if (!$is_logged_in) {
    echo render_template('splash2.tpl', $parts);
    // Non-logged in template.
} else {
    echo render_template('index.tpl', $parts);
    // Logged in template.
}
echo render_footer(null, true);
// Skip quickstats.
Example #17
0
    $work_multiplier = 30;
    $worked = $new_gold = $not_enough_energy = $use_second_description = null;
    $is_logged_in = is_logged_in();
    $worked = intval(in('worked'));
    $recommended_to_work = 10;
    // Store or retrieve the last value of turns worked.
    if ($worked && is_numeric($worked)) {
        set_setting('turns_worked', $worked);
        $recommended_to_work = $worked;
    } else {
        $last_worked = get_setting('turns_worked');
        $recommended_to_work = $last_worked ? $last_worked : 10;
    }
    // Work only if the work was requested, not just if the setting was set.
    if ($worked > 0) {
        $turns = get_turns($char_id);
        if ($worked > $turns) {
            $not_enough_energy = true;
        } else {
            $new_gold = $worked * $work_multiplier;
            // *** calc amount worked ***
            add_gold($char_id, $new_gold);
            $turns = subtractTurns($char_id, $worked);
            $use_second_description = true;
        }
    }
    $gold = get_gold($char_id);
    // Get the current/final gold.
    $gold_display = number_format($gold);
    display_page('work.tpl', 'Working in the Village', get_certain_vars(get_defined_vars(), array()), array('quickstat' => 'player'));
}
Example #18
0
        if ($deleteAccount == 2) {
            SESSION::set('delete_attempts', 1);
            $error = 'Deleting of account failed, please email ' . SUPPORT_EMAIL;
        } else {
            $confirm_delete = true;
        }
    }
} else {
    if ($changeprofile == 1) {
        // Limit the profile length.
        if ($newprofile != "") {
            $sql->Update("UPDATE players SET messages = '" . sql($newprofile) . "' WHERE uname = '" . sql($username) . "'");
            $affected_rows = $sql->a_rows;
            $profile_changed = true;
        } else {
            $error = "Can not enter a blank profile.";
        }
    }
}
$level_and_cat = render_level_and_category($player['level']);
$status_list = render_status_section();
$avatar_display = render_avatar_section($player['player_id']);
// include and render from player.php
$rank_display = get_rank($username, $sql);
// rank display.
$health_section = render_health_section($player['health']);
$profile_editable = $player['messages'];
$profile_display = out($profile_editable);
$parts = get_certain_vars(get_defined_vars(), array('player'));
echo render_template("stats.tpl", $parts);
include SERVER_ROOT . "interface/footer.php";
Example #19
0
    $sentMessage = in('message');
    $sent = false;
    $user_id = self_char_id();
    $target = $_SERVER['PHP_SELF'];
    $channel = 1;
    $chatlength = min(3000, max(30, $chatlength));
    // Min 30, max 3000
    // Take in a chat and record it to the database.
    if ($user_id) {
        if ($command == "postnow" && $message) {
            send_chat($user_id, $message);
            redirect('/village.php');
        }
    }
    // Output section.
    $message_count = get_chat_count();
    $chats = get_chats($view_all ? null : $chatlength);
    // Limit by chatlength unless a request to view all came in.
    $chats = $chats->fetchAll();
    $more_chats_to_see = count($chats) < $message_count ? true : null;
    $parts = get_certain_vars(get_defined_vars(), array('chats'));
    function get_time_ago($p_params, &$tpl)
    {
        return time_ago($p_params['ago'], $p_params['previous_date']);
    }
    $template = prep_page('village.tpl', 'Chat Board', $parts, array('quickstat' => false));
    //$template->register_function('time_ago', 'get_time_ago');
    $template->registerPlugin("function", "time_ago", "get_time_ago");
    $template->fullDisplay();
}
// End of player-is-live so no error block
Example #20
0
if ($message && $messenger) {
    if ($to_clan && $has_clan) {
        $message_sent_to = message_to_clan($message);
    } elseif (!!$target_id) {
        send_message($user_id, $target_id, $message);
        $message_sent_to = $to;
        // (
    }
}
if ($delete) {
    delete_messages();
}
$messages = get_messages($user_id, $limit, $offset);
$message_count = message_count();
$pages = ceil($message_count / $limit);
// Total pages.
//$current_page = floor(($message_count/$limit) - $limit); //
$nav = render_message_nav($page, $pages, $limit);
read_messages($user_id);
// mark messages as read for next viewing.
// TODO: Handle "send" and "deletion";
$message_list = '';
if (!empty($messages)) {
    foreach ($messages as $loop_message) {
        $loop_message['message'] = out($loop_message['message']);
        $message_list .= render_template('single_message.tpl', array('message' => $loop_message));
    }
}
$parts = get_certain_vars(get_defined_vars());
echo render_template('messages.tpl', $parts);
include SERVER_ROOT . "interface/footer.php";
Example #21
0
                        }
                        // phase 3
                    }
                    // phase 2
                }
                // phase 1
            }
            // phase 0
        } else {
            $error = 'Your password entries did not match. Please try again.';
        }
    }
    // *** Validates submission.
    // Pull the class choices.
    function class_choices()
    {
        $st = query_array('SELECT identity, class_name, class_note as expertise FROM class WHERE class_active');
        $classes = array();
        foreach ($st as $loop_class) {
            $classes[$loop_class['identity']] = array('name' => $loop_class['class_name'], 'expertise' => $loop_class['expertise']);
        }
        return $classes;
    }
    $classes = class_choices();
    if (!$enteredClass) {
        $first_class = key($classes);
        $enteredClass = $first_class;
    }
    display_page('signup.tpl', 'Become a Ninja', get_certain_vars(get_defined_vars(), array('classes')), array('quickstat' => false));
}
// End of display error check.