Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- global $tmp, $cache, $host, $user, $pass, $db, $realm_name;
- $realm_status = new cache('realm_status', 30);
- $output = $realm_status->get_cache();
- //Remake cache
- if(!$output)
- {
- //Let's make some statistics! :D
- $stat['accs'] = 0;²
- $stat['on'] = 0;
- $stat['char'] = 0;
- $stat['hor'] = 0; //Get your mind out of the gutter, young boy! :P
- $stat['all'] = 0; //Beats hordies 24/7, fosho!
- //Total Accounts:
- $account = new mysql;
- $account->connect($host['realm'], $user['realm'], $pass['realm'], true, $db['accounts']);
- $count = $account->query("SELECT count(*) FROM accounts");
- $count = $account->fetch_array($count);
- $stat['accs'] = $count['count(*)']; //Bampf, total accounts!
- //Online/Total characters:
- $characters = new MySQL();
- $characters->connect($host['realm'], $user['realm'], $pass['realm'], true, $db['characters']);
- $count = $characters->query("SELECT race, online FROM characters");
- while($row = $characters->fetch_array($count)) {
- if($row['online'] == '1') $stat['on']++; //Total Online
- if(($row['race'] == 1 || $row['race'] == 3 || $row['race'] == 4 || $row['race'] == 7 || $row['race'] == 11)) //Online Alliance
- $stat['all']++;
- $stat['char']++; //Total characters
- }
- //This way, we're not wasting time on the hordies
- $stat['hor'] = $stat['char'] - $stat['all'];
- //Let's make sure we don't get errors
- foreach($stat as $key => $val) {
- $stat[$key] = ($val) ? $val : '0';
- }
- //Now, let's make a nice little percentage
- $percent = $stat['on'] / 1000; //Then, make it the length of the bar
- $percent = round( $percent, 2); //We need to round it, so that it doesn't look messy
- if($percent > 95) $percent = 95; //The design can't take more than 95%, so this 'fixes' it
- //Alright, now let's cache all this junk.. in yo trunk.. 'Choo gonna do with all that junk, all that junk - in yo trunk?
- $output = "{$stat['on']}|{$stat['char']}|{$stat['hor']}|{$stat['all']}|{$percent}|{$stat['accs']}";
- $realm_status->set_cache($output);
- }
- //Cached? Well we need to ready this guy up!
- else {
- $output = explode('|', $output);
- $stat['accs'] = $output[5]; //Total Characters
- $stat['on'] = $output[0]; //Online players
- $stat['char'] = $output[1]; //Total Characters
- $stat['hor'] = $output[2]; //Total Hordies
- $stat['all'] = $output[3]; //Total Alliances
- $percent = $output[4]; //Percent bar
- }
- //And let's set dem vars! :)
- $tmp->set_var('total_accounts', $stat['accs']);
- $tmp->set_var('online_players', $stat['on']);
- $tmp->set_var('total_chars', $stat['char']);
- $tmp->set_var('total_hors', $stat['hor']);
- $tmp->set_var('total_alls', $stat['all']);
- $tmp->set_var('percent', $percent);
- #Shoutbox
- global $site, $tmp, $cache, $username;
- $shout_msg = ' ';
- $shout_color = 'red';
- //If a user has posted a shout
- if(isset($_POST['submit_shout']))
- {
- //Check the user is logged in
- if(@isset($_SESSION['ulogged_in']) and $_SESSION['ulogged_in'] === true)
- {
- //Let's make sure the shout isn't empty
- if(!empty($_POST['shoutmsg']))
- {
- //Let's set some vars!
- $time = @date("Y-m-d");
- $shout = mysql_real_escape_string($_POST['shoutmsg']);
- //And now, put it in the database
- $site->query("INSERT INTO shoutbox (user, shout, time, ip) VALUES ('{$username}', '{$shout}', '{$time}', '{$_SERVER['REMOTE_ADDR']}')");
- //Update status
- $shout_msg = 'Message submitted';
- $shout_color = 'green';
- //Now, we clear the cache
- @unlink('cache/shoutbox.cache');
- } else $shout_msg = 'Your shout is empty!';
- } else $shout_msg = 'You must be logged in for this!';
- }
- //Get shouts
- $shoutbox = new cache('shoutbox', 30);
- $output = $shoutbox->get_cache();
- //Same drill, if no cache:
- if(!$output)
- {
- $query = $site->query("SELECT * FROM shoutbox ORDER BY id DESC LIMIT 5");
- //Found any shouts?
- if($site->num_rows($query) > 0)
- {
- //Let's display dem mon!
- while($row = $site->fetch_array($query))
- {
- $output .= '<div class="shout"><img src="template/RedemptionWoW/images/bullet.png" width="5" height="5" alt="bullet" />';
- $output .= ' [<span class="blue">'.$row['time'].'</span>] '.$row['user'].' shouts:<br />';
- $output .= '<span class="shoutmsg">'.nl2br($row['shout']).'</span></div>';
- }
- }
- //No shouts? Well, let's post up a message!
- else
- {
- $output .= '<div class="shout"><img src="template/RedemptionWoW/images/bullet.png" width="5" height="5" alt="bullet" />';
- $output .= 'There are no shouts!</div>'; // :'(
- }
- }
- $tmp->set_var('shoutbox', $output);
- $tmp->set_var('shout_msg', $shout_msg);
- $tmp->set_var('shout_color', $shout_color);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement