public function index()
 {
     error_reporting(0);
     $this->content_view = 'home';
     $this->data['announcements'] = Announcement::get_announcements();
     $this->load->helper('twitch');
     load_api_interface();
     $result = json_decode(file_get_contents("https://api.twitch.tv/kraken/streams?game=StepMania&limit=4"));
     $this->data['streams'] = $result->streams;
     $this->data['recent_scores'] = User_score::get_recent_scores();
     $this->data['new_songs'] = Ranked_file::get_recent_files();
     $this->data['new_packs'] = Pack::get_recent_packs();
     $this->data['online_users'] = User::get_online_users();
     $this->data['leaderboards'] = Leaderboards_cache::get_all_lbs();
 }
 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);
         }
     }
 }
 public function view($id = null)
 {
     if (empty($id)) {
         redirect('packs');
     } else {
         if (Pack::count(array('conditions' => array('id = ?', $id))) == 0) {
             redirect('packs');
         } else {
             $this->data['pack'] = Pack::get_single_pack_info($id);
             $this->data['subtitle'] = $this->data['pack']->name;
             $this->data['songs'] = Ranked_file::all(array('conditions' => array("pack_id = ?", $id), 'order' => "rate ASC"));
             if (isset($_GET['recalc'])) {
                 error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE ^ E_WARNING);
                 set_time_limit(0);
                 foreach ($this->data['songs'] as $file) {
                     $calculated_difficulty = $this->_process_everything($file->raw_file, $file->rate);
                     $file->difficulty_score = $calculated_difficulty;
                 }
             }
             $this->content_view = 'packs/view';
         }
     }
 }
 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";
         }
     }
 }
 public static function get_recent_files()
 {
     return Ranked_file::all(array("select" => "`ranked_files`.id, `ranked_files`.title, `ranked_files`.artist, `ranked_files`.rate, `ranked_files`.stamina_file, `ranked_files`.file_type, `ranked_files`.pack_id, `ranked_files`.length, `ranked_files`.difficulty_score, `ranked_files`.new_difficulty_score, `packs`.name AS pack_name, `packs`.abbreviation AS pack_abbr", "joins" => "LEFT JOIN `packs` ON `packs`.id = `ranked_files`.pack_id", 'order' => '`ranked_files`.id DESC', 'limit' => 100));
 }
 public function charts_json()
 {
     $charts = Ranked_file::get_all_charts();
     $json_ready = array();
     $json_ready['data'] = array();
     foreach ($charts as $song) {
         $data = array();
         // Fill out the data array.
         if ($this->session->userdata('user_level') >= 2) {
             $data[0] = "<span class=\"label warning\"><a href=\"/mod/edit_chart/{$song->id}\">Edit</a></span> <a href=\"/charts/view/{$song->id}\">{$song->title}</a>";
         } else {
             $data[0] = "<a href=\"/charts/view/{$song->id}\">{$song->title}</a>";
         }
         $data[1] = $song->artist;
         $data[2] = number_format($song->rate, 1);
         $data[3] = number_format($song->difficulty_score, 2);
         $data[4] = "<a href=\"/packs/view/{$song->pack_id}\">{$song->pack_name}</a>" . (!empty($song->pack_abbr) ? " (" . $song->pack_abbr . ")" : "");
         $data[5] = gmdate("i:s", $song->length);
         $typestring = "";
         if ($song->stamina_file) {
             $typestring .= "Stamina, ";
         }
         $typestring .= ucwords($song->file_type);
         $data[6] = $typestring;
         if ($this->session->userdata('user_level')) {
             $data[7] = "<span class=\"label primary\"><a href=\"/scores/submit/{$song->id}\">Submit Score</a></span>";
         } else {
             $data[7] = null;
         }
         array_push($json_ready['data'], $data);
     }
     $this->data['charts'] = $json_ready;
     $this->output->set_content_type('application/json');
 }
 function auto_type_test()
 {
     $this->data['subtitle'] = "Auto File Type Comparison Page";
     $this->data['charts'] = Ranked_file::all();
     $this->content_view = "admin/auto_type";
 }
Esempio n. 10
0
 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);
 }