put($cache_league, $xml_str, 900);
+ }
+ else
+ {
+ trigger_error(sprintf($user->lang['ERROR_READ_LEAGUE_XML']) . adm_back_link($this->u_action), E_USER_WARNING);
+ }
+ }
+ else
+ {
+ trigger_error(sprintf($user->lang['ERROR_OPEN_LEAGUE_XML']) . adm_back_link($this->u_action), E_USER_WARNING);
+ }
+ }
+ $xml_league = new \SimpleXMLElement($xml_str);
+
+ $xml_table = array();
+ foreach ($xml_league->children() AS $node)
+ {
+ $xml_entry = array();
+ foreach($node->children() AS $cnode)
+ {
+ $xml_entry[$cnode->getName()] = sprintf("%s", $cnode);
+ }
+ $xml_table[$node->getName()][] = $xml_entry;
+ $this->xml_ary[$node->getName()] = $xml_table[$node->getName()];
+ }
+ return $this->xml_ary;
+ }
+
+ function check_teams($season, $league, &$team_id_map_ary, &$duplicate_team_ids_ary, &$missing_team_ids_ary)
+ {
+ global $config, $db, $user, $auth, $template, $cache;
+ global $phpbb_root_path, $phpbb_admin_path, $phpEx;
+
+ $team_id_ary = array();
+ foreach ($this->xml_ary['footb_teams'] AS $xml_team)
+ {
+ $new_team_id = $this->request->variable('team_id_db_' . $xml_team['team_id'], 0);
+ $team_id_map_ary[$xml_team['team_id']] = $new_team_id;
+ if (in_array($new_team_id, $team_id_ary) or $new_team_id == 0)
+ {
+ $duplicate_team_ids_ary[] = $new_team_id;
+ }
+ else
+ {
+ $team_id_ary[] = $new_team_id;
+ }
+ }
+ $table_name = constant('FOOTB_TEAMS');
+ // All database teams selected?
+ $sql = 'SELECT team_id
+ FROM ' . $table_name . "
+ WHERE season = $season
+ AND league = $league
+ ORDER BY team_id";
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if (!in_array($row['team_id'], $team_id_ary))
+ {
+ $missing_team_ids_ary[] = $row['team_id'];
+ }
+ }
+ $db->sql_freeresult($result);
+ if (sizeof($duplicate_team_ids_ary) or sizeof($missing_team_ids_ary))
+ {
+ // Display Mapping
+ return true;
+ }
+ else
+ {
+ // set new IDs in xml_ary
+ foreach ($this->xml_ary['footb_teams'] AS $key => $xml_team)
+ {
+ $this->xml_ary['footb_teams'][$key]['team_id'] = $team_id_map_ary[$xml_team['team_id']];
+ }
+ usort($this->xml_ary['footb_teams'], 'sort_teams');
+
+ foreach ($this->xml_ary['footb_matches'] AS $key => $xml_team)
+ {
+ $this->xml_ary['footb_matches'][$key]['team_id_home'] = $team_id_map_ary[$xml_team['team_id_home']];
+ $this->xml_ary['footb_matches'][$key]['team_id_guest'] = $team_id_map_ary[$xml_team['team_id_guest']];
+ }
+ return false;
+ }
+ }
+
+
+ function compare_teams($season, $league, $team_id_map_ary, $duplicate_team_ids_ary)
+ {
+ global $config, $db, $user, $auth, $template, $cache;
+ global $phpbb_root_path, $phpbb_admin_path, $phpEx;
+
+ $i = 0;
+ $j = 0;
+ $db_teams = array();
+ $different_teams = false;
+ $same_quantity = false;
+ $table_name = constant('FOOTB_TEAMS');
+ // Grab basic data for select league
+ $sql = 'SELECT team_id
+ , team_name
+ , team_name_short
+ , team_symbol
+ FROM ' . $table_name . "
+ WHERE season = $season
+ AND league = $league
+ ORDER BY team_name";
+ $result = $db->sql_query($sql);
+ $rows = $db->sql_fetchrowset($result);
+ $db->sql_freeresult($result);
+ $same_quantity = (sizeof($rows) == sizeof($this->xml_ary['footb_teams'])) ? true : false;
+
+ if ($same_quantity)
+ {
+ foreach ($rows AS $row)
+ {
+ $db_teams[$row['team_id']] = $row;
+ }
+ }
+ else
+ {
+ $different_teams = true;
+ $sql = 'SELECT DISTINCT team_id
+ , team_name
+ , team_name_short
+ , team_symbol
+ FROM ' . $table_name . "
+ ORDER BY team_name";
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $db_teams[$row['team_id']] = $row;
+ }
+ $db->sql_freeresult($result);
+ }
+ $row_number = 0;
+ foreach ($this->xml_ary['footb_teams'] AS $xml_team)
+ {
+ $team_options = '';
+ $team_id = (sizeof($team_id_map_ary)) ? $team_id_map_ary[$xml_team['team_id']] : $xml_team['team_id'];
+ if (!$same_quantity)
+ {
+ if (array_key_exists($team_id, $db_teams))
+ {
+ $team_options = '';
+ }
+ else
+ {
+ $team_options = '';
+ }
+ }
+ foreach ($db_teams AS $db_team_id => $db_team_data)
+ {
+ $selected = ($db_team_id == $team_id) ? ' selected="selected"' : '';
+ $team_options .= '';
+ }
+ if (!array_key_exists($team_id, $db_teams) or sizeof($duplicate_team_ids_ary))
+ {
+ $different_teams = true;
+ }
+ $row_number++;
+ $row_class = (!($row_number % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
+ $template->assign_block_vars('teams', array(
+ 'ROW_CLASS' => $row_class,
+ 'TEAM_ID_XML' => $xml_team['team_id'],
+ 'TEAM_IMAGE_XML' => ($xml_team['team_symbol']) ? $this->ext_football_path . 'images/flags/' . $xml_team['team_symbol'] : $phpbb_root_path . 'football/images/flags/blank.gif',
+ 'TEAM_NAME_XML' => $xml_team['team_name'],
+ 'TEAM_NAME_SHORT_XML' => $xml_team['team_name_short'],
+ 'TEAM_OPTIONS' => $team_options,
+ 'DUPLICATE_TEAM' => (in_array($team_id, $duplicate_team_ids_ary)) ? true : false,
+
+ ));
+ }
+ if ($different_teams)
+ {
+ // Display Mapping
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ function compare_table($table, $season, $league, $index_field, $check, &$error)
+ {
+ global $config, $db, $user, $auth, $template, $cache;
+ global $phpbb_root_path, $phpbb_admin_path, $phpEx;
+
+ $i = 0;
+ $j = 0;
+ $tpl = '';
+ $order = ($table == 'FOOTB_MATCHES') ? array('season' => 0, 'league' => 0, 'match_no' => 1, 'team_id_home' => 4, 'team_id_guest' => 5,
+ 'goals_home' => 6, 'goals_guest' => 7, 'matchday' => 0, 'status' => 12, 'match_datetime' => 2,
+ 'group_id' => 3, 'formula_home' => 10, 'formula_guest' => 11, 'ko_match' => 13,
+ 'goals_overtime_home' => 8, 'goals_overtime_guest' => 9) : array();
+ $table_name = constant($table);
+ // Grab basic data for select league
+ $sql = 'SELECT *
+ FROM ' . $table_name . "
+ WHERE season = $season
+ AND league = $league
+ ORDER BY 1, 2, 3";
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($table == 'FOOTB_TEAMS')
+ {
+ while ($i < sizeof($this->xml_ary[strtolower($table)]) and $this->xml_ary[strtolower($table)][$i]['team_id'] <> $row['team_id'])
+ {
+ // New team
+ if ($check)
+ {
+ $this->xml_ary[strtolower($table)][$i]['season'] = "$season";
+ $this->xml_ary[strtolower($table)][$i]['league'] = "$league";
+ }
+ else
+ {
+ $row_class = (!($j % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
+ $id = 'insert_team';
+ $tpl .= $this->print_differences(array(), $this->xml_ary[strtolower($table)][$i], $this->xml_ary[strtolower($table)][$i], $id, $row_class, array());
+ $j++;
+ }
+ $i++;
+ }
+ }
+ $diff = array_diff_assoc($this->xml_ary[strtolower($table)][$i], $row);
+ if ($check)
+ {
+ foreach ($diff AS $key => $value)
+ {
+ switch($key)
+ {
+ case 'league':
+ $this->xml_ary[strtolower($table)][$i]['league'] = "$league";
+ break;
+ case 'league_type':
+ $error[] = sprintf($user->lang['MISMATCH_LEAGUE_TYPE'], $value);
+ break;
+ case 'matchdays':
+ $error[] = sprintf($user->lang['MISMATCH_MATCHDAYS'], $value);
+ break;
+ case 'matches_on_matchday':
+ $error[] = sprintf($user->lang['MISMATCH_MOM'], $value);
+ break;
+ case 'matches':
+ $error[] = sprintf($user->lang['MISMATCH_MATCHES'], $value);
+ break;
+ case 'season':
+ $this->xml_ary[strtolower($table)][$i]['season'] = "$season";
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (sizeof($diff))
+ {
+ $row_class = (!($j % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
+ $id = $table . '_' . $row[$index_field];
+ $tpl .= $this->print_differences($row, $this->xml_ary[strtolower($table)][$i], $diff, $id, $row_class, $order);
+ $j++;
+ }
+ }
+ $i++;
+ }
+ $db->sql_freeresult($result);
+ if (!$check and $tpl <> '')
+ {
+ $template->assign_block_vars(strtolower($table), array(
+ 'TPL' => $tpl,
+ ));
+ }
+ }
+
+
+ function show_xml(&$xml_ary, $table, $season, $league)
+ {
+ global $config, $db, $user, $auth, $template, $cache;
+ global $phpbb_root_path, $phpbb_admin_path, $phpEx;
+
+ $j = 0;
+ $tpl = '';
+ switch ($table)
+ {
+ case 'FOOTB_LEAGUES':
+ $order = array('season' => 0, 'league' => 0, 'league_name' => 0, 'league_name_short' => 2, 'league_type' => 4,
+ 'matchdays' => 6, 'matches_on_matchday' => 8, 'win_result' => 10, 'win_result_02' => 10, 'win_matchday' => 10,
+ 'win_season' => 10, 'points_mode' => 10, 'points_result' => 12, 'points_tendency' => 12,
+ 'points_diff' => 12, 'points_last' => 12, 'join_by_user' => 12, 'join_in_season' => 12,
+ 'bet_in_time' => 12, 'rules_post_id' => 14, 'bet_ko_type' => 14, 'bet_points' => 16);
+ break;
+ case 'FOOTB_MATCHES':
+ $order = array('season' => 0, 'league' => 0, 'match_no' => 1, 'team_id_home' => 4, 'team_id_guest' => 5,
+ 'goals_home' => 6, 'goals_guest' => 7, 'matchday' => 0, 'status' => 12, 'match_datetime' => 2,
+ 'group_id' => 3, 'formula_home' => 10, 'formula_guest' => 11, 'ko_match' => 13,
+ 'goals_overtime_home' => 8, 'goals_overtime_guest' => 9);
+ break;
+ default:
+ $order = array();
+ }
+ foreach ($this->xml_ary[strtolower($table)] AS $key => $xml_row)
+ {
+ $this->xml_ary[strtolower($table)][$key]['season'] = "$season";
+ if ($league)
+ {
+ $this->xml_ary[strtolower($table)][$key]['league'] = "$league";
+ }
+ $row_class = (!($j % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
+ $tpl .= $this->print_xml_data($xml_row, $row_class, $order);
+ $j++;
+ }
+ $template->assign_block_vars(strtolower($table), array(
+ 'TPL' => $tpl,
+ ));
+ }
+
+
+ /**
+ * Print differences beetween Database and XML-Data
+ */
+ function print_differences($table_row, $xml_row, $diff, $id, $row_class, $order)
+ {
+ global $user, $league_info;
+
+ if (sizeof($table_row) AND substr($id, 0, 11) == 'FOOTB_TEAMS')
+ {
+ if ($xml_row['team_symbol'] == '')
+ {
+ unset($diff['team_symbol']);
+ if (!sizeof($diff))
+ {
+ return '';
+ }
+ }
+ }
+ if (sizeof($table_row) AND substr($id, 0, 13) == 'FOOTB_MATCHES')
+ {
+ if ($xml_row['status'] > 0 AND ($xml_row['status'] == $table_row['status'] - 3))
+ {
+ unset($diff['status']);
+ if (!sizeof($diff))
+ {
+ return '';
+ }
+ }
+ if ($xml_row['status'] < 0 AND $league_info['bet_in_time'])
+ {
+ if ($table_row['status'] == 0)
+ {
+ unset($diff['status']);
+ if (!sizeof($diff))
+ {
+ return '';
+ }
+ }
+ else
+ {
+ $diff['status'] = 0;
+ }
+ }
+ }
+ $tpl = '';
+ $tpl_ary = array();
+ if (sizeof($diff))
+ {
+ if (sizeof($table_row))
+ {
+ $tpl .= '';
+ // match status update and database
+ if (substr($id, 0, 13) == 'FOOTB_MATCHES')
+ {
+ $tpl .= '';
+ $tpl .= '';
+ if ($xml_row['status'] > 0 AND ($xml_row['status'] == $table_row['status'] +3))
+ {
+ unset($diff['status']);
+ }
+ }
+
+ }
+ else
+ {
+ // Insert team
+ $tpl .= '';
+ }
+ }
+
+ $tpl .= ' ';
+ foreach ($xml_row AS $key => $value)
+ {
+ if (array_key_exists($key, $diff))
+ {
+ if (sizeof($table_row))
+ {
+ $color_open = '* ';
+ $color_close = '';
+ }
+ else
+ {
+ $color_open = '* ';
+ $color_close = '';
+ }
+ }
+ else
+ {
+ $color_open = '';
+ $color_close = '';
+ }
+ if (sizeof($order))
+ {
+ $value = (substr($key, 0, 7) == 'team_id') ? $value . ' ' . $this->team_ary[$value] : $value;
+ $tpl_ary[$order[$key]] = ($order[$key] % 2) ? $color_open . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . $color_close . ' ' :
+ '' . $color_open . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . $color_close . ' ';
+ }
+ else
+ {
+ if ($key <> 'season' and $key <> 'league')
+ {
+ // Write table fields
+ if (sizeof($table_row))
+ {
+ $tpl .= ' | ' .
+ $color_open . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . $color_close .
+ ' | ';
+ }
+ else
+ {
+ $tpl .= '' .
+ $color_open . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . $color_close .
+ ' | ';
+ }
+ }
+ }
+ }
+ if (sizeof($order))
+ {
+ ksort($tpl_ary);
+ $tpl .= implode(" ", $tpl_ary);
+ }
+ if (sizeof($table_row))
+ {
+ $tpl .= ' |
';
+ }
+ else
+ {
+ $tpl .= ' | ';
+ }
+
+ return $tpl;
+ }
+
+
+ /**
+ * Print differences beetween Database and XML-Data
+ */
+ function print_xml_data($xml_row, $row_class, $order)
+ {
+ global $user;
+
+ $tpl = '';
+ $tpl_ary = array();
+
+ $tpl .= '';
+ foreach ($xml_row AS $key => $value)
+ {
+ if (sizeof($order))
+ {
+ $value = (substr($key, 0, 7) == 'team_id') ? $value . ' ' . $this->team_ary[$value] : $value;
+ $tpl_ary[$order[$key]] = ($order[$key] % 2) ? htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . ' ' :
+ '' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . ' ';
+ }
+ else
+ {
+ if ($key <> 'season' and $key <> 'league')
+ {
+ // Write XML-table fields
+ $tpl .= ' | ' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . ' | ';
+ }
+ }
+ }
+ if (sizeof($order))
+ {
+ ksort($tpl_ary);
+ $tpl .= implode(" ", $tpl_ary);
+ }
+ $tpl .= '
';
+
+ return $tpl;
+ }
+
+ /**
+ * Insert table into database
+ */
+ function insert_league($table)
+ {
+ global $db, $user;
+
+ $count_inserts = 0;
+ $table_name = constant($table);
+ foreach ($this->xml_ary[strtolower($table)] AS $sql_ary)
+ {
+ $sql = 'INSERT IGNORE INTO ' . $table_name . ' ' . $db->sql_build_array('INSERT', $sql_ary);
+ $db->sql_query($sql);
+ if ($db->sql_affectedrows())
+ {
+ $count_inserts++;
+ }
+ }
+ return $count_inserts;
+ }
+
+ /**
+ * Update database
+ */
+ function update_league($table, $season, $league, $index_field)
+ {
+ global $db, $user;
+
+ $count_updates = 0;
+ $table_name = constant($table);
+ $selected_fields = $this->selected_fields($table);
+ if (!sizeof($selected_fields))
+ {
+ return 0;
+ }
+
+ if ($table == 'FOOTB_MATCHES')
+ {
+ $update_neg_status = $this->request->variable('update_neg_status', false);
+ $update_same_status = $this->request->variable('update_same_status', false);
+ $update_only_final = $this->request->variable('update_only_final', false);
+ }
+
+ // Grab key data for update
+ $sql = "SELECT $index_field AS index_field
+ FROM " . $table_name . "
+ WHERE season = $season
+ AND league = $league
+ ORDER BY 1";
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($this->request->variable($table . '_' . $row['index_field'], false))
+ {
+
+ $diff_ary = unserialize(urldecode($this->request->variable('row_' . $table . '_' . $row['index_field'], '')));
+ $sql_ary = array_intersect_ukey($diff_ary, $selected_fields, 'self::key_compare_func');
+ if ($table == 'FOOTB_MATCHES')
+ {
+ $update_status = $this->request->variable('status_FOOTB_MATCHES_' . $row['index_field'], 0);
+ $db_status = $this->request->variable('db_status_FOOTB_MATCHES_' . $row['index_field'], 0);
+ switch ($update_status)
+ {
+ case -2:
+ case -1:
+ if (! $update_neg_status)
+ {
+ // remove resultfields and status
+ $sql_ary = array_intersect_ukey($sql_ary, $this->no_result_fields, 'self::key_compare_func');
+ }
+ break;
+ case 0:
+ case 1:
+ // remove resultfields and status
+ $sql_ary = array_intersect_ukey($sql_ary, $this->no_result_fields, 'self::key_compare_func');
+ break;
+ case 2:
+ if ($db_status <= 0 or $db_status == 3 or $db_status == 6 or $update_only_final or
+ (($db_status == 2 or $db_status == 5 ) and ! $update_same_status) )
+ {
+ // remove provisional results and status
+ $sql_ary = array_intersect_ukey($sql_ary, $this->no_result_fields, 'self::key_compare_func');
+ }
+ else
+ {
+ if ($db_status == 4 or $db_status == 5)
+ {
+ $sql_ary['status'] = 5;
+ }
+ }
+ break;
+ case 3:
+ if (($db_status == 3 or $db_status == 6 ) and !$update_same_status)
+ {
+ // don't replace final results
+ $sql_ary = array_intersect_ukey($sql_ary, $this->no_result_fields, 'self::key_compare_func');
+ }
+ else
+ {
+ if ($db_status > 3)
+ {
+ $sql_ary['status'] = 6;
+ }
+ }
+ break;
+ }
+ }
+ if (sizeof($sql_ary))
+ {
+ $sql = 'UPDATE ' . $table_name . '
+ SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
+ WHERE season = $season AND league = $league AND $index_field = " . $row['index_field'];
+ $db->sql_query($sql);
+ if ($db->sql_affectedrows())
+ {
+ $count_updates++;
+ }
+ }
+ }
+ }
+ return $count_updates;
+ }
+
+ /**
+ * Insert new teams into database
+ */
+ function insert_new_teams($season, $league)
+ {
+ global $db, $user;
+
+ $count_updates = 0;
+ $table_name = constant('FOOTB_TEAMS');
+ $insert_ary = $this->request->variable('insert_team', array(''));
+ if (sizeof($insert_ary) == 0)
+ {
+ return 0;
+ }
+ foreach ($insert_ary AS $insert)
+ {
+ $sql_ary = unserialize(urldecode($insert));
+ $sql = 'INSERT INTO ' . $table_name . ' ' . $db->sql_build_array('INSERT', $sql_ary);
+ $db->sql_query($sql);
+ if ($db->sql_affectedrows())
+ {
+ $count_updates++;
+ }
+ }
+ return $count_updates;
+ }
+
+
+ /**
+ * get selected fields
+ */
+ function selected_fields($table)
+ {
+ global $db, $user;
+
+ $tablename = strtolower($table);
+ $var_praefix = 'update_' . substr($tablename, 6) . '_';
+ $selected_fields = array();
+ $table_fields = array();
+
+ // Grab fields of table
+ $table_fields = $this->$tablename;
+ foreach ($table_fields AS $table_field)
+ {
+ switch ($table_field)
+ {
+ case 'formula_home':
+ case 'formula_guest':
+ $tag_name = 'formula';
+ break;
+ case 'goals_home':
+ case 'goals_guest':
+ $tag_name = 'goals';
+ break;
+ case 'goals_overtime_home':
+ case 'goals_overtime_guest':
+ $tag_name = 'goals_overtime';
+ break;
+ default:
+ $tag_name = $table_field;
+ break;
+ }
+ if ($this->request->variable($var_praefix . $tag_name, false))
+ {
+ $selected_fields[$table_field] = 0;
+ }
+ }
+ return $selected_fields;
+ }
+}
?>
\ No newline at end of file
diff --git a/block/delivery.php b/block/delivery.php
index f2243a3..b9d4299 100644
--- a/block/delivery.php
+++ b/block/delivery.php
@@ -1,193 +1,75 @@
-data['user_id'];
-$lang_dates = $user->lang['datetime'];
-$index = 0;
-$local_board_time = time() + (($config['board_timezone'] - $config['football_host_timezone']) * 3600);
-$sql = "(SELECT
- m.season,
- m.league,
- m.matchday,
- l.league_name_short,
- CASE m.matchday_name
- WHEN ''
- THEN CONCAT(m.matchday, '." . sprintf($user->lang['MATCHDAY']) . "')
- ELSE m.matchday_name
- END AS matchday_name,
- CONCAT(
- CASE DATE_FORMAT(m.delivery_date,'%w')
- WHEN 0 THEN '" . $lang_dates['Sun'] . "'
- WHEN 1 THEN '" . $lang_dates['Mon'] . "'
- WHEN 2 THEN '" . $lang_dates['Tue'] . "'
- WHEN 3 THEN '" . $lang_dates['Wed'] . "'
- WHEN 4 THEN '" . $lang_dates['Thu'] . "'
- WHEN 5 THEN '" . $lang_dates['Fri'] . "'
- WHEN 6 THEN '" . $lang_dates['Sat'] . "'
- ELSE 'Error' END,
- DATE_FORMAT(m.delivery_date,' %d.%m.%y %H:%i')
- ) as delivery_time,
- m.delivery_date AS delivery,
- SUM(IF(((b.goals_home = '') OR (b.goals_guest = '')), 0, 1)) AS bets_count,
- COUNT(*) AS matches_count,
- SUM(IF(eb.extra_no > 0, IF(eb.bet = '', 0, 1), 0)) AS extra_bets_count,
- SUM(IF(e.extra_no > 0, 1, 0)) AS extra_count
- FROM " . FOOTB_MATCHDAYS . " AS m
- JOIN " . FOOTB_LEAGUES . " AS l ON(l.season = m.season AND l.league = m.league AND l.bet_in_time = 0)
- JOIN " . FOOTB_MATCHES . " AS ma ON (ma.season = m.season AND ma.league = m.league AND ma.matchday = m.matchday AND ma.status = 0)
- JOIN " . FOOTB_BETS . " AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = ma.match_no AND b.user_id = $user_id)
- LEFT JOIN " . FOOTB_EXTRA . " AS e ON (e.season = m.season AND e.league = m.league AND e.matchday = m.matchday AND e.extra_status = 0)
- LEFT JOIN " . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = m.season AND eb.league = m.league AND eb.extra_no = e.extra_no AND eb.user_id = $user_id)
- WHERE m.delivery_date > FROM_UNIXTIME('$local_board_time')
- AND m.status <= 0
- GROUP BY m.delivery_date, m.league, b.user_id
- )
- UNION
- (SELECT
- m.season,
- m.league,
- m.matchday,
- l.league_name_short,
- CASE m.matchday_name
- WHEN ''
- THEN CONCAT(m.matchday, '." . sprintf($user->lang['MATCHDAY']) . "')
- ELSE m.matchday_name
- END AS matchday_name,
- CONCAT(
- CASE DATE_FORMAT(m.delivery_date_2,'%w')
- WHEN 0 THEN '" . $lang_dates['Sun'] . "'
- WHEN 1 THEN '" . $lang_dates['Mon'] . "'
- WHEN 2 THEN '" . $lang_dates['Tue'] . "'
- WHEN 3 THEN '" . $lang_dates['Wed'] . "'
- WHEN 4 THEN '" . $lang_dates['Thu'] . "'
- WHEN 5 THEN '" . $lang_dates['Fri'] . "'
- WHEN 6 THEN '" . $lang_dates['Sat'] . "'
- ELSE 'Error' END,
- DATE_FORMAT(m.delivery_date_2,' %d.%m.%y %H:%i')
- ) as delivery_time,
- m.delivery_date_2 AS delivery ,
- SUM(IF(((b.goals_home = '') OR (b.goals_guest = '')), 0, 1)) AS bets_count,
- COUNT(*) AS matches_count,
- 0 AS extra_bets_count,
- 0 AS extra_count
- FROM " . FOOTB_MATCHDAYS . " AS m
- JOIN " . FOOTB_LEAGUES . " AS l ON(l.season = m.season AND l.league = m.league AND l.bet_in_time = 0)
- JOIN " . FOOTB_MATCHES . " AS ma ON (ma.season = m.season AND ma.league = m.league AND ma.matchday = m.matchday AND ma.status = -1)
- JOIN " . FOOTB_BETS . " AS b ON (b.season = ma.season AND b.league = ma.league AND b.match_no = ma.match_no AND b.user_id = $user_id)
- WHERE m.delivery_date_2 > FROM_UNIXTIME('$local_board_time')
- AND m.status <= 0
- GROUP BY m.delivery_date, m.league, b.user_id
- )
- UNION
- (SELECT
- m.season,
- m.league,
- m.matchday,
- l.league_name_short,
- CASE m.matchday_name
- WHEN ''
- THEN CONCAT(m.matchday, '." . sprintf($user->lang['MATCHDAY']) . "')
- ELSE m.matchday_name
- END AS matchday_name,
- CONCAT(
- CASE DATE_FORMAT(m.delivery_date_3,'%w')
- WHEN 0 THEN '" . $lang_dates['Sun'] . "'
- WHEN 1 THEN '" . $lang_dates['Mon'] . "'
- WHEN 2 THEN '" . $lang_dates['Tue'] . "'
- WHEN 3 THEN '" . $lang_dates['Wed'] . "'
- WHEN 4 THEN '" . $lang_dates['Thu'] . "'
- WHEN 5 THEN '" . $lang_dates['Fri'] . "'
- WHEN 6 THEN '" . $lang_dates['Sat'] . "'
- ELSE 'Error' END,
- DATE_FORMAT(m.delivery_date_3,' %d.%m.%y %H:%i')
- ) as delivery_time,
- m.delivery_date_3 AS delivery,
- SUM(IF(((b.goals_home = '') OR (b.goals_guest = '')), 0, 1)) AS bets_count,
- COUNT(*) AS matches_count,
- 0 AS extra_bets_count,
- 0 AS extra_count
- FROM " . FOOTB_MATCHDAYS . " AS m
- JOIN " . FOOTB_LEAGUES . " AS l ON(l.season = m.season AND l.league = m.league AND l.bet_in_time = 0)
- JOIN " . FOOTB_MATCHES . " AS ma ON (ma.season = m.season AND ma.league = m.league AND ma.matchday = m.matchday AND ma.status = -2)
- JOIN " . FOOTB_BETS . " AS b ON (b.season = ma.season AND b.league = ma.league AND b.match_no = ma.match_no AND b.user_id = $user_id)
- WHERE m.delivery_date_3 > FROM_UNIXTIME('$local_board_time')
- AND m.status <= 0
- GROUP BY m.delivery_date, m.league, b.user_id
- )
- UNION
- (SELECT
- m.season,
- m.league,
- m.matchday,
- l.league_name_short,
- CASE m.matchday_name
- WHEN ''
- THEN CONCAT(m.matchday, '." . sprintf($user->lang['MATCHDAY']) . "')
- ELSE m.matchday_name
- END AS matchday_name,
- CONCAT(
- CASE DATE_FORMAT(ma.match_datetime,'%w')
- WHEN 0 THEN '" . $lang_dates['Sun'] . "'
- WHEN 1 THEN '" . $lang_dates['Mon'] . "'
- WHEN 2 THEN '" . $lang_dates['Tue'] . "'
- WHEN 3 THEN '" . $lang_dates['Wed'] . "'
- WHEN 4 THEN '" . $lang_dates['Thu'] . "'
- WHEN 5 THEN '" . $lang_dates['Fri'] . "'
- WHEN 6 THEN '" . $lang_dates['Sat'] . "'
- ELSE 'Error' END,
- DATE_FORMAT(ma.match_datetime,' %d.%m.%y %H:%i')
- ) as delivery_time,
- ma.match_datetime AS delivery,
- SUM(IF(((b.goals_home = '') OR (b.goals_guest = '')), 0, 1)) AS bets_count,
- COUNT(*) AS matches_count,
- 0 AS extra_bets_count,
- 0 AS extra_count
- FROM " . FOOTB_MATCHDAYS . " AS m
- JOIN " . FOOTB_LEAGUES . " AS l ON(l.season = m.season AND l.league = m.league AND l.bet_in_time = 1)
- JOIN " . FOOTB_MATCHES . " AS ma ON (ma.season = m.season AND ma.league = m.league AND ma.matchday = m.matchday AND ma.status = 0)
- JOIN " . FOOTB_BETS . " AS b ON (b.season = ma.season AND b.league = ma.league AND b.match_no = ma.match_no AND b.user_id = $user_id)
- WHERE ma.match_datetime > FROM_UNIXTIME('$local_board_time')
- AND m.status <= 0
- GROUP BY ma.match_datetime, m.league, b.user_id
- )
- ORDER BY delivery, league";
-
-$result = $db->sql_query($sql);
-while($row = $db->sql_fetchrow($result) AND $index < 11)
-{
- $index++;
- $data_delivery = true;
- $row_class = (!($index % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
-
- $template->assign_block_vars('delivery', array(
- 'ROW_CLASS' => $row_class,
- 'U_BET_LINK' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $row['season'], 'l' => $row['league'], 'm' => $row['matchday'])),
- 'LEAGUE_SHORT' => $row['league_name_short'],
- 'MATCHDAY_NAME' => $row['matchday_name'],
- 'COLOR' => ($row['bets_count'] == $row['matches_count'] && $row['extra_bets_count'] == $row['extra_count']) ? 'green' : 'red',
- 'TITLE' => ($row['bets_count'] == $row['matches_count']) ? sprintf($user->lang['DELIVERY_READY']) : sprintf($user->lang['DELIVERY_NOT_READY']),
- 'DELIVERY' => $row['delivery_time'],
- )
- );
-}
-$db->sql_freeresult($result);
-
-$template->assign_vars(array(
- 'S_DISPLAY_DELIVERY' => $data_delivery,
- 'S_DATA_DELIVERY' => $data_delivery,
- )
-);
-
+data['user_id'];
+$lang_dates = $user->lang['datetime'];
+$index = 0;
+$local_board_time = time() + (($config['board_timezone'] - $config['football_host_timezone']) * 3600);
+$sql = "SELECT
+ m.season,
+ m.league,
+ m.matchday,
+ l.league_name_short,
+ CASE m.matchday_name
+ WHEN ''
+ THEN CONCAT(m.matchday, '." . sprintf($user->lang['MATCHDAY']) . "')
+ ELSE m.matchday_name
+ END AS matchday_name,
+ IF(l.bet_in_time = 0, IF(ma.status = 0, m.delivery_date
+ , IF(ma.status = -1, m.delivery_date_2
+ , m.delivery_date_3
+ )
+ )
+ , ma.match_datetime) AS delivery,
+ SUM(IF(((b.goals_home = '') OR (b.goals_guest = '')), 0, 1)) AS bets_count,
+ COUNT(*) AS matches_count,
+ SUM(IF(eb.extra_no > 0, IF(eb.bet = '', 0, 1), 0)) AS extra_bets_count,
+ SUM(IF(e.extra_no > 0, 1, 0)) AS extra_count
+ FROM " . FOOTB_MATCHDAYS . " AS m
+ JOIN " . FOOTB_LEAGUES . " AS l ON(l.season = m.season AND l.league = m.league)
+ JOIN " . FOOTB_MATCHES . " AS ma ON (ma.season = m.season AND ma.league = m.league AND ma.matchday = m.matchday AND ma.status = 0)
+ JOIN " . FOOTB_BETS . " AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = ma.match_no AND b.user_id = $user_id)
+ LEFT JOIN " . FOOTB_EXTRA . " AS e ON (e.season = m.season AND e.league = m.league AND e.matchday = m.matchday AND e.extra_status = 0)
+ LEFT JOIN " . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = m.season AND eb.league = m.league AND eb.extra_no = e.extra_no AND eb.user_id = $user_id)
+ WHERE m.status <= 0
+ GROUP BY delivery, m.league
+ ORDER BY delivery, m.league";
+
+$result = $db->sql_query($sql);
+while($row = $db->sql_fetchrow($result) AND $index < 11)
+{
+ $index++;
+ $data_delivery = true;
+ $row_class = (!($index % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
+
+ $template->assign_block_vars('delivery', array(
+ 'ROW_CLASS' => $row_class,
+ 'U_BET_LINK' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $row['season'], 'l' => $row['league'], 'm' => $row['matchday'])),
+ 'LEAGUE_SHORT' => $row['league_name_short'],
+ 'MATCHDAY_NAME' => $row['matchday_name'],
+ 'COLOR' => ($row['bets_count'] == $row['matches_count'] && $row['extra_bets_count'] == $row['extra_count']) ? 'green' : 'red',
+ 'TITLE' => ($row['bets_count'] == $row['matches_count']) ? sprintf($user->lang['DELIVERY_READY']) : sprintf($user->lang['DELIVERY_NOT_READY']),
+ 'DELIVERY' => $lang_dates[date("D", strtotime($row['delivery']))] . date(" d.m.y G:i", strtotime($row['delivery'])),
+ )
+ );
+}
+$db->sql_freeresult($result);
+
+$template->assign_vars(array(
+ 'S_DISPLAY_DELIVERY' => $data_delivery,
+ 'S_DATA_DELIVERY' => $data_delivery,
+ )
+);
+
?>
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 363bd73..f8373ba 100644
--- a/composer.json
+++ b/composer.json
@@ -1,10 +1,10 @@
{
"name": "football/football",
"type": "phpbb-extension",
- "description": "Football Prediction League for phpBB 3.1",
+ "description": "Football Prediction League",
"homepage": "http://football.bplaced.net",
- "version": "0.9.7",
- "time": "2016-06-12",
+ "version": "0.9.8",
+ "time": "2017-02-19",
"license": "GPL-2.0",
"authors": [{
"name": "J. Helmke",
diff --git a/cron/task/football_remember.php b/cron/task/football_remember.php
index e24cda7..95eca76 100644
--- a/cron/task/football_remember.php
+++ b/cron/task/football_remember.php
@@ -1,334 +1,336 @@
-root_path = $root_path;
- $this->php_ext = $php_ext;
- $this->phpbb_extension_manager = $phpbb_extension_manager;
- $this->phpbb_path_helper = $phpbb_path_helper;
- $this->db = $db;
- $this->config = $config;
- $this->phpbb_log = $log;
- $this->user = $user;
- }
-
- /**
- * Runs this cron task.
- *
- * @return null
- */
- public function run()
- {
- global $request;
-
- $ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
- include($ext_path . 'includes/functions.' . $this->php_ext);
- include($ext_path . 'includes/constants.' . $this->php_ext);
-
- // Load extension language file
- $this->user->add_lang_ext('football/football', 'info_acp_football');
-
- // mode=test ?
- $mode = $request->variable('mode', '');
- $days = $request->variable('days', 0);
-
- //Mail Settings
- $use_queue = false;
- $used_method = NOTIFY_EMAIL;
- $priority = MAIL_NORMAL_PRIORITY;
-
-
- $season = curr_season();
- //Matchdays to close in 24 hours and 24 hours later
- // shift days to test
- $local_board_time = time() + ($days * 86400);
-
- if ($mode <> 'test')
- {
- // Update next run
- $run_time = getdate($this->config['football_remember_next_run']);
- $next_run = mktime($run_time['hours'], $run_time['minutes'], 0, date("n"), date("j") + 1, date("Y"));
- $this->config->set('football_remember_next_run', $next_run, true);
- }
- else
- {
- $message = sprintf($this->user->lang['LOG_FOOTBALL_MSG_TEST' . (($days == 0) ? '' : '_TRAVEL')], date("d.m.Y H:i", $local_board_time));
- $this->phpbb_log->add('admin', ANONYMOUS, '', 'LOG_FOOTBALL_REMEMBER_CRON_TEST', false, array($message));
- }
-
- $sql = 'SELECT
- m.*,
- l.*
- FROM ' . FOOTB_MATCHDAYS . ' AS m
- LEFT JOIN ' . FOOTB_LEAGUES . " AS l ON (l.season = m.season AND l.league = m.league)
- WHERE m.season >= $season AND m.status = 0
- AND (DATE_SUB(m.delivery_date, INTERVAL '1 23:59' DAY_MINUTE) < FROM_UNIXTIME('$local_board_time'))
- AND (DATE_SUB(m.delivery_date, INTERVAL '1 00:00' DAY_MINUTE) > FROM_UNIXTIME('$local_board_time'))";
- $result = $this->db->sql_query($sql);
- $toclose = $this->db->sql_fetchrowset($result);
- $this->db->sql_freeresult($result);
-
- // If we found matchdays to close, search missing bets and mail them
- foreach ($toclose as $close)
- {
- // prepare some variables
- $first_mail = true;
- $season = $close['season'];
- $league = $close['league'];
- $league_name = $close['league_name'];
- $league_short = $close['league_name_short'];
- $delivery = $close['delivery_date'];
- $matchday = $close['matchday'];
- $subject = sprintf($this->user->lang['FOOTBALL_REMEMBER_SUBJECT'], $league_short, $matchday);
- $usernames = '';
-
- // find missing users
- $sql = 'SELECT
- u.user_email AS user_email,
- u.username AS username,
- u.user_id AS userid,
- u.user_lang
- FROM ' . FOOTB_MATCHES . ' AS m
- LEFT JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = m.season AND l.league = m.league)
- LEFT JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
- LEFT JOIN ' . PROFILE_FIELDS_DATA_TABLE. ' AS p ON p.user_id = b.user_id
- LEFT JOIN ' . USERS_TABLE. " AS u ON u.user_id = b.user_id
- WHERE m.season = $season AND m.league = $league AND m.matchday = $matchday
- AND ((b.goals_home = '') OR (b.goals_guest = ''))
- AND m.status = 0 AND p.pf_footb_rem_f = 1
- AND (l.bet_in_time = 0 OR
- (l.bet_in_time = 1
- AND (DATE_SUB(m.match_datetime, INTERVAL '1 23:59' DAY_MINUTE) < FROM_UNIXTIME('$local_board_time'))
- AND (DATE_SUB(m.match_datetime, INTERVAL '1 00:00' DAY_MINUTE) > FROM_UNIXTIME('$local_board_time'))))
- GROUP BY b.user_id
- UNION
- SELECT
- p.pf_footb_email AS user_email,
- u.username AS username,
- u.user_id AS userid,
- u.user_lang
- FROM " . FOOTB_MATCHES . ' AS m
- LEFT JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = m.season AND l.league = m.league)
- LEFT JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
- LEFT JOIN ' . PROFILE_FIELDS_DATA_TABLE. ' AS p ON p.user_id = b.user_id
- LEFT JOIN ' . USERS_TABLE. " AS u ON u.user_id = b.user_id
- WHERE m.season = $season AND m.league = $league AND m.matchday = $matchday
- AND ((b.goals_home = '') OR (b.goals_guest = ''))
- AND m.status = 0 AND p.pf_footb_rem_s = 1
- AND (l.bet_in_time = 0 OR
- (l.bet_in_time = 1
- AND (DATE_SUB(m.match_datetime, INTERVAL '1 23:59' DAY_MINUTE) < FROM_UNIXTIME('$local_board_time'))
- AND (DATE_SUB(m.match_datetime, INTERVAL '1 00:00' DAY_MINUTE) > FROM_UNIXTIME('$local_board_time'))))
- GROUP BY b.user_id
- ";
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
-
- if (!$row)
- {
- $this->db->sql_freeresult($result);
- }
- else
- {
-
- // Send the messages
- include_once($this->root_path . 'includes/functions_messenger.' . $this->php_ext);
- $messenger = new \messenger($use_queue);
- include_once($this->root_path . 'includes/functions_user.' . $this->php_ext);
- $errored = false;
- $messenger->headers('X-AntiAbuse: Board servername - ' . $this->config['server_name']);
- $messenger->headers('X-AntiAbuse: User_id - ' . ANONYMOUS);
- $messenger->headers('X-AntiAbuse: Username - CRON TASK Football remember');
- $messenger->headers('X-AntiAbuse: User IP - ' . $this->user->ip);
- $messenger->subject(htmlspecialchars_decode($subject));
- $messenger->set_mail_priority($priority);
-
- do
- {
- // Send the messages
- $used_lang = $row['user_lang'];
- $mail_template_path = $ext_path . 'language/' . $used_lang . '/email/';
-
- if ($mode <> 'test')
- {
- $messenger->to($row['user_email'], $row['username']);
- }
- else
- {
- // test send to board email
- $messenger->to($this->config['board_email'], $this->config['sitename']);
- }
- $messenger->template('footb_send_remember', $used_lang, $mail_template_path);
-
- $messenger->assign_vars(array(
- 'USERNAME' => $row['username'],
- 'LEAGUE' => $league_name,
- 'MATCHDAY' => $matchday,
- 'DELIVERY' => $delivery,
- 'CONTACT_EMAIL' => $this->config['board_contact'])
- );
-
- if ($mode <> 'test')
- {
- if (!($messenger->send($used_method)))
- {
- $message = '' . sprintf($this->user->lang['FOOTBALL_REMEMBER_ERROR_EMAIL'], $league_short, $row['user_email']) . '';
- $this->phpbb_log->add('critical', ANONYMOUS, '', 'LOG_ERROR_EMAIL', false, array($message));
- $usernames .= (($usernames != '') ? ', ' : '') . $row['username']. '!';
- }
- else
- {
- $usernames .= (($usernames != '') ? ', ' : '') . $row['username'];
- }
- }
- else
- {
- // Test mode
- if ($first_mail)
- {
- // only send one mail
- if (!($messenger->send($used_method)))
- {
- $message = '' . sprintf($this->user->lang['FOOTBALL_REMEMBER_ERROR_EMAIL'], $league_short, $row['user_email']) . '';
- $this->phpbb_log->add('critical', ANONYMOUS, '', 'LOG_ERROR_EMAIL', false, array($message));
- $usernames .= (($usernames != '') ? ', ' : '') . $row['username']. '!';
- }
- else
- {
- $usernames .= (($usernames != '') ? ', ' : '') . $row['username'];
- }
- $first_mail = false;
- }
- else
- {
- $usernames .= (($usernames != '') ? ', ' : '') . $row['username'];
- }
- }
- }
- while ($row = $this->db->sql_fetchrow($result));
- $this->db->sql_freeresult($result);
-
- // Only if mails have already been sent previously
- if ($usernames <> '')
- {
- // send mail to board administration
- $used_lang = $this->config['default_lang'];
- $mail_template_path = $ext_path . 'language/' . $used_lang . '/email/';
- $subject = sprintf($this->user->lang['FOOTBALL_REMEMBER_SUBJECT_BOARD'], $league_short, $matchday);
- $messenger->to($this->config['board_email'], $this->config['sitename']);
- $messenger->subject(htmlspecialchars_decode($subject));
- $messenger->template('footb_board_remember', $used_lang, $mail_template_path);
- $messenger->assign_vars(array(
- 'CONTACT_EMAIL' => $this->config['board_contact'],
- 'REMEMBER_LIST' => $usernames,
- )
- );
-
- if (!($messenger->send($used_method)))
- {
- $message = '' . sprintf($this->user->lang['FOOTBALL_REMEMBER_ERROR_EMAIL_BOARD'], $league_short, $this->config['board_email']) . '';
- $this->phpbb_log->add('critical', ANONYMOUS, '', 'LOG_ERROR_EMAIL', false, array($message));
- }
- else
- {
- $log_subject = sprintf($this->user->lang['FOOTBALL_REMEMBER_SEND'], $league_short, $usernames) ;
- $this->phpbb_log->add('admin', ANONYMOUS, '', 'LOG_FOOTBALL_REMEMBER_CRON', false, array($log_subject));
- }
- }
- else
- {
- // Log the cronjob run
- $log_subject = sprintf($this->user->lang['FOOTBALL_REMEMBER_NOBODY']) ;
- $this->phpbb_log->add('admin', ANONYMOUS, '', 'LOG_FOOTBALL_REMEMBER_CRON', false, array($log_subject));
- }
- }
- }
- if (sizeof($toclose) == 0)
- {
- // Log the cronjob run
- $log_subject = sprintf($this->user->lang['FOOTBALL_REMEMBER_NO_DELIVERY']) ;
- $this->phpbb_log->add('admin', ANONYMOUS, '', 'LOG_FOOTBALL_REMEMBER_CRON', false, array($log_subject));
- }
-
- return;
- }
-
- /**
- * Returns whether this cron task can run, given current board configuration.
- *
- * @return bool
- */
- public function is_runnable()
- {
- return (bool) $this->config['football_remember_enable'];
- }
-
- /**
- * Returns whether this cron task should run now, because next run time
- * has passed.
- *
- * @return bool
- */
- public function should_run()
- {
- global $request;
- $mode = $request->variable('mode', '');
-
- if ($mode <> 'test')
- {
- return $this->config['football_remember_next_run'] < time();
- }
- else
- {
- return true;
- }
- }
-}
+root_path = $root_path;
+ $this->php_ext = $php_ext;
+ $this->phpbb_extension_manager = $phpbb_extension_manager;
+ $this->phpbb_path_helper = $phpbb_path_helper;
+ $this->db = $db;
+ $this->config = $config;
+ $this->phpbb_log = $log;
+ $this->user = $user;
+ }
+
+ /**
+ * Runs this cron task.
+ *
+ * @return null
+ */
+ public function run()
+ {
+ global $request;
+
+ $ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
+ include($ext_path . 'includes/functions.' . $this->php_ext);
+ include($ext_path . 'includes/constants.' . $this->php_ext);
+
+ // Load extension language file
+ $this->user->setup();
+ $this->user->add_lang_ext('football/football', 'info_acp_football');
+
+ // mode=test ?
+ $mode = $request->variable('mode', '');
+ $days = $request->variable('days', 0);
+
+ //Mail Settings
+ $use_queue = false;
+ $used_method = NOTIFY_EMAIL;
+ $priority = MAIL_NORMAL_PRIORITY;
+
+
+ $season = curr_season();
+ //Matchdays to close in 24 hours and 24 hours later
+ // shift days to test
+ $local_board_time = time() + ($days * 86400);
+
+ if ($mode <> 'test')
+ {
+ // Update next run
+ $run_time = getdate($this->config['football_remember_next_run']);
+ $next_run = mktime($run_time['hours'], $run_time['minutes'], 0, date("n"), date("j") + 1, date("Y"));
+ $this->config->set('football_remember_next_run', $next_run, true);
+ }
+ else
+ {
+ $message = sprintf($this->user->lang['LOG_FOOTBALL_MSG_TEST' . (($days == 0) ? '' : '_TRAVEL')], date("d.m.Y H:i", $local_board_time));
+ $this->phpbb_log->add('admin', ANONYMOUS, '', 'LOG_FOOTBALL_REMEMBER_CRON_TEST', false, array($message));
+ }
+
+ $sql = 'SELECT
+ m.*,
+ l.*
+ FROM ' . FOOTB_MATCHDAYS . ' AS m
+ LEFT JOIN ' . FOOTB_LEAGUES . " AS l ON (l.season = m.season AND l.league = m.league)
+ WHERE m.season >= $season AND m.status = 0
+ AND (DATE_SUB(m.delivery_date, INTERVAL '1 23:59' DAY_MINUTE) < FROM_UNIXTIME('$local_board_time'))
+ AND (DATE_SUB(m.delivery_date, INTERVAL '1 00:00' DAY_MINUTE) > FROM_UNIXTIME('$local_board_time'))
+ GROUP BY m.season, m.league, m.matchday";
+ $result = $this->db->sql_query($sql);
+ $toclose = $this->db->sql_fetchrowset($result);
+ $this->db->sql_freeresult($result);
+
+ // If we found matchdays to close, search missing bets and mail them
+ foreach ($toclose as $close)
+ {
+ // prepare some variables
+ $first_mail = true;
+ $season = $close['season'];
+ $league = $close['league'];
+ $league_name = $close['league_name'];
+ $league_short = $close['league_name_short'];
+ $delivery = $close['delivery_date'];
+ $matchday = $close['matchday'];
+ $subject = sprintf($this->user->lang['FOOTBALL_REMEMBER_SUBJECT'], $league_short, $matchday);
+ $usernames = '';
+
+ // find missing users
+ $sql = 'SELECT
+ u.user_email AS user_email,
+ u.username AS username,
+ u.user_id AS userid,
+ u.user_lang
+ FROM ' . FOOTB_MATCHES . ' AS m
+ LEFT JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = m.season AND l.league = m.league)
+ LEFT JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
+ LEFT JOIN ' . PROFILE_FIELDS_DATA_TABLE. ' AS p ON p.user_id = b.user_id
+ LEFT JOIN ' . USERS_TABLE. " AS u ON u.user_id = b.user_id
+ WHERE m.season = $season AND m.league = $league AND m.matchday = $matchday
+ AND ((b.goals_home = '') OR (b.goals_guest = ''))
+ AND m.status = 0 AND p.pf_footb_rem_f = 1
+ AND (l.bet_in_time = 0 OR
+ (l.bet_in_time = 1
+ AND (DATE_SUB(m.match_datetime, INTERVAL '1 23:59' DAY_MINUTE) < FROM_UNIXTIME('$local_board_time'))
+ AND (DATE_SUB(m.match_datetime, INTERVAL '1 00:00' DAY_MINUTE) > FROM_UNIXTIME('$local_board_time'))))
+ GROUP BY b.user_id
+ UNION
+ SELECT
+ p.pf_footb_email AS user_email,
+ u.username AS username,
+ u.user_id AS userid,
+ u.user_lang
+ FROM " . FOOTB_MATCHES . ' AS m
+ LEFT JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = m.season AND l.league = m.league)
+ LEFT JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
+ LEFT JOIN ' . PROFILE_FIELDS_DATA_TABLE. ' AS p ON p.user_id = b.user_id
+ LEFT JOIN ' . USERS_TABLE. " AS u ON u.user_id = b.user_id
+ WHERE m.season = $season AND m.league = $league AND m.matchday = $matchday
+ AND ((b.goals_home = '') OR (b.goals_guest = ''))
+ AND m.status = 0 AND p.pf_footb_rem_s = 1
+ AND (l.bet_in_time = 0 OR
+ (l.bet_in_time = 1
+ AND (DATE_SUB(m.match_datetime, INTERVAL '1 23:59' DAY_MINUTE) < FROM_UNIXTIME('$local_board_time'))
+ AND (DATE_SUB(m.match_datetime, INTERVAL '1 00:00' DAY_MINUTE) > FROM_UNIXTIME('$local_board_time'))))
+ GROUP BY b.user_id
+ ";
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+
+ if (!$row)
+ {
+ $this->db->sql_freeresult($result);
+ }
+ else
+ {
+
+ // Send the messages
+ include_once($this->root_path . 'includes/functions_messenger.' . $this->php_ext);
+ $messenger = new \messenger($use_queue);
+ include_once($this->root_path . 'includes/functions_user.' . $this->php_ext);
+ $errored = false;
+ $messenger->headers('X-AntiAbuse: Board servername - ' . $this->config['server_name']);
+ $messenger->headers('X-AntiAbuse: User_id - ' . ANONYMOUS);
+ $messenger->headers('X-AntiAbuse: Username - CRON TASK Football remember');
+ $messenger->headers('X-AntiAbuse: User IP - ' . $this->user->ip);
+ $messenger->subject(htmlspecialchars_decode($subject));
+ $messenger->set_mail_priority($priority);
+
+ do
+ {
+ // Send the messages
+ $used_lang = $row['user_lang'];
+ $mail_template_path = $ext_path . 'language/' . $used_lang . '/email/';
+
+ if ($mode <> 'test')
+ {
+ $messenger->to($row['user_email'], $row['username']);
+ }
+ else
+ {
+ // test send to board email
+ $messenger->to($this->config['board_email'], $this->config['sitename']);
+ }
+ $messenger->template('footb_send_remember', $used_lang, $mail_template_path);
+
+ $messenger->assign_vars(array(
+ 'USERNAME' => $row['username'],
+ 'LEAGUE' => $league_name,
+ 'MATCHDAY' => $matchday,
+ 'DELIVERY' => $delivery,
+ 'CONTACT_EMAIL' => $this->config['board_contact'])
+ );
+
+ if ($mode <> 'test')
+ {
+ if (!($messenger->send($used_method)))
+ {
+ $message = '' . sprintf($this->user->lang['FOOTBALL_REMEMBER_ERROR_EMAIL'], $league_short, $row['user_email']) . '';
+ $this->phpbb_log->add('critical', ANONYMOUS, '', 'LOG_ERROR_EMAIL', false, array($message));
+ $usernames .= (($usernames != '') ? ', ' : '') . $row['username']. '!';
+ }
+ else
+ {
+ $usernames .= (($usernames != '') ? ', ' : '') . $row['username'];
+ }
+ }
+ else
+ {
+ // Test mode
+ if ($first_mail)
+ {
+ // only send one mail
+ if (!($messenger->send($used_method)))
+ {
+ $message = '' . sprintf($this->user->lang['FOOTBALL_REMEMBER_ERROR_EMAIL'], $league_short, $row['user_email']) . '';
+ $this->phpbb_log->add('critical', ANONYMOUS, '', 'LOG_ERROR_EMAIL', false, array($message));
+ $usernames .= (($usernames != '') ? ', ' : '') . $row['username']. '!';
+ }
+ else
+ {
+ $usernames .= (($usernames != '') ? ', ' : '') . $row['username'];
+ }
+ $first_mail = false;
+ }
+ else
+ {
+ $usernames .= (($usernames != '') ? ', ' : '') . $row['username'];
+ }
+ }
+ }
+ while ($row = $this->db->sql_fetchrow($result));
+ $this->db->sql_freeresult($result);
+
+ // Only if mails have already been sent previously
+ if ($usernames <> '')
+ {
+ // send mail to board administration
+ $used_lang = $this->config['default_lang'];
+ $mail_template_path = $ext_path . 'language/' . $used_lang . '/email/';
+ $subject = sprintf($this->user->lang['FOOTBALL_REMEMBER_SUBJECT_BOARD'], $league_short, $matchday);
+ $messenger->to($this->config['board_email'], $this->config['sitename']);
+ $messenger->subject(htmlspecialchars_decode($subject));
+ $messenger->template('footb_board_remember', $used_lang, $mail_template_path);
+ $messenger->assign_vars(array(
+ 'CONTACT_EMAIL' => $this->config['board_contact'],
+ 'REMEMBER_LIST' => $usernames,
+ )
+ );
+
+ if (!($messenger->send($used_method)))
+ {
+ $message = '' . sprintf($this->user->lang['FOOTBALL_REMEMBER_ERROR_EMAIL_BOARD'], $league_short, $this->config['board_email']) . '';
+ $this->phpbb_log->add('critical', ANONYMOUS, '', 'LOG_ERROR_EMAIL', false, array($message));
+ }
+ else
+ {
+ $log_subject = sprintf($this->user->lang['FOOTBALL_REMEMBER_SEND'], $league_short, $usernames) ;
+ $this->phpbb_log->add('admin', ANONYMOUS, '', 'LOG_FOOTBALL_REMEMBER_CRON', false, array($log_subject));
+ }
+ }
+ else
+ {
+ // Log the cronjob run
+ $log_subject = sprintf($this->user->lang['FOOTBALL_REMEMBER_NOBODY']) ;
+ $this->phpbb_log->add('admin', ANONYMOUS, '', 'LOG_FOOTBALL_REMEMBER_CRON', false, array($log_subject));
+ }
+ }
+ }
+ if (sizeof($toclose) == 0)
+ {
+ // Log the cronjob run
+ $log_subject = sprintf($this->user->lang['FOOTBALL_REMEMBER_NO_DELIVERY']) ;
+ $this->phpbb_log->add('admin', ANONYMOUS, '', 'LOG_FOOTBALL_REMEMBER_CRON', false, array($log_subject));
+ }
+
+ return;
+ }
+
+ /**
+ * Returns whether this cron task can run, given current board configuration.
+ *
+ * @return bool
+ */
+ public function is_runnable()
+ {
+ return (bool) $this->config['football_remember_enable'];
+ }
+
+ /**
+ * Returns whether this cron task should run now, because next run time
+ * has passed.
+ *
+ * @return bool
+ */
+ public function should_run()
+ {
+ global $request;
+ $mode = $request->variable('mode', '');
+
+ if ($mode <> 'test')
+ {
+ return $this->config['football_remember_next_run'] < time();
+ }
+ else
+ {
+ return true;
+ }
+ }
+}
?>
\ No newline at end of file
diff --git a/event/main_listener.php b/event/main_listener.php
index ec81a3d..1c856b9 100644
--- a/event/main_listener.php
+++ b/event/main_listener.php
@@ -1,551 +1,549 @@
-auth = $auth;
- $this->config = $config;
- $this->controller_helper = $helper;
- $this->template = $template;
- $this->phpbb_path_helper = $path_helper;
- $this->phpbb_extension_manager = $phpbb_extension_manager;
- $this->user = $user;
- $this->phpbb_root_path = $phpbb_root_path;
- $this->php_ext = $php_ext;
-
-// include($path_helper->update_web_root_path($phpbb_extension_manager->get_extension_path('football/football', true)) . 'includes/constants.' . $php_ext);
- }
-
- /**
- * Assign functions defined in this class to event listeners in the core
- *
- * @return array
- */
- static public function getSubscribedEvents()
- {
- return array(
- 'core.viewonline_overwrite_location' => 'viewonline_page',
- 'core.user_setup' => 'load_language_on_setup',
- 'core.page_header' => 'add_football_links',
- 'core.session_kill_after' => 'detect_mobile_device',
- 'core.session_create_after' => 'detect_mobile_device',
- 'core.permissions' => 'add_permission_cat',
- );
- }
-
- /**
- * Show users as viewing the football prediction league on Who Is Online page
- *
- * @param object $event The event object
- * @return null
- */
- public function viewonline_page($event)
- {
- global $db;
- if (strrpos($event['row']['session_page'], 'app.' . $this->php_ext . '/football') === 0)
- {
- $action = substr($event['row']['session_page'], 17);
- $url_parts = $this->phpbb_path_helper->get_url_parts($action, false);
- $params = (isset($url_parts['params'])) ? $url_parts['params'] : array();
- if (isset($params['l']) and isset($params['s']))
- {
- include_once($this->phpbb_root_path . 'ext/football/football/includes/constants.' . $this->php_ext);
- $season = $params['s'];
- $league =$params['l'];
- $sql = 'SELECT league_name FROM ' . FOOTB_LEAGUES . "
- WHERE season = $season AND league = $league
- ";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $event['location'] = $this->user->lang('VIEWING_LEAGUE' . (empty($url_parts['base']) ? '' : '_' . strtoupper ($url_parts['base'])), $row['league_name']);
- }
- else
- {
- $event['location_url'] = $this->controller_helper->route('football_main_controller', array_merge(array('side' => $url_parts['base']), $url_parts['params']));
- }
- $db->sql_freeresult($result);
- }
- else
- {
- $event['location'] = $this->user->lang('VIEWING_FOOTBALL' . (empty($url_parts['base']) ? '' : '_' . strtoupper ($url_parts['base'])));
- }
- $event['location_url'] = $this->controller_helper->route('football_main_controller', array_merge(array('side' => $url_parts['base']), $url_parts['params']));
- }
- }
-
- /**
- * Load football prediction league language during user setup
- *
- * @param object $event The event object
- * @return null
- */
- public function load_language_on_setup($event)
- {
- $lang_set_ext = $event['lang_set_ext'];
- $lang_set_ext[] = array(
- 'ext_name' => 'football/football',
- 'lang_set' => 'football',
- );
- if (defined('ADMIN_START'))
- {
- $lang_set_ext[] = array(
- 'ext_name' => 'football/football',
- 'lang_set' => 'permissions_football',
- );
- }
- $event['lang_set_ext'] = $lang_set_ext;
- }
-
- /**
- * Add football links if user is authed to see it
- *
- * @return null
- */
- public function add_football_links($event)
- {
- global $request, $cache, $season, $league, $matchday;
-
- $ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
- if (!$this->has_football_access())
- {
- return;
- }
-
- if (isset($this->config['football_side']) && $this->config['football_side'] && !$this->user->data['football_mobile'])
- {
- if (!($wrapped_football_name = $cache->get('wrapped_football_name')))
- {
- $wrapped_football_name = '';
- $string = utf8_decode($this->config['football_name']);
- for($i = 0; $i < strlen($string); $i++)
- {
- $wrapped_football_name .= strtoupper($string[$i]) . '
';
- }
- $wrapped_football_name = utf8_encode($wrapped_football_name);
- $cache->put($wrapped_football_name, $wrapped_football_name);
- }
-
- $this->template->assign_vars(array(
- 'S_FOOTBALLSIDE' => $wrapped_football_name,
- 'S_FOOTBALL_SIDE' => true,
- ));
- }
-
-
- $football_season = (empty($this->user->data['football_season'])) ? 0 : $this->user->data['football_season'];
- $football_league = (empty($this->user->data['football_league'])) ? 0 : $this->user->data['football_league'];
- $football_matchday = (empty($this->user->data['football_matchday'])) ? 0 : $this->user->data['football_matchday'];
-
- $season = $request->variable('s', $football_season);
- $league = $request->variable('l', $football_league);
- $matchday = $request->variable('m', $football_matchday);
-
- $in_football_ext = (!defined('IN_FOOTBALL')) ? false : IN_FOOTBALL;
-
- $this->template->assign_vars(array(
- 'S_DISPLAY_FOOTBALL_MENU' => $this->config['football_menu'],
- 'S_FOOTBALL_BREADCRUMB' => $this->config['football_breadcrumb'],
- 'S_FOOTBALL_NAME' => $this->config['football_name'],
- 'S_FOOTBALL_HEADER_LEAGUE' => $league,
- 'S_FOOTBALL_EXT_PATH' => $ext_path,
- 'S_FOOTBALL_HEADER_ENABLED' => $this->config['football_header_enable'] ? $in_football_ext : false,
- 'U_FOOTBALL' => $this->controller_helper->route('football_main_controller', array('side' => 'bet')),
- 'U_BET' => $this->controller_helper->route('football_main_controller', array('side' => 'bet', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_ALL_BETS' => $this->controller_helper->route('football_main_controller', array('side' => 'all_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_RESULTS' => $this->controller_helper->route('football_main_controller', array('side' => 'results', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_TABLE' => $this->controller_helper->route('football_main_controller', array('side' => 'table', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_RANKS_TOTAL' => $this->controller_helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_RANKS_MATCHDAY' => $this->controller_helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_DELIVERY_LIST' => $this->controller_helper->route('football_main_controller', array('side' => 'delivery', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_LAST_VISITORS' => $this->controller_helper->route('football_main_controller', array('side' => 'last_users', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_FOOTBALL_BANK' => $this->controller_helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_RULES' => $this->controller_helper->route('football_football_popup', array('popside' => 'rules_popup', 's' => $season, 'l' => $league)),
- 'U_EXPORT' => $this->controller_helper->route('football_football_download', array('downside' => 'dload_export', 's' => $season, 'l' => $league)),
- 'U_ODDS' => $this->controller_helper->route('football_main_controller', array('side' => 'odds', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'S_MENU_LINK1' => (strlen($this->config['football_menu_link1']) > 4) ? true : false,
- 'U_MENU_LINK1' => $this->config['football_menu_link1'],
- 'MENU_DESC_LINK1' => $this->config['football_menu_desc1'],
- 'S_MENU_LINK2' => (strlen($this->config['football_menu_link2']) > 4) ? true : false,
- 'U_MENU_LINK2' => $this->config['football_menu_link2'],
- 'MENU_DESC_LINK2' => $this->config['football_menu_desc2'],
- 'S_MENU_LINK3' => (strlen($this->config['football_menu_link3']) > 4) ? true : false,
- 'U_MENU_LINK3' => (strpos($this->config['football_menu_link3'], 'xml/league.php') === false) ? $this->config['football_menu_link3'] : $this->config['football_menu_link3'] . "&season=$season&league=$league",
- 'MENU_DESC_LINK3' => $this->config['football_menu_desc3'],
- 'U_MY_BETS' => $this->controller_helper->route('football_main_controller', array('side' => 'my_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_MY_POINTS' => $this->controller_helper->route('football_main_controller', array('side' => 'my_points', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_MY_TABLE' => $this->controller_helper->route('football_main_controller', array('side' => 'my_table', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_MY_RANK' => $this->controller_helper->route('football_main_controller', array('side' => 'my_rank', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_MY_CHART' => $this->controller_helper->route('football_main_controller', array('side' => 'my_chart', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_MY_KOEFF' => $this->controller_helper->route('football_main_controller', array('side' => 'my_koeff', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_STAT_RESULTS' => $this->controller_helper->route('football_main_controller', array('side' => 'stat_results', 's' => $season, 'l' => $league, 'm' => $matchday)),
- 'U_STAT_POINTS' => $this->controller_helper->route('football_main_controller', array('side' => 'stat_points', 's' => $season, 'l' => $league, 'm' => $matchday)),
- ));
- }
-
- /**
- * Detect mobile devices
- *
- * @return null
- */
- public function detect_mobile_device()
- {
- global $db, $request, $mobile_device, $mobile;
-
- $mobile = false;
- $user_agent = $request->server('HTTP_USER_AGENT');
- if ($this->user->data['football_mobile_device'] == '')
- {
- switch(true)
- {
- /** Remove Bots from the list */
- case (preg_match('/bot|yahoo|Java|httpget/i', $user_agent));
- $mobile = false;
- break;
- case (preg_match('/ipad/i', $user_agent));
- $mobile_device = 'iPad';
- $mobile = true;
- break;
- case (preg_match('/ipod/i', $user_agent));
- $mobile_device = 'iPod';
- $mobile = true;
- break;
- case (preg_match('/iphone/i', $user_agent));
- $mobile_device = 'iPhone';
- $mobile = true;
- break;
- case (preg_match('/android/i', $user_agent));
- if (preg_match('/SM-G870A|SM-G900A|SM-G900F|SM-G900H|SM-G900M|SM-G900P|SM-G900R4|SM-G900T|SM-G900V|SM-G900W8|SM-G800F/i', $user_agent))
- {
- $mobile_device = 'Samsung S5';
- }
- elseif (preg_match('/SGH-I497/i', $user_agent))
- {
- $mobile_device = 'Samsung Tablet';
- }
- elseif (preg_match('/GT-P5210|SM-T110|SM-T310/i', $user_agent))
- {
- $mobile_device = 'Samsung Tab 3';
- }
- elseif (preg_match('/SM-T335|SM-T530/i', $user_agent))
- {
- $mobile_device = 'Samsung Tab 4';
- }
- elseif (preg_match('/SM-T520/i', $user_agent))
- {
- $mobile_device = 'Samsung TabPRO';
- }
- elseif (preg_match('/SGH-I537|GT-I9505|GT-I9500|SPH-L720T/i', $user_agent))
- {
- $mobile_device = 'Samsung S4';
- }
- elseif (preg_match('/GT-I9100P/i', $user_agent))
- {
- $mobile_device = 'Samsung S2';
- }
- elseif (preg_match('/SM-N7505|SM-N9005|SM-P600/i', $user_agent))
- {
- $mobile_device = 'Samsung Note 3';
- }
- elseif (preg_match('/SM-N910C|SM-N910F/i', $user_agent))
- {
- $mobile_device = 'Samsung Note 4';
- }
- elseif (preg_match('/SM-G357FZ/i', $user_agent))
- {
- $mobile_device = 'Samsung Ace 4';
- }
- elseif (preg_match('/SM-G925P/i', $user_agent))
- {
- $mobile_device = 'Samsung S6 Edge';
- }
- elseif (preg_match('/GT-S7582/i', $user_agent))
- {
- $mobile_device = 'Samsung S Duos 2';
- }
- elseif (preg_match('/GT-I9100P/i', $user_agent))
- {
- $mobile_device = 'Samsung S2';
- }
- elseif (preg_match('/IMM76B/i', $user_agent))
- {
- $mobile_device = 'Samsung Nexus';
- }
- elseif (preg_match('/TF101/i', $user_agent))
- {
- $mobile_device = 'Asus Transformer Tablet';
- }
- elseif (preg_match('/Archos 40b/i', $user_agent))
- {
- $mobile_device = 'Archos 40b Titanium Surround';
- }
- elseif (preg_match('/A0001/i', $user_agent))
- {
- $mobile_device = 'OnePlus One';
- }
- elseif (preg_match('/Orange Nura/i', $user_agent))
- {
- $mobile_device = 'Orange Nura';
- }
- elseif (preg_match('/XT1030/i', $user_agent))
- {
- $mobile_device = 'Motorola Droid Mini';
- }
- elseif (preg_match('/TIANYU-KTOUCH/i', $user_agent))
- {
- $mobile_device = 'Tianyu K-Touch';
- }
- elseif (preg_match('/D2005|D2105/i', $user_agent))
- {
- $mobile_device = 'Sony Xperia E1 Dual';
- }
- elseif (preg_match('/C2005|D2303/i', $user_agent))
- {
- $mobile_device = 'Sony XPERIA M2';
- }
- elseif (preg_match('/C6906/i', $user_agent))
- {
- $mobile_device = 'Sony Xperia Z1';
- }
- elseif (preg_match('/D5803/i', $user_agent))
- {
- $mobile_device = 'Sony Xperia Z3';
- }
- elseif (preg_match('/ASUS_T00J/i', $user_agent))
- {
- $mobile_device = 'ASUS T00J';
- }
- elseif (preg_match('/Aquaris E5/i', $user_agent))
- {
- $mobile_device = 'Aquaris E5 HD';
- }
- elseif (preg_match('/P710/i', $user_agent))
- {
- $mobile_device = 'LG Optimus L7 II';
- }
- elseif (preg_match('/HTC Desire|626s/i', $user_agent))
- {
- $mobile_device = 'HTC Desire';
- }
- elseif (preg_match('/Nexus 4|LRX22C|LVY48F/i', $user_agent))
- {
- $mobile_device = 'Nexus 4';
- }
- elseif (preg_match('/Nexus 5|LMY48S/i', $user_agent))
- {
- $mobile_device = 'Nexus 5';
- }
- elseif (preg_match('/Nexus 7|KTU84P/i', $user_agent))
- {
- $mobile_device = 'Nexus 7';
- }
- elseif (preg_match('/Nexus 9|LMY47X/i', $user_agent))
- {
- $mobile_device = 'Nexus 9';
- }
- elseif (preg_match('/Lenovo_K50_T5/i', $user_agent))
- {
- $mobile_device = 'Lenovo K50-t5';
- }
- elseif (preg_match('/HUAWEI GRA-L09/i', $user_agent))
- {
- $mobile_device = 'HUAWEI P8';
- }
- else
- {
- $mobile_device = 'ANDROID';
- }
- $mobile = true;
- break;
- case (preg_match('/lg/i', $user_agent));
- $mobile_device = 'LG';
- $mobile = true;
- break;
- case (preg_match('/opera mini/i', $user_agent));
- $mobile_device = 'MOBILE';
- $mobile = true;
- break;
- case (preg_match('/blackberry/i', $user_agent));
- if (preg_match('/BlackBerry9900|BlackBerry9930|BlackBerry9790|BlackBerry9780|BlackBerry9700|BlackBerry9650|BlackBerry9000/i', $user_agent))
- {
- $mobile_device = 'BlackBerry Bold';
- }
- elseif (preg_match('/BlackBerry9380|BlackBerry9370|BlackBerry9360|BlackBerry9350|BlackBerry9330|BlackBerry9320|BlackBerry9300|BlackBerry9220|BlackBerry8980|BlackBerry8900|BlackBerry8530|BlackBerry8520|BlackBerry8330|BlackBerry8320|BlackBerry8310|BlackBerry8300/i', $user_agent))
- {
- $mobile_device = 'BlackBerry Curve';
- }
- elseif (preg_match('/BlackBerry9860|BlackBerry9850|BlackBerry9810|BlackBerry9800/i', $user_agent))
- {
- $mobile_device = 'BlackBerry Torch';
- }
- elseif (preg_match('/BlackBerry9900/i', $user_agent))
- {
- $mobile_device = 'BlackBerry Touch';
- }
- elseif (preg_match('/BlackBerry9105/i', $user_agent))
- {
- $mobile_device = 'BlackBerry Pearl';
- }
- elseif (preg_match('/BlackBerry8220/i', $user_agent))
- {
- $mobile_device = 'BlackBerry Pearl Flip';
- }
- elseif (preg_match('/BlackBerry PlayBook|BlackBerry Porsche|BlackBerry Passport|BlackBerry Storm|BlackBerry Storm2/', $user_agent, $match_device))
- {
- $mobile_device = $match_device[0];
- }
- else
- {
- $mobile_device = 'BlackBerry';
- }
- $mobile = true;
- break;
- case (preg_match('/(pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i', $user_agent));
- $mobile_device = 'Palm';
- $mobile = true;
- break;
- case (preg_match('/(iris|3g_t|windows ce|windows Phone|opera mobi|windows ce; smartphone;|windows ce; iemobile)/i', $user_agent));
- $mobile_device = 'Windows Smartphone';
- $mobile = true;
- break;
- case (preg_match('/lge vx10000/i', $user_agent));
- $mobile_device = 'Voyager';
- $mobile = true;
- break;
- case (preg_match('/(mini 9.5|vx1000|lge |m800|e860|u940|ux840|compal|wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|m881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|s800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|d736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |sonyericsson|samsung|240x|x320|vx10|nokia|sony cmd|motorola|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|psp|treo)/i', $user_agent));
- $mobile_device = 'MOBILE';
- $mobile = true;
- break;
- case (isset($post['HTTP_X_WAP_PROFILE'])||isset($post['HTTP_PROFILE']));
- $mobile_device = 'MOBILE';
- $mobile = true;
- break;
- case (in_array(strtolower(substr($user_agent,0,4)),array('1207'=>'1207','3gso'=>'3gso','4thp'=>'4thp','501i'=>'501i','502i'=>'502i','503i'=>'503i','504i'=>'504i','505i'=>'505i','506i'=>'506i','6310'=>'6310','6590'=>'6590','770s'=>'770s','802s'=>'802s','a wa'=>'a wa','acer'=>'acer','acs-'=>'acs-','airn'=>'airn','alav'=>'alav','asus'=>'asus','attw'=>'attw','au-m'=>'au-m','aur '=>'aur ','aus '=>'aus ','abac'=>'abac','acoo'=>'acoo','aiko'=>'aiko','alco'=>'alco','alca'=>'alca','amoi'=>'amoi','anex'=>'anex','anny'=>'anny','anyw'=>'anyw','aptu'=>'aptu','arch'=>'arch','argo'=>'argo','bell'=>'bell','bird'=>'bird','bw-n'=>'bw-n','bw-u'=>'bw-u','beck'=>'beck','benq'=>'benq','bilb'=>'bilb','blac'=>'blac','c55/'=>'c55/','cdm-'=>'cdm-','chtm'=>'chtm','capi'=>'capi','cond'=>'cond','craw'=>'craw','dall'=>'dall','dbte'=>'dbte','dc-s'=>'dc-s','dica'=>'dica','ds-d'=>'ds-d','ds12'=>'ds12','dait'=>'dait','devi'=>'devi','dmob'=>'dmob','doco'=>'doco','dopo'=>'dopo','el49'=>'el49','erk0'=>'erk0','esl8'=>'esl8','ez40'=>'ez40','ez60'=>'ez60','ez70'=>'ez70','ezos'=>'ezos','ezze'=>'ezze','elai'=>'elai','emul'=>'emul','eric'=>'eric','ezwa'=>'ezwa','fake'=>'fake','fly-'=>'fly-','fly_'=>'fly_','g-mo'=>'g-mo','g1 u'=>'g1 u','g560'=>'g560','gf-5'=>'gf-5','grun'=>'grun','gene'=>'gene','go.w'=>'go.w','good'=>'good','grad'=>'grad','hcit'=>'hcit','hd-m'=>'hd-m','hd-p'=>'hd-p','hd-t'=>'hd-t','hei-'=>'hei-','hp i'=>'hp i','hpip'=>'hpip','hs-c'=>'hs-c','htc '=>'htc ','htc-'=>'htc-','htca'=>'htca','htcg'=>'htcg','htcp'=>'htcp','htcs'=>'htcs','htct'=>'htct','htc_'=>'htc_','haie'=>'haie','hita'=>'hita','huaw'=>'huaw','hutc'=>'hutc','i-20'=>'i-20','i-go'=>'i-go','i-ma'=>'i-ma','i230'=>'i230','iac'=>'iac','iac-'=>'iac-','iac/'=>'iac/','ig01'=>'ig01','im1k'=>'im1k','inno'=>'inno','iris'=>'iris','jata'=>'jata','java'=>'java','kddi'=>'kddi','kgt'=>'kgt','kgt/'=>'kgt/','kpt '=>'kpt ','kwc-'=>'kwc-','klon'=>'klon','lexi'=>'lexi','lg g'=>'lg g','lg-a'=>'lg-a','lg-b'=>'lg-b','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-f'=>'lg-f','lg-g'=>'lg-g','lg-k'=>'lg-k','lg-l'=>'lg-l','lg-m'=>'lg-m','lg-o'=>'lg-o','lg-p'=>'lg-p','lg-s'=>'lg-s','lg-t'=>'lg-t','lg-u'=>'lg-u','lg-w'=>'lg-w','lg/k'=>'lg/k','lg/l'=>'lg/l','lg/u'=>'lg/u','lg50'=>'lg50','lg54'=>'lg54','lge-'=>'lge-','lge/'=>'lge/','lynx'=>'lynx','leno'=>'leno','m1-w'=>'m1-w','m3ga'=>'m3ga','m50/'=>'m50/','maui'=>'maui','mc01'=>'mc01','mc21'=>'mc21','mcca'=>'mcca','medi'=>'medi','meri'=>'meri','mio8'=>'mio8','mioa'=>'mioa','mo01'=>'mo01','mo02'=>'mo02','mode'=>'mode','modo'=>'modo','mot '=>'mot ','mot-'=>'mot-','mt50'=>'mt50','mtp1'=>'mtp1','mtv '=>'mtv ','mate'=>'mate','maxo'=>'maxo','merc'=>'merc','mits'=>'mits','mobi'=>'mobi','motv'=>'motv','mozz'=>'mozz','n100'=>'n100','n101'=>'n101','n102'=>'n102','n202'=>'n202','n203'=>'n203','n300'=>'n300','n302'=>'n302','n500'=>'n500','n502'=>'n502','n505'=>'n505','n700'=>'n700','n701'=>'n701','n710'=>'n710','nec-'=>'nec-','nem-'=>'nem-','newg'=>'newg','neon'=>'neon','netf'=>'netf','noki'=>'noki','nzph'=>'nzph','o2 x'=>'o2 x','o2-x'=>'o2-x','opwv'=>'opwv','owg1'=>'owg1','opti'=>'opti','oran'=>'oran','p800'=>'p800','pand'=>'pand','pg-1'=>'pg-1','pg-2'=>'pg-2','pg-3'=>'pg-3','pg-6'=>'pg-6','pg-8'=>'pg-8','pg-c'=>'pg-c','pg13'=>'pg13','phil'=>'phil','pn-2'=>'pn-2','pt-g'=>'pt-g','palm'=>'palm','pana'=>'pana','pire'=>'pire','pock'=>'pock','pose'=>'pose','psio'=>'psio','qa-a'=>'qa-a','qc-2'=>'qc-2','qc-3'=>'qc-3','qc-5'=>'qc-5','qc-7'=>'qc-7','qc07'=>'qc07','qc12'=>'qc12','qc21'=>'qc21','qc32'=>'qc32','qc60'=>'qc60','qci-'=>'qci-','qwap'=>'qwap','qtek'=>'qtek','r380'=>'r380','r600'=>'r600','raks'=>'raks','rim9'=>'rim9','rove'=>'rove','s55/'=>'s55/','sage'=>'sage','sams'=>'sams','sc01'=>'sc01','sch-'=>'sch-','scp-'=>'scp-','sdk/'=>'sdk/','se47'=>'se47','sec-'=>'sec-','sec0'=>'sec0','sec1'=>'sec1','semc'=>'semc','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','sk-0'=>'sk-0','sl45'=>'sl45','slid'=>'slid','smb3'=>'smb3','smt5'=>'smt5','sp01'=>'sp01','sph-'=>'sph-','spv '=>'spv ','spv-'=>'spv-','sy01'=>'sy01','samm'=>'samm','sany'=>'sany','sava'=>'sava','scoo'=>'scoo','send'=>'send','siem'=>'siem','smar'=>'smar','smit'=>'smit','soft'=>'soft','sony'=>'sony','t-mo'=>'t-mo','t218'=>'t218','t250'=>'t250','t600'=>'t600','t610'=>'t610','t618'=>'t618','tcl-'=>'tcl-','tdg-'=>'tdg-','telm'=>'telm','tim-'=>'tim-','ts70'=>'ts70','tsm-'=>'tsm-','tsm3'=>'tsm3','tsm5'=>'tsm5','tx-9'=>'tx-9','tagt'=>'tagt','talk'=>'talk','teli'=>'teli','topl'=>'topl','hiba'=>'hiba','up.b'=>'up.b','upg1'=>'upg1','utst'=>'utst','v400'=>'v400','v750'=>'v750','veri'=>'veri','vk-v'=>'vk-v','vk40'=>'vk40','vk50'=>'vk50','vk52'=>'vk52','vk53'=>'vk53','vm40'=>'vm40','vx98'=>'vx98','virg'=>'virg','vite'=>'vite','voda'=>'voda','vulc'=>'vulc','w3c '=>'w3c ','w3c-'=>'w3c-','wapj'=>'wapj','wapp'=>'wapp','wapu'=>'wapu','wapm'=>'wapm','wig '=>'wig ','wapi'=>'wapi','wapr'=>'wapr','wapv'=>'wapv','wapy'=>'wapy','wapa'=>'wapa','waps'=>'waps','wapt'=>'wapt','winc'=>'winc','winw'=>'winw','wonu'=>'wonu','x700'=>'x700','xda2'=>'xda2','xdag'=>'xdag','yas-'=>'yas-','your'=>'your','zte-'=>'zte-','zeto'=>'zeto','acs-'=>'acs-','alav'=>'alav','alca'=>'alca','amoi'=>'amoi','aste'=>'aste','audi'=>'audi','avan'=>'avan','benq'=>'benq','bird'=>'bird','blac'=>'blac','blaz'=>'blaz','brew'=>'brew','brvw'=>'brvw','bumb'=>'bumb','ccwa'=>'ccwa','cell'=>'cell','cldc'=>'cldc','cmd-'=>'cmd-','dang'=>'dang','doco'=>'doco','eml2'=>'eml2','eric'=>'eric','fetc'=>'fetc','hipt'=>'hipt','http'=>'http','ibro'=>'ibro','idea'=>'idea','ikom'=>'ikom','inno'=>'inno','ipaq'=>'ipaq','jbro'=>'jbro','jemu'=>'jemu','java'=>'java','jigs'=>'jigs','kddi'=>'kddi','keji'=>'keji','kyoc'=>'kyoc','kyok'=>'kyok','leno'=>'leno','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-g'=>'lg-g','lge-'=>'lge-','libw'=>'libw','m-cr'=>'m-cr','maui'=>'maui','maxo'=>'maxo','midp'=>'midp','mits'=>'mits','mmef'=>'mmef','mobi'=>'mobi','mot-'=>'mot-','moto'=>'moto','mwbp'=>'mwbp','mywa'=>'mywa','nec-'=>'nec-','newt'=>'newt','nok6'=>'nok6','noki'=>'noki','o2im'=>'o2im','opwv'=>'opwv','palm'=>'palm','pana'=>'pana','pant'=>'pant','pdxg'=>'pdxg','phil'=>'phil','play'=>'play','pluc'=>'pluc','port'=>'port','prox'=>'prox','qtek'=>'qtek','qwap'=>'qwap','rozo'=>'rozo','sage'=>'sage','sama'=>'sama','sams'=>'sams','sany'=>'sany','sch-'=>'sch-','sec-'=>'sec-','send'=>'send','seri'=>'seri','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','siem'=>'siem','smal'=>'smal','smar'=>'smar','sony'=>'sony','sph-'=>'sph-','symb'=>'symb','t-mo'=>'t-mo','teli'=>'teli','tim-'=>'tim-','tosh'=>'tosh','treo'=>'treo','tsm-'=>'tsm-','upg1'=>'upg1','upsi'=>'upsi','vk-v'=>'vk-v','voda'=>'voda','vx52'=>'vx52','vx53'=>'vx53','vx60'=>'vx60','vx61'=>'vx61','vx70'=>'vx70','vx80'=>'vx80','vx81'=>'vx81','vx83'=>'vx83','vx85'=>'vx85','wap-'=>'wap-','wapa'=>'wapa','wapi'=>'wapi','wapp'=>'wapp','wapr'=>'wapr','webc'=>'webc','whit'=>'whit','winw'=>'winw','wmlb'=>'wmlb','xda-'=>'xda-',)));
- $mobile_device = 'MOBILE';
- $mobile = true;
- break;
- default;
- $mobile_device = 'Desktop';
- $mobile = false;
- break;
- }
-
- // Write to sessions table
- $sql_ary = array(
- 'football_mobile' => $mobile,
- 'football_mobile_device' => $db->sql_escape($mobile_device),
- );
- $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE session_id = '" . $db->sql_escape($this->user->session_id) . "'";
- $db->sql_query($sql);
- $this->user->data['football_mobile'] = $mobile;
- $this->user->data['football_mobile_device'] = $mobile_device;
- }
- }
-
- /**
- * Check if user should be able to access football prediction league
- *
- * @return bool True of user should be able to access it, false if not
- */
- protected function has_football_access()
- {
- // Can this user view Prediction Leagues pages?
- if (!$this->config['football_guest_view'])
- {
- if ($this->user->data['user_id'] == ANONYMOUS)
- {
- return false;
- }
- }
- if (!$this->config['football_user_view'])
- {
- return $this->auth->acl_get('u_use_football') && ! $this->config['football_disable'];
- }
- return ! $this->config['football_disable'];
- }
-
- public function add_permission_cat($event)
- {
- $perm_cat = $event['categories'];
- $perm_cat['football'] = 'ACP_FOOTBALL';
- $event['categories'] = $perm_cat;
-
- $permission = $event['permissions'];
- $permission['u_use_football'] = array('lang' => 'ACL_U_USE_FOOTBALL', 'cat' => 'football');
- $permission['a_football_config'] = array('lang' => 'ACL_A_FOOTBALL_CONFIG', 'cat' => 'football');
- $permission['a_football_delete'] = array('lang' => 'ACL_A_FOOTBALL_DELETE', 'cat' => 'football');
- $permission['a_football_editbets'] = array('lang' => 'ACL_A_FOOTBALL_EDITBETS', 'cat' => 'football');
- $permission['a_football_plan'] = array('lang' => 'ACL_A_FOOTBALL_PLAN', 'cat' => 'football');
- $permission['a_football_results'] = array('lang' => 'ACL_A_FOOTBALL_RESULTS', 'cat' => 'football');
- $permission['a_football_points'] = array('lang' => 'ACL_A_FOOTBALL_POINTS', 'cat' => 'football');
- $event['permissions'] = $permission;
- }
-}
+auth = $auth;
+ $this->config = $config;
+ $this->controller_helper = $helper;
+ $this->template = $template;
+ $this->phpbb_path_helper = $path_helper;
+ $this->phpbb_extension_manager = $phpbb_extension_manager;
+ $this->user = $user;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+
+// include($path_helper->update_web_root_path($phpbb_extension_manager->get_extension_path('football/football', true)) . 'includes/constants.' . $php_ext);
+ }
+
+ /**
+ * Assign functions defined in this class to event listeners in the core
+ *
+ * @return array
+ */
+ static public function getSubscribedEvents()
+ {
+ return array(
+ 'core.viewonline_overwrite_location' => 'viewonline_page',
+ 'core.user_setup' => 'load_language_on_setup',
+ 'core.page_header' => 'add_football_links',
+ 'core.session_kill_after' => 'detect_mobile_device',
+ 'core.session_create_after' => 'detect_mobile_device',
+ 'core.permissions' => 'add_permission_cat',
+ );
+ }
+
+ /**
+ * Show users as viewing the football prediction league on Who Is Online page
+ *
+ * @param object $event The event object
+ * @return null
+ */
+ public function viewonline_page($event)
+ {
+ global $db;
+ if (strrpos($event['row']['session_page'], 'app.' . $this->php_ext . '/football') === 0)
+ {
+ $action = substr($event['row']['session_page'], 17);
+ $url_parts = $this->phpbb_path_helper->get_url_parts($action, false);
+ $params = (isset($url_parts['params'])) ? $url_parts['params'] : array();
+ if (isset($params['l']) and isset($params['s']))
+ {
+ include_once($this->phpbb_root_path . 'ext/football/football/includes/constants.' . $this->php_ext);
+ $season = $params['s'];
+ $league =$params['l'];
+ $sql = 'SELECT league_name FROM ' . FOOTB_LEAGUES . "
+ WHERE season = $season AND league = $league
+ ";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $event['location'] = $this->user->lang('VIEWING_LEAGUE' . (empty($url_parts['base']) ? '' : '_' . strtoupper ($url_parts['base'])), $row['league_name']);
+ }
+ else
+ {
+ $event['location_url'] = $this->controller_helper->route('football_main_controller', array_merge(array('side' => $url_parts['base']), $url_parts['params']));
+ }
+ $db->sql_freeresult($result);
+ }
+ else
+ {
+ $event['location'] = $this->user->lang('VIEWING_FOOTBALL' . (empty($url_parts['base']) ? '' : '_' . strtoupper ($url_parts['base'])));
+ }
+ $event['location_url'] = $this->controller_helper->route('football_main_controller', array_merge(array('side' => $url_parts['base']), $url_parts['params']));
+ }
+ }
+
+ /**
+ * Load football prediction league language during user setup
+ *
+ * @param object $event The event object
+ * @return null
+ */
+ public function load_language_on_setup($event)
+ {
+ $lang_set_ext = $event['lang_set_ext'];
+ $lang_set_ext[] = array(
+ 'ext_name' => 'football/football',
+ 'lang_set' => 'football',
+ );
+ if (defined('ADMIN_START'))
+ {
+ $lang_set_ext[] = array(
+ 'ext_name' => 'football/football',
+ 'lang_set' => 'permissions_football',
+ );
+ }
+ $event['lang_set_ext'] = $lang_set_ext;
+ }
+
+ /**
+ * Add football links if user is authed to see it
+ *
+ * @return null
+ */
+ public function add_football_links($event)
+ {
+ global $request, $cache, $season, $league, $matchday;
+
+ $ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
+ if (!$this->has_football_access())
+ {
+ return;
+ }
+
+ if (isset($this->config['football_side']) && $this->config['football_side'] && !$this->user->data['football_mobile'])
+ {
+ if (!($wrapped_football_name = $cache->get('wrapped_football_name')))
+ {
+ $wrapped_football_name = '';
+ $string = utf8_decode($this->config['football_name']);
+ for($i = 0; $i < strlen($string); $i++)
+ {
+ $wrapped_football_name .= strtoupper($string[$i]) . '
';
+ }
+ $wrapped_football_name = utf8_encode($wrapped_football_name);
+ $cache->put($wrapped_football_name, $wrapped_football_name);
+ }
+
+ $this->template->assign_vars(array(
+ 'S_FOOTBALLSIDE' => $wrapped_football_name,
+ 'S_FOOTBALL_SIDE' => true,
+ ));
+ }
+
+
+ $football_season = (empty($this->user->data['football_season'])) ? 0 : $this->user->data['football_season'];
+ $football_league = (empty($this->user->data['football_league'])) ? 0 : $this->user->data['football_league'];
+ $football_matchday = (empty($this->user->data['football_matchday'])) ? 0 : $this->user->data['football_matchday'];
+
+ $season = $request->variable('s', $football_season);
+ $league = $request->variable('l', $football_league);
+ $matchday = $request->variable('m', $football_matchday);
+
+ $in_football_ext = (!defined('IN_FOOTBALL')) ? false : IN_FOOTBALL;
+
+ $this->template->assign_vars(array(
+ 'S_DISPLAY_FOOTBALL_MENU' => $this->config['football_menu'],
+ 'S_FOOTBALL_BREADCRUMB' => $this->config['football_breadcrumb'],
+ 'S_FOOTBALL_NAME' => $this->config['football_name'],
+ 'S_FOOTBALL_HEADER_LEAGUE' => $league,
+ 'S_FOOTBALL_EXT_PATH' => $ext_path,
+ 'S_FOOTBALL_HEADER_ENABLED' => $this->config['football_header_enable'] ? $in_football_ext : false,
+ 'U_FOOTBALL' => $this->controller_helper->route('football_main_controller', array('side' => 'bet')),
+ 'U_BET' => $this->controller_helper->route('football_main_controller', array('side' => 'bet', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_ALL_BETS' => $this->controller_helper->route('football_main_controller', array('side' => 'all_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_RESULTS' => $this->controller_helper->route('football_main_controller', array('side' => 'results', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_TABLE' => $this->controller_helper->route('football_main_controller', array('side' => 'table', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_RANKS_TOTAL' => $this->controller_helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_RANKS_MATCHDAY' => $this->controller_helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_DELIVERY_LIST' => $this->controller_helper->route('football_main_controller', array('side' => 'delivery', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_LAST_VISITORS' => $this->controller_helper->route('football_main_controller', array('side' => 'last_users', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_FOOTBALL_BANK' => $this->controller_helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_RULES' => $this->controller_helper->route('football_football_popup', array('popside' => 'rules_popup', 's' => $season, 'l' => $league)),
+ 'U_EXPORT' => $this->controller_helper->route('football_football_download', array('downside' => 'dload_export', 's' => $season, 'l' => $league)),
+ 'U_ODDS' => $this->controller_helper->route('football_main_controller', array('side' => 'odds', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'S_MENU_LINK1' => (strlen($this->config['football_menu_link1']) > 4) ? true : false,
+ 'U_MENU_LINK1' => $this->config['football_menu_link1'],
+ 'MENU_DESC_LINK1' => $this->config['football_menu_desc1'],
+ 'S_MENU_LINK2' => (strlen($this->config['football_menu_link2']) > 4) ? true : false,
+ 'U_MENU_LINK2' => $this->config['football_menu_link2'],
+ 'MENU_DESC_LINK2' => $this->config['football_menu_desc2'],
+ 'S_MENU_LINK3' => (strlen($this->config['football_menu_link3']) > 4) ? true : false,
+ 'U_MENU_LINK3' => (strpos($this->config['football_menu_link3'], 'xml/league.php') === false) ? $this->config['football_menu_link3'] : $this->config['football_menu_link3'] . "&season=$season&league=$league",
+ 'MENU_DESC_LINK3' => $this->config['football_menu_desc3'],
+ 'U_MY_BETS' => $this->controller_helper->route('football_main_controller', array('side' => 'my_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_MY_POINTS' => $this->controller_helper->route('football_main_controller', array('side' => 'my_points', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_MY_TABLE' => $this->controller_helper->route('football_main_controller', array('side' => 'my_table', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_MY_RANK' => $this->controller_helper->route('football_main_controller', array('side' => 'my_rank', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_MY_CHART' => $this->controller_helper->route('football_main_controller', array('side' => 'my_chart', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_MY_KOEFF' => $this->controller_helper->route('football_main_controller', array('side' => 'my_koeff', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_STAT_RESULTS' => $this->controller_helper->route('football_main_controller', array('side' => 'stat_results', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ 'U_STAT_POINTS' => $this->controller_helper->route('football_main_controller', array('side' => 'stat_points', 's' => $season, 'l' => $league, 'm' => $matchday)),
+ ));
+ }
+
+ /**
+ * Detect mobile devices
+ *
+ * @return null
+ */
+ public function detect_mobile_device()
+ {
+ global $db, $request, $mobile_device, $mobile;
+
+ $mobile = false;
+ $user_agent = $request->server('HTTP_USER_AGENT');
+
+ switch(true)
+ {
+ /** Remove Bots from the list */
+ case (preg_match('/bot|yahoo|Java|httpget/i', $user_agent));
+ $mobile = false;
+ break;
+ case (preg_match('/ipad/i', $user_agent));
+ $mobile_device = 'iPad';
+ $mobile = true;
+ break;
+ case (preg_match('/ipod/i', $user_agent));
+ $mobile_device = 'iPod';
+ $mobile = true;
+ break;
+ case (preg_match('/iphone/i', $user_agent));
+ $mobile_device = 'iPhone';
+ $mobile = true;
+ break;
+ case (preg_match('/android/i', $user_agent));
+ if (preg_match('/SM-G870A|SM-G900A|SM-G900F|SM-G900H|SM-G900M|SM-G900P|SM-G900R4|SM-G900T|SM-G900V|SM-G900W8|SM-G800F/i', $user_agent))
+ {
+ $mobile_device = 'Samsung S5';
+ }
+ elseif (preg_match('/SGH-I497/i', $user_agent))
+ {
+ $mobile_device = 'Samsung Tablet';
+ }
+ elseif (preg_match('/GT-P5210|SM-T110|SM-T310/i', $user_agent))
+ {
+ $mobile_device = 'Samsung Tab 3';
+ }
+ elseif (preg_match('/SM-T335|SM-T530/i', $user_agent))
+ {
+ $mobile_device = 'Samsung Tab 4';
+ }
+ elseif (preg_match('/SM-T520/i', $user_agent))
+ {
+ $mobile_device = 'Samsung TabPRO';
+ }
+ elseif (preg_match('/SGH-I537|GT-I9505|GT-I9500|SPH-L720T/i', $user_agent))
+ {
+ $mobile_device = 'Samsung S4';
+ }
+ elseif (preg_match('/GT-I9100P/i', $user_agent))
+ {
+ $mobile_device = 'Samsung S2';
+ }
+ elseif (preg_match('/SM-N7505|SM-N9005|SM-P600/i', $user_agent))
+ {
+ $mobile_device = 'Samsung Note 3';
+ }
+ elseif (preg_match('/SM-N910C|SM-N910F/i', $user_agent))
+ {
+ $mobile_device = 'Samsung Note 4';
+ }
+ elseif (preg_match('/SM-G357FZ/i', $user_agent))
+ {
+ $mobile_device = 'Samsung Ace 4';
+ }
+ elseif (preg_match('/SM-G925P/i', $user_agent))
+ {
+ $mobile_device = 'Samsung S6 Edge';
+ }
+ elseif (preg_match('/GT-S7582/i', $user_agent))
+ {
+ $mobile_device = 'Samsung S Duos 2';
+ }
+ elseif (preg_match('/GT-I9100P/i', $user_agent))
+ {
+ $mobile_device = 'Samsung S2';
+ }
+ elseif (preg_match('/IMM76B/i', $user_agent))
+ {
+ $mobile_device = 'Samsung Nexus';
+ }
+ elseif (preg_match('/TF101/i', $user_agent))
+ {
+ $mobile_device = 'Asus Transformer Tablet';
+ }
+ elseif (preg_match('/Archos 40b/i', $user_agent))
+ {
+ $mobile_device = 'Archos 40b Titanium Surround';
+ }
+ elseif (preg_match('/A0001/i', $user_agent))
+ {
+ $mobile_device = 'OnePlus One';
+ }
+ elseif (preg_match('/Orange Nura/i', $user_agent))
+ {
+ $mobile_device = 'Orange Nura';
+ }
+ elseif (preg_match('/XT1030/i', $user_agent))
+ {
+ $mobile_device = 'Motorola Droid Mini';
+ }
+ elseif (preg_match('/TIANYU-KTOUCH/i', $user_agent))
+ {
+ $mobile_device = 'Tianyu K-Touch';
+ }
+ elseif (preg_match('/D2005|D2105/i', $user_agent))
+ {
+ $mobile_device = 'Sony Xperia E1 Dual';
+ }
+ elseif (preg_match('/C2005|D2303/i', $user_agent))
+ {
+ $mobile_device = 'Sony XPERIA M2';
+ }
+ elseif (preg_match('/C6906/i', $user_agent))
+ {
+ $mobile_device = 'Sony Xperia Z1';
+ }
+ elseif (preg_match('/D5803/i', $user_agent))
+ {
+ $mobile_device = 'Sony Xperia Z3';
+ }
+ elseif (preg_match('/ASUS_T00J/i', $user_agent))
+ {
+ $mobile_device = 'ASUS T00J';
+ }
+ elseif (preg_match('/Aquaris E5/i', $user_agent))
+ {
+ $mobile_device = 'Aquaris E5 HD';
+ }
+ elseif (preg_match('/P710/i', $user_agent))
+ {
+ $mobile_device = 'LG Optimus L7 II';
+ }
+ elseif (preg_match('/HTC Desire|626s/i', $user_agent))
+ {
+ $mobile_device = 'HTC Desire';
+ }
+ elseif (preg_match('/Nexus 4|LRX22C|LVY48F/i', $user_agent))
+ {
+ $mobile_device = 'Nexus 4';
+ }
+ elseif (preg_match('/Nexus 5|LMY48S/i', $user_agent))
+ {
+ $mobile_device = 'Nexus 5';
+ }
+ elseif (preg_match('/Nexus 7|KTU84P/i', $user_agent))
+ {
+ $mobile_device = 'Nexus 7';
+ }
+ elseif (preg_match('/Nexus 9|LMY47X/i', $user_agent))
+ {
+ $mobile_device = 'Nexus 9';
+ }
+ elseif (preg_match('/Lenovo_K50_T5/i', $user_agent))
+ {
+ $mobile_device = 'Lenovo K50-t5';
+ }
+ elseif (preg_match('/HUAWEI GRA-L09/i', $user_agent))
+ {
+ $mobile_device = 'HUAWEI P8';
+ }
+ else
+ {
+ $mobile_device = 'ANDROID';
+ }
+ $mobile = true;
+ break;
+ case (preg_match('/lg/i', $user_agent));
+ $mobile_device = 'LG';
+ $mobile = true;
+ break;
+ case (preg_match('/opera mini/i', $user_agent));
+ $mobile_device = 'MOBILE';
+ $mobile = true;
+ break;
+ case (preg_match('/blackberry/i', $user_agent));
+ if (preg_match('/BlackBerry9900|BlackBerry9930|BlackBerry9790|BlackBerry9780|BlackBerry9700|BlackBerry9650|BlackBerry9000/i', $user_agent))
+ {
+ $mobile_device = 'BlackBerry Bold';
+ }
+ elseif (preg_match('/BlackBerry9380|BlackBerry9370|BlackBerry9360|BlackBerry9350|BlackBerry9330|BlackBerry9320|BlackBerry9300|BlackBerry9220|BlackBerry8980|BlackBerry8900|BlackBerry8530|BlackBerry8520|BlackBerry8330|BlackBerry8320|BlackBerry8310|BlackBerry8300/i', $user_agent))
+ {
+ $mobile_device = 'BlackBerry Curve';
+ }
+ elseif (preg_match('/BlackBerry9860|BlackBerry9850|BlackBerry9810|BlackBerry9800/i', $user_agent))
+ {
+ $mobile_device = 'BlackBerry Torch';
+ }
+ elseif (preg_match('/BlackBerry9900/i', $user_agent))
+ {
+ $mobile_device = 'BlackBerry Touch';
+ }
+ elseif (preg_match('/BlackBerry9105/i', $user_agent))
+ {
+ $mobile_device = 'BlackBerry Pearl';
+ }
+ elseif (preg_match('/BlackBerry8220/i', $user_agent))
+ {
+ $mobile_device = 'BlackBerry Pearl Flip';
+ }
+ elseif (preg_match('/BlackBerry PlayBook|BlackBerry Porsche|BlackBerry Passport|BlackBerry Storm|BlackBerry Storm2/', $user_agent, $match_device))
+ {
+ $mobile_device = $match_device[0];
+ }
+ else
+ {
+ $mobile_device = 'BlackBerry';
+ }
+ $mobile = true;
+ break;
+ case (preg_match('/(pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i', $user_agent));
+ $mobile_device = 'Palm';
+ $mobile = true;
+ break;
+ case (preg_match('/(iris|3g_t|windows ce|windows Phone|opera mobi|windows ce; smartphone;|windows ce; iemobile)/i', $user_agent));
+ $mobile_device = 'Windows Smartphone';
+ $mobile = true;
+ break;
+ case (preg_match('/lge vx10000/i', $user_agent));
+ $mobile_device = 'Voyager';
+ $mobile = true;
+ break;
+ case (preg_match('/(mini 9.5|vx1000|lge |m800|e860|u940|ux840|compal|wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|m881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|s800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|d736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |sonyericsson|samsung|240x|x320|vx10|nokia|sony cmd|motorola|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|psp|treo)/i', $user_agent));
+ $mobile_device = 'MOBILE';
+ $mobile = true;
+ break;
+ case (isset($post['HTTP_X_WAP_PROFILE'])||isset($post['HTTP_PROFILE']));
+ $mobile_device = 'MOBILE';
+ $mobile = true;
+ break;
+ case (in_array(strtolower(substr($user_agent,0,4)),array('1207'=>'1207','3gso'=>'3gso','4thp'=>'4thp','501i'=>'501i','502i'=>'502i','503i'=>'503i','504i'=>'504i','505i'=>'505i','506i'=>'506i','6310'=>'6310','6590'=>'6590','770s'=>'770s','802s'=>'802s','a wa'=>'a wa','acer'=>'acer','acs-'=>'acs-','airn'=>'airn','alav'=>'alav','asus'=>'asus','attw'=>'attw','au-m'=>'au-m','aur '=>'aur ','aus '=>'aus ','abac'=>'abac','acoo'=>'acoo','aiko'=>'aiko','alco'=>'alco','alca'=>'alca','amoi'=>'amoi','anex'=>'anex','anny'=>'anny','anyw'=>'anyw','aptu'=>'aptu','arch'=>'arch','argo'=>'argo','bell'=>'bell','bird'=>'bird','bw-n'=>'bw-n','bw-u'=>'bw-u','beck'=>'beck','benq'=>'benq','bilb'=>'bilb','blac'=>'blac','c55/'=>'c55/','cdm-'=>'cdm-','chtm'=>'chtm','capi'=>'capi','cond'=>'cond','craw'=>'craw','dall'=>'dall','dbte'=>'dbte','dc-s'=>'dc-s','dica'=>'dica','ds-d'=>'ds-d','ds12'=>'ds12','dait'=>'dait','devi'=>'devi','dmob'=>'dmob','doco'=>'doco','dopo'=>'dopo','el49'=>'el49','erk0'=>'erk0','esl8'=>'esl8','ez40'=>'ez40','ez60'=>'ez60','ez70'=>'ez70','ezos'=>'ezos','ezze'=>'ezze','elai'=>'elai','emul'=>'emul','eric'=>'eric','ezwa'=>'ezwa','fake'=>'fake','fly-'=>'fly-','fly_'=>'fly_','g-mo'=>'g-mo','g1 u'=>'g1 u','g560'=>'g560','gf-5'=>'gf-5','grun'=>'grun','gene'=>'gene','go.w'=>'go.w','good'=>'good','grad'=>'grad','hcit'=>'hcit','hd-m'=>'hd-m','hd-p'=>'hd-p','hd-t'=>'hd-t','hei-'=>'hei-','hp i'=>'hp i','hpip'=>'hpip','hs-c'=>'hs-c','htc '=>'htc ','htc-'=>'htc-','htca'=>'htca','htcg'=>'htcg','htcp'=>'htcp','htcs'=>'htcs','htct'=>'htct','htc_'=>'htc_','haie'=>'haie','hita'=>'hita','huaw'=>'huaw','hutc'=>'hutc','i-20'=>'i-20','i-go'=>'i-go','i-ma'=>'i-ma','i230'=>'i230','iac'=>'iac','iac-'=>'iac-','iac/'=>'iac/','ig01'=>'ig01','im1k'=>'im1k','inno'=>'inno','iris'=>'iris','jata'=>'jata','java'=>'java','kddi'=>'kddi','kgt'=>'kgt','kgt/'=>'kgt/','kpt '=>'kpt ','kwc-'=>'kwc-','klon'=>'klon','lexi'=>'lexi','lg g'=>'lg g','lg-a'=>'lg-a','lg-b'=>'lg-b','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-f'=>'lg-f','lg-g'=>'lg-g','lg-k'=>'lg-k','lg-l'=>'lg-l','lg-m'=>'lg-m','lg-o'=>'lg-o','lg-p'=>'lg-p','lg-s'=>'lg-s','lg-t'=>'lg-t','lg-u'=>'lg-u','lg-w'=>'lg-w','lg/k'=>'lg/k','lg/l'=>'lg/l','lg/u'=>'lg/u','lg50'=>'lg50','lg54'=>'lg54','lge-'=>'lge-','lge/'=>'lge/','lynx'=>'lynx','leno'=>'leno','m1-w'=>'m1-w','m3ga'=>'m3ga','m50/'=>'m50/','maui'=>'maui','mc01'=>'mc01','mc21'=>'mc21','mcca'=>'mcca','medi'=>'medi','meri'=>'meri','mio8'=>'mio8','mioa'=>'mioa','mo01'=>'mo01','mo02'=>'mo02','mode'=>'mode','modo'=>'modo','mot '=>'mot ','mot-'=>'mot-','mt50'=>'mt50','mtp1'=>'mtp1','mtv '=>'mtv ','mate'=>'mate','maxo'=>'maxo','merc'=>'merc','mits'=>'mits','mobi'=>'mobi','motv'=>'motv','mozz'=>'mozz','n100'=>'n100','n101'=>'n101','n102'=>'n102','n202'=>'n202','n203'=>'n203','n300'=>'n300','n302'=>'n302','n500'=>'n500','n502'=>'n502','n505'=>'n505','n700'=>'n700','n701'=>'n701','n710'=>'n710','nec-'=>'nec-','nem-'=>'nem-','newg'=>'newg','neon'=>'neon','netf'=>'netf','noki'=>'noki','nzph'=>'nzph','o2 x'=>'o2 x','o2-x'=>'o2-x','opwv'=>'opwv','owg1'=>'owg1','opti'=>'opti','oran'=>'oran','p800'=>'p800','pand'=>'pand','pg-1'=>'pg-1','pg-2'=>'pg-2','pg-3'=>'pg-3','pg-6'=>'pg-6','pg-8'=>'pg-8','pg-c'=>'pg-c','pg13'=>'pg13','phil'=>'phil','pn-2'=>'pn-2','pt-g'=>'pt-g','palm'=>'palm','pana'=>'pana','pire'=>'pire','pock'=>'pock','pose'=>'pose','psio'=>'psio','qa-a'=>'qa-a','qc-2'=>'qc-2','qc-3'=>'qc-3','qc-5'=>'qc-5','qc-7'=>'qc-7','qc07'=>'qc07','qc12'=>'qc12','qc21'=>'qc21','qc32'=>'qc32','qc60'=>'qc60','qci-'=>'qci-','qwap'=>'qwap','qtek'=>'qtek','r380'=>'r380','r600'=>'r600','raks'=>'raks','rim9'=>'rim9','rove'=>'rove','s55/'=>'s55/','sage'=>'sage','sams'=>'sams','sc01'=>'sc01','sch-'=>'sch-','scp-'=>'scp-','sdk/'=>'sdk/','se47'=>'se47','sec-'=>'sec-','sec0'=>'sec0','sec1'=>'sec1','semc'=>'semc','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','sk-0'=>'sk-0','sl45'=>'sl45','slid'=>'slid','smb3'=>'smb3','smt5'=>'smt5','sp01'=>'sp01','sph-'=>'sph-','spv '=>'spv ','spv-'=>'spv-','sy01'=>'sy01','samm'=>'samm','sany'=>'sany','sava'=>'sava','scoo'=>'scoo','send'=>'send','siem'=>'siem','smar'=>'smar','smit'=>'smit','soft'=>'soft','sony'=>'sony','t-mo'=>'t-mo','t218'=>'t218','t250'=>'t250','t600'=>'t600','t610'=>'t610','t618'=>'t618','tcl-'=>'tcl-','tdg-'=>'tdg-','telm'=>'telm','tim-'=>'tim-','ts70'=>'ts70','tsm-'=>'tsm-','tsm3'=>'tsm3','tsm5'=>'tsm5','tx-9'=>'tx-9','tagt'=>'tagt','talk'=>'talk','teli'=>'teli','topl'=>'topl','hiba'=>'hiba','up.b'=>'up.b','upg1'=>'upg1','utst'=>'utst','v400'=>'v400','v750'=>'v750','veri'=>'veri','vk-v'=>'vk-v','vk40'=>'vk40','vk50'=>'vk50','vk52'=>'vk52','vk53'=>'vk53','vm40'=>'vm40','vx98'=>'vx98','virg'=>'virg','vite'=>'vite','voda'=>'voda','vulc'=>'vulc','w3c '=>'w3c ','w3c-'=>'w3c-','wapj'=>'wapj','wapp'=>'wapp','wapu'=>'wapu','wapm'=>'wapm','wig '=>'wig ','wapi'=>'wapi','wapr'=>'wapr','wapv'=>'wapv','wapy'=>'wapy','wapa'=>'wapa','waps'=>'waps','wapt'=>'wapt','winc'=>'winc','winw'=>'winw','wonu'=>'wonu','x700'=>'x700','xda2'=>'xda2','xdag'=>'xdag','yas-'=>'yas-','your'=>'your','zte-'=>'zte-','zeto'=>'zeto','acs-'=>'acs-','alav'=>'alav','alca'=>'alca','amoi'=>'amoi','aste'=>'aste','audi'=>'audi','avan'=>'avan','benq'=>'benq','bird'=>'bird','blac'=>'blac','blaz'=>'blaz','brew'=>'brew','brvw'=>'brvw','bumb'=>'bumb','ccwa'=>'ccwa','cell'=>'cell','cldc'=>'cldc','cmd-'=>'cmd-','dang'=>'dang','doco'=>'doco','eml2'=>'eml2','eric'=>'eric','fetc'=>'fetc','hipt'=>'hipt','http'=>'http','ibro'=>'ibro','idea'=>'idea','ikom'=>'ikom','inno'=>'inno','ipaq'=>'ipaq','jbro'=>'jbro','jemu'=>'jemu','java'=>'java','jigs'=>'jigs','kddi'=>'kddi','keji'=>'keji','kyoc'=>'kyoc','kyok'=>'kyok','leno'=>'leno','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-g'=>'lg-g','lge-'=>'lge-','libw'=>'libw','m-cr'=>'m-cr','maui'=>'maui','maxo'=>'maxo','midp'=>'midp','mits'=>'mits','mmef'=>'mmef','mobi'=>'mobi','mot-'=>'mot-','moto'=>'moto','mwbp'=>'mwbp','mywa'=>'mywa','nec-'=>'nec-','newt'=>'newt','nok6'=>'nok6','noki'=>'noki','o2im'=>'o2im','opwv'=>'opwv','palm'=>'palm','pana'=>'pana','pant'=>'pant','pdxg'=>'pdxg','phil'=>'phil','play'=>'play','pluc'=>'pluc','port'=>'port','prox'=>'prox','qtek'=>'qtek','qwap'=>'qwap','rozo'=>'rozo','sage'=>'sage','sama'=>'sama','sams'=>'sams','sany'=>'sany','sch-'=>'sch-','sec-'=>'sec-','send'=>'send','seri'=>'seri','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','siem'=>'siem','smal'=>'smal','smar'=>'smar','sony'=>'sony','sph-'=>'sph-','symb'=>'symb','t-mo'=>'t-mo','teli'=>'teli','tim-'=>'tim-','tosh'=>'tosh','treo'=>'treo','tsm-'=>'tsm-','upg1'=>'upg1','upsi'=>'upsi','vk-v'=>'vk-v','voda'=>'voda','vx52'=>'vx52','vx53'=>'vx53','vx60'=>'vx60','vx61'=>'vx61','vx70'=>'vx70','vx80'=>'vx80','vx81'=>'vx81','vx83'=>'vx83','vx85'=>'vx85','wap-'=>'wap-','wapa'=>'wapa','wapi'=>'wapi','wapp'=>'wapp','wapr'=>'wapr','webc'=>'webc','whit'=>'whit','winw'=>'winw','wmlb'=>'wmlb','xda-'=>'xda-',)));
+ $mobile_device = 'MOBILE';
+ $mobile = true;
+ break;
+ default;
+ $mobile_device = 'Desktop';
+ $mobile = false;
+ break;
+ }
+
+ // Write to sessions table
+ $sql_ary = array(
+ 'football_mobile' => $mobile,
+ 'football_mobile_device' => $db->sql_escape($mobile_device),
+ );
+ $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
+ WHERE session_id = '" . $db->sql_escape($this->user->session_id) . "'";
+ $db->sql_query($sql);
+ $this->user->data['football_mobile'] = $mobile;
+ $this->user->data['football_mobile_device'] = $mobile_device;
+ }
+
+ /**
+ * Check if user should be able to access football prediction league
+ *
+ * @return bool True of user should be able to access it, false if not
+ */
+ protected function has_football_access()
+ {
+ // Can this user view Prediction Leagues pages?
+ if (!$this->config['football_guest_view'])
+ {
+ if ($this->user->data['user_id'] == ANONYMOUS)
+ {
+ return false;
+ }
+ }
+ if (!$this->config['football_user_view'])
+ {
+ return $this->auth->acl_get('u_use_football') && ! $this->config['football_disable'];
+ }
+ return ! $this->config['football_disable'];
+ }
+
+ public function add_permission_cat($event)
+ {
+ $perm_cat = $event['categories'];
+ $perm_cat['football'] = 'ACP_FOOTBALL';
+ $event['categories'] = $perm_cat;
+
+ $permission = $event['permissions'];
+ $permission['u_use_football'] = array('lang' => 'ACL_U_USE_FOOTBALL', 'cat' => 'football');
+ $permission['a_football_config'] = array('lang' => 'ACL_A_FOOTBALL_CONFIG', 'cat' => 'football');
+ $permission['a_football_delete'] = array('lang' => 'ACL_A_FOOTBALL_DELETE', 'cat' => 'football');
+ $permission['a_football_editbets'] = array('lang' => 'ACL_A_FOOTBALL_EDITBETS', 'cat' => 'football');
+ $permission['a_football_plan'] = array('lang' => 'ACL_A_FOOTBALL_PLAN', 'cat' => 'football');
+ $permission['a_football_results'] = array('lang' => 'ACL_A_FOOTBALL_RESULTS', 'cat' => 'football');
+ $permission['a_football_points'] = array('lang' => 'ACL_A_FOOTBALL_POINTS', 'cat' => 'football');
+ $event['permissions'] = $permission;
+ }
+}
diff --git a/includes/functions.php b/includes/functions.php
index a75e593..7bbf52c 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -1,2531 +1,2532 @@
- 0
- $where_status";
- $result = $db->sql_query($sql);
-
- $result_ary = array();
- $extra_points_error = true;
- while($row = $db->sql_fetchrow($result))
- {
- $extra_no = $row['extra_no'];
- if ($row['result'] <> '')
- {
- switch($row['question_type'])
- {
- case '2':
- case '4':
- // multiple results
- {
- $bet_points = 'CASE bet ';
- $result_ary = explode(';', $row['result']);
- foreach($result_ary AS $result_value)
- {
- if ($result_value <> '')
- {
- $result_value = (is_numeric($result_value)) ? $result_value : "'" . $result_value . "'";
- $bet_points .= ' WHEN ' . $result_value . ' THEN ' . $row['extra_points'] . ' ';
- $extra_points_error = false;
- }
- }
- $bet_points .= ' ELSE 0 END';
- }
- break;
- case '5':
- // difference to result
- {
- if (is_numeric($row['result']))
- {
- $bet_points = 'IF(' . $row['extra_points'] . '- ABS(bet - ' . $row['result'] . ') > 0, ' . $row['extra_points'] . '- ABS(bet - ' . $row['result'] . ')' . ', 0)';
- $extra_points_error = false;
- }
- else
- {
- $extra_points_error = true;
- }
- }
- break;
- default:
- // Case 1 and 3 and other
- // correct result
- {
- $result_value = (is_numeric($row['result'])) ? $row['result'] : "'" . $row['result'] . "'";
- $bet_points = 'CASE bet WHEN ' . $result_value . ' THEN ' . $row['extra_points'] . ' ELSE 0 END';
- $extra_points_error = false;
- }
- break;
- }
- if (!$extra_points_error)
- {
- $sql = 'UPDATE ' . FOOTB_EXTRA_BETS . '
- SET bet_points = ' . $bet_points . "
- WHERE season = $season
- AND league = $league
- AND extra_no = $extra_no";
- $db->sql_query($sql);
- }
- }
- }
- $db->sql_freeresult($result);
-}
-
-
-/**
-* Save matchday-ranking in database (table FOOTB_RANKS).
-*/
-function save_ranking_matchday($season, $league, $matchday, $cash = false)
-{
- global $db, $config, $lang, $league_info;
- $sql = 'SELECT * FROM ' . FOOTB_MATCHDAYS . " WHERE season = $season AND league = $league AND matchday = $matchday";
- $result = $db->sql_query($sql);
-
- if ( $row = $db->sql_fetchrow($result))
- {
- $matchday_status = $row['status'];
- if ($row['delivery_date_2'] != '' OR ($league_info['bet_in_time'] AND $matchday_status <> 3))
- // We set status to 2 to skip deleting the ranking
- $matchday_status = 2;
- $db->sql_freeresult($result);
- if ($matchday_status < 2)
- {
- $sql = 'SELECT * FROM ' . FOOTB_MATCHES . " WHERE season = $season AND league = $league AND matchday = $matchday AND status IN (2,3)";
- $result = $db->sql_query($sql);
- if ( $row = $db->sql_fetchrow($result))
- {
- $matchday_status = 2;
- }
- }
-
- if ($matchday_status == 0 OR $matchday_status == 1)
- {
- // No matches played, so we can delete the ranking
- $sql = 'DELETE FROM ' . FOOTB_RANKS . " WHERE season = $season AND league = $league AND matchday = $matchday";
- $result = $db->sql_query($sql);
- }
- else
- {
- $matchday_wins = array();
- $matchday_wins = matchday_wins($season, $league);
- $sql = "
- SELECT
- 1 AS rank,
- 0.00 AS win,
- u.user_id,
- u.username AS username,
- SUM(IF(m.match_no > 0, 1, 0)) AS matches,
- SUM(IF(b.goals_home = '' OR b.goals_guest = '', 1, 0)) AS nobet,
- SUM(IF(b.goals_home <> '' AND b.goals_guest <> '',
- IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest)
- , 1
- , 0
- )
- , 0
- )
- ) AS direct_hit,
- SUM(IF(b.goals_home <> '' AND b.goals_guest <> '',
- IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
- OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
- OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest)
- , 0
- , 1
- )
- , 0
- )
- ) AS tendency,
- " . select_points('m',true) . '
- FROM ' . FOOTB_MATCHES . ' AS m
- INNER JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
- INNER JOIN ' . USERS_TABLE . " AS u ON (b.user_id = u.user_id)
- WHERE m.season = $season AND m.league = $league AND m.matchday = $matchday AND m.status IN (2,3)
- GROUP BY b.user_id
- ORDER BY points DESC, nobet ASC, username ASC
- ";
-
- $result = $db->sql_query($sql);
-
- $ranking_ary = array();
- while( $row = $db->sql_fetchrow($result))
- {
- $ranking_ary[$row['user_id']] = $row;
- }
- $db->sql_freeresult($result);
- if ( sizeof($ranking_ary) > 0 )
- {
- $sql = '
- SELECT
- eb.user_id,
- SUM(eb.bet_points) AS points
- FROM ' . FOOTB_EXTRA . ' AS e
- INNER JOIN ' . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = e.season and eb.league = e.league and eb.extra_no = e.extra_no)
- WHERE e.season = $season
- AND e.league = $league
- AND e.matchday = $matchday
- AND e.matchday_eval = $matchday
- AND e.extra_status > 1
- GROUP BY eb.user_id";
-
- $result = $db->sql_query($sql);
- while( $row = $db->sql_fetchrow($result))
- {
- $ranking_ary[$row['user_id']]['points'] += $row['points'];
- }
- $db->sql_freeresult($result);
-
- // sort the ranking by points
- usort($ranking_ary, '_sort_points');
- }
-
- $last_points = -1;
- $last_rank = 1;
- $equal_rank = array();
- $money = array();
- $i = 0;
- foreach( $ranking_ary AS $curr_user => $curr_rank)
- {
- if ($curr_rank['nobet'] == $curr_rank['matches'] and $league_info['points_last'] == 1)
- {
- if ($last_points <> -1)
- {
- $ranking_ary[$curr_user]['points'] = $last_points;
- }
- else
- {
- $ranking_ary[$curr_user]['points'] = 0;
- $last_points = 0;
- $equal_rank[$last_rank] = 0;
- }
- }
- if ( $ranking_ary[$curr_user]['points'] != $last_points)
- {
- $ranking_ary[$curr_user]['rank'] = $i + 1;
- $last_rank = $i + 1;
- $equal_rank[$last_rank] = 1;
- if ($last_rank < sizeof($matchday_wins))
- {
- $money[$last_rank] = $matchday_wins[$last_rank];
- }
- else
- {
- $money[$last_rank] = 0;
- }
- $last_points = $ranking_ary[$curr_user]['points'];
- }
- else
- {
- $ranking_ary[$curr_user]['rank'] = $last_rank;
- $equal_rank[$last_rank] += 1;
- if ($i + 1 < sizeof($matchday_wins))
- {
- $money[$last_rank] += $matchday_wins[$i + 1];
- }
- }
- $i++;
- }
- foreach( $ranking_ary AS $curr_user => $curr_rank)
- {
- if ( round($money[$curr_rank['rank']] / $equal_rank[$curr_rank['rank']], 2) <> 0 )
- {
- $win = round($money[$curr_rank['rank']] / $equal_rank[$curr_rank['rank']], 2);
- $ranking_ary[$curr_user]['win'] = $win;
- }
- else
- {
- $win = 0;
- $ranking_ary[$curr_user]['win'] = 0;
- }
- $sql = 'REPLACE INTO ' . FOOTB_RANKS . "
- VALUES ($season
- , $league
- , $matchday
- , " . $curr_rank['user_id'] . "
- , $matchday_status
- , " . $curr_rank['rank'] . "
- , " . $curr_rank['points'] . "
- , $win
- , 0
- , " . $curr_rank['tendency'] . "
- , " . $curr_rank['direct_hit'] . "
- ,0
- ,0
- )";
- $result = $db->sql_query($sql);
- }
- if ( sizeof($ranking_ary) == 0 )
- {
- $sql = 'DELETE FROM ' . FOOTB_RANKS . "
- WHERE season = $season
- AND league = $league
- AND matchday = $matchday";
- $result = $db->sql_query($sql);
- }
- else
- {
- // Calculate total ranking
- $rank_total_ary = array();
- $sql = 'SELECT
- user_id ,
- SUM(points) AS points,
- SUM(win) AS wins_total
- FROM ' . FOOTB_RANKS . "
- WHERE season = $season
- AND league = $league
- AND matchday <= $matchday
- GROUP by user_id
- ORDER BY points DESC, user_id ASC";
- $result = $db->sql_query($sql);
- while( $row = $db->sql_fetchrow($result))
- {
- $rank_total_ary[$row['user_id']] = $row;
- }
- $db->sql_freeresult($result);
-
- // add extra tipp points total ranking
- $league_info = league_info($season, $league);
- if ( sizeof($rank_total_ary) > 0 )
- {
- if ( $matchday == $league_info['matchdays'])
- {
- $win_user_most_hits = win_user_most_hits($season, $league, $matchday);
- $win_user_most_hits_away = win_user_most_hits_away($season, $league, $matchday);
- $season_wins = season_wins($season, $league, $matchday);
- }
- $sql = 'SELECT
- eb.user_id,
- SUM(eb.bet_points) AS points
- FROM ' . FOOTB_EXTRA . ' AS e
- INNER JOIN ' . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = e.season and eb.league = e.league and eb.extra_no = e.extra_no)
- WHERE e.season = $season
- AND e.league = $league
- AND e.matchday <> e.matchday_eval
- AND e.matchday_eval <= $matchday
- AND e.extra_status > 1
- GROUP BY eb.user_id";
-
- $result = $db->sql_query($sql);
- while( $row = $db->sql_fetchrow($result))
- {
- $rank_total_ary[$row['user_id']]['points'] += $row['points'];
- }
- $db->sql_freeresult($result);
-
- // sort the ranking by points
- usort($rank_total_ary, '_sort_points');
- }
-
- $index = 0;
- $last_rank = 0;
- $last_points = -1;
- foreach( $rank_total_ary AS $curr_user => $curr_rank)
- {
- $index++;
- if ( $curr_rank['points'] == $last_points)
- {
- $rank_total = $last_rank;
- }
- else
- {
- $rank_total = $index;
- $last_points = $curr_rank['points'];
- $last_rank = $rank_total;
- }
- if ($matchday == $league_info['matchdays'])
- {
- // if someone didn't bet the hole Season
- if (!isset($win_user_most_hits[$curr_rank['user_id']]['win']))
- {
- $win_user_most_hits[$curr_rank['user_id']]['win'] = 0;
- }
- if (!isset($win_user_most_hits_away[$curr_rank['user_id']]['win']))
- {
- $win_user_most_hits_away[$curr_rank['user_id']]['win'] = 0;
- }
- if (!isset($season_wins[$curr_rank['user_id']]['win']))
- {
- $season_wins[$curr_rank['user_id']]['win'] = 0;
- }
- $rank_total_ary[$curr_user]['wins_total'] = sprintf('%01.2f',$curr_rank['wins_total'] + $win_user_most_hits[$curr_rank['user_id']]['win'] + $win_user_most_hits_away[$curr_rank['user_id']]['win'] + $season_wins[$curr_rank['user_id']]['win']);
- }
- else
- {
- $rank_total_ary[$curr_user]['wins_total'] = sprintf('%01.2f',$curr_rank['wins_total']);
- }
- $curr_userid = $curr_rank['user_id'];
- $points_total = $curr_rank['points'];
- $win_total = $rank_total_ary[$curr_user]['wins_total'];
- $sql = 'UPDATE ' . FOOTB_RANKS . "
- SET rank_total = $rank_total,
- points_total = $points_total,
- win_total = $win_total
- WHERE season = $season AND league = $league AND matchday = $matchday AND user_id = $curr_userid";
- $result = $db->sql_query($sql);
- }
- }
- }
- if ($config['football_bank'])
- {
- if ($matchday_status < 3)
- {
- //Delete points
- if ($matchday == $league_info['matchdays'])
- {
- // On last matchday
- rollback_points(POINTS_MOST_HITS, $season, $league, $matchday, $cash && ($config['football_ult_points'] == 1));
- rollback_points(POINTS_MOST_HITS_AWAY, $season, $league, $matchday, $cash && ($config['football_ult_points'] == 1));
- rollback_points(POINTS_SEASON, $season, $league, $matchday, $cash && ($config['football_ult_points'] == 1));
- }
- rollback_points(POINTS_MATCHDAY, $season, $league, $matchday, $cash && ($config['football_ult_points'] > 0));
- }
- else
- {
- //Set points on played matchday
- if ($matchday == $league_info['matchdays'] AND $config['football_bank'])
- {
- // On last matchday
- set_points_most_hits($season, $league, $matchday, $win_user_most_hits, $cash && ($config['football_ult_points'] == 1));
- set_points_most_hits_away($season, $league, $matchday, $win_user_most_hits_away, $cash && ($config['football_ult_points'] == 1));
- set_points_season($season, $league, $matchday, $season_wins, $cash && ($config['football_ult_points'] == 1));
- }
- set_points_matchday($season, $league, $matchday, $ranking_ary, $cash && ($config['football_ult_points'] > 0));
- }
- }
- $sql = 'SELECT matchday FROM ' . FOOTB_RANKS . "
- WHERE season = $season
- AND league = $league
- AND matchday > $matchday";
- $result = $db->sql_query($sql);
- if ( $next_matchday = (int) $db->sql_fetchfield('matchday'))
- {
- $db->sql_freeresult($result);
- save_ranking_matchday($season, $league, $next_matchday, $cash);
- }
- }
-}
-
-function set_points_most_hits($season, $league, $matchday, $win_user_most_hits, $cash)
-{
- rollback_points(POINTS_MOST_HITS, $season, $league, $matchday, $cash);
- set_footb_points(POINTS_MOST_HITS, $season, $league, $matchday, $win_user_most_hits, $cash);
-}
-
-function set_points_most_hits_away($season, $league, $matchday, $win_user_most_hits_away, $cash)
-{
- rollback_points(POINTS_MOST_HITS_AWAY, $season, $league, $matchday, $cash);
- set_footb_points(POINTS_MOST_HITS_AWAY, $season, $league, $matchday, $win_user_most_hits_away, $cash);
-}
-
-function set_points_season($season, $league, $matchday, $season_wins, $cash)
-{
- rollback_points(POINTS_SEASON, $season, $league, $matchday, $cash);
- set_footb_points(POINTS_SEASON, $season, $league, $matchday, $season_wins, $cash);
-}
-
-function set_points_matchday($season, $league, $matchday, $ranking_ary, $cash)
-{
- rollback_points(POINTS_MATCHDAY, $season, $league, $matchday, $cash);
- set_footb_points(POINTS_MATCHDAY, $season, $league, $matchday, $ranking_ary, $cash);
-}
-
-function rollback_points($points_type, $season, $league, $matchday, $cash)
-{
- global $db, $functions_points;
- if ($cash)
- {
- $where_matchday = ($matchday) ? " AND matchday = $matchday" : '';
- $sql = 'SELECT *
- FROM ' . FOOTB_POINTS . " AS p
- WHERE season = $season
- AND league = $league
- $where_matchday
- AND points_type = $points_type
- AND cash = 1";
-
- $result = $db->sql_query($sql);
- while( $row = $db->sql_fetchrow($result))
- {
- $functions_points->substract_points($row['user_id'], $row['points']);
- }
- $db->sql_freeresult($result);
-
- }
- $sql = 'DELETE FROM ' . FOOTB_POINTS . " WHERE season = $season AND league = $league AND matchday = $matchday AND points_type = $points_type";
- $result = $db->sql_query($sql);
-}
-
-function set_footb_points($points_type, $season, $league, $matchday, $wins, $cash)
-{
- global $db, $user, $config, $functions_points;
- switch($points_type)
- {
- case 1:
- $points_comment = sprintf($user->lang['BET_POINTS']);
- break;
- case 2:
- $points_comment = sprintf($user->lang['DEPOSIT']);
- break;
- case 3:
- $points_comment = '';
- break;
- case 4:
- $points_comment = '';
- break;
- case 5:
- $points_comment = sprintf($user->lang['WIN_HITS']);
- break;
- case 6:
- $points_comment = sprintf($user->lang['WIN_HITS02']);
- break;
- case 7:
- $points_comment = sprintf($user->lang['PAYOUT_WIN']);
- break;
- }
-
- foreach( $wins AS $curr_user => $curr_ary)
- {
- if ($config['football_ult_points'] == 2 AND $points_type == 3)
- {
- // points mode
-
- if ($curr_ary['points'] > 0 AND $curr_ary['points'] <> NULL)
- {
- $userid = (!isset($curr_ary['user_id'])) ? $curr_user : $curr_ary['user_id'];
- $points_comment = sprintf($user->lang['POINTS']);
- $factor_points = round($config['football_ult_points_factor'] * $curr_ary['points'],2);
- if ($cash)
- {
- $functions_points->add_points($userid, $factor_points);
- }
- $sql_ary = array(
- 'season' => (int) $season,
- 'league' => (int) $league,
- 'matchday' => (int) $matchday,
- 'points_type' => (int) $points_type,
- 'user_id' => (int) $userid,
- 'points' => $factor_points,
- 'points_comment'=> $points_comment,
- 'cash' => $cash,
- );
- $sql = 'INSERT INTO ' . FOOTB_POINTS . ' ' . $db->sql_build_array('INSERT', $sql_ary);
- $db->sql_query($sql);
- }
- }
- if ($config['football_ult_points'] <= 1 OR ($config['football_ult_points'] == 2 AND $points_type == 1))
- {
- if ($curr_ary['win'] > 0)
- {
- switch($points_type)
- {
- case 3:
- $points_comment = sprintf($user->lang['WIN_MATCHDAY']) . ' ' . $curr_ary['rank'] . '.' . sprintf($user->lang['PLACE']);
- break;
- case 4:
- $points_comment = sprintf($user->lang['WIN_SEASON']) . ' ' . $curr_ary['rank'] . '.' . sprintf($user->lang['PLACE']);
- break;
- }
- $userid = (!isset($curr_ary['user_id'])) ? $curr_user : $curr_ary['user_id'];
- if ($cash)
- {
- if ($points_type == 1 OR $points_type == 7)
- {
- // substract bets and payouts
- $functions_points->substract_points($userid, round($curr_ary['win'],2));
- }
- else
- {
- $functions_points->add_points($userid, round($curr_ary['win'],2));
- }
- }
- $sql_ary = array(
- 'season' => (int) $season,
- 'league' => (int) $league,
- 'matchday' => (int) $matchday,
- 'points_type' => (int) $points_type,
- 'user_id' => (int) $userid,
- 'points' => round($curr_ary['win'],2),
- 'points_comment'=> $points_comment,
- 'cash' => $cash,
- );
- $sql = 'INSERT INTO ' . FOOTB_POINTS . ' ' . $db->sql_build_array('INSERT', $sql_ary);
- $db->sql_query($sql);
- }
- }
- }
-}
-
-function _sort_points($value_a, $value_b)
-{
- if ($value_a['points'] > $value_b['points'])
- {
- return -1;
- }
- else
- {
- if ($value_a['points'] == $value_b['points'])
- {
- if (isset($value_a['nobet']))
- {
- if ($value_a['nobet'] < $value_b['nobet'])
- {
- return -1;
- }
- else
- {
- if ($value_a['nobet'] == $value_b['nobet'])
- {
- return 0;
- }
- else
- {
- return 1;
- }
- }
- }
- else
- {
- return 0;
- }
- }
- else
- {
- return 1;
- }
- }
-}
-
-
-/**
-* Return season-array
-*/
-function season_info($season)
-{
- global $db;
- $sql = 'SELECT * FROM ' . FOOTB_SEASONS . " WHERE season = $season";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- return $row;
- }
- else
- {
- return array();
- }
- $db->sql_freeresult($result);
-}
-
-/**
-* Return league-array
-*/
-function league_info($season, $league)
-{
- global $db;
- $sql = 'SELECT * FROM ' . FOOTB_LEAGUES . "
- WHERE season = $season AND league = $league
- ";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- return $row;
- }
- else
- {
- return array();
- }
- $db->sql_freeresult($result);
-}
-
-/**
-* Return team-array
-*/
-function team_info($season, $league, $team_id)
-{
- global $db;
- $sql = 'SELECT * FROM ' . FOOTB_TEAMS . "
- WHERE season = $season AND league = $league AND team_id = $team_id
- ";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- return $row;
- }
- else
- {
- return array();
- }
- $db->sql_freeresult($result);
-}
-
-/**
-* Is user member of this league
-*/
-function user_is_member($userid, $season, $league)
-{
- global $db;
- $sql = 'SELECT COUNT(*) AS counter
- FROM ' . FOOTB_BETS . "
- WHERE season = $season AND league = $league AND user_id = $userid";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
-
- if ($row['counter'] > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- $db->sql_freeresult($result);
-}
-
-/**
-* Count existing matches on matchday or league
-*/
-function count_existing_matches($season, $league, $matchday)
-{
- global $db;
- $where_matchday = ($matchday) ? " AND matchday = $matchday" : '';
- $sql = 'SELECT COUNT(*) AS counter
- FROM ' . FOOTB_MATCHES . "
- WHERE season = $season AND league = $league $where_matchday";
- $result = $db->sql_query($sql);
- if ($row = $db->sql_fetchrow($result))
- {
- return $row['counter'];
- $db->sql_freeresult($result);
- }
- else
- {
- return 0;
- }
-}
-
-/**
-* Determinate if join to league is allowed
-*/
-function join_allowed($season, $league)
-{
- global $db;
- $league_info = league_info($season, $league);
- if (! $league_info['join_by_user'])
- {
- return false;
- }
- else
- {
- if ($league_info['join_in_season'])
- {
- return true;
- }
- else
- {
- $sql = 'SELECT * FROM ' . FOOTB_MATCHDAYS . "
- WHERE season = $season AND league = $league AND matchday = 1 AND status = 0
- ";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $db->sql_freeresult($result);
- return true;
- }
- else
- {
- return false;
- }
- }
- }
-}
-
-/**
-* Calculate status or delivery of matchday
-*/
-function delivery($season, $league, $matchday)
-{
- global $db, $user;
- $delivery = '';
- $lang_dates = $user->lang['datetime'];
- $sql = "SELECT *,
- CONCAT(
- CASE DATE_FORMAT(delivery_date,'%w')
- WHEN 0 THEN '" . $lang_dates['Sun'] . "'
- WHEN 1 THEN '" . $lang_dates['Mon'] . "'
- WHEN 2 THEN '" . $lang_dates['Tue'] . "'
- WHEN 3 THEN '" . $lang_dates['Wed'] . "'
- WHEN 4 THEN '" . $lang_dates['Thu'] . "'
- WHEN 5 THEN '" . $lang_dates['Fri'] . "'
- WHEN 6 THEN '" . $lang_dates['Sat'] . "'
- ELSE 'Error' END,
- DATE_FORMAT(delivery_date,' %d.%m.%Y %H:%i')
- ) AS deliverytime
- FROM " . FOOTB_MATCHDAYS . "
- WHERE season = $season AND league = $league AND matchday = $matchday";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- switch($row['status'])
- {
- case 0:
- $delivery = '' . sprintf($user->lang['STATUS_TEXT0']) . $row['deliverytime'] . '';
- break;
- case 1:
- $delivery = '' . sprintf($user->lang['STATUS_TEXT1']) . '';
- break;
- case 2:
- $delivery = '' . sprintf($user->lang['STATUS_TEXT2']) . '';
- break;
- case 3:
- $delivery = '' . sprintf($user->lang['STATUS_TEXT3']) . '';
- break;
- }
- $db->sql_freeresult($result);
- }
- return $delivery;
-}
-
-/**
-* Calculate next delivery und return delivery string
-*/
-function next_delivery($season, $league)
-{
- global $db, $user;
- $next_delivery = '';
- $lang_dates = $user->lang['datetime'];
- $sql = "SELECT
- CONCAT(
- CASE DATE_FORMAT(delivery_date,'%w')
- WHEN 0 THEN '" . $lang_dates['Sun'] . "'
- WHEN 1 THEN '" . $lang_dates['Mon'] . "'
- WHEN 2 THEN '" . $lang_dates['Tue'] . "'
- WHEN 3 THEN '" . $lang_dates['Wed'] . "'
- WHEN 4 THEN '" . $lang_dates['Thu'] . "'
- WHEN 5 THEN '" . $lang_dates['Fri'] . "'
- WHEN 6 THEN '" . $lang_dates['Sat'] . "'
- ELSE 'Error' END,
- DATE_FORMAT(delivery_date,' %d.%m.%Y %H:%i')
- ) AS deliverytime
- FROM " . FOOTB_MATCHDAYS . "
- WHERE season = $season AND league = $league AND status = 0
- ORDER BY matchday ASC
- ";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $next_delivery = "". sprintf($user->lang['NEXT_DELIVERY_UNTIL']) . ' ' . $row['deliverytime'] . "";
- $db->sql_freeresult($result);
- }
- return $next_delivery;
-}
-
-/**
-* Calculate first delivery of matchday for bet in time
-*/
-function first_delivery($season, $league, $matchday)
-{
- global $db, $user;
- $sql = "SELECT MIN(match_datetime) AS min_match_datetime
- FROM " . FOOTB_MATCHES . "
- WHERE season = $season AND league = $league AND matchday = $matchday AND status = 0
- ORDER BY min_match_datetime ASC
- ";
- $result = $db->sql_query($sql);
- $first_delivery = '';
- if ($row = $db->sql_fetchrow($result))
- {
- $first_delivery = $row['min_match_datetime'];
- $db->sql_freeresult($result);
- }
- return $first_delivery;
-}
-
-/**
-* Set matchday delivery to first open match
-*/
-function set_bet_in_time_delivery($season, $league)
-{
- global $db, $user, $config;
- $sql = "SELECT *
- FROM " . FOOTB_MATCHDAYS . "
- WHERE season = $season AND league = $league AND status < 3
- ";
- $result = $db->sql_query($sql);
- $first_delivery = '';
- while ($row = $db->sql_fetchrow($result))
- {
- $new_status = $row['status'];
-
- // match-status maybe changed
- $sql_ary = array(
- 'status' => 0,
- 'goals_home' => '',
- 'goals_guest' => '',
- 'goals_overtime_home' => '',
- 'goals_overtime_guest' => '',
- );
- $local_board_time = time() + (($config['board_timezone'] - $config['football_host_timezone']) * 3600);
- $sql = 'UPDATE ' . FOOTB_MATCHES . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE season = $season AND league = $league AND matchday =" . $row['matchday'] . " AND match_datetime > FROM_UNIXTIME('$local_board_time')";
- $db->sql_query($sql);
-
- if ($db->sql_affectedrows())
- {
- // an open match exist, so set status 0
- $new_status = 0;
- }
- $first_delivery = first_delivery($season, $league, $row['matchday']);
- if ( $first_delivery <> '')
- {
- // Matchday has open matches so set matchday status = 0 and first delivery
- $sql_ary = array(
- 'status' => $new_status,
- 'delivery_date' => $first_delivery,
- 'delivery_date_2' => '',
- 'delivery_date_3' => '',
- );
- $sql = 'UPDATE ' . FOOTB_MATCHDAYS . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE season = $season AND league = $league AND matchday =" . $row['matchday'];
- $db->sql_query($sql);
- }
- }
- $db->sql_freeresult($result);
-}
-
-
-/**
-* return current season. The minimal seasons value with a open matchday (status = 0).
-*/
-function curr_season()
-{
- global $db, $lang, $user;
- $user_spec = '';
- if ($user->data['user_type']==0 OR $user->data['user_type']==3)
- {
- $curr_user = $user->data['user_id'];
- $user_spec = 'AND b.user_id = ' . $curr_user;
- }
-
- $sql = 'SELECT DISTINCT s.season
- FROM ' . FOOTB_SEASONS . ' AS s
- INNER JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = s.season)
- INNER JOIN ' . FOOTB_MATCHDAYS . ' AS m ON (m.season = s.season AND m.league = l.league)
- INNER JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league ' . $user_spec . ')
- WHERE m.status IN (0,1,2)
- ORDER BY s.season ASC';
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $curr_season = $row['season'];
- $db->sql_freeresult($result);
- }
- else
- {
- $sql = 'SELECT DISTINCT s.season FROM ' . FOOTB_SEASONS . ' AS s
- INNER JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = s.season)
- INNER JOIN ' . FOOTB_MATCHDAYS . ' AS m ON (m.season = s.season AND m.league = l.league)
- WHERE 1
- ORDER BY s.season DESC';
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $curr_season = $row['season'];
- }
- else
- {
- $sql = 'SELECT * FROM ' . FOOTB_SEASONS;
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $curr_season = $row['season'];
- }
- else
- {
- $curr_season = 0;
- }
- }
- $db->sql_freeresult($result);
- }
- return $curr_season;
-}
-
-/**
-* return first (minmal) league of season
-*/
-function first_league($season, $complete = true)
-{
- global $db, $lang;
- $join_matchday = '';
- if ($complete)
- {
- $join_matchday = 'INNER JOIN ' . FOOTB_MATCHDAYS . ' AS m ON (m.season = l.season AND m.league = l.league) ';
- }
- $sql = 'SELECT *
- FROM ' . FOOTB_LEAGUES . ' AS l ' .
- $join_matchday . "
- WHERE l.season = $season
- ORDER BY l.league ASC";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $first_league = $row['league'];
- }
- else
- {
- $first_league = 0;
- }
- $db->sql_freeresult($result);
- return $first_league;
-}
-
-/**
-* return current (wait for results) league of season
-*/
-function current_league($season)
-{
- global $db, $lang, $user;
- $user_spec = '';
- if ($user->data['user_type']==0 OR $user->data['user_type']==3)
- {
- $curr_user = $user->data['user_id'];
- $user_spec = 'AND b.user_id = ' . $curr_user;
- }
- $sql = 'SELECT m.league
- FROM ' . FOOTB_MATCHES . ' AS m
- INNER JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league ' . $user_spec . ")
- WHERE m.season = $season
- AND m.status in (0,1,2)
- ORDER BY m.match_datetime ASC";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $current_league = $row['league'];
- }
- else
- {
- $current_league = first_league($season);
- }
- $db->sql_freeresult($result);
- return $current_league;
-}
-
-/**
-* return next free team-id
-*/
-function nextfree_teamid()
-{
- global $db, $lang;
- $sql = 'SELECT Max(team_id) AS lastid FROM ' . FOOTB_TEAMS;
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- return ($row['lastid'] + 1);
- }
- else
- {
- return 0;
- }
- $db->sql_freeresult($result);
-}
-
-/**
-* return current (in order to play) matchday of league
-*/
-function curr_matchday($season, $league)
-{
- global $db, $lang;
- $sql = 'SELECT * FROM ' . FOOTB_MATCHDAYS . "
- WHERE season = $season AND league = $league AND status < 3
- ORDER BY status DESC, delivery_date ASC
- ";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $curr_matchday = $row['matchday'];
- $db->sql_freeresult($result);
- }
- else
- {
- $sql = 'SELECT * FROM ' . FOOTB_MATCHDAYS . "
- WHERE season = $season AND league = $league AND status = 3
- ORDER BY matchday DESC
- ";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $curr_matchday = $row['matchday'];
- }
- else
- {
- $curr_matchday = 0;
- }
- $db->sql_freeresult($result);
- }
- return $curr_matchday;
-}
-
-
-/**
-* Initialize user bets. Adds s user to a league.
-*/
-function join_league($season, $league, $user_id)
-{
- global $db, $lang;
-
- $league_info = league_info($season, $league);
- $matchdays = $league_info['matchdays'];
- if ($league_info['league_type'] == LEAGUE_CHAMP)
- {
- $matches_on_matchdays = $league_info['matches_on_matchday'];
- }
- else
- {
- $matches_on_matchdays = 0;
- }
-
- $count_updates = 0;
- $matches = $matches_on_matchdays;
- $match_id = 1;
- for($m_day = 1; $m_day <= $matchdays; $m_day++)
- {
- if ($matches_on_matchdays == 0)
- {
- $sql = 'SELECT matches from ' . FOOTB_MATCHDAYS . " WHERE season = $season AND league = $league AND matchday = $m_day";
- $result = $db->sql_query($sql);
- if( $row = $db->sql_fetchrow($result))
- {
- $matches = $row['matches'];
- $db->sql_freeresult($result);
- }
- else
- {
- // Matchday doesnt exist
- $matches = 0;
- }
- }
- for($i = 1; $i<= $matches; $i++)
- {
- $sqlup = 'REPLACE INTO ' . FOOTB_BETS . " VALUES($season, $league, $match_id, $user_id, '', '', 0)";
- $resultup = $db->sql_query($sqlup);
- $match_id++;
- $count_updates++;
- }
- }
- return $count_updates;
-}
-
-// Close matchday
-/**
-* Close all open matches.
-*/
-function close_open_matchdays()
-{
- global $db, $lang, $config;
-
- $local_board_time = time() + (($config['board_timezone'] - $config['football_host_timezone']) * 3600);
- $sql = 'SELECT * FROM ' . FOOTB_MATCHDAYS . " WHERE status = 0 AND delivery_date < FROM_UNIXTIME('$local_board_time')";
- $result = $db->sql_query($sql);
- $toclose = $db->sql_fetchrowset($result);
- $db->sql_freeresult($result);
- foreach ($toclose as $close)
- {
- // Matchday to close
- $season = $close['season'];
- $league = $close['league'];
- $matchday = $close['matchday'];
- $league_info = league_info($season, $league);
-
- if ($league_info['bet_in_time'] == 1)
- {
- $sql_ary = array(
- 'status' => 1,
- );
- $sql = 'UPDATE ' . FOOTB_MATCHES . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE season = $season AND league = $league AND matchday = $matchday AND status = 0 AND match_datetime < FROM_UNIXTIME('$local_board_time')";
- $db->sql_query($sql);
-
- // Check remaining open matches
- $first_delivery = first_delivery($season, $league, $close['matchday']);
- if ($first_delivery <> '')
- {
- // Matchday has open matches so set matchday status = 0 and first delivery
- $sql_ary = array(
- 'status' => 0,
- 'delivery_date' => first_delivery($season, $league, $close['matchday']),
- );
- $sql = 'UPDATE ' . FOOTB_MATCHDAYS . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE season = $season AND league = $league AND matchday = $matchday";
- $db->sql_query($sql);
- }
- else
- {
- // Matchday has no open match so close the matchday with setting status = 1
- $sql_ary = array(
- 'status' => 1,
- );
- $sql = 'UPDATE ' . FOOTB_MATCHDAYS . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE season = $season AND league = $league AND matchday = $matchday";
- $db->sql_query($sql);
- }
- }
- else
- {
- if ($close['delivery_date_2'] != '')
- {
- // More open matches exists, so shift delivery and status lower Null
- $sql_ary = array(
- 'delivery_date' => $close['delivery_date_2'],
- 'delivery_date_2' => $close['delivery_date_3'],
- 'delivery_date_3' => '',
- );
- $sql = 'UPDATE ' . FOOTB_MATCHDAYS . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
- WHERE season = $season AND league = $league AND matchday = $matchday";
- $db->sql_query($sql);
-
- $sql = 'UPDATE ' . FOOTB_MATCHES . "
- SET status = status + 1
- WHERE season = $season AND league = $league AND matchday = $matchday AND status <= 0";
- $db->sql_query($sql);
- }
- else
- {
- // Close all matches of the matchday and matchday
- $sql = 'UPDATE ' . FOOTB_MATCHDAYS . "
- SET status = 1
- WHERE season = $season AND league = $league AND matchday = $matchday";
- $db->sql_query($sql);
-
- $sql = 'UPDATE ' . FOOTB_MATCHES . "
- SET status = status + 1
- WHERE season = $season AND league = $league AND matchday = $matchday AND status <= 0";
- $db->sql_query($sql);
- }
- }
- // close extra bets
- $sql = 'UPDATE ' . FOOTB_EXTRA . "
- SET extra_status = extra_status + 1
- WHERE season = $season AND league = $league AND matchday = $matchday AND extra_status <= 0";
- $db->sql_query($sql);
- }
-}
-
-/**
-* return matchday wins in array.
-*/
-function matchday_wins($season, $league)
-{
- global $db, $lang;
- $matchday_wins = array();
-
- $sql = 'SELECT * FROM ' . FOOTB_LEAGUES . " WHERE season = $season AND league = $league";
- $result = $db->sql_query($sql);
- if ($row = $db->sql_fetchrow($result))
- {
- $matchday_wins = explode(';',"0;" . $row['win_matchday']);
- $db->sql_freeresult($result);
- }
- return $matchday_wins;
-}
-
-/**
-* return season wins in array.
-*/
-function season_wins($season, $league, $matchday)
-{
- global $db, $lang;
- $season_wins = array();
- $season_user_wins = array();
- $league_info = league_info($season, $league);
- if (sizeof($league_info))
- {
- $season_wins = explode(';',"0;" . $league_info['win_season']);
- $maxmatchday = $league_info['matchdays'];
- }
- else
- {
- $season_user_wins[0]['win'] = 0;
- return $season_user_wins;
- }
-
- $sql = 'SELECT
- 1 AS rank,
- user_id,
- SUM(points) AS points
- FROM ' . FOOTB_RANKS . "
- WHERE season = $season
- AND league = $league
- AND matchday <= $matchday
- AND status IN (2,3)
- GROUP by user_id
- ORDER BY points DESC, user_id ASC
- ";
- $result = $db->sql_query($sql);
- $ranking_ary = array();
- while( $row = $db->sql_fetchrow($result))
- {
- $ranking_ary[$row['user_id']] = $row;
- }
- $db->sql_freeresult($result);
-
- if ( sizeof($ranking_ary) > 0 )
- {
- $sql = 'SELECT
- eb.user_id,
- SUM(eb.bet_points) AS points
- FROM ' . FOOTB_EXTRA . ' AS e
- INNER JOIN ' . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = e.season and eb.league = e.league and eb.extra_no = e.extra_no)
- WHERE e.season = $season
- AND e.league = $league
- AND e.matchday <> e.matchday_eval
- AND e.matchday_eval <= $matchday
- AND e.extra_status > 1
- GROUP BY eb.user_id";
-
- $result = $db->sql_query($sql);
- while( $row = $db->sql_fetchrow($result))
- {
- $ranking_ary[$row['user_id']]['points'] += $row['points'];
- }
- $db->sql_freeresult($result);
- // sort the ranking by points
- usort($ranking_ary, '_sort_points');
-
- $last_points = -1;
- $last_rank = 1;
- $equal_rank = array();
- $money = array();
- $i = 0;
- foreach( $ranking_ary AS $curr_user => $curr_rank)
- {
- if ( $curr_rank['points'] != $last_points)
- {
- $ranking_ary[$curr_user]['rank'] = $i + 1;
- $last_rank = $i + 1;
- $equal_rank[$last_rank] = 1;
- $last_points = $curr_rank['points'];
- if ($last_rank < sizeof($season_wins))
- {
- $money[$last_rank] = $season_wins[$last_rank];
- }
- else
- {
- $money[$last_rank] = 0;
- }
- }
- else
- {
- $ranking_ary[$curr_user]['rank'] = $last_rank;
- $equal_rank[$last_rank] += 1;
- if ($i + 1 < sizeof($season_wins))
- {
- $money[$last_rank] += $season_wins[$i + 1];
- }
- }
- $i++;
- }
- foreach( $ranking_ary AS $curr_rank)
- {
- if ( round($money[$curr_rank['rank']] / $equal_rank[$curr_rank['rank']], 2) <> 0 )
- {
- $season_user_wins[$curr_rank['user_id']]['win'] = round($money[$curr_rank['rank']] / $equal_rank[$curr_rank['rank']], 2);
- }
- else
- {
- $season_user_wins[$curr_rank['user_id']]['win'] = 0;
- }
- $season_user_wins[$curr_rank['user_id']]['rank'] = $curr_rank['rank'];
- }
- return $season_user_wins;
- }
- else
- {
- $season_user_wins[0]['win'] = 0;
- return $season_user_wins;
- }
-}
-
-/**
-* return win most hits in array.
-*/
-function win_user_most_hits($season, $league, $matchday)
-{
- global $db, $lang;
-
- $sql = 'SELECT * FROM ' . FOOTB_LEAGUES . " WHERE season = $season AND league = $league";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $win_most_hits = $row['win_result'];
- $last_matchday = $row['matchdays'];
- $db->sql_freeresult($result);
- }
-
- $sql = 'SELECT
- b.user_id AS userid,
- COUNT(*) AS hits
- FROM ' . FOOTB_MATCHES . ' AS m
- LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
- WHERE m.season = $season AND m.league = $league AND m.matchday <= $matchday AND m.goals_home = b.goals_home AND
- m.goals_guest = b.goals_guest AND m.status IN (2,3)
- GROUP BY b.user_id
- ORDER BY hits DESC
- ";
- $result = $db->sql_query($sql);
-
- $last_count_hits = -1;
- $count_user = 0;
- $userid_ary = array();
- $hits = array();
- $rank = array();
- $equal_rank = array();
- $win_pos_most_hits = array();
- while( $row = $db->sql_fetchrow($result))
- {
- $userid_ary[$count_user] = $row['userid'];
- $hits[$count_user] = $row['hits'];
- if ($count_user == 0)
- {
- $rank[$count_user] = 1;
- $equal_rank[$rank[$count_user]] = 1;
- $win_pos_most_hits[$rank[$count_user]] = $win_most_hits;
- }
- else
- {
- if ( $row['hits'] != $last_count_hits)
- {
- $rank[$count_user] = $count_user + 1;
- $equal_rank[$rank[$count_user]] = 1;
- $win_pos_most_hits[$rank[$count_user]] = 0;
- }
- else
- {
- $rank[$count_user] = $rank[$count_user-1];
- $equal_rank[$rank[$count_user]] += 1;
- }
- }
- $last_count_hits = $row['hits'];
- $count_user++;
- }
- $db->sql_freeresult($result);
- $win_user_most_hits = array();
- for($i = 0; $i < $count_user; $i++)
- {
- $win_user_most_hits[$userid_ary[$i]]['direct_hit'] = $hits[$i];
- if ($matchday == $last_matchday)
- {
- if (round($win_pos_most_hits[$rank[$i]]/$equal_rank[$rank[$i]],2) <> 0)
- {
- $win_user_most_hits[$userid_ary[$i]]['win'] = round($win_pos_most_hits[$rank[$i]]/$equal_rank[$rank[$i]],2);
- }
- else
- {
- $win_user_most_hits[$userid_ary[$i]]['win'] = 0;
- }
- }
- else
- {
- $win_user_most_hits[$userid_ary[$i]]['win'] = 0;
- }
- }
- if ($count_user > 0)
- {
- return $win_user_most_hits;
- }
- else
- {
- $win_user_most_hits[0]['win'] = 0;
- return $win_user_most_hits;
- }
-}
-
-/**
-* return win most hits away in array.
-*/
-function win_user_most_hits_away($season, $league, $matchday)
-{
- global $db, $lang;
-
- $sql = 'SELECT * FROM ' . FOOTB_LEAGUES . " WHERE season = $season AND league = $league";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $win_most_hits_away = $row['win_result_02'];
- $last_matchday = $row['matchdays'];
- $db->sql_freeresult($result);
- }
-
- $sql = 'SELECT
- b.user_id AS userid,
- SUM(IF(m.goals_home <= m.goals_guest,1,0)) AS hits_away
- FROM ' . FOOTB_MATCHES . ' AS m
- LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
- WHERE m.season = $season AND m.league = $league AND m.matchday <= $matchday AND m.goals_home = b.goals_home AND
- m.goals_guest = b.goals_guest AND m.status IN (2,3)
- GROUP BY b.user_id
- ORDER BY hits_away DESC
- ";
- $result = $db->sql_query($sql);
-
- $last_hits_away = -1;
- $count_user = 0;
- $userid_ary = array();
- $hits_away = array();
- $rank = array();
- $equal_rank = array();
- $win_pos_most_hits_away = array();
- while( $row = $db->sql_fetchrow($result))
- {
- $userid_ary[$count_user] = $row['userid'];
- $hits_away[$count_user] = $row['hits_away'];
- if ($count_user == 0)
- {
- $rank[$count_user] = 1;
- $equal_rank[$rank[$count_user]] = 1;
- $win_pos_most_hits_away[$rank[$count_user]] = $win_most_hits_away;
- }
- else
- {
- if ( $row['hits_away'] != $last_hits_away)
- {
- $rank[$count_user] = $count_user + 1;
- $equal_rank[$rank[$count_user]] = 1;
- $win_pos_most_hits_away[$rank[$count_user]] = 0;
- }
- else
- {
- $rank[$count_user] = $rank[$count_user-1];
- $equal_rank[$rank[$count_user]] += 1;
- }
- }
- $last_hits_away = $row['hits_away'];
- $count_user++;
- }
- $db->sql_freeresult($result);
- $win_user_most_hits_away = array();
- for($i = 0; $i < $count_user; $i++)
- {
- $win_user_most_hits_away[$userid_ary[$i]]['direct_hit'] = $hits_away[$i];
- if ($matchday == $last_matchday)
- {
- if (round($win_pos_most_hits_away[$rank[$i]]/$equal_rank[$rank[$i]],2) <> 0)
- {
- $win_user_most_hits_away[$userid_ary[$i]]['win'] = round($win_pos_most_hits_away[$rank[$i]]/$equal_rank[$rank[$i]],2);
- }
- else
- {
- $win_user_most_hits_away[$userid_ary[$i]]['win'] = 0;
- }
- }
- else
- {
- $win_user_most_hits_away[$userid_ary[$i]]['win'] = 0;
- }
- }
- if ($count_user > 0)
- {
- return $win_user_most_hits_away;
- }
- else
- {
- $win_user_most_hits_away[0]['win'] = 0;
- return $win_user_most_hits_away;
- }
-}
-
-/**
-* return colorstyle to status.
-*/
-function color_style($status)
-{
- switch ($status)
- {
- case 2:
- $colorstyle = 'color_provisionally';
- break;
- case 3:
- $colorstyle = 'color_finally';
- break;
- case 4:
- case 5:
- case 6:
- $colorstyle = 'color_not_rated';
- break;
- default:
- $colorstyle = '';
- break;
- }
- return $colorstyle;
-}
-
-
-/**
-* color text on match status.
-*/
-function color_match($text, $status)
-{
- switch($status)
- {
- case 2:
- $colormatch = "". $text. '';
- break;
- case 3:
- $colormatch = "". $text. '';
- break;
- case 4:
- case 5:
- case 6:
- $colormatch = "". $text. '';
- break;
- default:
- $colormatch = $text;
- break;
- }
- return $colormatch;
-}
-
-/**
-* color text on points status.
-*/
-function color_points($text, $status)
-{
- switch($status)
- {
- case 2:
- $color_points = "". $text. '';
- break;
- case 3:
- $color_points = "". $text. '';
- break;
- default:
- $color_points = $text;
- break;
- }
- return $color_points;
-}
-
-/**
-* get table order on teams with equal points.
-*/
-function get_order_team_compare($team_ary, $season, $league, $group, $ranks, $matchday = 999, $first = true)
-{
- global $db;
- $sql = "
- SELECT
- t.*,
- SUM(IF(m.team_id_home = t.team_id,
- IF(goals_home + 0 > goals_guest, 3, IF(goals_home = goals_guest, 1, 0)),
- IF(goals_home + 0 < goals_guest, 3, IF(goals_home = goals_guest, 1, 0))
- )
- ) - IF(t.team_id = 20 AND t.season = 2011 AND $matchday > 7, 2, 0) AS points,
- SUM(IF(m.team_id_home = t.team_id, goals_home - goals_guest, goals_guest - goals_home)) AS goals_diff,
- SUM(IF(m.team_id_home = t.team_id, goals_home, goals_guest)) AS goals
- FROM " . FOOTB_TEAMS . ' AS t
- LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league AND
- (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id) AND m.group_id = t.group_id)
- WHERE t.season = $season
- AND t.league = $league
- AND m.matchday <= $matchday
- AND m.status IN (2,3,5,6)
- AND m.group_id = '$group'
- AND (m.team_id_home='" . implode("' OR m.team_id_home='", $team_ary) . "')
- AND (m.team_id_guest='" . implode("' OR m.team_id_guest='", $team_ary) . "')
- GROUP BY t.team_id
- ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC";
-
- $result = $db->sql_query($sql);
-
- $tmp = array();
- $rank_ary = array();
- $rank = 0;
- $last_points = 0;
- $last_goals_diff = 0;
- $last_goals = 0;
-
- while( $row = $db->sql_fetchrow($result))
- {
- if ($last_points <> $row['points'] OR $last_goals_diff <> $row['goals_diff'] OR $last_goals <> $row['goals'])
- {
- $rank++;
- }
- $rank_ary[$rank][]=$row['team_id'];
- $last_points = $row['points'];
- $last_goals_diff = $row['goals_diff'];
- $last_goals = $row['goals'];
- }
- foreach($rank_ary as $rank => $teams)
- {
- if(count($teams) > 1)
- {
- if ($first)
- {
- // Compare teams with equal ranks
- $teams = get_order_team_compare($teams, $season, $league, $group, $ranks, $matchday, false);
- }
- else
- {
- // Second compare is still equal, so look on total rank
- $teams = array_intersect($ranks, $teams);
- }
- }
- foreach($teams as $key => $team)
- {
- $tmp[] = $team;
- }
- }
- return (sizeof($tmp) == 0) ? $team_ary: $tmp;
-}
-
-/**
-* determine team items from formula.
-*/
-function get_team($season, $league, $matchnumber, $field, $formula)
-{
- global $db, $lang, $user;
- $first_letter = substr($formula, 0, 1);
- $para = substr($formula, 2, 7);
- $para_ary = explode(";",$para);
-
- switch($first_letter)
- {
- case '3':
- // 3. Place Euro 2106
- $groups = substr($para_ary[0], 0, 5);
- $sql = '
- SELECT
- SUM(1) AS matches,
- SUM(IF(m.status = 3, 1, 0)) AS played
- FROM ' . FOOTB_MATCHES . " AS m
- WHERE m.season = $season AND m.league = $league AND m.group_id <> ''
- GROUP BY m.group_id
- ";
- $result = $db->sql_query($sql);
-
- if ( $row = $db->sql_fetchrow($result))
- {
- if ($row['matches'] == $row['played'])
- {
- $rank = 0;
- // Get table-information
- $sql = "SELECT
- t.*,
- SUM(1) AS matches,
- SUM(IF((m.team_id_home = t.team_id), IF(goals_home + 0 > goals_guest, 1, 0), IF(goals_home + 0 < goals_guest, 1, 0))) AS win,
- SUM(IF(goals_home = goals_guest, 1, 0)) AS draw,
- SUM(IF((m.team_id_home = t.team_id), IF(goals_home + 0 < goals_guest, 1, 0), IF(goals_home + 0 > goals_guest, 1, 0))) AS lost,
- SUM(IF(m.team_id_home = t.team_id,
- IF(goals_home + 0 > goals_guest, 3, IF(goals_home = goals_guest, 1, 0)),
- IF(goals_home + 0 < goals_guest, 3, IF(goals_home = goals_guest, 1, 0))
- )
- ) AS points,
- SUM(IF(m.team_id_home = t.team_id, goals_home - goals_guest , goals_guest - goals_home)) AS goals_diff,
- SUM(IF(m.team_id_home = t.team_id, goals_home , goals_guest)) AS goals,
- SUM(IF(m.team_id_home = t.team_id, goals_guest , goals_home)) AS goals_against
- FROM " . FOOTB_TEAMS . ' AS t
- LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league
- AND (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id) AND m.group_id = t.group_id)
- WHERE t.season = $season
- AND t.league = $league
- AND m.status IN (2,3,5,6)
- GROUP BY t.team_id
- ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC, t.team_name ASC";
-
- $result = $db->sql_query($sql);
-
- $table_ary = array();
- $points_ary = array();
- $ranks_ary = array();
- $third_team = array();
- $third_group = array();
- $points3 = array();
- $diff3 = array();
- $goals3 = array();
- $rank = 0;
- while( $row = $db->sql_fetchrow($result))
- {
- $rank++;
- $table_ary[$row['team_id']] = $row;
- $points_ary[$row['group_id']][$row['points']][]=$row['team_id'];
- $ranks_ary[] = $row['team_id'];
- }
-
- foreach($points_ary as $group_id => $points)
- {
- $rank = 0;
-
- //sort on points descending
- krsort($points);
-
- foreach($points as $point => $teams)
- {
- if(count($teams) > 1)
- {
- // Compare teams with equal points
- $teams = get_order_team_compare($teams, $season, $league, $group_id, $ranks_ary);
- }
- foreach($teams as $key => $team)
- {
- $row = $table_ary[$team];
- $rank++;
- if ($rank == 3)
- {
- $points3[$team] = $row['points'];
- $diff3[$team] = $row['goals_diff'];
- $goals3[$team] = $row['goals'];
- $third_team[$team]= $team;
- $third_group[$team]= $row['group_id'];
- }
- }
- }
- }
- // Sort 3. Place on points, diff, goals
- array_multisort($points3, SORT_DESC, $diff3, SORT_DESC, $goals3, SORT_DESC, $third_team, $third_group);
- $qualified_groups = array();
- for($i = 0; $i < 4; $i++)
- {
- $qualified_groups[$i] = $third_group[$i];
- $team_of[$third_group[$i]] = $third_team[$i];
- }
- asort($qualified_groups);
- $qualified_groups_string = '';
- foreach($qualified_groups as $key => $letter)
- {
- $qualified_groups_string .= $letter;
- }
- $modus = array('ABCD' => 'CDAB', 'ABCE' => 'CABE', 'ABCF' => 'CABF', 'ABDE' => 'DABE', 'ABDF' => 'DABF',
- 'ABEF' => 'EABF', 'ACDE' => 'CDAE', 'ACDF' => 'CDAF', 'ACEF' => 'CAFE', 'ADEF' => 'DAFE',
- 'BCDE' => 'CDBE', 'BCDF' => 'CDBF', 'BCEF' => 'ECBF', 'BDEF' => 'EDBF', 'CDEF' => 'CDFE');
- $form_para = array('CDE', 'ACD', 'ABF', 'BEF');
- $mode = $modus[$qualified_groups_string];
- for($i = 0; $i < 4; $i++)
- {
- $team = $team_of[substr($mode, $i, 1)];
-
- $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET team_id_guest = $team WHERE season = $season AND league = $league AND formula_guest = '3 $form_para[$i]'";
- $resultup = $db->sql_query($sqlup);
- $sqlup = 'UPDATE ' . FOOTB_TEAMS . ' SET matchday = (SELECT max(matchday) FROM ' . FOOTB_MATCHES . "
- WHERE season = $season AND league = $league AND (team_id_home= $team OR team_id_guest = $team))
- WHERE season = $season AND league = $league AND team_id = $team";
- $resultup = $db->sql_query($sqlup);
- if ($form_para[$i] == $groups)
- {
- $team_id = $team;
- $row = $table_ary[$team];
- $team_symbol = $row['team_symbol'];
- $team_name = $row['team_name'];
- $team_name_short = $row['team_name_short'];
- }
- }
- return $team_symbol . '#' . $team_id . '#' . $team_name . '#' . $team_name_short;
-
- }
- else
- {
- return '#0#' . '3. ' . sprintf($user->lang['GROUP']) . ' ' . $groups . '#' . '3. ' . sprintf($user->lang['GROUP']) . ' ' . $groups;
- }
- }
- else
- {
- return '#0#' . '3. ' . sprintf($user->lang['GROUP']) . ' ' . $groups . '#' . '3. ' . sprintf($user->lang['GROUP']) . ' ' . $groups;
- }
- break;
- case 'D':
- // Drawing
- return '#0#' . sprintf($user->lang['DRAWING']) . '#' . sprintf($user->lang['DRAWING']);
- break;
- case 'G':
- // GROUP
- $group = substr($para_ary[0], 0, 1);
- $place = substr($para_ary[0], 1, 1);
- $sql = '
- SELECT
- SUM(1) AS matches,
- SUM(IF(m.status = 3, 1, 0)) AS played
- FROM ' . FOOTB_MATCHES . " AS m
- WHERE m.season = $season AND m.league = $league AND m.group_id = '$group'
- GROUP BY m.group_id
- ";
- $result = $db->sql_query($sql);
-
- if ( $row = $db->sql_fetchrow($result))
- {
- if ($row['matches'] == $row['played'])
- {
- $rank = 0;
- $sql = '
- SELECT
- t.*,
- SUM(IF(m.team_id_home = t.team_id,
- IF(goals_home + 0 > goals_guest, 3, IF(goals_home = goals_guest, 1, 0)),
- IF(goals_home + 0 < goals_guest, 3, IF(goals_home = goals_guest, 1, 0))
- )
- ) AS points,
- SUM(IF(m.team_id_home = t.team_id, goals_home - goals_guest, goals_guest - goals_home)) AS goals_diff,
- SUM(IF(m.team_id_home = t.team_id, goals_home, goals_guest)) AS goals,
- SUM(IF(m.team_id_home = t.team_id, goals_guest, goals_home)) AS goals_get
- FROM ' . FOOTB_TEAMS . ' AS t
- LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league AND
- (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id) AND m.group_id = t.group_id)
- WHERE t.season = $season AND t.league = $league AND m.group_id = '$group'
- GROUP BY t.team_id
- ORDER BY points DESC, goals_diff DESC, goals DESC
- ";
- $result = $db->sql_query($sql);
- $table_ary = array();
- $points_ary = array();
- $ranks_ary = array();
- while( $row = $db->sql_fetchrow($result))
- {
- $table_ary[$row['team_id']] = $row;
- $points_ary[$row['points']][]=$row['team_id'];
- $ranks_ary[] = $row['team_id'];
- }
- $db->sql_freeresult($result);
-
- //sort on points descending
- krsort($points_ary);
-
- foreach($points_ary as $point => $teams)
- {
- if(count($teams) > 1)
- {
- // Compare teams with equal points
- $teams = get_order_team_compare($teams, $season, $league, $group, $ranks_ary);
- }
- foreach($teams as $key => $team)
- {
- $row = $table_ary[$team];
- $rank++;
- if ($rank == $place)
- {
- $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $team WHERE season = $season AND league = $league AND match_no = $matchnumber";
- $resultup = $db->sql_query($sqlup);
- $sqlup = 'UPDATE ' . FOOTB_TEAMS . ' SET matchday = (SELECT max(matchday) FROM ' . FOOTB_MATCHES . "
- WHERE season = $season AND league = $league AND (team_id_home= $team OR team_id_guest = $team))
- WHERE season = $season AND league = $league AND team_id = $team";
- $resultup = $db->sql_query($sqlup);
- return $row['team_symbol'] . '#' . $team . '#' . $row['team_name'] . '#' . $row['team_name_short'];
- }
- }
- }
- }
- else
- {
- return '#0#' . $place . '. ' . sprintf($user->lang['GROUP']) . ' ' . $group . '#' . $place . '. ' . sprintf($user->lang['GROUP']) . ' ' . $group;
- }
- }
- else
- {
- return '#0#' . $place . '. ' . sprintf($user->lang['GROUP']) . ' ' . $group . '#' . $place . '. ' . sprintf($user->lang['GROUP']) . ' ' . $group;
- }
- break;
- case 'L':
- // Looser
- switch(sizeof($para_ary))
- {
- case 1:
- $sql = 'SELECT
- m.status,
- m.team_id_home AS home_id,
- m.team_id_guest AS guest_id,
- t1.team_symbol AS home_symbol,
- t2.team_symbol AS guest_symbol,
- t1.team_name AS home_name,
- t2.team_name AS guest_name,
- t1.team_name_short AS home_sname,
- t2.team_name_short AS guest_sname,
- m.goals_overtime_home,
- m.goals_overtime_guest,
- m.goals_home,
- m.goals_guest
- FROM ' . FOOTB_MATCHES . ' AS m
- LEFT JOIN ' . FOOTB_TEAMS . ' AS t1 ON (t1.season = m.season AND t1.league = m.league AND t1.team_id = m.team_id_home)
- LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = m.season AND t2.league = m.league AND t2.team_id = m.team_id_guest)
- WHERE m.season = $season AND m.league = $league AND m.match_no = $para_ary[0]";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- if ((3 == $row['status']) OR (6 == $row['status']))
- {
- if ($row['goals_home'] > $row['goals_guest'] OR $row['goals_overtime_home'] > $row['goals_overtime_guest'])
- {
- $new_id = $row['guest_id'];
- $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
- $resultup = $db->sql_query($sqlup);
- return $row['guest_symbol'] . '#' . $row['guest_id'] . '#' . $row['guest_name'] . '#' . $row['guest_sname'];
- }
- if ($row['goals_home'] < $row['goals_guest'] OR $row['goals_overtime_home'] < $row['goals_overtime_guest'])
- {
- $new_id = $row['home_id'];
- $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
- $resultup = $db->sql_query($sqlup);
- return $row['home_symbol'] . '#' . $row['home_id'] . '#' . $row['home_name'] . '#' . $row['home_sname'];
- }
- }
- else
- {
- return '#0#' . sprintf($user->lang['LOOSER_MATCH_NO']) . $para_ary[0] . '#' . sprintf($user->lang['LOOSER']) . ' ' . $para_ary[0];
- }
- }
- break;
- default:
- return '#0#' . sprintf($user->lang['DRAWING']) . '#' . sprintf($user->lang['DRAWING']);
- break;
- }
- break;
- case 'W':
- // Winner
- switch(sizeof($para_ary))
- {
- case 1:
- $sql = 'SELECT
- m.status,
- m.team_id_home AS home_id,
- m.team_id_guest AS guest_id,
- t1.team_symbol AS home_symbol,
- t2.team_symbol AS guest_symbol,
- t1.team_name AS home_name,
- t2.team_name AS guest_name,
- t1.team_name_short AS home_sname,
- t2.team_name_short AS guest_sname,
- m.goals_overtime_home,
- m.goals_overtime_guest,
- m.goals_home,
- m.goals_guest
- FROM ' . FOOTB_MATCHES . ' AS m
- LEFT JOIN ' . FOOTB_TEAMS . ' AS t1 ON (t1.season = m.season AND t1.league = m.league AND t1.team_id = m.team_id_home)
- LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = m.season AND t2.league = m.league AND t2.team_id = m.team_id_guest)
- WHERE m.season = $season AND m.league = $league AND m.match_no = $para_ary[0]";
- $result = $db->sql_query($sql);
-
- if ($row = $db->sql_fetchrow($result))
- {
- if ((3 == $row['status']) OR (6 == $row['status']))
- {
- if ($row['goals_home'] > $row['goals_guest'] OR $row['goals_overtime_home'] > $row['goals_overtime_guest'])
- {
- $new_id = $row['home_id'];
- $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
- $resultup = $db->sql_query($sqlup);
- return $row['home_symbol'] . '#' . $row['home_id'] . '#' . $row['home_name'] . '#' . $row['home_sname'];
- }
- if ($row['goals_home'] < $row['goals_guest'] OR $row['goals_overtime_home'] < $row['goals_overtime_guest'])
- {
- $new_id = $row['guest_id'];
- $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
- $resultup = $db->sql_query($sqlup);
- return $row['guest_symbol'] . '#' . $row['guest_id'] . '#' . $row['guest_name'] . '#' . $row['guest_sname'];
- }
- }
- else
- {
- if ($row['home_sname'] != '' AND $row['guest_sname'] != '')
- {
- return '#0#' . $row['home_sname'] . ' / ' . $row['guest_sname'] . '#' . $row['home_sname'] . '+' . $row['guest_sname'];
- }
- else
- {
- return '#0#' . sprintf($user->lang['WINNER_MATCH_NO']) . $para_ary[0] . '#' . sprintf($user->lang['WINNER']) . ' ' . $para_ary[0];
- }
- }
- }
- break;
- case 2:
-
- $sql = 'SELECT
- m.status,
- m.team_id_home AS home_id,
- m.team_id_guest AS guest_id,
- t1.team_symbol AS home_symbol,
- t2.team_symbol AS guest_symbol,
- t1.team_name AS home_name,
- t2.team_name AS guest_name,
- t1.team_name_short AS home_sname,
- t2.team_name_short AS guest_sname,
- m.goals_overtime_home,
- m.goals_overtime_guest,
- m.goals_home,
- m.goals_guest
- FROM ' . FOOTB_MATCHES . ' AS m
- LEFT JOIN ' . FOOTB_TEAMS . ' AS t1 ON (t1.season = m.season AND t1.league = m.league AND t1.team_id = m.team_id_home)
- LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = m.season AND t2.league = m.league AND t2.team_id = m.team_id_guest)
- WHERE m.season = $season AND m.league = $league AND (m.match_no = $para_ary[0] OR m.match_no = $para_ary[1])
- ORDER BY m.match_no ASC";
- $result = $db->sql_query($sql);
-
- if ($firstleg = $db->sql_fetchrow($result))
- {
- if ($replay = $db->sql_fetchrow($result))
- {
- if (((3 == $firstleg['status']) OR (6 == $firstleg['status'])) AND ((3 == $replay['status']) OR (6 == $replay['status'])))
- {
- if ($firstleg['home_id'] == $replay['guest_id'] AND $firstleg['guest_id'] == $replay['home_id'])
- {
- if ($firstleg['goals_home'] + $replay['goals_guest'] > $firstleg['goals_guest'] + $replay['goals_home'] OR $replay['goals_overtime_guest'] > $replay['goals_overtime_home'] OR
- ($firstleg['goals_home'] + $replay['goals_guest'] == $firstleg['goals_guest'] + $replay['goals_home'] AND $replay['goals_guest'] > $firstleg['goals_guest']))
- {
- $new_id = $firstleg['home_id'];
- $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
- $resultup = $db->sql_query($sqlup);
- return $firstleg['home_symbol'] . '#' . $firstleg['home_id'] . '#' . $firstleg['home_name'] . '#' . $firstleg['home_sname'];
- }
- if ($firstleg['goals_home'] + $replay['goals_guest'] < $firstleg['goals_guest'] + $replay['goals_home'] OR $replay['goals_overtime_guest'] < $replay['goals_overtime_home'] OR
- ($firstleg['goals_home'] + $replay['goals_guest'] == $firstleg['goals_guest'] + $replay['goals_home'] AND $firstleg['goals_guest'] > $replay['goals_guest']))
- {
- $new_id = $firstleg['guest_id'];
- $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
- $resultup = $db->sql_query($sqlup);
- return $firstleg['guest_symbol'] . '#' . $firstleg['guest_id'] . '#' . $firstleg['guest_name'] . '#' . $firstleg['guest_sname'];
- }
- }
- else if ($firstleg['home_id'] == $replay['home_id'] AND $firstleg['guest_id'] == $replay['guest_id'])
- {
- if ($firstleg['goals_home'] + $replay['goals_home'] <= $firstleg['goals_guest'] + $replay['goals_guest'] OR $replay['goals_overtime_home'] < $replay['goals_overtime_guest'])
- {
- $new_id = $firstleg['guest_id'];
- $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
- $resultup = $db->sql_query($sqlup);
- return $firstleg['guest_symbol'] . '#' . $firstleg['guest_id'] . '#' . $firstleg['guest_name'] . '#' . $firstleg['guest_sname'];
- }
- else
- {
- $new_id = $firstleg['home_id'];
- $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
- $resultup = $db->sql_query($sqlup);
- return $firstleg['home_symbol'] . '#' . $firstleg['home_id'] . '#' . $firstleg['home_name'] . '#' . $firstleg['home_sname'];
- }
- }
- else
- {
- return '#0#' . sprintf($user->lang['MATCH_ERROR']) . '#' . sprintf($user->lang['FORMULA']) . '!';
- }
- }
- else
- {
- if ($firstleg['home_sname'] != '' AND $firstleg['guest_sname'] != '')
- {
- return '#0#' . $firstleg['home_sname'] . ' / ' . $firstleg['guest_sname'] . '#' . $firstleg['home_sname'] . '+' . $firstleg['guest_sname'];
- }
- else
- {
- return '#0#' . sprintf($user->lang['WINNER_MATCH_NO']) . ' ' . $para_ary[0] . '+' . $para_ary[1] . '#S. ' . $para_ary[0] . '+' . $para_ary[1];
- }
- }
- }
- else
- {
- return '#0#' . sprintf($user->lang['SEC_LEG_ERROR']) . '#' . sprintf($user->lang['FORMULA']) . '!';
- }
- }
- else
- {
- return '#0#' . sprintf($user->lang['FIRSTLEG_ERROR']) . '#' . sprintf($user->lang['FORMULA']) . '!';
- }
- break;
- default:
- return '#0#Los#Los';
- break;
- }
- break;
- default:
- return '#0#' . sprintf($user->lang['DRAWING']) . '#' . sprintf($user->lang['DRAWING']);
- break;
- }
-}
-
-/**
-* KO-matches: Set team to next round.
-*/
-function ko_next_round($season, $league, $matchday_from, $matchday_to, $matchday_new)
-{
- global $db, $user;
- $sql = 'SELECT
- t.team_id,
- t.team_name,
- SUM(1) AS matches,
- SUM(IF(m.team_id_home = t.team_id,
- IF(goals_overtime_home + goals_overtime_guest > 0,
- goals_overtime_home,
- goals_home
- ),
- IF(goals_overtime_home + goals_overtime_guest > 0,
- goals_overtime_guest,
- goals_guest
- )
- )
- ) AS goals,
- SUM(IF(m.team_id_home = t.team_id,
- IF(goals_overtime_home + goals_overtime_guest > 0,
- goals_overtime_guest,
- goals_guest
- ),
- IF(goals_overtime_home + goals_overtime_guest > 0,
- goals_overtime_home,
- goals_home
- )
- )
- ) AS goals_get,
- SUM(IF(m.team_id_home = t.team_id,
- 0,
- IF(goals_overtime_home + goals_overtime_guest > 0,
- goals_overtime_guest,
- goals_guest
- )
- )
- ) AS goals_away,
- SUM(IF(m.team_id_home = t.team_id,
- IF(goals_overtime_home + goals_overtime_guest > 0,
- goals_overtime_guest,
- goals_guest
- ),
- 0
- )
- ) AS goals_away_opp
- FROM ' . FOOTB_TEAMS . ' AS t
- LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league AND (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id))
- WHERE t.season = $season AND t.league = $league AND m.matchday >= $matchday_from AND m.matchday <= $matchday_to AND m.status IN (3,6)
- GROUP BY t.team_id";
- $result = $db->sql_query($sql);
-
- $message = sprintf($user->lang['KO_NEXT']) . ':
';
- while ($row = $db->sql_fetchrow($result))
- {
- if (($matchday_to == $matchday_from AND $row['matches'] == 1) OR ($matchday_to != 0 AND $row['matches'] == 2))
- {
- if (($row['goals'] > $row['goals_get']) OR
- (($row['goals'] == $row['goals_get']) AND ($row['goals_away'] > $row['goals_away_opp'])))
- {
- $team_id = $row['team_id'];
- $sqlup = 'UPDATE ' . FOOTB_TEAMS . " SET matchday = $matchday_new WHERE season = $season AND league = $league AND team_id = $team_id";
- $resultup = $db->sql_query($sqlup);
- $message .= $row['team_name'] . '
';
- }
- }
- }
- $db->sql_freeresult($result);
-
- $message .= '
';
- return $message;
-}
-
-/**
-* KO-matches: Set groupleaders next round.
-*/
-function ko_group_next_round($season, $league, $matchday_from, $matchday_to, $matchday_new, $rank, $move_rank, $move_league, $move_matchday)
-{
- global $db, $user;
- $sql = '
- SELECT
- t.*,
- SUM(1) AS matches
- FROM ' . FOOTB_TEAMS . ' AS t
- LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league AND (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id) AND m.group_id = t.group_id)
- WHERE t.season = $season AND t.league = $league AND m.matchday >= $matchday_from AND m.matchday <= $matchday_to AND m.status NOT IN (3,6)
- GROUP BY t.team_id
- ";
- $result = $db->sql_query($sql);
- $rowset = $db->sql_fetchrowset($result);
- $db->sql_freeresult($result);
-
- if (sizeof($rowset) > 0)
- {
- $message = sprintf($user->lang['NO_KO_NEXT']);
- $messag_moved = '';
- }
- else
- {
- $sql = '
- SELECT
- t.*,
- SUM(1) AS matches,
- SUM(IF((m.team_id_home = t.team_id), IF(goals_home + 0 > goals_guest, 1, 0), IF(goals_home + 0 < goals_guest, 1, 0))) AS win,
- SUM(IF(goals_home = goals_guest, 1, 0)) AS draw,
- SUM(IF((m.team_id_home = t.team_id), IF(goals_home + 0 < goals_guest, 1, 0), IF(goals_home + 0 > goals_guest, 1, 0))) AS lose,
- SUM(IF(m.team_id_home = t.team_id,
- IF(goals_home + 0 > goals_guest,
- 3,
- IF(goals_home = goals_guest,
- 1,
- 0
- )
- ),
- IF(goals_home + 0 < goals_guest,
- 3,
- IF(goals_home = goals_guest,
- 1,
- 0
- )
- )
- )
- ) AS points,
- SUM(IF(m.team_id_home = t.team_id, goals_home - goals_guest, goals_guest - goals_home)) AS goal_diff,
- SUM(IF(m.team_id_home = t.team_id, goals_home, goals_guest)) AS goals,
- SUM(IF(m.team_id_home = t.team_id, goals_guest, goals_home)) AS goals_get
- FROM ' . FOOTB_TEAMS . ' AS t
- LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league AND (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id) AND m.group_id = t.group_id)
- WHERE t.season = $season AND t.league = $league AND m.matchday >= $matchday_from AND m.matchday <= $matchday_to AND m.status IN (3,6)
- GROUP BY t.team_id
- ORDER BY group_id ASC,points DESC, goal_diff DESC, goals DESC
- ";
- $result = $db->sql_query($sql);
-
- $table_ary = array();
- $points_ary = array();
- $ranks_ary = array();
- while( $row = $db->sql_fetchrow($result))
- {
- $table_ary[$row['team_id']] = $row;
- $points_ary[$row['group_id']][$row['points']][]=$row['team_id'];
- $ranks_ary[] = $row['team_id'];
- }
-
- $message = sprintf($user->lang['KO_NEXT_CHECK']) . ':
';
- $message .= sprintf($user->lang['KO_NEXT']) . ':
';
- $messag_moved = '
' . sprintf($user->lang['KO_MOVED']) . ':
';
- $group_id = 'XX';
- foreach($points_ary as $group_id => $points)
- {
- $place = 1;
- foreach($points as $point => $teams)
- {
- if(count($teams) > 1)
- {
- // Compare teams with equal points
- $teams = get_order_team_compare($teams, $season, $league, $group_id, $ranks_ary);
- }
- foreach($teams as $key => $team_id)
- {
- $row = $table_ary[$team_id];
-
- if ($place <= $rank)
- {
- $sqlup = 'UPDATE ' . FOOTB_TEAMS . " SET matchday = $matchday_new WHERE season = $season AND league = $league AND team_id = $team_id";
- $resultup = $db->sql_query($sqlup);
- $message .= $row['team_name'] . '
';
- }
- if ($move_rank > 0 AND $move_league > 0 AND $place == $move_rank)
- {
- $team_name = $row['team_name'];
- $short_name = $row['team_name_short'];
- $team_sign = $row['team_symbol'];
- $sqlinsert = 'INSERT INTO ' . FOOTB_TEAMS . " VALUES($season, $move_league, $team_id, '$team_name', '$short_name', '$team_sign', '', $move_matchday)";
- $resultinsert = $db->sql_query($sqlinsert);
- $messag_moved .= $row['team_name'] . '
';
- }
- $place++;
- }
- }
- }
- }
- $db->sql_freeresult($result);
-
- $message .= '
';
- return $message. $messag_moved;
-}
-
-/**
-* return SQL statement part to calculate points depending to mode.
-*/
-function select_points($creator = 'm', $sum = false)
-{
- global $league_info;
-
- $points_result = $league_info['points_result'];
- $points_tendency = $league_info['points_tendency'];
- $points_diff = $league_info['points_diff'];
-
- switch ($league_info['points_mode'])
- {
- // hit = points_result
- // right tendency (not draw) = points_result - difference between bet und result but minimal points_tendency
- // right tendency (draw) = points_result - difference between bet goals home und result goals home
- case 1:
- $select_part = ($sum ? "SUM(IF(b.goals_home <> '' AND b.goals_guest <> ''," : 'IF(((m.status = 2) OR (m.status = 3)),') .
- "IF(b.goals_home <> '' AND b.goals_guest <> '',
- IF((b.goals_home + 0 < b.goals_guest) <> ($creator.goals_home + 0 < $creator.goals_guest)
- OR (b.goals_home = b.goals_guest) <> ($creator.goals_home = $creator.goals_guest)
- OR (b.goals_home + 0 > b.goals_guest) <> ($creator.goals_home + 0 > $creator.goals_guest),
- " .($sum ? '0' : "''") . ",
- IF((b.goals_home = $creator.goals_home) AND (b.goals_guest = $creator.goals_guest),
- $points_result,
- IF((b.goals_home = b.goals_guest),
- $points_result - ABS(b.goals_home - $creator.goals_home),
- IF((($points_result - ABS(b.goals_home - $creator.goals_home) - ABS(b.goals_guest - $creator.goals_guest)) < $points_tendency),
- $points_tendency,
- $points_result - ABS(b.goals_home - $creator.goals_home) - ABS(b.goals_guest - $creator.goals_guest)
- )
- )
- )
- ),
- " .($sum ? '0' : "''") . '
- ),
- ' .($sum ? '0' : "''") . "
- ) " .($sum ? ')' : '') . 'AS points';
- break;
- // hit = points_result,
- // right tendency = points_result - difference between bet und result but minimal points_tendency
- case 2:
- $select_part = ($sum ? "SUM(IF(b.goals_home <> '' AND b.goals_guest <> ''," : 'IF(((m.status = 2) OR (m.status = 3)),') .
- "IF(b.goals_home <> '' AND b.goals_guest <> '',
- IF((b.goals_home + 0 < b.goals_guest) <> ($creator.goals_home + 0 < $creator.goals_guest)
- OR (b.goals_home = b.goals_guest) <> ($creator.goals_home = $creator.goals_guest)
- OR (b.goals_home + 0 > b.goals_guest) <> ($creator.goals_home + 0 > $creator.goals_guest),
- " .($sum ? '0' : "''") . ",
- IF((b.goals_home = $creator.goals_home) AND (b.goals_guest = $creator.goals_guest),
- $points_result,
- IF((b.goals_home = b.goals_guest),
- $points_result - ABS(b.goals_home - $creator.goals_home) - ABS(b.goals_guest - $creator.goals_guest),
- IF((($points_result - ABS(b.goals_home - $creator.goals_home) - ABS(b.goals_guest - $creator.goals_guest)) < $points_tendency),
- $points_tendency,
- $points_result - ABS(b.goals_home - $creator.goals_home) - ABS(b.goals_guest - $creator.goals_guest)
- )
- )
- )
- ),
- " .($sum ? '0' : "''") . '
- ),
- ' .($sum ? '0' : "''") . "
- ) " .($sum ? ')' : '') . 'AS points';
- break;
- // hit = points_result,
- // right tendency = points_tendency
- case 3:
- $select_part = ($sum ? "SUM(IF(b.goals_home <> '' AND b.goals_guest <> ''," : 'IF(((m.status = 2) OR (m.status = 3)),') .
- "IF(b.goals_home <> '' AND b.goals_guest <> '',
- IF((b.goals_home + 0 < b.goals_guest) <> ($creator.goals_home + 0 < $creator.goals_guest)
- OR (b.goals_home = b.goals_guest) <> ($creator.goals_home = $creator.goals_guest)
- OR (b.goals_home + 0 > b.goals_guest) <> ($creator.goals_home + 0 > $creator.goals_guest),
- " .($sum ? '0' : "''") . ",
- IF((b.goals_home = $creator.goals_home) AND (b.goals_guest = $creator.goals_guest),
- $points_result,
- $points_tendency
- )
- ),
- " .($sum ? '0' : "''") . '
- ),
- ' .($sum ? '0' : "''") . "
- ) " .($sum ? ')' : '') . 'AS points';
- break;
- // hit = points_result,
- // right goal-difference = points_diff,
- // right tendency = points_tendency
- case 4:
- $select_part = ($sum ? "SUM(IF(b.goals_home <> '' AND b.goals_guest <> ''," : 'IF(((m.status = 2) OR (m.status = 3)),') .
- "IF(b.goals_home <> '' AND b.goals_guest <> '',
- IF((b.goals_home + 0 < b.goals_guest) <> ($creator.goals_home + 0 < $creator.goals_guest)
- OR (b.goals_home = b.goals_guest) <> ($creator.goals_home = $creator.goals_guest)
- OR (b.goals_home + 0 > b.goals_guest) <> ($creator.goals_home + 0 > $creator.goals_guest),
- " .($sum ? '0' : "''") . ",
- IF((b.goals_home = $creator.goals_home) AND (b.goals_guest = $creator.goals_guest),
- $points_result,
- IF((b.goals_home - b.goals_guest = $creator.goals_home - $creator.goals_guest),
- $points_diff,
- $points_tendency
- )
- )
- ),
- " .($sum ? '0' : "''") . '
- ),
- ' .($sum ? '0' : "''") . "
- ) " .($sum ? ')' : '') . 'AS points';
- break;
- // hit = points_result,
- // right goal-difference (not draw) = points_diff,
- // right tendency = points_tendency
- case 5:
- $select_part = ($sum ? "SUM(IF(b.goals_home <> '' AND b.goals_guest <> ''," : 'IF(((m.status = 2) OR (m.status = 3)),') .
- "IF(b.goals_home <> '' AND b.goals_guest <> '',
- IF((b.goals_home + 0 < b.goals_guest) <> ($creator.goals_home + 0 < $creator.goals_guest)
- OR (b.goals_home = b.goals_guest) <> ($creator.goals_home = $creator.goals_guest)
- OR (b.goals_home + 0 > b.goals_guest) <> ($creator.goals_home + 0 > $creator.goals_guest),
- " .($sum ? '0' : "''") . ",
- IF((b.goals_home = $creator.goals_home) AND (b.goals_guest = $creator.goals_guest),
- $points_result,
- IF(((b.goals_home - b.goals_guest = $creator.goals_home - $creator.goals_guest)
- AND ($creator.goals_home <> $creator.goals_guest)) ,
- $points_diff,
- $points_tendency
- )
- )
- ),
- " .($sum ? '0' : "''") . '
- ),
- ' .($sum ? '0' : "''") . "
- ) " .($sum ? ')' : '') . 'AS points';
- break;
- // hit = points_result,
- // right tendency draw = points_diff,
- // right tendency (not draw) = points_tendency
- case 6:
- $select_part = ($sum ? "SUM(IF(b.goals_home <> '' AND b.goals_guest <> ''," : 'IF(((m.status = 2) OR (m.status = 3)),') .
- "IF(b.goals_home <> '' AND b.goals_guest <> '',
- IF((b.goals_home + 0 < b.goals_guest) <> ($creator.goals_home + 0 < $creator.goals_guest)
- OR (b.goals_home = b.goals_guest) <> ($creator.goals_home = $creator.goals_guest)
- OR (b.goals_home + 0 > b.goals_guest) <> ($creator.goals_home + 0 > $creator.goals_guest),
- " .($sum ? '0' : "''") . ",
- IF((b.goals_home = $creator.goals_home) AND (b.goals_guest = $creator.goals_guest),
- $points_result,
- IF(((b.goals_home = b.goals_guest) AND ($creator.goals_home = $creator.goals_guest) ) ,
- $points_diff,
- $points_tendency
- )
- )
- ),
- " .($sum ? '0' : "''") . '
- ),
- ' .($sum ? '0' : "''") . "
- ) " .($sum ? ')' : '') . 'AS points';
- break;
- }
- return $select_part;
-}
+ 0
+ $where_status";
+ $result = $db->sql_query($sql);
+
+ $result_ary = array();
+ $extra_points_error = true;
+ while($row = $db->sql_fetchrow($result))
+ {
+ $extra_no = $row['extra_no'];
+ if ($row['result'] <> '')
+ {
+ switch($row['question_type'])
+ {
+ case '2':
+ case '4':
+ // multiple results
+ {
+ $bet_points = 'CASE bet ';
+ $result_ary = explode(';', $row['result']);
+ foreach($result_ary AS $result_value)
+ {
+ if ($result_value <> '')
+ {
+ $result_value = (is_numeric($result_value)) ? $result_value : "'" . $result_value . "'";
+ $bet_points .= ' WHEN ' . $result_value . ' THEN ' . $row['extra_points'] . ' ';
+ $extra_points_error = false;
+ }
+ }
+ $bet_points .= ' ELSE 0 END';
+ }
+ break;
+ case '5':
+ // difference to result
+ {
+ if (is_numeric($row['result']))
+ {
+ $bet_points = 'IF(' . $row['extra_points'] . '- ABS(bet - ' . $row['result'] . ') > 0, ' . $row['extra_points'] . '- ABS(bet - ' . $row['result'] . ')' . ', 0)';
+ $extra_points_error = false;
+ }
+ else
+ {
+ $extra_points_error = true;
+ }
+ }
+ break;
+ default:
+ // Case 1 and 3 and other
+ // correct result
+ {
+ $result_value = (is_numeric($row['result'])) ? $row['result'] : "'" . $row['result'] . "'";
+ $bet_points = 'CASE bet WHEN ' . $result_value . ' THEN ' . $row['extra_points'] . ' ELSE 0 END';
+ $extra_points_error = false;
+ }
+ break;
+ }
+ if (!$extra_points_error)
+ {
+ $sql = 'UPDATE ' . FOOTB_EXTRA_BETS . '
+ SET bet_points = ' . $bet_points . "
+ WHERE season = $season
+ AND league = $league
+ AND extra_no = $extra_no";
+ $db->sql_query($sql);
+ }
+ }
+ }
+ $db->sql_freeresult($result);
+}
+
+
+/**
+* Save matchday-ranking in database (table FOOTB_RANKS).
+*/
+function save_ranking_matchday($season, $league, $matchday, $cash = false)
+{
+ global $db, $config, $lang, $league_info;
+ $sql = 'SELECT * FROM ' . FOOTB_MATCHDAYS . " WHERE season = $season AND league = $league AND matchday = $matchday";
+ $result = $db->sql_query($sql);
+
+ if ( $row = $db->sql_fetchrow($result))
+ {
+ $matchday_status = $row['status'];
+ if ($row['delivery_date_2'] != '' OR ($league_info['bet_in_time'] AND $matchday_status <> 3))
+ // We set status to 2 to skip deleting the ranking
+ $matchday_status = 2;
+ $db->sql_freeresult($result);
+ if ($matchday_status < 2)
+ {
+ $sql = 'SELECT * FROM ' . FOOTB_MATCHES . " WHERE season = $season AND league = $league AND matchday = $matchday AND status IN (2,3)";
+ $result = $db->sql_query($sql);
+ if ( $row = $db->sql_fetchrow($result))
+ {
+ $matchday_status = 2;
+ }
+ }
+
+ if ($matchday_status == 0 OR $matchday_status == 1)
+ {
+ // No matches played, so we can delete the ranking
+ $sql = 'DELETE FROM ' . FOOTB_RANKS . " WHERE season = $season AND league = $league AND matchday = $matchday";
+ $result = $db->sql_query($sql);
+ }
+ else
+ {
+ $matchday_wins = array();
+ $matchday_wins = matchday_wins($season, $league);
+ $sql = "
+ SELECT
+ 1 AS rank,
+ 0.00 AS win,
+ u.user_id,
+ u.username AS username,
+ SUM(IF(m.match_no > 0, 1, 0)) AS matches,
+ SUM(IF(b.goals_home = '' OR b.goals_guest = '', 1, 0)) AS nobet,
+ SUM(IF(b.goals_home <> '' AND b.goals_guest <> '',
+ IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest)
+ , 1
+ , 0
+ )
+ , 0
+ )
+ ) AS direct_hit,
+ SUM(IF(b.goals_home <> '' AND b.goals_guest <> '',
+ IF((b.goals_home + 0 < b.goals_guest) <> (m.goals_home + 0 < m.goals_guest)
+ OR (b.goals_home = b.goals_guest) <> (m.goals_home = m.goals_guest)
+ OR (b.goals_home + 0 > b.goals_guest) <> (m.goals_home + 0 > m.goals_guest)
+ , 0
+ , 1
+ )
+ , 0
+ )
+ ) AS tendency,
+ " . select_points('m',true) . '
+ FROM ' . FOOTB_MATCHES . ' AS m
+ INNER JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
+ INNER JOIN ' . USERS_TABLE . " AS u ON (b.user_id = u.user_id)
+ WHERE m.season = $season AND m.league = $league AND m.matchday = $matchday AND m.status IN (2,3)
+ GROUP BY b.user_id
+ ORDER BY points DESC, nobet ASC, username ASC
+ ";
+
+ $result = $db->sql_query($sql);
+
+ $ranking_ary = array();
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $ranking_ary[$row['user_id']] = $row;
+ }
+ $db->sql_freeresult($result);
+ if ( sizeof($ranking_ary) > 0 )
+ {
+ $sql = '
+ SELECT
+ eb.user_id,
+ SUM(eb.bet_points) AS points
+ FROM ' . FOOTB_EXTRA . ' AS e
+ INNER JOIN ' . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = e.season and eb.league = e.league and eb.extra_no = e.extra_no)
+ WHERE e.season = $season
+ AND e.league = $league
+ AND e.matchday = $matchday
+ AND e.matchday_eval = $matchday
+ AND e.extra_status > 1
+ GROUP BY eb.user_id";
+
+ $result = $db->sql_query($sql);
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $ranking_ary[$row['user_id']]['points'] += $row['points'];
+ }
+ $db->sql_freeresult($result);
+
+ // sort the ranking by points
+ usort($ranking_ary, '_sort_points');
+ }
+
+ $last_points = -1;
+ $last_rank = 1;
+ $equal_rank = array();
+ $money = array();
+ $i = 0;
+ foreach( $ranking_ary AS $curr_user => $curr_rank)
+ {
+ if ($curr_rank['nobet'] == $curr_rank['matches'] and $league_info['points_last'] == 1)
+ {
+ if ($last_points <> -1)
+ {
+ $ranking_ary[$curr_user]['points'] = $last_points;
+ }
+ else
+ {
+ $ranking_ary[$curr_user]['points'] = 0;
+ $last_points = 0;
+ $equal_rank[$last_rank] = 0;
+ }
+ }
+ if ( $ranking_ary[$curr_user]['points'] != $last_points)
+ {
+ $ranking_ary[$curr_user]['rank'] = $i + 1;
+ $last_rank = $i + 1;
+ $equal_rank[$last_rank] = 1;
+ if ($last_rank < sizeof($matchday_wins))
+ {
+ $money[$last_rank] = $matchday_wins[$last_rank];
+ }
+ else
+ {
+ $money[$last_rank] = 0;
+ }
+ $last_points = $ranking_ary[$curr_user]['points'];
+ }
+ else
+ {
+ $ranking_ary[$curr_user]['rank'] = $last_rank;
+ $equal_rank[$last_rank] += 1;
+ if ($i + 1 < sizeof($matchday_wins))
+ {
+ $money[$last_rank] += $matchday_wins[$i + 1];
+ }
+ }
+ $i++;
+ }
+ foreach( $ranking_ary AS $curr_user => $curr_rank)
+ {
+ if ( round($money[$curr_rank['rank']] / $equal_rank[$curr_rank['rank']], 2) <> 0 )
+ {
+ $win = round($money[$curr_rank['rank']] / $equal_rank[$curr_rank['rank']], 2);
+ $ranking_ary[$curr_user]['win'] = $win;
+ }
+ else
+ {
+ $win = 0;
+ $ranking_ary[$curr_user]['win'] = 0;
+ }
+ $sql = 'REPLACE INTO ' . FOOTB_RANKS . "
+ VALUES ($season
+ , $league
+ , $matchday
+ , " . $curr_rank['user_id'] . "
+ , $matchday_status
+ , " . $curr_rank['rank'] . "
+ , " . $curr_rank['points'] . "
+ , $win
+ , 0
+ , " . $curr_rank['tendency'] . "
+ , " . $curr_rank['direct_hit'] . "
+ ,0
+ ,0
+ )";
+ $result = $db->sql_query($sql);
+ }
+ if ( sizeof($ranking_ary) == 0 )
+ {
+ $sql = 'DELETE FROM ' . FOOTB_RANKS . "
+ WHERE season = $season
+ AND league = $league
+ AND matchday = $matchday";
+ $result = $db->sql_query($sql);
+ }
+ else
+ {
+ // Calculate total ranking
+ $rank_total_ary = array();
+ $sql = 'SELECT
+ user_id ,
+ SUM(points) AS points,
+ SUM(win) AS wins_total
+ FROM ' . FOOTB_RANKS . "
+ WHERE season = $season
+ AND league = $league
+ AND matchday <= $matchday
+ GROUP by user_id
+ ORDER BY points DESC, user_id ASC";
+ $result = $db->sql_query($sql);
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $rank_total_ary[$row['user_id']] = $row;
+ }
+ $db->sql_freeresult($result);
+
+ // add extra tipp points total ranking
+ $league_info = league_info($season, $league);
+ if ( sizeof($rank_total_ary) > 0 )
+ {
+ if ( $matchday == $league_info['matchdays'])
+ {
+ $win_user_most_hits = win_user_most_hits($season, $league, $matchday);
+ $win_user_most_hits_away = win_user_most_hits_away($season, $league, $matchday);
+ $season_wins = season_wins($season, $league, $matchday);
+ }
+ $sql = 'SELECT
+ eb.user_id,
+ SUM(eb.bet_points) AS points
+ FROM ' . FOOTB_EXTRA . ' AS e
+ INNER JOIN ' . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = e.season and eb.league = e.league and eb.extra_no = e.extra_no)
+ WHERE e.season = $season
+ AND e.league = $league
+ AND e.matchday <> e.matchday_eval
+ AND e.matchday_eval <= $matchday
+ AND e.extra_status > 1
+ GROUP BY eb.user_id";
+
+ $result = $db->sql_query($sql);
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $rank_total_ary[$row['user_id']]['points'] += $row['points'];
+ }
+ $db->sql_freeresult($result);
+
+ // sort the ranking by points
+ usort($rank_total_ary, '_sort_points');
+ }
+
+ $index = 0;
+ $last_rank = 0;
+ $last_points = -1;
+ foreach( $rank_total_ary AS $curr_user => $curr_rank)
+ {
+ $index++;
+ if ( $curr_rank['points'] == $last_points)
+ {
+ $rank_total = $last_rank;
+ }
+ else
+ {
+ $rank_total = $index;
+ $last_points = $curr_rank['points'];
+ $last_rank = $rank_total;
+ }
+ if ($matchday == $league_info['matchdays'])
+ {
+ // if someone didn't bet the hole Season
+ if (!isset($win_user_most_hits[$curr_rank['user_id']]['win']))
+ {
+ $win_user_most_hits[$curr_rank['user_id']]['win'] = 0;
+ }
+ if (!isset($win_user_most_hits_away[$curr_rank['user_id']]['win']))
+ {
+ $win_user_most_hits_away[$curr_rank['user_id']]['win'] = 0;
+ }
+ if (!isset($season_wins[$curr_rank['user_id']]['win']))
+ {
+ $season_wins[$curr_rank['user_id']]['win'] = 0;
+ }
+ $rank_total_ary[$curr_user]['wins_total'] = sprintf('%01.2f',$curr_rank['wins_total'] + $win_user_most_hits[$curr_rank['user_id']]['win'] + $win_user_most_hits_away[$curr_rank['user_id']]['win'] + $season_wins[$curr_rank['user_id']]['win']);
+ }
+ else
+ {
+ $rank_total_ary[$curr_user]['wins_total'] = sprintf('%01.2f',$curr_rank['wins_total']);
+ }
+ $curr_userid = $curr_rank['user_id'];
+ $points_total = $curr_rank['points'];
+ $win_total = $rank_total_ary[$curr_user]['wins_total'];
+ $sql = 'UPDATE ' . FOOTB_RANKS . "
+ SET rank_total = $rank_total,
+ points_total = $points_total,
+ win_total = $win_total
+ WHERE season = $season AND league = $league AND matchday = $matchday AND user_id = $curr_userid";
+ $result = $db->sql_query($sql);
+ }
+ }
+ }
+ if ($config['football_bank'])
+ {
+ if ($matchday_status < 3)
+ {
+ //Delete points
+ if ($matchday == $league_info['matchdays'])
+ {
+ // On last matchday
+ rollback_points(POINTS_MOST_HITS, $season, $league, $matchday, $cash && ($config['football_ult_points'] == 1));
+ rollback_points(POINTS_MOST_HITS_AWAY, $season, $league, $matchday, $cash && ($config['football_ult_points'] == 1));
+ rollback_points(POINTS_SEASON, $season, $league, $matchday, $cash && ($config['football_ult_points'] == 1));
+ }
+ rollback_points(POINTS_MATCHDAY, $season, $league, $matchday, $cash && ($config['football_ult_points'] > 0));
+ }
+ else
+ {
+ //Set points on played matchday
+ if ($matchday == $league_info['matchdays'] AND $config['football_bank'])
+ {
+ // On last matchday
+ set_points_most_hits($season, $league, $matchday, $win_user_most_hits, $cash && ($config['football_ult_points'] == 1));
+ set_points_most_hits_away($season, $league, $matchday, $win_user_most_hits_away, $cash && ($config['football_ult_points'] == 1));
+ set_points_season($season, $league, $matchday, $season_wins, $cash && ($config['football_ult_points'] == 1));
+ }
+ set_points_matchday($season, $league, $matchday, $ranking_ary, $cash && ($config['football_ult_points'] > 0));
+ }
+ }
+ $sql = 'SELECT matchday FROM ' . FOOTB_RANKS . "
+ WHERE season = $season
+ AND league = $league
+ AND matchday > $matchday";
+ $result = $db->sql_query($sql);
+ if ( $next_matchday = (int) $db->sql_fetchfield('matchday'))
+ {
+ $db->sql_freeresult($result);
+ save_ranking_matchday($season, $league, $next_matchday, $cash);
+ }
+ }
+}
+
+function set_points_most_hits($season, $league, $matchday, $win_user_most_hits, $cash)
+{
+ rollback_points(POINTS_MOST_HITS, $season, $league, $matchday, $cash);
+ set_footb_points(POINTS_MOST_HITS, $season, $league, $matchday, $win_user_most_hits, $cash);
+}
+
+function set_points_most_hits_away($season, $league, $matchday, $win_user_most_hits_away, $cash)
+{
+ rollback_points(POINTS_MOST_HITS_AWAY, $season, $league, $matchday, $cash);
+ set_footb_points(POINTS_MOST_HITS_AWAY, $season, $league, $matchday, $win_user_most_hits_away, $cash);
+}
+
+function set_points_season($season, $league, $matchday, $season_wins, $cash)
+{
+ rollback_points(POINTS_SEASON, $season, $league, $matchday, $cash);
+ set_footb_points(POINTS_SEASON, $season, $league, $matchday, $season_wins, $cash);
+}
+
+function set_points_matchday($season, $league, $matchday, $ranking_ary, $cash)
+{
+ rollback_points(POINTS_MATCHDAY, $season, $league, $matchday, $cash);
+ set_footb_points(POINTS_MATCHDAY, $season, $league, $matchday, $ranking_ary, $cash);
+}
+
+function rollback_points($points_type, $season, $league, $matchday, $cash)
+{
+ global $db, $functions_points;
+ if ($cash)
+ {
+ $where_matchday = ($matchday) ? " AND matchday = $matchday" : '';
+ $sql = 'SELECT *
+ FROM ' . FOOTB_POINTS . " AS p
+ WHERE season = $season
+ AND league = $league
+ $where_matchday
+ AND points_type = $points_type
+ AND cash = 1";
+
+ $result = $db->sql_query($sql);
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $functions_points->substract_points($row['user_id'], $row['points']);
+ }
+ $db->sql_freeresult($result);
+
+ }
+ $sql = 'DELETE FROM ' . FOOTB_POINTS . " WHERE season = $season AND league = $league AND matchday = $matchday AND points_type = $points_type";
+ $result = $db->sql_query($sql);
+}
+
+function set_footb_points($points_type, $season, $league, $matchday, $wins, $cash)
+{
+ global $db, $user, $config, $functions_points;
+ switch($points_type)
+ {
+ case 1:
+ $points_comment = sprintf($user->lang['BET_POINTS']);
+ break;
+ case 2:
+ $points_comment = sprintf($user->lang['DEPOSIT']);
+ break;
+ case 3:
+ $points_comment = '';
+ break;
+ case 4:
+ $points_comment = '';
+ break;
+ case 5:
+ $points_comment = sprintf($user->lang['WIN_HITS']);
+ break;
+ case 6:
+ $points_comment = sprintf($user->lang['WIN_HITS02']);
+ break;
+ case 7:
+ $points_comment = sprintf($user->lang['PAYOUT_WIN']);
+ break;
+ }
+
+ foreach( $wins AS $curr_user => $curr_ary)
+ {
+ if ($config['football_ult_points'] == 2 AND $points_type == 3)
+ {
+ // points mode
+
+ if ($curr_ary['points'] > 0 AND $curr_ary['points'] <> NULL)
+ {
+ $userid = (!isset($curr_ary['user_id'])) ? $curr_user : $curr_ary['user_id'];
+ $points_comment = sprintf($user->lang['POINTS']);
+ $factor_points = round($config['football_ult_points_factor'] * $curr_ary['points'],2);
+ if ($cash)
+ {
+ $functions_points->add_points($userid, $factor_points);
+ }
+ $sql_ary = array(
+ 'season' => (int) $season,
+ 'league' => (int) $league,
+ 'matchday' => (int) $matchday,
+ 'points_type' => (int) $points_type,
+ 'user_id' => (int) $userid,
+ 'points' => $factor_points,
+ 'points_comment'=> $points_comment,
+ 'cash' => $cash,
+ );
+ $sql = 'INSERT INTO ' . FOOTB_POINTS . ' ' . $db->sql_build_array('INSERT', $sql_ary);
+ $db->sql_query($sql);
+ }
+ }
+ if ($config['football_ult_points'] <= 1 OR ($config['football_ult_points'] == 2 AND $points_type == 1))
+ {
+ if ($curr_ary['win'] > 0)
+ {
+ switch($points_type)
+ {
+ case 3:
+ $points_comment = sprintf($user->lang['WIN_MATCHDAY']) . ' ' . $curr_ary['rank'] . '.' . sprintf($user->lang['PLACE']);
+ break;
+ case 4:
+ $points_comment = sprintf($user->lang['WIN_SEASON']) . ' ' . $curr_ary['rank'] . '.' . sprintf($user->lang['PLACE']);
+ break;
+ }
+ $userid = (!isset($curr_ary['user_id'])) ? $curr_user : $curr_ary['user_id'];
+ if ($cash)
+ {
+ if ($points_type == 1 OR $points_type == 7)
+ {
+ // substract bets and payouts
+ $functions_points->substract_points($userid, round($curr_ary['win'],2));
+ }
+ else
+ {
+ $functions_points->add_points($userid, round($curr_ary['win'],2));
+ }
+ }
+ $sql_ary = array(
+ 'season' => (int) $season,
+ 'league' => (int) $league,
+ 'matchday' => (int) $matchday,
+ 'points_type' => (int) $points_type,
+ 'user_id' => (int) $userid,
+ 'points' => round($curr_ary['win'],2),
+ 'points_comment'=> $points_comment,
+ 'cash' => $cash,
+ );
+ $sql = 'INSERT INTO ' . FOOTB_POINTS . ' ' . $db->sql_build_array('INSERT', $sql_ary);
+ $db->sql_query($sql);
+ }
+ }
+ }
+}
+
+function _sort_points($value_a, $value_b)
+{
+ if ($value_a['points'] > $value_b['points'])
+ {
+ return -1;
+ }
+ else
+ {
+ if ($value_a['points'] == $value_b['points'])
+ {
+ if (isset($value_a['nobet']))
+ {
+ if ($value_a['nobet'] < $value_b['nobet'])
+ {
+ return -1;
+ }
+ else
+ {
+ if ($value_a['nobet'] == $value_b['nobet'])
+ {
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ return 1;
+ }
+ }
+}
+
+
+/**
+* Return season-array
+*/
+function season_info($season)
+{
+ global $db;
+ $sql = 'SELECT * FROM ' . FOOTB_SEASONS . " WHERE season = $season";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ return $row;
+ }
+ else
+ {
+ return array();
+ }
+ $db->sql_freeresult($result);
+}
+
+/**
+* Return league-array
+*/
+function league_info($season, $league)
+{
+ global $db;
+ $sql = 'SELECT * FROM ' . FOOTB_LEAGUES . "
+ WHERE season = $season AND league = $league
+ ";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ return $row;
+ }
+ else
+ {
+ return array();
+ }
+ $db->sql_freeresult($result);
+}
+
+/**
+* Return team-array
+*/
+function team_info($season, $league, $team_id)
+{
+ global $db;
+ $sql = 'SELECT * FROM ' . FOOTB_TEAMS . "
+ WHERE season = $season AND league = $league AND team_id = $team_id
+ ";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ return $row;
+ }
+ else
+ {
+ return array();
+ }
+ $db->sql_freeresult($result);
+}
+
+/**
+* Is user member of this league
+*/
+function user_is_member($userid, $season, $league)
+{
+ global $db;
+ $sql = 'SELECT COUNT(*) AS counter
+ FROM ' . FOOTB_BETS . "
+ WHERE season = $season AND league = $league AND user_id = $userid";
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+
+ if ($row['counter'] > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ $db->sql_freeresult($result);
+}
+
+/**
+* Count existing matches on matchday or league
+*/
+function count_existing_matches($season, $league, $matchday)
+{
+ global $db;
+ $where_matchday = ($matchday) ? " AND matchday = $matchday" : '';
+ $sql = 'SELECT COUNT(*) AS counter
+ FROM ' . FOOTB_MATCHES . "
+ WHERE season = $season AND league = $league $where_matchday";
+ $result = $db->sql_query($sql);
+ if ($row = $db->sql_fetchrow($result))
+ {
+ return $row['counter'];
+ $db->sql_freeresult($result);
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+/**
+* Determinate if join to league is allowed
+*/
+function join_allowed($season, $league)
+{
+ global $db;
+ $league_info = league_info($season, $league);
+ if (! $league_info['join_by_user'])
+ {
+ return false;
+ }
+ else
+ {
+ if ($league_info['join_in_season'])
+ {
+ return true;
+ }
+ else
+ {
+ $sql = 'SELECT * FROM ' . FOOTB_MATCHDAYS . "
+ WHERE season = $season AND league = $league AND matchday = 1 AND status = 0
+ ";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $db->sql_freeresult($result);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+}
+
+/**
+* Calculate status or delivery of matchday
+*/
+function delivery($season, $league, $matchday)
+{
+ global $db, $user;
+ $delivery = '';
+ $lang_dates = $user->lang['datetime'];
+ $sql = "SELECT *,
+ CONCAT(
+ CASE DATE_FORMAT(delivery_date,'%w')
+ WHEN 0 THEN '" . $lang_dates['Sun'] . "'
+ WHEN 1 THEN '" . $lang_dates['Mon'] . "'
+ WHEN 2 THEN '" . $lang_dates['Tue'] . "'
+ WHEN 3 THEN '" . $lang_dates['Wed'] . "'
+ WHEN 4 THEN '" . $lang_dates['Thu'] . "'
+ WHEN 5 THEN '" . $lang_dates['Fri'] . "'
+ WHEN 6 THEN '" . $lang_dates['Sat'] . "'
+ ELSE 'Error' END,
+ DATE_FORMAT(delivery_date,' %d.%m.%Y %H:%i')
+ ) AS deliverytime
+ FROM " . FOOTB_MATCHDAYS . "
+ WHERE season = $season AND league = $league AND matchday = $matchday";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ switch($row['status'])
+ {
+ case 0:
+ $delivery = '' . sprintf($user->lang['STATUS_TEXT0']) . $row['deliverytime'] . '';
+ break;
+ case 1:
+ $delivery = '' . sprintf($user->lang['STATUS_TEXT1']) . '';
+ break;
+ case 2:
+ $delivery = '' . sprintf($user->lang['STATUS_TEXT2']) . '';
+ break;
+ case 3:
+ $delivery = '' . sprintf($user->lang['STATUS_TEXT3']) . '';
+ break;
+ }
+ $db->sql_freeresult($result);
+ }
+ return $delivery;
+}
+
+/**
+* Calculate next delivery und return delivery string
+*/
+function next_delivery($season, $league)
+{
+ global $db, $user;
+ $next_delivery = '';
+ $lang_dates = $user->lang['datetime'];
+ $sql = "SELECT
+ CONCAT(
+ CASE DATE_FORMAT(delivery_date,'%w')
+ WHEN 0 THEN '" . $lang_dates['Sun'] . "'
+ WHEN 1 THEN '" . $lang_dates['Mon'] . "'
+ WHEN 2 THEN '" . $lang_dates['Tue'] . "'
+ WHEN 3 THEN '" . $lang_dates['Wed'] . "'
+ WHEN 4 THEN '" . $lang_dates['Thu'] . "'
+ WHEN 5 THEN '" . $lang_dates['Fri'] . "'
+ WHEN 6 THEN '" . $lang_dates['Sat'] . "'
+ ELSE 'Error' END,
+ DATE_FORMAT(delivery_date,' %d.%m.%Y %H:%i')
+ ) AS deliverytime
+ FROM " . FOOTB_MATCHDAYS . "
+ WHERE season = $season AND league = $league AND status = 0
+ ORDER BY matchday ASC
+ ";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $next_delivery = "". sprintf($user->lang['NEXT_DELIVERY_UNTIL']) . ' ' . $row['deliverytime'] . "";
+ $db->sql_freeresult($result);
+ }
+ return $next_delivery;
+}
+
+/**
+* Calculate first delivery of matchday for bet in time
+*/
+function first_delivery($season, $league, $matchday)
+{
+ global $db, $user;
+ $sql = "SELECT MIN(match_datetime) AS min_match_datetime
+ FROM " . FOOTB_MATCHES . "
+ WHERE season = $season AND league = $league AND matchday = $matchday AND status = 0
+ ORDER BY min_match_datetime ASC
+ ";
+ $result = $db->sql_query($sql);
+ $first_delivery = '';
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $first_delivery = $row['min_match_datetime'];
+ $db->sql_freeresult($result);
+ }
+ return $first_delivery;
+}
+
+/**
+* Set matchday delivery to first open match
+*/
+function set_bet_in_time_delivery($season, $league)
+{
+ global $db, $user, $config;
+ $sql = "SELECT *
+ FROM " . FOOTB_MATCHDAYS . "
+ WHERE season = $season AND league = $league AND status < 3
+ ";
+ $result = $db->sql_query($sql);
+ $first_delivery = '';
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $new_status = $row['status'];
+
+ // match-status maybe changed
+ $sql_ary = array(
+ 'status' => 0,
+ 'goals_home' => '',
+ 'goals_guest' => '',
+ 'goals_overtime_home' => '',
+ 'goals_overtime_guest' => '',
+ );
+ $local_board_time = time() + (($config['board_timezone'] - $config['football_host_timezone']) * 3600);
+ $sql = 'UPDATE ' . FOOTB_MATCHES . '
+ SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
+ WHERE season = $season AND league = $league AND matchday =" . $row['matchday'] . " AND match_datetime > FROM_UNIXTIME('$local_board_time')";
+ $db->sql_query($sql);
+
+ if ($db->sql_affectedrows())
+ {
+ // an open match exist, so set status 0
+ $new_status = 0;
+ }
+ $first_delivery = first_delivery($season, $league, $row['matchday']);
+ if ( $first_delivery <> '')
+ {
+ // Matchday has open matches so set matchday status = 0 and first delivery
+ $sql_ary = array(
+ 'status' => $new_status,
+ 'delivery_date' => $first_delivery,
+ 'delivery_date_2' => '',
+ 'delivery_date_3' => '',
+ );
+ $sql = 'UPDATE ' . FOOTB_MATCHDAYS . '
+ SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
+ WHERE season = $season AND league = $league AND matchday =" . $row['matchday'];
+ $db->sql_query($sql);
+ }
+ }
+ $db->sql_freeresult($result);
+}
+
+
+/**
+* return current season. The minimal seasons value with a open matchday (status = 0).
+*/
+function curr_season()
+{
+ global $db, $lang, $user;
+ $user_spec = '';
+ if ($user->data['user_type']==0 OR $user->data['user_type']==3)
+ {
+ $curr_user = $user->data['user_id'];
+ $user_spec = 'AND b.user_id = ' . $curr_user;
+ }
+
+ $sql = 'SELECT DISTINCT s.season
+ FROM ' . FOOTB_SEASONS . ' AS s
+ INNER JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = s.season)
+ INNER JOIN ' . FOOTB_MATCHDAYS . ' AS m ON (m.season = s.season AND m.league = l.league)
+ INNER JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league ' . $user_spec . ')
+ WHERE m.status IN (0,1,2)
+ ORDER BY s.season ASC';
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $curr_season = $row['season'];
+ $db->sql_freeresult($result);
+ }
+ else
+ {
+ $sql = 'SELECT DISTINCT s.season FROM ' . FOOTB_SEASONS . ' AS s
+ INNER JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = s.season)
+ INNER JOIN ' . FOOTB_MATCHDAYS . ' AS m ON (m.season = s.season AND m.league = l.league)
+ WHERE 1
+ ORDER BY s.season DESC';
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $curr_season = $row['season'];
+ }
+ else
+ {
+ $sql = 'SELECT * FROM ' . FOOTB_SEASONS;
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $curr_season = $row['season'];
+ }
+ else
+ {
+ $curr_season = 0;
+ }
+ }
+ $db->sql_freeresult($result);
+ }
+ return $curr_season;
+}
+
+/**
+* return first (minmal) league of season
+*/
+function first_league($season, $complete = true)
+{
+ global $db, $lang;
+ $join_matchday = '';
+ if ($complete)
+ {
+ $join_matchday = 'INNER JOIN ' . FOOTB_MATCHDAYS . ' AS m ON (m.season = l.season AND m.league = l.league) ';
+ }
+ $sql = 'SELECT *
+ FROM ' . FOOTB_LEAGUES . ' AS l ' .
+ $join_matchday . "
+ WHERE l.season = $season
+ ORDER BY l.league ASC";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $first_league = $row['league'];
+ }
+ else
+ {
+ $first_league = 0;
+ }
+ $db->sql_freeresult($result);
+ return $first_league;
+}
+
+/**
+* return current (wait for results) league of season
+*/
+function current_league($season)
+{
+ global $db, $lang, $user;
+ $user_spec = '';
+ if ($user->data['user_type']==0 OR $user->data['user_type']==3)
+ {
+ $curr_user = $user->data['user_id'];
+ $user_spec = 'AND b.user_id = ' . $curr_user;
+ }
+ $sql = 'SELECT DISTINCT m.league
+ FROM ' . FOOTB_MATCHES . ' AS m
+ INNER JOIN ' . FOOTB_BETS . ' AS b ON (b.season = m.season AND b.league = m.league ' . $user_spec . ")
+ WHERE m.season = $season
+ AND m.status in (0,1,2)
+ ORDER BY m.match_datetime ASC
+ LIMIT 1";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $current_league = $row['league'];
+ }
+ else
+ {
+ $current_league = first_league($season);
+ }
+ $db->sql_freeresult($result);
+ return $current_league;
+}
+
+/**
+* return next free team-id
+*/
+function nextfree_teamid()
+{
+ global $db, $lang;
+ $sql = 'SELECT Max(team_id) AS lastid FROM ' . FOOTB_TEAMS;
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ return ($row['lastid'] + 1);
+ }
+ else
+ {
+ return 0;
+ }
+ $db->sql_freeresult($result);
+}
+
+/**
+* return current (in order to play) matchday of league
+*/
+function curr_matchday($season, $league)
+{
+ global $db, $lang;
+ $sql = 'SELECT * FROM ' . FOOTB_MATCHDAYS . "
+ WHERE season = $season AND league = $league AND status < 3
+ ORDER BY status DESC, delivery_date ASC
+ ";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $curr_matchday = $row['matchday'];
+ $db->sql_freeresult($result);
+ }
+ else
+ {
+ $sql = 'SELECT * FROM ' . FOOTB_MATCHDAYS . "
+ WHERE season = $season AND league = $league AND status = 3
+ ORDER BY matchday DESC
+ ";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $curr_matchday = $row['matchday'];
+ }
+ else
+ {
+ $curr_matchday = 0;
+ }
+ $db->sql_freeresult($result);
+ }
+ return $curr_matchday;
+}
+
+
+/**
+* Initialize user bets. Adds s user to a league.
+*/
+function join_league($season, $league, $user_id)
+{
+ global $db, $lang;
+
+ $league_info = league_info($season, $league);
+ $matchdays = $league_info['matchdays'];
+ if ($league_info['league_type'] == LEAGUE_CHAMP)
+ {
+ $matches_on_matchdays = $league_info['matches_on_matchday'];
+ }
+ else
+ {
+ $matches_on_matchdays = 0;
+ }
+
+ $count_updates = 0;
+ $matches = $matches_on_matchdays;
+ $match_id = 1;
+ for($m_day = 1; $m_day <= $matchdays; $m_day++)
+ {
+ if ($matches_on_matchdays == 0)
+ {
+ $sql = 'SELECT matches from ' . FOOTB_MATCHDAYS . " WHERE season = $season AND league = $league AND matchday = $m_day";
+ $result = $db->sql_query($sql);
+ if( $row = $db->sql_fetchrow($result))
+ {
+ $matches = $row['matches'];
+ $db->sql_freeresult($result);
+ }
+ else
+ {
+ // Matchday doesnt exist
+ $matches = 0;
+ }
+ }
+ for($i = 1; $i<= $matches; $i++)
+ {
+ $sqlup = 'REPLACE INTO ' . FOOTB_BETS . " VALUES($season, $league, $match_id, $user_id, '', '', 0)";
+ $resultup = $db->sql_query($sqlup);
+ $match_id++;
+ $count_updates++;
+ }
+ }
+ return $count_updates;
+}
+
+// Close matchday
+/**
+* Close all open matches.
+*/
+function close_open_matchdays()
+{
+ global $db, $lang, $config;
+
+ $local_board_time = time() + (($config['board_timezone'] - $config['football_host_timezone']) * 3600);
+ $sql = 'SELECT * FROM ' . FOOTB_MATCHDAYS . " WHERE status = 0 AND delivery_date < FROM_UNIXTIME('$local_board_time')";
+ $result = $db->sql_query($sql);
+ $toclose = $db->sql_fetchrowset($result);
+ $db->sql_freeresult($result);
+ foreach ($toclose as $close)
+ {
+ // Matchday to close
+ $season = $close['season'];
+ $league = $close['league'];
+ $matchday = $close['matchday'];
+ $league_info = league_info($season, $league);
+
+ if ($league_info['bet_in_time'] == 1)
+ {
+ $sql_ary = array(
+ 'status' => 1,
+ );
+ $sql = 'UPDATE ' . FOOTB_MATCHES . '
+ SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
+ WHERE season = $season AND league = $league AND matchday = $matchday AND status = 0 AND match_datetime < FROM_UNIXTIME('$local_board_time')";
+ $db->sql_query($sql);
+
+ // Check remaining open matches
+ $first_delivery = first_delivery($season, $league, $close['matchday']);
+ if ($first_delivery <> '')
+ {
+ // Matchday has open matches so set matchday status = 0 and first delivery
+ $sql_ary = array(
+ 'status' => 0,
+ 'delivery_date' => first_delivery($season, $league, $close['matchday']),
+ );
+ $sql = 'UPDATE ' . FOOTB_MATCHDAYS . '
+ SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
+ WHERE season = $season AND league = $league AND matchday = $matchday";
+ $db->sql_query($sql);
+ }
+ else
+ {
+ // Matchday has no open match so close the matchday with setting status = 1
+ $sql_ary = array(
+ 'status' => 1,
+ );
+ $sql = 'UPDATE ' . FOOTB_MATCHDAYS . '
+ SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
+ WHERE season = $season AND league = $league AND matchday = $matchday";
+ $db->sql_query($sql);
+ }
+ }
+ else
+ {
+ if ($close['delivery_date_2'] != '')
+ {
+ // More open matches exists, so shift delivery and status lower Null
+ $sql_ary = array(
+ 'delivery_date' => $close['delivery_date_2'],
+ 'delivery_date_2' => $close['delivery_date_3'],
+ 'delivery_date_3' => '',
+ );
+ $sql = 'UPDATE ' . FOOTB_MATCHDAYS . '
+ SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
+ WHERE season = $season AND league = $league AND matchday = $matchday";
+ $db->sql_query($sql);
+
+ $sql = 'UPDATE ' . FOOTB_MATCHES . "
+ SET status = status + 1
+ WHERE season = $season AND league = $league AND matchday = $matchday AND status <= 0";
+ $db->sql_query($sql);
+ }
+ else
+ {
+ // Close all matches of the matchday and matchday
+ $sql = 'UPDATE ' . FOOTB_MATCHDAYS . "
+ SET status = 1
+ WHERE season = $season AND league = $league AND matchday = $matchday";
+ $db->sql_query($sql);
+
+ $sql = 'UPDATE ' . FOOTB_MATCHES . "
+ SET status = status + 1
+ WHERE season = $season AND league = $league AND matchday = $matchday AND status <= 0";
+ $db->sql_query($sql);
+ }
+ }
+ // close extra bets
+ $sql = 'UPDATE ' . FOOTB_EXTRA . "
+ SET extra_status = extra_status + 1
+ WHERE season = $season AND league = $league AND matchday = $matchday AND extra_status <= 0";
+ $db->sql_query($sql);
+ }
+}
+
+/**
+* return matchday wins in array.
+*/
+function matchday_wins($season, $league)
+{
+ global $db, $lang;
+ $matchday_wins = array();
+
+ $sql = 'SELECT * FROM ' . FOOTB_LEAGUES . " WHERE season = $season AND league = $league";
+ $result = $db->sql_query($sql);
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $matchday_wins = explode(';',"0;" . $row['win_matchday']);
+ $db->sql_freeresult($result);
+ }
+ return $matchday_wins;
+}
+
+/**
+* return season wins in array.
+*/
+function season_wins($season, $league, $matchday)
+{
+ global $db, $lang;
+ $season_wins = array();
+ $season_user_wins = array();
+ $league_info = league_info($season, $league);
+ if (sizeof($league_info))
+ {
+ $season_wins = explode(';',"0;" . $league_info['win_season']);
+ $maxmatchday = $league_info['matchdays'];
+ }
+ else
+ {
+ $season_user_wins[0]['win'] = 0;
+ return $season_user_wins;
+ }
+
+ $sql = 'SELECT
+ 1 AS rank,
+ user_id,
+ SUM(points) AS points
+ FROM ' . FOOTB_RANKS . "
+ WHERE season = $season
+ AND league = $league
+ AND matchday <= $matchday
+ AND status IN (2,3)
+ GROUP by user_id
+ ORDER BY points DESC, user_id ASC
+ ";
+ $result = $db->sql_query($sql);
+ $ranking_ary = array();
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $ranking_ary[$row['user_id']] = $row;
+ }
+ $db->sql_freeresult($result);
+
+ if ( sizeof($ranking_ary) > 0 )
+ {
+ $sql = 'SELECT
+ eb.user_id,
+ SUM(eb.bet_points) AS points
+ FROM ' . FOOTB_EXTRA . ' AS e
+ INNER JOIN ' . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = e.season and eb.league = e.league and eb.extra_no = e.extra_no)
+ WHERE e.season = $season
+ AND e.league = $league
+ AND e.matchday <> e.matchday_eval
+ AND e.matchday_eval <= $matchday
+ AND e.extra_status > 1
+ GROUP BY eb.user_id";
+
+ $result = $db->sql_query($sql);
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $ranking_ary[$row['user_id']]['points'] += $row['points'];
+ }
+ $db->sql_freeresult($result);
+ // sort the ranking by points
+ usort($ranking_ary, '_sort_points');
+
+ $last_points = -1;
+ $last_rank = 1;
+ $equal_rank = array();
+ $money = array();
+ $i = 0;
+ foreach( $ranking_ary AS $curr_user => $curr_rank)
+ {
+ if ( $curr_rank['points'] != $last_points)
+ {
+ $ranking_ary[$curr_user]['rank'] = $i + 1;
+ $last_rank = $i + 1;
+ $equal_rank[$last_rank] = 1;
+ $last_points = $curr_rank['points'];
+ if ($last_rank < sizeof($season_wins))
+ {
+ $money[$last_rank] = $season_wins[$last_rank];
+ }
+ else
+ {
+ $money[$last_rank] = 0;
+ }
+ }
+ else
+ {
+ $ranking_ary[$curr_user]['rank'] = $last_rank;
+ $equal_rank[$last_rank] += 1;
+ if ($i + 1 < sizeof($season_wins))
+ {
+ $money[$last_rank] += $season_wins[$i + 1];
+ }
+ }
+ $i++;
+ }
+ foreach( $ranking_ary AS $curr_rank)
+ {
+ if ( round($money[$curr_rank['rank']] / $equal_rank[$curr_rank['rank']], 2) <> 0 )
+ {
+ $season_user_wins[$curr_rank['user_id']]['win'] = round($money[$curr_rank['rank']] / $equal_rank[$curr_rank['rank']], 2);
+ }
+ else
+ {
+ $season_user_wins[$curr_rank['user_id']]['win'] = 0;
+ }
+ $season_user_wins[$curr_rank['user_id']]['rank'] = $curr_rank['rank'];
+ }
+ return $season_user_wins;
+ }
+ else
+ {
+ $season_user_wins[0]['win'] = 0;
+ return $season_user_wins;
+ }
+}
+
+/**
+* return win most hits in array.
+*/
+function win_user_most_hits($season, $league, $matchday)
+{
+ global $db, $lang;
+
+ $sql = 'SELECT * FROM ' . FOOTB_LEAGUES . " WHERE season = $season AND league = $league";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $win_most_hits = $row['win_result'];
+ $last_matchday = $row['matchdays'];
+ $db->sql_freeresult($result);
+ }
+
+ $sql = 'SELECT
+ b.user_id AS userid,
+ COUNT(*) AS hits
+ FROM ' . FOOTB_MATCHES . ' AS m
+ LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
+ WHERE m.season = $season AND m.league = $league AND m.matchday <= $matchday AND m.goals_home = b.goals_home AND
+ m.goals_guest = b.goals_guest AND m.status IN (2,3)
+ GROUP BY b.user_id
+ ORDER BY hits DESC
+ ";
+ $result = $db->sql_query($sql);
+
+ $last_count_hits = -1;
+ $count_user = 0;
+ $userid_ary = array();
+ $hits = array();
+ $rank = array();
+ $equal_rank = array();
+ $win_pos_most_hits = array();
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $userid_ary[$count_user] = $row['userid'];
+ $hits[$count_user] = $row['hits'];
+ if ($count_user == 0)
+ {
+ $rank[$count_user] = 1;
+ $equal_rank[$rank[$count_user]] = 1;
+ $win_pos_most_hits[$rank[$count_user]] = $win_most_hits;
+ }
+ else
+ {
+ if ( $row['hits'] != $last_count_hits)
+ {
+ $rank[$count_user] = $count_user + 1;
+ $equal_rank[$rank[$count_user]] = 1;
+ $win_pos_most_hits[$rank[$count_user]] = 0;
+ }
+ else
+ {
+ $rank[$count_user] = $rank[$count_user-1];
+ $equal_rank[$rank[$count_user]] += 1;
+ }
+ }
+ $last_count_hits = $row['hits'];
+ $count_user++;
+ }
+ $db->sql_freeresult($result);
+ $win_user_most_hits = array();
+ for($i = 0; $i < $count_user; $i++)
+ {
+ $win_user_most_hits[$userid_ary[$i]]['direct_hit'] = $hits[$i];
+ if ($matchday == $last_matchday)
+ {
+ if (round($win_pos_most_hits[$rank[$i]]/$equal_rank[$rank[$i]],2) <> 0)
+ {
+ $win_user_most_hits[$userid_ary[$i]]['win'] = round($win_pos_most_hits[$rank[$i]]/$equal_rank[$rank[$i]],2);
+ }
+ else
+ {
+ $win_user_most_hits[$userid_ary[$i]]['win'] = 0;
+ }
+ }
+ else
+ {
+ $win_user_most_hits[$userid_ary[$i]]['win'] = 0;
+ }
+ }
+ if ($count_user > 0)
+ {
+ return $win_user_most_hits;
+ }
+ else
+ {
+ $win_user_most_hits[0]['win'] = 0;
+ return $win_user_most_hits;
+ }
+}
+
+/**
+* return win most hits away in array.
+*/
+function win_user_most_hits_away($season, $league, $matchday)
+{
+ global $db, $lang;
+
+ $sql = 'SELECT * FROM ' . FOOTB_LEAGUES . " WHERE season = $season AND league = $league";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $win_most_hits_away = $row['win_result_02'];
+ $last_matchday = $row['matchdays'];
+ $db->sql_freeresult($result);
+ }
+
+ $sql = 'SELECT
+ b.user_id AS userid,
+ SUM(IF(m.goals_home <= m.goals_guest,1,0)) AS hits_away
+ FROM ' . FOOTB_MATCHES . ' AS m
+ LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = m.season AND b.league = m.league AND b.match_no = m.match_no)
+ WHERE m.season = $season AND m.league = $league AND m.matchday <= $matchday AND m.goals_home = b.goals_home AND
+ m.goals_guest = b.goals_guest AND m.status IN (2,3)
+ GROUP BY b.user_id
+ ORDER BY hits_away DESC
+ ";
+ $result = $db->sql_query($sql);
+
+ $last_hits_away = -1;
+ $count_user = 0;
+ $userid_ary = array();
+ $hits_away = array();
+ $rank = array();
+ $equal_rank = array();
+ $win_pos_most_hits_away = array();
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $userid_ary[$count_user] = $row['userid'];
+ $hits_away[$count_user] = $row['hits_away'];
+ if ($count_user == 0)
+ {
+ $rank[$count_user] = 1;
+ $equal_rank[$rank[$count_user]] = 1;
+ $win_pos_most_hits_away[$rank[$count_user]] = $win_most_hits_away;
+ }
+ else
+ {
+ if ( $row['hits_away'] != $last_hits_away)
+ {
+ $rank[$count_user] = $count_user + 1;
+ $equal_rank[$rank[$count_user]] = 1;
+ $win_pos_most_hits_away[$rank[$count_user]] = 0;
+ }
+ else
+ {
+ $rank[$count_user] = $rank[$count_user-1];
+ $equal_rank[$rank[$count_user]] += 1;
+ }
+ }
+ $last_hits_away = $row['hits_away'];
+ $count_user++;
+ }
+ $db->sql_freeresult($result);
+ $win_user_most_hits_away = array();
+ for($i = 0; $i < $count_user; $i++)
+ {
+ $win_user_most_hits_away[$userid_ary[$i]]['direct_hit'] = $hits_away[$i];
+ if ($matchday == $last_matchday)
+ {
+ if (round($win_pos_most_hits_away[$rank[$i]]/$equal_rank[$rank[$i]],2) <> 0)
+ {
+ $win_user_most_hits_away[$userid_ary[$i]]['win'] = round($win_pos_most_hits_away[$rank[$i]]/$equal_rank[$rank[$i]],2);
+ }
+ else
+ {
+ $win_user_most_hits_away[$userid_ary[$i]]['win'] = 0;
+ }
+ }
+ else
+ {
+ $win_user_most_hits_away[$userid_ary[$i]]['win'] = 0;
+ }
+ }
+ if ($count_user > 0)
+ {
+ return $win_user_most_hits_away;
+ }
+ else
+ {
+ $win_user_most_hits_away[0]['win'] = 0;
+ return $win_user_most_hits_away;
+ }
+}
+
+/**
+* return colorstyle to status.
+*/
+function color_style($status)
+{
+ switch ($status)
+ {
+ case 2:
+ $colorstyle = 'color_provisionally';
+ break;
+ case 3:
+ $colorstyle = 'color_finally';
+ break;
+ case 4:
+ case 5:
+ case 6:
+ $colorstyle = 'color_not_rated';
+ break;
+ default:
+ $colorstyle = '';
+ break;
+ }
+ return $colorstyle;
+}
+
+
+/**
+* color text on match status.
+*/
+function color_match($text, $status)
+{
+ switch($status)
+ {
+ case 2:
+ $colormatch = "". $text. '';
+ break;
+ case 3:
+ $colormatch = "". $text. '';
+ break;
+ case 4:
+ case 5:
+ case 6:
+ $colormatch = "". $text. '';
+ break;
+ default:
+ $colormatch = $text;
+ break;
+ }
+ return $colormatch;
+}
+
+/**
+* color text on points status.
+*/
+function color_points($text, $status)
+{
+ switch($status)
+ {
+ case 2:
+ $color_points = "". $text. '';
+ break;
+ case 3:
+ $color_points = "". $text. '';
+ break;
+ default:
+ $color_points = $text;
+ break;
+ }
+ return $color_points;
+}
+
+/**
+* get table order on teams with equal points.
+*/
+function get_order_team_compare($team_ary, $season, $league, $group, $ranks, $matchday = 999, $first = true)
+{
+ global $db;
+ $sql = "
+ SELECT
+ t.*,
+ SUM(IF(m.team_id_home = t.team_id,
+ IF(goals_home + 0 > goals_guest, 3, IF(goals_home = goals_guest, 1, 0)),
+ IF(goals_home + 0 < goals_guest, 3, IF(goals_home = goals_guest, 1, 0))
+ )
+ ) - IF(t.team_id = 20 AND t.season = 2011 AND $matchday > 7, 2, 0) AS points,
+ SUM(IF(m.team_id_home = t.team_id, goals_home - goals_guest, goals_guest - goals_home)) AS goals_diff,
+ SUM(IF(m.team_id_home = t.team_id, goals_home, goals_guest)) AS goals
+ FROM " . FOOTB_TEAMS . ' AS t
+ LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league AND
+ (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id) AND m.group_id = t.group_id)
+ WHERE t.season = $season
+ AND t.league = $league
+ AND m.matchday <= $matchday
+ AND m.status IN (2,3,5,6)
+ AND m.group_id = '$group'
+ AND (m.team_id_home='" . implode("' OR m.team_id_home='", $team_ary) . "')
+ AND (m.team_id_guest='" . implode("' OR m.team_id_guest='", $team_ary) . "')
+ GROUP BY t.team_id
+ ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC";
+
+ $result = $db->sql_query($sql);
+
+ $tmp = array();
+ $rank_ary = array();
+ $rank = 0;
+ $last_points = 0;
+ $last_goals_diff = 0;
+ $last_goals = 0;
+
+ while( $row = $db->sql_fetchrow($result))
+ {
+ if ($last_points <> $row['points'] OR $last_goals_diff <> $row['goals_diff'] OR $last_goals <> $row['goals'])
+ {
+ $rank++;
+ }
+ $rank_ary[$rank][]=$row['team_id'];
+ $last_points = $row['points'];
+ $last_goals_diff = $row['goals_diff'];
+ $last_goals = $row['goals'];
+ }
+ foreach($rank_ary as $rank => $teams)
+ {
+ if(count($teams) > 1)
+ {
+ if ($first)
+ {
+ // Compare teams with equal ranks
+ $teams = get_order_team_compare($teams, $season, $league, $group, $ranks, $matchday, false);
+ }
+ else
+ {
+ // Second compare is still equal, so look on total rank
+ $teams = array_intersect($ranks, $teams);
+ }
+ }
+ foreach($teams as $key => $team)
+ {
+ $tmp[] = $team;
+ }
+ }
+ return (sizeof($tmp) == 0) ? $team_ary: $tmp;
+}
+
+/**
+* determine team items from formula.
+*/
+function get_team($season, $league, $matchnumber, $field, $formula)
+{
+ global $db, $lang, $user;
+ $first_letter = substr($formula, 0, 1);
+ $para = substr($formula, 2, 7);
+ $para_ary = explode(";",$para);
+
+ switch($first_letter)
+ {
+ case '3':
+ // 3. Place Euro 2106
+ $groups = substr($para_ary[0], 0, 5);
+ $sql = '
+ SELECT
+ SUM(1) AS matches,
+ SUM(IF(m.status = 3, 1, 0)) AS played
+ FROM ' . FOOTB_MATCHES . " AS m
+ WHERE m.season = $season AND m.league = $league AND m.group_id <> ''
+ GROUP BY m.group_id
+ ";
+ $result = $db->sql_query($sql);
+
+ if ( $row = $db->sql_fetchrow($result))
+ {
+ if ($row['matches'] == $row['played'])
+ {
+ $rank = 0;
+ // Get table-information
+ $sql = "SELECT
+ t.*,
+ SUM(1) AS matches,
+ SUM(IF((m.team_id_home = t.team_id), IF(goals_home + 0 > goals_guest, 1, 0), IF(goals_home + 0 < goals_guest, 1, 0))) AS win,
+ SUM(IF(goals_home = goals_guest, 1, 0)) AS draw,
+ SUM(IF((m.team_id_home = t.team_id), IF(goals_home + 0 < goals_guest, 1, 0), IF(goals_home + 0 > goals_guest, 1, 0))) AS lost,
+ SUM(IF(m.team_id_home = t.team_id,
+ IF(goals_home + 0 > goals_guest, 3, IF(goals_home = goals_guest, 1, 0)),
+ IF(goals_home + 0 < goals_guest, 3, IF(goals_home = goals_guest, 1, 0))
+ )
+ ) AS points,
+ SUM(IF(m.team_id_home = t.team_id, goals_home - goals_guest , goals_guest - goals_home)) AS goals_diff,
+ SUM(IF(m.team_id_home = t.team_id, goals_home , goals_guest)) AS goals,
+ SUM(IF(m.team_id_home = t.team_id, goals_guest , goals_home)) AS goals_against
+ FROM " . FOOTB_TEAMS . ' AS t
+ LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league
+ AND (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id) AND m.group_id = t.group_id)
+ WHERE t.season = $season
+ AND t.league = $league
+ AND m.status IN (2,3,5,6)
+ GROUP BY t.team_id
+ ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC, t.team_name ASC";
+
+ $result = $db->sql_query($sql);
+
+ $table_ary = array();
+ $points_ary = array();
+ $ranks_ary = array();
+ $third_team = array();
+ $third_group = array();
+ $points3 = array();
+ $diff3 = array();
+ $goals3 = array();
+ $rank = 0;
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $rank++;
+ $table_ary[$row['team_id']] = $row;
+ $points_ary[$row['group_id']][$row['points']][]=$row['team_id'];
+ $ranks_ary[] = $row['team_id'];
+ }
+
+ foreach($points_ary as $group_id => $points)
+ {
+ $rank = 0;
+
+ //sort on points descending
+ krsort($points);
+
+ foreach($points as $point => $teams)
+ {
+ if(count($teams) > 1)
+ {
+ // Compare teams with equal points
+ $teams = get_order_team_compare($teams, $season, $league, $group_id, $ranks_ary);
+ }
+ foreach($teams as $key => $team)
+ {
+ $row = $table_ary[$team];
+ $rank++;
+ if ($rank == 3)
+ {
+ $points3[$team] = $row['points'];
+ $diff3[$team] = $row['goals_diff'];
+ $goals3[$team] = $row['goals'];
+ $third_team[$team]= $team;
+ $third_group[$team]= $row['group_id'];
+ }
+ }
+ }
+ }
+ // Sort 3. Place on points, diff, goals
+ array_multisort($points3, SORT_DESC, $diff3, SORT_DESC, $goals3, SORT_DESC, $third_team, $third_group);
+ $qualified_groups = array();
+ for($i = 0; $i < 4; $i++)
+ {
+ $qualified_groups[$i] = $third_group[$i];
+ $team_of[$third_group[$i]] = $third_team[$i];
+ }
+ asort($qualified_groups);
+ $qualified_groups_string = '';
+ foreach($qualified_groups as $key => $letter)
+ {
+ $qualified_groups_string .= $letter;
+ }
+ $modus = array('ABCD' => 'CDAB', 'ABCE' => 'CABE', 'ABCF' => 'CABF', 'ABDE' => 'DABE', 'ABDF' => 'DABF',
+ 'ABEF' => 'EABF', 'ACDE' => 'CDAE', 'ACDF' => 'CDAF', 'ACEF' => 'CAFE', 'ADEF' => 'DAFE',
+ 'BCDE' => 'CDBE', 'BCDF' => 'CDBF', 'BCEF' => 'ECBF', 'BDEF' => 'EDBF', 'CDEF' => 'CDFE');
+ $form_para = array('CDE', 'ACD', 'ABF', 'BEF');
+ $mode = $modus[$qualified_groups_string];
+ for($i = 0; $i < 4; $i++)
+ {
+ $team = $team_of[substr($mode, $i, 1)];
+
+ $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET team_id_guest = $team WHERE season = $season AND league = $league AND formula_guest = '3 $form_para[$i]'";
+ $resultup = $db->sql_query($sqlup);
+ $sqlup = 'UPDATE ' . FOOTB_TEAMS . ' SET matchday = (SELECT max(matchday) FROM ' . FOOTB_MATCHES . "
+ WHERE season = $season AND league = $league AND (team_id_home= $team OR team_id_guest = $team))
+ WHERE season = $season AND league = $league AND team_id = $team";
+ $resultup = $db->sql_query($sqlup);
+ if ($form_para[$i] == $groups)
+ {
+ $team_id = $team;
+ $row = $table_ary[$team];
+ $team_symbol = $row['team_symbol'];
+ $team_name = $row['team_name'];
+ $team_name_short = $row['team_name_short'];
+ }
+ }
+ return $team_symbol . '#' . $team_id . '#' . $team_name . '#' . $team_name_short;
+
+ }
+ else
+ {
+ return '#0#' . '3. ' . sprintf($user->lang['GROUP']) . ' ' . $groups . '#' . '3. ' . sprintf($user->lang['GROUP']) . ' ' . $groups;
+ }
+ }
+ else
+ {
+ return '#0#' . '3. ' . sprintf($user->lang['GROUP']) . ' ' . $groups . '#' . '3. ' . sprintf($user->lang['GROUP']) . ' ' . $groups;
+ }
+ break;
+ case 'D':
+ // Drawing
+ return '#0#' . sprintf($user->lang['DRAWING']) . '#' . sprintf($user->lang['DRAWING']);
+ break;
+ case 'G':
+ // GROUP
+ $group = substr($para_ary[0], 0, 1);
+ $place = substr($para_ary[0], 1, 1);
+ $sql = '
+ SELECT
+ SUM(1) AS matches,
+ SUM(IF(m.status = 3, 1, 0)) AS played
+ FROM ' . FOOTB_MATCHES . " AS m
+ WHERE m.season = $season AND m.league = $league AND m.group_id = '$group'
+ GROUP BY m.group_id
+ ";
+ $result = $db->sql_query($sql);
+
+ if ( $row = $db->sql_fetchrow($result))
+ {
+ if ($row['matches'] == $row['played'])
+ {
+ $rank = 0;
+ $sql = '
+ SELECT
+ t.*,
+ SUM(IF(m.team_id_home = t.team_id,
+ IF(goals_home + 0 > goals_guest, 3, IF(goals_home = goals_guest, 1, 0)),
+ IF(goals_home + 0 < goals_guest, 3, IF(goals_home = goals_guest, 1, 0))
+ )
+ ) AS points,
+ SUM(IF(m.team_id_home = t.team_id, goals_home - goals_guest, goals_guest - goals_home)) AS goals_diff,
+ SUM(IF(m.team_id_home = t.team_id, goals_home, goals_guest)) AS goals,
+ SUM(IF(m.team_id_home = t.team_id, goals_guest, goals_home)) AS goals_get
+ FROM ' . FOOTB_TEAMS . ' AS t
+ LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league AND
+ (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id) AND m.group_id = t.group_id)
+ WHERE t.season = $season AND t.league = $league AND m.group_id = '$group'
+ GROUP BY t.team_id
+ ORDER BY points DESC, goals_diff DESC, goals DESC
+ ";
+ $result = $db->sql_query($sql);
+ $table_ary = array();
+ $points_ary = array();
+ $ranks_ary = array();
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $table_ary[$row['team_id']] = $row;
+ $points_ary[$row['points']][]=$row['team_id'];
+ $ranks_ary[] = $row['team_id'];
+ }
+ $db->sql_freeresult($result);
+
+ //sort on points descending
+ krsort($points_ary);
+
+ foreach($points_ary as $point => $teams)
+ {
+ if(count($teams) > 1)
+ {
+ // Compare teams with equal points
+ $teams = get_order_team_compare($teams, $season, $league, $group, $ranks_ary);
+ }
+ foreach($teams as $key => $team)
+ {
+ $row = $table_ary[$team];
+ $rank++;
+ if ($rank == $place)
+ {
+ $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $team WHERE season = $season AND league = $league AND match_no = $matchnumber";
+ $resultup = $db->sql_query($sqlup);
+ $sqlup = 'UPDATE ' . FOOTB_TEAMS . ' SET matchday = (SELECT max(matchday) FROM ' . FOOTB_MATCHES . "
+ WHERE season = $season AND league = $league AND (team_id_home= $team OR team_id_guest = $team))
+ WHERE season = $season AND league = $league AND team_id = $team";
+ $resultup = $db->sql_query($sqlup);
+ return $row['team_symbol'] . '#' . $team . '#' . $row['team_name'] . '#' . $row['team_name_short'];
+ }
+ }
+ }
+ }
+ else
+ {
+ return '#0#' . $place . '. ' . sprintf($user->lang['GROUP']) . ' ' . $group . '#' . $place . '. ' . sprintf($user->lang['GROUP']) . ' ' . $group;
+ }
+ }
+ else
+ {
+ return '#0#' . $place . '. ' . sprintf($user->lang['GROUP']) . ' ' . $group . '#' . $place . '. ' . sprintf($user->lang['GROUP']) . ' ' . $group;
+ }
+ break;
+ case 'L':
+ // Looser
+ switch(sizeof($para_ary))
+ {
+ case 1:
+ $sql = 'SELECT
+ m.status,
+ m.team_id_home AS home_id,
+ m.team_id_guest AS guest_id,
+ t1.team_symbol AS home_symbol,
+ t2.team_symbol AS guest_symbol,
+ t1.team_name AS home_name,
+ t2.team_name AS guest_name,
+ t1.team_name_short AS home_sname,
+ t2.team_name_short AS guest_sname,
+ m.goals_overtime_home,
+ m.goals_overtime_guest,
+ m.goals_home,
+ m.goals_guest
+ FROM ' . FOOTB_MATCHES . ' AS m
+ LEFT JOIN ' . FOOTB_TEAMS . ' AS t1 ON (t1.season = m.season AND t1.league = m.league AND t1.team_id = m.team_id_home)
+ LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = m.season AND t2.league = m.league AND t2.team_id = m.team_id_guest)
+ WHERE m.season = $season AND m.league = $league AND m.match_no = $para_ary[0]";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ if ((3 == $row['status']) OR (6 == $row['status']))
+ {
+ if ($row['goals_home'] > $row['goals_guest'] OR $row['goals_overtime_home'] > $row['goals_overtime_guest'])
+ {
+ $new_id = $row['guest_id'];
+ $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
+ $resultup = $db->sql_query($sqlup);
+ return $row['guest_symbol'] . '#' . $row['guest_id'] . '#' . $row['guest_name'] . '#' . $row['guest_sname'];
+ }
+ if ($row['goals_home'] < $row['goals_guest'] OR $row['goals_overtime_home'] < $row['goals_overtime_guest'])
+ {
+ $new_id = $row['home_id'];
+ $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
+ $resultup = $db->sql_query($sqlup);
+ return $row['home_symbol'] . '#' . $row['home_id'] . '#' . $row['home_name'] . '#' . $row['home_sname'];
+ }
+ }
+ else
+ {
+ return '#0#' . sprintf($user->lang['LOOSER_MATCH_NO']) . $para_ary[0] . '#' . sprintf($user->lang['LOOSER']) . ' ' . $para_ary[0];
+ }
+ }
+ break;
+ default:
+ return '#0#' . sprintf($user->lang['DRAWING']) . '#' . sprintf($user->lang['DRAWING']);
+ break;
+ }
+ break;
+ case 'W':
+ // Winner
+ switch(sizeof($para_ary))
+ {
+ case 1:
+ $sql = 'SELECT
+ m.status,
+ m.team_id_home AS home_id,
+ m.team_id_guest AS guest_id,
+ t1.team_symbol AS home_symbol,
+ t2.team_symbol AS guest_symbol,
+ t1.team_name AS home_name,
+ t2.team_name AS guest_name,
+ t1.team_name_short AS home_sname,
+ t2.team_name_short AS guest_sname,
+ m.goals_overtime_home,
+ m.goals_overtime_guest,
+ m.goals_home,
+ m.goals_guest
+ FROM ' . FOOTB_MATCHES . ' AS m
+ LEFT JOIN ' . FOOTB_TEAMS . ' AS t1 ON (t1.season = m.season AND t1.league = m.league AND t1.team_id = m.team_id_home)
+ LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = m.season AND t2.league = m.league AND t2.team_id = m.team_id_guest)
+ WHERE m.season = $season AND m.league = $league AND m.match_no = $para_ary[0]";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ if ((3 == $row['status']) OR (6 == $row['status']))
+ {
+ if ($row['goals_home'] > $row['goals_guest'] OR $row['goals_overtime_home'] > $row['goals_overtime_guest'])
+ {
+ $new_id = $row['home_id'];
+ $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
+ $resultup = $db->sql_query($sqlup);
+ return $row['home_symbol'] . '#' . $row['home_id'] . '#' . $row['home_name'] . '#' . $row['home_sname'];
+ }
+ if ($row['goals_home'] < $row['goals_guest'] OR $row['goals_overtime_home'] < $row['goals_overtime_guest'])
+ {
+ $new_id = $row['guest_id'];
+ $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
+ $resultup = $db->sql_query($sqlup);
+ return $row['guest_symbol'] . '#' . $row['guest_id'] . '#' . $row['guest_name'] . '#' . $row['guest_sname'];
+ }
+ }
+ else
+ {
+ if ($row['home_sname'] != '' AND $row['guest_sname'] != '')
+ {
+ return '#0#' . $row['home_sname'] . ' / ' . $row['guest_sname'] . '#' . $row['home_sname'] . '+' . $row['guest_sname'];
+ }
+ else
+ {
+ return '#0#' . sprintf($user->lang['WINNER_MATCH_NO']) . $para_ary[0] . '#' . sprintf($user->lang['WINNER']) . ' ' . $para_ary[0];
+ }
+ }
+ }
+ break;
+ case 2:
+
+ $sql = 'SELECT
+ m.status,
+ m.team_id_home AS home_id,
+ m.team_id_guest AS guest_id,
+ t1.team_symbol AS home_symbol,
+ t2.team_symbol AS guest_symbol,
+ t1.team_name AS home_name,
+ t2.team_name AS guest_name,
+ t1.team_name_short AS home_sname,
+ t2.team_name_short AS guest_sname,
+ m.goals_overtime_home,
+ m.goals_overtime_guest,
+ m.goals_home,
+ m.goals_guest
+ FROM ' . FOOTB_MATCHES . ' AS m
+ LEFT JOIN ' . FOOTB_TEAMS . ' AS t1 ON (t1.season = m.season AND t1.league = m.league AND t1.team_id = m.team_id_home)
+ LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = m.season AND t2.league = m.league AND t2.team_id = m.team_id_guest)
+ WHERE m.season = $season AND m.league = $league AND (m.match_no = $para_ary[0] OR m.match_no = $para_ary[1])
+ ORDER BY m.match_no ASC";
+ $result = $db->sql_query($sql);
+
+ if ($firstleg = $db->sql_fetchrow($result))
+ {
+ if ($replay = $db->sql_fetchrow($result))
+ {
+ if (((3 == $firstleg['status']) OR (6 == $firstleg['status'])) AND ((3 == $replay['status']) OR (6 == $replay['status'])))
+ {
+ if ($firstleg['home_id'] == $replay['guest_id'] AND $firstleg['guest_id'] == $replay['home_id'])
+ {
+ if ($firstleg['goals_home'] + $replay['goals_guest'] > $firstleg['goals_guest'] + $replay['goals_home'] OR $replay['goals_overtime_guest'] > $replay['goals_overtime_home'] OR
+ ($firstleg['goals_home'] + $replay['goals_guest'] == $firstleg['goals_guest'] + $replay['goals_home'] AND $replay['goals_guest'] > $firstleg['goals_guest']))
+ {
+ $new_id = $firstleg['home_id'];
+ $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
+ $resultup = $db->sql_query($sqlup);
+ return $firstleg['home_symbol'] . '#' . $firstleg['home_id'] . '#' . $firstleg['home_name'] . '#' . $firstleg['home_sname'];
+ }
+ if ($firstleg['goals_home'] + $replay['goals_guest'] < $firstleg['goals_guest'] + $replay['goals_home'] OR $replay['goals_overtime_guest'] < $replay['goals_overtime_home'] OR
+ ($firstleg['goals_home'] + $replay['goals_guest'] == $firstleg['goals_guest'] + $replay['goals_home'] AND $firstleg['goals_guest'] > $replay['goals_guest']))
+ {
+ $new_id = $firstleg['guest_id'];
+ $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
+ $resultup = $db->sql_query($sqlup);
+ return $firstleg['guest_symbol'] . '#' . $firstleg['guest_id'] . '#' . $firstleg['guest_name'] . '#' . $firstleg['guest_sname'];
+ }
+ }
+ else if ($firstleg['home_id'] == $replay['home_id'] AND $firstleg['guest_id'] == $replay['guest_id'])
+ {
+ if ($firstleg['goals_home'] + $replay['goals_home'] <= $firstleg['goals_guest'] + $replay['goals_guest'] OR $replay['goals_overtime_home'] < $replay['goals_overtime_guest'])
+ {
+ $new_id = $firstleg['guest_id'];
+ $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
+ $resultup = $db->sql_query($sqlup);
+ return $firstleg['guest_symbol'] . '#' . $firstleg['guest_id'] . '#' . $firstleg['guest_name'] . '#' . $firstleg['guest_sname'];
+ }
+ else
+ {
+ $new_id = $firstleg['home_id'];
+ $sqlup = 'UPDATE ' . FOOTB_MATCHES . " SET $field = $new_id WHERE season = $season AND league = $league AND match_no = $matchnumber";
+ $resultup = $db->sql_query($sqlup);
+ return $firstleg['home_symbol'] . '#' . $firstleg['home_id'] . '#' . $firstleg['home_name'] . '#' . $firstleg['home_sname'];
+ }
+ }
+ else
+ {
+ return '#0#' . sprintf($user->lang['MATCH_ERROR']) . '#' . sprintf($user->lang['FORMULA']) . '!';
+ }
+ }
+ else
+ {
+ if ($firstleg['home_sname'] != '' AND $firstleg['guest_sname'] != '')
+ {
+ return '#0#' . $firstleg['home_sname'] . ' / ' . $firstleg['guest_sname'] . '#' . $firstleg['home_sname'] . '+' . $firstleg['guest_sname'];
+ }
+ else
+ {
+ return '#0#' . sprintf($user->lang['WINNER_MATCH_NO']) . ' ' . $para_ary[0] . '+' . $para_ary[1] . '#S. ' . $para_ary[0] . '+' . $para_ary[1];
+ }
+ }
+ }
+ else
+ {
+ return '#0#' . sprintf($user->lang['SEC_LEG_ERROR']) . '#' . sprintf($user->lang['FORMULA']) . '!';
+ }
+ }
+ else
+ {
+ return '#0#' . sprintf($user->lang['FIRSTLEG_ERROR']) . '#' . sprintf($user->lang['FORMULA']) . '!';
+ }
+ break;
+ default:
+ return '#0#Los#Los';
+ break;
+ }
+ break;
+ default:
+ return '#0#' . sprintf($user->lang['DRAWING']) . '#' . sprintf($user->lang['DRAWING']);
+ break;
+ }
+}
+
+/**
+* KO-matches: Set team to next round.
+*/
+function ko_next_round($season, $league, $matchday_from, $matchday_to, $matchday_new)
+{
+ global $db, $user;
+ $sql = 'SELECT
+ t.team_id,
+ t.team_name,
+ SUM(1) AS matches,
+ SUM(IF(m.team_id_home = t.team_id,
+ IF(goals_overtime_home + goals_overtime_guest > 0,
+ goals_overtime_home,
+ goals_home
+ ),
+ IF(goals_overtime_home + goals_overtime_guest > 0,
+ goals_overtime_guest,
+ goals_guest
+ )
+ )
+ ) AS goals,
+ SUM(IF(m.team_id_home = t.team_id,
+ IF(goals_overtime_home + goals_overtime_guest > 0,
+ goals_overtime_guest,
+ goals_guest
+ ),
+ IF(goals_overtime_home + goals_overtime_guest > 0,
+ goals_overtime_home,
+ goals_home
+ )
+ )
+ ) AS goals_get,
+ SUM(IF(m.team_id_home = t.team_id,
+ 0,
+ IF(goals_overtime_home + goals_overtime_guest > 0,
+ goals_overtime_guest,
+ goals_guest
+ )
+ )
+ ) AS goals_away,
+ SUM(IF(m.team_id_home = t.team_id,
+ IF(goals_overtime_home + goals_overtime_guest > 0,
+ goals_overtime_guest,
+ goals_guest
+ ),
+ 0
+ )
+ ) AS goals_away_opp
+ FROM ' . FOOTB_TEAMS . ' AS t
+ LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league AND (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id))
+ WHERE t.season = $season AND t.league = $league AND m.matchday >= $matchday_from AND m.matchday <= $matchday_to AND m.status IN (3,6)
+ GROUP BY t.team_id";
+ $result = $db->sql_query($sql);
+
+ $message = sprintf($user->lang['KO_NEXT']) . ':
';
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if (($matchday_to == $matchday_from AND $row['matches'] == 1) OR ($matchday_to != 0 AND $row['matches'] == 2))
+ {
+ if (($row['goals'] > $row['goals_get']) OR
+ (($row['goals'] == $row['goals_get']) AND ($row['goals_away'] > $row['goals_away_opp'])))
+ {
+ $team_id = $row['team_id'];
+ $sqlup = 'UPDATE ' . FOOTB_TEAMS . " SET matchday = $matchday_new WHERE season = $season AND league = $league AND team_id = $team_id";
+ $resultup = $db->sql_query($sqlup);
+ $message .= $row['team_name'] . '
';
+ }
+ }
+ }
+ $db->sql_freeresult($result);
+
+ $message .= '
';
+ return $message;
+}
+
+/**
+* KO-matches: Set groupleaders next round.
+*/
+function ko_group_next_round($season, $league, $matchday_from, $matchday_to, $matchday_new, $rank, $move_rank, $move_league, $move_matchday)
+{
+ global $db, $user;
+ $sql = '
+ SELECT
+ t.*,
+ SUM(1) AS matches
+ FROM ' . FOOTB_TEAMS . ' AS t
+ LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league AND (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id) AND m.group_id = t.group_id)
+ WHERE t.season = $season AND t.league = $league AND m.matchday >= $matchday_from AND m.matchday <= $matchday_to AND m.status NOT IN (3,6)
+ GROUP BY t.team_id
+ ";
+ $result = $db->sql_query($sql);
+ $rowset = $db->sql_fetchrowset($result);
+ $db->sql_freeresult($result);
+
+ if (sizeof($rowset) > 0)
+ {
+ $message = sprintf($user->lang['NO_KO_NEXT']);
+ $messag_moved = '';
+ }
+ else
+ {
+ $sql = '
+ SELECT
+ t.*,
+ SUM(1) AS matches,
+ SUM(IF((m.team_id_home = t.team_id), IF(goals_home + 0 > goals_guest, 1, 0), IF(goals_home + 0 < goals_guest, 1, 0))) AS win,
+ SUM(IF(goals_home = goals_guest, 1, 0)) AS draw,
+ SUM(IF((m.team_id_home = t.team_id), IF(goals_home + 0 < goals_guest, 1, 0), IF(goals_home + 0 > goals_guest, 1, 0))) AS lose,
+ SUM(IF(m.team_id_home = t.team_id,
+ IF(goals_home + 0 > goals_guest,
+ 3,
+ IF(goals_home = goals_guest,
+ 1,
+ 0
+ )
+ ),
+ IF(goals_home + 0 < goals_guest,
+ 3,
+ IF(goals_home = goals_guest,
+ 1,
+ 0
+ )
+ )
+ )
+ ) AS points,
+ SUM(IF(m.team_id_home = t.team_id, goals_home - goals_guest, goals_guest - goals_home)) AS goal_diff,
+ SUM(IF(m.team_id_home = t.team_id, goals_home, goals_guest)) AS goals,
+ SUM(IF(m.team_id_home = t.team_id, goals_guest, goals_home)) AS goals_get
+ FROM ' . FOOTB_TEAMS . ' AS t
+ LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = t.season AND m.league = t.league AND (m.team_id_home = t.team_id OR m.team_id_guest = t.team_id) AND m.group_id = t.group_id)
+ WHERE t.season = $season AND t.league = $league AND m.matchday >= $matchday_from AND m.matchday <= $matchday_to AND m.status IN (3,6)
+ GROUP BY t.team_id
+ ORDER BY group_id ASC,points DESC, goal_diff DESC, goals DESC
+ ";
+ $result = $db->sql_query($sql);
+
+ $table_ary = array();
+ $points_ary = array();
+ $ranks_ary = array();
+ while( $row = $db->sql_fetchrow($result))
+ {
+ $table_ary[$row['team_id']] = $row;
+ $points_ary[$row['group_id']][$row['points']][]=$row['team_id'];
+ $ranks_ary[] = $row['team_id'];
+ }
+
+ $message = sprintf($user->lang['KO_NEXT_CHECK']) . ':
';
+ $message .= sprintf($user->lang['KO_NEXT']) . ':
';
+ $messag_moved = '
' . sprintf($user->lang['KO_MOVED']) . ':
';
+ $group_id = 'XX';
+ foreach($points_ary as $group_id => $points)
+ {
+ $place = 1;
+ foreach($points as $point => $teams)
+ {
+ if(count($teams) > 1)
+ {
+ // Compare teams with equal points
+ $teams = get_order_team_compare($teams, $season, $league, $group_id, $ranks_ary);
+ }
+ foreach($teams as $key => $team_id)
+ {
+ $row = $table_ary[$team_id];
+
+ if ($place <= $rank)
+ {
+ $sqlup = 'UPDATE ' . FOOTB_TEAMS . " SET matchday = $matchday_new WHERE season = $season AND league = $league AND team_id = $team_id";
+ $resultup = $db->sql_query($sqlup);
+ $message .= $row['team_name'] . '
';
+ }
+ if ($move_rank > 0 AND $move_league > 0 AND $place == $move_rank)
+ {
+ $team_name = $row['team_name'];
+ $short_name = $row['team_name_short'];
+ $team_sign = $row['team_symbol'];
+ $sqlinsert = 'INSERT INTO ' . FOOTB_TEAMS . " VALUES($season, $move_league, $team_id, '$team_name', '$short_name', '$team_sign', '', $move_matchday)";
+ $resultinsert = $db->sql_query($sqlinsert);
+ $messag_moved .= $row['team_name'] . '
';
+ }
+ $place++;
+ }
+ }
+ }
+ }
+ $db->sql_freeresult($result);
+
+ $message .= '
';
+ return $message. $messag_moved;
+}
+
+/**
+* return SQL statement part to calculate points depending to mode.
+*/
+function select_points($creator = 'm', $sum = false)
+{
+ global $league_info;
+
+ $points_result = $league_info['points_result'];
+ $points_tendency = $league_info['points_tendency'];
+ $points_diff = $league_info['points_diff'];
+
+ switch ($league_info['points_mode'])
+ {
+ // hit = points_result
+ // right tendency (not draw) = points_result - difference between bet und result but minimal points_tendency
+ // right tendency (draw) = points_result - difference between bet goals home und result goals home
+ case 1:
+ $select_part = ($sum ? "SUM(IF(b.goals_home <> '' AND b.goals_guest <> ''," : 'IF(((m.status = 2) OR (m.status = 3)),') .
+ "IF(b.goals_home <> '' AND b.goals_guest <> '',
+ IF((b.goals_home + 0 < b.goals_guest) <> ($creator.goals_home + 0 < $creator.goals_guest)
+ OR (b.goals_home = b.goals_guest) <> ($creator.goals_home = $creator.goals_guest)
+ OR (b.goals_home + 0 > b.goals_guest) <> ($creator.goals_home + 0 > $creator.goals_guest),
+ " .($sum ? '0' : "''") . ",
+ IF((b.goals_home = $creator.goals_home) AND (b.goals_guest = $creator.goals_guest),
+ $points_result,
+ IF((b.goals_home = b.goals_guest),
+ $points_result - ABS(b.goals_home - $creator.goals_home),
+ IF((($points_result - ABS(b.goals_home - $creator.goals_home) - ABS(b.goals_guest - $creator.goals_guest)) < $points_tendency),
+ $points_tendency,
+ $points_result - ABS(b.goals_home - $creator.goals_home) - ABS(b.goals_guest - $creator.goals_guest)
+ )
+ )
+ )
+ ),
+ " .($sum ? '0' : "''") . '
+ ),
+ ' .($sum ? '0' : "''") . "
+ ) " .($sum ? ')' : '') . 'AS points';
+ break;
+ // hit = points_result,
+ // right tendency = points_result - difference between bet und result but minimal points_tendency
+ case 2:
+ $select_part = ($sum ? "SUM(IF(b.goals_home <> '' AND b.goals_guest <> ''," : 'IF(((m.status = 2) OR (m.status = 3)),') .
+ "IF(b.goals_home <> '' AND b.goals_guest <> '',
+ IF((b.goals_home + 0 < b.goals_guest) <> ($creator.goals_home + 0 < $creator.goals_guest)
+ OR (b.goals_home = b.goals_guest) <> ($creator.goals_home = $creator.goals_guest)
+ OR (b.goals_home + 0 > b.goals_guest) <> ($creator.goals_home + 0 > $creator.goals_guest),
+ " .($sum ? '0' : "''") . ",
+ IF((b.goals_home = $creator.goals_home) AND (b.goals_guest = $creator.goals_guest),
+ $points_result,
+ IF((b.goals_home = b.goals_guest),
+ $points_result - ABS(b.goals_home - $creator.goals_home) - ABS(b.goals_guest - $creator.goals_guest),
+ IF((($points_result - ABS(b.goals_home - $creator.goals_home) - ABS(b.goals_guest - $creator.goals_guest)) < $points_tendency),
+ $points_tendency,
+ $points_result - ABS(b.goals_home - $creator.goals_home) - ABS(b.goals_guest - $creator.goals_guest)
+ )
+ )
+ )
+ ),
+ " .($sum ? '0' : "''") . '
+ ),
+ ' .($sum ? '0' : "''") . "
+ ) " .($sum ? ')' : '') . 'AS points';
+ break;
+ // hit = points_result,
+ // right tendency = points_tendency
+ case 3:
+ $select_part = ($sum ? "SUM(IF(b.goals_home <> '' AND b.goals_guest <> ''," : 'IF(((m.status = 2) OR (m.status = 3)),') .
+ "IF(b.goals_home <> '' AND b.goals_guest <> '',
+ IF((b.goals_home + 0 < b.goals_guest) <> ($creator.goals_home + 0 < $creator.goals_guest)
+ OR (b.goals_home = b.goals_guest) <> ($creator.goals_home = $creator.goals_guest)
+ OR (b.goals_home + 0 > b.goals_guest) <> ($creator.goals_home + 0 > $creator.goals_guest),
+ " .($sum ? '0' : "''") . ",
+ IF((b.goals_home = $creator.goals_home) AND (b.goals_guest = $creator.goals_guest),
+ $points_result,
+ $points_tendency
+ )
+ ),
+ " .($sum ? '0' : "''") . '
+ ),
+ ' .($sum ? '0' : "''") . "
+ ) " .($sum ? ')' : '') . 'AS points';
+ break;
+ // hit = points_result,
+ // right goal-difference = points_diff,
+ // right tendency = points_tendency
+ case 4:
+ $select_part = ($sum ? "SUM(IF(b.goals_home <> '' AND b.goals_guest <> ''," : 'IF(((m.status = 2) OR (m.status = 3)),') .
+ "IF(b.goals_home <> '' AND b.goals_guest <> '',
+ IF((b.goals_home + 0 < b.goals_guest) <> ($creator.goals_home + 0 < $creator.goals_guest)
+ OR (b.goals_home = b.goals_guest) <> ($creator.goals_home = $creator.goals_guest)
+ OR (b.goals_home + 0 > b.goals_guest) <> ($creator.goals_home + 0 > $creator.goals_guest),
+ " .($sum ? '0' : "''") . ",
+ IF((b.goals_home = $creator.goals_home) AND (b.goals_guest = $creator.goals_guest),
+ $points_result,
+ IF((b.goals_home - b.goals_guest = $creator.goals_home - $creator.goals_guest),
+ $points_diff,
+ $points_tendency
+ )
+ )
+ ),
+ " .($sum ? '0' : "''") . '
+ ),
+ ' .($sum ? '0' : "''") . "
+ ) " .($sum ? ')' : '') . 'AS points';
+ break;
+ // hit = points_result,
+ // right goal-difference (not draw) = points_diff,
+ // right tendency = points_tendency
+ case 5:
+ $select_part = ($sum ? "SUM(IF(b.goals_home <> '' AND b.goals_guest <> ''," : 'IF(((m.status = 2) OR (m.status = 3)),') .
+ "IF(b.goals_home <> '' AND b.goals_guest <> '',
+ IF((b.goals_home + 0 < b.goals_guest) <> ($creator.goals_home + 0 < $creator.goals_guest)
+ OR (b.goals_home = b.goals_guest) <> ($creator.goals_home = $creator.goals_guest)
+ OR (b.goals_home + 0 > b.goals_guest) <> ($creator.goals_home + 0 > $creator.goals_guest),
+ " .($sum ? '0' : "''") . ",
+ IF((b.goals_home = $creator.goals_home) AND (b.goals_guest = $creator.goals_guest),
+ $points_result,
+ IF(((b.goals_home - b.goals_guest = $creator.goals_home - $creator.goals_guest)
+ AND ($creator.goals_home <> $creator.goals_guest)) ,
+ $points_diff,
+ $points_tendency
+ )
+ )
+ ),
+ " .($sum ? '0' : "''") . '
+ ),
+ ' .($sum ? '0' : "''") . "
+ ) " .($sum ? ')' : '') . 'AS points';
+ break;
+ // hit = points_result,
+ // right tendency draw = points_diff,
+ // right tendency (not draw) = points_tendency
+ case 6:
+ $select_part = ($sum ? "SUM(IF(b.goals_home <> '' AND b.goals_guest <> ''," : 'IF(((m.status = 2) OR (m.status = 3)),') .
+ "IF(b.goals_home <> '' AND b.goals_guest <> '',
+ IF((b.goals_home + 0 < b.goals_guest) <> ($creator.goals_home + 0 < $creator.goals_guest)
+ OR (b.goals_home = b.goals_guest) <> ($creator.goals_home = $creator.goals_guest)
+ OR (b.goals_home + 0 > b.goals_guest) <> ($creator.goals_home + 0 > $creator.goals_guest),
+ " .($sum ? '0' : "''") . ",
+ IF((b.goals_home = $creator.goals_home) AND (b.goals_guest = $creator.goals_guest),
+ $points_result,
+ IF(((b.goals_home = b.goals_guest) AND ($creator.goals_home = $creator.goals_guest) ) ,
+ $points_diff,
+ $points_tendency
+ )
+ )
+ ),
+ " .($sum ? '0' : "''") . '
+ ),
+ ' .($sum ? '0' : "''") . "
+ ) " .($sum ? ')' : '') . 'AS points';
+ break;
+ }
+ return $select_part;
+}
?>
\ No newline at end of file
diff --git a/language/de/info_acp_football.php b/language/de/info_acp_football.php
index 3ce2857..f9531b7 100644
--- a/language/de/info_acp_football.php
+++ b/language/de/info_acp_football.php
@@ -1,205 +1,206 @@
- 'Fussball',
- 'ACP_FOOTBALL_MANAGEMENT' => 'Tipprunde-Verwalten',
- 'ACP_FOOTBALL_OPERATION' => 'Spielbetrieb',
- 'ACP_FOOTBALL_MANAGE' => 'Spielplan Verwaltung',
-
- 'ACP_FOOTBALL_CONFIGURATION' => 'Tipprunden-Konfiguration',
- 'ACP_FOOTBALL_SETTINGS' => 'Tipprunden-Einstellungen',
- 'ACP_FOOTBALL_SETTINGS_EXPLAIN' => 'Hier kannst du einige grundlegende Einstellungen der Tipprunde vornehmen, ihr einen passenden Namen und eine Beschreibung geben und, neben anderen Werten, die Standard-Einstellungen für die Anzeige anpassen. ',
-
- 'DISABLE_FOOTBALL' => 'Tipprunde deaktivieren',
- 'DISABLE_FOOTBALL_EXPLAIN' => 'Hiermit sperrst du die Tipprunde für alle Benutzer. Wenn du möchtest, kannst du eine kurze Nachricht (bis zu 255 Zeichen) angeben. ',
- 'DISPLAY_RANKS' => 'Anzahl angezeigter Tipper in den Übersichts-Ranglisten',
- 'DISPLAY_RANKS_EXPLAIN' => 'Limitiert die Anzeige der Spieltags- und Gesamtrangliste in der Hauptansicht. Die eigene Platzierung wird ggf. unten angehängt. ',
-
- 'FOOTBALL_CODE' => 'Tipprunden Code',
- 'FOOTBALL_CODE_EXPLAIN' => 'Zugangscode zur Tipprunde z.B. für Cronjobs. ',
- 'FOOTBALL_FULLSCREEN' => 'Tipprunden-Seiten im Fullscreen-Modus',
- 'FOOTBALL_FULLSCREEN_EXPLAIN' => 'Hiermit kannst Du, abweichend vom Forum, die Tipprundenseiten mit minimalen Seitenrändern anzeigen lassen. ',
- 'FOOTBALL_HEADER_ENABLE' => 'Header-Bild je Liga verwenden',
- 'FOOTBALL_HEADER_ENABLE_EXPLAIN' => 'Hiermit kannst Du festlegen, ob je Liga die zugehöriges Bild im Header angezeigt werden soll. ',
- 'FOOTBALL_INFO' => 'Tipprunden Information anzeigen',
- 'FOOTBALL_INFO_EXPLAIN' => 'Hiermit kannst Du eine kurze Information (bis zu 255 Zeichen) oberhalb der Tippdaten anzeigen lassen. ',
- 'FOOTBALL_NAME' => 'Name der Tipprunde',
- 'FOOTBALL_NAME_EXPLAIN' => 'Name der im Tipprunden-Menu verwendet wird, um zur Hauptseite zu gelangen. ',
- 'FOOTBALL_OVERRIDE_STYLE' => 'Style überschreiben',
- 'FOOTBALL_OVERRIDE_STYLE_EXPLAIN' => 'Verwendet für die Tipprunde immer den Standard-Tipprunden-Style. ',
- 'FOOTBALL_STYLE' => 'Standard Tipprunden Style',
- 'FOOTBALL_UPDATE_SOURCE' => 'Update Quelle',
- 'FOOTBALL_UPDATE_SOURCE_EXPLAIN' => 'Link zur Quelle des Updates. Falls leer, wird automatisch http://football.bplaced.net/football/xml/football_xml_season.php gewählt. ',
- 'FOOTBALL_UPDATE_CODE' => 'Update Code',
- 'FOOTBALL_UPDATE_CODE_EXPLAIN' => 'Nur mit diesem Code können Updates von dieser Seite heruntergeladen werden. ',
-
- 'GUEST_VIEW' => 'Tipprunde für Gäste sichtbar',
- 'GUEST_VIEW_EXPLAIN' => 'Soll die Tipprunde für Gäste sichtbar sein?',
-
- 'USER_VIEW' => 'Tipprunde nur für Teilnehmer sichtbar',
- 'USER_VIEW_EXPLAIN' => 'Soll die Tipprunde nur für Tipprunden-Teilnehmer sichtbar sein?',
-
- 'HOST_TIMEZONE' => 'Host Zeitzone',
- 'HOST_TIMEZONE_EXPLAIN' => 'Differenz zur Board Zeitzone wenn dein Host in einer anderen Zeitzone steht, damit die Tippabgabe korrekt funktioniert. ',
-
- 'LEFT_COLUMN' => 'Spaltenbreite Links in Pixeln',
- 'LEFT_COLUMN_EXPLAIN' => 'Optimale Breite 180 Pixel. Dieser Wert sollte nicht unterschritten werden. ',
-
- 'PREDICTION_LEAGUE' => 'Tipprunde',
-
- 'RIGHT_COLUMN' => 'Spaltenbreite Rechts in Pixeln',
- 'RIGHT_COLUMN_EXPLAIN' => 'Optimal 180 Pixel. Dieser Wert wird durch externe Einblendungen ggf. übersteuert. ',
-
- 'USERS_PAGE' => 'Tipper pro Seite',
- 'USERS_PAGE_EXPLAIN' => 'Anzahl der Tipper je Seite in der Hauptrangliste und Alle Tipps. ',
-
- 'WIN_NAME' => 'Gewinn Name (oder Währung)',
- 'WIN_NAME_EXPLAIN' => 'Der Name, der für die Gewinne in der Tipprunde angezeigt werden soll',
-
- 'ANNOUNCEMENT_TOPIC' => 'Release Ankündigung',
- 'CURRENT_VERSION' => 'Derzeitige Version',
- 'DOWNLOAD_LATEST' => 'Neueste Version herunterladen',
- 'LATEST_VERSION' => 'Neueste Version',
- 'NOT_UP_TO_DATE' => '%s ist nicht aktuell',
- 'RELEASE_ANNOUNCEMENT' => 'Ankündigungsthema',
- 'UP_TO_DATE' => '%s ist aktuell',
- 'FOOTBALL_VERSION_CHECK' => 'Football Prediction League Extension Version Check',
-
-));
-
-// Football Features
-$lang = array_merge($lang, array(
- 'ACP_FOOTBALL_FEATURES' => 'Tipprunden-Funktionalitäten',
- 'ACP_FOOTBALL_FEATURES_EXPLAIN' => 'Hier kannst du einige Funktionen der Tipprunde aktivieren bzw. deaktivieren',
-
- 'AUTO' => 'Auto',
-
- 'BANK' => 'Tipprunden Konto verwalten',
- 'BANK_EXPLAIN' => 'Sollen Tipprunden Konten mit Einsätzen und Gewinnen gepflegt werden?',
-
- 'FOOTBALL_SEASON_START' => 'Starte in Saison',
- 'FOOTBALL_SEASON_START_EXPLAIN' => 'Starte in dieser oder in der automatisch ermittelten Saison, wenn noch keine ausgewählt wurde. ',
-
- 'FOOTBALL_REMEMBER_ENABLE' => 'Cronjob für die Tipp-Erinnerungsmail aktivieren',
- 'FOOTBALL_REMEMBER_ENABLE_EXPLAIN' => 'Hier kannst Du angeben, ob 1 Tag vor Tippabgabe eine Erinnerungsmail versendet werden soll.',
-
- 'FOOTBALL_REMEMBER_NEXT_RUN' => 'Nächster Cronjoblauf für die Tipp-Erinnerungsmail',
- 'FOOTBALL_REMEMBER_NEXT_RUN_EXPLAIN'=> 'Hier kannst Du einstellen, wann der Cronjob für die Tipp-Erinnerungsmail frühestens wieder aufgerufen wird. Nach Ausführung wird der Cronjob für den Folgetag zur gleichen Uhrzeit neu eingeplant.',
-
- 'FOUNDER_DELETE' => 'Nur Gründungsmitglieder dürfen löschen',
- 'FOUNDER_DELETE_EXPLAIN' => 'Löschung von Spielplandaten wie Saisons, Ligen, Teams, Spieltage und Spielpläne nur auf Gründungsmitglieder beschränken. ',
-
- 'RESULTS_AT_TIME' => 'Eingabe endgültiger Spielergebnisse erst nach Spielende',
- 'RESULTS_AT_TIME_EXPLAIN' => 'Eingabe der endgültigen Spielergebnisse im Adminbereich erst nach Spielende freigeben. Die Eingabe von vorläufigen Spielergebnissen durch die Tipper ist hiervon unabhängig. ',
-
- 'SAME_ALLOWED' => 'Alle Tipps an einem Spieltag gleich',
- 'SAME_ALLOWED_EXPLAIN' => 'Identische Tipps (Oma-Tipps) bei allen Spielen eines Spieltags erlauben bzw. verbieten. ',
-
- 'ULT_POINTS' => 'Ultimate Points einbinden',
- 'ULT_POINTS_EXPLAIN' => 'Soll es möglich sein, die Punkte oder Gewinne in Ultimate Points verrechnen zu lassen? Dazu muss Ultimate Points installiert sein. ',
- 'ULT_POINTS_FACTOR' => 'Ultimate Points Faktor',
- 'ULT_POINTS_FACTOR_EXPLAIN' => 'Faktor mit dem die Punkte je Spieltag in Ultimate Points gutgeschrieben werden. ',
- 'UP_NONE' => 'Keine',
- 'UP_POINTS' => 'Punkte',
- 'UP_WINS' => 'Gewinne',
-
- 'VIEW_BETS' => 'Tipps immer Anzeigen',
- 'VIEW_BETS_EXPLAIN' => 'Sollen alle Tipps sofort angezeigt werden? Wenn Nein, dann werden sie erst nach Tippabgabeschluss angezeigt. ',
- 'VIEW_CURRENT' => 'Anzeige startet in aktueller Liga',
- 'VIEW_CURRENT_EXPLAIN' => 'Soll beim ersten Aufruf die Liga angezeigt werden, in der die nächsten Spiele stattfinden? Sonst wird immer die erste Liga angezeigt',
- 'VIEW_TENDENCIES' => 'Tipp-Tendenzen immer Anzeigen',
- 'VIEW_TENDENCIES_EXPLAIN' => 'Sollen alle Tipp-Tendenzen sofort angezeigt werden? Wenn Nein, dann werden sie erst nach Tippabgabeschluss angezeigt. ',
-
- 'WIN_HITS02' => 'Gewinne Volltreffer-Wertung mit Auswärtspunkten',
- 'WIN_HITS02_EXPLAIN' => 'Sollen Gewinne der Volltreffer-Wertung mit Auswärtspunkten angezeigt werden? Wenn Nein, muss sichergestellt werden, dass dazu keine Gewinne in den bestehenden Ligen hinterlegt wurden. ',
-));
-
-// Football Menu
-$lang = array_merge($lang, array(
- 'ACP_FOOTBALL_MENU' => 'Tipprunden-Menu',
- 'ACP_FOOTBALL_MENU_EXPLAIN' => 'Hier kannst du Links für das Tipprunden-Menu hinterlegen. Die Linkbeschriftung kannst du frei wählen. ',
-
- 'FOOTBALL_BREADCRUMB' => 'Tipprunden breadcrumb anzeigen',
- 'FOOTBALL_BREADCRUMB_EXPLAIN' => 'Soll ein Breadcrumb-Link für die Tipprunden angezeigt werden? ',
- 'FOOTBALL_SIDE' => 'Tipprunden Sidebar anzeigen',
- 'FOOTBALL_SIDE_EXPLAIN' => 'Soll die Tipprunden Sidebar mit den Menüeinträgen angezeigt werden? ',
- 'FOOTBALL_MENU' => 'Tipprunden Menu anzeigen',
- 'FOOTBALL_MENU_EXPLAIN' => 'Soll das Tipprunden Dropdown Menü in der Navigationsleiste angezeigt werden? ',
- 'MENU_DESC1' => 'Beschriftung http-Link 1',
- 'MENU_DESC1_EXPLAIN' => 'Die Beschriftung des Links darf keine unzulässigen Sonderzeichen enthalten und höchsten 20 Zeichen lang sein. ',
- 'MENU_DESC2' => 'Beschriftung http-Link 2',
- 'MENU_DESC3' => 'Beschriftung http-Link 3',
- 'MENU_LINK1' => 'Http-Link 1',
- 'MENU_LINK1_EXPLAIN' => 'Bitte hier nur http Links eingeben. ',
- 'MENU_LINK2' => 'Http-Link 2',
- 'MENU_LINK3' => 'Http-Link 3',
- 'MENU_NO_LINK' => 'Kein Link hinterlegt',
-));
-
-
-// Football Help
-$lang = array_merge($lang, array(
- 'ACP_FOOTBALL_USERGUIDE' => 'Benutzerhilfe',
- 'ACP_FOOTBALL_USERGUIDE_EXPLAIN' => 'Hier findest du Hilfe für die Einstellungen des phpBB3 Football MODs.
Wenn du Fragen hast, dann schaue bitte immer zuerst hier!',
-));
-
-
-#// Football Logs
-$lang = array_merge($lang, array(
- 'LOG_FOOTBALL_FEATURES' => 'Tipprunden-Funktionalitäten geändert',
- 'LOG_FOOTBALL_MENU' => 'Tipprunden-Menu geändert',
- 'LOG_FOOTBALL_SETTINGS' => 'Tipprunde-Einstellungen geändert',
-
- 'LOG_FOOTBALL_MSG_TEST' => 'Aufruf am %s.',
- 'LOG_FOOTBALL_MSG_TEST_TRAVEL' => 'Aufruf mit Zeitreise zum %s.',
-
- 'LOG_FOOTBALL_REMEMBER_CRON' => 'Cronjob Football remember ausgeführt
» %s',
- 'LOG_FOOTBALL_REMEMBER_CRON_TEST' => 'Cronjob Football remember Testaufruf
» %s',
-
- 'FOOTBALL_REMEMBER_SUBJECT' => 'Bitte %1$s %2$d. Spieltag tippen',
- 'FOOTBALL_REMEMBER_SUBJECT_BOARD' => 'Versendete Erinnerungs-Mails %1$s %2$d',
- 'FOOTBALL_REMEMBER_ERROR_EMAIL' => '%1$s Erinnerungs-Mail an: %2$s gescheitert',
- 'FOOTBALL_REMEMBER_ERROR_EMAIL_BOARD'=> '%1$s Versandliste Erinnerungs-Mail an: %2$s gescheitert',
- 'FOOTBALL_REMEMBER_NOBODY' => 'Es muss niemand erinnert werden.',
- 'FOOTBALL_REMEMBER_NO_DELIVERY' => 'Keine anstehende Tippabgabe im Zeitraum.',
- 'FOOTBALL_REMEMBER_SEND' => '%1$s Erinnerungs-Mail an: %2$s',
-
-));
-
+ 'Fussball',
+ 'ACP_FOOTBALL_MANAGEMENT' => 'Tipprunde-Verwalten',
+ 'ACP_FOOTBALL_OPERATION' => 'Spielbetrieb',
+ 'ACP_FOOTBALL_MANAGE' => 'Spielplan Verwaltung',
+
+ 'ACP_FOOTBALL_CONFIGURATION' => 'Tipprunden-Konfiguration',
+ 'ACP_FOOTBALL_SETTINGS' => 'Tipprunden-Einstellungen',
+ 'ACP_FOOTBALL_SETTINGS_EXPLAIN' => 'Hier kannst du einige grundlegende Einstellungen der Tipprunde vornehmen, ihr einen passenden Namen und eine Beschreibung geben und, neben anderen Werten, die Standard-Einstellungen für die Anzeige anpassen. ',
+
+ 'DISABLE_FOOTBALL' => 'Tipprunde deaktivieren',
+ 'DISABLE_FOOTBALL_EXPLAIN' => 'Hiermit sperrst du die Tipprunde für alle Benutzer. Wenn du möchtest, kannst du eine kurze Nachricht (bis zu 255 Zeichen) angeben. ',
+ 'DISPLAY_RANKS' => 'Anzahl angezeigter Tipper in den Übersichts-Ranglisten',
+ 'DISPLAY_RANKS_EXPLAIN' => 'Limitiert die Anzeige der Spieltags- und Gesamtrangliste in der Hauptansicht. Die eigene Platzierung wird ggf. unten angehängt. ',
+
+ 'FOOTBALL_CODE' => 'Tipprunden Code',
+ 'FOOTBALL_CODE_EXPLAIN' => 'Zugangscode zur Tipprunde z.B. für Cronjobs. ',
+ 'FOOTBALL_FULLSCREEN' => 'Tipprunden-Seiten im Fullscreen-Modus',
+ 'FOOTBALL_FULLSCREEN_EXPLAIN' => 'Hiermit kannst Du, abweichend vom Forum, die Tipprundenseiten mit minimalen Seitenrändern anzeigen lassen. ',
+ 'FOOTBALL_HEADER_ENABLE' => 'Header-Bild je Liga verwenden',
+ 'FOOTBALL_HEADER_ENABLE_EXPLAIN' => 'Hiermit kannst Du festlegen, ob je Liga die zugehöriges Bild im Header angezeigt werden soll. ',
+ 'FOOTBALL_INFO' => 'Tipprunden Information anzeigen',
+ 'FOOTBALL_INFO_EXPLAIN' => 'Hiermit kannst Du eine kurze Information (bis zu 255 Zeichen) oberhalb der Tippdaten anzeigen lassen. ',
+ 'FOOTBALL_NAME' => 'Name der Tipprunde',
+ 'FOOTBALL_NAME_EXPLAIN' => 'Name der im Tipprunden-Menu verwendet wird, um zur Hauptseite zu gelangen. ',
+ 'FOOTBALL_OVERRIDE_STYLE' => 'Style überschreiben',
+ 'FOOTBALL_OVERRIDE_STYLE_EXPLAIN' => 'Verwendet für die Tipprunde immer den Standard-Tipprunden-Style. ',
+ 'FOOTBALL_STYLE' => 'Standard Tipprunden Style',
+ 'FOOTBALL_UPDATE_SOURCE' => 'Update Quelle',
+ 'FOOTBALL_UPDATE_SOURCE_EXPLAIN' => 'Link zur Quelle des Updates. Falls leer, wird automatisch http://football.bplaced.net/football/xml/football_xml_season.php gewählt. ',
+ 'FOOTBALL_UPDATE_CODE' => 'Update Code',
+ 'FOOTBALL_UPDATE_CODE_EXPLAIN' => 'Nur mit diesem Code können Updates von dieser Seite heruntergeladen werden. ',
+
+ 'GUEST_VIEW' => 'Tipprunde für Gäste sichtbar',
+ 'GUEST_VIEW_EXPLAIN' => 'Soll die Tipprunde für Gäste sichtbar sein?',
+
+ 'USER_VIEW' => 'Tipprunde nur für Teilnehmer sichtbar',
+ 'USER_VIEW_EXPLAIN' => 'Soll die Tipprunde nur für Tipprunden-Teilnehmer sichtbar sein?',
+
+ 'HOST_TIMEZONE' => 'Host Zeitzone',
+ 'HOST_TIMEZONE_EXPLAIN' => 'Differenz zur Board Zeitzone wenn dein Host in einer anderen Zeitzone steht, damit die Tippabgabe korrekt funktioniert. ',
+
+ 'LEFT_COLUMN' => 'Spaltenbreite Links in Pixeln',
+ 'LEFT_COLUMN_EXPLAIN' => 'Optimale Breite 180 Pixel. Dieser Wert sollte nicht unterschritten werden. ',
+
+ 'PREDICTION_LEAGUE' => 'Tipprunde',
+
+ 'RIGHT_COLUMN' => 'Spaltenbreite Rechts in Pixeln',
+ 'RIGHT_COLUMN_EXPLAIN' => 'Optimal 180 Pixel. Dieser Wert wird durch externe Einblendungen ggf. übersteuert. ',
+
+ 'USERS_PAGE' => 'Tipper pro Seite',
+ 'USERS_PAGE_EXPLAIN' => 'Anzahl der Tipper je Seite in der Hauptrangliste und Alle Tipps. ',
+
+ 'WIN_NAME' => 'Gewinn Name (oder Währung)',
+ 'WIN_NAME_EXPLAIN' => 'Der Name, der für die Gewinne in der Tipprunde angezeigt werden soll',
+
+ 'ANNOUNCEMENT_TOPIC' => 'Release Ankündigung',
+ 'CURRENT_VERSION' => 'Derzeitige Version',
+ 'DOWNLOAD_LATEST' => 'Neueste Version herunterladen',
+ 'LATEST_VERSION' => 'Neueste Version',
+ 'NOT_UP_TO_DATE' => '%s ist nicht aktuell',
+ 'RELEASE_ANNOUNCEMENT' => 'Ankündigungsthema',
+ 'UP_TO_DATE' => '%s ist aktuell',
+ 'FOOTBALL_VERSION_CHECK' => 'Football Prediction League Extension Version Check',
+
+));
+
+// Football Features
+$lang = array_merge($lang, array(
+ 'ACP_FOOTBALL_FEATURES' => 'Tipprunden-Funktionalitäten',
+ 'ACP_FOOTBALL_FEATURES_EXPLAIN' => 'Hier kannst du einige Funktionen der Tipprunde aktivieren bzw. deaktivieren',
+
+ 'AUTO' => 'Auto',
+
+ 'BANK' => 'Tipprunden Konto verwalten',
+ 'BANK_EXPLAIN' => 'Sollen Tipprunden Konten mit Einsätzen und Gewinnen gepflegt werden?',
+
+ 'FOOTBALL_SEASON_START' => 'Starte in Saison',
+ 'FOOTBALL_SEASON_START_EXPLAIN' => 'Starte in dieser oder in der automatisch ermittelten Saison, wenn noch keine ausgewählt wurde. ',
+
+ 'FOOTBALL_REMEMBER_ENABLE' => 'Cronjob für die Tipp-Erinnerungsmail aktivieren',
+ 'FOOTBALL_REMEMBER_ENABLE_EXPLAIN' => 'Hier kannst Du angeben, ob 1 Tag vor Tippabgabe eine Erinnerungsmail versendet werden soll.',
+
+ 'FOOTBALL_REMEMBER_NEXT_RUN' => 'Nächster Cronjoblauf für die Tipp-Erinnerungsmail',
+ 'FOOTBALL_REMEMBER_NEXT_RUN_EXPLAIN'=> 'Hier kannst Du einstellen, wann der Cronjob für die Tipp-Erinnerungsmail frühestens wieder aufgerufen wird. Nach Ausführung wird der Cronjob für den Folgetag zur gleichen Uhrzeit neu eingeplant.',
+
+ 'FOUNDER_DELETE' => 'Nur Gründungsmitglieder dürfen löschen',
+ 'FOUNDER_DELETE_EXPLAIN' => 'Löschung von Spielplandaten wie Saisons, Ligen, Teams, Spieltage und Spielpläne nur auf Gründungsmitglieder beschränken. ',
+
+ 'RESULTS_AT_TIME' => 'Eingabe endgültiger Spielergebnisse erst nach Spielende',
+ 'RESULTS_AT_TIME_EXPLAIN' => 'Eingabe der endgültigen Spielergebnisse im Adminbereich erst nach Spielende freigeben. Die Eingabe von vorläufigen Spielergebnissen durch die Tipper ist hiervon unabhängig. ',
+
+ 'SAME_ALLOWED' => 'Alle Tipps an einem Spieltag gleich',
+ 'SAME_ALLOWED_EXPLAIN' => 'Identische Tipps (Oma-Tipps) bei allen Spielen eines Spieltags erlauben bzw. verbieten. ',
+
+ 'ULT_POINTS' => 'Ultimate Points einbinden',
+ 'ULT_POINTS_EXPLAIN' => 'Soll es möglich sein, die Punkte oder Gewinne in Ultimate Points verrechnen zu lassen? Dazu muss Ultimate Points installiert sein. ',
+ 'ULT_POINTS_FACTOR' => 'Ultimate Points Faktor',
+ 'ULT_POINTS_FACTOR_EXPLAIN' => 'Faktor mit dem die Punkte je Spieltag in Ultimate Points gutgeschrieben werden. ',
+ 'UP_NONE' => 'Keine',
+ 'UP_POINTS' => 'Punkte',
+ 'UP_WINS' => 'Gewinne',
+
+ 'VIEW_BETS' => 'Tipps immer Anzeigen',
+ 'VIEW_BETS_EXPLAIN' => 'Sollen alle Tipps sofort angezeigt werden? Wenn Nein, dann werden sie erst nach Tippabgabeschluss angezeigt. ',
+ 'VIEW_CURRENT' => 'Anzeige startet in aktueller Liga',
+ 'VIEW_CURRENT_EXPLAIN' => 'Soll beim ersten Aufruf die Liga angezeigt werden, in der die nächsten Spiele stattfinden? Sonst wird immer die erste Liga angezeigt',
+ 'VIEW_TENDENCIES' => 'Tipp-Tendenzen immer Anzeigen',
+ 'VIEW_TENDENCIES_EXPLAIN' => 'Sollen alle Tipp-Tendenzen sofort angezeigt werden? Wenn Nein, dann werden sie erst nach Tippabgabeschluss angezeigt. ',
+
+ 'WIN_HITS02' => 'Gewinne Volltreffer-Wertung mit Auswärtspunkten',
+ 'WIN_HITS02_EXPLAIN' => 'Sollen Gewinne der Volltreffer-Wertung mit Auswärtspunkten angezeigt werden? Wenn Nein, muss sichergestellt werden, dass dazu keine Gewinne in den bestehenden Ligen hinterlegt wurden. ',
+));
+
+// Football Menu
+$lang = array_merge($lang, array(
+ 'ACP_FOOTBALL_MENU' => 'Tipprunden-Menu',
+ 'ACP_FOOTBALL_MENU_EXPLAIN' => 'Hier kannst du Links für das Tipprunden-Menu hinterlegen. Die Linkbeschriftung kannst du frei wählen. ',
+
+ 'FOOTBALL_BREADCRUMB' => 'Tipprunden breadcrumb anzeigen',
+ 'FOOTBALL_BREADCRUMB_EXPLAIN' => 'Soll ein Breadcrumb-Link für die Tipprunden angezeigt werden? ',
+ 'FOOTBALL_SIDE' => 'Tipprunden Sidebar anzeigen',
+ 'FOOTBALL_SIDE_EXPLAIN' => 'Soll die Tipprunden Sidebar mit den Menüeinträgen angezeigt werden? ',
+ 'FOOTBALL_MENU' => 'Tipprunden Menu anzeigen',
+ 'FOOTBALL_MENU_EXPLAIN' => 'Soll das Tipprunden Dropdown Menü in der Navigationsleiste angezeigt werden? ',
+ 'MENU_DESC1' => 'Beschriftung http-Link 1',
+ 'MENU_DESC1_EXPLAIN' => 'Die Beschriftung des Links darf keine unzulässigen Sonderzeichen enthalten und höchsten 20 Zeichen lang sein. ',
+ 'MENU_DESC2' => 'Beschriftung http-Link 2',
+ 'MENU_DESC3' => 'Beschriftung http-Link 3',
+ 'MENU_LINK1' => 'Http-Link 1',
+ 'MENU_LINK1_EXPLAIN' => 'Bitte hier nur http Links eingeben. ',
+ 'MENU_LINK2' => 'Http-Link 2',
+ 'MENU_LINK3' => 'Http-Link 3',
+ 'MENU_NO_LINK' => 'Kein Link hinterlegt',
+));
+
+
+// Football Help
+$lang = array_merge($lang, array(
+ 'ACP_FOOTBALL_USERGUIDE' => 'Benutzerhilfe',
+ 'ACP_FOOTBALL_USERGUIDE_EXPLAIN' => 'Hier findest du Hilfe für die Einstellungen des phpBB3 Football MODs.
Wenn du Fragen hast, dann schaue bitte immer zuerst hier!',
+));
+
+
+#// Football Logs
+$lang = array_merge($lang, array(
+ 'LOG_FOOTBALL_FEATURES' => 'Tipprunden-Funktionalitäten geändert',
+ 'LOG_FOOTBALL_MENU' => 'Tipprunden-Menu geändert',
+ 'LOG_FOOTBALL_SETTINGS' => 'Tipprunde-Einstellungen geändert',
+ 'LOG_PL_BACKUP' => 'Tipprunden Backup',
+
+ 'LOG_FOOTBALL_MSG_TEST' => 'Aufruf am %s.',
+ 'LOG_FOOTBALL_MSG_TEST_TRAVEL' => 'Aufruf mit Zeitreise zum %s.',
+
+ 'LOG_FOOTBALL_REMEMBER_CRON' => 'Cronjob Football remember ausgeführt
» %s',
+ 'LOG_FOOTBALL_REMEMBER_CRON_TEST' => 'Cronjob Football remember Testaufruf
» %s',
+
+ 'FOOTBALL_REMEMBER_SUBJECT' => 'Bitte %1$s %2$d. Spieltag tippen',
+ 'FOOTBALL_REMEMBER_SUBJECT_BOARD' => 'Versendete Erinnerungs-Mails %1$s %2$d',
+ 'FOOTBALL_REMEMBER_ERROR_EMAIL' => '%1$s Erinnerungs-Mail an: %2$s gescheitert',
+ 'FOOTBALL_REMEMBER_ERROR_EMAIL_BOARD'=> '%1$s Versandliste Erinnerungs-Mail an: %2$s gescheitert',
+ 'FOOTBALL_REMEMBER_NOBODY' => 'Es muss niemand erinnert werden.',
+ 'FOOTBALL_REMEMBER_NO_DELIVERY' => 'Keine anstehende Tippabgabe im Zeitraum.',
+ 'FOOTBALL_REMEMBER_SEND' => '%1$s Erinnerungs-Mail an: %2$s',
+
+));
+
?>
\ No newline at end of file
diff --git a/language/en/info_acp_football.php b/language/en/info_acp_football.php
index 802e8f2..55e01b6 100644
--- a/language/en/info_acp_football.php
+++ b/language/en/info_acp_football.php
@@ -146,6 +146,7 @@ $lang = array_merge($lang, array(
'LOG_FOOTBALL_MSG_TEST_TRAVEL' => 'Call with time travel to %s.',
'LOG_FOOTBALL_REMEMBER_CRON' => 'Cronjob Football remember running %s',
'LOG_FOOTBALL_REMEMBER_CRON_TEST' => 'Cronjob Football remember test call %s',
+ 'LOG_PL_BACKUP' => 'Prediction League backup',
'FOOTBALL_REMEMBER_SUBJECT' => 'Please bet %1$s %2$d. matchday',
'FOOTBALL_REMEMBER_SUBJECT_BOARD' => 'Sent reminder mails %1$s %2$d',
'FOOTBALL_REMEMBER_ERROR_EMAIL' => '%1$s reminder email to: %2$d failed',
diff --git a/migrations/v094_beta_update.php b/migrations/v094_beta_update.php
index 365d5f6..f3104db 100644
--- a/migrations/v094_beta_update.php
+++ b/migrations/v094_beta_update.php
@@ -58,23 +58,13 @@ class v094_beta_update extends \phpbb\db\migration\migration
{
return array(
'drop_columns' => array(
- $this->table_prefix . 'groups' => array(
- 'group_teampage',
- ),
$this->table_prefix . 'sessions' => array(
+ 'football_season',
+ 'football_league',
+ 'football_matchday',
'football_mobile',
'football_mobile_device',
),
- $this->table_prefix . 'footb_bets' => array(
- 'bet_time',
- ),
- $this->table_prefix . 'footb_matches' => array(
- 'trend',
- 'odd_1',
- 'odd_x',
- 'odd_2',
- 'rating',
- ),
)
);
}
diff --git a/migrations/v098_beta.php b/migrations/v098_beta.php
new file mode 100644
index 0000000..f5e2755
--- /dev/null
+++ b/migrations/v098_beta.php
@@ -0,0 +1,30 @@
+config['football_version']) && version_compare($this->config['football_version'], '0.9.8', '>=');
+ }
+
+ static public function depends_on()
+ {
+ return array('\football\football\migrations\v097_beta');
+ }
+
+ public function update_data()
+ {
+ return array(
+ array('config.update', array('football_version', '0.9.8', '0')),
+ );
+ }
+}
diff --git a/styles/prosilver/template/event/overall_header_head_append.html b/styles/prosilver/template/event/overall_header_head_append.html
index b824949..588d391 100644
--- a/styles/prosilver/template/event/overall_header_head_append.html
+++ b/styles/prosilver/template/event/overall_header_head_append.html
@@ -1,29 +1,29 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/styles/prosilver/template/event/overall_header_page_body_before.html b/styles/prosilver/template/event/overall_header_page_body_before.html
index b5ea2a4..21d0a2b 100644
--- a/styles/prosilver/template/event/overall_header_page_body_before.html
+++ b/styles/prosilver/template/event/overall_header_page_body_before.html
@@ -1,64 +1,64 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/styles/prosilver/template/football_body.html b/styles/prosilver/template/football_body.html
index 4a382f2..5edd0e3 100644
--- a/styles/prosilver/template/football_body.html
+++ b/styles/prosilver/template/football_body.html
@@ -1,220 +1,220 @@
-
-
-
-
-
-
-
-
- {L_INFORMATION}: {S_FOOTBALL_INFO}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ {L_INFORMATION}: {S_FOOTBALL_INFO}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/styles/prosilver/template/mobile_football_body.html b/styles/prosilver/template/mobile_football_body.html
index ba28567..721e91d 100644
--- a/styles/prosilver/template/mobile_football_body.html
+++ b/styles/prosilver/template/mobile_football_body.html
@@ -1,179 +1,179 @@
-
-
-
-
- {L_INFORMATION}: {S_FOOTBALL_INFO}
-
-
-
-
-
-
-
-
-
-
-
-
- {S_DELIVERY}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ {L_INFORMATION}: {S_FOOTBALL_INFO}
+
+
+
+
+
+
+
+
+
+
+
+
+ {S_DELIVERY}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file