Exemplo n.º 1
0
    public function leaderboards($category = '')
    {
        //@todo: Fix this hack. OMG what a horrible hack. That's what I get for coding at 4am =)
        $categories = array('acceleration-0-20' => 'Acceleration from 0 to 20 km/h', 'acceleration-0-40' => 'Acceleration from 0 to 40 km/h', 'acceleration-0-100' => 'Acceleration from 0 to 100 km/h');
        if (!array_key_exists($category, $categories)) {
            $category = 'acceleration-0-100';
        }
        $this->template->title = $categories[$category];
        $results = new Result_Model();
        if ($rows = $results->get_results($category, 10)) {
            $output = '';
            foreach ($rows as $r) {
                $output .= '
			<tr>
	<td align="right">' . $r->username . '</td>
	<td align="center">' . $r->value . ' seconds</td>
	<td>' . $r->result_date . '</td>
</tr>';
            }
            $output = '
<table cellspacing="20" cellpadding="20">
<tr>
	<td><strong>Nick</strong></td>
	<td><strong>Record (seconds)</strong></td>
	<td><strong>Date</strong></td>
</tr>
' . $output . '
</table>
		
';
        } else {
            $output = "No results :(";
        }
        $this->template->header = $categories[$category];
        $this->template->content = $output;
        $this->template->sidebar_title = 'Categories';
        $this->template->sidebar_content = '
<ul class="list">
	<li><a href="' . url::site('pages/leaderboards/acceleration-0-20') . '" title="Leaderboard for acceleration from 0 to 20 km/h category">Acceleration from 0 to 20 km/h</a></li> 
	<li><a href="' . url::site('pages/leaderboards/acceleration-0-40') . '" title="Leaderboard for acceleration from 0 to 40 km/h category">Acceleration from 0 to 40 km/h</a></li> 
	<li><a href="' . url::site('pages/leaderboards/acceleration-0-100') . '" title="Leaderboard for acceleration from 0 to 100 km/h category">Acceleration from 0 to 100 km/h</a></li> 
</ul>
';
    }
Exemplo n.º 2
0
 public function update($category)
 {
     $cat = new Category_Model();
     if ($cat->category_exists($category) and apiler::is_authorized()) {
         $xml = apiler::get_xml();
         $result = new Result_Model();
         if ($result->insert($category, $_SERVER['PHP_AUTH_USER'], $xml['value'])) {
             print "OK";
             die;
         } else {
             header("HTTP/1.1 400 Bad Request");
             echo "Invalid request";
             die;
         }
     } else {
         header("HTTP/1.0 404 Not Found");
         die('Category not found or not authorized');
     }
 }