37 Commits

Author SHA1 Message Date
Julian 76cedb15a2 Only allow betting if user is in a match 2022-08-12 20:07:38 +02:00
Julian 41397ffbdc Fix warning in all bets when no bets are shown. 2022-08-11 16:29:35 +02:00
Julian abf7e95d08 Fix calculation of bonuspoints and corrected values for form table 2021-01-27 22:12:23 +01:00
Julian 573a3bdea7 Changes for phpbb 3.3.0 2020-08-03 21:22:09 +02:00
Julian 25e4e53485 Fix mobile style to display correct page when results_tl is clicked.
Rearrange mobile menu to fit to the desktop menu.
2018-08-04 16:00:21 +02:00
Julian adfecaac96 Fix change sign in ranks_matchday and ranks_total. 2018-07-07 16:03:31 +02:00
Julian 4870166b96 Show table on bet site also on mobile devices 2018-06-24 16:39:04 +02:00
Julian 9d57480e6d Change last blue color to green in table. 2018-06-24 15:57:39 +02:00
Julian 948f7b8511 Updated desktop menu to show ranks_total if bet_type is 1
Updated mobile menu to behave like desktop menu
2018-06-23 16:08:29 +02:00
Julian 90172d076b Add modifications for show_table of matches and bet_type for leagues in ACP. 2018-06-03 13:57:34 +02:00
Julian 66dceff9f2 change color to green 2018-05-20 16:18:38 +02:00
Julian 8b679b1286 Change order of tippers in all_bets site according to the tipper vs tipper matches and change background color. 2018-04-03 22:16:31 +02:00
Julian e1db71c99d Add matchtime tooltip to all_bets site 2018-04-03 21:58:09 +02:00
Julian 3ade0f043f Add bonuspoint, corr and chart calculation and update displaying of chart. 2018-04-03 21:06:22 +02:00
Julian f56cf04e74 Rearange main menu and change external links to internal links 2018-04-03 19:57:48 +02:00
Julian 66b2a1a8d0 Readd rank_matchday in all sites and add check for correct league --> Display of rank_matchday works on table and results_tl site. 2018-04-03 19:24:37 +02:00
Julian 889ff05ca6 Remove highlight of table menu item in bet site. 2018-04-03 19:14:08 +02:00
Julian 0b9f099381 Remove small rank total from main view. 2018-04-03 19:13:08 +02:00
Julian 148c16c87a Remove unneeded teams from tables in mytable site. 2018-04-03 19:12:36 +02:00
Julian 511fab50b7 Add results_tl and handling in different files 2018-04-03 18:43:39 +02:00
Julian 6c06de3772 Remove unneeded menu items. 2018-04-03 17:47:42 +02:00
Julian 37204150dc Add results_tl to language and main controller. 2018-04-03 17:47:30 +02:00
Julian 85d3c835d2 Change short team names to full team names 2018-04-02 23:25:37 +02:00
Julian ac536658fa Add auto selection of correct leage (higher or lower league id 50) 2018-04-02 22:58:54 +02:00
Julian 92267523b9 Include full table in bet view instead of small table 2018-04-02 22:56:21 +02:00
Julian 4a64eb71a3 Add bonus points to the missing tables and make non relevant teams invisible in tables. 2018-04-02 22:24:49 +02:00
Julian 268ca763f7 Fix BNS coloumn displaying 2018-02-21 23:26:07 +01:00
Julian 66b35b0155 Fix table and add corr to constants 2018-02-21 23:24:04 +01:00
Julian 4b627586f8 Add bonus points calculation to table total. 2018-02-21 23:19:03 +01:00
Julian 3b47093a3a fix broken function current_league($season) sql select 2018-02-19 22:57:59 +01:00
Julian 511a23d609 Wappen der Mannschaften hinzugefügt 2018-02-19 22:10:07 +01:00
Julian 6b9ebb0d1a Football functions.php angepasst, damit ertippte Punkte bei ihren jeweiligen Teams als Tore eingetragen werden. 2018-02-19 21:56:29 +01:00
football 7d8b92f1df Version 0.9.9 2017-09-09 13:51:15 +02:00
football c075143bfc Version 0.9.9b1
-replace icons with font awesome icons
-display icons on tabs and hide it on mobile access
-new block last results
-new config values for last users, last results
-replace config value football_host_timezone with football_time_shift
-fixed errors on php 7
-remove unnecessary sql_freeresult calls
-fixed non-numeric value errors
2017-09-09 10:58:32 +02:00
football a502b5d082 Fix problem in admin-help-section on phpBB3.2 (no help is shown):
[phpBB Debug] PHP Warning: in file [ROOT]/ext/football/football/acp/football_module.php on line 80: Invalid argument supplied for foreach()
2017-03-05 18:04:34 +01:00
football a16e0e3c79 Version 0.9.8 2017-02-19 20:25:32 +01:00
football 09631cbe15 Version 0.9.7 2016-06-12 17:20:16 +02:00
684 changed files with 20060 additions and 19476 deletions
+24
View File
@@ -39,3 +39,27 @@ Icon
# Files that might appear on external disk
.Spotlight-V100
.Trashes
/styles/prosilver/theme/images/right_arrow.png
/styles/prosilver/theme/images/icon_allbets.gif
/styles/prosilver/theme/images/icon_ball.gif
/styles/prosilver/theme/images/icon_ball2.gif
/styles/prosilver/theme/images/icon_bet.gif
/styles/prosilver/theme/images/icon_bookmark.gif
/styles/prosilver/theme/images/icon_download.gif
/styles/prosilver/theme/images/icon_info.gif
/styles/prosilver/theme/images/icon_list.gif
/styles/prosilver/theme/images/icon_mark.gif
/styles/prosilver/theme/images/icon_odds.gif
/styles/prosilver/theme/images/icon_points.gif
/styles/prosilver/theme/images/icon_print.gif
/styles/prosilver/theme/images/icon_rank.gif
/styles/prosilver/theme/images/icon_results.gif
/styles/prosilver/theme/images/icon_rules.gif
/styles/prosilver/theme/images/icon_statistic.gif
/styles/prosilver/theme/images/icon_statistics.gif
/styles/prosilver/theme/images/icon_xml.gif
/styles/prosilver/theme/images/left_arrow.png
/images/no_change.gif
/images/arrow_down.gif
/images/arrow_up.gif
/migrations/v099_beta1.php
+3
View File
@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_14" project-jdk-name="openjdk-14" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/phpbb_football_tlw.iml" filepath="$PROJECT_DIR$/.idea/phpbb_football_tlw.iml" />
</modules>
</component>
</project>
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Generated
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
+598 -599
View File
File diff suppressed because it is too large Load Diff
+673 -672
View File
File diff suppressed because it is too large Load Diff
+755 -752
View File
File diff suppressed because it is too large Load Diff
+458 -462
View File
@@ -1,463 +1,459 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class extra_module
{
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log;
public function __construct()
{
global $db, $user, $request, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_extra');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$provider = new \phpbb\controller\ provider();
$symphony_request = new \phpbb\ symfony_request($request);
$filesystem = new \phpbb\ filesystem();
$helper = new \phpbb\controller\ helper($template, $user, $config, $provider, $phpbb_extension_manager, $symphony_request, $request, $filesystem, $phpbb_root_path, $phpEx);
$this->tpl_name = 'acp_football_extra';
$this->page_title = 'ACP_FOOTBALL_EXTRA_MANAGE';
$form_key = 'acp_football_extra';
add_form_key($form_key);
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
// Check and set some common vars
$action = (isset($_POST['add'])) ? 'add' : ((isset($_POST['remove'])) ? 'remove' : $this->request->variable('action', ''));
$edit = $this->request->variable('edit', 0);
$season = $this->request->variable('s', 0);
$league = $this->request->variable('l', 0);
$matchday = $this->request->variable('matchday', 0);
$matchday_eval = $this->request->variable('matchday_eval', 0);
$extra_no = $this->request->variable('e', 0);
$update = (isset($_POST['update'])) ? true : false;
// Clear some vars
$extra_row = array();
$error = array();
// Grab current season
if (!$season)
{
$season = curr_season();
}
// Grab basic data for select season
if ($season)
{
$sql = 'SELECT *
FROM ' . FOOTB_SEASONS . '
ORDER BY season DESC';
$result = $db->sql_query($sql);
$season_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($season && $row['season'] == $season) ? ' selected="selected"' : '';
$season_options .= '<option value="' . $row['season'] . '"' . $selected . '>' . $row['season_name_short'] . '</option>';
if ($selected <> '')
{
$season_name = $row['season_name_short'];
}
}
$db->sql_freeresult($result);
}
else
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Grab current league
if (!$league)
{
$league = first_league($season, false);
}
// Grab basic data for select league
if ($league)
{
$sql = 'SELECT *
FROM ' . FOOTB_LEAGUES . "
WHERE season = $season
ORDER BY league ASC";
$result = $db->sql_query($sql);
$league_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($league && $row['league'] == $league) ? ' selected="selected"' : '';
$league_options .= '<option value="' . $row['league'] . '"' . $selected . '>' . $row['league_name'] . '</option>';
if ($selected <> '')
{
$league_matchdays = $row['matchdays'];
$league_name = $row['league_name'];
$league_type = $row['league_type'];
$ko_league = ($row['league_type'] == LEAGUE_KO) ? true : false;
}
}
$db->sql_freeresult($result);
}
else
{
trigger_error(sprintf($user->lang['NO_LEAGUE'], $season) . adm_back_link($this->u_action . "&amp;s=$season"), E_USER_WARNING);
}
// Grab basic data for extra bets, if extra bet is set and exists
if ($extra_no)
{
$sql = 'SELECT *
FROM ' . FOOTB_EXTRA . "
WHERE season = $season
AND league = $league
AND extra_no = $extra_no";
$result = $db->sql_query($sql);
$extra_row = $db->sql_fetchrow($result);
$existing_extra = sizeof($extra_row);
$db->sql_freeresult($result);
}
$db->sql_freeresult($result);
// Which page?
switch ($action)
{
case 'delete':
if (!$season)
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (!$league)
{
trigger_error($user->lang['NO_LEAGUE'] . adm_back_link($this->u_action . "&amp;s=$season"), E_USER_WARNING);
}
if (!$extra_no)
{
trigger_error($user->lang['NO_EXTRA'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
if (confirm_box(true))
{
$error = '';
if (!$auth->acl_get('a_football_delete'))
{
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
trigger_error($user->lang['EXTRA_NO_DELETE'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
// Delete extra
$sql = 'DELETE FROM ' . FOOTB_EXTRA . "
WHERE season = $season AND league = $league AND extra_no = $extra_no";
$db->sql_query($sql);
// Delete extra bets
$sql = 'DELETE FROM ' . FOOTB_EXTRA_BETS . "
WHERE season = $season
AND league = $league
AND extra_no = $extra_no";
$db->sql_query($sql);
trigger_error($user->lang['EXTRA_DELETED'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"));
}
else
{
confirm_box(false, sprintf($user->lang['EXTRA_CONFIRM_DELETE'], $extra_row['question'], $league, $season), build_hidden_fields(array(
's' => $season,
'l' => $league,
'e' => $extra_no,
'mode' => $mode,
'action' => $action))
);
}
break;
case 'add':
$sql = "SELECT
max(extra_no) AS max_extra_no
FROM " . FOOTB_EXTRA . "
WHERE season = $season
AND league = $league";
$result = $db->sql_query($sql);
$row_extra = $db->sql_fetchrow($result);
$existing_extra = sizeof($row_extra);
$db->sql_freeresult($result);
$extra_no = ($existing_extra) ? $row_extra['max_extra_no'] + 1 : 1;
$extra_row['extra_no'] = $extra_no;
$extra_row['question_type'] = $this->request->variable('question_type', 3);
$extra_row['question'] = utf8_normalize_nfc($this->request->variable('question', '', true));
$extra_row['matchday'] = $this->request->variable('matchday', 0);
$extra_row['matchday_eval'] = $this->request->variable('matchday_eval', 0);
$extra_row['result'] = utf8_normalize_nfc($this->request->variable('result', ''));
$extra_row['extra_points'] = $this->request->variable('extra_points', 0);
$extra_row['extra_status'] = $this->request->variable('extra_status', 0);
// No break for edit add
case 'edit':
$error_msg = array();
if (!sizeof($error))
{
if ($action == 'edit' && !$extra_no)
{
trigger_error($user->lang['NO_EXTRA'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
$matchday = $extra_row['matchday'];
$matchday_eval = $extra_row['matchday_eval'];
$sql = 'SELECT *
FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season
AND league = $league
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
$matchday_options = '<option value="0"' . ((!$matchday) ? ' selected="selected"' : '') . '>' . $user->lang['SELECT_MATCHDAY'] . '</option>';
$matchday_eval_options = '<option value="0"' . ((!$matchday_eval) ? ' selected="selected"' : '') . '>' . $user->lang['SELECT_MATCHDAY'] . '</option>';
while ($row = $db->sql_fetchrow($result))
{
if ($row['status'] == 0 or $action == 'edit')
{
$selected_matchday = ($matchday && $row['matchday'] == $matchday) ? ' selected="selected"' : '';
$selected_eval = ($matchday_eval && $row['matchday'] == $matchday_eval) ? ' selected="selected"' : '';
$day_name = (strlen($row['matchday_name']) > 0) ? $row['matchday_name'] : $row['matchday'] . '. ' . sprintf($user->lang['MATCHDAY']);
$matchday_options .= '<option value="' . $row['matchday'] . '"' . $selected_matchday . '>' . $day_name . '</option>';
$matchday_eval_options .= '<option value="' . $row['matchday'] . '"' . $selected_eval . '>' . $day_name . '</option>';
}
}
$question_type_options = '';
for($i = 1; $i<= 5; $i++)
{
$selected = ($i == $extra_row['question_type']) ? ' selected="selected"' : '';
$question_type_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$extra_status_options = '';
for($i = 0; $i<= 3; $i++)
{
$selected = ($i == $extra_row['extra_status']) ? ' selected="selected"' : '';
$extra_status_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
// Did we submit?
if ($update)
{
$data = array();
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
$extra_row['extra_no'] = $extra_no;
$extra_row['question_type'] = $this->request->variable('question_type', $extra_row['question_type']);
$extra_row['question'] = $this->request->variable('question', $extra_row['question'], true);
$extra_row['matchday'] = $this->request->variable('matchday', $extra_row['matchday']);
$extra_row['matchday_eval'] = $this->request->variable('matchday_eval', $extra_row['matchday_eval']);
$extra_row['extra_points'] = $this->request->variable('extra_points', $extra_row['extra_points']);
$extra_row['extra_status'] = $this->request->variable('extra_status', $extra_row['extra_status']);
$data['extra_points'] = (int) $extra_row['extra_points'];
$data['matchday'] = (int) $extra_row['matchday'];
$data['matchday_eval'] = (int) $extra_row['matchday_eval'];
if ($data['matchday_eval'] < $data['matchday'])
{
$error[] = $user->lang['EVAL_BEFORE_DELIVERY'];
}
if (!sizeof($error))
{
$sql_ary = array(
'season' => (int) $season,
'league' => (int) $league,
'extra_no' => (int) $extra_no,
'question_type' => (int) $extra_row['question_type'],
'question' => strlen($extra_row['question']) ? $extra_row['question'] : '',
'matchday' => (int) $extra_row['matchday'],
'matchday_eval' => (int) $extra_row['matchday_eval'],
'result' => $extra_row['result'],
'extra_points' => (int) $extra_row['extra_points'],
'extra_status' => (int) $extra_row['extra_status'],
);
$var_ary = array(
'extra_points' => array('num', false, 0, 99),
'matchday' => array('num', false, 1),
'matchday_eval' => array('num', false, 1),
);
if (!($error_vals = validate_data($data, $var_ary)))
{
if ($action == 'add')
{
$sql = 'INSERT INTO ' . FOOTB_EXTRA . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
}
else
{
$sql = 'UPDATE ' . FOOTB_EXTRA . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE season = $season AND league = $league AND extra_no = $extra_no";
$db->sql_query($sql);
}
trigger_error($user->lang['EXTRA_UPDATED'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"));
}
else
{
foreach ($error_vals as $error_val)
{
$error_msg[] = $user->lang[$error_val];
}
$error[] = $user->lang['EXTRA_UPDATE_FAILED'];
$error = array_merge($error, $error_msg);
}
}
}
}
$u_back = $this->u_action . "&amp;s=$season&amp;l=$league";
$template->assign_vars(array(
'S_EDIT' => true,
'S_ADD_EXTRA' => ($action == 'add') ? true : false,
'S_ERROR' => (sizeof($error)) ? true : false,
'S_EDIT_EXTRAS' => ($existing_extra) ? false : true,
'S_QUESTION_TYPE_OPTIONS' => $question_type_options,
'S_MATCHDAY_OPTIONS' => $matchday_options,
'S_MATCHDAY_EVAL_OPTIONS' => $matchday_eval_options,
'S_EXTRA_STATUS_OPTIONS' => $extra_status_options,
'S_VERSION_NO' => $this->config['football_version'],
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'SEASON' => $season,
'SEASON_NAME' => $season_name,
'LEAGUE' => $league,
'LEAGUE_NAME' => $league_name,
'EXTRA_NO' => $extra_no,
'QUESTION_TYPE' => $extra_row['question_type'],
'QUESTION' => $extra_row['question'],
'MATCHDAY' => $extra_row['matchday'],
'MATCHDAY_EVAL' => $extra_row['matchday_eval'],
'MATCHDAY_OPTION' => $extra_row['matchday'],
'MATCHDAY_EVAL' => $extra_row['matchday_eval'],
'RESULT' => $extra_row['result'],
'EXTRA_POINTS' => $extra_row['extra_points'],
'EXTRA_STATUS' => $extra_row['extra_status'],
'U_BACK' => $u_back,
'U_ACTION' => "{$this->u_action}&amp;action=$action&amp;s=$season&amp;l=$league",
)
);
return;
break;
}
// Check open matchday in league
$sql = 'SELECT *
FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season
AND league = $league
AND status <= 0";
$result = $db->sql_query($sql);
$open_matchdays = sizeof($db->sql_fetchrowset($result));
$db->sql_freeresult($result);
// Get us all the extra
$sql = "SELECT e.*,
m1.matchday_name AS matchday_name,
m2.matchday_name AS matchday_eval_name
FROM " . FOOTB_EXTRA . ' AS e
LEFT JOIN ' . FOOTB_MATCHDAYS . ' AS m1 ON (m1.season = e.season AND m1.league = e.league AND m1.matchday = e.matchday)
LEFT JOIN ' . FOOTB_MATCHDAYS . " AS m2 ON (m2.season = e.season AND m2.league = e.league AND m2.matchday = e.matchday_eval)
WHERE e.season = $season
AND e.league = $league
ORDER BY e.extra_no ASC";
$result = $db->sql_query($sql);
$rows_extra = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet', 's' => $season, 'l' => $league)),
'S_SEASON' => $season,
'S_LEAGUE' => $league,
'S_SEASON_OPTIONS' => $season_options,
'S_LEAGUE_OPTIONS' => $league_options,
'S_EXTRA_ADD' => ($open_matchdays) ? true : false,
'S_VERSION_NO' => $this->config['football_version'],
)
);
// Check if the user is allowed to delete a extra.
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
$allow_delete = false;
}
else
{
$allow_delete = true;
}
$row_number = 0;
foreach ($rows_extra as $row_extra)
{
$row_number++;
$row_class = (!($row_number % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('extras', array(
'ROW_CLASS' => $row_class,
'EXTRA_NO' => $row_extra['extra_no'],
'QUESTION_TYPE' => $row_extra['question_type'],
'QUESTION' => $row_extra['question'],
'MATCHDAY' => (strlen($row_extra['matchday_name']) > 0) ? $row_extra['matchday_name'] : $row_extra['matchday'] . '. ' . sprintf($user->lang['MATCHDAY']),
'MATCHDAY_EVAL' => (strlen($row_extra['matchday_name']) > 0) ? $row_extra['matchday_eval_name'] : $row_extra['matchday_eval'] . '. ' . sprintf($user->lang['MATCHDAY']),
'EXTRA_POINTS' => $row_extra['extra_points'],
'EXTRA_STATUS' => $row_extra['extra_status'],
'U_EDIT' => "{$this->u_action}&amp;action=edit&amp;s=" . $season . "&amp;l=" .$league . "&amp;e=" .$row_extra['extra_no'],
'U_DELETE' => ($allow_delete) ? "{$this->u_action}&amp;action=delete&amp;s=" . $season . "&amp;l=" . $league . "&amp;e=" . $row_extra['extra_no'] : '',
)
);
}
}
}
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class extra_module
{
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log;
public function __construct()
{
global $db, $user, $request, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_extra');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$helper = $phpbb_container->get('controller.helper');
$this->tpl_name = 'acp_football_extra';
$this->page_title = 'ACP_FOOTBALL_EXTRA_MANAGE';
$form_key = 'acp_football_extra';
add_form_key($form_key);
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
// Check and set some common vars
$action = (isset($_POST['add'])) ? 'add' : ((isset($_POST['remove'])) ? 'remove' : $this->request->variable('action', ''));
$edit = $this->request->variable('edit', 0);
$season = $this->request->variable('s', 0);
$league = $this->request->variable('l', 0);
$matchday = $this->request->variable('matchday', 0);
$matchday_eval = $this->request->variable('matchday_eval', 0);
$extra_no = $this->request->variable('e', 0);
$update = (isset($_POST['update'])) ? true : false;
// Clear some vars
$extra_row = array();
$error = array();
// Grab current season
if (!$season)
{
$season = curr_season();
}
// Grab basic data for select season
if ($season)
{
$sql = 'SELECT *
FROM ' . FOOTB_SEASONS . '
ORDER BY season DESC';
$result = $db->sql_query($sql);
$season_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($season && $row['season'] == $season) ? ' selected="selected"' : '';
$season_options .= '<option value="' . $row['season'] . '"' . $selected . '>' . $row['season_name_short'] . '</option>';
if ($selected <> '')
{
$season_name = $row['season_name_short'];
}
}
$db->sql_freeresult($result);
}
else
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Grab current league
if (!$league)
{
$league = first_league($season, false);
}
// Grab basic data for select league
if ($league)
{
$sql = 'SELECT *
FROM ' . FOOTB_LEAGUES . "
WHERE season = $season
ORDER BY league ASC";
$result = $db->sql_query($sql);
$league_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($league && $row['league'] == $league) ? ' selected="selected"' : '';
$league_options .= '<option value="' . $row['league'] . '"' . $selected . '>' . $row['league_name'] . '</option>';
if ($selected <> '')
{
$league_matchdays = $row['matchdays'];
$league_name = $row['league_name'];
$league_type = $row['league_type'];
$ko_league = ($row['league_type'] == LEAGUE_KO) ? true : false;
}
}
$db->sql_freeresult($result);
}
else
{
trigger_error(sprintf($user->lang['NO_LEAGUE'], $season) . adm_back_link($this->u_action . "&amp;s=$season"), E_USER_WARNING);
}
// Grab basic data for extra bets, if extra bet is set and exists
if ($extra_no)
{
$sql = 'SELECT *
FROM ' . FOOTB_EXTRA . "
WHERE season = $season
AND league = $league
AND extra_no = $extra_no";
$result = $db->sql_query($sql);
$extra_row = $db->sql_fetchrow($result);
$existing_extra = sizeof($extra_row);
$db->sql_freeresult($result);
}
// Which page?
switch ($action)
{
case 'delete':
if (!$season)
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (!$league)
{
trigger_error($user->lang['NO_LEAGUE'] . adm_back_link($this->u_action . "&amp;s=$season"), E_USER_WARNING);
}
if (!$extra_no)
{
trigger_error($user->lang['NO_EXTRA'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
if (confirm_box(true))
{
$error = '';
if (!$auth->acl_get('a_football_delete'))
{
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
trigger_error($user->lang['EXTRA_NO_DELETE'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
// Delete extra
$sql = 'DELETE FROM ' . FOOTB_EXTRA . "
WHERE season = $season AND league = $league AND extra_no = $extra_no";
$db->sql_query($sql);
// Delete extra bets
$sql = 'DELETE FROM ' . FOOTB_EXTRA_BETS . "
WHERE season = $season
AND league = $league
AND extra_no = $extra_no";
$db->sql_query($sql);
trigger_error($user->lang['EXTRA_DELETED'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"));
}
else
{
confirm_box(false, sprintf($user->lang['EXTRA_CONFIRM_DELETE'], $extra_row['question'], $league, $season), build_hidden_fields(array(
's' => $season,
'l' => $league,
'e' => $extra_no,
'mode' => $mode,
'action' => $action))
);
}
break;
case 'add':
$sql = "SELECT
max(extra_no) AS max_extra_no
FROM " . FOOTB_EXTRA . "
WHERE season = $season
AND league = $league";
$result = $db->sql_query($sql);
$row_extra = $db->sql_fetchrow($result);
$existing_extra = sizeof($row_extra);
$db->sql_freeresult($result);
$extra_no = ($existing_extra) ? $row_extra['max_extra_no'] + 1 : 1;
$extra_row['extra_no'] = $extra_no;
$extra_row['question_type'] = $this->request->variable('question_type', 3);
$extra_row['question'] = utf8_normalize_nfc($this->request->variable('question', '', true));
$extra_row['matchday'] = $this->request->variable('matchday', 0);
$extra_row['matchday_eval'] = $this->request->variable('matchday_eval', 0);
$extra_row['result'] = utf8_normalize_nfc($this->request->variable('result', ''));
$extra_row['extra_points'] = $this->request->variable('extra_points', 0);
$extra_row['extra_status'] = $this->request->variable('extra_status', 0);
// No break for edit add
case 'edit':
$error_msg = array();
if (!sizeof($error))
{
if ($action == 'edit' && !$extra_no)
{
trigger_error($user->lang['NO_EXTRA'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
$matchday = $extra_row['matchday'];
$matchday_eval = $extra_row['matchday_eval'];
$sql = 'SELECT *
FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season
AND league = $league
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
$matchday_options = '<option value="0"' . ((!$matchday) ? ' selected="selected"' : '') . '>' . $user->lang['SELECT_MATCHDAY'] . '</option>';
$matchday_eval_options = '<option value="0"' . ((!$matchday_eval) ? ' selected="selected"' : '') . '>' . $user->lang['SELECT_MATCHDAY'] . '</option>';
while ($row = $db->sql_fetchrow($result))
{
if ($row['status'] == 0 or $action == 'edit')
{
$selected_matchday = ($matchday && $row['matchday'] == $matchday) ? ' selected="selected"' : '';
$selected_eval = ($matchday_eval && $row['matchday'] == $matchday_eval) ? ' selected="selected"' : '';
$day_name = (strlen($row['matchday_name']) > 0) ? $row['matchday_name'] : $row['matchday'] . '. ' . sprintf($user->lang['MATCHDAY']);
$matchday_options .= '<option value="' . $row['matchday'] . '"' . $selected_matchday . '>' . $day_name . '</option>';
$matchday_eval_options .= '<option value="' . $row['matchday'] . '"' . $selected_eval . '>' . $day_name . '</option>';
}
}
$db->sql_freeresult($result);
$question_type_options = '';
for($i = 1; $i<= 5; $i++)
{
$selected = ($i == $extra_row['question_type']) ? ' selected="selected"' : '';
$question_type_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$extra_status_options = '';
for($i = 0; $i<= 3; $i++)
{
$selected = ($i == $extra_row['extra_status']) ? ' selected="selected"' : '';
$extra_status_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
// Did we submit?
if ($update)
{
$data = array();
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
$extra_row['extra_no'] = $extra_no;
$extra_row['question_type'] = $this->request->variable('question_type', $extra_row['question_type']);
$extra_row['question'] = $this->request->variable('question', $extra_row['question'], true);
$extra_row['matchday'] = $this->request->variable('matchday', $extra_row['matchday']);
$extra_row['matchday_eval'] = $this->request->variable('matchday_eval', $extra_row['matchday_eval']);
$extra_row['extra_points'] = $this->request->variable('extra_points', $extra_row['extra_points']);
$extra_row['extra_status'] = $this->request->variable('extra_status', $extra_row['extra_status']);
$data['extra_points'] = (int) $extra_row['extra_points'];
$data['matchday'] = (int) $extra_row['matchday'];
$data['matchday_eval'] = (int) $extra_row['matchday_eval'];
if ($data['matchday_eval'] < $data['matchday'])
{
$error[] = $user->lang['EVAL_BEFORE_DELIVERY'];
}
if (!sizeof($error))
{
$sql_ary = array(
'season' => (int) $season,
'league' => (int) $league,
'extra_no' => (int) $extra_no,
'question_type' => (int) $extra_row['question_type'],
'question' => strlen($extra_row['question']) ? $extra_row['question'] : '',
'matchday' => (int) $extra_row['matchday'],
'matchday_eval' => (int) $extra_row['matchday_eval'],
'result' => $extra_row['result'],
'extra_points' => (int) $extra_row['extra_points'],
'extra_status' => (int) $extra_row['extra_status'],
);
$var_ary = array(
'extra_points' => array('num', false, 0, 99),
'matchday' => array('num', false, 1),
'matchday_eval' => array('num', false, 1),
);
if (!($error_vals = validate_data($data, $var_ary)))
{
if ($action == 'add')
{
$sql = 'INSERT INTO ' . FOOTB_EXTRA . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
}
else
{
$sql = 'UPDATE ' . FOOTB_EXTRA . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE season = $season AND league = $league AND extra_no = $extra_no";
$db->sql_query($sql);
}
trigger_error($user->lang['EXTRA_UPDATED'] . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"));
}
else
{
foreach ($error_vals as $error_val)
{
$error_msg[] = $user->lang[$error_val];
}
$error[] = $user->lang['EXTRA_UPDATE_FAILED'];
$error = array_merge($error, $error_msg);
}
}
}
}
$u_back = $this->u_action . "&amp;s=$season&amp;l=$league";
$template->assign_vars(array(
'S_EDIT' => true,
'S_ADD_EXTRA' => ($action == 'add') ? true : false,
'S_ERROR' => (sizeof($error)) ? true : false,
'S_EDIT_EXTRAS' => ($existing_extra) ? false : true,
'S_QUESTION_TYPE_OPTIONS' => $question_type_options,
'S_MATCHDAY_OPTIONS' => $matchday_options,
'S_MATCHDAY_EVAL_OPTIONS' => $matchday_eval_options,
'S_EXTRA_STATUS_OPTIONS' => $extra_status_options,
'S_VERSION_NO' => $this->config['football_version'],
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'SEASON' => $season,
'SEASON_NAME' => $season_name,
'LEAGUE' => $league,
'LEAGUE_NAME' => $league_name,
'EXTRA_NO' => $extra_no,
'QUESTION_TYPE' => $extra_row['question_type'],
'QUESTION' => $extra_row['question'],
'MATCHDAY' => $extra_row['matchday'],
'MATCHDAY_EVAL' => $extra_row['matchday_eval'],
'MATCHDAY_OPTION' => $extra_row['matchday'],
'MATCHDAY_EVAL' => $extra_row['matchday_eval'],
'RESULT' => $extra_row['result'],
'EXTRA_POINTS' => $extra_row['extra_points'],
'EXTRA_STATUS' => $extra_row['extra_status'],
'U_BACK' => $u_back,
'U_ACTION' => "{$this->u_action}&amp;action=$action&amp;s=$season&amp;l=$league",
)
);
return;
break;
}
// Check open matchday in league
$sql = 'SELECT *
FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season
AND league = $league
AND status <= 0";
$result = $db->sql_query($sql);
$open_matchdays = sizeof($db->sql_fetchrowset($result));
$db->sql_freeresult($result);
// Get us all the extra
$sql = "SELECT e.*,
m1.matchday_name AS matchday_name,
m2.matchday_name AS matchday_eval_name
FROM " . FOOTB_EXTRA . ' AS e
LEFT JOIN ' . FOOTB_MATCHDAYS . ' AS m1 ON (m1.season = e.season AND m1.league = e.league AND m1.matchday = e.matchday)
LEFT JOIN ' . FOOTB_MATCHDAYS . " AS m2 ON (m2.season = e.season AND m2.league = e.league AND m2.matchday = e.matchday_eval)
WHERE e.season = $season
AND e.league = $league
ORDER BY e.extra_no ASC";
$result = $db->sql_query($sql);
$rows_extra = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet', 's' => $season, 'l' => $league)),
'S_SEASON' => $season,
'S_LEAGUE' => $league,
'S_SEASON_OPTIONS' => $season_options,
'S_LEAGUE_OPTIONS' => $league_options,
'S_EXTRA_ADD' => ($open_matchdays) ? true : false,
'S_VERSION_NO' => $this->config['football_version'],
)
);
// Check if the user is allowed to delete a extra.
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
$allow_delete = false;
}
else
{
$allow_delete = true;
}
$row_number = 0;
foreach ($rows_extra as $row_extra)
{
$row_number++;
$row_class = (!($row_number % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('extras', array(
'ROW_CLASS' => $row_class,
'EXTRA_NO' => $row_extra['extra_no'],
'QUESTION_TYPE' => $row_extra['question_type'],
'QUESTION' => $row_extra['question'],
'MATCHDAY' => (strlen($row_extra['matchday_name']) > 0) ? $row_extra['matchday_name'] : $row_extra['matchday'] . '. ' . sprintf($user->lang['MATCHDAY']),
'MATCHDAY_EVAL' => (strlen($row_extra['matchday_name']) > 0) ? $row_extra['matchday_eval_name'] : $row_extra['matchday_eval'] . '. ' . sprintf($user->lang['MATCHDAY']),
'EXTRA_POINTS' => $row_extra['extra_points'],
'EXTRA_STATUS' => $row_extra['extra_status'],
'U_EDIT' => "{$this->u_action}&amp;action=edit&amp;s=" . $season . "&amp;l=" .$league . "&amp;e=" .$row_extra['extra_no'],
'U_DELETE' => ($allow_delete) ? "{$this->u_action}&amp;action=delete&amp;s=" . $season . "&amp;l=" . $league . "&amp;e=" . $row_extra['extra_no'] : '',
)
);
}
}
}
?>
+437 -425
View File
@@ -1,426 +1,438 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class football_module
{
var $new_config = array();
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log, $phpbb_container, $version_check;
public function __construct()
{
global $db, $user, $request, $template, $phpbb_container;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'help_football');
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_football');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
$this->phpbb_container = $phpbb_container;
$this->version_check = $this->phpbb_container->get('football.football.version.check');
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info, $phpbb_log;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$provider = new \phpbb\controller\ provider();
$symphony_request = new \phpbb\ symfony_request($request);
$filesystem = new \phpbb\ filesystem();
$helper = new \phpbb\controller\ helper($template, $user, $config, $provider, $phpbb_extension_manager, $symphony_request, $request, $filesystem, $phpbb_root_path, $phpEx);
$user->add_lang('acp/board');
$action = $this->request->variable('action', '');
$submit = (isset($_POST['submit'])) ? true : false;
$form_key = 'acp_football';
add_form_key($form_key);
switch ($mode)
{
case 'userguide':
$this->page_title = 'ACP_FOOTBALL_USERGUIDE';
$this->tpl_name = 'acp_football_userguide';
$template->assign_vars(array(
'S_IN_FOOTBALL_USERGUIDE' => true,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet')),
'L_BACK_TO_TOP' => $user->lang['BACK_TO_TOP'],
'ICON_BACK_TO_TOP' => '<img src="' . $phpbb_admin_path . 'images/icon_up.gif" style="vertical-align: middle;" alt="' . $user->lang['BACK_TO_TOP'] . '" title="' . $user->lang['BACK_TO_TOP'] . '" />',
'S_VERSION_NO' => $this->config['football_version'],
));
// Pull the array data from the lang pack
foreach ($user->help as $help_ary)
{
if ($help_ary[0] == '--')
{
$template->assign_block_vars('userguide_block', array(
'BLOCK_TITLE' => $help_ary[1])
);
continue;
}
$template->assign_block_vars('userguide_block.userguide_row', array(
'USERGUIDE_QUESTION' => $help_ary[0],
'USERGUIDE_ANSWER' => $help_ary[1])
);
}
return;
break;
case 'settings':
$display_vars = array(
'title' => 'ACP_FOOTBALL_SETTINGS',
'vars' => array(
'legend1' => 'ACP_FOOTBALL_SETTINGS',
'football_name' => array('lang' => 'FOOTBALL_NAME', 'validate' => 'string', 'type' => 'text:25:25', 'explain' => true),
'football_disable' => array('lang' => 'DISABLE_FOOTBALL', 'validate' => 'bool', 'type' => 'custom', 'method' => 'football_disable', 'explain' => true),
'football_disable_msg' => false,
'football_fullscreen' => array('lang' => 'FOOTBALL_FULLSCREEN','validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_header_enable' => array('lang' => 'FOOTBALL_HEADER_ENABLE','validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_guest_view' => array('lang' => 'GUEST_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_user_view' => array('lang' => 'USER_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_host_timezone' => array('lang' => 'HOST_TIMEZONE', 'validate' => 'string', 'type' => 'select', 'function' => 'phpbb_timezone_select', 'params' => array($template, $user, '{CONFIG_VALUE}', true), 'explain' => true),
'football_info_display' => array('lang' => 'FOOTBALL_INFO', 'validate' => 'bool', 'type' => 'custom', 'method' => 'football_info', 'explain' => true),
'football_info' => false,
'football_win_name' => array('lang' => 'WIN_NAME', 'validate' => 'string', 'type' => 'text:6:6', 'explain' => true),
'football_code' => array('lang' => 'FOOTBALL_CODE', 'validate' => 'string', 'type' => 'text:25:25', 'explain' => true),
'football_style' => array('lang' => 'FOOTBALL_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => false),
'football_override_style' => array('lang' => 'FOOTBALL_OVERRIDE_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_update_source' => array('lang' => 'FOOTBALL_UPDATE_SOURCE', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => true),
'football_update_code' => array('lang' => 'FOOTBALL_UPDATE_CODE', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true),
'legend2' => 'GENERAL_SETTINGS',
'football_left_column_width' => array('lang' => 'LEFT_COLUMN', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'football_right_column_width' => array('lang' => 'RIGHT_COLUMN', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'football_display_ranks' => array('lang' => 'DISPLAY_RANKS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'football_users_per_page' => array('lang' => 'USERS_PAGE', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'legend3' => 'ACP_SUBMIT_CHANGES',
)
);
// show the extension version check on Settings page
$this->version_check->check();
break;
case 'features':
$display_vars = array(
'title' => 'ACP_FOOTBALL_FEATURES',
'vars' => array(
'legend1' => 'ACP_FOOTBALL_FEATURES',
'football_founder_delete' => array('lang' => 'FOUNDER_DELETE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_results_at_time' => array('lang' => 'RESULTS_AT_TIME', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_win_hits02' => array('lang' => 'WIN_HITS02', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_same_allowed' => array('lang' => 'SAME_ALLOWED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_season_start' => array('lang' => 'FOOTBALL_SEASON_START', 'validate' => 'int', 'type' => 'select', 'method' => 'season_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true),
'football_view_current' => array('lang' => 'VIEW_CURRENT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_view_bets' => array('lang' => 'VIEW_BETS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_view_tendencies' => array('lang' => 'VIEW_TENDENCIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_bank' => array('lang' => 'BANK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_ult_points' => array('lang' => 'ULT_POINTS', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_up_method', 'explain' => true),
'football_ult_points_factor'=> array('lang' => 'ULT_POINTS_FACTOR', 'validate' => 'dec:3:2','type' => 'text:4:10', 'explain' => true),
'football_remember_enable' => array('lang' => 'FOOTBALL_REMEMBER_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_remember_next_run'=> array('lang' => 'FOOTBALL_REMEMBER_NEXT_RUN','validate' => 'int', 'type' => 'custom', 'method' => 'next_run', 'explain' => true),
'legend2' => 'ACP_SUBMIT_CHANGES',
)
);
break;
case 'menu':
$display_vars = array(
'title' => 'ACP_FOOTBALL_MENU',
'vars' => array(
'legend1' => 'ACP_FOOTBALL_MENU',
'football_breadcrumb' => array('lang' => 'FOOTBALL_BREADCRUMB', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_side' => array('lang' => 'FOOTBALL_SIDE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_menu' => array('lang' => 'FOOTBALL_MENU', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_menu_link1' => array('lang' => 'MENU_LINK1', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => true),
'football_menu_desc1' => array('lang' => 'MENU_DESC1', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => true),
'football_menu_link2' => array('lang' => 'MENU_LINK2', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => false),
'football_menu_desc2' => array('lang' => 'MENU_DESC2', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => false),
'football_menu_link3' => array('lang' => 'MENU_LINK3', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => false),
'football_menu_desc3' => array('lang' => 'MENU_DESC3', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => false),
)
);
break;
default:
trigger_error('NO_MODE', E_USER_ERROR);
break;
}
if (isset($display_vars['lang']))
{
$user->add_lang($display_vars['lang']);
}
$this->new_config = $this->config;
$cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc($this->request->variable('config', array('' => ''), true)) : $this->new_config;
$error = array();
// We validate the complete config if whished
validate_config_vars($display_vars['vars'], $cfg_array, $error);
if ($submit && !check_form_key($form_key))
{
$error[] = $user->lang['FORM_INVALID'];
}
// Do not write values if there is an error
if (sizeof($error))
{
$submit = false;
}
// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
foreach ($display_vars['vars'] as $this->config_name => $null)
{
if (!isset($cfg_array[$this->config_name]) || strpos($this->config_name, 'legend') !== false)
{
continue;
}
$this->new_config[$this->config_name] = $this->config_value = $cfg_array[$this->config_name];
if ($submit)
{
if ($this->config_name == 'football_ult_points' && $this->config_value)
{
$this->config->set('football_bank', 1);
}
if ($this->config_name == 'football_remember_enable')
{
$day = $this->request->variable('next_run_day', 0);
$month = $this->request->variable('next_run_month', 0);
$year = $this->request->variable('next_run_year', 0);
$hour = $this->request->variable('next_run_hour', 0);
$minute = $this->request->variable('next_run_minute', 0);
$next_run = mktime($hour, $minute, 0, $month, $day, $year);
$this->config->set('football_remember_next_run', $next_run);
}
$this->config->set($this->config_name, $this->config_value);
}
}
if ($submit)
{
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FOOTBALL_' . strtoupper($mode));
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
$this->tpl_name = 'acp_football';
$this->page_title = $display_vars['title'];
$template->assign_vars(array(
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet')),
'L_TITLE' => $user->lang[$display_vars['title']],
'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'],
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => implode('<br />', $error),
'U_ACTION' => $this->u_action,
'S_VERSION_NO' => $this->config['football_version'],
)
);
// Output relevant page
foreach ($display_vars['vars'] as $this->config_key => $vars)
{
if (!is_array($vars) && strpos($this->config_key, 'legend') === false)
{
continue;
}
if (strpos($this->config_key, 'legend') !== false)
{
$template->assign_block_vars('options', array(
'S_LEGEND' => true,
'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars,
)
);
continue;
}
$type = explode(':', $vars['type']);
$l_explain = '';
if ($vars['explain'] && isset($vars['lang_explain']))
{
$l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
}
else if ($vars['explain'])
{
$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
$content = build_cfg_template($type, $this->config_key, $this->new_config, $this->config_key, $vars);
if (empty($content))
{
continue;
}
$template->assign_block_vars('options', array(
'KEY' => $this->config_key,
'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
'S_EXPLAIN' => $vars['explain'],
'TITLE_EXPLAIN' => $l_explain,
'CONTENT' => $content,
)
);
unset($display_vars['vars'][$this->config_key]);
}
}
/**
* Football disable option and message
*/
function football_disable($value, $key)
{
global $user;
$radio_ary = array(1 => 'YES', 0 => 'NO');
return h_radio('config[football_disable]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[football_disable_msg]" maxlength="255" size="80" value="' . $this->new_config['football_disable_msg'] . '" />';
}
/**
* Football info option and message
*/
function football_info($value, $key)
{
global $user;
$radio_ary = array(1 => 'YES', 0 => 'NO');
return h_radio('config[football_info_display]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[football_info]" maxlength="255" size="80" value="' . $this->new_config['football_info'] . '" />';
}
/**
* Select ultimate points method
*/
function select_up_method($value, $key = '')
{
global $user, $config;
$radio_ary = array(UP_NONE => 'UP_NONE', UP_WINS => 'UP_WINS', UP_POINTS => 'UP_POINTS');
return h_radio('config[football_ult_points]', $radio_ary, $value, $key);
}
function season_select($default = 0)
{
global $user, $db;
$sql = 'SELECT DISTINCT s.season, s.season_name_short FROM ' . FOOTB_SEASONS . ' AS s
INNER JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = s.season)
INNER JOIN ' . FOOTB_MATCHDAYS . ' AS md ON (md.season = s.season AND md.league = l.league)
WHERE 1
ORDER BY s.season DESC';
$result = $db->sql_query($sql);
$selected = (0 == $default) ? ' selected="selected"' : '';
$season_options = '<option value="0"' . $selected . '>' . $user->lang['AUTO'] . '</option>';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($row['season'] == $default) ? ' selected="selected"' : '';
$season_options .= '<option value="' . $row['season'] . '"' . $selected . '>' . $row['season_name_short'] . '</option>';
}
$db->sql_freeresult($result);
return $season_options;
}
/**
* Adjust Cronjob EMail remember next un
*/
function next_run($value, $key = '')
{
global $user, $db;
$next_run = getdate($this->config['football_remember_next_run']);
// Days
$day_options = '<select name="next_run_day" id="next_run_day">';
for ($i = 1; $i < 32; $i++)
{
$selected = ($i == $next_run['mday']) ? ' selected="selected"' : '';
$day_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$day_options .= '</select>';
// Months
$month_options = '<select name="next_run_month" id="next_run_month">';
for ($i = 1; $i < 13; $i++)
{
$selected = ($i == $next_run['mon']) ? ' selected="selected"' : '';
$month_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$month_options .= '</select>';
// Years
$year_options = '<select name="next_run_year" id="next_run_year">';
for ($i = date("Y"); $i < (date("Y") + 1); $i++)
{
$selected = ($i == $next_run['year']) ? ' selected="selected"' : '';
$year_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$year_options .= '</select>';
// Hours
$hour_options = '<select name="next_run_hour" id="next_run_hour">';
for ($i = 0; $i < 24; $i++)
{
$selected = ($i == $next_run['hours']) ? ' selected="selected"' : '';
$hour_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$hour_options .= '</select>';
// Minutes
$minute_options = '<select name="next_run_minute" id="next_run_minute">';
for ($i = 0; $i < 60; $i++)
{
$selected = ($i == $next_run['minutes']) ? ' selected="selected"' : '';
$minute_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$minute_options .= '</select>';
return $user->lang['DAY'] . ': ' . $day_options . ' ' . $user->lang['MONTH'] . ': ' . $month_options . ' ' . $user->lang['YEAR'] . ': ' .
$year_options . ' ' . $user->lang['HOURS'] . ': ' . $hour_options . ' ' . $user->lang['MINUTES'] . ': ' . $minute_options;
}
}
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class football_module
{
var $new_config = array();
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log, $phpbb_container, $version_check;
public function __construct()
{
global $db, $user, $request, $template, $phpbb_container;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'help_football');
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_football');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
$this->phpbb_container = $phpbb_container;
$this->version_check = $this->phpbb_container->get('football.football.version.check');
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info, $phpbb_log;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$helper = $phpbb_container->get('controller.helper');
$user->add_lang('acp/board');
$action = $this->request->variable('action', '');
$submit = (isset($_POST['submit'])) ? true : false;
$form_key = 'acp_football';
add_form_key($form_key);
switch ($mode)
{
case 'userguide':
$this->page_title = 'ACP_FOOTBALL_USERGUIDE';
$this->tpl_name = 'acp_football_userguide';
$template->assign_vars(array(
'S_IN_FOOTBALL_USERGUIDE' => true,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet')),
'L_BACK_TO_TOP' => $user->lang['BACK_TO_TOP'],
'ICON_BACK_TO_TOP' => '<img src="' . $phpbb_admin_path . 'images/icon_up.gif" style="vertical-align: middle;" alt="' . $user->lang['BACK_TO_TOP'] . '" title="' . $user->lang['BACK_TO_TOP'] . '" />',
'S_VERSION_NO' => $this->config['football_version'],
));
// Pull the array data from the lang pack
foreach ($user->lang['FOOTBALL_HELP_FAQ'] as $help_ary)
{
if ($help_ary[0] == '--')
{
$template->assign_block_vars('userguide_block', array(
'BLOCK_TITLE' => $help_ary[1])
);
continue;
}
$template->assign_block_vars('userguide_block.userguide_row', array(
'USERGUIDE_QUESTION' => $help_ary[0],
'USERGUIDE_ANSWER' => $help_ary[1])
);
}
return;
break;
case 'settings':
$display_vars = array(
'title' => 'ACP_FOOTBALL_SETTINGS',
'vars' => array(
'legend1' => 'ACP_FOOTBALL_SETTINGS',
'football_name' => array('lang' => 'FOOTBALL_NAME', 'validate' => 'string', 'type' => 'text:25:25', 'explain' => true),
'football_disable' => array('lang' => 'DISABLE_FOOTBALL', 'validate' => 'bool', 'type' => 'custom', 'method' => 'football_disable', 'explain' => true),
'football_disable_msg' => false,
'football_fullscreen' => array('lang' => 'FOOTBALL_FULLSCREEN','validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_header_enable' => array('lang' => 'FOOTBALL_HEADER_ENABLE','validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_guest_view' => array('lang' => 'GUEST_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_user_view' => array('lang' => 'USER_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_time_shift' => array('lang' => 'TIME_SHIFT', 'validate' => 'int', 'type' => 'select', 'method' => 'time_shift_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true),
'football_info_display' => array('lang' => 'FOOTBALL_INFO', 'validate' => 'bool', 'type' => 'custom', 'method' => 'football_info', 'explain' => true),
'football_info' => false,
'football_win_name' => array('lang' => 'WIN_NAME', 'validate' => 'string', 'type' => 'text:6:6', 'explain' => true),
'football_code' => array('lang' => 'FOOTBALL_CODE', 'validate' => 'string', 'type' => 'text:25:25', 'explain' => true),
'football_style' => array('lang' => 'FOOTBALL_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => false),
'football_override_style' => array('lang' => 'FOOTBALL_OVERRIDE_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_update_source' => array('lang' => 'FOOTBALL_UPDATE_SOURCE', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => true),
'football_update_code' => array('lang' => 'FOOTBALL_UPDATE_CODE', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true),
'legend2' => 'GENERAL_SETTINGS',
'football_left_column_width' => array('lang' => 'LEFT_COLUMN', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'football_right_column_width' => array('lang' => 'RIGHT_COLUMN', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'football_display_last_users' => array('lang' => 'DISPLAY_LAST_USERS', 'validate' => 'int','type' => 'text:3:3', 'explain' => true),
'football_display_last_results' => array('lang' => 'DISPLAY_LAST_RESULTS', 'validate' => 'int','type' => 'text:3:3', 'explain' => true),
'football_display_ranks' => array('lang' => 'DISPLAY_RANKS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'football_users_per_page' => array('lang' => 'USERS_PAGE', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'legend3' => 'ACP_SUBMIT_CHANGES',
)
);
// show the extension version check on Settings page
$this->version_check->check();
break;
case 'features':
$display_vars = array(
'title' => 'ACP_FOOTBALL_FEATURES',
'vars' => array(
'legend1' => 'ACP_FOOTBALL_FEATURES',
'football_founder_delete' => array('lang' => 'FOUNDER_DELETE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_results_at_time' => array('lang' => 'RESULTS_AT_TIME', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_win_hits02' => array('lang' => 'WIN_HITS02', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_same_allowed' => array('lang' => 'SAME_ALLOWED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_season_start' => array('lang' => 'FOOTBALL_SEASON_START', 'validate' => 'int', 'type' => 'select', 'method' => 'season_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => true),
'football_view_current' => array('lang' => 'VIEW_CURRENT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_view_bets' => array('lang' => 'VIEW_BETS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_view_tendencies' => array('lang' => 'VIEW_TENDENCIES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_bank' => array('lang' => 'BANK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_ult_points' => array('lang' => 'ULT_POINTS', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_up_method', 'explain' => true),
'football_ult_points_factor'=> array('lang' => 'ULT_POINTS_FACTOR', 'validate' => 'dec:3:2','type' => 'text:4:10', 'explain' => true),
'football_remember_enable' => array('lang' => 'FOOTBALL_REMEMBER_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_remember_next_run'=> array('lang' => 'FOOTBALL_REMEMBER_NEXT_RUN','validate' => 'int', 'type' => 'custom', 'method' => 'next_run', 'explain' => true),
'legend2' => 'ACP_SUBMIT_CHANGES',
)
);
break;
case 'menu':
$display_vars = array(
'title' => 'ACP_FOOTBALL_MENU',
'vars' => array(
'legend1' => 'ACP_FOOTBALL_MENU',
'football_breadcrumb' => array('lang' => 'FOOTBALL_BREADCRUMB', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_side' => array('lang' => 'FOOTBALL_SIDE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_menu' => array('lang' => 'FOOTBALL_MENU', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'football_menu_link1' => array('lang' => 'MENU_LINK1', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => true),
'football_menu_desc1' => array('lang' => 'MENU_DESC1', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => true),
'football_menu_link2' => array('lang' => 'MENU_LINK2', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => false),
'football_menu_desc2' => array('lang' => 'MENU_DESC2', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => false),
'football_menu_link3' => array('lang' => 'MENU_LINK3', 'validate' => 'string', 'type' => 'text:80:255', 'explain' => false),
'football_menu_desc3' => array('lang' => 'MENU_DESC3', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => false),
)
);
break;
default:
trigger_error('NO_MODE', E_USER_ERROR);
break;
}
if (isset($display_vars['lang']))
{
$user->add_lang($display_vars['lang']);
}
$this->new_config = $this->config;
$cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc($this->request->variable('config', array('' => ''), true)) : $this->new_config;
$error = array();
// We validate the complete config if whished
validate_config_vars($display_vars['vars'], $cfg_array, $error);
if ($submit && !check_form_key($form_key))
{
$error[] = $user->lang['FORM_INVALID'];
}
// Do not write values if there is an error
if (sizeof($error))
{
$submit = false;
}
// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
foreach ($display_vars['vars'] as $this->config_name => $null)
{
if (!isset($cfg_array[$this->config_name]) || strpos($this->config_name, 'legend') !== false)
{
continue;
}
$this->new_config[$this->config_name] = $this->config_value = $cfg_array[$this->config_name];
if ($submit)
{
if ($this->config_name == 'football_ult_points' && $this->config_value)
{
$this->config->set('football_bank', 1);
}
if ($this->config_name == 'football_remember_enable')
{
$day = $this->request->variable('next_run_day', 0);
$month = $this->request->variable('next_run_month', 0);
$year = $this->request->variable('next_run_year', 0);
$hour = $this->request->variable('next_run_hour', 0);
$minute = $this->request->variable('next_run_minute', 0);
$next_run = mktime($hour, $minute, 0, $month, $day, $year);
$this->config->set('football_remember_next_run', $next_run);
}
$this->config->set($this->config_name, $this->config_value);
}
}
if ($submit)
{
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FOOTBALL_' . strtoupper($mode));
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
$this->tpl_name = 'acp_football';
$this->page_title = $display_vars['title'];
$template->assign_vars(array(
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet')),
'L_TITLE' => $user->lang[$display_vars['title']],
'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'],
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => implode('<br />', $error),
'U_ACTION' => $this->u_action,
'S_VERSION_NO' => $this->config['football_version'],
)
);
// Output relevant page
foreach ($display_vars['vars'] as $this->config_key => $vars)
{
if (!is_array($vars) && strpos($this->config_key, 'legend') === false)
{
continue;
}
if (strpos($this->config_key, 'legend') !== false)
{
$template->assign_block_vars('options', array(
'S_LEGEND' => true,
'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars,
)
);
continue;
}
$type = explode(':', $vars['type']);
$l_explain = '';
if ($vars['explain'] && isset($vars['lang_explain']))
{
$l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
}
else if ($vars['explain'])
{
$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
$content = build_cfg_template($type, $this->config_key, $this->new_config, $this->config_key, $vars);
if (empty($content))
{
continue;
}
$template->assign_block_vars('options', array(
'KEY' => $this->config_key,
'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
'S_EXPLAIN' => $vars['explain'],
'TITLE_EXPLAIN' => $l_explain,
'CONTENT' => $content,
)
);
unset($display_vars['vars'][$this->config_key]);
}
}
/**
* Football disable option and message
*/
function football_disable($value, $key)
{
global $user;
$radio_ary = array(1 => 'YES', 0 => 'NO');
return h_radio('config[football_disable]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[football_disable_msg]" maxlength="255" size="80" value="' . $this->new_config['football_disable_msg'] . '" />';
}
/**
* Football info option and message
*/
function football_info($value, $key)
{
global $user;
$radio_ary = array(1 => 'YES', 0 => 'NO');
return h_radio('config[football_info_display]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[football_info]" maxlength="255" size="80" value="' . $this->new_config['football_info'] . '" />';
}
/**
* Select ultimate points method
*/
function select_up_method($value, $key = '')
{
global $user, $config;
$radio_ary = array(UP_NONE => 'UP_NONE', UP_WINS => 'UP_WINS', UP_POINTS => 'UP_POINTS');
return h_radio('config[football_ult_points]', $radio_ary, $value, $key);
}
function season_select($default = 0)
{
global $user, $db;
$sql = 'SELECT DISTINCT s.season, s.season_name_short FROM ' . FOOTB_SEASONS . ' AS s
INNER JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = s.season)
INNER JOIN ' . FOOTB_MATCHDAYS . ' AS md ON (md.season = s.season AND md.league = l.league)
WHERE 1
ORDER BY s.season DESC';
$result = $db->sql_query($sql);
$selected = (0 == $default) ? ' selected="selected"' : '';
$season_options = '<option value="0"' . $selected . '>' . $user->lang['AUTO'] . '</option>';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($row['season'] == $default) ? ' selected="selected"' : '';
$season_options .= '<option value="' . $row['season'] . '"' . $selected . '>' . $row['season_name_short'] . '</option>';
}
$db->sql_freeresult($result);
return $season_options;
}
/**
* Adjust Cronjob EMail remember next run
*/
function next_run($value, $key = '')
{
global $user, $db;
$next_run = getdate($this->config['football_remember_next_run']);
// Days
$day_options = '<select name="next_run_day" id="next_run_day">';
for ($i = 1; $i < 32; $i++)
{
$selected = ($i == $next_run['mday']) ? ' selected="selected"' : '';
$day_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$day_options .= '</select>';
// Months
$month_options = '<select name="next_run_month" id="next_run_month">';
for ($i = 1; $i < 13; $i++)
{
$selected = ($i == $next_run['mon']) ? ' selected="selected"' : '';
$month_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$month_options .= '</select>';
// Years
$year_options = '<select name="next_run_year" id="next_run_year">';
for ($i = date("Y"); $i < (date("Y") + 1); $i++)
{
$selected = ($i == $next_run['year']) ? ' selected="selected"' : '';
$year_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$year_options .= '</select>';
// Hours
$hour_options = '<select name="next_run_hour" id="next_run_hour">';
for ($i = 0; $i < 24; $i++)
{
$selected = ($i == $next_run['hours']) ? ' selected="selected"' : '';
$hour_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$hour_options .= '</select>';
// Minutes
$minute_options = '<select name="next_run_minute" id="next_run_minute">';
for ($i = 0; $i < 60; $i++)
{
$selected = ($i == $next_run['minutes']) ? ' selected="selected"' : '';
$minute_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
$minute_options .= '</select>';
return $user->lang['DAY'] . ': ' . $day_options . ' ' . $user->lang['MONTH'] . ': ' . $month_options . ' ' . $user->lang['YEAR'] . ': ' .
$year_options . ' ' . $user->lang['HOURS'] . ': ' . $hour_options . ' ' . $user->lang['MINUTES'] . ': ' . $minute_options;
}
function time_shift_select($default = 0)
{
$time_shift_options = "";
for ($i = -23; $i < 24; $i++)
{
$selected = ($i == $default) ? ' selected="selected"' : '';
$time_shift_options .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
return $time_shift_options;
}
}
?>
+254 -256
View File
@@ -1,257 +1,255 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class ko_module
{
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log;
public function __construct()
{
global $db, $user, $request, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_ko');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$provider = new \phpbb\controller\ provider();
$symphony_request = new \phpbb\ symfony_request($request);
$filesystem = new \phpbb\ filesystem();
$helper = new \phpbb\controller\ helper($template, $user, $config, $provider, $phpbb_extension_manager, $symphony_request, $request, $filesystem, $phpbb_root_path, $phpEx);
$this->tpl_name = 'acp_football_ko';
$this->page_title = 'ACP_FOOTBALL_KO_MANAGE';
$form_key = 'acp_football_ko';
add_form_key($form_key);
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
// Check and set some common vars
$action = (isset($_POST['update'])) ? 'update' : $this->request->variable('action', '');
$season = $this->request->variable('s', 0);
$league = $this->request->variable('l', 0);
$matchday_from = $this->request->variable('matchday_from', 0);
$matchday_to = $this->request->variable('matchday_to', 0);
$matchday_new = $this->request->variable('matchday_new', 0);
$check_rank = $this->request->variable('check_rank', 0);
$rank = $this->request->variable('rank', 2);
$move_rank = $this->request->variable('move_rank', 3);
$move_league = $this->request->variable('move_league', 0);
$move_matchday = $this->request->variable('move_matchday', 8);
// Clear some vars
$error = array();
$success = array();
$curr_season = curr_season();
// Grab current season
if (!$season)
{
$season = $curr_season;
}
// Grab basic data for select season
if ($season)
{
$sql = 'SELECT
DISTINCT s.*
FROM ' . FOOTB_SEASONS . ' AS s
LEFT JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = s.season)
WHERE l.league_type = 2
ORDER BY s.season DESC';
$result = $db->sql_query($sql);
$season_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($season && $row['season'] == $season) ? ' selected="selected"' : '';
$season_options .= '<option value="' . $row['season'] . '"' . $selected . '>' . $row['season_name_short'] . '</option>';
if ($selected <> '')
{
$season_name = $row['season_name_short'];
}
}
$db->sql_freeresult($result);
}
else
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Grab basic data for select league
$sql = 'SELECT *
FROM ' . FOOTB_LEAGUES . '
WHERE season = ' . $season . '
AND league_type = ' . LEAGUE_KO . '
ORDER BY league ASC';
$result = $db->sql_query($sql);
$league_options = '';
if ($move_league == 0)
{
$league_move_options = '<option value="0" selected="selected">' . sprintf($user->lang['CHOOSE_LEAGUE']) . '</option>';
}
else
{
$league_move_options = '<option value="0">' . sprintf($user->lang['CHOOSE_LEAGUE']) . '</option>';
}
while ($row = $db->sql_fetchrow($result))
{
// Grab current league
if (!$league)
{
$league = $row['league'];
}
$selected = ($league && $row['league'] == $league) ? ' selected="selected"' : '';
$league_options .= '<option value="' . $row['league'] . '"' . $selected . '>' . $row['league_name'] . '</option>';
if ($selected <> '')
{
$league_matchdays = $row['matchdays'];
$matches_matchday = $row['matches_on_matchday'];
$league_name = $row['league_name'];
}
else
{
$selected_move = ($move_league && $row['league'] == $move_league) ? ' selected="selected"' : '';
$league_move_options .= '<option value="' . $row['league'] . '"' . $selected_move . '>' . $row['league_name'] . '</option>';
}
}
$db->sql_freeresult($result);
if (!$league)
{
trigger_error(sprintf($user->lang['NO_LEAGUE'], $season) . adm_back_link($this->u_action . "&amp;s=$season"), E_USER_WARNING);
}
// Grab basic data for select matchday
if (!$matchday_from)
{
$matchday_from = curr_matchday($season, $league);
if ($matchday_from > 1)
{
$matchday_from = $matchday_from - 1;
}
}
if (!$matchday_to)
{
$matchday_to = $matchday_from;
}
if (!$matchday_new)
{
$matchday_new = $matchday_to + 1;
}
$sql = 'SELECT *
FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season
AND league = $league
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
$matchday_from_options = '';
$matchday_to_options = '';
$matchday_new_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected_from = ($matchday_from && $row['matchday'] == $matchday_from) ? ' selected="selected"' : '';
$selected_to = ($matchday_to && $row['matchday'] == $matchday_to) ? ' selected="selected"' : '';
$selected_new = ($matchday_new && $row['matchday'] == $matchday_new) ? ' selected="selected"' : '';
$day_name = (strlen($row['matchday_name']) > 0) ? $row['matchday_name'] : $row['matchday'] . '. ' . sprintf($user->lang['MATCHDAY']);
$matchday_from_options .= '<option value="' . $row['matchday'] . '"' . $selected_from . '>' . $day_name . '</option>';
$matchday_to_options .= '<option value="' . $row['matchday'] . '"' . $selected_to . '>' . $day_name . '</option>';
$matchday_new_options .= '<option value="' . $row['matchday'] . '"' . $selected_new . '>' . $day_name . '</option>';
}
$db->sql_freeresult($result);
if ($matchday_from_options == '')
{
trigger_error(sprintf($user->lang['NO_MATCHDAY'], $league_name, $season) . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
// Which page?
switch ($action)
{
case 'update':
{
if ($matchday_from > $matchday_to)
{
$error[] = sprintf($user->lang['ERROR_FROM_TO']);
}
if ($matchday_new <= $matchday_to)
{
$error[] = sprintf($user->lang['ERROR_TARGET']);
}
if (!sizeof($error))
{
if (1 == $check_rank)
{
$success = ko_group_next_round($season, $league, $matchday_from, $matchday_to, $matchday_new, $rank, $move_rank, $move_league, $move_matchday);
}
else
{
$success = ko_next_round($season, $league, $matchday_from, $matchday_to, $matchday_new);
}
trigger_error($success . adm_back_link($this->u_action));
}
}
break;
}
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet', 's' => $season, 'l' => $league)),
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'S_SUCCESS' => (sizeof($success)) ? true : false,
'SUCCESS_MSG' => (sizeof($success)) ? implode('<br />', $success) : '',
'S_SEASON_OPTIONS' => $season_options,
'S_LEAGUE_OPTIONS' => $league_options,
'S_SEASON' => $season,
'S_LEAGUE' => $league,
'S_MATCHDAY_FROM_OPTIONS'=> $matchday_from_options,
'S_MATCHDAY_TO_OPTIONS' => $matchday_to_options,
'S_MATCHDAY_NEW_OPTIONS'=> $matchday_new_options,
'S_CHECK_RANK' => $check_rank,
'S_RANK' => $rank,
'S_MOVE_RANK' => $move_rank,
'S_MOVE_LEAGUE_OPTIONS' => $league_move_options,
'S_MOVE_MATCHDAY' => $move_matchday,
'S_VERSION_NO' => $this->config['football_version'],
)
);
}
}
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class ko_module
{
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log;
public function __construct()
{
global $db, $user, $request, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_ko');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$helper = $phpbb_container->get('controller.helper');
$this->tpl_name = 'acp_football_ko';
$this->page_title = 'ACP_FOOTBALL_KO_MANAGE';
$form_key = 'acp_football_ko';
add_form_key($form_key);
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
// Check and set some common vars
$action = (isset($_POST['update'])) ? 'update' : $this->request->variable('action', '');
$season = $this->request->variable('s', 0);
$league = $this->request->variable('l', 0);
$matchday_from = $this->request->variable('matchday_from', 0);
$matchday_to = $this->request->variable('matchday_to', 0);
$matchday_new = $this->request->variable('matchday_new', 0);
$check_rank = $this->request->variable('check_rank', 0);
$rank = $this->request->variable('rank', 2);
$move_rank = $this->request->variable('move_rank', 3);
$move_league = $this->request->variable('move_league', 0);
$move_matchday = $this->request->variable('move_matchday', 8);
// Clear some vars
$error = array();
$success = array();
$curr_season = curr_season();
// Grab current season
if (!$season)
{
$season = $curr_season;
}
// Grab basic data for select season
if ($season)
{
$sql = 'SELECT
DISTINCT s.*
FROM ' . FOOTB_SEASONS . ' AS s
LEFT JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = s.season)
WHERE l.league_type = 2
ORDER BY s.season DESC';
$result = $db->sql_query($sql);
$season_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected = ($season && $row['season'] == $season) ? ' selected="selected"' : '';
$season_options .= '<option value="' . $row['season'] . '"' . $selected . '>' . $row['season_name_short'] . '</option>';
if ($selected <> '')
{
$season_name = $row['season_name_short'];
}
}
$db->sql_freeresult($result);
}
else
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Grab basic data for select league
$sql = 'SELECT *
FROM ' . FOOTB_LEAGUES . '
WHERE season = ' . $season . '
AND league_type = ' . LEAGUE_KO . '
ORDER BY league ASC';
$result = $db->sql_query($sql);
$league_options = '';
if ($move_league == 0)
{
$league_move_options = '<option value="0" selected="selected">' . sprintf($user->lang['CHOOSE_LEAGUE']) . '</option>';
}
else
{
$league_move_options = '<option value="0">' . sprintf($user->lang['CHOOSE_LEAGUE']) . '</option>';
}
while ($row = $db->sql_fetchrow($result))
{
// Grab current league
if (!$league)
{
$league = $row['league'];
}
$selected = ($league && $row['league'] == $league) ? ' selected="selected"' : '';
$league_options .= '<option value="' . $row['league'] . '"' . $selected . '>' . $row['league_name'] . '</option>';
if ($selected <> '')
{
$league_matchdays = $row['matchdays'];
$matches_matchday = $row['matches_on_matchday'];
$league_name = $row['league_name'];
}
else
{
$selected_move = ($move_league && $row['league'] == $move_league) ? ' selected="selected"' : '';
$league_move_options .= '<option value="' . $row['league'] . '"' . $selected_move . '>' . $row['league_name'] . '</option>';
}
}
$db->sql_freeresult($result);
if (!$league)
{
trigger_error(sprintf($user->lang['NO_LEAGUE'], $season) . adm_back_link($this->u_action . "&amp;s=$season"), E_USER_WARNING);
}
// Grab basic data for select matchday
if (!$matchday_from)
{
$matchday_from = curr_matchday($season, $league);
if ($matchday_from > 1)
{
$matchday_from = $matchday_from - 1;
}
}
if (!$matchday_to)
{
$matchday_to = $matchday_from;
}
if (!$matchday_new)
{
$matchday_new = $matchday_to + 1;
}
$sql = 'SELECT *
FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season
AND league = $league
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
$matchday_from_options = '';
$matchday_to_options = '';
$matchday_new_options = '';
while ($row = $db->sql_fetchrow($result))
{
$selected_from = ($matchday_from && $row['matchday'] == $matchday_from) ? ' selected="selected"' : '';
$selected_to = ($matchday_to && $row['matchday'] == $matchday_to) ? ' selected="selected"' : '';
$selected_new = ($matchday_new && $row['matchday'] == $matchday_new) ? ' selected="selected"' : '';
$day_name = (strlen($row['matchday_name']) > 0) ? $row['matchday_name'] : $row['matchday'] . '. ' . sprintf($user->lang['MATCHDAY']);
$matchday_from_options .= '<option value="' . $row['matchday'] . '"' . $selected_from . '>' . $day_name . '</option>';
$matchday_to_options .= '<option value="' . $row['matchday'] . '"' . $selected_to . '>' . $day_name . '</option>';
$matchday_new_options .= '<option value="' . $row['matchday'] . '"' . $selected_new . '>' . $day_name . '</option>';
}
$db->sql_freeresult($result);
if ($matchday_from_options == '')
{
trigger_error(sprintf($user->lang['NO_MATCHDAY'], $league_name, $season) . adm_back_link($this->u_action . "&amp;s=$season&amp;l=$league"), E_USER_WARNING);
}
// Which page?
switch ($action)
{
case 'update':
{
if ($matchday_from > $matchday_to)
{
$error[] = sprintf($user->lang['ERROR_FROM_TO']);
}
if ($matchday_new <= $matchday_to)
{
$error[] = sprintf($user->lang['ERROR_TARGET']);
}
if (!sizeof($error))
{
if (1 == $check_rank)
{
$success = ko_group_next_round($season, $league, $matchday_from, $matchday_to, $matchday_new, $rank, $move_rank, $move_league, $move_matchday);
}
else
{
$success = ko_next_round($season, $league, $matchday_from, $matchday_to, $matchday_new);
}
trigger_error($success . adm_back_link($this->u_action));
}
}
break;
}
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet', 's' => $season, 'l' => $league)),
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'S_SUCCESS' => (sizeof($success)) ? true : false,
'SUCCESS_MSG' => (sizeof($success)) ? implode('<br />', $success) : '',
'S_SEASON_OPTIONS' => $season_options,
'S_LEAGUE_OPTIONS' => $league_options,
'S_SEASON' => $season,
'S_LEAGUE' => $league,
'S_MATCHDAY_FROM_OPTIONS'=> $matchday_from_options,
'S_MATCHDAY_TO_OPTIONS' => $matchday_to_options,
'S_MATCHDAY_NEW_OPTIONS'=> $matchday_new_options,
'S_CHECK_RANK' => $check_rank,
'S_RANK' => $rank,
'S_MOVE_RANK' => $move_rank,
'S_MOVE_LEAGUE_OPTIONS' => $league_move_options,
'S_MOVE_MATCHDAY' => $move_matchday,
'S_VERSION_NO' => $this->config['football_version'],
)
);
}
}
?>
+753 -735
View File
File diff suppressed because it is too large Load Diff
+1133 -1133
View File
File diff suppressed because it is too large Load Diff
+786 -766
View File
File diff suppressed because it is too large Load Diff
+821 -818
View File
File diff suppressed because it is too large Load Diff
+393 -395
View File
@@ -1,396 +1,394 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class seasons_module
{
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log;
public function __construct()
{
global $db, $user, $request, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_seasons');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$provider = new \phpbb\controller\ provider();
$symphony_request = new \phpbb\ symfony_request($request);
$filesystem = new \phpbb\ filesystem();
$helper = new \phpbb\controller\ helper($template, $user, $config, $provider, $phpbb_extension_manager, $symphony_request, $request, $filesystem, $phpbb_root_path, $phpEx);
$this->tpl_name = 'acp_football_seasons';
$this->page_title = 'ACP_FOOTBALL_SEASONS_MANAGE';
$form_key = 'acp_football_seasons';
add_form_key($form_key);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
// Check and set some common vars
$action = (isset($_POST['add'])) ? 'add' : $this->request->variable('action', '');
$season = $this->request->variable('s', 0);
$edit = $this->request->variable('edit', 0);
$update = (isset($_POST['update'])) ? true : false;
// Clear some vars
$season_row = array();
$error = array();
// Grab basic data for season, if season is set and exists
if ($season)
{
$sql = 'SELECT *
FROM ' . FOOTB_SEASONS . "
WHERE season = $season";
$result = $db->sql_query($sql);
$season_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
// Which page?
switch ($action)
{
case 'delete':
if (!$season)
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (confirm_box(true))
{
$error = '';
if (!$auth->acl_get('a_football_delete'))
{
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
trigger_error($user->lang['SEASONS_NO_DELETE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Delete season
$sql = 'DELETE FROM ' . FOOTB_SEASONS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete leagues
$sql = 'DELETE FROM ' . FOOTB_LEAGUES . "
WHERE season = $season";
$db->sql_query($sql);
// Delete matchdays
$sql = 'DELETE FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete matches
$sql = 'DELETE FROM ' . FOOTB_MATCHES . "
WHERE season = $season";
$db->sql_query($sql);
// Delete teams
$sql = 'DELETE FROM ' . FOOTB_TEAMS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete ranks
$sql = 'DELETE FROM ' . FOOTB_RANKS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete bets
$sql = 'DELETE FROM ' . FOOTB_BETS . "
WHERE season = $season";
$db->sql_query($sql);
trigger_error($user->lang['SEASON_DELETED'] . adm_back_link($this->u_action));
}
else
{
confirm_box(false, sprintf($user->lang['SEASON_CONFIRM_DELETE'], $season), build_hidden_fields(array(
's' => $season,
'mode' => $mode,
'action' => $action))
);
}
break;
case 'add':
if ($season >= 1963 AND $season <= 2099)
{
if ($season_row)
{
if ($edit)
{
$error[] = $user->lang['SEASON_TAKEN'];
}
else
{
trigger_error($user->lang['SEASON_TAKEN'] . adm_back_link($this->u_action), E_USER_WARNING);
}
}
$season_row['season_name'] = utf8_normalize_nfc($this->request->variable('season_name', '', true));
if ($season_row['season_name'] <> '')
{
$sql = 'SELECT
season_name
FROM ' . FOOTB_SEASONS . "
WHERE season_name = '" . $season_row['season_name'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
$error[] = $user->lang['SEASON_NAME_TAKEN'];
}
}
else
{
$intseason = ((int) $season) - 1;
$season_row['season_name'] = $user->lang['SEASON'] . ' ' . $intseason . '/' . $season;
}
$season_row['season_name_short'] = utf8_normalize_nfc($this->request->variable('season_short', '', true));
if ($season_row['season_name_short'] <> '')
{
$sql = 'SELECT
season_name_short
FROM ' . FOOTB_SEASONS . "
WHERE season_name_short = '" . $season_row['season_name_short'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
$error[] = $user->lang['SEASON_SHORT_TAKEN'];
}
}
else
{
$intseason = ((int) $season) - 1;
$season_row['season_name_short'] = $intseason . '/' . $season;
}
}
else
{
trigger_error($user->lang['SEASON_NUMBER'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// No break for edit add
case 'edit':
$data = array();
if (!sizeof($error))
{
if ($action == 'edit' && !$season)
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Did we submit?
if ($update)
{
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
return;
}
$season_row['season_name'] = utf8_normalize_nfc($this->request->variable('season_name', '', true));
if ($season_row['season_name'] <> '')
{
$sql = 'SELECT
season
FROM ' . FOOTB_SEASONS . "
WHERE season_name = '" . $season_row['season_name'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
if ($row['season'] <> $season)
{
$error[] = $user->lang['SEASON_NAME_TAKEN'];
}
}
}
else
{
$error[] = $user->lang['SEASON_NAME_EMPTY'];
}
$season_row['season_name_short'] = utf8_normalize_nfc($this->request->variable('season_short', '', true));
if ($season_row['season_name_short'] <> '')
{
$sql = 'SELECT
season
FROM ' . FOOTB_SEASONS . "
WHERE season_name_short = '" . $season_row['season_name_short'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
if ($row['season'] <> $season)
{
$error[] = $user->lang['SEASON_SHORT_TAKEN'];
}
}
}
else
{
$error[] = $user->lang['SEASON_SHORT_EMPTY'];
}
if (!sizeof($error))
{
$sql_ary = array(
'season' => (int) $season,
'season_name' => $season_row['season_name'],
'season_name_short' => $season_row['season_name_short'],
);
$data['season'] = $season;
$data['season_name'] = $this->request->variable('season_name', '');
$data['season_short'] = $this->request->variable('season_short', '');
$var_ary = array(
'season' => array('num', false, 1963, 2099),
'season_name' => array('string', false, 4, 20),
'season_short' => array('string', false, 2, 10),
);
if (!($error_vals = validate_data($data, $var_ary)))
{
if ($action == 'add')
{
$sql = 'INSERT INTO ' . FOOTB_SEASONS . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
}
else
{
$sql = 'UPDATE ' . FOOTB_SEASONS . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE season = $season";
$db->sql_query($sql);
}
$message = ($action == 'edit') ? 'SEASON_UPDATED' : 'SEASON_CREATED';
trigger_error($user->lang[$message] . adm_back_link($this->u_action));
}
else
{
foreach ($error_vals as $error_val)
{
$error_msg[] = $user->lang[$error_val];
}
$message = ($action == 'edit') ? 'SEASON_UPDATE_FAILED' : 'SEASON_CREATE_FAILED';
$error[] = $user->lang[$message];
$error = array_merge($error, $error_msg);
}
}
}
}
$u_back = $this->u_action;
$template->assign_vars(array(
'S_EDIT' => true,
'S_ADD_SEASON' => ($action == 'add') ? true : false,
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'SEASON' => $season,
'SEASON_NAME' => $season_row['season_name'],
'SEASON_SHORT' => $season_row['season_name_short'],
'U_BACK' => $u_back,
'U_ACTION' => "{$this->u_action}&amp;action=$action&amp;s=$season",
)
);
return;
break;
}
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet')),
'S_SEASON_ADD' => true,
)
);
// Get us all the seasons
$sql = 'SELECT
s.season,
s.season_name,
s.season_name_short,
COUNT(l.league) AS leagues
FROM ' . FOOTB_SEASONS . ' s
LEFT JOIN ' . FOOTB_LEAGUES . ' l on l.season = s.season
GROUP BY season
ORDER BY season DESC';
$result = $db->sql_query($sql);
$rows_seasons = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
// Check if the user is allowed to delete a season.
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
$allow_delete = false;
}
else
{
$allow_delete = true;
}
$row_number = 0;
foreach ($rows_seasons as $row_season)
{
$row_number++;
$row_class = (!($row_number % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('seasons', array(
'ROW_CLASS' => $row_class,
'SEASON' => $row_season['season'],
'SEASON_NAME' => $row_season['season_name'],
'SEASON_SHORT' => $row_season['season_name_short'],
'LEAGUES' => $row_season['leagues'],
'U_EDIT' => "{$this->u_action}&amp;action=edit&amp;s=" .$row_season['season'],
'U_DELETE' => ($allow_delete) ? "{$this->u_action}&amp;action=delete&amp;s=" . $row_season['season'] : '',
)
);
}
}
}
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\acp;
class seasons_module
{
public $u_action;
protected $db, $user, $template, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
protected $root_path, $request, $php_ext, $log;
public function __construct()
{
global $db, $user, $request, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang_ext('football/football', 'football');
$user->add_lang_ext('football/football', 'info_acp_seasons');
$this->root_path = $phpbb_root_path . 'ext/football/football/';
$this->config = $config;
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->php_ext = $phpEx;
if(!function_exists('season_info'))
{
include($this->root_path . 'includes/functions.' . $this->php_ext);
}
if (!defined('FOOTB_SEASONS'))
{
include($this->root_path . 'includes/constants.' . $this->php_ext);
}
}
function main($id, $mode)
{
global $db, $auth, $phpbb_container, $phpbb_admin_path, $league_info;
global $template, $user, $config, $phpbb_extension_manager, $request, $phpbb_root_path, $phpEx;
$helper = $phpbb_container->get('controller.helper');
$this->tpl_name = 'acp_football_seasons';
$this->page_title = 'ACP_FOOTBALL_SEASONS_MANAGE';
$form_key = 'acp_football_seasons';
add_form_key($form_key);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
// Check and set some common vars
$action = (isset($_POST['add'])) ? 'add' : $this->request->variable('action', '');
$season = $this->request->variable('s', 0);
$edit = $this->request->variable('edit', 0);
$update = (isset($_POST['update'])) ? true : false;
// Clear some vars
$season_row = array();
$error = array();
// Grab basic data for season, if season is set and exists
if ($season)
{
$sql = 'SELECT *
FROM ' . FOOTB_SEASONS . "
WHERE season = $season";
$result = $db->sql_query($sql);
$season_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
}
// Which page?
switch ($action)
{
case 'delete':
if (!$season)
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (confirm_box(true))
{
$error = '';
if (!$auth->acl_get('a_football_delete'))
{
trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
trigger_error($user->lang['SEASONS_NO_DELETE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Delete season
$sql = 'DELETE FROM ' . FOOTB_SEASONS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete leagues
$sql = 'DELETE FROM ' . FOOTB_LEAGUES . "
WHERE season = $season";
$db->sql_query($sql);
// Delete matchdays
$sql = 'DELETE FROM ' . FOOTB_MATCHDAYS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete matches
$sql = 'DELETE FROM ' . FOOTB_MATCHES . "
WHERE season = $season";
$db->sql_query($sql);
// Delete teams
$sql = 'DELETE FROM ' . FOOTB_TEAMS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete ranks
$sql = 'DELETE FROM ' . FOOTB_RANKS . "
WHERE season = $season";
$db->sql_query($sql);
// Delete bets
$sql = 'DELETE FROM ' . FOOTB_BETS . "
WHERE season = $season";
$db->sql_query($sql);
trigger_error($user->lang['SEASON_DELETED'] . adm_back_link($this->u_action));
}
else
{
confirm_box(false, sprintf($user->lang['SEASON_CONFIRM_DELETE'], $season), build_hidden_fields(array(
's' => $season,
'mode' => $mode,
'action' => $action))
);
}
break;
case 'add':
if ($season >= 1963 AND $season <= 2099)
{
if ($season_row)
{
if ($edit)
{
$error[] = $user->lang['SEASON_TAKEN'];
}
else
{
trigger_error($user->lang['SEASON_TAKEN'] . adm_back_link($this->u_action), E_USER_WARNING);
}
}
$season_row['season_name'] = utf8_normalize_nfc($this->request->variable('season_name', '', true));
if ($season_row['season_name'] <> '')
{
$sql = 'SELECT
season_name
FROM ' . FOOTB_SEASONS . "
WHERE season_name = '" . $season_row['season_name'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
$error[] = $user->lang['SEASON_NAME_TAKEN'];
}
}
else
{
$intseason = ((int) $season) - 1;
$season_row['season_name'] = $user->lang['SEASON'] . ' ' . $intseason . '/' . $season;
}
$season_row['season_name_short'] = utf8_normalize_nfc($this->request->variable('season_short', '', true));
if ($season_row['season_name_short'] <> '')
{
$sql = 'SELECT
season_name_short
FROM ' . FOOTB_SEASONS . "
WHERE season_name_short = '" . $season_row['season_name_short'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
$error[] = $user->lang['SEASON_SHORT_TAKEN'];
}
}
else
{
$intseason = ((int) $season) - 1;
$season_row['season_name_short'] = $intseason . '/' . $season;
}
}
else
{
trigger_error($user->lang['SEASON_NUMBER'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// No break for edit add
case 'edit':
$data = array();
if (!sizeof($error))
{
if ($action == 'edit' && !$season)
{
trigger_error($user->lang['NO_SEASON'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Did we submit?
if ($update)
{
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
return;
}
$season_row['season_name'] = utf8_normalize_nfc($this->request->variable('season_name', '', true));
if ($season_row['season_name'] <> '')
{
$sql = 'SELECT
season
FROM ' . FOOTB_SEASONS . "
WHERE season_name = '" . $season_row['season_name'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
if ($row['season'] <> $season)
{
$error[] = $user->lang['SEASON_NAME_TAKEN'];
}
}
}
else
{
$error[] = $user->lang['SEASON_NAME_EMPTY'];
}
$season_row['season_name_short'] = utf8_normalize_nfc($this->request->variable('season_short', '', true));
if ($season_row['season_name_short'] <> '')
{
$sql = 'SELECT
season
FROM ' . FOOTB_SEASONS . "
WHERE season_name_short = '" . $season_row['season_name_short'] . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
if ($row['season'] <> $season)
{
$error[] = $user->lang['SEASON_SHORT_TAKEN'];
}
}
}
else
{
$error[] = $user->lang['SEASON_SHORT_EMPTY'];
}
if (!sizeof($error))
{
$sql_ary = array(
'season' => (int) $season,
'season_name' => $season_row['season_name'],
'season_name_short' => $season_row['season_name_short'],
);
$data['season'] = $season;
$data['season_name'] = $this->request->variable('season_name', '');
$data['season_short'] = $this->request->variable('season_short', '');
$var_ary = array(
'season' => array('num', false, 1963, 2099),
'season_name' => array('string', false, 4, 20),
'season_short' => array('string', false, 2, 10),
);
if (!($error_vals = validate_data($data, $var_ary)))
{
if ($action == 'add')
{
$sql = 'INSERT INTO ' . FOOTB_SEASONS . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
}
else
{
$sql = 'UPDATE ' . FOOTB_SEASONS . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE season = $season";
$db->sql_query($sql);
}
$message = ($action == 'edit') ? 'SEASON_UPDATED' : 'SEASON_CREATED';
trigger_error($user->lang[$message] . adm_back_link($this->u_action));
}
else
{
foreach ($error_vals as $error_val)
{
$error_msg[] = $user->lang[$error_val];
}
$message = ($action == 'edit') ? 'SEASON_UPDATE_FAILED' : 'SEASON_CREATE_FAILED';
$error[] = $user->lang[$message];
$error = array_merge($error, $error_msg);
}
}
}
}
$u_back = $this->u_action;
$template->assign_vars(array(
'S_EDIT' => true,
'S_ADD_SEASON' => ($action == 'add') ? true : false,
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
'SEASON' => $season,
'SEASON_NAME' => $season_row['season_name'],
'SEASON_SHORT' => $season_row['season_name_short'],
'U_BACK' => $u_back,
'U_ACTION' => "{$this->u_action}&amp;action=$action&amp;s=$season",
)
);
return;
break;
}
$template->assign_vars(array(
'U_ACTION' => $this->u_action,
'U_FOOTBALL' => $helper->route('football_main_controller',array('side' => 'bet')),
'S_SEASON_ADD' => true,
)
);
// Get us all the seasons
$sql = 'SELECT
s.season,
s.season_name,
s.season_name_short,
COUNT(l.league) AS leagues
FROM ' . FOOTB_SEASONS . ' s
LEFT JOIN ' . FOOTB_LEAGUES . ' l on l.season = s.season
GROUP BY season
ORDER BY season DESC';
$result = $db->sql_query($sql);
$rows_seasons = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
// Check if the user is allowed to delete a season.
if ($user->data['user_type'] != USER_FOUNDER && $this->config['football_founder_delete'])
{
$allow_delete = false;
}
else
{
$allow_delete = true;
}
$row_number = 0;
foreach ($rows_seasons as $row_season)
{
$row_number++;
$row_class = (!($row_number % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('seasons', array(
'ROW_CLASS' => $row_class,
'SEASON' => $row_season['season'],
'SEASON_NAME' => $row_season['season_name'],
'SEASON_SHORT' => $row_season['season_name_short'],
'LEAGUES' => $row_season['leagues'],
'U_EDIT' => "{$this->u_action}&amp;action=edit&amp;s=" .$row_season['season'],
'U_DELETE' => ($allow_delete) ? "{$this->u_action}&amp;action=delete&amp;s=" . $row_season['season'] : '',
)
);
}
}
}
?>
+656 -658
View File
File diff suppressed because it is too large Load Diff
+1463 -1461
View File
File diff suppressed because it is too large Load Diff
+5 -1
View File
@@ -33,7 +33,7 @@
</dl>
<dl>
<dt><label for="league_name">{L_LEAGUE_NAME}:</label></dt>
<dd><input name="league_name" type="text" id="league_name" size="20" maxlength="20" value="{LEAGUE_NAME}" /></dd>
<dd><input name="league_name" type="text" id="league_name" size="25" maxlength="21" value="{LEAGUE_NAME}" /></dd>
</dl>
<dl>
<dt><label for="league_short">{L_LEAGUE_SHORT}:</label><br /><span>{L_LEAGUE_SHORT_EXPLAIN}</span></dt>
@@ -100,6 +100,10 @@
</dd>
</dl>
<!-- ENDIF -->
<dl>
<dt><label for="bet_type">{L_BET_TYPE}:</label><br /><span>{L_BET_TYPE_EXPLAIN}</span></dt>
<dd><input name="bet_type" type="checkbox" id="bet_type" <!-- IF S_BET_TYPE -->checked="checked" <!-- ENDIF --> /></dd>
</dl>
</fieldset>
<fieldset>
+4
View File
@@ -96,6 +96,10 @@
<dd><input name="formula_guest" type="text" id="formula_guest" size="9" maxlength="9" value="{FORMULA_GUEST}" /></dd>
</dl>
<!-- ENDIF -->
<dl>
<dt><label for="show_table">{L_SHOW_TABLE}:</label><br /><span>{L_SHOW_TABLE_EXPLAIN}</span></dt>
<dd><input name="show_table" type="checkbox" class="radio" id="show_table" <!-- IF S_SHOW_TABLE --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
<input type="hidden" name="ko_league" value="1" />
</fieldset>
+197 -130
View File
@@ -14,11 +14,23 @@ if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
$start = $this->request->variable('start', 0);
$matches_on_matchday = false;
$sql = 'SELECT COUNT(DISTINCT user_id) AS num_users
FROM ' . FOOTB_BETS . "
WHERE season = $season AND league = $league";
$league_info = league_info($season, $league);
if($league_info['bet_type'])
{
$sql = 'SELECT COUNT(DISTINCT b.user_id) AS num_users
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 b.season = $season AND b.league = $league AND m.matchday = $matchday";
}
else
{
$sql = 'SELECT COUNT(DISTINCT b.user_id) AS num_users
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)
LEFT JOIN ' . FOOTB_MATCHES . ' AS m2 ON (m2.season = m.season AND m2.league = m.league + 50 AND m2.matchday = m.matchday AND m2.team_id_home = b.user_id + 2000)
LEFT JOIN ' . FOOTB_MATCHES . " AS m3 ON (m3.season = m.season AND m3.league = m.league + 50 AND m3.matchday = m.matchday AND m3.team_id_guest = b.user_id + 2000)
WHERE b.season = $season AND b.league = $league AND m.matchday = $matchday AND (m2.match_no IS NOT NULL || m3.match_no IS NOT NULL) ";
}
$result = $db->sql_query($sql);
$total_users = (int) $db->sql_fetchfield('num_users');
$db->sql_freeresult($result);
@@ -36,7 +48,19 @@ $sql = "SELECT
m.goals_guest,
SUM(IF(b.goals_home + 0 > b.goals_guest AND b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS home,
SUM(IF(b.goals_home = b.goals_guest AND b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS draw,
SUM(IF(b.goals_home + 0 < b.goals_guest AND b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS guest
SUM(IF(b.goals_home + 0 < b.goals_guest AND b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS guest,
CONCAT(
CASE DATE_FORMAT(m.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(m.match_datetime,' %d.%m. %H:%i')
) AS match_time
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)
@@ -67,7 +91,7 @@ if ($user->data['football_mobile'])
}
else
{
if ($count_matches > 11)
if ($count_matches > 12)
{
$split_after = 8;
$splits = ceil($count_matches / 8);
@@ -78,7 +102,6 @@ else
$splits = 1;
}
}
$db->sql_freeresult($result);
// Make sure $start is set to the last page if it exceeds the amount
if ($start < 0 || $start >= $total_users)
@@ -114,21 +137,47 @@ if ($count_matches > 0)
{
$matches_on_matchday = true;
$sql = "SELECT
u.user_id,
u.username,
m.status,
b.goals_home AS bet_home,
b.goals_guest AS bet_guest,
" . select_points() . '
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)
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
ORDER BY LOWER(u.username) ASC, m.match_datetime ASC, m.match_no ASC";
if($league_info['bet_type'])
{
$sql = "SELECT
u.user_id,
u.username,
m.status,
b.goals_home AS bet_home,
b.goals_guest AS bet_guest,
IFNULL(m2.match_no,m3.match_no),
" . select_points() . '
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)
LEFT JOIN ' . USERS_TABLE . ' AS u ON (u.user_id = b.user_id)
LEFT JOIN ' . FOOTB_MATCHES . ' AS m2 ON (m2.season = m.season AND m2.league = m.league + 50 AND m2.matchday = m.matchday AND m2.team_id_home = b.user_id + 2000)
LEFT JOIN ' . FOOTB_MATCHES . " AS m3 ON (m3.season = m.season AND m3.league = m.league + 50 AND m3.matchday = m.matchday AND m3.team_id_guest = b.user_id + 2000)
WHERE m.season = $season
AND m.league = $league
AND m.matchday = $matchday
ORDER BY IFNULL(m2.match_no,m3.match_no) ASC, m3.match_no ASC, LOWER(u.username) ASC, m.match_datetime ASC, m.match_no ASC";
}
else
{
$sql = "SELECT
u.user_id,
u.username,
m.status,
b.goals_home AS bet_home,
b.goals_guest AS bet_guest,
IFNULL(m2.match_no,m3.match_no),
" . select_points() . '
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)
LEFT JOIN ' . USERS_TABLE . ' AS u ON (u.user_id = b.user_id)
LEFT JOIN ' . FOOTB_MATCHES . ' AS m2 ON (m2.season = m.season AND m2.league = m.league + 50 AND m2.matchday = m.matchday AND m2.team_id_home = b.user_id + 2000)
LEFT JOIN ' . FOOTB_MATCHES . " AS m3 ON (m3.season = m.season AND m3.league = m.league + 50 AND m3.matchday = m.matchday AND m3.team_id_guest = b.user_id + 2000)
WHERE m.season = $season
AND m.league = $league
AND m.matchday = $matchday
AND (m3.match_no IS NOT NULL OR m2.match_no IS NOT NULL)
ORDER BY IFNULL(m2.match_no,m3.match_no) ASC, m3.match_no ASC, LOWER(u.username) ASC, m.match_datetime ASC, m.match_no ASC";
}
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
$user_bets = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
@@ -165,56 +214,67 @@ foreach ($matches AS $match)
$count_user = 0;
$bet_index = 0;
$last_match_index = 0;
foreach ($bet_line[$split_index] AS $user_bet)
{
if ($bet_index == 0)
{
$count_user++;
$row_class = (!($count_user % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($user_bet['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('match_panel.user_row', array(
'ROW_CLASS' => $row_class,
'USER_NAME' => $user_bet['username'],
)
);
$total = 0;
}
$bet_index++;
$total += $user_bet['points'];
if ($user_bet['status'] < 3)
{
$colorstyle_total = ' color_provisionally';
}
if ($user_bet['status'] < 1 && !$config['football_view_bets'])
{
// hide bets
$bet_home = ($user_bet['bet_home'] == '') ? '&nbsp;' : '?';
$bet_guest = ($user_bet['bet_guest'] == '') ? '&nbsp;' : '?';
}
else
{
$bet_home = $user_bet['bet_home'];
$bet_guest = $user_bet['bet_guest'];
}
$colorstyle_bet = color_style($user_bet['status']);
$template->assign_block_vars('match_panel.user_row.bet', array(
'BET' => $bet_home. ':'. $bet_guest,
'COLOR_STYLE' => $colorstyle_bet,
'POINTS' => ($user_bet['points'] == '') ? '&nbsp;' : $user_bet['points'],
)
);
if(!empty($bet_line))
{
foreach ($bet_line[$split_index] AS $user_bet)
{
if ($bet_index == 0)
{
$count_user++;
$league_info = league_info($season, $league);
if ($league_info['bet_type'])
{
$row_class = (!($count_user % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
}
else
{
$row_class = (!(($count_user + ($count_user % 2)) % 4)) ? 'bg1 row_light' : 'bg2 row_dark';
}
if ($user_bet['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('match_panel.user_row', array(
'ROW_CLASS' => $row_class,
'USER_NAME' => $user_bet['username'],
)
);
$total = 0;
}
$bet_index++;
$total += ($user_bet['points'] == '') ? 0 : $user_bet['points'];
if ($user_bet['status'] < 3)
{
$colorstyle_total = ' color_provisionally';
}
if ($user_bet['status'] < 1 && !$config['football_view_bets'])
{
// hide bets
$bet_home = ($user_bet['bet_home'] == '') ? '&nbsp;' : '?';
$bet_guest = ($user_bet['bet_guest'] == '') ? '&nbsp;' : '?';
}
else
{
$bet_home = $user_bet['bet_home'];
$bet_guest = $user_bet['bet_guest'];
}
if ($bet_index == $split_after)
{
$sum_total[$user_bet['username']] += $total;
$matchday_sum_total += $total;
$bet_index = 0;
}
}
$colorstyle_bet = color_style($user_bet['status']);
$template->assign_block_vars('match_panel.user_row.bet', array(
'BET' => $bet_home. ':'. $bet_guest,
'COLOR_STYLE' => $colorstyle_bet,
'POINTS' => ($user_bet['points'] == '') ? '&nbsp;' : $user_bet['points'],
)
);
if ($bet_index == $split_after)
{
$sum_total[$user_bet['username']] += $total;
$matchday_sum_total += $total;
$bet_index = 0;
}
}
}
$template->assign_block_vars('match_panel.tendency_footer', array(
'S_TOTAL' => false,
@@ -265,10 +325,11 @@ foreach ($matches AS $match)
}
$colorstyle_match = color_style($match['status']);
$template->assign_block_vars('match_panel.match_entry', array(
'HOME_NAME' => $homename,
'GUEST_NAME' => $guestname,
'RESULT' => $match['goals_home']. ':'.$match['goals_guest'],
'COLOR_STYLE' => $colorstyle_match,
'HOME_NAME' => $homename,
'GUEST_NAME' => $guestname,
'RESULT' => $match['goals_home']. ':'.$match['goals_guest'],
'COLOR_STYLE' => $colorstyle_match,
'MATCH_TIME' => $match['match_time'],
)
);
if ($match['status'] < 1 && !$config['football_view_tendencies'])
@@ -288,59 +349,70 @@ if ($count_matches > 0)
$total = 0;
$count_user = 0;
$bet_index = 0;
foreach ($bet_line[$split_index] AS $user_bet)
if(!empty($bet_line))
{
if ($bet_index == 0)
foreach ($bet_line[$split_index] AS $user_bet)
{
$count_user++;
$row_class = (!($count_user % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($user_bet['user_id'] == $user->data['user_id'])
if ($bet_index == 0)
{
$row_class = 'bg3 row_user';
$count_user++;
$league_info = league_info($season, $league);
if ($league_info['bet_type'])
{
$row_class = (!($count_user % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
}
else
{
$row_class = (!(($count_user + ($count_user % 2)) % 4)) ? 'bg1 row_light' : 'bg2 row_dark';
}
if ($user_bet['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('match_panel.user_row', array(
'ROW_CLASS' => $row_class,
'USER_NAME' => $user_bet['username'],
)
);
$total = 0;
}
$bet_index++;
$total += ($user_bet['points'] == '') ? 0 : $user_bet['points'];
if ($user_bet['status'] < 3)
{
$colorstyle_total = ' color_provisionally';
}
$template->assign_block_vars('match_panel.user_row', array(
'ROW_CLASS' => $row_class,
'USER_NAME' => $user_bet['username'],
if ($user_bet['status'] < 1 && !$config['football_view_bets'])
{
// hide bets
$bet_home = ($user_bet['bet_home'] == '') ? '' : '?';
$bet_guest = ($user_bet['bet_guest'] == '') ? '' : '?';
}
else
{
$bet_home = $user_bet['bet_home'];
$bet_guest = $user_bet['bet_guest'];
}
$colorstyle_bet = color_style($user_bet['status']);
$template->assign_block_vars('match_panel.user_row.bet', array(
'BET' => $bet_home. ':'. $bet_guest,
'COLOR_STYLE' => $colorstyle_bet,
'POINTS' => ($user_bet['points'] == '') ? '&nbsp;' : $user_bet['points'],
)
);
$total = 0;
}
$bet_index++;
$total += $user_bet['points'];
if ($user_bet['status'] < 3)
{
$colorstyle_total = ' color_provisionally';
}
if ($user_bet['status'] < 1 && !$config['football_view_bets'])
{
// hide bets
$bet_home = ($user_bet['bet_home'] == '') ? '' : '?';
$bet_guest = ($user_bet['bet_guest'] == '') ? '' : '?';
}
else
{
$bet_home = $user_bet['bet_home'];
$bet_guest = $user_bet['bet_guest'];
}
$colorstyle_bet = color_style($user_bet['status']);
$template->assign_block_vars('match_panel.user_row.bet', array(
'BET' => $bet_home. ':'. $bet_guest,
'COLOR_STYLE' => $colorstyle_bet,
'POINTS' => ($user_bet['points'] == '') ? '&nbsp;' : $user_bet['points'],
)
);
if ($bet_index == $last_match_index)
{
$sum_total[$user_bet['username']] += $total;
$matchday_sum_total += $total;
$template->assign_block_vars('match_panel.user_row.points', array(
'COLOR_STYLE' => $colorstyle_total,
'POINTS_TOTAL' => $sum_total[$user_bet['username']],
)
);
$bet_index = 0;
if ($bet_index == $last_match_index)
{
$sum_total[$user_bet['username']] += $total;
$matchday_sum_total += $total;
$template->assign_block_vars('match_panel.user_row.points', array(
'COLOR_STYLE' => $colorstyle_total,
'POINTS_TOTAL' => $sum_total[$user_bet['username']],
)
);
$bet_index = 0;
}
}
}
@@ -451,7 +523,7 @@ while ($row = $db->sql_fetchrow($result))
while ($user_row = $db->sql_fetchrow($result_bet))
{
$bet_number++ ;
$row_class = (!($bet_number % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$row_class = (!(($count_user + ($count_user % 2)) % 4)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($user_row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
@@ -479,19 +551,14 @@ while ($row = $db->sql_fetchrow($result))
)
);
}
$db->sql_freeresult($result_bet);
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['ALL_BETS']);
$template->assign_vars(array(
'S_DISPLAY_ALL_BETS' => true,
'S_SIDENAME' => $sidename,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['BET']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'results', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['RESULTS']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_BET']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_RESULTS']),
'S_MATCHES_ON_MATCHDAY' => $matches_on_matchday,
'S_SPALTEN' => ($count_matches * 2) + 2,
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
+228 -234
View File
@@ -1,235 +1,229 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
// Check Prediction League authorisation
if ( !$this->auth->acl_get('u_use_football') )
{
trigger_error('NO_AUTH_VIEW');
}
global $phpbb_extension_manager;
if ($phpbb_extension_manager->is_enabled('dmzx/ultimatepoints'))
{
$this->user->add_lang_ext('dmzx/ultimatepoints', 'common');
// Get an instance of the ultimatepoints functions_points
$functions_points = $phpbb_container->get('dmzx.ultimatepoints.core.functions.points');
}
else
{
// Get an instance of the football functions_points
$functions_points = $phpbb_container->get('football.football.core.functions.points');
}
if (!$user_sel)
{
if (user_is_member($user->data['user_id'], $season, $league) or $league == 0)
{
$user_sel = $user->data['user_id'];
}
}
$username = '';
$member = true;
if ($this->auth->acl_get('a_football_points'))
{
$where_user = '';
$multi_view = true;
}
else
{
$multi_view = false;
if (user_is_member($user->data['user_id'], $season, $league))
{
$where_user = ' AND b.user_id = ' . $user->data['user_id'] . ' ';
$user_sel = $user->data['user_id'];
}
else
{
if ($league)
{
$member = false;
}
}
}
$where_league = '';
if ($league)
{
$where_league = " AND b.league = $league";
}
$data = false;
// Select user
$total_users = 0;
$sql = 'SELECT DISTINCT
u.user_id,
u.username
FROM ' . FOOTB_BETS . ' AS b
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
WHERE season = $season
$where_league
$where_user
ORDER BY LOWER(u.username) ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$total_users++;
if ($user_sel == $row['user_id'] OR !$user_sel)
{
$selectid = ' selected="selected"';
$username = $row['username'];
$user_sel = $row['user_id'];
}
else
{
$selectid = '';
}
$template->assign_block_vars('form_user', array(
'S_USER' => $row['user_id'],
'S_USERNAME' => $row['username'],
'S_SELECTEDID' => $selectid,
)
);
}
$db->sql_freeresult($result);
$where_season = '';
if ($season)
{
$where_season = " AND fp.season = $season";
}
$where_league = '';
$order_by = 'ORDER BY fp.points_type ASC, fp.matchday ASC, fp.league ASC';
if ($league)
{
$where_league = " AND fp.league = $league";
$order_by = 'ORDER BY fp.league ASC, fp.matchday ASC, fp.points_type ASC';
}
// The different book types
$types = array(
0 => '--',
1 => sprintf($user->lang['FOOTBALL_BET_POINTS']),
2 => $user->lang['FOOTBALL_DEPOSIT'],
3 => sprintf($user->lang['FOOTBALL_WIN']),
4 => $user->lang['FOOTBALL_WIN'],
5 => $user->lang['FOOTBALL_WIN'],
6 => $user->lang['FOOTBALL_WIN'],
7 => $user->lang['FOOTBALL_PAYOUT'],
);
// Grab the football points
$sql = 'SELECT fp.season,
s.season_name,
s.season_name_short,
fp.league,
l.league_name,
l.league_name_short,
fp.matchday,
md.matchday_name,
fp.points_type,
fp.points,
fp.points_comment,
fp.cash
FROM ' . FOOTB_POINTS . ' AS fp
INNER JOIN ' . FOOTB_SEASONS . ' AS s ON (s.season = fp.season)
INNER JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = fp.season AND l.league = fp.league)
INNER JOIN ' . FOOTB_MATCHDAYS . ' AS md ON (md.season = fp.season AND md.league = fp.league AND md.matchday = fp.matchday)
WHERE user_id = ' . (int) $user_sel . "
$where_season
$where_league
$order_by";
$result = $db->sql_query($sql);
$current_balance = 0.00;
$count = 0;
// Start looping all the football points
while ($row = $db->sql_fetchrow($result))
{
$count = $count + 1;
if ($row['points_type'] == POINTS_BET OR $row['points_type'] == POINTS_PAID)
{
$points_sign = '-';
$points_style = " color: red;";
$current_balance -= $row['points'];
}
else
{
$points_sign = '+';
$points_style = " color: green;";
$current_balance += $row['points'];
}
// Add the items to the template
$template->assign_block_vars('football', array(
'SEASON' => $season,
'SEASON_NAME' => $season_name,
'LEAGUE' => $row['league'],
'LEAGUE_NAME' => $row['league_name'],
'LEAGUE_SHORT' => $row['league_name_short'],
'MATCHDAY' => $row['matchday'],
'MATCHDAY_NAME' => ($row['matchday_name'] == '') ? $row['matchday'] . '.' . sprintf($user->lang['FOOTBALL_MATCHDAY']) : $row['matchday_name'],
'MATCHDAY_SHORT'=> $row['matchday'] . '.' . sprintf($user->lang['MATCHDAY_SHORT']),
'POINTS_SIGN' => $points_sign,
'POINTS_STYLE' => $points_style,
'POINTS_TYPE' => $types[$row['points_type']],
'S_CASH' => $row['cash'],
'POINTS' => $functions_points->number_format_points($row['points']),
'COMMENT' => nl2br($row['points_comment']),
));
}
$db->sql_freeresult($result);
if ($current_balance < 0)
{
$points_style = " color: red;";
}
else
{
$points_style = " color: green;";
}
$template->assign_block_vars('football', array(
'SEASON' => $season,
'SEASON_NAME' => '',
'LEAGUE' => $league,
'LEAGUE_NAME' => '',
'MATCHDAY' => '',
'MATCHDAY_NAME' => '',
'POINTS_SIGN' => '',
'POINTS_STYLE' => $points_style,
'POINTS_TYPE' => '',
'S_CASH' => 1,
'POINTS' => $functions_points->number_format_points($current_balance),
'COMMENT' => ($league == 0) ? sprintf($user->lang['FOOTBALL_BALANCES']) : sprintf($user->lang['FOOTBALL_BALANCE']),
));
$sidename = sprintf($user->lang['FOOTBALL_BANK']);
$template->assign_vars(array(
'S_DISPLAY_BANK' => true,
'S_MATCHDAY_HIDE' => true,
'S_MEMBER' => $member,
'S_SIDENAME' => $sidename,
'S_MULTI_VIEW' => $multi_view,
'L_TOTAL_ENTRIES' => ($count == 1) ? $count . ' ' .sprintf($user->lang['FOOTBALL_RECORD']) : $count . ' ' .sprintf($user->lang['FOOTBALL_RECORDS']),
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['RANK_TOTAL']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'my_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['MY_BETS']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_RANK_TOTAL']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_MY_BETS']),
'USERNAME' => $username,
'POINTS' => $config['football_win_name'],
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
// Check Prediction League authorisation
if ( !$this->auth->acl_get('u_use_football') )
{
trigger_error('NO_AUTH_VIEW');
}
global $phpbb_extension_manager;
if ($phpbb_extension_manager->is_enabled('dmzx/ultimatepoints'))
{
$this->user->add_lang_ext('dmzx/ultimatepoints', 'common');
// Get an instance of the ultimatepoints functions_points
$functions_points = $phpbb_container->get('dmzx.ultimatepoints.core.functions.points');
}
else
{
// Get an instance of the football functions_points
$functions_points = $phpbb_container->get('football.football.core.functions.points');
}
if (!$user_sel)
{
if (user_is_member($user->data['user_id'], $season, $league) or $league == 0)
{
$user_sel = $user->data['user_id'];
}
}
$username = '';
$member = true;
if ($this->auth->acl_get('a_football_points'))
{
$where_user = '';
$multi_view = true;
}
else
{
$multi_view = false;
if (user_is_member($user->data['user_id'], $season, $league))
{
$where_user = ' AND b.user_id = ' . $user->data['user_id'] . ' ';
$user_sel = $user->data['user_id'];
}
else
{
if ($league)
{
$member = false;
}
}
}
$where_league = '';
if ($league)
{
$where_league = " AND b.league = $league";
}
$data = false;
// Select user
$total_users = 0;
$sql = 'SELECT DISTINCT
u.user_id,
u.username
FROM ' . FOOTB_BETS . ' AS b
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
WHERE season = $season
$where_league
$where_user
ORDER BY LOWER(u.username) ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$total_users++;
if ($user_sel == $row['user_id'] OR !$user_sel)
{
$selectid = ' selected="selected"';
$username = $row['username'];
$user_sel = $row['user_id'];
}
else
{
$selectid = '';
}
$template->assign_block_vars('form_user', array(
'S_USER' => $row['user_id'],
'S_USERNAME' => $row['username'],
'S_SELECTEDID' => $selectid,
)
);
}
$db->sql_freeresult($result);
$where_season = '';
if ($season)
{
$where_season = " AND fp.season = $season";
}
$where_league = '';
$order_by = 'ORDER BY fp.points_type ASC, fp.matchday ASC, fp.league ASC';
if ($league)
{
$where_league = " AND fp.league = $league";
$order_by = 'ORDER BY fp.league ASC, fp.matchday ASC, fp.points_type ASC';
}
// The different book types
$types = array(
0 => '--',
1 => sprintf($user->lang['FOOTBALL_BET_POINTS']),
2 => $user->lang['FOOTBALL_DEPOSIT'],
3 => sprintf($user->lang['FOOTBALL_WIN']),
4 => $user->lang['FOOTBALL_WIN'],
5 => $user->lang['FOOTBALL_WIN'],
6 => $user->lang['FOOTBALL_WIN'],
7 => $user->lang['FOOTBALL_PAYOUT'],
);
// Grab the football points
$sql = 'SELECT fp.season,
s.season_name,
s.season_name_short,
fp.league,
l.league_name,
l.league_name_short,
fp.matchday,
md.matchday_name,
fp.points_type,
fp.points,
fp.points_comment,
fp.cash
FROM ' . FOOTB_POINTS . ' AS fp
INNER JOIN ' . FOOTB_SEASONS . ' AS s ON (s.season = fp.season)
INNER JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = fp.season AND l.league = fp.league)
INNER JOIN ' . FOOTB_MATCHDAYS . ' AS md ON (md.season = fp.season AND md.league = fp.league AND md.matchday = fp.matchday)
WHERE user_id = ' . (int) $user_sel . "
$where_season
$where_league
$order_by";
$result = $db->sql_query($sql);
$current_balance = 0.00;
$count = 0;
// Start looping all the football points
while ($row = $db->sql_fetchrow($result))
{
$count = $count + 1;
if ($row['points_type'] == POINTS_BET OR $row['points_type'] == POINTS_PAID)
{
$points_sign = '-';
$points_style = " color: red;";
$current_balance -= $row['points'];
}
else
{
$points_sign = '+';
$points_style = " color: green;";
$current_balance += $row['points'];
}
// Add the items to the template
$template->assign_block_vars('football', array(
'SEASON' => $season,
'SEASON_NAME' => $season_name,
'LEAGUE' => $row['league'],
'LEAGUE_NAME' => $row['league_name'],
'LEAGUE_SHORT' => $row['league_name_short'],
'MATCHDAY' => $row['matchday'],
'MATCHDAY_NAME' => ($row['matchday_name'] == '') ? $row['matchday'] . '.' . sprintf($user->lang['FOOTBALL_MATCHDAY']) : $row['matchday_name'],
'MATCHDAY_SHORT'=> $row['matchday'] . '.' . sprintf($user->lang['MATCHDAY_SHORT']),
'POINTS_SIGN' => $points_sign,
'POINTS_STYLE' => $points_style,
'POINTS_TYPE' => $types[$row['points_type']],
'S_CASH' => $row['cash'],
'POINTS' => $functions_points->number_format_points($row['points']),
'COMMENT' => nl2br($row['points_comment']),
));
}
$db->sql_freeresult($result);
if ($current_balance < 0)
{
$points_style = " color: red;";
}
else
{
$points_style = " color: green;";
}
$template->assign_block_vars('football', array(
'SEASON' => $season,
'SEASON_NAME' => '',
'LEAGUE' => $league,
'LEAGUE_NAME' => '',
'MATCHDAY' => '',
'MATCHDAY_NAME' => '',
'POINTS_SIGN' => '',
'POINTS_STYLE' => $points_style,
'POINTS_TYPE' => '',
'S_CASH' => 1,
'POINTS' => $functions_points->number_format_points($current_balance),
'COMMENT' => ($league == 0) ? sprintf($user->lang['FOOTBALL_BALANCES']) : sprintf($user->lang['FOOTBALL_BALANCE']),
));
$sidename = sprintf($user->lang['FOOTBALL_BANK']);
$template->assign_vars(array(
'S_DISPLAY_BANK' => true,
'S_MATCHDAY_HIDE' => true,
'S_MEMBER' => $member,
'S_SIDENAME' => $sidename,
'S_MULTI_VIEW' => $multi_view,
'L_TOTAL_ENTRIES' => ($count == 1) ? $count . ' ' .sprintf($user->lang['FOOTBALL_RECORD']) : $count . ' ' .sprintf($user->lang['FOOTBALL_RECORDS']),
'USERNAME' => $username,
'POINTS' => $config['football_win_name'],
)
);
?>
+530 -533
View File
File diff suppressed because it is too large Load Diff
+391 -390
View File
@@ -1,391 +1,392 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
// Can this user view Prediction Leagues pages?
if (!$config['football_guest_view'])
{
if ($user->data['user_id'] == ANONYMOUS)
{
trigger_error('NO_GUEST_VIEW');
}
}
if (!$config['football_user_view'])
{
// Only Prediction League member should see this page
// Check Prediction League authorisation
if ( !$this->auth->acl_get('u_use_football') )
{
trigger_error('NO_AUTH_VIEW');
}
}
// Football disabled?
if ($config['football_disable'])
{
$message = (!empty($config['football_disable_msg'])) ? $config['football_disable_msg'] : 'FOOTBALL_DISABLED';
trigger_error($message);
}
$userid = $this->request->variable('u', 0);
$season = $this->request->variable('s', 0);
$league = $this->request->variable('l', 0);
$matchday = $this->request->variable('m', 0);
$error_message = '';
$username = '?';
if (!$userid OR !$season OR !$league OR !$matchday)
{
$data_bet = false;
if (!$userid)
{
$error_message .= sprintf($user->lang['NO_USERID']) . '<br />';
}
if (!$season)
{
$error_message .= sprintf($user->lang['NO_SEASON']) . '<br />';
}
if (!$league)
{
$error_message .= sprintf($user->lang['NO_LEAGUE']) . '<br />';
}
if (!$matchday)
{
$error_message .= sprintf($user->lang['NO_MATCHDAY']) . '<br />';
}
}
else
{
$season_info = season_info($season);
if (sizeof($season_info))
{
$league_info = league_info($season, $league);
if (sizeof($league_info))
{
// Get username
$sql = 'SELECT username
FROM ' . USERS_TABLE . "
WHERE user_id = $userid ";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$username = $row['username'];
}
else
{
$data_bet = false;
$error_message .= sprintf($user->lang['NO_USERID']) . '<br />';
}
$db->sql_freeresult($result);
$display_group = false;
$lang_dates = $user->lang['datetime'];
// Required for select_points function:
$league_info = league_info($season, $league);
// Calculate matches and bets of matchday
$sql = "SELECT
m.league,
m.match_no,
m.matchday,
m.status,
m.group_id,
m.formula_home,
m.formula_guest,
t1.team_symbol AS home_symbol,
t2.team_symbol AS guest_symbol,
t1.team_id AS home_id,
t2.team_id AS guest_id,
t1.team_name AS home_name,
t2.team_name AS guest_name,
b.goals_home AS bet_home,
b.goals_guest AS bet_guest,
m.goals_home,
m.goals_guest,
CONCAT(
CASE DATE_FORMAT(m.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(m.match_datetime,' %d.%m. %H:%i')
) AS match_time,
" . select_points() . "
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 AND b.user_id = $userid)
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.matchday = $matchday
GROUP BY m.match_no
ORDER BY m.match_datetime ASC, m.match_no ASC";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$data_bet = true;
$matchnumber = 0;
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
do
{
$matchnumber++ ;
$row_class = (!($matchnumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$display_link = true;
if (0 == $row['home_id'])
{
$home_info = get_team($season, $league, $row['match_no'], 'team_id_home', $row['formula_home']);
$home_in_array = explode("#",$home_info);
$homelogo = $home_in_array[0];
$homeid = $home_in_array[1];
$homename = $home_in_array[2];
}
else
{
$homelogo = $row['home_symbol'];
$homeid = $row['home_id'];
$homename = $row['home_name'];
}
if (0 == $row['guest_id'])
{
$guest_info = get_team($season, $league, $row['match_no'], 'team_id_guest', $row['formula_guest']);
$guest_in_array = explode("#",$guest_info);
$guestlogo = $guest_in_array[0];
$guestid = $guest_in_array[1];
$guestname = $guest_in_array[2];
}
else
{
$guestlogo = $row['guest_symbol'];
$guestid = $row['guest_id'];
$guestname = $row['guest_name'];
}
if ($homelogo <> '')
{
$logoH = "<img src=\"" . $ext_path . 'images/flags/' . $homelogo . "\" alt=\"" . $homelogo . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logoH = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
if ($guestlogo <> '')
{
$logoG = "<img src=\"" . $ext_path . 'images/flags/' . $guestlogo . "\" alt=\"" . $guestlogo . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logoG = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
if ($row['group_id'] == '')
{
$group_id = '&nbsp;';
}
else
{
$display_group = true;
$group_id = $row['group_id'];
}
if ($row['status'] < 1 && !$config['football_view_bets'])
{
// hide bets
$bet_home = ($row['bet_home'] == '') ? '&nbsp;' : '?';
$bet_guest = ($row['bet_guest'] == '') ? '&nbsp;' : '?';
}
else
{
$bet_home = ($row['bet_home'] == '') ? '&nbsp;' : $row['bet_home'];
$bet_guest = ($row['bet_guest'] == '') ? '&nbsp;' : $row['bet_guest'];
}
$colorstyle = color_style($row['status']);
$template->assign_block_vars('bet_view', array(
'ROW_CLASS' => $row_class,
'LEAGUE_ID' => $row['league'],
'MATCH_NUMBER' => $row['match_no'],
'MATCHDAY' => $row['matchday'],
'STATUS' => $row['status'],
'MATCH_TIME' => $row['match_time'],
'GROUP' => $group_id,
'HOME_ID' => $homeid,
'GUEST_ID' => $guestid,
'LOGO_HOME' => $logoH,
'LOGO_GUEST' => $logoG,
'HOME_NAME' => $homename,
'GUEST_NAME' => $guestname,
'BET_HOME' => $bet_home,
'BET_GUEST' => $bet_guest,
'GOALS_HOME' => ($row['goals_home'] == '') ? '&nbsp;' : $row['goals_home'],
'GOALS_GUEST' => ($row['goals_guest'] == '') ? '&nbsp;' : $row['goals_guest'],
'POINTS' => ($row['points'] == '') ? '&nbsp;' : $row['points'],
'COLOR_STYLE' => $colorstyle,
)
);
}
while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
}
else
{
$data_bet = false;
$error_message .= sprintf($user->lang['NO_BETS']) . '<br />';
}
}
else
{
$data_bet = false;
$error_message .= sprintf($user->lang['NO_LEAGUE']) . '<br />';
}
}
else
{
$data_bet = false;
$error_message .= sprintf($user->lang['NO_SEASON']) . '<br />';
}
}
// Calculate extra bets of matchday
$sql = "SELECT e.*,
eb.bet,
eb.bet_points,
t1.team_name AS result_team,
t2.team_name AS bet_team
FROM " . FOOTB_EXTRA . ' AS e
LEFT JOIN ' . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = e.season AND eb.league = e.league AND eb.extra_no = e.extra_no AND eb.user_id = $userid)
LEFT JOIN " . FOOTB_TEAMS . ' AS t1 ON (t1.season = e.season AND t1.league = e.league AND t1.team_id = e.result)
LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = e.season AND t2.league = e.league AND t2.team_id = eb.bet)
WHERE e.season = $season
AND e.league = $league
AND e.matchday = $matchday
ORDER BY e.extra_no ASC";
$result = $db->sql_query($sql);
$extra_bet = false;
$extranumber = 0;
while ($row = $db->sql_fetchrow($result))
{
$extra_bet = true;
$extranumber++ ;
$row_class = (!($extranumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['extra_status'] < 1 && !$config['football_view_bets'])
{
// hide bets
$bet = ($row['bet'] == '') ? '&nbsp;' : '?';
$bet_team = ($row['bet_team'] == NULL) ? '&nbsp;' : '?';
}
else
{
$bet = ($row['bet'] == '') ? '&nbsp;' : $row['bet'];
$bet_team = ($row['bet_team'] == NULL) ? '&nbsp;' : $row['bet_team'];
}
$extra_colorstyle = color_style($row['extra_status']);
switch($row['question_type'])
{
case '1':
{
$display_type = 1;
$eval_title = sprintf($user->lang['EXTRA_HIT']);
}
break;
case '2':
{
$display_type = 1;
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
}
break;
case '3':
{
$display_type = 2;
$eval_title = sprintf($user->lang['EXTRA_HIT']);
}
break;
case '4':
{
$display_type = 2;
$eval_title = sprintf($user->lang['EXTRA_DIFFERENCE']);
}
break;
case '5':
{
$display_type = 2;
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
}
break;
default :
{
$display_type = 2;
$eval_title = '';
}
break;
}
$template->assign_block_vars('extra_view', array(
'ROW_CLASS' => $row_class,
'QUESTION' => $row['question'],
'EXTRA_POINTS' => $row['extra_points'],
'EVALUATION' => ($row['matchday'] == $row['matchday_eval']) ? sprintf($user->lang['MATCHDAY']) : sprintf($user->lang['TOTAL']),
'EVALUATION_TITLE' => $eval_title,
'RESULT' => ($display_type == 1) ? $row['result_team'] : $row['result'],
'BET' => ($display_type == 1) ? $bet_team : $bet,
'BET_POINTS' => $row['bet_points'],
'COLOR_STYLE' => $extra_colorstyle,
)
);
}
$sidename = sprintf($user->lang['BET']);
if ($data_bet)
{
$template->assign_vars(array(
'S_SIDENAME' => $sidename,
'S_USER_NAME' => $username,
'S_ERROR_MESSAGE' => $error_message,
'S_FROM' => sprintf($user->lang['FROM_DAY_SEASON'], $matchday, $season),
'S_FOOTBALL_COPY' => sprintf($user->lang['FOOTBALL_COPY'], $config['football_version'], $phpbb_root_path . 'football/'),
'S_DATA_BET' => $data_bet,
'S_DISPLAY_GROUP' => $display_group,
'S_EXTRA_BET' => $extra_bet,
)
);
// output page
page_header(sprintf($user->lang['BETS_OF']) . ' ' . $username);
}
else
{
$template->assign_vars(array(
'S_SIDENAME' => $sidename,
'S_USER_NAME' => '',
'S_ERROR_MESSAGE' => $error_message,
'S_FROM' => '',
'S_FOOTBALL_COPY' => sprintf($user->lang['FOOTBALL_COPY'], $config['football_version'], $phpbb_root_path . 'football/'),
'S_DATA_BET' => $data_bet,
'S_DISPLAY_GROUP' => false,
)
);
// output page
page_header(sprintf($user->lang['BETS_OF']));
}
$template->set_filenames(array(
'body' => 'bet_popup.html')
);
page_footer();
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
// Can this user view Prediction Leagues pages?
if (!$config['football_guest_view'])
{
if ($user->data['user_id'] == ANONYMOUS)
{
trigger_error('NO_GUEST_VIEW');
}
}
if (!$config['football_user_view'])
{
// Only Prediction League member should see this page
// Check Prediction League authorisation
if ( !$this->auth->acl_get('u_use_football') )
{
trigger_error('NO_AUTH_VIEW');
}
}
// Football disabled?
if ($config['football_disable'])
{
$message = (!empty($config['football_disable_msg'])) ? $config['football_disable_msg'] : 'FOOTBALL_DISABLED';
trigger_error($message);
}
$userid = $this->request->variable('u', 0);
$season = $this->request->variable('s', 0);
$league = $this->request->variable('l', 0);
$matchday = $this->request->variable('m', 0);
$error_message = '';
$username = '?';
if (!$userid OR !$season OR !$league OR !$matchday)
{
$data_bet = false;
if (!$userid)
{
$error_message .= sprintf($user->lang['NO_USERID']) . '<br />';
}
if (!$season)
{
$error_message .= sprintf($user->lang['NO_SEASON']) . '<br />';
}
if (!$league)
{
$error_message .= sprintf($user->lang['NO_LEAGUE']) . '<br />';
}
if (!$matchday)
{
$error_message .= sprintf($user->lang['NO_MATCHDAY']) . '<br />';
}
}
else
{
$season_info = season_info($season);
if (sizeof($season_info))
{
$league_info = league_info($season, $league);
if (sizeof($league_info))
{
// Get username
$sql = 'SELECT username
FROM ' . USERS_TABLE . "
WHERE user_id = $userid ";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$username = $row['username'];
}
else
{
$data_bet = false;
$error_message .= sprintf($user->lang['NO_USERID']) . '<br />';
}
$db->sql_freeresult($result);
$display_group = false;
$lang_dates = $user->lang['datetime'];
// Required for select_points function:
$league_info = league_info($season, $league);
// Calculate matches and bets of matchday
$sql = "SELECT
m.league,
m.match_no,
m.matchday,
m.status,
m.group_id,
m.formula_home,
m.formula_guest,
t1.team_symbol AS home_symbol,
t2.team_symbol AS guest_symbol,
t1.team_id AS home_id,
t2.team_id AS guest_id,
t1.team_name AS home_name,
t2.team_name AS guest_name,
b.goals_home AS bet_home,
b.goals_guest AS bet_guest,
m.goals_home,
m.goals_guest,
CONCAT(
CASE DATE_FORMAT(m.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(m.match_datetime,' %d.%m. %H:%i')
) AS match_time,
" . select_points() . "
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 AND b.user_id = $userid)
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.matchday = $matchday
GROUP BY m.match_no
ORDER BY m.match_datetime ASC, m.match_no ASC";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$data_bet = true;
$matchnumber = 0;
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
do
{
$matchnumber++ ;
$row_class = (!($matchnumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$display_link = true;
if (0 == $row['home_id'])
{
$home_info = get_team($season, $league, $row['match_no'], 'team_id_home', $row['formula_home']);
$home_in_array = explode("#",$home_info);
$homelogo = $home_in_array[0];
$homeid = $home_in_array[1];
$homename = $home_in_array[2];
}
else
{
$homelogo = $row['home_symbol'];
$homeid = $row['home_id'];
$homename = $row['home_name'];
}
if (0 == $row['guest_id'])
{
$guest_info = get_team($season, $league, $row['match_no'], 'team_id_guest', $row['formula_guest']);
$guest_in_array = explode("#",$guest_info);
$guestlogo = $guest_in_array[0];
$guestid = $guest_in_array[1];
$guestname = $guest_in_array[2];
}
else
{
$guestlogo = $row['guest_symbol'];
$guestid = $row['guest_id'];
$guestname = $row['guest_name'];
}
if ($homelogo <> '')
{
$logoH = "<img src=\"" . $ext_path . 'images/flags/' . $homelogo . "\" alt=\"" . $homelogo . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logoH = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
if ($guestlogo <> '')
{
$logoG = "<img src=\"" . $ext_path . 'images/flags/' . $guestlogo . "\" alt=\"" . $guestlogo . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logoG = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
if ($row['group_id'] == '')
{
$group_id = '&nbsp;';
}
else
{
$display_group = true;
$group_id = $row['group_id'];
}
if ($row['status'] < 1 && !$config['football_view_bets'])
{
// hide bets
$bet_home = ($row['bet_home'] == '') ? '&nbsp;' : '?';
$bet_guest = ($row['bet_guest'] == '') ? '&nbsp;' : '?';
}
else
{
$bet_home = ($row['bet_home'] == '') ? '&nbsp;' : $row['bet_home'];
$bet_guest = ($row['bet_guest'] == '') ? '&nbsp;' : $row['bet_guest'];
}
$colorstyle = color_style($row['status']);
$template->assign_block_vars('bet_view', array(
'ROW_CLASS' => $row_class,
'LEAGUE_ID' => $row['league'],
'MATCH_NUMBER' => $row['match_no'],
'MATCHDAY' => $row['matchday'],
'STATUS' => $row['status'],
'MATCH_TIME' => $row['match_time'],
'GROUP' => $group_id,
'HOME_ID' => $homeid,
'GUEST_ID' => $guestid,
'LOGO_HOME' => $logoH,
'LOGO_GUEST' => $logoG,
'HOME_NAME' => $homename,
'GUEST_NAME' => $guestname,
'BET_HOME' => $bet_home,
'BET_GUEST' => $bet_guest,
'GOALS_HOME' => ($row['goals_home'] == '') ? '&nbsp;' : $row['goals_home'],
'GOALS_GUEST' => ($row['goals_guest'] == '') ? '&nbsp;' : $row['goals_guest'],
'POINTS' => ($row['points'] == '') ? '&nbsp;' : $row['points'],
'COLOR_STYLE' => $colorstyle,
)
);
}
while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
}
else
{
$data_bet = false;
$error_message .= sprintf($user->lang['NO_BETS']) . '<br />';
}
}
else
{
$data_bet = false;
$error_message .= sprintf($user->lang['NO_LEAGUE']) . '<br />';
}
}
else
{
$data_bet = false;
$error_message .= sprintf($user->lang['NO_SEASON']) . '<br />';
}
}
// Calculate extra bets of matchday
$sql = "SELECT e.*,
eb.bet,
eb.bet_points,
t1.team_name AS result_team,
t2.team_name AS bet_team
FROM " . FOOTB_EXTRA . ' AS e
LEFT JOIN ' . FOOTB_EXTRA_BETS . " AS eb ON (eb.season = e.season AND eb.league = e.league AND eb.extra_no = e.extra_no AND eb.user_id = $userid)
LEFT JOIN " . FOOTB_TEAMS . ' AS t1 ON (t1.season = e.season AND t1.league = e.league AND t1.team_id = e.result)
LEFT JOIN ' . FOOTB_TEAMS . " AS t2 ON (t2.season = e.season AND t2.league = e.league AND t2.team_id = eb.bet)
WHERE e.season = $season
AND e.league = $league
AND e.matchday = $matchday
ORDER BY e.extra_no ASC";
$result = $db->sql_query($sql);
$extra_bet = false;
$extranumber = 0;
while ($row = $db->sql_fetchrow($result))
{
$extra_bet = true;
$extranumber++ ;
$row_class = (!($extranumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['extra_status'] < 1 && !$config['football_view_bets'])
{
// hide bets
$bet = ($row['bet'] == '') ? '&nbsp;' : '?';
$bet_team = ($row['bet_team'] == NULL) ? '&nbsp;' : '?';
}
else
{
$bet = ($row['bet'] == '') ? '&nbsp;' : $row['bet'];
$bet_team = ($row['bet_team'] == NULL) ? '&nbsp;' : $row['bet_team'];
}
$extra_colorstyle = color_style($row['extra_status']);
switch($row['question_type'])
{
case '1':
{
$display_type = 1;
$eval_title = sprintf($user->lang['EXTRA_HIT']);
}
break;
case '2':
{
$display_type = 1;
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
}
break;
case '3':
{
$display_type = 2;
$eval_title = sprintf($user->lang['EXTRA_HIT']);
}
break;
case '4':
{
$display_type = 2;
$eval_title = sprintf($user->lang['EXTRA_DIFFERENCE']);
}
break;
case '5':
{
$display_type = 2;
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
}
break;
default :
{
$display_type = 2;
$eval_title = '';
}
break;
}
$template->assign_block_vars('extra_view', array(
'ROW_CLASS' => $row_class,
'QUESTION' => $row['question'],
'EXTRA_POINTS' => $row['extra_points'],
'EVALUATION' => ($row['matchday'] == $row['matchday_eval']) ? sprintf($user->lang['MATCHDAY']) : sprintf($user->lang['TOTAL']),
'EVALUATION_TITLE' => $eval_title,
'RESULT' => ($display_type == 1) ? $row['result_team'] : $row['result'],
'BET' => ($display_type == 1) ? $bet_team : $bet,
'BET_POINTS' => $row['bet_points'],
'COLOR_STYLE' => $extra_colorstyle,
)
);
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['BET']);
if ($data_bet)
{
$template->assign_vars(array(
'S_SIDENAME' => $sidename,
'S_USER_NAME' => $username,
'S_ERROR_MESSAGE' => $error_message,
'S_FROM' => sprintf($user->lang['FROM_DAY_SEASON'], $matchday, $season),
'S_FOOTBALL_COPY' => sprintf($user->lang['FOOTBALL_COPY'], $config['football_version'], $phpbb_root_path . 'football/'),
'S_DATA_BET' => $data_bet,
'S_DISPLAY_GROUP' => $display_group,
'S_EXTRA_BET' => $extra_bet,
)
);
// output page
page_header(sprintf($user->lang['BETS_OF']) . ' ' . $username);
}
else
{
$template->assign_vars(array(
'S_SIDENAME' => $sidename,
'S_USER_NAME' => '',
'S_ERROR_MESSAGE' => $error_message,
'S_FROM' => '',
'S_FOOTBALL_COPY' => sprintf($user->lang['FOOTBALL_COPY'], $config['football_version'], $phpbb_root_path . 'football/'),
'S_DATA_BET' => $data_bet,
'S_DISPLAY_GROUP' => false,
)
);
// output page
page_header(sprintf($user->lang['BETS_OF']));
}
$template->set_filenames(array(
'body' => 'bet_popup.html')
);
page_footer();
?>
+74 -192
View File
@@ -1,193 +1,75 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data_delivery = false;
$user_id = $user->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,
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data_delivery = false;
$user_id = $user->data['user_id'];
$lang_dates = $user->lang['datetime'];
$index = 0;
$local_board_time = time() + ($config['football_time_shift'] * 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,
)
);
?>
+134 -133
View File
@@ -1,134 +1,135 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
$this->user->add_lang_ext('football/football', 'info_acp_bank');
// Check Prediction League authorisation
if ( !$this->auth->acl_get('u_use_football') )
{
trigger_error('NO_AUTH_VIEW');
}
$action='';
$phpbb_root_path = './../../';
if (!$season OR !$league)
{
redirect($this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league)));
}
else
{
$season_info = season_info($season);
if (!sizeof($season_info))
{
$error_message = sprintf($user->lang['NO_SEASON']);
trigger_error($error_message);
}
else
{
$league_info = league_info($season, $league);
if (!sizeof($league_info))
{
$error_message = sprintf($user->lang['NO_LEAGUE']);
trigger_error($error_message);
}
else
{
$bet_points = $league_info['bet_points'];
$league_name =$league_info['league_name'];
$league_short =$league_info['league_name_short'];
$user_points = '';
global $phpbb_extension_manager;
if ($phpbb_extension_manager->is_enabled('dmzx/ultimatepoints') && $config['points_enable'])
{
$user_points = 'u.user_points,';
}
else
{
$user_points = "0.00 AS user_points,";
}
// Grab the members points
$sql = "SELECT
b.user_id,
u.username,
$user_points
$bet_points AS bet_points,
SUM(IF(p.points_type = " . POINTS_BET . ', IF(p.cash = 0, p.points, 0.00), 0.00)) AS no_cash_bet_points,
SUM(IF(p.points_type = ' . POINTS_DEPOSITED . ', IF(p.cash = 0, p.points, 0.00), 0.00)) AS no_cash_deposit,
SUM(IF(p.points_type IN (' . POINTS_MATCHDAY . ',' . POINTS_SEASON . ',' . POINTS_MOST_HITS . ',' . POINTS_MOST_HITS_AWAY . '),
IF(p.cash = 0, p.points, 0.00),
0.00)) AS no_cash_wins,
SUM(IF(p.points_type = ' . POINTS_PAID . ', IF(p.cash = 0, p.points, 0.00), 0.00)) AS no_cash_paid,
SUM(IF(p.points_type = ' . POINTS_DEPOSITED . ', p.points, 0.00)) AS deposit,
IF(SUM(IF(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points, p.points * -1.0)) > 0,
SUM(IF(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points, p.points * -1.0)), 0.00) AS new_deposit,
SUM(IF(p.points_type IN (' . POINTS_MATCHDAY . ',' . POINTS_SEASON . ',' . POINTS_MOST_HITS . ',' . POINTS_MOST_HITS_AWAY . '),
p.points, 0.00)) AS wins,
SUM(IF(p.points_type = ' . POINTS_PAID . ', p.points, 0.00)) AS paid,
IF(SUM(IF(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points * -1.0, p.points)) > 0,
SUM(IF(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points * -1.0, p.points)), 0.00) AS new_pay
FROM ' . FOOTB_BETS . ' AS b
JOIN ' . USERS_TABLE . ' AS u ON (u.user_id = b.user_id)
LEFT JOIN ' . FOOTB_POINTS . " AS p ON (p.season = $season AND p.league = $league AND p.user_id = b.user_id)
WHERE b.season = $season
AND b.league = $league
AND b.match_no = 1
GROUP BY b.user_id
ORDER BY u.username ASC";
if(!$result = $db->sql_query($sql))
{
trigger_error('NO_LEAGUE');
}
$user_rows = $db->sql_fetchrowset($result);
$export_file = $league_short . '_' . $season . '_bank.csv';
$newline = "\r\n";
header('Pragma: no-cache');
header("Content-Type: text/csv; name=\"$export_file\"");
header("Content-disposition: attachment; filename=$export_file");
$export= '';
$export .= $league_name . ' ' . sprintf($user->lang['SEASON']) . ' ' . $season. $newline;
$export .= sprintf($user->lang['NAME']) . ';' . $config['football_win_name'] . ';' . sprintf($user->lang['BET_POINTS']) . ';' .
sprintf($user->lang['DEPOSITED']) . ';' . sprintf($user->lang['DEPOSIT']) . ';' . sprintf($user->lang['WINS']) . ';' .
sprintf($user->lang['PAID']) . ';' . sprintf($user->lang['PAYOUT']) . ';' . $newline;
$curr_season = curr_season();
foreach ($user_rows as $user_row)
{
if ($phpbb_extension_manager->is_enabled('dmzx/ultimatepoints') && $config['points_enable'] && $season == $curr_season)
{
$no_cash_bet_points = ($user_row['no_cash_bet_points'] == 0.00) ? '' : ' (' . str_replace('.', ',', $user_row['no_cash_bet_points']) . ')';
$no_cash_deposit = ($user_row['no_cash_deposit'] == 0.00) ? '' : ' (' . str_replace('.', ',', $user_row['no_cash_deposit']) . ')';
$no_cash_wins = ($user_row['no_cash_wins'] == 0.00) ? '' : ' (' . str_replace('.', ',', $user_row['no_cash_wins']) . ')';
$no_cash_paid = ($user_row['no_cash_paid'] == 0.00) ? '' : ' (' . str_replace('.', ',', $user_row['no_cash_paid']) . ')';
}
else
{
$no_cash_bet_points = '';
$no_cash_deposit = '';
$no_cash_wins = '';
$no_cash_paid = '';
}
$export .= str_replace("\"", "\"\"", $user_row['username']) . ';' .
str_replace('.', ',', $user_row['user_points']) . ';' .
str_replace('.', ',', $user_row['bet_points']) . $no_cash_bet_points . ';' .
str_replace('.', ',', $user_row['deposit']) . $no_cash_deposit . ';' .
str_replace('.', ',', $user_row['new_deposit']) . ';' .
str_replace('.', ',', $user_row['wins']) . $no_cash_wins . ';' .
str_replace('.', ',', $user_row['paid']) . $no_cash_paid . ';' .
str_replace('.', ',', $user_row['new_pay']) . ';' . $newline;
}
echo utf8_decode($export);
exit;
}
}
}
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
$this->user->add_lang_ext('football/football', 'info_acp_bank');
// Check Prediction League authorisation
if ( !$this->auth->acl_get('u_use_football') )
{
trigger_error('NO_AUTH_VIEW');
}
$action='';
$phpbb_root_path = './../../';
if (!$season OR !$league)
{
redirect($this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league)));
}
else
{
$season_info = season_info($season);
if (!sizeof($season_info))
{
$error_message = sprintf($user->lang['NO_SEASON']);
trigger_error($error_message);
}
else
{
$league_info = league_info($season, $league);
if (!sizeof($league_info))
{
$error_message = sprintf($user->lang['NO_LEAGUE']);
trigger_error($error_message);
}
else
{
$bet_points = $league_info['bet_points'];
$league_name =$league_info['league_name'];
$league_short =$league_info['league_name_short'];
$user_points = '';
global $phpbb_extension_manager;
if ($phpbb_extension_manager->is_enabled('dmzx/ultimatepoints') && $config['points_enable'])
{
$user_points = 'u.user_points,';
}
else
{
$user_points = "0.00 AS user_points,";
}
// Grab the members points
$sql = "SELECT
b.user_id,
u.username,
$user_points
$bet_points AS bet_points,
SUM(IF(p.points_type = " . POINTS_BET . ', IF(p.cash = 0, p.points, 0.00), 0.00)) AS no_cash_bet_points,
SUM(IF(p.points_type = ' . POINTS_DEPOSITED . ', IF(p.cash = 0, p.points, 0.00), 0.00)) AS no_cash_deposit,
SUM(IF(p.points_type IN (' . POINTS_MATCHDAY . ',' . POINTS_SEASON . ',' . POINTS_MOST_HITS . ',' . POINTS_MOST_HITS_AWAY . '),
IF(p.cash = 0, p.points, 0.00),
0.00)) AS no_cash_wins,
SUM(IF(p.points_type = ' . POINTS_PAID . ', IF(p.cash = 0, p.points, 0.00), 0.00)) AS no_cash_paid,
SUM(IF(p.points_type = ' . POINTS_DEPOSITED . ', p.points, 0.00)) AS deposit,
IF(SUM(IF(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points, p.points * -1.0)) > 0,
SUM(IF(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points, p.points * -1.0)), 0.00) AS new_deposit,
SUM(IF(p.points_type IN (' . POINTS_MATCHDAY . ',' . POINTS_SEASON . ',' . POINTS_MOST_HITS . ',' . POINTS_MOST_HITS_AWAY . '),
p.points, 0.00)) AS wins,
SUM(IF(p.points_type = ' . POINTS_PAID . ', p.points, 0.00)) AS paid,
IF(SUM(IF(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points * -1.0, p.points)) > 0,
SUM(IF(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points * -1.0, p.points)), 0.00) AS new_pay
FROM ' . FOOTB_BETS . ' AS b
JOIN ' . USERS_TABLE . ' AS u ON (u.user_id = b.user_id)
LEFT JOIN ' . FOOTB_POINTS . " AS p ON (p.season = $season AND p.league = $league AND p.user_id = b.user_id)
WHERE b.season = $season
AND b.league = $league
AND b.match_no = 1
GROUP BY b.user_id
ORDER BY u.username ASC";
if(!$result = $db->sql_query($sql))
{
trigger_error('NO_LEAGUE');
}
$user_rows = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$export_file = $league_short . '_' . $season . '_bank.csv';
$newline = "\r\n";
header('Pragma: no-cache');
header("Content-Type: text/csv; name=\"$export_file\"");
header("Content-disposition: attachment; filename=$export_file");
$export= '';
$export .= $league_name . ' ' . sprintf($user->lang['SEASON']) . ' ' . $season. $newline;
$export .= sprintf($user->lang['NAME']) . ';' . $config['football_win_name'] . ';' . sprintf($user->lang['BET_POINTS']) . ';' .
sprintf($user->lang['DEPOSITED']) . ';' . sprintf($user->lang['DEPOSIT']) . ';' . sprintf($user->lang['WINS']) . ';' .
sprintf($user->lang['PAID']) . ';' . sprintf($user->lang['PAYOUT']) . ';' . $newline;
$curr_season = curr_season();
foreach ($user_rows as $user_row)
{
if ($phpbb_extension_manager->is_enabled('dmzx/ultimatepoints') && $config['points_enable'] && $season == $curr_season)
{
$no_cash_bet_points = ($user_row['no_cash_bet_points'] == 0.00) ? '' : ' (' . str_replace('.', ',', $user_row['no_cash_bet_points']) . ')';
$no_cash_deposit = ($user_row['no_cash_deposit'] == 0.00) ? '' : ' (' . str_replace('.', ',', $user_row['no_cash_deposit']) . ')';
$no_cash_wins = ($user_row['no_cash_wins'] == 0.00) ? '' : ' (' . str_replace('.', ',', $user_row['no_cash_wins']) . ')';
$no_cash_paid = ($user_row['no_cash_paid'] == 0.00) ? '' : ' (' . str_replace('.', ',', $user_row['no_cash_paid']) . ')';
}
else
{
$no_cash_bet_points = '';
$no_cash_deposit = '';
$no_cash_wins = '';
$no_cash_paid = '';
}
$export .= str_replace("\"", "\"\"", $user_row['username']) . ';' .
str_replace('.', ',', $user_row['user_points']) . ';' .
str_replace('.', ',', $user_row['bet_points']) . $no_cash_bet_points . ';' .
str_replace('.', ',', $user_row['deposit']) . $no_cash_deposit . ';' .
str_replace('.', ',', $user_row['new_deposit']) . ';' .
str_replace('.', ',', $user_row['wins']) . $no_cash_wins . ';' .
str_replace('.', ',', $user_row['paid']) . $no_cash_paid . ';' .
str_replace('.', ',', $user_row['new_pay']) . ';' . $newline;
}
echo utf8_decode($export);
exit;
}
}
}
?>
+87 -86
View File
@@ -1,87 +1,88 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
$this->user->add_lang_ext('football/football', 'info_acp_bank');
// Check Prediction League authorisation
if ( !$this->auth->acl_get('u_use_football') )
{
trigger_error('NO_AUTH_VIEW');
}
$action='';
if (!$season)
{
redirect($this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season)));
}
else
{
$season_info = season_info($season);
if (!sizeof($season_info))
{
$error_message = sprintf($user->lang['NO_SEASON']);
trigger_error($error_message);
}
else
{
// Grab the members points
$sql = 'SELECT
u.username,
p.season,
p.league,
round(sum(if(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points * -1.0, p.points)),2) as saldo
FROM ' . FOOTB_POINTS . ' AS p
JOIN ' . USERS_TABLE . " AS u ON (u.user_id = p.user_id)
WHERE p.season <= $season
GROUP BY p.season, p.league, u.username
HAVING saldo <> 0.00
ORDER BY u.username, p.season, p.league";
if(!$result = $db->sql_query($sql))
{
trigger_error('NO_SEASON');
}
$user_rows = $db->sql_fetchrowset($result);
$export_file = $season. '_bank.csv';
$newline = "\r\n";
header('Pragma: no-cache');
header("Content-Type: text/csv; name=\"$export_file\"");
header("Content-disposition: attachment; filename=$export_file");
$export= '';
$export .= sprintf($user->lang['SEASON']) . ' ' . $season. $newline;
$export .= sprintf($user->lang['NAME']) . ';' . sprintf($user->lang['SEASON']) . ';' . sprintf($user->lang['LEAGUE']) . ';Saldo;' . $newline;
$last_username = '';
$sum_saldo = 0.0;
foreach ($user_rows as $user_row)
{
if ($last_username != '' AND $last_username != $user_row['username'])
{
$export .= str_replace("\"", "\"\"", $last_username) . ';Summe;;' .
str_replace('.', ',', $sum_saldo) . ';' . $newline;
$sum_saldo = 0.0;
}
$export .= str_replace("\"", "\"\"", $user_row['username']) . ';' .
$user_row['season'] . ';' .
$user_row['league'] . ';' .
str_replace('.', ',', $user_row['saldo']) . ';' . $newline;
$sum_saldo += $user_row['saldo'];
$last_username = $user_row['username'];
}
if ($last_username != '')
{
$export .= str_replace("\"", "\"\"", $last_username) . ';Summe;;' .
str_replace('.', ',', $sum_saldo) . ';' . $newline;
}
echo utf8_decode($export);
exit;
}
}
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
$this->user->add_lang_ext('football/football', 'info_acp_bank');
// Check Prediction League authorisation
if ( !$this->auth->acl_get('u_use_football') )
{
trigger_error('NO_AUTH_VIEW');
}
$action='';
if (!$season)
{
redirect($this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season)));
}
else
{
$season_info = season_info($season);
if (!sizeof($season_info))
{
$error_message = sprintf($user->lang['NO_SEASON']);
trigger_error($error_message);
}
else
{
// Grab the members points
$sql = 'SELECT
u.username,
p.season,
p.league,
round(sum(if(p.points_type IN (' . POINTS_BET . ',' . POINTS_PAID . '), p.points * -1.0, p.points)),2) as saldo
FROM ' . FOOTB_POINTS . ' AS p
JOIN ' . USERS_TABLE . " AS u ON (u.user_id = p.user_id)
WHERE p.season <= $season
GROUP BY p.season, p.league, u.username
HAVING saldo <> 0.00
ORDER BY u.username, p.season, p.league";
if(!$result = $db->sql_query($sql))
{
trigger_error('NO_SEASON');
}
$user_rows = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$export_file = $season. '_bank.csv';
$newline = "\r\n";
header('Pragma: no-cache');
header("Content-Type: text/csv; name=\"$export_file\"");
header("Content-disposition: attachment; filename=$export_file");
$export= '';
$export .= sprintf($user->lang['SEASON']) . ' ' . $season. $newline;
$export .= sprintf($user->lang['NAME']) . ';' . sprintf($user->lang['SEASON']) . ';' . sprintf($user->lang['LEAGUE']) . ';Saldo;' . $newline;
$last_username = '';
$sum_saldo = 0.0;
foreach ($user_rows as $user_row)
{
if ($last_username != '' AND $last_username != $user_row['username'])
{
$export .= str_replace("\"", "\"\"", $last_username) . ';Summe;;' .
str_replace('.', ',', $sum_saldo) . ';' . $newline;
$sum_saldo = 0.0;
}
$export .= str_replace("\"", "\"\"", $user_row['username']) . ';' .
$user_row['season'] . ';' .
$user_row['league'] . ';' .
str_replace('.', ',', $user_row['saldo']) . ';' . $newline;
$sum_saldo += $user_row['saldo'];
$last_username = $user_row['username'];
}
if ($last_username != '')
{
$export .= str_replace("\"", "\"\"", $last_username) . ';Summe;;' .
str_replace('.', ',', $sum_saldo) . ';' . $newline;
}
echo utf8_decode($export);
exit;
}
}
?>
+5 -12
View File
@@ -91,6 +91,10 @@ else
$data_last_home = false;
$data_last_away = false;
$form_from = $matchday-5;
$percent_home = 0;
$percent_draw = 0;
$percent_guest = 0;
$stat_hist = '';
$value_h = 0;
$value_g = 0;
$value_hg = 0;
@@ -115,7 +119,6 @@ else
{
$logo[$home_id] = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$db->sql_freeresult($result);
}
else
{
@@ -142,7 +145,6 @@ else
{
$logo[$guest_id] = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$db->sql_freeresult($result);
}
else
{
@@ -245,7 +247,6 @@ else
)
);
}
$db->sql_freeresult($result);
// Statistic and forecast-points for historie
$sql = "SELECT
@@ -322,10 +323,6 @@ else
}
}
$stat_hist = '';
$percent_home = 0;
$percent_draw = 0;
$percent_guest = 0;
if (sizeof($row))
{
if ($history_count <= 2)
@@ -1003,7 +1000,6 @@ else
);
}
}
$db->sql_freeresult($result);
//last matches home hometeam
$sql = '(SELECT
@@ -1074,7 +1070,6 @@ else
);
}
}
$db->sql_freeresult($result);
//last game guestteam
$sql = "(SELECT
@@ -1158,7 +1153,6 @@ else
);
}
}
$db->sql_freeresult($result);
//last matches away guestteam
$sql = '(SELECT
@@ -1226,7 +1220,6 @@ else
);
}
}
$db->sql_freeresult($result);
if ($history_count == 0 and !($data_home and $data_guest))
{
@@ -1266,7 +1259,7 @@ else
$sql = 'UPDATE ' . FOOTB_MATCHES . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
WHERE season = $season AND league = $league AND match_no = $matchnumber";
$result = $db->sql_query($sql);
$db->sql_freeresult($result);
$forecast_value = 0;
+150
View File
@@ -0,0 +1,150 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$user_is_member = user_is_member($user->data['user_id'], $season, $league);
$edit_mode = false;
$display_group = false;
$display_ko = false;
$data_lastresults = false;
$curr_year = date("Y");
$matchnumber = 0;
$match_date = "";
$local_board_time = time() + ($config['football_time_shift'] * 3600);
$sql = 'SELECT * FROM ' . FOOTB_MATCHDAYS . " WHERE status = 0 AND delivery_date < FROM_UNIXTIME('$local_board_time')";
// Calculate matches AND results of matchday
$sql = "SELECT
m.season,
m.league,
m.matchday,
m.status,
m.match_datetime,
LEFT(m.match_datetime, 10) AS match_date,
l.league_name,
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_short,
t2.team_name_short AS guest_short,
m.goals_home,
m.goals_guest,
m.ko_match AS ko_match,
m.goals_overtime_home AS kogoals_home,
m.goals_overtime_guest AS kogoals_guest,
CONCAT(
CASE DATE_FORMAT(m.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(m.match_datetime,' %d.%m. %H:%i')
) AS match_time
FROM " . FOOTB_MATCHES . ' AS m
LEFT JOIN ' . FOOTB_LEAGUES . ' AS l ON (l.season = m.season AND l.league = m.league)
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.match_datetime < FROM_UNIXTIME('$local_board_time')
ORDER BY m.match_datetime DESC, m.league ASC
LIMIT 100";
$result = $db->sql_query($sql);
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
while($row = $db->sql_fetchrow($result))
{
$data_lastresults = true;
$matchnumber++ ;
$row_class = (!($matchnumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($match_date <> $row['match_date'])
{
$match_date = ($match_date == "") ? $row['match_date'] : $match_date;
if ($matchnumber > $config['football_display_last_results'] )
{
break;
}
}
$homelogo = $row['home_symbol'];
$homename = $row['home_name'];
$homeshort = $row['home_short'];
$guestlogo = $row['guest_symbol'];
$guestname = $row['guest_name'];
$guestshort = $row['guest_short'];
if ($homelogo <> '')
{
$logoH = "<img src=\"" . $ext_path . 'images/flags/' . $homelogo . "\" alt=\"" . $homelogo . "\" width=\"20\" height=\"20\"/>" ;
}
else
{
$logoH = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"20\" height=\"20\"/>" ;
}
if ($guestlogo <> '')
{
$logoG = "<img src=\"" . $ext_path . 'images/flags/' . $guestlogo . "\" alt=\"" . $guestlogo . "\" width=\"20\" height=\"20\"/>" ;
}
else
{
$logoG = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"20\" height=\"20\"/>" ;
}
$goals_home = ($row['goals_home'] == '') ? '- ' : $row['goals_home'];
$goals_guest = ($row['goals_guest'] == '') ? ' -' : $row['goals_guest'];
$kogoals_home = ($row['kogoals_home'] == '') ? '- ' : $row['kogoals_home'];
$kogoals_guest = ($row['kogoals_guest'] == '') ? ' -' : $row['kogoals_guest'];
$colorstyle = color_style($row['status']);
$template->assign_block_vars('last_results', array(
'ROW_CLASS' => $row_class,
'U_RESULTS_LINK'=> $this->helper->route('football_main_controller', array('side' => 'results', 's' => $row['season'], 'l' => $row['league'], 'm' => $row['matchday'])),
'MATCH_DATE' => $row['match_date'],
'MATCH_TIME' => $row['match_time'],
'LEAGUE_NAME' => $row['league_name'],
'LOGO_HOME' => $logoH,
'LOGO_GUEST' => $logoG,
'HOME_NAME' => $homename,
'GUEST_NAME' => $guestname,
'HOME_SHORT' => $homeshort,
'GUEST_SHORT' => $guestshort,
'GOALS_HOME' => $goals_home,
'GOALS_GUEST' => $goals_guest,
'COLOR_STYLE' => color_style($row['status']),
'KOGOALS_HOME' => $kogoals_home,
'KOGOALS_GUEST' => $kogoals_guest,
'COLOR_STYLE' => $colorstyle,
)
);
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['LAST_RESULTS']);
$template->assign_vars(array(
'S_DISPLAY_LAST_RESULTS' => true,
'S_SIDENAME' => $sidename,
'S_DATA_LAST_RESULTS' => $data_lastresults,
'S_USER_IS_MEMBER' => $user_is_member,
)
);
?>
+65 -65
View File
@@ -1,66 +1,66 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB'))
{
exit;
}
$display_last_users = false;
// Last 5 users
$sql = 'SELECT s.session_user_id
, u.username
, u.user_colour
, u.user_lastvisit
, MAX(s.session_time) AS session_time
, IF(MAX(s.session_time) > u.user_lastvisit, MAX(s.session_time), u.user_lastvisit) AS lastvisit
, IF(MAX(s.session_time) > u.user_lastvisit, MAX(CONCAT(s.session_time,s.session_browser)), "") AS session_browser
FROM ' . USERS_TABLE . ' AS u
LEFT JOIN ' . SESSIONS_TABLE . ' AS s ON (u.user_id = s.session_user_id)
WHERE u.user_lastvisit > 0
AND u.user_type IN (0,3)
GROUP BY u.user_id
ORDER BY lastvisit DESC';
$result = $db->sql_query_limit($sql, 5);
$first = true;
while ($row = $db->sql_fetchrow($result))
{
if (!$row['lastvisit'] && $first == true)
{
$display_last_users = false;
}
else
{
$display_last_users = true;
if($row['lastvisit'] > 0)
{
$browser = '';
if (preg_match('/iPad|iPhone|iOS|Opera Mobi|BlackBerry|Android|IEMobile|Symbian/', $row['session_browser'], $match_browser))
{
$browser = ' (' . $match_browser[0] . ')';
}
$template->assign_block_vars('last_users', array(
'USER_NAME' => get_username_string('full', '', $row['username'], $row['user_colour']) . $browser,
'LAST_VISIT_DATE' => $user->format_date($row['lastvisit']),
));
}
}
$first = false;
}
$db->sql_freeresult($result);
// Assign specific vars
$template->assign_vars(array(
'LAST_USERS' => sprintf($user->lang['LAST_VISITORS'], 5),
'S_DISPLAY_LAST_USERS' => $display_last_users,
'S_LAST_USERS' => true,
));
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB'))
{
exit;
}
$display_last_users = false;
// Last users
$sql = 'SELECT s.session_user_id
, u.username
, u.user_colour
, u.user_lastvisit
, MAX(s.session_time) AS session_time
, IF(MAX(s.session_time) > u.user_lastvisit, MAX(s.session_time), u.user_lastvisit) AS lastvisit
, IF(MAX(s.session_time) > u.user_lastvisit, MAX(CONCAT(s.session_time,s.session_browser)), "") AS session_browser
FROM ' . USERS_TABLE . ' AS u
LEFT JOIN ' . SESSIONS_TABLE . ' AS s ON (u.user_id = s.session_user_id)
WHERE u.user_lastvisit > 0
AND u.user_type IN (0,3)
GROUP BY u.user_id
ORDER BY lastvisit DESC';
$result = $db->sql_query_limit($sql, $config['football_display_last_users']);
$first = true;
while ($row = $db->sql_fetchrow($result))
{
if (!$row['lastvisit'] && $first == true)
{
$display_last_users = false;
}
else
{
$display_last_users = true;
if($row['lastvisit'] > 0)
{
$browser = '';
if (preg_match('/iPad|iPhone|iOS|Opera Mobi|BlackBerry|Android|IEMobile|Symbian/', $row['session_browser'], $match_browser))
{
$browser = ' (' . $match_browser[0] . ')';
}
$template->assign_block_vars('last_users', array(
'USER_NAME' => get_username_string('full', '', $row['username'], $row['user_colour']) . $browser,
'LAST_VISIT_DATE' => $user->format_date($row['lastvisit']),
));
}
}
$first = false;
}
$db->sql_freeresult($result);
// Assign specific vars
$template->assign_vars(array(
'LAST_USERS' => sprintf($user->lang['LAST_VISITORS'], $config['football_display_last_users']),
'S_DISPLAY_LAST_USERS' => $display_last_users,
'S_LAST_USERS' => true,
));
?>
+323 -331
View File
@@ -1,332 +1,324 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
if (!$user_sel)
{
if (user_is_member($user->data['user_id'], $season, $league))
{
$user_sel = $user->data['user_id'];
}
}
$username = '';
$data = false;
// select user
$sql = 'SELECT DISTINCT
u.user_id,
u.username
FROM ' . FOOTB_BETS . ' AS b
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
WHERE season = $season AND league = $league
ORDER BY LOWER(u.username) ASC";
$numb_users = 0;
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$numb_users++;
$data = true;
if ($user_sel == $row['user_id'] OR !$user_sel)
{
$selectid = ' selected="selected"';
$username = $row['username'];
$user_sel = $row['user_id'];
}
else
{
$selectid = '';
}
$template->assign_block_vars('form_user', array(
'S_USER' => $row['user_id'],
'S_USERNAME' => $row['username'],
'S_SELECTEDID' => $selectid,
)
);
}
$db->sql_freeresult($result);
// All bets of selected user group by bet
$rank = 0;
$bets_home_win = 0;
$bets_draw = 0;
$bets_guest_win = 0;
$win_home_win = 0;
$win_draw = 0;
$win_guest_win = 0;
$points_home_win = 0;
$points_draw = 0;
$points_guest_win = 0;
$sql = 'SELECT
COUNT(b.match_no) AS bets,
b.goals_home,
b.goals_guest,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0)
)
) AS hits,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
)
) AS tendencies,
' . select_points('m',true) . '
FROM ' . FOOTB_BETS . ' AS b
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
WHERE b.season = $season
AND b.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.status = 3
AND b.user_id = $user_sel
AND m.matchday <= $matchday
GROUP by b.goals_home, b.goals_guest
ORDER by bets DESC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
if ($row['goals_home'] > $row['goals_guest'])
{
$bets_home_win += $row['bets'];
$win_home_win += $row['hits'] + $row['tendencies'];
$points_home_win += $row['points'];
}
if ($row['goals_home'] == $row['goals_guest'])
{
$bets_draw += $row['bets'];
$win_draw += $row['hits'] + $row['tendencies'];
$points_draw += $row['points'];
}
if ($row['goals_home'] < $row['goals_guest'])
{
$bets_guest_win += $row['bets'];
$win_guest_win += $row['hits'] + $row['tendencies'];
$points_guest_win += $row['points'];
}
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('bets', array(
'ROW_CLASS' => $row_class,
'GOALSHOME' => $row['goals_home'],
'GOALSGUEST' => $row['goals_guest'],
'COUNT' => $row['bets'],
'DIRECTHITS' => $row['hits'],
'TENDENCIES' => $row['tendencies'],
'TOTAL' => $row['hits'] + $row['tendencies'],
'POINTS' => $row['points'],
'AVERAGE' => round($row['points'] / $row['bets'],1),
)
);
}
$db->sql_freeresult($result);
// Tendencies of all results
$sql = "SELECT
SUM(IF(goals_home + 0 > goals_guest,1,0)) AS SUM_HOME_WIN,
SUM(IF(goals_home = goals_guest,1,0)) AS SUM_DRAW,
SUM(IF(goals_home + 0 < goals_guest,1,0)) AS SUM_GUEST_WIN
FROM " . FOOTB_MATCHES . "
WHERE season = $season
AND league = $league
AND status = 3
AND matchday <= $matchday";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('bets_wdl', array(
'ROW_CLASS' => 'bg2 row_dark',
'SCORE' => sprintf($user->lang['PLAYED']),
'HOMEWIN' => $row['SUM_HOME_WIN'],
'DRAW' => $row['SUM_DRAW'],
'GUESTWIN' => $row['SUM_GUEST_WIN'],
)
);
// Muliply with user of this league
$template->assign_block_vars('bets_wdl_all', array(
'ROW_CLASS' => 'bg2 row_dark',
'SCORE' => sprintf($user->lang['PLAYED']),
'HOMEWIN' => $row['SUM_HOME_WIN'] * $numb_users,
'DRAW' => $row['SUM_DRAW'] * $numb_users,
'GUESTWIN' => $row['SUM_GUEST_WIN'] * $numb_users,
)
);
}
$db->sql_freeresult($result);
// Count tendencies (bets of selected user)
$template->assign_block_vars('bets_wdl', array(
'ROW_CLASS' => 'bg1 row_light',
'SCORE' => sprintf($user->lang['GUESSED']),
'HOMEWIN' => $bets_home_win,
'DRAW' => $bets_draw,
'GUESTWIN' => $bets_guest_win,
)
);
// Scored with tendency (bets of selected user)
$template->assign_block_vars('bets_wdl', array(
'ROW_CLASS' => 'bg2 row_dark',
'SCORE' => sprintf($user->lang['SCORED']),
'HOMEWIN' => $win_home_win,
'DRAW' => $win_draw,
'GUESTWIN' => $win_guest_win,
)
);
// Points with tendency (bets of selected user)
$template->assign_block_vars('bets_wdl', array(
'ROW_CLASS' => 'bg1 row_light',
'SCORE' => sprintf($user->lang['POINTS']),
'HOMEWIN' => $points_home_win,
'DRAW' => $points_draw,
'GUESTWIN' => $points_guest_win,
)
);
// All bets of all users group by bet
$rank = 0;
$bets_home_win = 0;
$bets_draw = 0;
$bets_guest_win = 0;
$win_home_win = 0;
$win_draw = 0;
$win_guest_win = 0;
$points_home_win = 0;
$points_draw = 0;
$points_guest_win = 0;
$sql = 'SELECT
COUNT(b.match_no) AS bets,
b.goals_home,
b.goals_guest,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0)
)
) AS hits,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
)
) AS tendencies,
' . select_points('m',true) . '
FROM ' . FOOTB_BETS . ' AS b
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
WHERE b.season = $season
AND b.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.status = 3
AND m.matchday <= $matchday
GROUP by b.goals_home, b.goals_guest
ORDER by bets DESC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
if ($row['goals_home'] > $row['goals_guest'])
{
$bets_home_win += $row['bets'];
$win_home_win += $row['hits'] + $row['tendencies'];
$points_home_win += $row['points'];
}
if ($row['goals_home'] == $row['goals_guest'])
{
$bets_draw += $row['bets'];
$win_draw += $row['hits'] + $row['tendencies'];
$points_draw += $row['points'];
}
if ($row['goals_home'] < $row['goals_guest'])
{
$bets_guest_win += $row['bets'];
$win_guest_win += $row['hits'] + $row['tendencies'];
$points_guest_win += $row['points'];
}
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('allbets', array(
'ROW_CLASS' => $row_class,
'GOALSHOME' => $row['goals_home'],
'GOALSGUEST' => $row['goals_guest'],
'COUNT' => $row['bets'],
'DIRECTHITS' => $row['hits'],
'TENDENCIES' => $row['tendencies'],
'TOTAL' => $row['hits'] + $row['tendencies'],
'POINTS' => $row['points'],
'AVERAGE' => round($row['points'] / $row['bets'],1),
)
);
}
$db->sql_freeresult($result);
// Count tendencies (bets of all user)
$template->assign_block_vars('bets_wdl_all', array(
'ROW_CLASS' => 'bg2 row_dark',
'SCORE' => sprintf($user->lang['GUESSED']),
'HOMEWIN' => $bets_home_win,
'DRAW' => $bets_draw,
'GUESTWIN' => $bets_guest_win,
)
);
// Scored with tendency (bets of all user)
$template->assign_block_vars('bets_wdl_all', array(
'ROW_CLASS' => 'bg1 row_light',
'SCORE' => sprintf($user->lang['SCORED']),
'HOMEWIN' => $win_home_win,
'DRAW' => $win_draw,
'GUESTWIN' => $win_guest_win,
)
);
// Points with tendency (bets of all user)
$template->assign_block_vars('bets_wdl_all', array(
'ROW_CLASS' => 'bg2 row_dark',
'SCORE' => sprintf($user->lang['POINTS']),
'HOMEWIN' => $points_home_win,
'DRAW' => $points_draw,
'GUESTWIN' => $points_guest_win,
)
);
$sidename = sprintf($user->lang['MY_BETS']);
$template->assign_vars(array(
'S_DISPLAY_MY_BETS' => true,
'S_SIDENAME' => $sidename,
'U_LEFT' => ($config['football_bank']) ? $this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league, 'm' => $matchday)) :
$this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => ($config['football_bank']) ? '&lt; ' . sprintf($user->lang['FOOTBALL_BANK']) :
'&lt; ' . sprintf($user->lang['RANK_TOTAL']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'my_points', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['MY_POINTS']) . ' &gt;',
'LEFT_TITLE' => ($config['football_bank']) ? sprintf($user->lang['TITLE_FOOTBALL_BANK']) : sprintf($user->lang['TITLE_RANK_TOTAL']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_MY_POINTS']),
'S_DATA_MY_BETS' => $data,
'SEASON' => $season,
'LEAGUE' => $league,
'USERNAME' => $username,
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
if (!$user_sel)
{
if (user_is_member($user->data['user_id'], $season, $league))
{
$user_sel = $user->data['user_id'];
}
}
$username = '';
$data = false;
// select user
$sql = 'SELECT DISTINCT
u.user_id,
u.username
FROM ' . FOOTB_BETS . ' AS b
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
WHERE season = $season AND league = $league
ORDER BY LOWER(u.username) ASC";
$numb_users = 0;
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$numb_users++;
$data = true;
if ($user_sel == $row['user_id'] OR !$user_sel)
{
$selectid = ' selected="selected"';
$username = $row['username'];
$user_sel = $row['user_id'];
}
else
{
$selectid = '';
}
$template->assign_block_vars('form_user', array(
'S_USER' => $row['user_id'],
'S_USERNAME' => $row['username'],
'S_SELECTEDID' => $selectid,
)
);
}
$db->sql_freeresult($result);
// All bets of selected user group by bet
$rank = 0;
$bets_home_win = 0;
$bets_draw = 0;
$bets_guest_win = 0;
$win_home_win = 0;
$win_draw = 0;
$win_guest_win = 0;
$points_home_win = 0;
$points_draw = 0;
$points_guest_win = 0;
$sql = 'SELECT
COUNT(b.match_no) AS bets,
b.goals_home,
b.goals_guest,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0)
)
) AS hits,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
)
) AS tendencies,
' . select_points('m',true) . '
FROM ' . FOOTB_BETS . ' AS b
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
WHERE b.season = $season
AND b.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.status = 3
AND b.user_id = $user_sel
AND m.matchday <= $matchday
GROUP by b.goals_home, b.goals_guest
ORDER by bets DESC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
if ($row['goals_home'] > $row['goals_guest'])
{
$bets_home_win += $row['bets'];
$win_home_win += $row['hits'] + $row['tendencies'];
$points_home_win += $row['points'];
}
if ($row['goals_home'] == $row['goals_guest'])
{
$bets_draw += $row['bets'];
$win_draw += $row['hits'] + $row['tendencies'];
$points_draw += $row['points'];
}
if ($row['goals_home'] < $row['goals_guest'])
{
$bets_guest_win += $row['bets'];
$win_guest_win += $row['hits'] + $row['tendencies'];
$points_guest_win += $row['points'];
}
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('bets', array(
'ROW_CLASS' => $row_class,
'GOALSHOME' => $row['goals_home'],
'GOALSGUEST' => $row['goals_guest'],
'COUNT' => $row['bets'],
'DIRECTHITS' => $row['hits'],
'TENDENCIES' => $row['tendencies'],
'TOTAL' => $row['hits'] + $row['tendencies'],
'POINTS' => $row['points'],
'AVERAGE' => round($row['points'] / $row['bets'],1),
)
);
}
$db->sql_freeresult($result);
// Tendencies of all results
$sql = "SELECT
SUM(IF(goals_home + 0 > goals_guest,1,0)) AS SUM_HOME_WIN,
SUM(IF(goals_home = goals_guest,1,0)) AS SUM_DRAW,
SUM(IF(goals_home + 0 < goals_guest,1,0)) AS SUM_GUEST_WIN
FROM " . FOOTB_MATCHES . "
WHERE season = $season
AND league = $league
AND status = 3
AND matchday <= $matchday";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('bets_wdl', array(
'ROW_CLASS' => 'bg2 row_dark',
'SCORE' => sprintf($user->lang['PLAYED']),
'HOMEWIN' => $row['SUM_HOME_WIN'],
'DRAW' => $row['SUM_DRAW'],
'GUESTWIN' => $row['SUM_GUEST_WIN'],
)
);
// Muliply with user of this league
$template->assign_block_vars('bets_wdl_all', array(
'ROW_CLASS' => 'bg2 row_dark',
'SCORE' => sprintf($user->lang['PLAYED']),
'HOMEWIN' => $row['SUM_HOME_WIN'] * $numb_users,
'DRAW' => $row['SUM_DRAW'] * $numb_users,
'GUESTWIN' => $row['SUM_GUEST_WIN'] * $numb_users,
)
);
}
$db->sql_freeresult($result);
// Count tendencies (bets of selected user)
$template->assign_block_vars('bets_wdl', array(
'ROW_CLASS' => 'bg1 row_light',
'SCORE' => sprintf($user->lang['GUESSED']),
'HOMEWIN' => $bets_home_win,
'DRAW' => $bets_draw,
'GUESTWIN' => $bets_guest_win,
)
);
// Scored with tendency (bets of selected user)
$template->assign_block_vars('bets_wdl', array(
'ROW_CLASS' => 'bg2 row_dark',
'SCORE' => sprintf($user->lang['SCORED']),
'HOMEWIN' => $win_home_win,
'DRAW' => $win_draw,
'GUESTWIN' => $win_guest_win,
)
);
// Points with tendency (bets of selected user)
$template->assign_block_vars('bets_wdl', array(
'ROW_CLASS' => 'bg1 row_light',
'SCORE' => sprintf($user->lang['POINTS']),
'HOMEWIN' => $points_home_win,
'DRAW' => $points_draw,
'GUESTWIN' => $points_guest_win,
)
);
// All bets of all users group by bet
$rank = 0;
$bets_home_win = 0;
$bets_draw = 0;
$bets_guest_win = 0;
$win_home_win = 0;
$win_draw = 0;
$win_guest_win = 0;
$points_home_win = 0;
$points_draw = 0;
$points_guest_win = 0;
$sql = 'SELECT
COUNT(b.match_no) AS bets,
b.goals_home,
b.goals_guest,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0)
)
) AS hits,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
)
) AS tendencies,
' . select_points('m',true) . '
FROM ' . FOOTB_BETS . ' AS b
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
WHERE b.season = $season
AND b.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.status = 3
AND m.matchday <= $matchday
GROUP by b.goals_home, b.goals_guest
ORDER by bets DESC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
if ($row['goals_home'] > $row['goals_guest'])
{
$bets_home_win += $row['bets'];
$win_home_win += $row['hits'] + $row['tendencies'];
$points_home_win += $row['points'];
}
if ($row['goals_home'] == $row['goals_guest'])
{
$bets_draw += $row['bets'];
$win_draw += $row['hits'] + $row['tendencies'];
$points_draw += $row['points'];
}
if ($row['goals_home'] < $row['goals_guest'])
{
$bets_guest_win += $row['bets'];
$win_guest_win += $row['hits'] + $row['tendencies'];
$points_guest_win += $row['points'];
}
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('allbets', array(
'ROW_CLASS' => $row_class,
'GOALSHOME' => $row['goals_home'],
'GOALSGUEST' => $row['goals_guest'],
'COUNT' => $row['bets'],
'DIRECTHITS' => $row['hits'],
'TENDENCIES' => $row['tendencies'],
'TOTAL' => $row['hits'] + $row['tendencies'],
'POINTS' => $row['points'],
'AVERAGE' => round($row['points'] / $row['bets'],1),
)
);
}
$db->sql_freeresult($result);
// Count tendencies (bets of all user)
$template->assign_block_vars('bets_wdl_all', array(
'ROW_CLASS' => 'bg2 row_dark',
'SCORE' => sprintf($user->lang['GUESSED']),
'HOMEWIN' => $bets_home_win,
'DRAW' => $bets_draw,
'GUESTWIN' => $bets_guest_win,
)
);
// Scored with tendency (bets of all user)
$template->assign_block_vars('bets_wdl_all', array(
'ROW_CLASS' => 'bg1 row_light',
'SCORE' => sprintf($user->lang['SCORED']),
'HOMEWIN' => $win_home_win,
'DRAW' => $win_draw,
'GUESTWIN' => $win_guest_win,
)
);
// Points with tendency (bets of all user)
$template->assign_block_vars('bets_wdl_all', array(
'ROW_CLASS' => 'bg2 row_dark',
'SCORE' => sprintf($user->lang['POINTS']),
'HOMEWIN' => $points_home_win,
'DRAW' => $points_draw,
'GUESTWIN' => $points_guest_win,
)
);
$sidename = sprintf($user->lang['MY_BETS']);
$template->assign_vars(array(
'S_DISPLAY_MY_BETS' => true,
'S_SIDENAME' => $sidename,
'S_DATA_MY_BETS' => $data,
'SEASON' => $season,
'LEAGUE' => $league,
'USERNAME' => $username,
)
);
?>
+333 -338
View File
@@ -1,339 +1,334 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data = false;
$user1 = '';
$user2 = '';
$user3 = '';
$user4 = '';
$username = '';
$username2 = '';
$username3 = '';
$username4 = '';
// Calculate rank total
$sql = 'SELECT
r.user_id,
u.username,
SUM(r.points) AS points_total
FROM ' . FOOTB_RANKS . ' AS r
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
WHERE r.season = $season
AND r.league = $league
AND r.matchday <= $matchday
GROUP BY r.user_id
ORDER BY points_total DESC, LOWER(u.username) ASC";
$result = $db->sql_query($sql);
$current_ranks = $db->sql_fetchrowset($result);
$total_users = sizeof($current_ranks);
if ($total_users > 3 AND $total_users <= 50)
{
$data = true;
$middle = round($total_users / 2,0);
// If user = leader then first = seconde
$user_first = $current_ranks[0]['user_id'];
if ($user_first == $user->data['user_id'])
$user_first = $current_ranks[1]['user_id'];
// If user = middle then middle = middle - 1
$user_middle = $current_ranks[$middle-1]['user_id'];
if ($user_middle == $user->data['user_id'])
$user_middle = $current_ranks[$middle]['user_id'];
// If user = last then last = last but one
$user_last = $current_ranks[$total_users - 1]['user_id'];
if ($user_last == $user->data['user_id'])
$user_last = $current_ranks[$total_users - 2]['user_id'];
if (user_is_member($user->data['user_id'], $season, $league))
{
// Take user, leader, middle and last
$user1 = $this->request->variable('user1', $user->data['user_id']);
$user2 = $this->request->variable('user2', $user_first);
$user3 = $this->request->variable('user3', $user_middle);
$user4 = $this->request->variable('user4', $user_last);
}
else
{
// Only take leader, middle and last
$user1 = $this->request->variable('user1', $user_first);
$user2 = $this->request->variable('user2', $user_middle);
$user3 = $this->request->variable('user3', $user_last);
$user4 = $this->request->variable('user4', 0);
}
// Add empty choice
$template->assign_block_vars('form_user2', array(
'S_USERNAME' => sprintf($user->lang['OPTION_USER']),
'S_USERID' => 0,
'S_SELECTEDID2' => '',
)
);
$template->assign_block_vars('form_user3', array(
'S_USERNAME' => sprintf($user->lang['OPTION_USER']),
'S_USERID' => 0,
'S_SELECTEDID3' => '',
)
);
$template->assign_block_vars('form_user4', array(
'S_USERNAME' => sprintf($user->lang['OPTION_USER']),
'S_USERID' => 0,
'S_SELECTEDID4' => '',
)
);
// Start select user
foreach ($current_ranks as $rank_user)
{
$curr_userid =$rank_user['user_id'];
if ($user1 == $curr_userid)
{
$selectid1 = ' selected="selected"';
$username = $rank_user['username'];
}
else
{
$selectid1 = '';
}
if ($user2 == $curr_userid)
{
$selectid2 = ' selected="selected"';
$username2 = $rank_user['username'];
}
else
{
$selectid2 = '';
}
if ($user3 == $curr_userid)
{
$selectid3 = ' selected="selected"';
$username3 = $rank_user['username'];
}
else
{
$selectid3 = '';
}
if ($user4 == $curr_userid)
{
$selectid4 = ' selected="selected"';
$username4 = $rank_user['username'];
}
else
{
$selectid4 = '';
}
if ($curr_userid != $user2 AND $curr_userid != $user3 AND $curr_userid != $user4)
$template->assign_block_vars('form_user1', array(
'S_USERNAME' => $rank_user['username'],
'S_USERID' => $curr_userid,
'S_SELECTEDID' => $selectid1));
if ($curr_userid != $user1 AND $curr_userid != $user3 AND $curr_userid != $user4)
$template->assign_block_vars('form_user2', array(
'S_USERNAME' => $rank_user['username'],
'S_USERID' => $curr_userid,
'S_SELECTEDID' => $selectid2));
if ($curr_userid != $user1 AND $curr_userid != $user2 AND $curr_userid != $user4)
$template->assign_block_vars('form_user3', array(
'S_USERNAME' => $rank_user['username'],
'S_USERID' => $curr_userid,
'S_SELECTEDID' => $selectid3));
if ($curr_userid != $user1 AND $curr_userid != $user2 AND $curr_userid != $user3)
$template->assign_block_vars('form_user4', array(
'S_USERNAME' => $rank_user['username'],
'S_USERID' => $curr_userid,
'S_SELECTEDID' => $selectid4));
}
$ranks_total_1 = '';
$ranks_dayl_1 = '';
$points_1 = '';
$sql = 'SELECT *
FROM ' . FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND matchday <= $matchday
AND user_id = $user1
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$points_1 = $points_1. $row['points']. ',';
$ranks_total_1 = $ranks_total_1. $row['rank_total']. ',';
$ranks_dayl_1 = $ranks_dayl_1. $row['rank']. ',';
}
$points_1 = substr($points_1, 0, strlen($points_1) - 1);
$ranks_total_1 = substr($ranks_total_1, 0, strlen($ranks_total_1) - 1);
$ranks_dayl_1 = substr($ranks_dayl_1, 0, strlen($ranks_dayl_1) - 1);
$db->sql_freeresult($result);
$ranks_total_2 = '';
$ranks_dayl_2 = '';
$points_2 = '';
if ($user2 != 0)
{
$sql = 'SELECT *
FROM ' . FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND matchday <= $matchday
AND user_id = $user2
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$points_2 = $points_2 . $row['points']. ',';
$ranks_total_2 = $ranks_total_2 . $row['rank_total']. ',';
$ranks_dayl_2 = $ranks_dayl_2 . $row['rank']. ',';
}
$points_2 = substr($points_2, 0, strlen($points_2) - 1);
$ranks_total_2 = substr($ranks_total_2, 0, strlen($ranks_total_2) - 1);
$ranks_dayl_2 = substr($ranks_dayl_2, 0, strlen($ranks_dayl_2) - 1);
$db->sql_freeresult($result);
}
$ranks_total_3 = '';
$ranks_dayl_3 = '';
$points_3 = '';
if ($user3 != 0)
{
$sql = 'SELECT *
FROM ' . FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND matchday <= $matchday
AND user_id = $user3
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$points_3 = $points_3. $row['points']. ',';
$ranks_total_3 = $ranks_total_3. $row['rank_total']. ',';
$ranks_dayl_3 = $ranks_dayl_3. $row['rank']. ',';
}
$points_3 = substr($points_3,0,strlen($points_3)-1);
$ranks_total_3 = substr($ranks_total_3,0,strlen($ranks_total_3)-1);
$ranks_dayl_3 = substr($ranks_dayl_3,0,strlen($ranks_dayl_3)-1);
$db->sql_freeresult($result);
}
$ranks_total_4 = '';
$ranks_dayl_4 = '';
$points_4 = '';
if ($user4 != 0)
{
$sql = 'SELECT *
FROM ' . FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND matchday <= $matchday
AND user_id = $user4
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$points_4 = $points_4. $row['points']. ',';
$sptagplatz = $row['rank'];
$ranks_total_4 = $ranks_total_4. $row['rank_total']. ',';
$ranks_dayl_4 = $ranks_dayl_4. $row['rank']. ',';
}
$points_4 = substr($points_4,0,strlen($points_4)-1);
$ranks_total_4 = substr($ranks_total_4,0,strlen($ranks_total_4)-1);
$ranks_dayl_4 = substr($ranks_dayl_4,0,strlen($ranks_dayl_4)-1);
$db->sql_freeresult($result);
}
$min = '';
$max = '';
if ($user1 != 0)
{
$sql = 'SELECT
MIN(points) As points_min,
MAX(points) As points_max
FROM ' . FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND matchday <= $matchday
GROUP BY matchday
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$min = $min. $row['points_min']. ',';
$max = $max. $row['points_max']. ',';
}
$min = substr($min,0,strlen($min)-1);
$max = substr($max,0,strlen($max)-1);
$db->sql_freeresult($result);
}
// Create and display charts
$chart= "<img src='". generate_board_url() . '/' . $this->football_root_path
. "includes/chart_rank.php?t=$total_users&amp;m=$matchday&amp;v1=$ranks_total_1&amp;v2=$ranks_total_2&amp;v3=$ranks_total_3&amp;v4=$ranks_total_4&amp;c="
. sprintf($user->lang['PLACE']) . "' alt='"
. sprintf($user->lang['CHART_TOTAL'])
. "'/>";
$template->assign_block_vars('chart_rank', array(
'CHARTIMAGE' => $chart,
)
);
$chart= "<img src='". generate_board_url() . '/' . $this->football_root_path
. "includes/chart_rank.php?t=$total_users&amp;m=$matchday&amp;v1=$ranks_dayl_1&amp;v2=$ranks_dayl_2&amp;v3=$ranks_dayl_3&amp;v4=$ranks_dayl_4&amp;c="
. sprintf($user->lang['PLACE']) . "' alt='"
. sprintf($user->lang['CHART_MATCHDAY'])
. "'/>";
$template->assign_block_vars('chart_matchtdays', array(
'CHARTIMAGE' => $chart,
)
);
$chart= "<img src='". generate_board_url() . '/' . $this->football_root_path
. "includes/chart_points.php?m=$matchday&amp;v1=$points_1&amp;v2=$points_2&amp;v3=$points_3&amp;v4=$points_4&amp;min=$min&amp;max=$max&amp;c="
. sprintf($user->lang['POINTS']) . ',' . sprintf($user->lang['BANDWIDTH']) . "' alt='"
. sprintf($user->lang['CHART_POINTS'])
. "'/>";
$template->assign_block_vars('chart_points', array(
'CHARTIMAGE' => $chart,
)
);
}
$sidename = sprintf($user->lang['MY_CHART']);
$template->assign_vars(array(
'S_DISPLAY_MY_CHART' => true,
'S_SIDENAME' => $sidename,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'my_rank', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['MY_RANK']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'my_koeff', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['MY_KOEFF']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_MY_RANKS']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_MY_KOEFF']),
'S_DATA_MY_CHART' => $data,
'SEASON' => $season,
'LEAGUE' => $league,
'S_USER1' => $user1,
'S_USER2' => $user2,
'S_USER3' => $user3,
'S_USER4' => $user4,
'USERNAME1' => $username,
'USERNAME2' => $username2,
'USERNAME3' => $username3,
'USERNAME4' => $username4,
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data = false;
$user1 = '';
$user2 = '';
$user3 = '';
$user4 = '';
$username = '';
$username2 = '';
$username3 = '';
$username4 = '';
// Calculate rank total
$sql = "SELECT
r.user_id,
u.username,
(SELECT SUM(c.rank_total) FROM " . FOOTB_MY_CHART . " AS c WHERE c.user_id = (r.user_id) AND c.season = r.season AND c.league = r.league AND c.matchday = $matchday) AS points_total
FROM " . FOOTB_RANKS . ' AS r
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
WHERE r.season = $season
AND r.league = $league
AND r.matchday <= $matchday
GROUP BY r.user_id
ORDER BY points_total ASC, LOWER(u.username) ASC";
$result = $db->sql_query($sql);
$current_ranks = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$total_users = sizeof($current_ranks);
if ($total_users > 3 AND $total_users <= 50)
{
$data = true;
$middle = round($total_users / 2,0);
// If user = leader then first = seconde
$user_first = $current_ranks[0]['user_id'];
if ($user_first == $user->data['user_id'])
$user_first = $current_ranks[1]['user_id'];
// If user = middle then middle = middle - 1
$user_middle = $current_ranks[$middle-1]['user_id'];
if ($user_middle == $user->data['user_id'])
$user_middle = $current_ranks[$middle]['user_id'];
// If user = last then last = last but one
$user_last = $current_ranks[$total_users - 1]['user_id'];
if ($user_last == $user->data['user_id'])
$user_last = $current_ranks[$total_users - 2]['user_id'];
if (user_is_member($user->data['user_id'], $season, $league))
{
// Take user, leader, middle and last
$user1 = $this->request->variable('user1', $user->data['user_id']);
$user2 = $this->request->variable('user2', $user_first);
$user3 = $this->request->variable('user3', $user_middle);
$user4 = $this->request->variable('user4', $user_last);
}
else
{
// Only take leader, middle and last
$user1 = $this->request->variable('user1', $user_first);
$user2 = $this->request->variable('user2', $user_middle);
$user3 = $this->request->variable('user3', $user_last);
$user4 = $this->request->variable('user4', 0);
}
// Add empty choice
$template->assign_block_vars('form_user2', array(
'S_USERNAME' => sprintf($user->lang['OPTION_USER']),
'S_USERID' => 0,
'S_SELECTEDID2' => '',
)
);
$template->assign_block_vars('form_user3', array(
'S_USERNAME' => sprintf($user->lang['OPTION_USER']),
'S_USERID' => 0,
'S_SELECTEDID3' => '',
)
);
$template->assign_block_vars('form_user4', array(
'S_USERNAME' => sprintf($user->lang['OPTION_USER']),
'S_USERID' => 0,
'S_SELECTEDID4' => '',
)
);
// Start select user
foreach ($current_ranks as $rank_user)
{
$curr_userid =$rank_user['user_id'];
if ($user1 == $curr_userid)
{
$selectid1 = ' selected="selected"';
$username = $rank_user['username'];
}
else
{
$selectid1 = '';
}
if ($user2 == $curr_userid)
{
$selectid2 = ' selected="selected"';
$username2 = $rank_user['username'];
}
else
{
$selectid2 = '';
}
if ($user3 == $curr_userid)
{
$selectid3 = ' selected="selected"';
$username3 = $rank_user['username'];
}
else
{
$selectid3 = '';
}
if ($user4 == $curr_userid)
{
$selectid4 = ' selected="selected"';
$username4 = $rank_user['username'];
}
else
{
$selectid4 = '';
}
if ($curr_userid != $user2 AND $curr_userid != $user3 AND $curr_userid != $user4)
$template->assign_block_vars('form_user1', array(
'S_USERNAME' => $rank_user['username'],
'S_USERID' => $curr_userid,
'S_SELECTEDID' => $selectid1));
if ($curr_userid != $user1 AND $curr_userid != $user3 AND $curr_userid != $user4)
$template->assign_block_vars('form_user2', array(
'S_USERNAME' => $rank_user['username'],
'S_USERID' => $curr_userid,
'S_SELECTEDID' => $selectid2));
if ($curr_userid != $user1 AND $curr_userid != $user2 AND $curr_userid != $user4)
$template->assign_block_vars('form_user3', array(
'S_USERNAME' => $rank_user['username'],
'S_USERID' => $curr_userid,
'S_SELECTEDID' => $selectid3));
if ($curr_userid != $user1 AND $curr_userid != $user2 AND $curr_userid != $user3)
$template->assign_block_vars('form_user4', array(
'S_USERNAME' => $rank_user['username'],
'S_USERID' => $curr_userid,
'S_SELECTEDID' => $selectid4));
}
$ranks_total_1 = '';
$ranks_dayl_1 = '';
$points_1 = '';
$sql = 'SELECT *
FROM ' . FOOTB_MY_CHART . "
WHERE season = $season
AND league = $league
AND matchday <= $matchday
AND user_id = $user1
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$points_1 = $points_1. $row['points']. ',';
$ranks_total_1 = $ranks_total_1. $row['rank_total']. ',';
$ranks_dayl_1 = $ranks_dayl_1. $row['rank']. ',';
}
$points_1 = substr($points_1, 0, strlen($points_1) - 1);
$ranks_total_1 = substr($ranks_total_1, 0, strlen($ranks_total_1) - 1);
$ranks_dayl_1 = substr($ranks_dayl_1, 0, strlen($ranks_dayl_1) - 1);
$db->sql_freeresult($result);
$ranks_total_2 = '';
$ranks_dayl_2 = '';
$points_2 = '';
if ($user2 != 0)
{
$sql = 'SELECT *
FROM ' . FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND matchday <= $matchday
AND user_id = $user2
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$points_2 = $points_2 . $row['points']. ',';
$ranks_total_2 = $ranks_total_2 . $row['rank_total']. ',';
$ranks_dayl_2 = $ranks_dayl_2 . $row['rank']. ',';
}
$points_2 = substr($points_2, 0, strlen($points_2) - 1);
$ranks_total_2 = substr($ranks_total_2, 0, strlen($ranks_total_2) - 1);
$ranks_dayl_2 = substr($ranks_dayl_2, 0, strlen($ranks_dayl_2) - 1);
$db->sql_freeresult($result);
}
$ranks_total_3 = '';
$ranks_dayl_3 = '';
$points_3 = '';
if ($user3 != 0)
{
$sql = 'SELECT *
FROM ' . FOOTB_MY_CHART . "
WHERE season = $season
AND league = $league
AND matchday <= $matchday
AND user_id = $user3
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$points_3 = $points_3. $row['points']. ',';
$ranks_total_3 = $ranks_total_3. $row['rank_total']. ',';
$ranks_dayl_3 = $ranks_dayl_3. $row['rank']. ',';
}
$points_3 = substr($points_3,0,strlen($points_3)-1);
$ranks_total_3 = substr($ranks_total_3,0,strlen($ranks_total_3)-1);
$ranks_dayl_3 = substr($ranks_dayl_3,0,strlen($ranks_dayl_3)-1);
$db->sql_freeresult($result);
}
$ranks_total_4 = '';
$ranks_dayl_4 = '';
$points_4 = '';
if ($user4 != 0)
{
$sql = 'SELECT *
FROM ' . FOOTB_MY_CHART . "
WHERE season = $season
AND league = $league
AND matchday <= $matchday
AND user_id = $user4
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$points_4 = $points_4. $row['points']. ',';
$sptagplatz = $row['rank'];
$ranks_total_4 = $ranks_total_4. $row['rank_total']. ',';
$ranks_dayl_4 = $ranks_dayl_4. $row['rank']. ',';
}
$points_4 = substr($points_4,0,strlen($points_4)-1);
$ranks_total_4 = substr($ranks_total_4,0,strlen($ranks_total_4)-1);
$ranks_dayl_4 = substr($ranks_dayl_4,0,strlen($ranks_dayl_4)-1);
$db->sql_freeresult($result);
}
$min = '';
$max = '';
if ($user1 != 0)
{
$sql = 'SELECT
MIN(points) As points_min,
MAX(points) As points_max
FROM ' . FOOTB_MY_CHART . "
WHERE season = $season
AND league = $league
AND matchday <= $matchday
GROUP BY matchday
ORDER BY matchday ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$min = $min. $row['points_min']. ',';
$max = $max. $row['points_max']. ',';
}
$min = substr($min,0,strlen($min)-1);
$max = substr($max,0,strlen($max)-1);
$db->sql_freeresult($result);
}
// Create and display charts
$chart= "<img src='". generate_board_url() . '/' . $this->football_root_path
. "includes/chart_rank.php?t=$total_users&amp;m=$matchday&amp;v1=$ranks_total_1&amp;v2=$ranks_total_2&amp;v3=$ranks_total_3&amp;v4=$ranks_total_4&amp;c="
. sprintf($user->lang['PLACE']) . "' alt='"
. sprintf($user->lang['CHART_TOTAL'])
. "'/>";
$template->assign_block_vars('chart_rank', array(
'CHARTIMAGE' => $chart,
)
);
$chart= "<img src='". generate_board_url() . '/' . $this->football_root_path
. "includes/chart_rank.php?t=$total_users&amp;m=$matchday&amp;v1=$ranks_dayl_1&amp;v2=$ranks_dayl_2&amp;v3=$ranks_dayl_3&amp;v4=$ranks_dayl_4&amp;c="
. sprintf($user->lang['PLACE']) . "' alt='"
. sprintf($user->lang['CHART_MATCHDAY'])
. "'/>";
$template->assign_block_vars('chart_matchtdays', array(
'CHARTIMAGE' => $chart,
)
);
$chart= "<img src='". generate_board_url() . '/' . $this->football_root_path
. "includes/chart_points.php?m=$matchday&amp;v1=$points_1&amp;v2=$points_2&amp;v3=$points_3&amp;v4=$points_4&amp;min=$min&amp;max=$max&amp;c="
. sprintf($user->lang['POINTS']) . ',' . sprintf($user->lang['BANDWIDTH']) . "' alt='"
. sprintf($user->lang['CHART_POINTS'])
. "'/>";
$template->assign_block_vars('chart_points', array(
'CHARTIMAGE' => $chart,
)
);
}
$sidename = sprintf($user->lang['MY_CHART']);
$template->assign_vars(array(
'S_DISPLAY_MY_CHART' => true,
'S_SIDENAME' => $sidename,
'S_DATA_MY_CHART' => $data,
'SEASON' => $season,
'LEAGUE' => $league,
'S_USER1' => $user1,
'S_USER2' => $user2,
'S_USER3' => $user3,
'S_USER4' => $user4,
'USERNAME1' => $username,
'USERNAME2' => $username2,
'USERNAME3' => $username3,
'USERNAME4' => $username4,
)
);
?>
+2 -9
View File
@@ -98,7 +98,6 @@ else
$split_after = $count_matches;
$splits = 1;
}
$db->sql_freeresult($result);
// Make sure $start is set to the last page if it exceeds the amount
if ($start < 0 || $start >= $total_users)
@@ -192,7 +191,7 @@ foreach ($matches AS $match)
$total = 0;
}
$bet_index++;
$total += $user_bet['points'];
$total += ($user_bet['points'] == '') ? 0 : $user_bet['points'];
if ($user_bet['status'] < 1 && !$config['football_view_bets'])
{
// hide bets
@@ -310,7 +309,7 @@ if ($count_matches > 0)
$total = 0;
}
$bet_index++;
$total += $user_bet['points'];
$total += ($user_bet['points'] == '') ? 0 : $user_bet['points'];
if ($user_bet['status'] < 1)
{
if ($user_bet['bet_home'] == '')
@@ -376,12 +375,6 @@ $sidename = sprintf($user->lang['MY_KOEFF']);
$template->assign_vars(array(
'S_DISPLAY_MY_KOEFF' => true,
'S_SIDENAME' => $sidename,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'my_chart', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['MY_CHART']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'stat_points', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['STAT_POINTS']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_MY_CHART']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_STAT_POINTS']),
'S_MATCHES_ON_MATCHDAY' => $matches_on_matchday,
'S_SPALTEN' => ($count_matches * 2) + 2,
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
+197 -203
View File
@@ -1,204 +1,198 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
if (!$user_sel)
{
if (user_is_member($user->data['user_id'], $season, $league))
{
$user_sel = $user->data['user_id'];
}
}
$username = '';
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
$data = false;
// Select user
$sql = 'SELECT DISTINCT
u.user_id,
u.username
FROM ' . FOOTB_BETS . ' AS b
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
WHERE season = $season
AND league = $league
ORDER BY LOWER(u.username) ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$data = true;
if ($user_sel == $row['user_id'] OR !$user_sel)
{
$selectid = ' selected="selected"';
$username = $row['username'];
$user_sel = $row['user_id'];
}
else
{
$selectid = '';
}
$template->assign_block_vars('form_user', array(
'S_USER' => $row['user_id'],
'S_USERNAME' => $row['username'],
'S_SELECTEDID' => $selectid,
)
);
}
$db->sql_freeresult($result);
$rank = 0;
// Select sum of users points group by team
$sql = "SELECT
t.*,
SUM(1) AS bets,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 > b.goals_guest, 1, 0),
IF(b.goals_home + 0 < b.goals_guest, 1, 0)
)
) AS win,
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 < b.goals_guest, 1, 0),
IF(b.goals_home + 0 > b.goals_guest, 1, 0)
)
) AS lost,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest=m.goals_guest),
0,1
)
)
)AS tendencies,
SUM(IF((b.goals_home = m.goals_home) AND (b.goals_guest=m.goals_guest),1,0))AS hits,
" . select_points('m',true) . "
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))
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no=m.match_no)
WHERE t.season = $season
AND t.league = $league
AND m.status IN (3,6)
AND b.user_id = $user_sel
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.matchday <= $matchday
GROUP BY t.team_id
ORDER BY points DESC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$template->assign_block_vars('points', array(
'ROW_CLASS' => $row_class,
'RANK' => $rank,
'LOGO' => $logo,
'TEAM' => $row['team_name_short'],
'COUNT' => $row['bets'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'DIRECTHITS' => $row['hits'],
'TENDENCIES' => $row['tendencies'],
'TOTAL' => $row['hits'] + $row['tendencies'],
'POINTS' => $row['points'],
)
);
}
$db->sql_freeresult($result);
$rank = 0;
// Select sum of all users points group by team
$sql = "SELECT
t.*,
SUM(1) AS bets,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 > b.goals_guest, 1, 0),
IF(b.goals_home + 0 < b.goals_guest, 1, 0)
)
) AS win,
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 < b.goals_guest, 1, 0),
IF(b.goals_home + 0 > b.goals_guest, 1, 0)
)
) AS lost,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
)
)AS tendencies,
SUM(IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0)) AS hits,
" . select_points('m',true) . "
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))
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no=m.match_no)
WHERE t.season = $season
AND t.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.status IN (3,6)
AND m.matchday <= $matchday
GROUP BY t.team_id
ORDER BY points DESC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$template->assign_block_vars('allpoints', array(
'ROW_CLASS' => $row_class,
'RANK' => $rank,
'LOGO' => $logo,
'TEAM' => $row['team_name_short'],
'COUNT' => $row['bets'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'DIRECTHITS' => $row['hits'],
'TENDENCIES' => $row['tendencies'],
'TOTAL' => $row['hits'] + $row['tendencies'],
'POINTS' => $row['points'],
)
);
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['MY_POINTS']);
$template->assign_vars(array(
'S_DISPLAY_MY_POINTS' => true,
'S_SIDENAME' => $sidename,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'my_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['MY_BETS']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'my_table', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['MY_TABLE']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_MY_BETS']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_MY_TABLE']),
'S_DATA_MY_POINTS' => $data,
'SEASON' => $season,
'LEAGUE' => $league,
'USERNAME' => $username,
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
if (!$user_sel)
{
if (user_is_member($user->data['user_id'], $season, $league))
{
$user_sel = $user->data['user_id'];
}
}
$username = '';
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
$data = false;
// Select user
$sql = 'SELECT DISTINCT
u.user_id,
u.username
FROM ' . FOOTB_BETS . ' AS b
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
WHERE season = $season
AND league = $league
ORDER BY LOWER(u.username) ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$data = true;
if ($user_sel == $row['user_id'] OR !$user_sel)
{
$selectid = ' selected="selected"';
$username = $row['username'];
$user_sel = $row['user_id'];
}
else
{
$selectid = '';
}
$template->assign_block_vars('form_user', array(
'S_USER' => $row['user_id'],
'S_USERNAME' => $row['username'],
'S_SELECTEDID' => $selectid,
)
);
}
$db->sql_freeresult($result);
$rank = 0;
// Select sum of users points group by team
$sql = "SELECT
t.*,
SUM(1) AS bets,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 > b.goals_guest, 1, 0),
IF(b.goals_home + 0 < b.goals_guest, 1, 0)
)
) AS win,
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 < b.goals_guest, 1, 0),
IF(b.goals_home + 0 > b.goals_guest, 1, 0)
)
) AS lost,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest=m.goals_guest),
0,1
)
)
)AS tendencies,
SUM(IF((b.goals_home = m.goals_home) AND (b.goals_guest=m.goals_guest),1,0))AS hits,
" . select_points('m',true) . "
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))
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no=m.match_no)
WHERE t.season = $season
AND t.league = $league
AND m.status IN (3,6)
AND b.user_id = $user_sel
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.matchday <= $matchday
GROUP BY t.team_id
ORDER BY points DESC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$template->assign_block_vars('points', array(
'ROW_CLASS' => $row_class,
'RANK' => $rank,
'LOGO' => $logo,
'TEAM' => $row['team_name_short'],
'COUNT' => $row['bets'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'DIRECTHITS' => $row['hits'],
'TENDENCIES' => $row['tendencies'],
'TOTAL' => $row['hits'] + $row['tendencies'],
'POINTS' => $row['points'],
)
);
}
$db->sql_freeresult($result);
$rank = 0;
// Select sum of all users points group by team
$sql = "SELECT
t.*,
SUM(1) AS bets,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 > b.goals_guest, 1, 0),
IF(b.goals_home + 0 < b.goals_guest, 1, 0)
)
) AS win,
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 < b.goals_guest, 1, 0),
IF(b.goals_home + 0 > b.goals_guest, 1, 0)
)
) AS lost,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
)
)AS tendencies,
SUM(IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0)) AS hits,
" . select_points('m',true) . "
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))
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no=m.match_no)
WHERE t.season = $season
AND t.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.status IN (3,6)
AND m.matchday <= $matchday
GROUP BY t.team_id
ORDER BY points DESC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$template->assign_block_vars('allpoints', array(
'ROW_CLASS' => $row_class,
'RANK' => $rank,
'LOGO' => $logo,
'TEAM' => $row['team_name_short'],
'COUNT' => $row['bets'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'DIRECTHITS' => $row['hits'],
'TENDENCIES' => $row['tendencies'],
'TOTAL' => $row['hits'] + $row['tendencies'],
'POINTS' => $row['points'],
)
);
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['MY_POINTS']);
$template->assign_vars(array(
'S_DISPLAY_MY_POINTS' => true,
'S_SIDENAME' => $sidename,
'S_DATA_MY_POINTS' => $data,
'SEASON' => $season,
'LEAGUE' => $league,
'USERNAME' => $username,
)
);
?>
+172 -178
View File
@@ -1,179 +1,173 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
if (!$user_sel)
{
if (user_is_member($user->data['user_id'], $season, $league))
{
$user_sel = $user->data['user_id'];
}
}
$username = '';
$data = false;
// select user
$sql = 'SELECT DISTINCT
u.user_id,
u.username
FROM ' . FOOTB_BETS . ' AS w
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = w.user_id)
WHERE season = $season
AND league = $league
ORDER BY LOWER(u.username) ASC ";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
if ($user_sel == $row['user_id'] OR !$user_sel)
{
$selectid = ' selected="selected"';
$username = $row['username'];
$user_sel = $row['user_id'];
}
else
{
$selectid = '';
}
$template->assign_block_vars('form_user', array(
'S_USER' => $row['user_id'],
'S_USERNAME' => $row['username'],
'S_SELECTEDID' => $selectid,
)
);
}
$db->sql_freeresult($result);
$rank = 0;
// Get ranks 1-3 of selected user
$sql = 'SELECT
season,
COUNT(matchday) AS matchdays,
SUM(points) AS points,
SUM(IF(rank = 1, 1, 0)) AS rank1,
SUM(IF(rank = 2, 1, 0)) AS rank2,
SUM(IF(rank = 3, 1, 0)) AS rank3
FROM ' . FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND user_id = $user_sel
GROUP BY user_id, season
ORDER BY season ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('myrank', array(
'ROW_CLASS' => $row_class,
'SEASON' => $row['season'],
'MATCHDAYS' => $row['matchdays'],
'POINTS' => $row['points'],
'RANK1' => $row['rank1'],
'RANK2' => $row['rank2'],
'RANK3' => $row['rank3'],
)
);
}
$db->sql_freeresult($result);
$rank = 0;
// Get all ranks 1-3 of selected user
$sql = 'SELECT
COUNT(matchday) AS matchdays,
rank
FROM ' . FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND user_id = $user_sel
GROUP BY user_id, rank
ORDER BY rank ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('season_ranks', array(
'ROW_CLASS' => $row_class,
'RANK' => $row['rank'],
'MATCHDAYS' => $row['matchdays'],
)
);
}
$db->sql_freeresult($result);
$rank = 0;
// Get ranks 1-3 of all users
$sql = 'SELECT
r.user_id,
u.username,
COUNT(r.matchday) AS matchdays,
SUM(r.points) AS points,
SUM(IF(r.rank =1, 1, 0)) AS rank1,
SUM(IF(r.rank =2, 1, 0)) AS rank2,
SUM(IF(r.rank =3, 1, 0)) AS rank3
FROM ' . FOOTB_RANKS . " AS r
LEFT JOIN " . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
WHERE r.season = $season
AND r.league = $league
GROUP BY r.user_id
ORDER BY rank1 DESC, rank2 DESC, rank3 DESC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$data = true;
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('allranks', array(
'ROW_CLASS' => $row_class,
'NAME' => $row['username'],
'MATCHDAYS' => $row['matchdays'],
'POINTS' => $row['points'],
'AVERAGE' => round($row['points'] / $row['matchdays'],1),
'RANK1' => $row['rank1'],
'RANK2' => $row['rank2'],
'RANK3' => $row['rank3'],
)
);
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['MY_RANK']);
$template->assign_vars(array(
'S_DISPLAY_MY_RANK' => true,
'S_MATCHDAY_HIDE' => true,
'S_SIDENAME' => $sidename,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'my_table', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['MY_TABLE']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'my_chart', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['MY_CHART']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_MY_TABLE']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_MY_CHART']),
'S_DATA_MY_RANK' => $data,
'SEASON' => $season,
'LEAGUE' => $league,
'USERNAME' => $username,
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
if (!$user_sel)
{
if (user_is_member($user->data['user_id'], $season, $league))
{
$user_sel = $user->data['user_id'];
}
}
$username = '';
$data = false;
// select user
$sql = 'SELECT DISTINCT
u.user_id,
u.username
FROM ' . FOOTB_BETS . ' AS w
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = w.user_id)
WHERE season = $season
AND league = $league
ORDER BY LOWER(u.username) ASC ";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
if ($user_sel == $row['user_id'] OR !$user_sel)
{
$selectid = ' selected="selected"';
$username = $row['username'];
$user_sel = $row['user_id'];
}
else
{
$selectid = '';
}
$template->assign_block_vars('form_user', array(
'S_USER' => $row['user_id'],
'S_USERNAME' => $row['username'],
'S_SELECTEDID' => $selectid,
)
);
}
$db->sql_freeresult($result);
$rank = 0;
// Get ranks 1-3 of selected user
$sql = 'SELECT
season,
COUNT(matchday) AS matchdays,
SUM(points) AS points,
SUM(IF(rank = 1, 1, 0)) AS rank1,
SUM(IF(rank = 2, 1, 0)) AS rank2,
SUM(IF(rank = 3, 1, 0)) AS rank3
FROM ' . FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND user_id = $user_sel
GROUP BY user_id, season
ORDER BY season ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('myrank', array(
'ROW_CLASS' => $row_class,
'SEASON' => $row['season'],
'MATCHDAYS' => $row['matchdays'],
'POINTS' => $row['points'],
'RANK1' => $row['rank1'],
'RANK2' => $row['rank2'],
'RANK3' => $row['rank3'],
)
);
}
$db->sql_freeresult($result);
$rank = 0;
// Get all ranks 1-3 of selected user
$sql = 'SELECT
COUNT(matchday) AS matchdays,
rank
FROM ' . FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND user_id = $user_sel
GROUP BY user_id, rank
ORDER BY rank ASC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('season_ranks', array(
'ROW_CLASS' => $row_class,
'RANK' => $row['rank'],
'MATCHDAYS' => $row['matchdays'],
)
);
}
$db->sql_freeresult($result);
$rank = 0;
// Get ranks 1-3 of all users
$sql = 'SELECT
r.user_id,
u.username,
COUNT(r.matchday) AS matchdays,
SUM(r.points) AS points,
SUM(IF(r.rank =1, 1, 0)) AS rank1,
SUM(IF(r.rank =2, 1, 0)) AS rank2,
SUM(IF(r.rank =3, 1, 0)) AS rank3
FROM ' . FOOTB_RANKS . " AS r
LEFT JOIN " . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
WHERE r.season = $season
AND r.league = $league
GROUP BY r.user_id
ORDER BY rank1 DESC, rank2 DESC, rank3 DESC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$data = true;
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('allranks', array(
'ROW_CLASS' => $row_class,
'NAME' => $row['username'],
'MATCHDAYS' => $row['matchdays'],
'POINTS' => $row['points'],
'AVERAGE' => round($row['points'] / $row['matchdays'],1),
'RANK1' => $row['rank1'],
'RANK2' => $row['rank2'],
'RANK3' => $row['rank3'],
)
);
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['MY_RANK']);
$template->assign_vars(array(
'S_DISPLAY_MY_RANK' => true,
'S_MATCHDAY_HIDE' => true,
'S_SIDENAME' => $sidename,
'S_DATA_MY_RANK' => $data,
'SEASON' => $season,
'LEAGUE' => $league,
'USERNAME' => $username,
)
);
?>
+429 -433
View File
@@ -1,434 +1,430 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
if (!$user_sel)
{
if (user_is_member($user->data['user_id'], $season, $league))
{
$user_sel = $user->data['user_id'];
}
}
$username = '';
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
// select user
$sql = 'SELECT DISTINCT
u.user_id,
u.username
FROM ' . FOOTB_BETS . ' AS b
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
WHERE season = $season
AND league = $league
ORDER BY LOWER(u.username) ASC";
$result = $db->sql_query($sql);
if ($user_sel == 900)
{
$selectid = ' selected="selected"';
$username = 'Alle';
$user_sel = 900;
$where_user = "";
}
else
{
$selectid = '';
$where_user = "b.user_id = $user_sel AND ";
}
$template->assign_block_vars('form_user', array(
'S_USER' => 900,
'S_USERNAME' => 'Alle',
'S_SELECTEDID' => $selectid,
)
);
while($row = $db->sql_fetchrow($result))
{
if ($user_sel == $row['user_id'] OR !$user_sel)
{
$selectid = ' selected="selected"';
$username = $row['username'];
$user_sel = $row['user_id'];
}
else
{
$selectid = '';
}
$template->assign_block_vars('form_user', array(
'S_USER' => $row['user_id'],
'S_USERNAME' => $row['username'],
'S_SELECTEDID' => $selectid,
)
);
}
$db->sql_freeresult($result);
$data_table = false;
$data_form = false;
if ($matchday > 5)
{
$form_from = $matchday - 5;
}
else
{
$form_from = 1;
}
$sql = '
SELECT *
FROM ' . FOOTB_LEAGUES . "
WHERE season = $season
AND league = $league";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$league_type = $row['league_type'];
$db->sql_freeresult($result);
$text_form = sprintf($user->lang['TABLE_FORM_FROM'], $form_from);
$rank = 0;
// Select table on selected user bets
$sql = 'SELECT
t.*,
SUM(1) AS matches,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 > b.goals_guest, 1, 0),
IF(b.goals_home + 0 < b.goals_guest, 1, 0)
)
) AS win,
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 < b.goals_guest, 1, 0),
IF(b.goals_home + 0 > b.goals_guest, 1, 0)
)
) AS lost,
SUM(IF(m.team_id_home = t.team_id,
IF(b.goals_home + 0 > b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0)),
IF(b.goals_home + 0 < b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0))
)
) AS points,
SUM(IF(m.team_id_home = t.team_id,
IF(m.goals_home + 0 > m.goals_guest, 3, IF(m.goals_home = m.goals_guest, 1, 0)),
IF(m.goals_home + 0 < m.goals_guest, 3, IF(m.goals_home = m.goals_guest, 1, 0))
)
) AS realpoints,
SUM(IF(m.team_id_home = t.team_id, b.goals_home - b.goals_guest, b.goals_guest - b.goals_home)) AS goals_diff,
SUM(IF(m.team_id_home = t.team_id, b.goals_home, b.goals_guest)) AS goals,
SUM(IF(m.team_id_home = t.team_id, b.goals_guest, b.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)
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no = m.match_no)
WHERE $where_user
t.season = $season
AND t.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.matchday <= $matchday
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC";
$result = $db->sql_query($sql);
$lastGroup = '';
$sumdiff = 0;
while($row = $db->sql_fetchrow($result))
{
if ($lastGroup != $row['group_id'])
{
$lastGroup = $row['group_id'];
$rank = 0;
$template->assign_block_vars('total', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$data_table = true;
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$pdiff = $row['points'] - $row['realpoints'];
if ($pdiff >= 0)
{
$sumdiff += $pdiff;
$pdiff = ' (+' . $pdiff . ')';
}
else
{
$sumdiff -= $pdiff;
$pdiff = ' (' . $pdiff . ')';
}
if ($user_sel == 900)
{
$pdiff = '';
}
$template->assign_block_vars('total', array(
'RANK' => $rank . '.',
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $row['team_id'], 'mode' => 'played')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'] . $pdiff,
)
);
}
}
$db->sql_freeresult($result);
$rank = 0;
// Select formtable on selected user bets
$sql = 'SELECT
t.*,
SUM(1) AS matches,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 > b.goals_guest, 1, 0),
IF(b.goals_home + 0 < b.goals_guest, 1, 0)
)
) AS win,
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 < b.goals_guest, 1, 0),
IF(b.goals_home + 0 > b.goals_guest, 1, 0)
)
) AS lost,
SUM(IF(m.team_id_home = t.team_id,
IF(b.goals_home + 0 > b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0)),
IF(b.goals_home + 0 < b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0))
)
) AS points,
SUM(IF(m.team_id_home = t.team_id, b.goals_home - b.goals_guest, b.goals_guest - b.goals_home)) AS goals_diff,
SUM(IF(m.team_id_home = t.team_id, b.goals_home, b.goals_guest)) AS goals,
SUM(IF(m.team_id_home = t.team_id, b.goals_guest, b.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)
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no = m.match_no)
WHERE $where_user
t.season = $season
AND t.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.matchday >= $form_from
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC";
$result = $db->sql_query($sql);
$lastGroup = '';
while($row = $db->sql_fetchrow($result))
{
$data_form = true;
if ($lastGroup != $row['group_id'])
{
$lastGroup = $row['group_id'];
$rank = 0;
$template->assign_block_vars('form', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$template->assign_block_vars('form', array(
'RANK' => $rank . '.',
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $row['team_id'], 'mode' => 'rest')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
)
);
}
}
$db->sql_freeresult($result);
$rank = 0;
// Select home-table on selected user bets
$sql = 'SELECT
t.*,
SUM(1) AS matches,
SUM(IF(b.goals_home + 0 > b.goals_guest, 1, 0)) AS win,
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
SUM(IF(b.goals_home + 0 < b.goals_guest, 1, 0)) AS lost,
SUM(IF(b.goals_home + 0 > b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0))) AS points,
SUM(b.goals_home - b.goals_guest) AS goals_diff,
SUM(b.goals_home) AS goals,
SUM(b.goals_guest) 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 AND m.group_id = t.group_id)
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no = m.match_no)
WHERE $where_user
t.season = $season
AND t.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.matchday <= $matchday
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC";
$result = $db->sql_query($sql);
$lastGroup = '';
while($row = $db->sql_fetchrow($result))
{
if ($lastGroup != $row['group_id'])
{
$lastGroup = $row['group_id'];
$rank = 0;
$template->assign_block_vars('home', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$template->assign_block_vars('home', array(
'RANK' => $rank . '.',
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $row['team_id'], 'mode' => 'home')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
)
);
}
}
$db->sql_freeresult($result);
$rank = 0;
// Select away-table on selected user bets
$sql = 'SELECT
t.*,
SUM(1) AS matches,
SUM(IF(b.goals_home + 0 < b.goals_guest, 1, 0)) AS win,
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
SUM(IF(b.goals_home + 0 > b.goals_guest, 1, 0)) AS lost,
SUM(IF(b.goals_home + 0 < b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0))) AS points,
SUM(b.goals_guest - b.goals_home) AS goals_diff,
SUM(b.goals_guest) AS goals,
SUM(b.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_guest = t.team_id AND m.group_id = t.group_id)
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no = m.match_no)
WHERE $where_user
t.season = $season
AND t.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.matchday <= $matchday
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC";
$result = $db->sql_query($sql);
$lastGroup = '';
while($row = $db->sql_fetchrow($result))
{
if ($lastGroup != $row['group_id'])
{
$lastGroup = $row['group_id'];
$rank = 0;
$template->assign_block_vars('away', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$template->assign_block_vars('away', array(
'RANK' => $rank . '.',
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $row['team_id'], 'mode' => 'away')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
)
);
}
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['MY_TABLE']);
$template->assign_vars(array(
'S_DISPLAY_MY_TABLE' => true,
'S_SIDENAME' => $sidename,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'my_points', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['MY_TABLE']),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['MY_POINTS']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'my_rank', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['MY_TABLE']),
'RIGHT_LINK' => sprintf($user->lang['MY_RANK']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_MY_POINTS']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_MY_RANKS']),
'S_DATA_MY_TABLE' => $data_table,
'S_DATA_FORM' => $data_form,
'SEASON' => $season,
'LEAGUE' => $league,
'TEXT_FORM' => $text_form,
'S_PDIFF' => $sumdiff,
'USERNAME' => $username,
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
if (!$user_sel)
{
if (user_is_member($user->data['user_id'], $season, $league))
{
$user_sel = $user->data['user_id'];
}
}
$username = '';
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
// select user
$sql = 'SELECT DISTINCT
u.user_id,
u.username
FROM ' . FOOTB_BETS . ' AS b
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = b.user_id)
WHERE season = $season
AND league = $league
ORDER BY LOWER(u.username) ASC";
$result = $db->sql_query($sql);
if ($user_sel == 900)
{
$selectid = ' selected="selected"';
$username = 'Alle';
$user_sel = 900;
$where_user = "";
}
else
{
$selectid = '';
$where_user = "b.user_id = $user_sel AND ";
}
$template->assign_block_vars('form_user', array(
'S_USER' => 900,
'S_USERNAME' => 'Alle',
'S_SELECTEDID' => $selectid,
)
);
while($row = $db->sql_fetchrow($result))
{
if ($user_sel == $row['user_id'] OR !$user_sel)
{
$selectid = ' selected="selected"';
$username = $row['username'];
$user_sel = $row['user_id'];
}
else
{
$selectid = '';
}
$template->assign_block_vars('form_user', array(
'S_USER' => $row['user_id'],
'S_USERNAME' => $row['username'],
'S_SELECTEDID' => $selectid,
)
);
}
$db->sql_freeresult($result);
$data_table = false;
$data_form = false;
if ($matchday > 5)
{
$form_from = $matchday - 5;
}
else
{
$form_from = 1;
}
$sql = '
SELECT *
FROM ' . FOOTB_LEAGUES . "
WHERE season = $season
AND league = $league";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$league_type = $row['league_type'];
$db->sql_freeresult($result);
$text_form = sprintf($user->lang['TABLE_FORM_FROM'], $form_from);
$rank = 0;
// Select table on selected user bets
$sql = 'SELECT
t.*,
SUM(1) AS matches,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 > b.goals_guest, 1, 0),
IF(b.goals_home + 0 < b.goals_guest, 1, 0)
)
) AS win,
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 < b.goals_guest, 1, 0),
IF(b.goals_home + 0 > b.goals_guest, 1, 0)
)
) AS lost,
SUM(IF(m.team_id_home = t.team_id,
IF(b.goals_home + 0 > b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0)),
IF(b.goals_home + 0 < b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0))
)
) AS points,
SUM(IF(m.team_id_home = t.team_id,
IF(m.goals_home + 0 > m.goals_guest, 3, IF(m.goals_home = m.goals_guest, 1, 0)),
IF(m.goals_home + 0 < m.goals_guest, 3, IF(m.goals_home = m.goals_guest, 1, 0))
)
) AS realpoints,
SUM(IF(m.team_id_home = t.team_id, b.goals_home - b.goals_guest, b.goals_guest - b.goals_home)) AS goals_diff,
SUM(IF(m.team_id_home = t.team_id, b.goals_home, b.goals_guest)) AS goals,
SUM(IF(m.team_id_home = t.team_id, b.goals_guest, b.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)
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no = m.match_no)
WHERE $where_user
t.season = $season
AND t.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.matchday <= $matchday
AND m.show_table = 0
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC";
$result = $db->sql_query($sql);
$lastGroup = '';
$sumdiff = 0;
while($row = $db->sql_fetchrow($result))
{
if ($lastGroup != $row['group_id'])
{
$lastGroup = $row['group_id'];
$rank = 0;
$template->assign_block_vars('total', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$data_table = true;
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$pdiff = $row['points'] - $row['realpoints'];
if ($pdiff >= 0)
{
$sumdiff += $pdiff;
$pdiff = ' (+' . $pdiff . ')';
}
else
{
$sumdiff -= $pdiff;
$pdiff = ' (' . $pdiff . ')';
}
if ($user_sel == 900)
{
$pdiff = '';
}
$template->assign_block_vars('total', array(
'RANK' => $rank . '.',
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $row['team_id'], 'mode' => 'played')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'] . $pdiff,
)
);
}
}
$db->sql_freeresult($result);
$rank = 0;
// Select formtable on selected user bets
$sql = 'SELECT
t.*,
SUM(1) AS matches,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 > b.goals_guest, 1, 0),
IF(b.goals_home + 0 < b.goals_guest, 1, 0)
)
) AS win,
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
SUM(IF((m.team_id_home = t.team_id),
IF(b.goals_home + 0 < b.goals_guest, 1, 0),
IF(b.goals_home + 0 > b.goals_guest, 1, 0)
)
) AS lost,
SUM(IF(m.team_id_home = t.team_id,
IF(b.goals_home + 0 > b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0)),
IF(b.goals_home + 0 < b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0))
)
) AS points,
SUM(IF(m.team_id_home = t.team_id, b.goals_home - b.goals_guest, b.goals_guest - b.goals_home)) AS goals_diff,
SUM(IF(m.team_id_home = t.team_id, b.goals_home, b.goals_guest)) AS goals,
SUM(IF(m.team_id_home = t.team_id, b.goals_guest, b.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)
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no = m.match_no)
WHERE $where_user
t.season = $season
AND t.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.matchday >= $form_from
AND m.show_table = 0
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC";
$result = $db->sql_query($sql);
$lastGroup = '';
while($row = $db->sql_fetchrow($result))
{
$data_form = true;
if ($lastGroup != $row['group_id'])
{
$lastGroup = $row['group_id'];
$rank = 0;
$template->assign_block_vars('form', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$template->assign_block_vars('form', array(
'RANK' => $rank . '.',
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $row['team_id'], 'mode' => 'rest')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
)
);
}
}
$db->sql_freeresult($result);
$rank = 0;
// Select home-table on selected user bets
$sql = 'SELECT
t.*,
SUM(1) AS matches,
SUM(IF(b.goals_home + 0 > b.goals_guest, 1, 0)) AS win,
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
SUM(IF(b.goals_home + 0 < b.goals_guest, 1, 0)) AS lost,
SUM(IF(b.goals_home + 0 > b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0))) AS points,
SUM(b.goals_home - b.goals_guest) AS goals_diff,
SUM(b.goals_home) AS goals,
SUM(b.goals_guest) 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 AND m.group_id = t.group_id)
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no = m.match_no)
WHERE $where_user
t.season = $season
AND t.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.matchday <= $matchday
AND m.show_table = 0
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC";
$result = $db->sql_query($sql);
$lastGroup = '';
while($row = $db->sql_fetchrow($result))
{
if ($lastGroup != $row['group_id'])
{
$lastGroup = $row['group_id'];
$rank = 0;
$template->assign_block_vars('home', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$template->assign_block_vars('home', array(
'RANK' => $rank . '.',
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $row['team_id'], 'mode' => 'home')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
)
);
}
}
$db->sql_freeresult($result);
$rank = 0;
// Select away-table on selected user bets
$sql = 'SELECT
t.*,
SUM(1) AS matches,
SUM(IF(b.goals_home + 0 < b.goals_guest, 1, 0)) AS win,
SUM(IF(b.goals_home = b.goals_guest, 1, 0)) AS draw,
SUM(IF(b.goals_home + 0 > b.goals_guest, 1, 0)) AS lost,
SUM(IF(b.goals_home + 0 < b.goals_guest, 3, IF(b.goals_home = b.goals_guest, 1, 0))) AS points,
SUM(b.goals_guest - b.goals_home) AS goals_diff,
SUM(b.goals_guest) AS goals,
SUM(b.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_guest = t.team_id AND m.group_id = t.group_id)
LEFT JOIN ' . FOOTB_BETS . " AS b ON (b.season = t.season AND b.league = t.league AND b.match_no = m.match_no)
WHERE $where_user
t.season = $season
AND t.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND m.matchday <= $matchday
AND m.show_table = 0
GROUP BY t.team_id
ORDER BY t.group_id ASC, points DESC, goals_diff DESC, goals DESC";
$result = $db->sql_query($sql);
$lastGroup = '';
while($row = $db->sql_fetchrow($result))
{
if ($lastGroup != $row['group_id'])
{
$lastGroup = $row['group_id'];
$rank = 0;
$template->assign_block_vars('away', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$template->assign_block_vars('away', array(
'RANK' => $rank . '.',
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $row['team_id'], 'mode' => 'away')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
)
);
}
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['MY_TABLE']);
$template->assign_vars(array(
'S_DISPLAY_MY_TABLE' => true,
'S_SIDENAME' => $sidename,
'S_DATA_MY_TABLE' => $data_table,
'S_DATA_FORM' => $data_form,
'SEASON' => $season,
'LEAGUE' => $league,
'TEXT_FORM' => $text_form,
'S_PDIFF' => $sumdiff,
'USERNAME' => $username,
)
);
?>
+204 -210
View File
@@ -1,211 +1,205 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data_odds = false;
$matchnumber = 0;
$lang_dates = $user->lang['datetime'];
$sql = "SELECT
m.league,
m.match_no,
CONCAT(
CASE DATE_FORMAT(m.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(m.match_datetime,' %d.%m. %H:%i')
) AS match_time,
t1.team_symbol AS home_symbol,
t2.team_symbol AS guest_symbol,
t1.team_name_short AS home_name,
t2.team_name_short AS guest_name,
t1.team_id AS home_id,
t2.team_id AS guest_id,
m.goals_home,
m.goals_guest,
m.goals_overtime_home AS kogoals_home,
m.goals_overtime_guest AS kogoals_guest,
m.ko_match,
m.group_id,
m.formula_home,
m.formula_guest,
m.odd_1,
m.odd_x,
m.odd_2,
m.trend 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.matchday = $matchday
ORDER BY m.match_datetime ASC, m.match_no ASC";
$result = $db->sql_query($sql);
$rows = $db->sql_fetchrowset($result);
$league_info = league_info($season, $league);
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
//while($row = $db->sql_fetchrow($result))
foreach ($rows as $row)
{
$data_odds = true;
$matchnumber++ ;
$row_class = (!($matchnumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if (0 == $row['home_id'])
{
$home_info = get_team($season, $league, $row['match_no'], 'team_id_home', $row['formula_home']);
$home_in_array = explode("#",$home_info);
$homelogo = $home_in_array[0];
$homeid = $home_in_array[1];
$homename = $home_in_array[2];
}
else
{
$homelogo = $row['home_symbol'];
$homeid = $row['home_id'];
$homename = $row['home_name'];
}
if (0 == $row['guest_id'])
{
$guest_info = get_team($season, $league, $row['match_no'], 'team_id_guest', $row['formula_guest']);
$guest_in_array = explode("#",$guest_info);
$guestlogo = $guest_in_array[0];
$guestid = $guest_in_array[1];
$guestname = $guest_in_array[2];
}
else
{
$guestlogo = $row['guest_symbol'];
$guestid = $row['guest_id'];
$guestname = $row['guest_name'];
}
if ($homelogo <> '')
{
$logoH = "<img src=\"" . $ext_path . 'images/flags/' . $homelogo . "\" alt=\"" . $homelogo . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logoH = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
if ($guestlogo <> '')
{
$logoG = "<img src=\"" . $ext_path . 'images/flags/' . $guestlogo . "\" alt=\"" . $guestlogo . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logoG = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
if ($row['ko_match'])
{
$display_ko = true;
$ko_match = true;
}
else
{
$ko_match = false;
}
if ($row['group_id'] == '')
{
$group_id = '&nbsp;';
}
else
{
$display_group = true;
$group_id = $row['group_id'];
}
$edit_match = false;
$goals_home = ($row['goals_home'] == '') ? '&nbsp;' : $row['goals_home'];
$goals_guest = ($row['goals_guest'] == '') ? '&nbsp;' : $row['goals_guest'];
$kogoals_home = ($row['kogoals_home'] == '') ? '&nbsp;' : $row['kogoals_home'];
$kogoals_guest = ($row['kogoals_guest'] == '') ? '&nbsp;' : $row['kogoals_guest'];
$template->assign_block_vars('odds', array(
'ROW_CLASS' => $row_class,
'MATCH_NUMBER' => $row['match_no'],
'MATCHDAY' => $matchday,
'MATCH_TIME' => $row['match_time'],
'GROUP' => $group_id,
'HOME_ID' => $homeid,
'GUEST_ID' => $guestid,
'LOGO_HOME' => $logoH,
'LOGO_GUEST' => $logoG,
'HOME_NAME' => $homename,
'GUEST_NAME' => $guestname,
'U_PLAN_HOME' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $homeid, 'mode' => 'all')),
'U_PLAN_GUEST' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $guestid, 'mode' => 'all')),
'GOALS_HOME' => $goals_home,
'GOALS_GUEST' => $goals_guest,
'COLOR_STYLE' => '',
'KOGOALS_HOME' => $kogoals_home,
'KOGOALS_GUEST' => $kogoals_guest,
'S_KO_MATCH' => $ko_match,
'TREND' => $row['trend'],
'U_MATCH_STATS' => $this->helper->route('football_football_popup', array('popside' => 'hist_popup', 's' => $season, 'l' => $league,
'hid' => $homeid, 'gid' => $guestid, 'm' => $matchday,
'mn' => $row['match_no'], 'gr' => $row['group_id'])),
'ODD_1' => $row['odd_1'],
'ODD_X' => $row['odd_x'],
'ODD_2' => $row['odd_2'],
)
);
}
$db->sql_freeresult($result);
$sidename = 'Chancen';
switch ($league_info['bet_ko_type'])
{
case BET_KO_90:
$result_explain = sprintf($user->lang['MIN90']);
$label_finalresult = sprintf($user->lang['EXTRATIME_SHORT']) . '/' . sprintf($user->lang['PENALTY_SHORT']);
break;
case BET_KO_EXTRATIME:
$result_explain = sprintf($user->lang['EXTRATIME_SHORT']);
$label_finalresult = sprintf($user->lang['PENALTY']);
break;
case BET_KO_PENALTY:
$result_explain = sprintf($user->lang['PENALTY']);
$display_ko = false;
break;
default:
$result_explain = sprintf($user->lang['MIN90']);
$label_finalresult = sprintf($user->lang['EXTRATIME_SHORT']) . '/' . sprintf($user->lang['PENALTY_SHORT']);
break;
}
$template->assign_vars(array(
'S_DISPLAY_ODDS' => true,
'S_SIDENAME' => $sidename,
'RESULT_EXPLAIN' => $result_explain,
'LABEL_FINALRESULT' => $label_finalresult,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['BET']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'table', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['TABLE']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_BET']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_TABLE']),
'S_DATA_ODDS' => $data_odds,
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data_odds = false;
$matchnumber = 0;
$lang_dates = $user->lang['datetime'];
$sql = "SELECT
m.league,
m.match_no,
CONCAT(
CASE DATE_FORMAT(m.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(m.match_datetime,' %d.%m. %H:%i')
) AS match_time,
t1.team_symbol AS home_symbol,
t2.team_symbol AS guest_symbol,
t1.team_name_short AS home_name,
t2.team_name_short AS guest_name,
t1.team_id AS home_id,
t2.team_id AS guest_id,
m.goals_home,
m.goals_guest,
m.goals_overtime_home AS kogoals_home,
m.goals_overtime_guest AS kogoals_guest,
m.ko_match,
m.group_id,
m.formula_home,
m.formula_guest,
m.odd_1,
m.odd_x,
m.odd_2,
m.trend 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.matchday = $matchday
ORDER BY m.match_datetime ASC, m.match_no ASC";
$result = $db->sql_query($sql);
$rows = $db->sql_fetchrowset($result);
$league_info = league_info($season, $league);
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
//while($row = $db->sql_fetchrow($result))
foreach ($rows as $row)
{
$data_odds = true;
$matchnumber++ ;
$row_class = (!($matchnumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if (0 == $row['home_id'])
{
$home_info = get_team($season, $league, $row['match_no'], 'team_id_home', $row['formula_home']);
$home_in_array = explode("#",$home_info);
$homelogo = $home_in_array[0];
$homeid = $home_in_array[1];
$homename = $home_in_array[2];
}
else
{
$homelogo = $row['home_symbol'];
$homeid = $row['home_id'];
$homename = $row['home_name'];
}
if (0 == $row['guest_id'])
{
$guest_info = get_team($season, $league, $row['match_no'], 'team_id_guest', $row['formula_guest']);
$guest_in_array = explode("#",$guest_info);
$guestlogo = $guest_in_array[0];
$guestid = $guest_in_array[1];
$guestname = $guest_in_array[2];
}
else
{
$guestlogo = $row['guest_symbol'];
$guestid = $row['guest_id'];
$guestname = $row['guest_name'];
}
if ($homelogo <> '')
{
$logoH = "<img src=\"" . $ext_path . 'images/flags/' . $homelogo . "\" alt=\"" . $homelogo . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logoH = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
if ($guestlogo <> '')
{
$logoG = "<img src=\"" . $ext_path . 'images/flags/' . $guestlogo . "\" alt=\"" . $guestlogo . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logoG = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
if ($row['ko_match'])
{
$display_ko = true;
$ko_match = true;
}
else
{
$ko_match = false;
}
if ($row['group_id'] == '')
{
$group_id = '&nbsp;';
}
else
{
$display_group = true;
$group_id = $row['group_id'];
}
$edit_match = false;
$goals_home = ($row['goals_home'] == '') ? '&nbsp;' : $row['goals_home'];
$goals_guest = ($row['goals_guest'] == '') ? '&nbsp;' : $row['goals_guest'];
$kogoals_home = ($row['kogoals_home'] == '') ? '&nbsp;' : $row['kogoals_home'];
$kogoals_guest = ($row['kogoals_guest'] == '') ? '&nbsp;' : $row['kogoals_guest'];
$template->assign_block_vars('odds', array(
'ROW_CLASS' => $row_class,
'MATCH_NUMBER' => $row['match_no'],
'MATCHDAY' => $matchday,
'MATCH_TIME' => $row['match_time'],
'GROUP' => $group_id,
'HOME_ID' => $homeid,
'GUEST_ID' => $guestid,
'LOGO_HOME' => $logoH,
'LOGO_GUEST' => $logoG,
'HOME_NAME' => $homename,
'GUEST_NAME' => $guestname,
'U_PLAN_HOME' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $homeid, 'mode' => 'all')),
'U_PLAN_GUEST' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $guestid, 'mode' => 'all')),
'GOALS_HOME' => $goals_home,
'GOALS_GUEST' => $goals_guest,
'COLOR_STYLE' => '',
'KOGOALS_HOME' => $kogoals_home,
'KOGOALS_GUEST' => $kogoals_guest,
'S_KO_MATCH' => $ko_match,
'TREND' => $row['trend'],
'U_MATCH_STATS' => $this->helper->route('football_football_popup', array('popside' => 'hist_popup', 's' => $season, 'l' => $league,
'hid' => $homeid, 'gid' => $guestid, 'm' => $matchday,
'mn' => $row['match_no'], 'gr' => $row['group_id'])),
'ODD_1' => $row['odd_1'],
'ODD_X' => $row['odd_x'],
'ODD_2' => $row['odd_2'],
)
);
}
$db->sql_freeresult($result);
$sidename = 'Chancen';
switch ($league_info['bet_ko_type'])
{
case BET_KO_90:
$result_explain = sprintf($user->lang['MIN90']);
$label_finalresult = sprintf($user->lang['EXTRATIME_SHORT']) . '/' . sprintf($user->lang['PENALTY_SHORT']);
break;
case BET_KO_EXTRATIME:
$result_explain = sprintf($user->lang['EXTRATIME_SHORT']);
$label_finalresult = sprintf($user->lang['PENALTY']);
break;
case BET_KO_PENALTY:
$result_explain = sprintf($user->lang['PENALTY']);
$display_ko = false;
break;
default:
$result_explain = sprintf($user->lang['MIN90']);
$label_finalresult = sprintf($user->lang['EXTRATIME_SHORT']) . '/' . sprintf($user->lang['PENALTY_SHORT']);
break;
}
$template->assign_vars(array(
'S_DISPLAY_ODDS' => true,
'S_SIDENAME' => $sidename,
'RESULT_EXPLAIN' => $result_explain,
'LABEL_FINALRESULT' => $label_finalresult,
'S_DATA_ODDS' => $data_odds,
)
);
?>
+12 -3
View File
@@ -12,6 +12,15 @@ if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
exit;
}
if ($league > 50)
{
$league_corr = $league - 50;
}
else
{
$league_corr = $league;
}
if ($league <> 0)
{
$data_rank_matchday = false;
@@ -26,7 +35,7 @@ if ($league <> 0)
FROM " . FOOTB_RANKS . ' AS r
LEFT Join ' . USERS_TABLE . " AS u ON (r.user_id = u.user_id)
WHERE r.season = $season
AND r.league = $league
AND r.league = $league_corr
AND r.matchday = $matchday
AND r.status IN (2,3)
ORDER BY rank ASC, LOWER(u.username) ASC";
@@ -50,7 +59,7 @@ if ($league <> 0)
'ROW_CLASS' => $row_class,
'USERID' => $row['user_id'],
'USERNAME' => $row['username'],
'U_BET_USER' => $this->helper->route('football_football_popup', array('popside' => 'bet_popup', 's' => $season, 'l' => $league,
'U_BET_USER' => $this->helper->route('football_football_popup', array('popside' => 'bet_popup', 's' => $season, 'l' => $league_corr,
'm' => $matchday, 'u' => $row['user_id'])),
'POINTS' => $row['points'],
'COLOR_STYLE' => $colorstyle,
@@ -60,7 +69,7 @@ if ($league <> 0)
}
}
$db->sql_freeresult($result);
$league_info = league_info($season, $league);
$league_info = league_info($season, $league_corr);
$template->assign_vars(array(
'S_DISPLAY_RANK_MATCHDAY' => true,
+260 -269
View File
@@ -1,270 +1,261 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$start = $this->request->variable('start', 0);
$win_user_most_hits = array();
$win_user_most_hits_away = array();
$season_wins = array();
$win_user_most_hits = win_user_most_hits($season, $league, $matchday);
$win_user_most_hits_away = win_user_most_hits_away($season, $league, $matchday);
// Statistics of matchday
$sql = "SELECT
b.user_id,
COUNT(b.match_no) AS matches,
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS bets,
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 hits,
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '',
IF((m.goals_home <= m.goals_guest),
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0),
0
),
0
)
) AS hits02,
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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
),
0
)
) AS tendency
FROM " . FOOTB_BETS . ' AS b
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
WHERE b.season = $season
AND b.league = $league
AND m.status IN (2,3)
AND m.matchday = $matchday
GROUP BY user_id";
$result = $db->sql_query($sql);
$usersstats = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
foreach ($usersstats AS $userstats)
{
$betsof[$userstats['user_id']] = $userstats['bets'];
$nobetsof[$userstats['user_id']] = $userstats['matches'] - $userstats['bets'];
$tendenciesof[$userstats['user_id']] = $userstats['tendency'];
$hitsof[$userstats['user_id']] = $userstats['hits'];
$hits02of[$userstats['user_id']] = $userstats['hits02'];
}
// ranks of matchday
$sql = 'SELECT
rank,
user_id
FROM '. FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND matchday = $matchday
AND status IN (2,3)
ORDER BY rank ASC, user_id ASC";
$result = $db->sql_query($sql);
$ranks = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$total_users = sizeof($ranks);
foreach ($ranks AS $rank)
{
$rankof[$rank['user_id']] = $rank['rank'];
}
if ($matchday > 1)
{
// rank previous matchday
$sql = 'SELECT
rank AS last_rang,
user_id
FROM '. FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND matchday = ($matchday-1)
AND status IN (2,3)
ORDER BY last_rang ASC, user_id ASC";
$result = $db->sql_query($sql);
$ranks = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
foreach ($ranks AS $rank)
{
$prevrankof[$rank['user_id']] = $rank['last_rang'];
}
}
if ($matchday == $maxmatchday)
{
$season_wins = season_wins($season, $league, $matchday);
}
// Make sure $start is set to the last page if it exceeds the amount
if ($start < 0 || $start >= $total_users)
{
$sql_start = ($start < 0) ? 0 : floor(($total_users - 1) / $config['football_users_per_page']) * $config['football_users_per_page'];
}
else
{
$sql_start = floor($start / $config['football_users_per_page']) * $config['football_users_per_page'];
}
$sql_limit = $config['football_users_per_page'];
// handle pagination.
$base_url = $this->helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday));
$pagination = $phpbb_container->get('pagination');
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_users, $this->config['football_users_per_page'], $start);
$data_ranks = false;
$index = 0;
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
$sql = 'SELECT
r.rank,
r.status,
r.user_id,
r.points,
r.win AS wins,
u.user_colour,
u.username
FROM '. FOOTB_RANKS . ' AS r
LEFT Join '. USERS_TABLE . " AS u ON (r.user_id = u.user_id)
WHERE r.season = $season
AND r.league = $league
AND r.matchday = $matchday
AND r.status IN (2,3)
ORDER BY r.rank ASC, r.points DESC, LOWER(u.username) ASC";
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
while($row = $db->sql_fetchrow($result))
{
$index++;
$data_ranks = true;
if (isset($prevrankof[$row['user_id']]))
{
if ($rankof[$row['user_id']] == '')
{
$change_sign = '';
$change_img = '';
$change_differ = '&nbsp;';
}
else
{
if ($rankof[$row['user_id']] == $prevrankof[$row['user_id']])
{
$change_sign = '=';
$change_img = "<img src=\"" . $ext_path . "images/no_change.gif\" alt=\"" . $user->lang['NO_CHANGES'] . "\"/>";
$change_differ = '&nbsp;';
}
else
{
if ($rankof[$row['user_id']] > $prevrankof[$row['user_id']])
{
$change_sign = '+';
$change_img = "<img src=\"" . $ext_path . "images/arrow_down.gif\" alt=\"" . $user->lang['WORSENED'] . "\"/>";
$differ = $rankof[$row['user_id']] - $prevrankof[$row['user_id']];
$change_differ = ' (' . $differ . ')';
}
else
{
$change_sign = '-';
$change_img = "<img src=\"" . $ext_path . "images/arrow_up.gif\" alt=\"" . $user->lang['IMPROVED'] . "\"/>";
$differ = $prevrankof[$row['user_id']] - $rankof[$row['user_id']];
$change_differ = ' (' . $differ . ')';
}
}
}
}
else
{
$change_sign = '';
$change_img = '';
$change_differ = '&nbsp;';
}
if ($matchday == $maxmatchday)
{
// if someone didn't bet the hole Season
if(!isset($win_user_most_hits[$row['user_id']]['win']))
{
$win_user_most_hits[$row['user_id']]['win'] = 0;
}
if(!isset($win_user_most_hits_away[$row['user_id']]['win']))
{
$win_user_most_hits_away[$row['user_id']]['win'] = 0;
}
if(!isset($season_wins[$row['user_id']]['win']))
{
$season_wins[$row['user_id']]['win'] = 0;
}
$win_total = sprintf('%01.2f',$row['wins'] + $win_user_most_hits[$row['user_id']]['win'] + $win_user_most_hits_away[$row['user_id']]['win']
+ $season_wins[$row['user_id']]['win']);
}
else
{
$win_total = sprintf('%01.2f',$row['wins']);
}
$row_class = (!($index % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$colorstyle = color_style($row['status']);
$template->assign_block_vars('rankstotal', array(
'ROW_CLASS' => $row_class,
'RANK' => $rankof[$row['user_id']],
'CHANGE_SIGN' => $change_sign,
'CHANGE_IMG' => $change_img,
'CHANGE_DIFFER' => $change_differ,
'USERID' => $row['user_id'],
'USERNAME' => $row['username'],
'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
'BETS' => $betsof[$row['user_id']],
'NOBETS' => ($nobetsof[$row['user_id']] == 0) ? '&nbsp;' : $nobetsof[$row['user_id']],
'TENDENCIES' => ($tendenciesof[$row['user_id']] == 0) ? '&nbsp;' : $tendenciesof[$row['user_id']],
'DIRECTHITS' => ($hitsof[$row['user_id']] == 0) ? '&nbsp;' : $hitsof[$row['user_id']],
'DIRECTHITS02' => ($hits02of[$row['user_id']] == 0) ? '&nbsp;' : $hits02of[$row['user_id']],
'POINTS' => $row['points'],
'COLOR_STYLE' => $colorstyle,
'WIN' => $win_total,
)
);
}
$db->sql_freeresult($result);
$league_info = league_info($season, $league);
$sidename = sprintf($user->lang['RANK_MATCHDAY']);
$template->assign_vars(array(
'S_DISPLAY_RANKS_MATCHDAY' => true,
'S_DISPLAY_HITS02' => $config['football_win_hits02'],
'S_SIDENAME' => $sidename,
'S_WIN' => ($league_info['win_matchday'] == '0') ? false : true,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'table', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['TABLE']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'ranks_total', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['RANK_TOTAL']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_TABLE']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_RANK_TOTAL']),
'S_DATA_RANKS' => $data_ranks,
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
'TOTAL_USERS' => ($total_users == 1) ? $user->lang['VIEW_BET_USER'] : sprintf($user->lang['VIEW_BET_USERS'], $total_users),
'WIN_NAME' => $config['football_win_name'],
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$start = $this->request->variable('start', 0);
$win_user_most_hits = array();
$win_user_most_hits_away = array();
$season_wins = array();
$win_user_most_hits = win_user_most_hits($season, $league, $matchday);
$win_user_most_hits_away = win_user_most_hits_away($season, $league, $matchday);
// Statistics of matchday
$sql = "SELECT
b.user_id,
COUNT(b.match_no) AS matches,
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '', 1, 0)) AS bets,
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 hits,
SUM(IF(b.goals_home <> '' AND b.goals_guest <> '',
IF((m.goals_home <= m.goals_guest),
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0),
0
),
0
)
) AS hits02,
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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
),
0
)
) AS tendency
FROM " . FOOTB_BETS . ' AS b
LEFT JOIN ' . FOOTB_MATCHES . " AS m ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
WHERE b.season = $season
AND b.league = $league
AND m.status IN (2,3)
AND m.matchday = $matchday
GROUP BY user_id";
$result = $db->sql_query($sql);
$usersstats = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
foreach ($usersstats AS $userstats)
{
$betsof[$userstats['user_id']] = $userstats['bets'];
$nobetsof[$userstats['user_id']] = $userstats['matches'] - $userstats['bets'];
$tendenciesof[$userstats['user_id']] = $userstats['tendency'];
$hitsof[$userstats['user_id']] = $userstats['hits'];
$hits02of[$userstats['user_id']] = $userstats['hits02'];
}
// ranks of matchday
$sql = 'SELECT
rank,
user_id
FROM '. FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND matchday = $matchday
AND status IN (2,3)
ORDER BY rank ASC, user_id ASC";
$result = $db->sql_query($sql);
$ranks = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$total_users = sizeof($ranks);
foreach ($ranks AS $rank)
{
$rankof[$rank['user_id']] = $rank['rank'];
}
if ($matchday > 1)
{
// rank previous matchday
$sql = 'SELECT
rank AS last_rang,
user_id
FROM '. FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND matchday = ($matchday-1)
AND status IN (2,3)
ORDER BY last_rang ASC, user_id ASC";
$result = $db->sql_query($sql);
$ranks = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
foreach ($ranks AS $rank)
{
$prevrankof[$rank['user_id']] = $rank['last_rang'];
}
}
if ($matchday == $maxmatchday)
{
$season_wins = season_wins($season, $league, $matchday);
}
// Make sure $start is set to the last page if it exceeds the amount
if ($start < 0 || $start >= $total_users)
{
$sql_start = ($start < 0) ? 0 : floor(($total_users - 1) / $config['football_users_per_page']) * $config['football_users_per_page'];
}
else
{
$sql_start = floor($start / $config['football_users_per_page']) * $config['football_users_per_page'];
}
$sql_limit = $config['football_users_per_page'];
// handle pagination.
$base_url = $this->helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday));
$pagination = $phpbb_container->get('pagination');
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_users, $this->config['football_users_per_page'], $start);
$data_ranks = false;
$index = 0;
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
$sql = 'SELECT
r.rank,
r.status,
r.user_id,
r.points,
r.win AS wins,
u.user_colour,
u.username
FROM '. FOOTB_RANKS . ' AS r
LEFT Join '. USERS_TABLE . " AS u ON (r.user_id = u.user_id)
WHERE r.season = $season
AND r.league = $league
AND r.matchday = $matchday
AND r.status IN (2,3)
ORDER BY r.rank ASC, r.points DESC, LOWER(u.username) ASC";
$result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
while($row = $db->sql_fetchrow($result))
{
$index++;
$data_ranks = true;
if (isset($prevrankof[$row['user_id']]))
{
if ($rankof[$row['user_id']] == '')
{
$change_sign = '';
$change_differ = '&nbsp;';
}
else
{
if ($rankof[$row['user_id']] == $prevrankof[$row['user_id']])
{
$change_sign = '=';
$change_differ = '&nbsp;';
}
else
{
if ($rankof[$row['user_id']] > $prevrankof[$row['user_id']])
{
$change_sign = '-';
$differ = $prevrankof[$row['user_id']] - $rankof[$row['user_id']];
$change_differ = ' (' . $differ . ')';
}
else
{
$change_sign = '+';
$differ = $prevrankof[$row['user_id']] - $rankof[$row['user_id']];
$change_differ = ' (' . $differ . ')';
}
}
}
}
else
{
$change_sign = '';
$change_differ = '&nbsp;';
}
if ($matchday == $maxmatchday)
{
// if someone didn't bet the hole Season
if(!isset($win_user_most_hits[$row['user_id']]['win']))
{
$win_user_most_hits[$row['user_id']]['win'] = 0;
}
if(!isset($win_user_most_hits_away[$row['user_id']]['win']))
{
$win_user_most_hits_away[$row['user_id']]['win'] = 0;
}
if(!isset($season_wins[$row['user_id']]['win']))
{
$season_wins[$row['user_id']]['win'] = 0;
}
$win_total = sprintf('%01.2f',$row['wins'] + $win_user_most_hits[$row['user_id']]['win'] + $win_user_most_hits_away[$row['user_id']]['win']
+ $season_wins[$row['user_id']]['win']);
}
else
{
$win_total = sprintf('%01.2f',$row['wins']);
}
$row_class = (!($index % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$colorstyle = color_style($row['status']);
$template->assign_block_vars('rankstotal', array(
'ROW_CLASS' => $row_class,
'RANK' => $rankof[$row['user_id']],
'NO_CHANGES' => ($change_sign == '=') ? true : false,
'WORSENED' => ($change_sign == '-') ? true : false,
'IMPROVED' => ($change_sign == '+') ? true : false,
'CHANGE_SIGN' => $change_sign,
'CHANGE_DIFFER' => $change_differ,
'USERID' => $row['user_id'],
'USERNAME' => $row['username'],
'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
'BETS' => $betsof[$row['user_id']],
'NOBETS' => ($nobetsof[$row['user_id']] == 0) ? '&nbsp;' : $nobetsof[$row['user_id']],
'TENDENCIES' => ($tendenciesof[$row['user_id']] == 0) ? '&nbsp;' : $tendenciesof[$row['user_id']],
'DIRECTHITS' => ($hitsof[$row['user_id']] == 0) ? '&nbsp;' : $hitsof[$row['user_id']],
'DIRECTHITS02' => ($hits02of[$row['user_id']] == 0) ? '&nbsp;' : $hits02of[$row['user_id']],
'POINTS' => $row['points'],
'COLOR_STYLE' => $colorstyle,
'WIN' => $win_total,
)
);
}
$db->sql_freeresult($result);
$league_info = league_info($season, $league);
$sidename = sprintf($user->lang['RANK_MATCHDAY']);
$template->assign_vars(array(
'S_DISPLAY_RANKS_MATCHDAY' => true,
'S_DISPLAY_HITS02' => $config['football_win_hits02'],
'S_SIDENAME' => $sidename,
'S_WIN' => ($league_info['win_matchday'] == '0') ? false : true,
'S_DATA_RANKS' => $data_ranks,
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
'TOTAL_USERS' => ($total_users == 1) ? $user->lang['VIEW_BET_USER'] : sprintf($user->lang['VIEW_BET_USERS'], $total_users),
'WIN_NAME' => $config['football_win_name'],
)
);
?>
+6 -32
View File
@@ -157,7 +157,6 @@ switch ($mode)
}
$index++;
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['RANK_TOTAL']);
$league_info = league_info($season, $league);
@@ -166,13 +165,6 @@ switch ($mode)
'S_DISPLAY_HITS02' => $config['football_win_hits02'],
'S_DATA_RANKS' => $data_ranks,
'S_SIDENAME' => $sidename,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['RANK_MATCHDAY']),
'U_RIGHT' => ($config['football_bank']) ? $this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league, 'm' => $matchday)) :
$this->helper->route('football_main_controller', array('side' => 'my_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => ($config['football_bank']) ? sprintf($user->lang['FOOTBALL_BANK']) . ' &gt;' : sprintf($user->lang['MY_BETS']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_RANK_MATCHDAY']),
'RIGHT_TITLE' => ($config['football_bank']) ? sprintf($user->lang['TITLE_FOOTBALL_BANK']) : sprintf($user->lang['TITLE_MY_BETS']),
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
'TOTAL_USERS' => ($total_users == 1) ? $user->lang['VIEW_BET_USER'] : sprintf($user->lang['VIEW_BET_USERS'], $total_users),
'S_WIN' => false,
@@ -328,7 +320,6 @@ switch ($mode)
}
$index++;
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['RANK_TOTAL']);
$league_info = league_info($season, $league);
@@ -337,13 +328,6 @@ switch ($mode)
'S_DISPLAY_HITS02' => $config['football_win_hits02'],
'S_DATA_RANKS' => $data_ranks,
'S_SIDENAME' => $sidename,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['RANK_MATCHDAY']),
'U_RIGHT' => ($config['football_bank']) ? $this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league, 'm' => $matchday)) :
$this->helper->route('football_main_controller', array('side' => 'my_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => ($config['football_bank']) ? sprintf($user->lang['FOOTBALL_BANK']) . ' &gt;' : sprintf($user->lang['MY_BETS']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_RANK_MATCHDAY']),
'RIGHT_TITLE' => ($config['football_bank']) ? sprintf($user->lang['TITLE_FOOTBALL_BANK']) : sprintf($user->lang['TITLE_MY_BETS']),
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
'TOTAL_USERS' => ($total_users == 1) ? $user->lang['VIEW_BET_USER'] : sprintf($user->lang['VIEW_BET_USERS'], $total_users),
'S_WIN' => ($league_info['win_matchday'] == '0' and $league_info['win_season'] == '0') ? false : ($this->auth->acl_gets('a_')) ? true : false,
@@ -492,22 +476,19 @@ switch ($mode)
if ($rank == $prev_rank_of[$curr_rank['user_id']])
{
$change_sign = '=';
$change_img = "<img src=\"" . $ext_path . "images/no_change.gif\" alt=\"" . $user->lang['NO_CHANGES'] . "\"/>";
$change_differ = '';
}
else
{
if ($rank > $prev_rank_of[$curr_rank['user_id']])
{
$change_sign = '+';
$change_img = "<img src=\"" . $ext_path . "images/arrow_down.gif\" alt=\"" . $user->lang['WORSENED'] . "\"/>";
$differ = $rank - $prev_rank_of[$curr_rank['user_id']];
$change_sign = '-';
$differ = $prev_rank_of[$curr_rank['user_id']] - $rank;
$change_differ = ' (' . $differ . ')';
}
else
{
$change_sign = '-';
$change_img = "<img src=\"" . $ext_path . "images/arrow_up.gif\" alt=\"" . $user->lang['IMPROVED'] . "\"/>";
$change_sign = '+';
$differ = $prev_rank_of[$curr_rank['user_id']] - $rank;
$change_differ = ' (' . $differ . ')';
}
@@ -516,7 +497,6 @@ switch ($mode)
else
{
$change_sign = '';
$change_img = '';
$change_differ = '';
}
@@ -539,8 +519,10 @@ switch ($mode)
$template->assign_block_vars('rankstotal', array(
'ROW_CLASS' => $row_class,
'RANK' => $rank,
'NO_CHANGES' => ($change_sign == '=') ? true : false,
'WORSENED' => ($change_sign == '-') ? true : false,
'IMPROVED' => ($change_sign == '+') ? true : false,
'CHANGE_SIGN' => $change_sign,
'CHANGE_IMG' => $change_img,
'CHANGE_DIFFER' => $change_differ,
'USERID' => $curr_rank['user_id'],
'USERNAME' => $curr_rank['username'],
@@ -558,7 +540,6 @@ switch ($mode)
}
$index++;
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['RANK_TOTAL']);
$league_info = league_info($season, $league);
@@ -567,13 +548,6 @@ switch ($mode)
'S_DISPLAY_HITS02' => $config['football_win_hits02'],
'S_DATA_RANKS' => $data_ranks,
'S_SIDENAME' => $sidename,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['RANK_MATCHDAY']),
'U_RIGHT' => ($config['football_bank']) ? $this->helper->route('football_main_controller', array('side' => 'bank', 's' => $season, 'l' => $league, 'm' => $matchday)) :
$this->helper->route('football_main_controller', array('side' => 'my_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => ($config['football_bank']) ? sprintf($user->lang['FOOTBALL_BANK']) . ' &gt;' : sprintf($user->lang['MY_BETS']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_RANK_MATCHDAY']),
'RIGHT_TITLE' => ($config['football_bank']) ? sprintf($user->lang['TITLE_FOOTBALL_BANK']) : sprintf($user->lang['TITLE_MY_BETS']),
'PAGE_NUMBER' => $pagination->on_page($total_users, $this->config['football_users_per_page'], $start),
'TOTAL_USERS' => ($total_users == 1) ? $user->lang['VIEW_BET_USER'] : sprintf($user->lang['VIEW_BET_USERS'], $total_users),
'S_WIN' => ($league_info['win_matchday'] == '0' and $league_info['win_season'] == '0') ? false : true,
+439 -432
View File
@@ -1,433 +1,440 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$user_is_member = user_is_member($user->data['user_id'], $season, $league);
$edit_mode = false;
$display_group = false;
$display_ko = false;
$data_results = false;
$lang_dates = $user->lang['datetime'];
$matchnumber = 0;
$editstatus = array(1, 2, 4, 5);
$league_info = league_info($season, $league);
// Calculate matches AND results of matchday
$sql = "SELECT
m.match_no,
m.matchday,
m.status,
m.group_id,
m.formula_home,
m.formula_guest,
t1.team_symbol AS home_symbol,
t2.team_symbol AS guest_symbol,
t1.team_id AS home_id,
t2.team_id AS guest_id,
t1.team_name AS home_name,
t2.team_name AS guest_name,
t1.team_name_short AS home_short,
t2.team_name_short AS guest_short,
m.goals_home,
m.goals_guest,
m.ko_match AS ko_match,
m.goals_overtime_home AS kogoals_home,
m.goals_overtime_guest AS kogoals_guest,
CONCAT(
CASE DATE_FORMAT(m.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(m.match_datetime,' %d.%m. %H:%i')
) AS match_time
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.matchday = $matchday
ORDER BY m.match_datetime ASC, m.match_no ASC";
$result = $db->sql_query($sql);
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
while($row = $db->sql_fetchrow($result))
{
$data_results = true;
$matchnumber++ ;
$row_class = (!($matchnumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if (0 == $row['home_id'])
{
$home_info = get_team($season, $league, $row['match_no'], 'team_id_home', $row['formula_home']);
$home_in_array = explode("#",$home_info);
$homelogo = $home_in_array[0];
$homeid = $home_in_array[1];
$homename = $home_in_array[2];
$homeshort = $home_in_array[2];
}
else
{
$homelogo = $row['home_symbol'];
$homeid = $row['home_id'];
$homename = $row['home_name'];
$homeshort = $row['home_short'];
}
if (0 == $row['guest_id'])
{
$guest_info = get_team($season, $league, $row['match_no'], 'team_id_guest', $row['formula_guest']);
$guest_in_array = explode("#",$guest_info);
$guestlogo = $guest_in_array[0];
$guestid = $guest_in_array[1];
$guestname = $guest_in_array[2];
$guestshort = $guest_in_array[2];
}
else
{
$guestlogo = $row['guest_symbol'];
$guestid = $row['guest_id'];
$guestname = $row['guest_name'];
$guestshort = $row['guest_short'];
}
if ($homelogo <> '')
{
$logoH = "<img src=\"" . $ext_path . 'images/flags/' . $homelogo . "\" alt=\"" . $homelogo . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logoH = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
if ($guestlogo <> '')
{
$logoG = "<img src=\"" . $ext_path . 'images/flags/' . $guestlogo . "\" alt=\"" . $guestlogo . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logoG = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
if ($row['ko_match'])
{
$display_ko = true;
$ko_match = true;
}
else
{
$ko_match = false;
}
if ($row['group_id'] == '')
{
$group_id = '&nbsp;';
}
else
{
$display_group = true;
$group_id = $row['group_id'];
}
if (in_array($row['status'], $editstatus) AND $user_is_member)
{
$edit_mode = true;
$edit_match = true;
$goals_home = $row['goals_home'];
$goals_guest = $row['goals_guest'];
$kogoals_home = $row['kogoals_home'];
$kogoals_guest = $row['kogoals_guest'];
}
else
{
$edit_match = false;
$goals_home = ($row['goals_home'] == '') ? '&nbsp;' : $row['goals_home'];
$goals_guest = ($row['goals_guest'] == '') ? '&nbsp;' : $row['goals_guest'];
$kogoals_home = ($row['kogoals_home'] == '') ? '&nbsp;' : $row['kogoals_home'];
$kogoals_guest = ($row['kogoals_guest'] == '') ? '&nbsp;' : $row['kogoals_guest'];
}
$template->assign_block_vars('result', array(
'ROW_CLASS' => $row_class,
'MATCH_NUMBER' => $row['match_no'],
'MATCHDAY' => $row['matchday'],
'STATUS' => $row['status'],
'MATCH_TIME' => $row['match_time'],
'GROUP' => $group_id,
'HOME_ID' => $homeid,
'GUEST_ID' => $guestid,
'LOGO_HOME' => $logoH,
'LOGO_GUEST' => $logoG,
'HOME_NAME' => $homename,
'GUEST_NAME' => $guestname,
'HOME_SHORT' => $homeshort,
'GUEST_SHORT' => $guestshort,
'U_PLAN_HOME' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $homeid, 'mode' => 'all')),
'U_PLAN_GUEST' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $guestid, 'mode' => 'all')),
'GOALS_HOME' => $goals_home,
'GOALS_GUEST' => $goals_guest,
'COLOR_STYLE' => color_style($row['status']),
'KOGOALS_HOME' => $kogoals_home,
'KOGOALS_GUEST' => $kogoals_guest,
'S_KO_MATCH' => $ko_match,
'S_EDIT_MATCH' => $edit_match,
)
);
}
$db->sql_freeresult($result);
// Calculate extra bets of matchday
// Start select team
$sql = 'SELECT
team_id AS option_value,
team_name AS option_name
FROM ' . FOOTB_TEAMS . "
WHERE season = $season
AND league = $league
ORDER BY team_name ASC";
$result = $db->sql_query($sql);
$option_rows = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
if ($edit_mode)
{
$template->assign_block_vars('worldfootball', array('LEAGUE' => $league-1,));
}
$sql = "SELECT e.*,
t1.team_name AS result_team
FROM " . FOOTB_EXTRA . ' AS e
LEFT JOIN ' . FOOTB_TEAMS . " AS t1 ON (t1.season = e.season AND t1.league = e.league AND t1.team_id = e.result)
WHERE e.season = $season
AND e.league = $league
AND e.matchday_eval = $matchday
ORDER BY e.extra_no ASC";
$result = $db->sql_query($sql);
$extra_results = false;
$extranumber = 0;
while ($row = $db->sql_fetchrow($result))
{
$extra_results = true;
$extranumber++ ;
$row_class = (!($extranumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
switch($row['question_type'])
{
case '1':
{
$display_type = 1;
$eval_title = sprintf($user->lang['EXTRA_HIT']);
}
break;
case '2':
{
$display_type = 1;
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
}
break;
case '3':
{
$display_type = 2;
$eval_title = sprintf($user->lang['EXTRA_HIT']);
}
break;
case '4':
case '5':
{
$display_type = 2;
$eval_title = sprintf($user->lang['EXTRA_DIFFERENCE']);
}
break;
default :
{
$display_type = 2;
$eval_title = '';
}
break;
}
if ($row['extra_status'] > 0 && $row['extra_status'] < 3 && $user_is_member)
{
$edit_mode = true;
$result_extra = ($row['result_team'] == NULL) ? '' : $row['result_team'];
$multiple = '';
switch($row['question_type'])
{
case '2':
{
$multiple = ' multiple="multiple" size="3" ';
}
break;
case '4':
{
$option_arr = array();
for ($i = 65; $i <= 72; $i++)
{
if (strstr($row['question'], chr($i) . ':'))
{
$option_arr[] = array(
'option_value' => chr($i),
'option_name' => chr($i),
);
}
}
if (sizeof($option_arr) > 1)
{
$display_type = 1;
$option_rows = $option_arr;
$result_extra = $row['result'];
$multiple = ' multiple="multiple" size="3" ';
}
}
break;
case '3':
{
$option_arr = array();
for ($i = 65; $i <= 72; $i++)
{
if (strstr($row['question'], chr($i) . ':'))
{
$option_arr[] = array(
'option_value' => chr($i),
'option_name' => chr($i),
);
}
}
if (sizeof($option_arr) > 1)
{
$display_type = 1;
$option_rows = $option_arr;
$result_extra = $row['result'];
}
}
break;
}
$template->assign_block_vars('extra_result', array(
'ROW_CLASS' => $row_class,
'EXTRA_NO' => $row['extra_no'],
'S_EDIT_EXTRA' => true,
'QUESTION' => $row['question'],
'EXTRA_POINTS' => $row['extra_points'],
'EVALUATION' => ($row['matchday'] == $row['matchday_eval']) ? sprintf($user->lang['MATCHDAY']) : sprintf($user->lang['TOTAL']),
'EVALUATION_TITLE' => $eval_title,
'RESULT' => ($display_type == 1) ? $result_extra : $row['result'],
'S_DISPLAY_TYPE' => $display_type,
)
);
if ($display_type == 1)
{
$selected = ($row['result'] == '') ? ' selected="selected"' : '';
$template->assign_block_vars('extra_result.extra_option', array(
'OPTION_VALUE' => '',
'OPTION_NAME' => sprintf($user->lang['SELECT']),
'S_SELECTED' => $selected));
foreach ($option_rows as $option_row)
{
if (strstr($row['result'], ';'))
{
$selected = '';
$result_arr = explode(';', $row['result']);
foreach($result_arr AS $result_value)
{
if ($result_value <> '')
{
if ($option_row['option_value'] == $result_value)
{
$selected = ' selected="selected"';
}
}
}
}
else
{
$selected = ($option_row['option_value'] == $row['result']) ? ' selected="selected"' : '';
}
$template->assign_block_vars('extra_result.extra_option', array(
'OPTION_VALUE' => $option_row['option_value'],
'OPTION_NAME' => $option_row['option_name'],
'S_SELECTED' => $selected));
}
}
}
else
{
$extra_colorstyle = color_style($row['extra_status']);
$extra_result = ($row['result'] == '') ? '&nbsp;' : $row['result'];
$result_extra = ($row['result_team'] == NULL) ? '&nbsp;' : $row['result_team'];
$template->assign_block_vars('extra_result', array(
'ROW_CLASS' => $row_class,
'S_EDIT_EXTRA' => false,
'QUESTION' => $row['question'],
'EXTRA_POINTS' => $row['extra_points'],
'EVALUATION' => ($row['matchday'] == $row['matchday_eval']) ? sprintf($user->lang['MATCHDAY']) : sprintf($user->lang['TOTAL']),
'RESULT' => ($display_type == 1) ? $result_extra : $extra_result,
'COLOR_STYLE' => $extra_colorstyle,
)
);
}
}
$sidename = sprintf($user->lang['RESULTS']);
switch ($league_info['bet_ko_type'])
{
case BET_KO_90:
$result_explain = sprintf($user->lang['MIN90']);
$label_finalresult = sprintf($user->lang['EXTRATIME_SHORT']) . '/' . sprintf($user->lang['PENALTY_SHORT']);
break;
case BET_KO_EXTRATIME:
$result_explain = sprintf($user->lang['EXTRATIME_SHORT']);
$label_finalresult = sprintf($user->lang['PENALTY']);
break;
case BET_KO_PENALTY:
$result_explain = sprintf($user->lang['PENALTY']);
$display_ko = false;
break;
default:
$result_explain = sprintf($user->lang['MIN90']);
$label_finalresult = sprintf($user->lang['EXTRATIME_SHORT']) . '/' . sprintf($user->lang['PENALTY_SHORT']);
break;
}
$template->assign_vars(array(
'S_DISPLAY_RESULTS' => true,
'S_EXTRA_RESULTS' => $extra_results,
'S_SIDENAME' => $sidename,
'RESULT_EXPLAIN' => $result_explain,
'LABEL_FINALRESULT' => $label_finalresult,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'all_bets', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['ALL_BETS']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'table', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['TABLE']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_ALL_BETS']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_TABLE']),
'S_FORM_ACTION_RESULT' => $this->helper->route('football_main_controller', array('side' => 'results', 's' => $season, 'l' => $league, 'm' => $matchday, 'action' => 'result')),
'S_DATA_RESULTS' => $data_results,
'S_USER_IS_MEMBER' => $user_is_member,
'S_DISPLAY_GROUP' => $display_group,
'S_DISPLAY_KO' => $display_ko,
'S_EDIT_MODE' => $edit_mode,
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$user_is_member = user_is_member($user->data['user_id'], $season, $league);
$edit_mode = false;
$display_group = false;
$display_ko = false;
$data_results = false;
$lang_dates = $user->lang['datetime'];
$matchnumber = 0;
$editstatus = array(1, 2, 4, 5);
$league_info = league_info($season, $league);
// Calculate matches AND results of matchday
$sql = "SELECT
m.match_no,
m.matchday,
m.status,
m.group_id,
m.formula_home,
m.formula_guest,
t1.team_symbol AS home_symbol,
t2.team_symbol AS guest_symbol,
t1.team_id AS home_id,
t2.team_id AS guest_id,
t1.team_name AS home_name,
t2.team_name AS guest_name,
t1.team_name_short AS home_short,
t2.team_name_short AS guest_short,
m.goals_home,
m.goals_guest,
m.ko_match AS ko_match,
m.goals_overtime_home AS kogoals_home,
m.goals_overtime_guest AS kogoals_guest,
CONCAT(
CASE DATE_FORMAT(m.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(m.match_datetime,' %d.%m. %H:%i')
) AS match_time
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.matchday = $matchday
ORDER BY m.match_datetime ASC, m.match_no ASC";
$result = $db->sql_query($sql);
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
while($row = $db->sql_fetchrow($result))
{
$data_results = true;
$matchnumber++ ;
$row_class = (!($matchnumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if (0 == $row['home_id'])
{
$home_info = get_team($season, $league, $row['match_no'], 'team_id_home', $row['formula_home']);
$home_in_array = explode("#",$home_info);
$homelogo = $home_in_array[0];
$homeid = $home_in_array[1];
$homename = $home_in_array[2];
$homeshort = $home_in_array[2];
}
else
{
$homelogo = $row['home_symbol'];
$homeid = $row['home_id'];
$homename = $row['home_name'];
$homeshort = $row['home_short'];
}
if (0 == $row['guest_id'])
{
$guest_info = get_team($season, $league, $row['match_no'], 'team_id_guest', $row['formula_guest']);
$guest_in_array = explode("#",$guest_info);
$guestlogo = $guest_in_array[0];
$guestid = $guest_in_array[1];
$guestname = $guest_in_array[2];
$guestshort = $guest_in_array[2];
}
else
{
$guestlogo = $row['guest_symbol'];
$guestid = $row['guest_id'];
$guestname = $row['guest_name'];
$guestshort = $row['guest_short'];
}
if ($homelogo <> '')
{
$logoH = "<img src=\"" . $ext_path . 'images/flags/' . $homelogo . "\" alt=\"" . $homelogo . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logoH = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
if ($guestlogo <> '')
{
$logoG = "<img src=\"" . $ext_path . 'images/flags/' . $guestlogo . "\" alt=\"" . $guestlogo . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logoG = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
if ($row['ko_match'])
{
$display_ko = true;
$ko_match = true;
}
else
{
$ko_match = false;
}
if ($row['group_id'] == '')
{
$group_id = '&nbsp;';
}
else
{
$display_group = true;
$group_id = $row['group_id'];
}
if (in_array($row['status'], $editstatus) AND $user_is_member)
{
$edit_mode = true;
$edit_match = true;
$goals_home = $row['goals_home'];
$goals_guest = $row['goals_guest'];
$kogoals_home = $row['kogoals_home'];
$kogoals_guest = $row['kogoals_guest'];
}
else
{
$edit_match = false;
$goals_home = ($row['goals_home'] == '') ? '&nbsp;' : $row['goals_home'];
$goals_guest = ($row['goals_guest'] == '') ? '&nbsp;' : $row['goals_guest'];
$kogoals_home = ($row['kogoals_home'] == '') ? '&nbsp;' : $row['kogoals_home'];
$kogoals_guest = ($row['kogoals_guest'] == '') ? '&nbsp;' : $row['kogoals_guest'];
}
$template->assign_block_vars('result', array(
'ROW_CLASS' => $row_class,
'MATCH_NUMBER' => $row['match_no'],
'MATCHDAY' => $row['matchday'],
'STATUS' => $row['status'],
'MATCH_TIME' => $row['match_time'],
'GROUP' => $group_id,
'HOME_ID' => $homeid,
'GUEST_ID' => $guestid,
'LOGO_HOME' => $logoH,
'LOGO_GUEST' => $logoG,
'HOME_NAME' => $homename,
'GUEST_NAME' => $guestname,
'HOME_SHORT' => $homeshort,
'GUEST_SHORT' => $guestshort,
'U_PLAN_HOME' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $homeid, 'mode' => 'all')),
'U_PLAN_GUEST' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $league,
'tid' => $guestid, 'mode' => 'all')),
'GOALS_HOME' => $goals_home,
'GOALS_GUEST' => $goals_guest,
'COLOR_STYLE' => color_style($row['status']),
'KOGOALS_HOME' => $kogoals_home,
'KOGOALS_GUEST' => $kogoals_guest,
'S_KO_MATCH' => $ko_match,
'S_EDIT_MATCH' => $edit_match,
)
);
}
$db->sql_freeresult($result);
// Calculate extra bets of matchday
// Start select team
$sql = 'SELECT
team_id AS option_value,
team_name AS option_name
FROM ' . FOOTB_TEAMS . "
WHERE season = $season
AND league = $league
ORDER BY team_name ASC";
$result = $db->sql_query($sql);
$option_rows = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
if ($edit_mode)
{
$template->assign_block_vars('worldfootball', array('LEAGUE' => $league-1,));
}
$sql = "SELECT e.*,
t1.team_name AS result_team
FROM " . FOOTB_EXTRA . ' AS e
LEFT JOIN ' . FOOTB_TEAMS . " AS t1 ON (t1.season = e.season AND t1.league = e.league AND t1.team_id = e.result)
WHERE e.season = $season
AND e.league = $league
AND e.matchday_eval = $matchday
ORDER BY e.extra_no ASC";
$result = $db->sql_query($sql);
$extra_results = false;
$extranumber = 0;
while ($row = $db->sql_fetchrow($result))
{
$extra_results = true;
$extranumber++ ;
$row_class = (!($extranumber % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
switch($row['question_type'])
{
case '1':
{
$display_type = 1;
$eval_title = sprintf($user->lang['EXTRA_HIT']);
}
break;
case '2':
{
$display_type = 1;
$eval_title = sprintf($user->lang['EXTRA_MULTI_HIT']);
}
break;
case '3':
{
$display_type = 2;
$eval_title = sprintf($user->lang['EXTRA_HIT']);
}
break;
case '4':
case '5':
{
$display_type = 2;
$eval_title = sprintf($user->lang['EXTRA_DIFFERENCE']);
}
break;
default :
{
$display_type = 2;
$eval_title = '';
}
break;
}
if ($row['extra_status'] > 0 && $row['extra_status'] < 3 && $user_is_member)
{
$edit_mode = true;
$result_extra = ($row['result_team'] == NULL) ? '' : $row['result_team'];
$multiple = '';
switch($row['question_type'])
{
case '2':
{
$multiple = ' multiple="multiple" size="3" ';
}
break;
case '4':
{
$option_arr = array();
for ($i = 65; $i <= 72; $i++)
{
if (strstr($row['question'], chr($i) . ':'))
{
$option_arr[] = array(
'option_value' => chr($i),
'option_name' => chr($i),
);
}
}
if (sizeof($option_arr) > 1)
{
$display_type = 1;
$option_rows = $option_arr;
$result_extra = $row['result'];
$multiple = ' multiple="multiple" size="3" ';
}
}
break;
case '3':
{
$option_arr = array();
for ($i = 65; $i <= 72; $i++)
{
if (strstr($row['question'], chr($i) . ':'))
{
$option_arr[] = array(
'option_value' => chr($i),
'option_name' => chr($i),
);
}
}
if (sizeof($option_arr) > 1)
{
$display_type = 1;
$option_rows = $option_arr;
$result_extra = $row['result'];
}
}
break;
}
$template->assign_block_vars('extra_result', array(
'ROW_CLASS' => $row_class,
'EXTRA_NO' => $row['extra_no'],
'S_EDIT_EXTRA' => true,
'QUESTION' => $row['question'],
'EXTRA_POINTS' => $row['extra_points'],
'EVALUATION' => ($row['matchday'] == $row['matchday_eval']) ? sprintf($user->lang['MATCHDAY']) : sprintf($user->lang['TOTAL']),
'EVALUATION_TITLE' => $eval_title,
'RESULT' => ($display_type == 1) ? $result_extra : $row['result'],
'S_DISPLAY_TYPE' => $display_type,
)
);
if ($display_type == 1)
{
$selected = ($row['result'] == '') ? ' selected="selected"' : '';
$template->assign_block_vars('extra_result.extra_option', array(
'OPTION_VALUE' => '',
'OPTION_NAME' => sprintf($user->lang['SELECT']),
'S_SELECTED' => $selected));
foreach ($option_rows as $option_row)
{
if (strstr($row['result'], ';'))
{
$selected = '';
$result_arr = explode(';', $row['result']);
foreach($result_arr AS $result_value)
{
if ($result_value <> '')
{
if ($option_row['option_value'] == $result_value)
{
$selected = ' selected="selected"';
}
}
}
}
else
{
$selected = ($option_row['option_value'] == $row['result']) ? ' selected="selected"' : '';
}
$template->assign_block_vars('extra_result.extra_option', array(
'OPTION_VALUE' => $option_row['option_value'],
'OPTION_NAME' => $option_row['option_name'],
'S_SELECTED' => $selected));
}
}
}
else
{
$extra_colorstyle = color_style($row['extra_status']);
$extra_result = ($row['result'] == '') ? '&nbsp;' : $row['result'];
$result_extra = ($row['result_team'] == NULL) ? '&nbsp;' : $row['result_team'];
$template->assign_block_vars('extra_result', array(
'ROW_CLASS' => $row_class,
'S_EDIT_EXTRA' => false,
'QUESTION' => $row['question'],
'EXTRA_POINTS' => $row['extra_points'],
'EVALUATION' => ($row['matchday'] == $row['matchday_eval']) ? sprintf($user->lang['MATCHDAY']) : sprintf($user->lang['TOTAL']),
'RESULT' => ($display_type == 1) ? $result_extra : $extra_result,
'COLOR_STYLE' => $extra_colorstyle,
)
);
}
}
$db->sql_freeresult($result);
switch ($league_info['bet_ko_type'])
{
case BET_KO_90:
$result_explain = sprintf($user->lang['MIN90']);
$label_finalresult = sprintf($user->lang['EXTRATIME_SHORT']) . '/' . sprintf($user->lang['PENALTY_SHORT']);
break;
case BET_KO_EXTRATIME:
$result_explain = sprintf($user->lang['EXTRATIME_SHORT']);
$label_finalresult = sprintf($user->lang['PENALTY']);
break;
case BET_KO_PENALTY:
$result_explain = sprintf($user->lang['PENALTY']);
$display_ko = false;
break;
default:
$result_explain = sprintf($user->lang['MIN90']);
$label_finalresult = sprintf($user->lang['EXTRATIME_SHORT']) . '/' . sprintf($user->lang['PENALTY_SHORT']);
break;
}
// set correct display for usage in menu template
if($side == 'results')
{
$display_results = true;
$sidename = sprintf($user->lang['RESULTS']);
}
if($side == 'results_tl')
{
$display_results_tl = true;
$sidename = sprintf($user->lang['RESULTS']);
}
$template->assign_vars(array(
'S_DISPLAY_RESULTS' => $display_results,
'S_DISPLAY_RESULTS_TL' => $display_results_tl,
'S_EXTRA_RESULTS' => $extra_results,
'S_SIDENAME' => $sidename,
'RESULT_EXPLAIN' => $result_explain,
'LABEL_FINALRESULT' => $label_finalresult,
'S_FORM_ACTION_RESULT' => $this->helper->route('football_main_controller', array('side' => 'results', 's' => $season, 'l' => $league, 'm' => $matchday, 'action' => 'result')),
'S_DATA_RESULTS' => $data_results,
'S_USER_IS_MEMBER' => $user_is_member,
'S_DISPLAY_GROUP' => $display_group,
'S_DISPLAY_KO' => $display_ko,
'S_EDIT_MODE' => $edit_mode,
)
);
?>
+144 -144
View File
@@ -1,145 +1,145 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data_table = false;
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
$sql = 'SELECT *
FROM ' . FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND matchday = $matchday";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
include($this->football_root_path . 'block/rank_matchday.' . $this->php_ext);
}
else
{
$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, 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,
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.matchday <= $matchday
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();
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'];
}
$last_group = '';
$rank = 0;
$current_rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
foreach($points_ary as $group_id => $points)
{
$data_table = true;
if ($last_group != $group_id)
{
$last_group =$group_id;
$rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
$template->assign_block_vars('side_total', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' .$group_id,
)
);
}
foreach($points as $point => $teams)
{
if(count($teams) > 1 AND $group_id != '')
{
// Compare teams with equal points and sort
$teams = get_order_team_compare($teams, $season, $league, $group_id, $ranks_ary, $matchday);
}
foreach($teams as $key => $team)
{
$row = $table_ary[$team];
$rank++;
if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
{
$current_rank = $rank . '.';
}
else
{
$current_rank = '';
}
$last_points = $row['points'];
$last_goals = $row['goals'];
$last_goals_againts = $row['goals_against'];
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['team_symbol'] <> '')
{
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$template->assign_block_vars('side_total', array(
'RANK' => $current_rank,
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM_SHORT' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
'tid' => $row['team_id'], 'mode' => 'played')),
'GAMES' => $row['matches'],
'POINTS' => $row['points'],
)
);
}
}
}
$db->sql_freeresult($result);
$template->assign_vars(array(
'S_DISPLAY_SIDE_TABLE' => true,
'S_DATA_SIDE_TABLE' => $data_table,
)
);
}
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data_table = false;
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
$sql = 'SELECT *
FROM ' . FOOTB_RANKS . "
WHERE season = $season
AND league = $league
AND matchday = $matchday";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
include($this->football_root_path . 'block/rank_matchday.' . $this->php_ext);
}
else
{
$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, 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,
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.matchday <= $matchday
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();
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'];
}
$last_group = '';
$rank = 0;
$current_rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
foreach($points_ary as $group_id => $points)
{
$data_table = true;
if ($last_group != $group_id)
{
$last_group =$group_id;
$rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
$template->assign_block_vars('side_total', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' .$group_id,
)
);
}
foreach($points as $point => $teams)
{
if(count($teams) > 1 AND $group_id != '')
{
// Compare teams with equal points and sort
$teams = get_order_team_compare($teams, $season, $league, $group_id, $ranks_ary, $matchday);
}
foreach($teams as $key => $team)
{
$row = $table_ary[$team];
$rank++;
if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
{
$current_rank = $rank . '.';
}
else
{
$current_rank = '';
}
$last_points = $row['points'];
$last_goals = $row['goals'];
$last_goals_againts = $row['goals_against'];
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['team_symbol'] <> '')
{
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"20\" height=\"20\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"20\" height=\"20\"/>" ;
}
$template->assign_block_vars('side_total', array(
'RANK' => $current_rank,
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM_SHORT' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
'tid' => $row['team_id'], 'mode' => 'played')),
'GAMES' => $row['matches'],
'POINTS' => $row['points'],
)
);
}
}
}
$db->sql_freeresult($result);
$template->assign_vars(array(
'S_DISPLAY_SIDE_TABLE' => true,
'S_DATA_SIDE_TABLE' => $data_table,
)
);
}
?>
+163 -169
View File
@@ -1,170 +1,164 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data = false;
$data_all = false;
$rank = 0;
$sql = 'SELECT
r.user_id,
u.username,
r.*
FROM ' . FOOTB_RANKS . ' AS r
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
WHERE season = $season
AND league = $league
ORDER BY r.points DESC";
$result = $db->sql_query_limit($sql, 20);
while($row = $db->sql_fetchrow($result))
{
$data = true;
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('top20', array(
'ROW_CLASS' => $row_class,
'NAME' => $row['username'],
'MATCHDAY' => $row['matchday'],
'POINTS' => $row['points'],
'WIN' => $row['win'],
'DIRECTHITS' => $row['correct_result'],
'TENDENCIES' => $row['tendencies'] - $row['correct_result'],
'TOTAL' => $row['tendencies'],
)
);
}
$db->sql_freeresult($result);
$rank = 0;
$sql = 'SELECT
r.user_id,
u.username,
r.*
FROM ' . FOOTB_RANKS . ' AS r
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
WHERE r.season = $season
AND r.league = $league
ORDER BY r.points ASC";
$result = $db->sql_query_limit($sql, 20);
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('flop20', array(
'ROW_CLASS' => $row_class,
'NAME' => $row['username'],
'MATCHDAY' => $row['matchday'],
'POINTS' => $row['points'],
'DIRECTHITS' => $row['correct_result'],
'TENDENCIES' => $row['tendencies'] - $row['correct_result'],
'TOTAL' => $row['tendencies'],
)
);
}
$db->sql_freeresult($result);
$rank = 0;
$sql = 'SELECT
r.user_id,
u.username,
r.*
FROM ' . FOOTB_RANKS . ' AS r
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
WHERE league = $league
ORDER BY r.points DESC";
$result = $db->sql_query_limit($sql, 20);
while($row = $db->sql_fetchrow($result))
{
$data_all = true;
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('alltop20', array(
'ROW_CLASS' => $row_class,
'NAME' => $row['username'],
'SEASON' => $row['season'],
'MATCHDAY' => $row['matchday'],
'POINTS' => $row['points'],
'WIN' => $row['win'],
'DIRECTHITS' => $row['correct_result'],
'TENDENCIES' => $row['tendencies'] - $row['correct_result'],
'TOTAL' => $row['tendencies'],
)
);
}
$db->sql_freeresult($result);
$rank = 0;
$sql = 'SELECT
r.user_id,
u.username,
COUNT(points) AS count_zero
FROM ' . FOOTB_RANKS . ' AS r
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
WHERE r.league = $league
AND r.points = 0
GROUP BY r.user_id
ORDER BY count_zero DESC";
$result = $db->sql_query_limit($sql, 20);
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('allflop20', array(
'ROW_CLASS' => $row_class,
'NAME' => $row['username'],
'COUNTZERO' => $row['count_zero'],
)
);
}
$db->sql_freeresult($result);
$league_info = league_info($season, $league);
$sidename = sprintf($user->lang['STAT_POINTS']);
$template->assign_vars(array(
'S_DISPLAY_STAT_POINTS' => true,
'S_MATCHDAY_HIDE' => true,
'S_SIDENAME' => $sidename,
'S_WIN' => ($league_info['win_matchday'] == '0') ? false : true,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'my_koeff', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['MY_KOEFF']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'stat_results', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['STAT_RESULTS']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_MY_KOEFF']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_STAT_RESULTS']),
'S_DATA_STAT_POINTS' => $data,
'S_DATA_ALL_POINTS' => $data_all,
'SEASON' => $season,
'LEAGUE' => $league,
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data = false;
$data_all = false;
$rank = 0;
$sql = 'SELECT
r.user_id,
u.username,
r.*
FROM ' . FOOTB_RANKS . ' AS r
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
WHERE season = $season
AND league = $league
ORDER BY r.points DESC";
$result = $db->sql_query_limit($sql, 20);
while($row = $db->sql_fetchrow($result))
{
$data = true;
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('top20', array(
'ROW_CLASS' => $row_class,
'NAME' => $row['username'],
'MATCHDAY' => $row['matchday'],
'POINTS' => $row['points'],
'WIN' => $row['win'],
'DIRECTHITS' => $row['correct_result'],
'TENDENCIES' => $row['tendencies'] - $row['correct_result'],
'TOTAL' => $row['tendencies'],
)
);
}
$db->sql_freeresult($result);
$rank = 0;
$sql = 'SELECT
r.user_id,
u.username,
r.*
FROM ' . FOOTB_RANKS . ' AS r
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
WHERE r.season = $season
AND r.league = $league
ORDER BY r.points ASC";
$result = $db->sql_query_limit($sql, 20);
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('flop20', array(
'ROW_CLASS' => $row_class,
'NAME' => $row['username'],
'MATCHDAY' => $row['matchday'],
'POINTS' => $row['points'],
'DIRECTHITS' => $row['correct_result'],
'TENDENCIES' => $row['tendencies'] - $row['correct_result'],
'TOTAL' => $row['tendencies'],
)
);
}
$db->sql_freeresult($result);
$rank = 0;
$sql = 'SELECT
r.user_id,
u.username,
r.*
FROM ' . FOOTB_RANKS . ' AS r
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
WHERE league = $league
ORDER BY r.points DESC";
$result = $db->sql_query_limit($sql, 20);
while($row = $db->sql_fetchrow($result))
{
$data_all = true;
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('alltop20', array(
'ROW_CLASS' => $row_class,
'NAME' => $row['username'],
'SEASON' => $row['season'],
'MATCHDAY' => $row['matchday'],
'POINTS' => $row['points'],
'WIN' => $row['win'],
'DIRECTHITS' => $row['correct_result'],
'TENDENCIES' => $row['tendencies'] - $row['correct_result'],
'TOTAL' => $row['tendencies'],
)
);
}
$db->sql_freeresult($result);
$rank = 0;
$sql = 'SELECT
r.user_id,
u.username,
COUNT(points) AS count_zero
FROM ' . FOOTB_RANKS . ' AS r
LEFT JOIN ' . USERS_TABLE . " AS u ON (u.user_id = r.user_id)
WHERE r.league = $league
AND r.points = 0
GROUP BY r.user_id
ORDER BY count_zero DESC";
$result = $db->sql_query_limit($sql, 20);
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['user_id'] == $user->data['user_id'])
{
$row_class = 'bg3 row_user';
}
$template->assign_block_vars('allflop20', array(
'ROW_CLASS' => $row_class,
'NAME' => $row['username'],
'COUNTZERO' => $row['count_zero'],
)
);
}
$db->sql_freeresult($result);
$league_info = league_info($season, $league);
$sidename = sprintf($user->lang['STAT_POINTS']);
$template->assign_vars(array(
'S_DISPLAY_STAT_POINTS' => true,
'S_MATCHDAY_HIDE' => true,
'S_SIDENAME' => $sidename,
'S_WIN' => ($league_info['win_matchday'] == '0') ? false : true,
'S_DATA_STAT_POINTS' => $data,
'S_DATA_ALL_POINTS' => $data_all,
'SEASON' => $season,
'LEAGUE' => $league,
)
);
?>
+139 -145
View File
@@ -1,146 +1,140 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data = false;
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
$rank = 0;
// Select results and count
$sql = 'SELECT
COUNT(DISTINCT(m.match_no)) AS count_result,
COUNT(m.match_no) AS count_bets,
m.goals_home,
m.goals_guest,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0)
)
) AS hits,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
)
) AS tendencies,
' . select_points('m',true) . '
FROM ' . FOOTB_MATCHES . ' AS m
LEFT JOIN ' . FOOTB_BETS . " AS b ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
WHERE m.season = $season
AND m.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND (m.status IN (3,6))
AND m.matchday <= $matchday
GROUP BY m.goals_home, m.goals_guest
ORDER BY count_bets DESC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$data = true;
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('result', array(
'ROW_CLASS' => $row_class,
'GOALS_HOME' => $row['goals_home'],
'GOALS_GUEST' => $row['goals_guest'],
'RESULTS' => $row['count_result'],
'BETS' => $row['count_bets'],
'HITS' => $row['hits'],
'TENDENCIES' => $row['tendencies'],
'TOTAL' => $row['hits'] + $row['tendencies'],
'POINTS' => $row['points'],
'AVERAGE' => round($row['points'] / $row['count_bets'],1),
)
);
}
$db->sql_freeresult($result);
// Get goaldifferences by team
$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 wins,
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+2), 1, 0), IF((goals_home + 2) < goals_guest, 1, 0))) AS plus3,
SUM(IF((m.team_id_home = t.team_id), IF(goals_home = (goals_guest+2), 1, 0), IF((goals_home + 2) = goals_guest, 1, 0))) AS plus2,
SUM(IF((m.team_id_home = t.team_id), IF(goals_home = (goals_guest+1), 1, 0), IF((goals_home + 1) = goals_guest, 1, 0))) AS plus1,
SUM(IF((m.team_id_home = t.team_id), IF((goals_home + 1) = goals_guest, 1, 0), IF(goals_home = (goals_guest + 1), 1, 0))) AS minus1,
SUM(IF((m.team_id_home = t.team_id), IF((goals_home + 2) = goals_guest, 1, 0), IF(goals_home = (goals_guest + 2), 1, 0))) AS minus2,
SUM(IF((m.team_id_home = t.team_id), IF((goals_home + 2) < goals_guest, 1, 0), IF(goals_home + 0 > (goals_guest + 2), 1, 0))) AS minus3,
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))
WHERE t.season = $season
AND t.league = $league
AND m.season = $season
AND m.league = $league
AND m.status IN (3,6)
AND m.matchday <= $matchday
GROUP BY t.team_id
ORDER BY points DESC, goal_diff DESC, goals DESC";
$result = $db->sql_query($sql);
$rank = 0;
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$template->assign_block_vars('points', array(
'ROW_CLASS' => $row_class,
'RANK' => $rank,
'LOGO' => $logo,
'TEAM' => $row['team_name_short'],
'MATCHES' => $row['matches'],
'PLUS3' => $row['plus3'],
'PLUS2' => $row['plus2'],
'PLUS1' => $row['plus1'],
'DRAW' => $row['draw'],
'MINUS1' => $row['minus1'],
'MINUS2' => $row['minus2'],
'MINUS3' => $row['minus3'],
'GOALS_DIFF' => $row['goal_diff'],
'POINTS' => $row['points'],
)
);
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['STAT_RESULTS']);
$template->assign_vars(array(
'S_DISPLAY_STAT_RESULTS' => true,
'S_SIDENAME' => $sidename,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'stat_points', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['STAT_POINTS']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['BET']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_STAT_POINTS']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_BET']),
'S_DATA_STAT_RESULTS' => $data,
'SEASON' => $season,
'LEAGUE' => $league,
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data = false;
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
$rank = 0;
// Select results and count
$sql = 'SELECT
COUNT(DISTINCT(m.match_no)) AS count_result,
COUNT(m.match_no) AS count_bets,
m.goals_home,
m.goals_guest,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 1, 0)
)
) AS hits,
SUM(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,
IF((b.goals_home = m.goals_home) AND (b.goals_guest = m.goals_guest), 0, 1)
)
) AS tendencies,
' . select_points('m',true) . '
FROM ' . FOOTB_MATCHES . ' AS m
LEFT JOIN ' . FOOTB_BETS . " AS b ON (m.season = b.season AND m.league = b.league AND m.match_no = b.match_no)
WHERE m.season = $season
AND m.league = $league
AND b.goals_home <> ''
AND b.goals_guest <> ''
AND (m.status IN (3,6))
AND m.matchday <= $matchday
GROUP BY m.goals_home, m.goals_guest
ORDER BY count_bets DESC";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$data = true;
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$template->assign_block_vars('result', array(
'ROW_CLASS' => $row_class,
'GOALS_HOME' => $row['goals_home'],
'GOALS_GUEST' => $row['goals_guest'],
'RESULTS' => $row['count_result'],
'BETS' => $row['count_bets'],
'HITS' => $row['hits'],
'TENDENCIES' => $row['tendencies'],
'TOTAL' => $row['hits'] + $row['tendencies'],
'POINTS' => $row['points'],
'AVERAGE' => round($row['points'] / $row['count_bets'],1),
)
);
}
$db->sql_freeresult($result);
// Get goaldifferences by team
$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 wins,
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+2), 1, 0), IF((goals_home + 2) < goals_guest, 1, 0))) AS plus3,
SUM(IF((m.team_id_home = t.team_id), IF(goals_home = (goals_guest+2), 1, 0), IF((goals_home + 2) = goals_guest, 1, 0))) AS plus2,
SUM(IF((m.team_id_home = t.team_id), IF(goals_home = (goals_guest+1), 1, 0), IF((goals_home + 1) = goals_guest, 1, 0))) AS plus1,
SUM(IF((m.team_id_home = t.team_id), IF((goals_home + 1) = goals_guest, 1, 0), IF(goals_home = (goals_guest + 1), 1, 0))) AS minus1,
SUM(IF((m.team_id_home = t.team_id), IF((goals_home + 2) = goals_guest, 1, 0), IF(goals_home = (goals_guest + 2), 1, 0))) AS minus2,
SUM(IF((m.team_id_home = t.team_id), IF((goals_home + 2) < goals_guest, 1, 0), IF(goals_home + 0 > (goals_guest + 2), 1, 0))) AS minus3,
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))
WHERE t.season = $season
AND t.league = $league
AND m.season = $season
AND m.league = $league
AND m.status IN (3,6)
AND m.matchday <= $matchday
GROUP BY t.team_id
ORDER BY points DESC, goal_diff DESC, goals DESC";
$result = $db->sql_query($sql);
$rank = 0;
while($row = $db->sql_fetchrow($result))
{
$rank++;
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
$template->assign_block_vars('points', array(
'ROW_CLASS' => $row_class,
'RANK' => $rank,
'LOGO' => $logo,
'TEAM' => $row['team_name_short'],
'MATCHES' => $row['matches'],
'PLUS3' => $row['plus3'],
'PLUS2' => $row['plus2'],
'PLUS1' => $row['plus1'],
'DRAW' => $row['draw'],
'MINUS1' => $row['minus1'],
'MINUS2' => $row['minus2'],
'MINUS3' => $row['minus3'],
'GOALS_DIFF' => $row['goal_diff'],
'POINTS' => $row['points'],
)
);
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['STAT_RESULTS']);
$template->assign_vars(array(
'S_DISPLAY_STAT_RESULTS' => true,
'S_SIDENAME' => $sidename,
'S_DATA_STAT_RESULTS' => $data,
'SEASON' => $season,
'LEAGUE' => $league,
)
);
?>
+479 -445
View File
@@ -1,446 +1,480 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data_table = false;
$data_form = false;
if ($matchday > 5)
{
$form_from = $matchday - 5;
}
else
{
$form_from = 1;
}
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
$sql = 'SELECT *
FROM ' . FOOTB_LEAGUES . "
WHERE season = $season
AND league = $league";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$league_type = $row['league_type'];
$db->sql_freeresult($result);
$text_form = sprintf($user->lang['TABLE_FORM_FROM'], $form_from);
$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))
)
) - 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,
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.matchday <= $matchday
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();
$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'];
}
$last_group = '';
$rank = 0;
$current_rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
foreach($points_ary as $group_id => $points)
{
$data_table = true;
if ($last_group != $group_id)
{
$last_group =$group_id;
$rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
$template->assign_block_vars('total', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' .$group_id,
)
);
}
foreach($points as $point => $teams)
{
if(count($teams) > 1 AND $group_id != '')
{
// Compare teams with equal points and sort
$teams = get_order_team_compare($teams, $season, $league, $group_id, $ranks_ary, $matchday);
}
foreach($teams as $key => $team)
{
$row = $table_ary[$team];
$rank++;
if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
{
$current_rank = $rank . '.';
}
else
{
$current_rank = '';
}
$last_points = $row['points'];
$last_goals = $row['goals'];
$last_goals_againts = $row['goals_against'];
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['team_symbol'] <> '')
{
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$template->assign_block_vars('total', array(
'RANK' => $current_rank,
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name'],
'TEAM_SHORT' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
'tid' => $row['team_id'], 'mode' => 'played')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
)
);
}
}
}
$db->sql_freeresult($result);
$rank = 0;
// Get form-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.matchday >= $form_from
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);
$last_group = '';
$current_rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
while($row = $db->sql_fetchrow($result))
{
if ($last_group != $row['group_id'])
{
$last_group = $row['group_id'];
$rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
$template->assign_block_vars('form', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$data_form = true;
$rank++;
if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
{
$current_rank = $rank . '.';
}
else
{
$current_rank = '';
}
$last_points = $row['points'];
$last_goals = $row['goals'];
$last_goals_againts = $row['goals_against'];
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['team_symbol'] <> '')
{
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$template->assign_block_vars('form', array(
'RANK' => $current_rank,
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name'],
'TEAM_SHORT' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
'tid' => $row['team_id'], 'mode' => 'rest')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
)
);
}
}
$db->sql_freeresult($result);
$rank = 0;
// Get home-table-information
$sql = 'SELECT
t.*,
SUM(1) AS matches,
SUM(IF(goals_home + 0 > goals_guest, 1, 0)) AS win,
SUM(IF(goals_home = goals_guest, 1, 0)) AS draw,
SUM(IF(goals_home + 0 < goals_guest, 1, 0)) AS lost,
SUM(IF(goals_home + 0 > goals_guest, 3, IF(goals_home = goals_guest, 1, 0))) AS points,
SUM(goals_home - goals_guest) AS goals_diff,
SUM(goals_home) AS goals,
SUM(goals_guest) 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 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)
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);
$last_group = '';
$current_rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
while($row = $db->sql_fetchrow($result))
{
if ($last_group != $row['group_id'])
{
$last_group = $row['group_id'];
$rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
$template->assign_block_vars('home', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$rank++;
if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
{
$current_rank = $rank . '.';
}
else
{
$current_rank = '';
}
$last_points = $row['points'];
$last_goals = $row['goals'];
$last_goals_againts = $row['goals_against'];
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['team_symbol'] <> '')
{
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$template->assign_block_vars('home', array(
'RANK' => $current_rank,
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name'],
'TEAM_SHORT' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
'tid' => $row['team_id'], 'mode' => 'home')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
)
);
}
}
$db->sql_freeresult($result);
$rank = 0;
// Get away-table-information
$sql = 'SELECT
t.*,
SUM(1) AS matches,
SUM(IF(goals_home + 0 < goals_guest, 1, 0)) AS win,
SUM(IF(goals_home = goals_guest, 1, 0)) AS draw,
SUM(IF(goals_home + 0 > goals_guest, 1, 0)) AS lost,
SUM(IF(goals_home + 0 < goals_guest, 3, IF(goals_home = goals_guest, 1, 0))) AS points,
SUM(goals_guest - goals_home) AS goals_diff,
SUM(goals_guest) AS goals,
SUM(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_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)
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);
$last_group = '';
$current_rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
while($row = $db->sql_fetchrow($result))
{
if ($last_group != $row['group_id'])
{
$last_group = $row['group_id'];
$rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
$template->assign_block_vars('away', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$rank++;
if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
{
$current_rank = $rank . '.';
}
else
{
$current_rank = '';
}
$last_points = $row['points'];
$last_goals = $row['goals'];
$last_goals_againts = $row['goals_against'];
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['team_symbol'] <> '')
{
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$template->assign_block_vars('away', array(
'RANK' => $current_rank,
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name'],
'TEAM_SHORT' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
'tid' => $row['team_id'], 'mode' => 'away')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'POINTS' => $row['points'],
)
);
}
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['TABLE']);
$template->assign_vars(array(
'S_DISPLAY_TABLE' => true,
'S_SIDENAME' => $sidename,
'U_LEFT' => $this->helper->route('football_main_controller', array('side' => 'results', 's' => $season, 'l' => $league, 'm' => $matchday)),
'LEFT_LINK' => '&lt; ' . sprintf($user->lang['RESULTS']),
'U_RIGHT' => $this->helper->route('football_main_controller', array('side' => 'ranks_matchday', 's' => $season, 'l' => $league, 'm' => $matchday)),
'RIGHT_LINK' => sprintf($user->lang['RANK_MATCHDAY']) . ' &gt;',
'LEFT_TITLE' => sprintf($user->lang['TITLE_RESULTS']),
'RIGHT_TITLE' => sprintf($user->lang['TITLE_RANK_MATCHDAY']),
'S_DATA_TABLE' => $data_table,
'S_DATA_FORM' => $data_form,
'SEASON' => $season,
'LEAGUE' => $league,
'TEXT_FORM' => $text_form,
)
);
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
if (!defined('IN_PHPBB') OR !defined('IN_FOOTBALL'))
{
exit;
}
$data_table = false;
$data_form = false;
if ($matchday > 5)
{
$form_from = $matchday - 5;
}
else
{
$form_from = 1;
}
$ext_path = $this->phpbb_path_helper->update_web_root_path($this->phpbb_extension_manager->get_extension_path('football/football', true));
$sql = 'SELECT *
FROM ' . FOOTB_LEAGUES . "
WHERE season = $season
AND league = $league";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$league_type = $row['league_type'];
$db->sql_freeresult($result);
$text_form = sprintf($user->lang['TABLE_FORM_FROM'], $form_from);
$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)))
+ IFNULL((SELECT SUM(c.win) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday),0)AS win,
SUM(IF(goals_home = goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.draw) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday),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)))
+ IFNULL((SELECT SUM(c.lost) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday),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))
)
) + IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND b.matchday <= $matchday), 0)
+ IFNULL((SELECT SUM(c.points) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday),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,
SUM(IF(m.team_id_home = t.team_id, goals_guest , goals_home)) AS goals_against,
IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND b.matchday <= $matchday), 0) AS bonus
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.show_table = 0
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();
$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'];
}
$last_group = '';
$rank = 0;
$current_rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
foreach($points_ary as $group_id => $points)
{
$data_table = true;
if ($last_group != $group_id)
{
$last_group =$group_id;
$rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
$template->assign_block_vars('total', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' .$group_id,
)
);
}
foreach($points as $point => $teams)
{
if(count($teams) > 1 AND $group_id != '')
{
// Compare teams with equal points and sort
$teams = get_order_team_compare($teams, $season, $league, $group_id, $ranks_ary, $matchday);
}
foreach($teams as $key => $team)
{
$row = $table_ary[$team];
$rank++;
if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
{
$current_rank = $rank . '.';
}
else
{
$current_rank = '';
}
$last_points = $row['points'];
$last_goals = $row['goals'];
$last_goals_againts = $row['goals_against'];
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['team_symbol'] <> '')
{
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$template->assign_block_vars('total', array(
'RANK' => $current_rank,
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name'],
'TEAM_SHORT' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
'tid' => $row['team_id'], 'mode' => 'played')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'BONUS' => round($row['bonus'],2),
'POINTS' => round($row['points'],2),
)
);
}
}
}
$db->sql_freeresult($result);
$rank = 0;
// Get form-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)))
+ IFNULL((SELECT SUM(c.win) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.matchday >= $form_from),0)AS win,
SUM(IF(goals_home = goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.draw) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.matchday >= $form_from),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)))
+ IFNULL((SELECT SUM(c.lost) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.matchday >= $form_from),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))
)
) + IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND b.matchday <= $matchday AND b.matchday >= $form_from),0)
+ IFNULL((SELECT SUM(c.points) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.matchday >= $form_from),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,
SUM(IF(m.team_id_home = t.team_id, goals_guest , goals_home)) AS goals_against,
IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND b.matchday <= $matchday AND b.matchday >= $form_from),0) AS bonus
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 >= $form_from
AND m.status IN (2, 3,5,6)
AND m.show_table = 0
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);
$last_group = '';
$current_rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
while($row = $db->sql_fetchrow($result))
{
if ($last_group != $row['group_id'])
{
$last_group = $row['group_id'];
$rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
$template->assign_block_vars('form', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$data_form = true;
$rank++;
if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
{
$current_rank = $rank . '.';
}
else
{
$current_rank = '';
}
$last_points = $row['points'];
$last_goals = $row['goals'];
$last_goals_againts = $row['goals_against'];
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['team_symbol'] <> '')
{
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$template->assign_block_vars('form', array(
'RANK' => $current_rank,
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name'],
'TEAM_SHORT' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
'tid' => $row['team_id'], 'mode' => 'rest')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'BONUS' => round($row['bonus'],2),
'POINTS' => round($row['points'],2),
)
);
}
}
$db->sql_freeresult($result);
$rank = 0;
// Get home-table-information
$sql = "SELECT
t.*,
SUM(1) AS matches,
SUM(IF(goals_home + 0 > goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.win) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 1 ),0)AS win,
SUM(IF(goals_home = goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.draw) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 1 ),0)AS draw,
SUM(IF(goals_home + 0 < goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.lost) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 1 ),0)AS lost,
SUM(IF(goals_home + 0 > goals_guest, 3, IF(goals_home = goals_guest, 1, 0)))+ IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND b.matchday <= $matchday AND home = '1'),0)
+ IFNULL((SELECT SUM(c.points) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 1 ),0)AS points,
SUM(goals_home - goals_guest) AS goals_diff,
SUM(goals_home) AS goals,
SUM(goals_guest) AS goals_against,
IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND home = '1'),0) AS bonus
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 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.show_table = 0
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);
$last_group = '';
$current_rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
while($row = $db->sql_fetchrow($result))
{
if ($last_group != $row['group_id'])
{
$last_group = $row['group_id'];
$rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
$template->assign_block_vars('home', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$rank++;
if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
{
$current_rank = $rank . '.';
}
else
{
$current_rank = '';
}
$last_points = $row['points'];
$last_goals = $row['goals'];
$last_goals_againts = $row['goals_against'];
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['team_symbol'] <> '')
{
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$template->assign_block_vars('home', array(
'RANK' => $current_rank,
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name'],
'TEAM_SHORT' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
'tid' => $row['team_id'], 'mode' => 'home')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'BONUS' => round($row['bonus'],2),
'POINTS' => round($row['points'],2),
)
);
}
}
$db->sql_freeresult($result);
$rank = 0;
// Get away-table-information
$sql = "SELECT
t.*,
SUM(1) AS matches,
SUM(IF(goals_home + 0 < goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.win) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 0 ),0)AS win,
SUM(IF(goals_home = goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.draw) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 0 ),0)AS draw,
SUM(IF(goals_home + 0 > goals_guest, 1, 0))
+ IFNULL((SELECT SUM(c.lost) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 0 ),0)AS lost,
SUM(IF(goals_home + 0 < goals_guest, 3, IF(goals_home = goals_guest, 1, 0))) + IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND b.matchday <= $matchday AND home = '0'),0)
+ IFNULL((SELECT SUM(c.points) FROM " . FOOTB_CORR . " AS c WHERE c.team_id = t.team_id AND c.season = t.season AND c.league = t.league AND c.matchday <= $matchday AND c.home = 0 ),0)AS points,
SUM(goals_guest - goals_home) AS goals_diff,
SUM(goals_guest) AS goals,
SUM(goals_home) AS goals_against,
IFNULL((SELECT SUM(b.bonuspoints) FROM " . FOOTB_BONUS_DAY . " AS b WHERE b.team_id = t.team_id AND b.season = t.season AND b.league = t.league AND home = '0'),0) AS bonus
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_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.show_table = 0
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);
$last_group = '';
$current_rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
while($row = $db->sql_fetchrow($result))
{
if ($last_group != $row['group_id'])
{
$last_group = $row['group_id'];
$rank = 0;
$last_goals = 0;
$last_goals_againts = 0;
$last_points = 0;
$template->assign_block_vars('away', array(
'GROUP' => sprintf($user->lang['GROUP']) . ' ' . $row['group_id'],
)
);
}
if ($league_type != 2 OR $row['group_id'] != '')
{
$rank++;
if ($last_points <> $row['points'] OR $last_goals <> $row['goals'] OR $last_goals_againts <> $row['goals_against'])
{
$current_rank = $rank . '.';
}
else
{
$current_rank = '';
}
$last_points = $row['points'];
$last_goals = $row['goals'];
$last_goals_againts = $row['goals_against'];
$row_class = (!($rank % 2)) ? 'bg1 row_light' : 'bg2 row_dark';
if ($row['team_symbol'] <> '')
{
$logo = "<img src=\"" . $ext_path . 'images/flags/' . $row['team_symbol'] . "\" alt=\"" . $row['team_symbol'] . "\" width=\"28\" height=\"28\"/>" ;
}
else
{
$logo = "<img src=\"" . $ext_path . "images/flags/blank.gif\" alt=\"\" width=\"28\" height=\"28\"/>" ;
}
$template->assign_block_vars('away', array(
'RANK' => $current_rank,
'ROW_CLASS' => $row_class,
'LOGO' => $logo,
'TEAM_ID' => $row['team_id'],
'TEAM' => $row['team_name'],
'TEAM_SHORT' => $row['team_name_short'],
'U_PLAN_TEAM' => $this->helper->route('football_football_popup', array('popside' => 'viewplan_popup', 's' => $season, 'l' => $row['league'],
'tid' => $row['team_id'], 'mode' => 'away')),
'GAMES' => $row['matches'],
'WIN' => $row['win'],
'DRAW' => $row['draw'],
'LOST' => $row['lost'],
'GOALS' => $row['goals'],
'GOALS_AGAINST' => $row['goals_against'],
'GOALS_DIFF' => $row['goals_diff'],
'BONUS' => round($row['bonus'],2),
'POINTS' => round($row['points'],2),
)
);
}
}
if($league > 50)
{
// Activate bonus coloumn only for tippers.
$data_bns = true;
}
if($side == 'table') {
$display_table_menu = true;
}
$db->sql_freeresult($result);
$sidename = sprintf($user->lang['TABLE']);
$template->assign_vars(array(
'S_DISPLAY_TABLE' => true,
'S_DISPLAY_TABLE_MENU' => $display_table_menu,
'S_SIDENAME' => $sidename,
'S_DATA_TABLE' => $data_table,
'S_DATA_FORM' => $data_form,
'SEASON' => $season,
'LEAGUE' => $league,
'TEXT_FORM' => $text_form,
'S_DATA_BNS' => $data_bns,
)
);
?>
+4 -4
View File
@@ -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.6",
"time": "2016-05-29",
"version": "0.9.9",
"time": "2017-09-09",
"license": "GPL-2.0",
"authors": [{
"name": "J. Helmke",
@@ -18,7 +18,7 @@
"extra": {
"display-name": "Football Prediction League",
"soft-require": {
"phpbb/phpbb": "3.1.*"
"phpbb/phpbb": ">3.1.*"
},
"version-check": {
"host": "football.bplaced.net",
+52 -52
View File
@@ -12,46 +12,46 @@ services:
football.football.controller:
class: football\football\controller\main
arguments:
- @auth
- @config
- @ext.manager
- @notification_manager
- @log
- @path_helper
- @dbal.conn
- @controller.helper
- @template
- @user
- @pagination
- '@auth'
- '@config'
- '@ext.manager'
- '@notification_manager'
- '@log'
- '@path_helper'
- '@dbal.conn'
- '@controller.helper'
- '@template'
- '@user'
- '@pagination'
- %core.root_path%
- %core.php_ext%
football.football.controller_popup:
class: football\football\controller\popup
arguments:
- @auth
- @config
- @ext.manager
- @path_helper
- @dbal.conn
- @controller.helper
- @template
- @user
- @pagination
- '@auth'
- '@config'
- '@ext.manager'
- '@path_helper'
- '@dbal.conn'
- '@controller.helper'
- '@template'
- '@user'
- '@pagination'
- %core.root_path%
- %core.php_ext%
football.football.controller_download:
class: football\football\controller\download
arguments:
- @auth
- @config
- @ext.manager
- @path_helper
- @dbal.conn
- @controller.helper
- @template
- @user
- '@auth'
- '@config'
- '@ext.manager'
- '@path_helper'
- '@dbal.conn'
- '@controller.helper'
- '@template'
- '@user'
- %core.root_path%
- %core.php_ext%
@@ -60,38 +60,38 @@ services:
scope: prototype
arguments:
- %football.version_data%
- @config
- @version_helper
- @template
- @user
- '@config'
- '@version_helper'
- '@template'
- '@user'
football.football.controller_xml:
class: football\football\controller\xmlplan
arguments:
- @config
- @ext.manager
- @path_helper
- @dbal.conn
- @user
- '@config'
- '@ext.manager'
- '@path_helper'
- '@dbal.conn'
- '@user'
- %core.root_path%
- %core.php_ext%
football.football.core.functions.points:
class: football\football\core\functions_points
arguments:
- @user
- @dbal.conn
- '@user'
- '@dbal.conn'
football.football.listener:
class: football\football\event\main_listener
arguments:
- @auth
- @config
- @controller.helper
- @template
- @path_helper
- @ext.manager
- @user
- '@auth'
- '@config'
- '@controller.helper'
- '@template'
- '@path_helper'
- '@ext.manager'
- '@user'
- %core.root_path%
- %core.php_ext%
tags:
@@ -102,12 +102,12 @@ services:
arguments:
- %core.root_path%
- %core.php_ext%
- @ext.manager
- @path_helper
- @dbal.conn
- @config
- @log
- @user
- '@ext.manager'
- '@path_helper'
- '@dbal.conn'
- '@config'
- '@log'
- '@user'
calls:
- [set_name, [football.football.cron.task.football_remember]]
tags:
+62 -17
View File
@@ -308,8 +308,8 @@ class main
$user_id = $user->data['user_id'];
$sql = 'SELECT * FROM ' . FOOTB_MATCHES . " WHERE season = $season AND league = $league AND matchday = $matchday AND status <= 0";
$resultopen = $db->sql_query($sql);
$rows = $db->sql_fetchrowset($resultopen);
$db->sql_freeresult($resultopen);
$count_matches = 0;
$count_updates = 0;
@@ -419,7 +419,6 @@ class main
{
$dbmsg = sprintf($user->lang['NO_BETS_SAVED']);
}
$db->sql_freeresult($resultopen);
// extra bets
$sql = 'SELECT * FROM ' . FOOTB_EXTRA . " WHERE season = $season AND league = $league AND matchday = $matchday AND extra_status <= 0";
@@ -479,6 +478,7 @@ class main
}
}
}
$db->sql_freeresult($resultextra);
if ($count_extra_updates)
{
$dbmsg = $dbmsg . ' ' . sprintf($user->lang['EXTRA_BET' . (($count_extra_updates == 1) ? '' : 'S') . '_SAVED'], $count_extra_updates);
@@ -725,12 +725,16 @@ class main
}
}
}
$db->sql_freeresult($resultextra);
if ($count_extra_updates)
{
$dbmsg = $dbmsg . ' ' . sprintf($user->lang['EXTRA_RESULT' . (($count_extra_updates == 1) ? '' : 'S') . '_SAVED'], $count_extra_updates);
}
calculate_extra_points($season, $league, $matchday);
save_ranking_matchday($season, $league, $matchday);
bonuspoints($season, $league, $matchday);
corr($season, $league, $matchday);
chart($season, $league, $matchday);
break;
case 'join':
join_league($season, $league, $user->data['user_id']);
@@ -781,19 +785,48 @@ class main
}
$league_name = '';
$sql = 'SELECT * FROM ' . FOOTB_LEAGUES . " WHERE season = $season AND league_type >= 1";
if ($side == 'table' OR $side == 'results_tl')
{
$sql = 'SELECT * FROM ' . FOOTB_LEAGUES . " WHERE season = $season AND league_type >= 1 AND (league >= 50 OR bet_type = 1) ORDER BY sort ASC";
}
else
{
$sql = 'SELECT * FROM ' . FOOTB_LEAGUES . " WHERE season = $season AND league_type >= 1 AND league < 50";
}
$result = $db->sql_query($sql);
while( $row = $db->sql_fetchrow($result))
{
$selected = ($league && $row['league'] == $league) ? ' selected="selected"' : '';
$selected = ($league && $row['league'] == $league) ? ' selected="selected"' : '';
if ($side == 'table' && $league_info['bet_type'])
{
$side = 'ranks_total';
}
elseif ($side == 'ranks_total' && !$league_info['bet_type'])
{
$side = 'table';
}
elseif ($side == 'table' OR $side == 'results_tl')
{
if ($league < 51)
{
$league = $league + 50;
}
}
else
{
if ($league > 50)
{
$league = $league - 50;
}
}
if ($selected)
{
$league_name = $row['league_name'];
}
$template->assign_block_vars('form_league', array(
'S_LEAGUE' => $row['league'],
'S_LEAGUENAME' => $row['league_name'],
'S_SELECTED' => $selected
'S_LEAGUENAME' => $row['league_name'],
'S_SELECTED' => $selected
)
);
}
@@ -823,7 +856,7 @@ class main
$league_type = $row['league_type'];
$db->sql_freeresult($result);
$lang_dates = $user->lang['datetime'];
$local_board_time = time() + (($config['board_timezone'] - $config['football_host_timezone']) * 3600);
$local_board_time = time() + ($config['football_time_shift'] * 3600);
$sql = "SELECT *,
CONCAT(
CASE DATE_FORMAT(delivery_date,'%w')
@@ -904,7 +937,7 @@ class main
// Start matchday list
if ($side == 'bet')
{
include($this->football_root_path . 'block/side_table.' . $this->php_ext);
}
else
{
@@ -914,18 +947,18 @@ class main
//*****************************************************************************
// Start total list
include($this->football_root_path . 'block/rank_total.' . $this->php_ext);
// End total list
//*****************************************************************************
// Start delivery list
include($this->football_root_path . 'block/delivery.' . $this->php_ext);
// End delivery list
//*****************************************************************************
}
if ($side == 'bet')
{
include($this->football_root_path . 'block/table.' . $this->php_ext);
}
// Start assign vars
$sql_ary = array(
'football_season' => (int) $season,
@@ -977,8 +1010,9 @@ class main
'S_NEXT_CLASS' => $next_class,
'S_NEXT_DEADLINE' => $next_deadline,
'S_DBMSG' => $dbmsg,
'FOOTBALL_LEFT_COLUMN' => $config['football_left_column_width'],
'FOOTBALL_RIGHT_COLUMN' => $config['football_right_column_width'],
'FOOTBALL_LEFT_COLUMN' => $config['football_left_column_width'],
'FOOTBALL_RIGHT_COLUMN' => $config['football_right_column_width'],
'S_BET_TYPE' => $league_info['bet_type'],
));
// End assign vars
@@ -988,6 +1022,10 @@ class main
{
include($this->football_root_path . 'block/under_construction.' . $this->php_ext);
}
elseif ($side == 'results_tl')
{
include($this->football_root_path . 'block/results.' . $this->php_ext);
}
else
{
include($this->football_root_path . 'block/' . $side . '.' . $this->php_ext);
@@ -1000,7 +1038,14 @@ class main
else
{
$mobile = '';
include($this->football_root_path . 'block/last_users.' . $this->php_ext);
if ($config['football_display_last_users'] > 0)
{
include($this->football_root_path . 'block/last_users.' . $this->php_ext);
}
if ($config['football_display_last_results'] > 0)
{
include($this->football_root_path . 'block/last_results.' . $this->php_ext);
}
}
// Send data to the template file
if ($view == 'print')
+335 -333
View File
@@ -1,334 +1,336 @@
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\cron\task;
class football_remember extends \phpbb\cron\task\base
{
/* @var string phpBB root path */
protected $root_path;
/* @var string phpEx */
protected $php_ext;
/* @var \phpbb\extension\manager */
protected $phpbb_extension_manager;
/* @var \phpbb\path_helper */
protected $phpbb_path_helper;
/* @var \phpbb\db\driver\driver_interface */
protected $db;
/* @var \phpbb\config\config */
protected $config;
/* @var \phpbb\log\log_interface */
protected $log;
/* @var \phpbb\user */
protected $user;
/**
* Constructor
*
* @param string $root_path
* @param string $php_ext
* @param \phpbb\extension\manager $phpbb_extension_manager
* @param \phpbb\path_helper $phpbb_path_helper
* @param \phpbb\db\driver\driver_interfacer $db
* @param \phpbb\config\config $config
* @param \phpbb\log\log_interface $log
* @param \phpbb\user $user
*/
public function __construct($root_path, $php_ext, \phpbb\extension\manager $phpbb_extension_manager, \phpbb\path_helper $phpbb_path_helper, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\log\log_interface $log, \phpbb\user $user)
{
$this->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 = '<strong>' . sprintf($this->user->lang['FOOTBALL_REMEMBER_ERROR_EMAIL'], $league_short, $row['user_email']) . '</strong>';
$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 = '<strong>' . sprintf($this->user->lang['FOOTBALL_REMEMBER_ERROR_EMAIL'], $league_short, $row['user_email']) . '</strong>';
$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 = '<strong>' . sprintf($this->user->lang['FOOTBALL_REMEMBER_ERROR_EMAIL_BOARD'], $league_short, $this->config['board_email']) . '</strong>';
$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;
}
}
}
<?php
/**
*
* @package phpBB Extension - Football Football
* @copyright (c) 2016 football (http://football.bplaced.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace football\football\cron\task;
class football_remember extends \phpbb\cron\task\base
{
/* @var string phpBB root path */
protected $root_path;
/* @var string phpEx */
protected $php_ext;
/* @var \phpbb\extension\manager */
protected $phpbb_extension_manager;
/* @var \phpbb\path_helper */
protected $phpbb_path_helper;
/* @var \phpbb\db\driver\driver_interface */
protected $db;
/* @var \phpbb\config\config */
protected $config;
/* @var \phpbb\log\log_interface */
protected $log;
/* @var \phpbb\user */
protected $user;
/**
* Constructor
*
* @param string $root_path
* @param string $php_ext
* @param \phpbb\extension\manager $phpbb_extension_manager
* @param \phpbb\path_helper $phpbb_path_helper
* @param \phpbb\db\driver\driver_interfacer $db
* @param \phpbb\config\config $config
* @param \phpbb\log\log_interface $log
* @param \phpbb\user $user
*/
public function __construct($root_path, $php_ext, \phpbb\extension\manager $phpbb_extension_manager, \phpbb\path_helper $phpbb_path_helper, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\log\log_interface $log, \phpbb\user $user)
{
$this->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 = '<strong>' . sprintf($this->user->lang['FOOTBALL_REMEMBER_ERROR_EMAIL'], $league_short, $row['user_email']) . '</strong>';
$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 = '<strong>' . sprintf($this->user->lang['FOOTBALL_REMEMBER_ERROR_EMAIL'], $league_short, $row['user_email']) . '</strong>';
$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 = '<strong>' . sprintf($this->user->lang['FOOTBALL_REMEMBER_ERROR_EMAIL_BOARD'], $league_short, $this->config['board_email']) . '</strong>';
$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;
}
}
}
?>
+550 -551
View File
File diff suppressed because one or more lines are too long
Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Some files were not shown because too many files have changed in this diff Show More