Ejemplo n.º 1
0
 public function reCalculate()
 {
     $this->clearPoints();
     $users = array();
     foreach ($this->GetIdNameTournament() as $t_id => $name) {
         foreach ($this->GetMatches(array("tournament_id" => $t_id, 'calculate' => 1)) as $m_id => $matche) {
             if ($rates = $this->GetRate(array("matche_id" => $m_id))) {
                 foreach ($rates as $rate) {
                     $point = intval(GetPoint($matche['points_1'], $matche['points_2'], $rate['rpoints_1'], $rate['rpoints_2']));
                     if (empty($users[$rate['user_id']])) {
                         $users[$rate['user_id']] = 0;
                     }
                     $users[$rate['user_id']] += $point;
                 }
             }
         }
     }
     foreach ($users as $id => $points) {
         $this->db->query("UPDATE " . PREFIX . "_users SET points={$points} WHERE user_id=" . $id);
     }
     clear_cache();
 }
Ejemplo n.º 2
0
 Данный код защищен авторскими правами
=====================================================
*/
if (!defined('DATALIFEENGINE')) {
    die("Hacking attempt!");
}
$per_page = 50;
$start = intval($_REQUEST['start']) ? intval($_REQUEST['start']) : 0;
if ($rates = $total->GetRate('', $start, $per_page, array("date_rate" => "DESC"))) {
    $tpl->OpenTable();
    $tpl->OpenSubtable("Ставки");
    $tpl->OTable(array("Пользователь", "Турнир", "Матч", "Балы"));
    $i = $start;
    foreach ($rates as $rate) {
        if ($rate['calculate']) {
            $point = GetPoint($rate['mpoints_1'], $rate['mpoints_2'], $rate['rpoints_1'], $rate['rpoints_2']);
        } else {
            $point = "n/a";
        }
        $archive = $rate['archive'] ? 'style="color:gray;" align="center"' : 'align="center"';
        $tpl->row(array($rate['username'], $archive => $rate['tname'], $rate['komanda1'] . " " . $rate['rpoints_1'] . " - " . $rate['rpoints_2'] . " " . $rate['komanda2'], $point));
        $i++;
    }
    $tpl->echo = FALSE;
    if ($nav = $tpl->navigation($start, $per_page, $i, $total->GetCount('', "rates"), $PHP_SELF . "?mod=totalizator&action=rates")) {
        echo $tpl->row($nav, true, true);
    }
    $tpl->echo = TRUE;
    $tpl->CTable();
    $tpl->CloseSubtable();
    $tpl->CloseTable();
Ejemplo n.º 3
0
 $tpl->load_template("totalizator/totalizator.tpl");
 if ($matche || $stats || $user) {
     $tpl->set_block('#\\[matches\\](.*?)\\[/matches\\]#si', "");
     $tpl->set_block('#\\[rates\\](.*?)\\[/rates\\]#si', "\\1");
     $tpl->set_block("#\\[user_page\\](.*?)\\[/user_page\\]#si", "");
     foreach ($array as $value) {
         $j++;
         preg_match("'\\[rates_row\\](.*?)\\[/rates_row\\]'si", $tpl->copy_template, $matches);
         $point = $total_conf['allow_view_points'] || $value['calculate'] ? $value['rpoints_1'] . " - " . $value['rpoints_2'] : $lang_total['wait_result'];
         if ($matche || $user) {
             if ($user && isset($_GET['tor'])) {
                 $point = $value['name'];
                 $points = $value['points'];
             } else {
                 if ($value['calculate']) {
                     $points = "+" . GetPoint($value['mpoints_1'], $value['mpoints_2'], $value['rpoints_1'], $value['rpoints_2']);
                     if ($user) {
                         $point = $value['komanda1'] . " " . $value['rpoints_1'] . " - " . $value['rpoints_2'] . " " . $value['komanda2'];
                     }
                 } else {
                     $points = $lang_total['wait_result'];
                     if ($user) {
                         $point = $value['komanda1'] . " " . ($total_conf['allow_view_points'] ? $value['rpoints_1'] . " - " . $value['rpoints_2'] : '') . " " . $value['komanda2'];
                     }
                 }
             }
         } else {
             $points = $value['points'];
         }
         $replace = array("{user}" => "<a " . GetUrl("user", $value['username']) . " >" . $value['username'] . "</a>", "{point}" => $point, "{points}" => $points, "{i}" => $j);
         $tpl->copy_template = strtr($tpl->copy_template, $replace);
Ejemplo n.º 4
0
 $id = intval($id);
 if (!$id) {
     $error[] = "Не указан матч";
 } elseif ($matche = $total->GetMatches(array("matche_id" => $id), 0, 1)) {
     if ($matche['points_1'] == "" || $matche['points_2'] == "") {
         $error[] = "Не уазан счёт в этом матче";
         $hidden_array['subaction'] = "doedit";
         $hidden_array['id'] = $id;
         $button = "Сохранить";
         $title = "Редактирование матча";
     } else {
         clear_cache();
         $good = 0;
         if ($rates = $total->GetRate(array("matche_id" => $id))) {
             foreach ($rates as $rate) {
                 $point = intval(GetPoint($matche['points_1'], $matche['points_2'], $rate['rpoints_1'], $rate['rpoints_2']));
                 if ($point) {
                     $total->db->query("UPDATE " . PREFIX . "_users SET points=points+{$point} WHERE user_id='{$rate['user_id']}'");
                     $good++;
                 }
             }
             $total->UpdateMatche(array("rates_right" => $good, "calculate" => 1), array("matche_id" => $id));
             $tpl->msg("Подсчёт очков", "Подсчёт отчков завершён. Из {$matche['rates']} ставок, правильно продугадали исход матча {$good}", $PHP_SELF, false);
         } else {
             $total->UpdateMatche(array("calculate" => 1), array("matche_id" => $id));
             $tpl->msg("Подсчёт очков", "Ставок на этот матч не было", $PHP_SELF, false);
         }
     }
 } else {
     $error[] = "Такого матча не существует";
 }