public function view($id = null) { if (empty($id)) { redirect('charts'); } else { if (Ranked_file::count(array('conditions' => array('id = ?', $id))) == 0) { redirect('charts'); } else { error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE ^ E_WARNING); $file = Ranked_file::find($id); $pack = Pack::find($file->pack_id); $this->data['user_scores'] = User_score::get_scores_for_chart($id); $this->data['pack'] = $pack; $this->data['subtitle'] = $file->title; $this->_process_everything($file->raw_file, $file->rate); } } }
function recalculate_score($id) { $score_to_calculate = User_score::get_score_for_recalculate($id); $score_only = User_score::find($id); $file_only = Ranked_file::find($score_to_calculate[0]->file_id); $this->data['score'] = $score_to_calculate; $user_percent = calculate_dp_percent($score_to_calculate[0]) / 100; if ($user_percent < 0.91) { $this->data['new_difficulty'] = "Score below 91%, not calculated."; } else { if ($user_percent > 0.97) { $user_percent = 0.97; } $this->_process_everything($file_only->raw_file, $file_only->rate, $user_percent); $applied_difficulty = $this->data['user_score_goal_result']; $score_only->applied_score = $applied_difficulty; $score_only->save(); $this->data['new_difficulty'] = $applied_difficulty; } $this->layout_view = "ajax"; $this->content_view = "ajax/recalculate_score"; }
public function view($username) { $username = urldecode($username); if (empty($username) || User::count(array('conditions' => array('username = ?', $username))) != 1) { redirect('home'); } $this_user = User::find_by_username($username); $this->data['user'] = $this_user; $this->data['subtitle'] = $this_user->display_name; $this->data['scores'] = User_score::get_scores_for_user($this_user->id); if (isset($_GET['recalc'])) { error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE ^ E_WARNING); set_time_limit(0); foreach ($this->data['scores'] as $score) { $chart = Ranked_file::find($score->file_id); $calculated_difficulty = $this->_process_everything($chart->raw_file, $chart->rate); $score->difficulty_score = $calculated_difficulty; } } $approved_scores = User_score::get_scores_for_user_approved($this_user->id, "difficulty_score DESC"); $overall_leaderboard = Leaderboards_cache::find(array('conditions' => array('type = ?', 1), 'order' => 'id desc')); $overall_leaderboard = (array) json_decode(base64_decode($overall_leaderboard->data)); $speed_leaderboard = Leaderboards_cache::find(array('conditions' => array('type = ?', 2), 'order' => 'id desc')); $speed_leaderboard = (array) json_decode(base64_decode($speed_leaderboard->data)); $jumpstream_leaderboard = Leaderboards_cache::find(array('conditions' => array('type = ?', 3), 'order' => 'id desc')); $jumpstream_leaderboard = (array) json_decode(base64_decode($jumpstream_leaderboard->data)); $jack_leaderboard = Leaderboards_cache::find(array('conditions' => array('type = ?', 4), 'order' => 'id desc')); $jack_leaderboard = (array) json_decode(base64_decode($jack_leaderboard->data)); $technical_leaderboard = Leaderboards_cache::find(array('conditions' => array('type = ?', 5), 'order' => 'id desc')); $technical_leaderboard = (array) json_decode(base64_decode($technical_leaderboard->data)); $stamina_leaderboard = Leaderboards_cache::find(array('conditions' => array('type = ?', 6), 'order' => 'id desc')); $stamina_leaderboard = (array) json_decode(base64_decode($stamina_leaderboard->data)); $i = 1; foreach ($overall_leaderboard as $row) { if ($row->username == $this_user->display_name) { $this->data['overall_rank'] = $i; $this->data['overall_score'] = $row->average_score; } $i++; } $i = 1; foreach ($speed_leaderboard as $row) { if ($row->username == $this_user->display_name) { $this->data['speed_rank'] = $i; $this->data['speed_score'] = $row->average_score; } $i++; } $i = 1; foreach ($jumpstream_leaderboard as $row) { if ($row->username == $this_user->display_name) { $this->data['jumpstream_rank'] = $i; $this->data['jumpstream_score'] = $row->average_score; } $i++; } $i = 1; foreach ($jack_leaderboard as $row) { if ($row->username == $this_user->display_name) { $this->data['jack_rank'] = $i; $this->data['jack_score'] = $row->average_score; } $i++; } $i = 1; foreach ($technical_leaderboard as $row) { if ($row->username == $this_user->display_name) { $this->data['technical_rank'] = $i; $this->data['technical_score'] = $row->average_score; } $i++; } $i = 1; foreach ($stamina_leaderboard as $row) { if ($row->username == $this_user->display_name) { $this->data['stamina_rank'] = $i; $this->data['stamina_score'] = $row->average_score; } $i++; } foreach ($approved_scores as $score) { $this->data['top_score'] = $score->difficulty_score; break; } $categories_required = 1; $individual_required = 1; if ($this->data['top_score'] < 15) { $categories_required = 1; $individual_required = 1; } else { if ($this->data['top_score'] < 20) { $categories_required = 2; $individual_required = 1; } else { if ($this->data['top_score'] < 24) { $categories_required = 2; $individual_required = 2; } else { if ($this->data['top_score'] < 28) { $categories_required = 3; $individual_required = 2; } else { if ($this->data['top_score'] < 31) { $categories_required = 3; $individual_required = 3; } else { $categories_required = 3; $individual_required = 5; } } } } } $this->data['categories_required'] = $categories_required; $this->data['individual_required'] = $individual_required; $this->content_view = "profiles/view"; }
if ($error) { ?> <div data-alert class="alert-box alert"> Something went wrong with your submission, please make sure all fields are completed properly.<br /> <?php echo validation_errors('<span>', '</span><br />'); ?> </div> <?php } ?> <?php $c = Ranked_file::count(array('conditions' => array('title = ? AND subtitle = ? AND artist = ? AND rate = ?', $meta['title'], $meta['subtitle'], $meta['artist'], $rate))); if ($c > 0) { $f = Ranked_file::find(array('conditions' => array('title = ? AND subtitle = ? AND artist = ? AND rate = ?', $meta['title'], $meta['subtitle'], $meta['artist'], $rate))); ?> <div data-alert class="alert-box alert"> This appears to be a duplicate of <a href="/charts/view/<?php echo $f->id; ?> " style="color: #ffffff; text-decoration: underline;">this chart.</a> </div> <?php } ?> <form action="/mod/rank_chart" method="post" id="rank-chart-confirm"> <input type="hidden" name="step" value="2" /> <input type="hidden" name="auto_type" value="<?php echo $meta['autodetermined_file_type'];
public function remove($score_id = null) { $this->require_login(); if (!$score_id) { redirect('home'); } else { if (User_score::count(array('conditions' => array('id = ?', $score_id))) != 1) { redirect('home'); } else { $user_score = User_score::find($score_id); $write_mod_log = false; if ($user_score->user_id != $this->session->userdata('user_id')) { if ($this->session->userdata('user_level') < 2) { redirect('home'); } else { $write_mod_log = true; } } $this->data['user_score'] = $user_score; $song = Ranked_file::find($user_score->file_id); $this->data['song'] = $song; $user_score->status = "removed"; $user_score->save(); $scores_user = User::find($user_score->user_id); if ($write_mod_log) { $log_string = $this->session->userdata('username') . " (" . $this->session->userdata('display_name') . ") removed user score: " . $scores_user->username . " (" . $scores_user->display_name . ") " . $song->title . " " . number_format($song->rate, 2) . "x"; write_to_mod_log($log_string); } $this->content_view = "scores/removed"; } } }
function delete_chart($chart_id) { if (Ranked_file::count(array('conditions' => array('id = ?', $chart_id))) != 1) { redirect('home'); } $this->content_view = "mod/delete_chart_success"; $chart = Ranked_file::find($chart_id); $title = $chart->title; $diff = $chart->difficulty_score; $rate = $chart->rate; $chart->delete(); $scores = User_score::all(array('conditions' => array('file_id = ?', $chart_id))); foreach ($scores as $score) { $score->status = "removed"; $score->save(); } $log_string = $this->session->userdata('username') . " (" . $this->session->userdata('display_name') . ") deleted chart: " . $title . " " . number_format($rate, 1) . "x " . " - " . $diff; write_to_mod_log($log_string); }