示例#1
0
function listMarksBinds($l)
{
    $lmb = array();
    $l = forceArray($l);
    $listMarks = array();
    for ($i = 0; $i < count($l); $i++) {
        array_push($listMarks, "?");
    }
    $lmb["marks"] = implode(",", $listMarks);
    $lmb["binds"] = str_repeat("i", count($l));
    return $lmb;
}
示例#2
0
文件: save.php 项目: joomux/jTips
<?php

if (!defined('_JEXEC') and !defined('_VALID_MOS')) {
    die('Restricted Access');
}
/**
 * Author: Jeremy Roberts
 * Package: jTicket
 * Website: www.jtips.com.au
 * Created: 30/09/2008
 * 
 * Description: Saves the User Preferences
 */
global $database, $Itemid;
$jTipsUsers = new jTipsUser($database);
$jTipsUserParams = array('user_id' => jTipsGetParam($_REQUEST, 'id', 0));
$jTipsUserArr = forceArray($jTipsUsers->loadByParams($jTipsUserParams));
foreach ($jTipsUserArr as $jTipsUser) {
    $jTipsUser->setPreference('default_season', jTipsGetParam($_REQUEST, 'default_season', -1));
    $jTipsUser->setPreference('timezone', jTipsGetParam($_REQUEST, 'timezone', null));
    $jTipsUser->setPreference('email_reminder', jTipsGetParam($_REQUEST, 'email_reminder', '0'));
    $jTipsUser->setPreference('tips_notifications', jTipsGetParam($_REQUEST, 'tips_notifications', '0'));
}
$return_view = jTipsGetParam($_REQUEST, 'return', 'Dashboard');
if (!$return_view) {
    $return_view = 'Dashboard';
}
jTipsRedirect('index.php?option=com_jtips&view=' . jTipsGetParam($_REQUEST, 'return', 'Dashboard') . '&Itemid=' . $Itemid . '&season=' . getSeasonID());
示例#3
0
$jtips_params = array('name' => trim($season_name));
$jSeason = new jSeason($database);
$jSeason->loadByParams($jtips_params);
if (isset($jSeason->id) and !empty($jSeason->id)) {
    //parse the info here
    $hasData = true;
    $round_id = $jSeason->getCurrentRound();
    $jRound = new jRound($database);
    if (!$round_id) {
        $hasData = false;
    } else {
        $jRound->load($round_id);
    }
    $data = array('round_id' => $round_id);
    $game = new jGame($database);
    $jGames = forceArray($game->loadByParams($data));
    if (empty($jGames)) {
        $hasData = false;
    }
    if ($hasData) {
        if ($jSeason->tips_layout == 'away') {
            $left = 'away';
            $right = 'home';
        } else {
            $left = 'home';
            $right = 'away';
        }
        if ($params->get('showseason')) {
            ?>
		    <h4 style="text-align:center;"><?php 
            echo $jSeason->name;
示例#4
0
<?php

defined('_JEXEC') or defined('_VALID_MOS') or die('Restricted Access');
/**
 * Website: www.jtips.com.au
 * @author Jeremy Roberts
 * @copyright Copyright &copy; 2009, jTips
 * @license Commercial - See website for details
 * 
 * @since 2.1 - 07/10/2008
 * @version 2.1
 * @package jTips
 * 
 * Description: Load a JSON encoded array of teams
 */
global $database, $mosConfig_absolute_path;
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jteam.class.php';
ob_clean();
if ($season_id = jTipsGetParam($_REQUEST, 'season_id', false)) {
    $params = array('season_id' => $season_id, 'order' => array('type' => 'order', 'by' => 'name', 'direction' => 'ASC'));
    $jTeam = new jTeam($database);
    $jTeams = forceArray($jTeam->loadByParams($params));
    die(@json_encode($jTeams));
} else {
    die(json_encode(false));
}
示例#5
0
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jround.class.php';
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jseason.class.php';
$element_id = jTipsGetParam($_REQUEST, 'element', '');
$season_id = jTipsGetParam($_REQUEST, 'season_id', null);
$preselected = jTipsGetParam($_REQUEST, 'round_id', false);
if (empty($season_id) or !isset($preselected)) {
    $js = "document.getElementById('{$element_id}').length = 0;\n";
    $js .= "document.getElementById('{$element_id}').options[0] = new Option('--None--', '-1');\n";
    die($js . "document.getElementById('{$element_id}').disabled = true;");
}
$jSeason = new jSeason($database);
$jSeason->load($season_id);
$curr = $jSeason->getLatestRound();
$jRound = new jRound($database);
$parameters = array('season_id' => $season_id, 'scored' => 1);
$jRounds = forceArray($jRound->loadByParams($parameters));
$js = "document.getElementById('{$element_id}').length = 0;\n";
$selected = 0;
$roundsArr = array();
for ($i = 0; $i < count($jRounds); $i++) {
    if ($jRounds[$i]->id == $curr and !$preselected) {
        $selected = $i;
    }
    $js .= "document.getElementById('{$element_id}').options[{$i}] = new Option('" . $jRounds[$i]->round . "', '" . $jRounds[$i]->id . "');\n";
    $roundsArr[$jRounds[$i]->id] = $i;
}
if ($preselected and isset($roundsArr[$preselected])) {
    $selected = $roundsArr[$preselected];
}
if (!empty($roundsArr)) {
    $js .= "document.getElementById('{$element_id}').disabled = false;\n";
示例#6
0
function submitPractice($conn, $userID, $cr, $incr)
{
    $cr = arrayTypeInt(forceArray($cr));
    $incr = arrayTypeInt(forceArray($incr));
    $allcrin = array_merge($cr, $incr);
    $wlmb = listMarksBinds($allcrin);
    $sql = "INSERT INTO UserWordStep (WordID, UserID) \n  SELECT DISTINCT w.ID,? FROM Words w \n  WHERE w.ID IN (%AllWords%) AND w.ID NOT IN (\n      SELECT DISTINCT w.ID FROM Words w \n      INNER JOIN UserWordStep uws ON uws.WordID=w.ID AND uws.UserID = ?\n      WHERE w.ID IN (%AllWords%) )";
    $sql = str_ireplace("%AllWords%", $wlmb["marks"], $sql);
    $binds = 'i' . $wlmb["binds"] . 'i' . $wlmb["binds"];
    $args = array();
    $args = array_merge(array($conn, $sql, $binds, $userID), $allcrin, array($userID), $allcrin);
    if (call_user_func_array('modifyRows', $args)) {
        $sqlcr = "UPDATE UserWordStep SET Step=Step+1, LastCheckTime=CURRENT_TIMESTAMP WHERE UserID=? AND WordID IN (%Corrects%)";
        $sqlincr = "UPDATE UserWordStep SET Step=1, LastCheckTime=CURRENT_TIMESTAMP WHERE UserID=? AND WordID IN (%InCorrects%)";
        $crres = false;
        $incrres = false;
        if (count($cr) > 0) {
            $crlmb = listMarksBinds($cr);
            $sqlcr = str_ireplace("%Corrects%", $crlmb["marks"], $sqlcr);
            $binds = 'i' . $crlmb["binds"];
            $args = array();
            $args = array_merge(array($conn, $sqlcr, $binds, $userID), $cr);
            if (call_user_func_array('modifyRows', $args)) {
                $crres = true;
            }
        } else {
            $crres = true;
        }
        if (count($incr) > 0) {
            $incrlmb = listMarksBinds($incr);
            $sqlincr = str_ireplace("%InCorrects%", $incrlmb["marks"], $sqlincr);
            $binds = 'i' . $incrlmb["binds"];
            $args = array();
            $args = array_merge(array($conn, $sqlincr, $binds, $userID), $incr);
            if (call_user_func_array('modifyRows', $args)) {
                $incrres = true;
            }
        } else {
            $incrres = true;
        }
        return $crres && $incrres;
    }
    return false;
}
示例#7
0
<?php

defined('_JEXEC') or defined('_VALID_MOS') or die('Restricted Access');
/**
 * Website: www.jtips.com.au
 * @author Jeremy Roberts
 * @copyright Copyright &copy; 2009, jTips
 * @license Commercial - See website for details
 * 
 * @since 2.1 - 07/10/2008
 * @version 2.1
 * @package jTips
 * 
 * Description: Load a JSON encoded string of game objects for the passed in round
 */
//Can't do this here since this script is loaded with ajax
//jTipsSpoofCheck();
global $database;
require_once 'components/com_jtips/classes/jgame.class.php';
ob_clean();
//ob_start();
if ($round_id = jTipsGetParam($_REQUEST, 'round_id', false)) {
    $jGame = new jGame($database);
    $params = array('round_id' => $round_id, 'order' => array('type' => 'order', 'by' => 'position', 'direction' => 'asc'));
    $jGames = forceArray($jGame->loadByParams($params));
    die(@json_encode($jGames));
} else {
    die(json_encode(false));
}
示例#8
0
 function destroy($id = false)
 {
     if ($id == FALSE) {
         $id = $this->id;
     }
     jTipsLogger::_log("Delete " . $this->_tbl . " record with id = '{$id}'");
     //delete all history records for this user and season
     if (!$this->id) {
         $this->load($id);
     }
     // BUG 129 - Unsubscribing from season leaves history
     $params = array('user_id' => $id);
     //deleting history etc can take a while, so dont time out
     set_time_limit(0);
     $jHistory = new jHistory($this->_db);
     $jHistories = forceArray($jHistory->loadByParams($params));
     jTipsLogger::_log('Found ' . count($jHistories) . ' history records for user ' . $id, 'INFO');
     if (is_array($jHistories) and !empty($jHistories)) {
         foreach ($jHistories as $jHist) {
             jTipsLogger::_log('deleting history record', 'INFO');
             $jHist->destroy();
         }
     }
     //reset outof and ranks for remaining users
     //get the rounds to be updated firs
     $query = "SELECT id FROM #__jtips_rounds WHERE season_id = '" . $this->season_id . "' AND scored = 1";
     $this->_db->setQuery($query);
     $rids = $this->_db->loadResultArray();
     //die(implode(", ", $rids));
     if (!empty($rids)) {
         foreach ($rids as $r) {
             $jHistory->setRanks($r);
         }
     }
     //Now delete the tips
     $tip = new jTip($this->_db);
     $tips = forceArray($tip->loadByParams($params));
     if (!empty($tips)) {
         foreach ($tips as $t) {
             $t->destroy();
         }
     }
     // BUG 402 - need to also delete any comments made
     $comment = new jComment($this->_db);
     $comments = $comment->loadByParams($params);
     if (!empty($comments)) {
         foreach ($comments as $c) {
             $c->destroy();
         }
     }
     return $this->delete($id);
 }
示例#9
0
 function getCommentLadder($num_to_show, $round_id, $page, $dir)
 {
     global $database;
     $jComment = new jComment($database);
     $params = array('#__jtips_history.round_id' => $round_id, 'join_jtips_users' => array('type' => 'join', 'join_table' => '#__jtips_users', 'lhs_table' => '#__jtips_history', 'lhs_key' => 'user_id', 'rhs_table' => '#__jtips_users', 'rhs_key' => 'id'), 'join_users' => array('type' => 'join', 'join_table' => '#__users', 'lhs_table' => '#__jtips_users', 'lhs_key' => 'user_id', 'rhs_table' => '#__users', 'rhs_key' => 'id'), 'left_join_comments' => array('type' => 'left_join', 'join_table' => '#__jtips_comments', 'lhs_table' => '#__jtips_history', 'rhs_table' => '#__jtips_comments', 'lhs_key' => 'round_id', 'rhs_key' => 'round_id', 'supplement' => 'AND #__jtips_history.user_id = #__jtips_comments.user_id'), 'o1' => array('type' => 'order', 'by' => 'comment', 'direction' => $dir));
     $offset = $page * $num_to_show;
     $jHistories = forceArray($this->loadByParams($params, $num_to_show, $offset));
     $users = array();
     foreach ($jHistories as $jc) {
         $jTipsUser = new jTipsUser($database);
         $jTipsUser->load($jc->user_id);
         array_push($users, $jTipsUser);
     }
     return $users;
 }
示例#10
0
文件: list.php 项目: joomux/jTips
global $database, $jTips;
require_once 'components/com_jtips/classes/jbadword.class.php';
$formData = array('title' => $jLang['_ADMIN_BW_HEADER'], 'editTask' => 'edit', 'module' => 'BadWords', 'icon' => 'badwords');
$currentDir = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc');
if ($currentDir == 'asc') {
    $dir = 'desc';
} else {
    $dir = 'asc';
}
//The header row
$header = array('', "<a href='javascript:tableOrdering(\"badword\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_BW_BAD_WORD'] . "</a>", "<a href='javascript:tableOrdering(\"match_case\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_BW_CASE_SENSITIVE'] . "</a>", "<a href='javascript:tableOrdering(\"action\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_BW_ACTION'] . "</a>", "<a href='javascript:tableOrdering(\"replace\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_BW_REPLACEMENT'] . "</a>", "<a href='javascript:tableOrdering(\"hits\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_BW_HITS'] . "</a>", "<a href='javascript:tableOrdering(\"updated\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_BW_UPDATED'] . "</a>");
$jBadWord = new jBadWord($database);
$limitstart = jTipsGetParam($_REQUEST, 'limitstart', 0);
$limit = jTipsGetParam($_REQUEST, 'limit', 25);
$direction = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc');
if (empty($direction)) {
    $direction = 'asc';
}
$orderby = jTipsGetParam($_REQUEST, 'filter_order', 'badword');
if (empty($orderby)) {
    $orderby = 'badword';
}
$params = array('order' => array('type' => 'order', 'direction' => $direction, 'by' => $orderby));
$jBadWords = forceArray($jBadWord->loadByParams($params, $limit, $limitstart));
$pageNav = new mosPageNav($jBadWord->getCount(), $limitstart, $limit);
$data = array();
$i = 0;
foreach ($jBadWords as $badword) {
    $data[$badword->id] = array(makeListLink($badword->badword, $i++), "<div style='text-align:center;'><img src='images/" . ($badword->match_case ? 'tick' : 'publish_x') . ".png' border='0' alt='{$badword->match_case}' /></div>", ucwords($badword->action), $badword->replace, $badword->hits, TimeDate::toDisplayDateTime($badword->updated));
}
jTipsAdminDisplay::ListView($formData, $header, $data, $pageNav, 'edit');
示例#11
0
 function process()
 {
     global $database, $jTips, $mosConfig_absolute_path;
     $this->clearHistory();
     $params = array('round_id' => $this->id);
     $jSeason = new jSeason($database);
     $jSeason->load($this->season_id);
     $jGame = new jGame($database);
     $jGames = forceArray($jGame->loadByParams($params));
     $params = array('season_id' => $this->season_id);
     $jTipsUser = new jTipsUser($database);
     $jTipsUsers = forceArray($jTipsUser->loadByParams($params));
     $noTips = $scores = $worst_precision = array();
     $played = count($jGames);
     foreach ($jTipsUsers as $jTipsUser) {
         jTipsLogger::_log("Processing scores for user " . $jTipsUser->id);
         $score = $matching = $precision = $allAwayScore = 0;
         if ($jTipsUser->hasTipped($this->id)) {
             jTipsLogger::_log($jTipsUser->id . " has tipped in round " . $this->id);
             foreach ($jGames as $jGame) {
                 jTipsLogger::_log("Processing game " . $jGame->id);
                 $params = array('user_id' => $jTipsUser->id, 'game_id' => $jGame->id);
                 $jTip = new jTip($database);
                 $jTip->loadByParams($params);
                 // make sure this is not a bye game
                 if (!$jGame->home_id or !$jGame->away_id or !$jGame->winner_id) {
                     jTipsLogger::_log('attempting to process tips on a bye game, skipping', 'INFO');
                     continue;
                 }
                 /*
                  * Feature Request 101 - Team Starts
                  * Determine the winner when we take the starts into account
                  * We only care about the starts for picking the winner/draw
                  * For picking the margins and scores, use the actual winner
                  */
                 if ($jSeason->team_starts) {
                     jTipsLogger::_log('processing team starts');
                     $homeScore = $awayScore = 0;
                     $homeScore = $jGame->home_score + ($jGame->home_start + 0);
                     $awayScore = $jGame->away_score + ($jGame->away_start + 0);
                     if ($homeScore > $awayScore) {
                         $winnerID = $jGame->home_id;
                     } else {
                         if ($homeScore < $awayScore) {
                             $winnerID = $jGame->away_id;
                         } else {
                             if ($homeScore == $awayScore) {
                                 $winnerID = -1;
                             }
                         }
                     }
                     jTipsLogger::_log('feature 101: With starts, the winner is ' . $winnerID . ', otherwise the winner is ' . $jGame->winner_id . " HOME {$homeScore} v AWAY {$awayScore}");
                 } else {
                     $winnerID = $jGame->winner_id;
                 }
                 if ($jTip->tip_id == $winnerID) {
                     //User tipped right!
                     jTipsLogger::_log("CORRECT TIP by " . $jTipsUser->id . " in round_id " . $this->id . " in game_id " . $jGame->id);
                     //BUG 248 - Add ToughScore if enabled
                     if ($jSeason->tough_score and $jGame->tough_score) {
                         $score += $jGame->tough_score;
                     }
                     if ($winnerID == -1) {
                         $score += isset($jSeason->user_draw) ? $jSeason->user_draw : 0;
                         jTipsLogger::_log("Draw correctly picked!");
                     } else {
                         $score += isset($jSeason->user_correct) ? $jSeason->user_correct : 0;
                     }
                     $matching++;
                 }
                 if ($winnerID == $jGame->away_id) {
                     $allAwayScore += $jSeason->user_correct;
                 }
                 //Check for correct margins and handle precision score gathering
                 if ($jSeason->pick_margin == 1 and $jGame->has_margin == 1) {
                     $margin = abs($jGame->home_score - $jGame->away_score);
                     if ($jTip->margin == $margin) {
                         $score += isset($jSeason->user_pick_margin) ? $jSeason->user_pick_margin : 0;
                         jTipsLogger::_log("correct margin picked!");
                     }
                     if ($jSeason->precision_score == 1) {
                         if ($jGame->winner_id == $jTip->tip_id) {
                             $margin_offset = abs($margin - $jTip->margin);
                         } else {
                             $margin_offset = abs($margin + $jTip->margin);
                         }
                         if (isset($worst_precision[$jGame->id]) && $margin_offset > $worst_precision[$jGame->id] || empty($worst_precision[$jGame->id])) {
                             $worst_precision[$jGame->id] = $margin_offset;
                         }
                         $precision += $margin_offset;
                         jTipsLogger::_log("PICK_MARGIN: Adding {$margin_offset} to precision of {$precision}");
                     }
                 }
                 //Check for correct scores and handle precision score gathering
                 if ($jSeason->pick_score == 1 and $jGame->has_score == 1) {
                     $margin = abs($jGame->home_score - $jGame->away_score);
                     if ($jTip->home_score == $jGame->home_score and $jTip->away_score == $jGame->away_score) {
                         $score += isset($jSeason->user_pick_score) ? $jSeason->user_pick_score : 0;
                         jTipsLogger::_log("Correct scores picked!");
                     }
                     if ($jSeason->precision_score == 1) {
                         $pickedScoreMargin = abs($jTip->home_score - $jTips->away_score);
                         if ($jGame->winner_id == $jTip->tip_id) {
                             $score_offset = abs($margin - $pickedScoreMargin);
                         } else {
                             $score_offset = abs($margin + $pickedScoreMargin);
                         }
                         if (isset($worst_precision[$jGame->id]) and $score_offset > $worst_precision[$jGame->id] or empty($worst_precision[$jGame->id])) {
                             $worst_precision[$jGame->id] = $score_offset;
                         }
                         $precision += $score_offset;
                         jTipsLogger::_log("PICK_SCORE: Adding {$score_offset} to precision of {$precision}");
                         jTipsLogger::_log("PREC DEBUG: {$jTipsUser->id}-{$jTipsUser->user_id} Picked Margin: {$pickedScoreMargin}. Actual Margin: {$margin}. Applied Precision: {$score_offset}. Running Precision: {$precision}", 'INFO');
                     }
                 }
                 //Check for a bonus team selection
                 if ($jSeason->pick_bonus >= 1 and $jGame->has_bonus == 1) {
                     if ($jTip->bonus_id == $jGame->bonus_id && $jGame->bonus_id != -1) {
                         $score += isset($jSeason->user_pick_bonus) ? $jSeason->user_pick_bonus : 0;
                     }
                 }
             }
             //was a perfect round picked?
             if ($matching == $played) {
                 $score += isset($jSeason->user_bonus) ? $jSeason->user_bonus : 0;
             }
             //did the user use their 'doubleup'
             if ($jTipsUser->doubleup == $this->id and $jTips['DoubleUp'] == 1) {
                 $score = $score * 2;
             }
             $scores[] = $score;
             //Save the data to the history object
             $jHistory = new jHistory($database);
             $jHistory->user_id = $jTipsUser->id;
             $jHistory->round_id = $this->id;
             jTipsLogger::_log("Score for user_id " . $jTipsUser->id . " in round_id " . $this->id . " is {$score}");
             $jHistory->points = $score;
             //Update rank after all users have been saved
             $jHistory->outof = count($jTipsUsers);
             //$jHistory->comment	= $jTipsUser->comment;
             if ($jSeason->precision_score == 1) {
                 jTipsLogger::_log("setting precision to {$precision} for user_id " . $jTipsUser->id . " in round_id " . $this->id);
                 $jHistory->precision = $precision;
             } else {
                 $jHistory->precision = 0;
             }
             if ($jHistory->save() !== false) {
                 $results[] = 1;
             } else {
                 jTipsLogger::_log("Error saving history: " . $jHistory->_error);
                 $results[] = 0;
             }
             //remove the current comment
             $jTipsUser->comment = null;
             $jTipsUser->save();
             // Check if the AlphaUserPoints config option is set
             if (isJoomla15()) {
                 $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php';
             } else {
                 $api_AUP = $mosConfig_absolute_path . 'components/com_alphauserpoints/helper.php';
             }
             if (!$this->scored and $jTips['AlphaUserPoints'] and jTipsFileExists($api_AUP)) {
                 require_once $api_AUP;
                 jTipsLogger::_log('sending ' . $score . ' points for user ' . $jTipsUser->user_id, 'INFO');
                 $refID = AlphaUserPointsHelper::getAnyUserReferreID($jTipsUser->user_id);
                 AlphaUserPointsHelper::newpoints('plgaup_jtips_total_points', $refID, '', '', $score);
             }
             if (!$this->scored and $jTips['JomSocialActivities'] and $jTips['JomSocialUserResults']) {
                 global $mosConfig_absolute_path;
                 require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/utils/jTipsJomSocial.php';
                 jTipsJomSocial::writeRoundResult($jSeason, $this, $jTipsUser->user_id, $score);
             }
         } else {
             $noTips[] = $jTipsUser;
         }
     }
     if (count($noTips) > 0) {
         /////////////////////////////////////////////////
         // Feature Request 71
         // Allow users that did not to be assigned
         // all the away teams
         //
         /*if ($jSeason->user_none != -1) {
         		$thisRound = $jSeason->user_none;
         		} else if (is_array($scores) && count($scores) > 0) {
         		$thisRound = min($scores);
         		} else {
         		$thisRound = 0;
         		}*/
         if ($jSeason->user_none == -2) {
             //handle all away teams
             $thisRound = $allAwayScore;
             jTipsLogger::_log("didn't tip? You'll be stuck with the away teams. You got {$thisRound}");
         } else {
             if ($jSeason->user_none == -1) {
                 //handle lowest possible score
                 if (is_array($scores) and count($scores) > 0) {
                     $thisRound = min($scores);
                     jTipsLogger::_log("didn't tip? You'll be stuck with the lowest score this round, {$thisRound}");
                 } else {
                     $thisRound = 0;
                     jTipsLogger::_log("didn't tip? You'll be stuck {$thisRound}");
                 }
             } else {
                 //handle allocated score
                 $thisRound = $jSeason->user_none;
                 jTipsLogger::_log("didn't tip? You're getting {$thisRound}");
             }
         }
         //
         // END Feature Request 71
         ////////////////////////////////////////////////////
         foreach ($noTips as $jTipsUser) {
             $jHistory = new jHistory($database);
             $jHistory->user_id = $jTipsUser->id;
             $jHistory->round_id = $this->id;
             $jHistory->points = $thisRound;
             $jHistory->precision = array_sum($worst_precision);
             //$jHistory->outof		= count($jTipsUsers);
             //$jHistory->comment	= $jTipsUser->comment;
             if ($jHistory->save() !== false) {
                 $results[] = 1;
             } else {
                 $results[] = 0;
             }
             $jTipsUser->save();
             // Check if the AlphaUserPoints config option is set
             if (isJoomla15()) {
                 $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php';
             } else {
                 $api_AUP = $mosConfig_absolute_path . 'components/com_alphauserpoints/helper.php';
             }
             if (!$this->scored and $jTips['AlphaUserPoints'] and jTipsFileExists($api_AUP)) {
                 require_once $api_AUP;
                 jTipsLogger::_log('sending ' . $score . ' points for user ' . $jTipsUser->user_id, 'INFO');
                 $refID = AlphaUserPointsHelper::getAnyUserReferreID($jTipsUser->user_id);
                 AlphaUserPointsHelper::newpoints('plgaup_jtips_total_points', $refID, '', '', $thisRound);
             }
             if (!$this->scored and $jTips['JomSocialActivities']) {
                 global $mosConfig_absolute_path;
                 require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/utils/jTipsJomSocial.php';
                 if ($jTips['JomSocialUserResults']) {
                     jTipsJomSocial::writeRoundResult($jSeason, $this, $jTipsUser->user_id, $score);
                 }
                 if ($jTips['JomSocialOnNoTips']) {
                     jTipsJomSocial::writeOnNoTips($jTipsUser->user_id, $jSeason, $this);
                 }
             }
         }
     }
     $jHistory = new jHistory($database);
     $jHistory->setRanks($this->id, true);
     if (!$this->scored and $jTips['JomSocialActivities']) {
         // find out who won the round and write it to the JomSocial stream
         $winners = $this->getRoundWinners();
         jTipsJomSocial::writeRoundWinners($winners, $this, $jSeason);
     }
     $this->scored = 1;
     $result = $this->save();
     //if ($this->scored != 1) {
     jTeam::updateLadder($this, $jSeason);
     //}
     //$this->scored = 1;
     //return $this->save();
     return $result;
 }
示例#12
0
文件: jtips.php 项目: joomux/jTips
    jtips_HTML::title();
}
jTips_HTML::expired();
/*
 * Load the current user object
 */
global $jTipsCurrentUser, $mainframe;
$jTipsCurrentUser = new jTipsUser($database);
if (jTipsGetParam($_REQUEST, 'user_id', false)) {
    $jTipsCurrentUser->load(jTipsGetParam($_REQUEST, 'user_id', false));
} else {
    $my =& $mainframe->getUser();
    $parameters = array('season_id' => getSeasonID(), 'user_id' => $my->id);
    //BUG 219 - simplify user loading
    // BUG 348 - when somehow multiple users exist for the same competition, load only one.
    $usersArray = forceArray($jTipsCurrentUser->loadByParams($parameters));
    if (!count($usersArray)) {
        $jTipsCurrentUser->loadByParams($parameters);
    } else {
        $jTipsCurrentUser = array_shift($usersArray);
    }
    unset($parameters);
}
if (jTipsGetParam($_REQUEST, 'menu', 1)) {
    $_REQUEST['season'] = $jTipsCurrentUser->season_id;
    $_GET['season'] = $jTipsCurrentUser->season_id;
}
$task = $task ? $task : 'Dashboard';
$view = jTipsGetParam($_REQUEST, 'view', 'Dashboard');
if (!$view) {
    $view = 'Dashboard';
示例#13
0
文件: list.php 项目: joomux/jTips
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jseason.class.php';
$jSeason = new jSeason($database);
//can add in an ordering field here in the params
$direction = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc');
if (empty($direction)) {
    $direction = 'asc';
}
$orderby = jTipsGetParam($_REQUEST, 'filter_order', 'name');
if (empty($orderby)) {
    $orderby = 'name';
}
$parameters = array('order' => array('type' => 'order', 'direction' => $direction, 'by' => $orderby));
$limit = jTipsGetParam($_REQUEST, 'limit', 25);
$limitstart = jTipsGetParam($_REQUEST, 'limitstart', 0);
$pageNav = new mosPageNav($jSeason->getCount(), $limitstart, $limit);
$jSeasons = forceArray($jSeason->loadByParams($parameters, $limit, $limitstart));
$formData = array('title' => $jLang['_ADMIN_SEASON_TITLE'], 'editTask' => 'edit', 'module' => 'Seasons', 'icon' => 'seasons');
$currentDir = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc');
if ($currentDir == 'asc') {
    $dir = 'desc';
} else {
    $dir = 'asc';
}
//The header row
$header = array('', "<a href='javascript:tableOrdering(\"name\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_SEASON_NAME'] . "</a>", "<a href='javascript:tableOrdering(\"start_time\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_SEASON_START'] . "</a>", "<a href='javascript:tableOrdering(\"end_time\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_SEASON_END'] . "</a>");
//The row data for each for
$data = array();
$i = 0;
foreach ($jSeasons as $jSeason) {
    $data[$jSeason->id] = array(makeListLink($jSeason->name, $i++), $jSeason->start_time, $jSeason->end_time);
}
示例#14
0
文件: list.php 项目: joomux/jTips
$jTip = new jTip($database);
$limitstart = jTipsGetParam($_REQUEST, 'limitstart', 0);
$limit = jTipsGetParam($_REQUEST, 'limit', $jTips['NumMax']);
$params = array('join' => array('type' => 'join', 'join_table' => '#__jtips_games', 'lhs_table' => '#__jtips_tips', 'lhs_key' => 'game_id', 'rhs_table' => '#__jtips_games', 'rhs_key' => 'id'), 'group' => array('type' => 'group', 'by' => 'round_id`, `user_id'), 'order' => array('type' => 'order', 'by' => 'round_id', 'direction' => 'DESC'));
if ($user_id = jTipsGetParam($_REQUEST, 'user_id', false)) {
    $params['user_id'] = $user_id;
}
$jTipArray = forceArray($jTip->loadByParams($params, $limit, $limitstart));
unset($params['order']);
$pageNav = new mosPageNav($jTip->getCount($params, true), $limitstart, $limit);
$header = array('', 'User', 'Round', 'Season');
$data = array();
$i = 0;
foreach ($jTipArray as $tip) {
    $tip->fillInAdditionalFields();
    $data[$tip->id] = array(makeListLink($tip->user->getName(), $i++), $tip->round_num, $tip->season->name);
}
$jSeason = new jSeason($database);
$jSeasons = forceArray($jSeason->loadByParams(array()));
$seasons = objectsToSelectList($jSeasons, 'name');
$jTipsUser = new jTipsUser($database);
$jTipsUsers = forceArray($jTipsUser->loadByParams(array()));
foreach ($jTipsUsers as $u) {
    $u->name = $u->getName() . " (" . $seasons[$u->season_id] . ")";
    $jTipsUsersArray[] = $u;
}
$users = objectsToSelectList($jTipsUsersArray, 'name');
asort($users);
$formData = array('title' => $jLang['_ADMIN_DASH_TIPS_MANAGER'], 'editTask' => 'edit', 'module' => 'Tips', 'icon' => 'tips');
$filters = array($jLang['_ADMIN_USERS_SELECT'] => makeSelectList($users, 'user_id', "id='user_id' onChange='this.form.submit();'", jTipsGetParam($_REQUEST, 'user_id', '')), $jLang['_ADMIN_SEASON_SELECT'] => makeSelectList($seasons, 'season_id', "id='season_id' onChange='this.form.submit();'", jTipsGetParam($_REQUEST, 'season_id', '')));
jTipsAdminDisplay::ListView($formData, $header, $data, $pageNav, 'list', $filters);
示例#15
0
文件: process.php 项目: joomux/jTips
 * @license Commercial - See website for details
 * 
 * @since 2.1 - 02/10/2008
 * @version 2.1
 * @package jTips
 * 
 * Description: 
 */
jTipsSpoofCheck();
global $database;
require_once 'components/com_jtips/classes/jbadword.class.php';
require_once 'components/com_jtips/classes/jcomment.class.php';
$jBadWordFocus = new jBadWord($database);
$jCommentFocus = new jComment($database);
$badwords = forceArray($jBadWordFocus->loadByParams());
$comments = forceArray($jCommentFocus->loadByParams());
$count = $deleted = $replaced = 0;
foreach ($comments as $jComment) {
    foreach ($badwords as $jBadWord) {
        $search = '/' . $jBadWord->badword . '/' . ($jBadWord->match_case == 1 ? 'i' : '');
        $found = preg_match_all($search, $jComment->comment, $matches);
        if ($found > 0) {
            $count++;
            $found = $found + $jBadWord->hits;
            $jBadWord->hits = $found;
            if ($jBadWord->action == 'delete') {
                $jComment->delete($jComment->id);
                $deleted++;
            } else {
                $new_comment = preg_replace($search, $jBadWord->replace, $jComment->comment);
                $jComment->comment = $new_comment;
示例#16
0
文件: list.php 项目: joomux/jTips
            $jTipsVersion = getFullVersion();
            //BUG 262 - AutoUpgrade to version message corrected
            $newVersion = jTipsGetParam($_SESSION, 'jtips_upgraded_version', 'Latest Version');
            $message = 'System Upgraded!';
            // to ' .$jTipsVersion;
            unset($_SESSION['jtips_upgraded_version']);
        } else {
            if ($autoUpgradeResult == 0) {
                //upgrade not required
            } else {
                if (is_string($autoUpgradeResult)) {
                    //display the error message
                    //Auto Update Failed: [message]
                    $message = 'System Upgrade Failed: ' . $autoUpgradeResult;
                }
            }
        }
        if ($message) {
            mosRedirect('index2.php?option=com_jtips&module=Dashboard&nu=1&task=Validate', $message);
        }
    }
}
$jSeason = new jSeason($database);
$parameters = array('end_time' => array('type' => 'query', 'query' => "> '" . gmdate('Y-m-d') . "'"), 'start_time' => array('type' => 'query', 'query' => "< '" . gmdate('Y-m-d') . "'"));
$jSeasons = forceArray($jSeason->loadByParams($parameters));
$tpl->jSeasons = $jSeasons;
$dashboard = array();
include 'components/com_jtips/modules/Dashboard/dashboard.php';
$tpl->menu = $dashboard;
//jdash_HTML::dashboard($jSeasons, $dashboard);
$tpl->display();
示例#17
0
文件: locked.php 项目: joomux/jTips
    /**
     * Take data assigned in $data and display it
     */
    function display()
    {
        global $jTipsCurrentUser, $mainframe, $database, $jLang, $jTips, $mosConfig_live_site;
        $mosConfig_offset = $mainframe->getCfg('offset');
        global $Itemid;
        $useJs = false;
        if ($jTips['JsLadder'] != 'none') {
            $useJs = true;
        }
        ?>
<h2 class="contentheading jmain_heading"><?php 
        echo $this->jSeason->name;
        ?>
</h2>
<h3 align="center"><?php 
        if ($this->jRound->getPrev()) {
            ?>
 <a style="font-size: smaller;"
	href='<?php 
            echo jTipsRoute("index.php?option=com_jtips&amp;Itemid={$Itemid}&amp;view=Tips&amp;layout=locked&amp;rid=" . $this->jRound->getPrev());
            ?>
'>&laquo;
	<?php 
            echo $jLang['_COM_PREV_ROUND'];
            ?>
</a> <?php 
        }
        echo "&nbsp;" . $jLang['_COM_DASH_ROUND'] . " " . $this->jRound->round . "&nbsp;";
        if ($this->jRound->getNext()) {
            ?>
 <a style="font-size: smaller;"
	href='<?php 
            echo jTipsRoute("index.php?option=com_jtips&amp;Itemid={$Itemid}&amp;view=Tips&amp;layout=locked&amp;rid=" . $this->jRound->getNext());
            ?>
'><?php 
            echo $jLang['_COM_NEXT_ROUND'];
            ?>
&raquo;</a> <?php 
        }
        ?>
</h3>
<?php 
        if ($this->jRound->exists()) {
            $jGameParams = array('round_id' => $this->jRound->id, 'order' => array('type' => 'order', 'by' => 'position', 'direction' => 'ASC'));
            $jGame = new jGame($database);
            $jGames = forceArray($jGame->loadByParams($jGameParams));
            $tags = "class='sectiontableheader jtableheader'";
            ?>
		<table width="100%" cellspacing="0">
			<thead>
				<tr class="sectiontableheader">
					<th <?php 
            echo $tags;
            ?>
 width="50%"><?php 
            echo $jLang['_COM_ROUND_START_TIME'];
            ?>
</th>
					<?php 
            if ($jTips['ShowJSCountdown'] == 1) {
                ?>
					<th <?php 
                echo $tags;
                ?>
 width="50%"><?php 
                echo $jLang['_COM_ROUND_TIME_TO_START'];
                ?>
</th>
					<?php 
            }
            ?>
				</tr>
			</thead>
			<tbody>
				<tr class="sectiontableentry1">
					<td style="text-align: center;"><?php 
            //BUG 136 - show closed/closes depending on start time
            echo TimeDate::toDisplayDateTime($this->jRound->start_time, false);
            ?>
</td>
					<?php 
            if ($jTips['ShowJSCountdown'] == 1) {
                ?>
					<td>
					<div id='countdown' style="text-align: center;" class="highlight"><?php 
                echo $jLang['_COM_CLOSED'];
                ?>
</div>
					</td>
					<?php 
            }
            ?>
				</tr>
			</tbody>
		</table>
					<?php 
            if (jTipsGetParam($jTips, 'TeamLadderPopup', 0)) {
                $url = "view=TeamLadder&Itemid={$Itemid}&menu=0";
                ?>
		<p style="text-align: center; font-weight: bold;">
						<?php 
                if (isJoomla15()) {
                    // better popup handling in J1.5
                    JHTML::_('behavior.modal');
                    $rel = json_encode(array('size' => array('x' => $jTips['ShowTipsWidth'], 'y' => $jTips['ShowTipsHeight'])));
                    $url = jTipsRoute("index.php?option=com_jtips&tmpl=component&" . $url);
                    $attribs = array('class' => 'modal', 'rel' => str_replace('"', "'", $rel), 'title' => $jLang['_COM_TIPS_SHOWHIDE']);
                    echo JHTML::link($url, $jLang['_COM_TIPS_SHOWHIDE'], $attribs);
                } else {
                    ?>
 <a href='javascript:void(0);'
							onClick="openPopup('<?php 
                    echo $url;
                    ?>
', 'Team Ladder');"><?php 
                    echo $jLang['_COM_TIPS_SHOWHIDE'];
                    ?>
</a>
							<?php 
                }
                ?>
</p><?php 
            }
            //BUG 189 - Which order should the tips panel be shown in
            if ($this->jSeason->tips_layout == 'away') {
                $left = 'away';
                $right = 'home';
            } else {
                $left = 'home';
                $right = 'away';
            }
            ?>
		<table align='center' width='100%' class="jdatatable" cellspacing="0">
			<tr>
				<th <?php 
            echo $tags;
            ?>
><?php 
            echo $jLang['_COM_GAME_' . strtoupper($left)];
            ?>
</th>
				<?php 
            if ($this->jSeason->team_starts) {
                ?>
				<th <?php 
                echo $tags;
                ?>
><?php 
                echo $jLang['_COM_TIPS_' . strtoupper($left) . 'START'];
                ?>
</th>
				<?php 
            }
            if ($this->jSeason->team_starts) {
                ?>
				<th <?php 
                echo $tags;
                ?>
><?php 
                echo $jLang['_COM_TIPS_' . strtoupper($right) . 'START'];
                ?>
</th>
				<?php 
            }
            ?>
				<th <?php 
            echo $tags;
            ?>
>&nbsp;</th>
				<th <?php 
            echo $tags;
            ?>
><?php 
            echo $jLang['_COM_GAME_' . strtoupper($right)];
            ?>
</th>
				<?php 
            if ($this->jSeason->game_times) {
                ?>
				<th <?php 
                echo $tags;
                ?>
><?php 
                echo $jLang['_COM_TIPS_TIME'];
                ?>
</th>
				<?php 
            }
            if ($this->jRound->scored == 1) {
                ?>
				<th <?php 
                echo $tags;
                ?>
><?php 
                echo $jLang['_COM_TIPS_RESULT'];
                ?>
</th>
				<?php 
            }
            ?>
				<th <?php 
            echo $tags;
            ?>
>&nbsp;</th>
			</tr>
			<?php 
            $rowIndex = 0;
            foreach ($jGames as $jGame) {
                $leftTeam = new jTeam($database);
                $rightTeam = new jTeam($database);
                $left_id_field = $left . '_id';
                $right_id_field = $right . '_id';
                $leftLoaded = $rightLoaded = false;
                if ($jGame->{$left_id_field}) {
                    $leftTeam->load($jGame->{$left_id_field});
                    $leftLoaded = true;
                }
                if ($jGame->{$right_id_field}) {
                    $rightTeam->load($jGame->{$right_id_field});
                    $rightLoaded = true;
                }
                if (!$leftLoaded and $rightLoaded) {
                    $this->byes[] = $rightTeam;
                }
                if ($leftLoaded and !$rightLoaded) {
                    $this->byes[] = $leftTeam;
                }
                if (!$leftLoaded or !$rightLoaded) {
                    continue;
                }
                if ($jGame->winner_id == $leftTeam->id) {
                    $left_style = "font-weight:bold;";
                    $right_style = "";
                } else {
                    if ($jGame->winner_id == -1) {
                        $left_style = "font-style:italics;";
                        $right_style = "font-style:italics;";
                    } else {
                        if ($jGame->winner_id == $rightTeam->id) {
                            $left_style = "";
                            $right_style = "font-weight:bold;";
                        } else {
                            $left_style = "";
                            $right_style = "";
                        }
                    }
                }
                $rowClasses = "class='sectiontableentry" . ($rowIndex % 2 + 1) . " jtablerow" . ($rowIndex % 2 + 1) . "'";
                ?>
			<tr <?php 
                echo $rowClasses;
                ?>
>
				<td style='text-align:right;<?php 
                echo $left_style;
                ?>
'><label
					for="<?php 
                echo $left;
                ?>
_game<?php 
                echo $jGame->id;
                ?>
"><?php 
                echo $leftTeam->getDisplayLogoName('right');
                ?>
</label></td>
					<?php 
                if ($this->jSeason->team_starts) {
                    $left_start_field = $left . '_start';
                    $leftStart = $jGame->{$left_start_field} + 0;
                    if ($jGame->{$left_start_field} > 0) {
                        $leftStart = "+{$leftStart}";
                    } else {
                        if ($leftStart == 0) {
                            $leftStart = "&nbsp;";
                        }
                    }
                    ?>
				<td style='text-align: center;'><?php 
                    echo $leftStart;
                    ?>
</td>
				<?php 
                }
                ?>
				<td style='text-align: center;'>&nbsp;<?php 
                echo $jLang['_COM_TEAM_VS'];
                ?>
&nbsp;</td>
				<?php 
                $right_start_field = $right . '_start';
                if ($this->jSeason->team_starts) {
                    $rightStart = $jGame->{$right_start_field} + 0;
                    if ($jGame->{$right_start_field} > 0) {
                        $rightStart = "+{$rightStart}";
                    } else {
                        if ($rightStart == 0) {
                            $rightStart = "&nbsp;";
                        }
                    }
                    ?>
				<td style='text-align: center;'><?php 
                    echo $rightStart;
                    ?>
</td>
				<?php 
                }
                ?>
				<td style='text-align:left;<?php 
                echo $right_style;
                ?>
'><label
					for="<?php 
                echo $right;
                ?>
_game<?php 
                echo $jGame->id;
                ?>
"><?php 
                echo $rightTeam->getDisplayLogoName('left');
                ?>
</label>
				</td>
				<?php 
                //show the game time
                if ($this->jSeason->game_times) {
                    ?>
					<td><?php 
                    if ($jGame->start_time) {
                        echo TimeDate::toDisplayDateTime($jGame->start_time, false);
                    } else {
                        echo "&nbsp;";
                    }
                    ?>
</td><?php 
                }
                if ($this->jRound->scored == 1) {
                    $left_score_field = $left . '_score';
                    $right_score_field = $right . '_score';
                    ?>
					<th <?php 
                    echo $tags;
                    ?>
><?php 
                    echo $jGame->{$left_score_field} . " - " . $jGame->{$right_score_field};
                    ?>
&nbsp;</th>
					<?php 
                }
                ?>
<td><?php 
                if (!empty($jGame->description)) {
                    $description = nl2br(stripslashes($jGame->description));
                    echo jTipsToolTip($description, $jLang['_COM_GAME_ADDITIONAL_INFO']);
                } else {
                    echo "&nbsp;";
                }
                ?>
</td>
			</tr>
			<?php 
                $rowIndex++;
            }
            ?>
		</table>
		<div><?php 
            $this->renderByes();
            ?>
</div>
		<?php 
        } else {
            if ($this->jRound->exists() and TimeDate::toDatabaseDateTime($this->jRound->start_time) > gmdate('Y-m-d H:i:s')) {
                ?>
		<h2 style='text-align: center'><?php 
                echo $jLang['_COM_DASH_ROUND'] . " " . $this->jRound->round;
                ?>
</h2>
		<h2 style='text-align: center'><?php 
                echo $jLang['_COM_ROUND_CLOSED'];
                ?>
</h2>
			<?php 
            } else {
                if ($this->jRound->exists()) {
                    ?>
		<h2 style='text-align: center'><?php 
                    echo $jLang['_COM_DASH_ROUND'] . " " . $this->jRound->round;
                    ?>
</h2>
				<?php 
                } else {
                    ?>
		<h2 style='text-align: center'><?php 
                    echo $jLang['_COM_ROUND_NOGAMES'];
                    ?>
</h2>
				<?php 
                }
            }
        }
        if ($this->jRound->getStatus() === false) {
            $userTime = strtotime($this->jRound->start_time) - TimeDate::getOffset(false);
            $targetTime = date('Y-m-d H:i:s', $userTime);
            if ($jTips['ShowJSCountdown'] == 1) {
                $field = "'countdown'";
            } else {
                $field = "false";
            }
            ?>
		<script type='text/javascript'>
						window.addEvent('domready', function(){
							var year = <?php 
            echo TimeDate::format($targetTime, '%Y', true, false);
            ?>
;
							var month = <?php 
            echo TimeDate::format($targetTime, '%m', true, false) - 1;
            ?>
;
							var day = <?php 
            echo TimeDate::format($targetTime, '%d', true, false);
            ?>
;
							var hour = <?php 
            echo TimeDate::format($targetTime, '%H', true, false);
            ?>
;
							var min = <?php 
            echo TimeDate::format($targetTime, '%M', true, false);
            ?>
;
							var sec = 0;
							jTipsCountdown(year, month, day, hour, min, 1, <?php 
            echo $field;
            ?>
);
						});
					</script>
			<?php 
        }
    }
示例#18
0
 * @author Jeremy Roberts
 * @copyright Copyright &copy; 2009, jTips
 * @license Commercial - See website for details
 * 
 * @since 2.1 - 16/10/2008
 * @version 2.1
 * @package jTips
 * 
 * Description: 
 */
global $database, $mosConfig_absolute_path;
ob_clean();
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jbadword.class.php';
$comment = jTipsGetParam($_REQUEST, 'comment', '');
$jBad = new jBadWord($database);
$badwords = forceArray($jBad->loadByParams(array()));
$count = $deleted = $replaced = 0;
$results = array();
foreach ($badwords as $jBadWord) {
    $search = '/' . $jBadWord->badword . '/' . ($jBadWord->match_case == 1 ? 'i' : '');
    $found = preg_match_all($search, $comment, $matches);
    if ($found > 0) {
        $count++;
        $found = $found + $jBadWord->hits;
        $jBadWord->hits = $found;
        if ($jBadWord->action == 'delete') {
            $deleted++;
            array_push($results, 0);
        } else {
            $new_comment = preg_replace($search, $jBadWord->replace, $comment);
            $replaced++;
示例#19
0
文件: default.php 项目: joomux/jTips
    /**
     * Take data assigned in $data and display it
     */
    function display()
    {
        global $jTipsCurrentUser, $mainframe, $database, $jLang, $jTips, $mosConfig_live_site;
        $mosConfig_offset = $mainframe->getCfg('offset');
        //$Itemid = jTipsGetParam($_REQUEST, 'Itemid', '');
        global $Itemid;
        //$mainframe->setPageTitle(getComponentName($Itemid).' > '.$jTips['Menu']['Tips']);
        //jTipsCommonHTML::loadOverlib();
        $useJs = false;
        if ($jTips['JsLadder'] != 'none') {
            $useJs = true;
        }
        if ($jTips['EnableComments'] == 1 and $jTips['EnableCommentFilter'] == 1) {
            $checkComment = "onclick='return validateComment(\"comment\");'";
        } else {
            $checkComment = "onClick='document.tips_form.submit();'";
        }
        //jtips_HTML::buildMenu('tips', $this->jSeason, $this->jTipsUser);
        //jtips_HTML::seasonsList($this->jTipsUser, $this->jSeasons, "onchange='getSeason(this);'", true, jTipsGetParam($_REQUEST, 'season', jTipsGetParam($_REQUEST, 'season_id', false)));
        $postURL = jTipsRoute("index.php?option=com_jtips&Itemid={$Itemid}");
        ?>
		<script type='text/javascript'>
		function getSeason(obj) {
			var id = obj.options[obj.selectedIndex].value;
			return window.location.href='<?php 
        echo html_entity_decode(jTipsRoute("index.php?option=com_jtips&Itemid={$Itemid}&task=Tips&season="));
        ?>
' + id;
		}
		</script>
		<form action='<?php 
        echo $postURL;
        ?>
' method='post' name='tips_form' id='tips_form'>
		<input type='hidden' name='option' value='com_jtips' />
		<input type='hidden' name='view' value='Tips' />
		<input type="hidden" name="action" value="save" />
		<input type='hidden' name='user_id' value='<?php 
        echo $jTipsCurrentUser->id;
        ?>
' />
		<input type="hidden" name="<?php 
        echo jTipsSpoofValue();
        ?>
" value="1" />
		<h2 class="contentheading jmain_heading"><?php 
        echo $this->jSeason->name;
        ?>
</h2>
		<h3 align="center">
		<?php 
        if ($this->jRound->getPrev()) {
            ?>
			<a style="font-size:smaller;" href='<?php 
            echo jTipsRoute("index.php?option=com_jtips&amp;Itemid={$Itemid}&amp;view=Tips&amp;rid=" . $this->jRound->getPrev());
            ?>
'>&laquo; <?php 
            echo $jLang['_COM_PREV_ROUND'];
            ?>
</a>
			<?php 
        }
        echo "&nbsp;" . $jLang['_COM_DASH_ROUND'] . " " . $this->jRound->round . "&nbsp;";
        if ($this->jRound->getNext()) {
            ?>
			<a  style="font-size:smaller;" href='<?php 
            echo jTipsRoute("index.php?option=com_jtips&amp;Itemid={$Itemid}&amp;view=Tips&amp;rid=" . $this->jRound->getNext());
            ?>
'><?php 
            echo $jLang['_COM_NEXT_ROUND'];
            ?>
 &raquo;</a>
			<?php 
        }
        ?>
		</h3>
		<?php 
        if ($this->jRound->exists()) {
            $jGameParams = array('round_id' => $this->jRound->id, 'order' => array('type' => 'order', 'by' => 'position', 'direction' => 'ASC'));
            $jGame = new jGame($database);
            $jGames = forceArray($jGame->loadByParams($jGameParams));
            $tags = "class='sectiontableheader jtableheader'";
            ?>
			<table width="100%" cellspacing="0">
			<thead>
				<tr class="sectiontableheader">
				<th <?php 
            echo $tags;
            ?>
 width="33%"><?php 
            echo $jLang['_COM_TIPS_TIPPING_CLOSE'];
            ?>
</th>
			<?php 
            if ($jTips['ShowJSCountdown'] == 1) {
                ?>
				<th <?php 
                echo $tags;
                ?>
 width="34%"><?php 
                echo $jLang['_COM_TIPS_TIME_TO_CLOSE'];
                ?>
</th>
				<?php 
            }
            ?>
				<th <?php 
            echo $tags;
            ?>
 width="33%"><?php 
            echo $jLang['_COM_TIPS_LASTUP'];
            ?>
</th>
				</tr>
			</thead>
			<tbody>
				<tr class="sectiontableentry1">
				<td style="text-align:center;">
				<?php 
            //BUG 136 - show closed/closes depending on start time
            echo TimeDate::toDisplayDateTime($this->jRound->start_time, false);
            ?>
</td>
				<?php 
            if ($jTips['ShowJSCountdown'] == 1) {
                ?>
				<td><div id='countdown' style="text-align:center;" class="highlight"><?php 
                echo $jLang['_COM_CLOSED'];
                ?>
</div></td>
			<?php 
            }
            $jTipParams = array('game_id' => array('type' => 'reference', 'query' => "SELECT DISTINCT id FROM #__jtips_games WHERE round_id = " . $this->jRound->id), 'user_id' => $jTipsCurrentUser->id);
            $jTip = new jTip($database);
            $jTipss = forceArray($jTip->loadByParams($jTipParams));
            ?>
<td><?php 
            if (count($jTipss) > 0) {
                echo TimeDate::toDisplayDateTime($jTipss[0]->updated, false);
            } else {
                echo "&nbsp;";
            }
            ?>
			</td>
			</tr>
			</tbody>
			</table>
			<?php 
            if (jTipsGetParam($jTips, 'TeamLadderPopup', 0)) {
                $url = "view=TeamLadder&Itemid={$Itemid}&menu=0";
                ?>
<p style="text-align:center;font-weight:bold;"><?php 
                if (isJoomla15()) {
                    /*?>
                    		<a class="modal" rel="{handler: 'iframe', size: {x: <?php echo $jTips['ShowTipsWidth']; ?>, y: <?php echo $jTips['ShowTipsHeight']; ?>}}" href="<?php echo jTipsRoute("index2.php?option=com_jtips&" .$url); ?>" title='Team Ladder'><?php echo $jLang['_COM_TIPS_SHOWHIDE']; ?></a>
                    		<?php*/
                    // better popup handling in J1.5
                    JHTML::_('behavior.modal');
                    $rel = json_encode(array('size' => array('x' => $jTips['ShowTipsWidth'], 'y' => $jTips['ShowTipsHeight'])));
                    $url = jTipsRoute("index.php?option=com_jtips&tmpl=component&" . $url);
                    $attribs = array('class' => 'modal', 'rel' => str_replace('"', "'", $rel), 'title' => $jLang['_COM_TIPS_SHOWHIDE']);
                    echo JHTML::link($url, $jLang['_COM_TIPS_SHOWHIDE'], $attribs);
                } else {
                    ?>
					<a href='javascript:void(0);' onClick="openPopup('<?php 
                    echo $url;
                    ?>
', 'Team Ladder');"><?php 
                    echo $jLang['_COM_TIPS_SHOWHIDE'];
                    ?>
</a>
					<?php 
                }
                ?>
</p><?php 
            }
            //BUG 189 - Which order should the tips panel be shown in
            if ($this->jSeason->tips_layout == 'away') {
                $left = 'away';
                $right = 'home';
            } else {
                $left = 'home';
                $right = 'away';
            }
            ?>
			<table align='center' width='100%' class="jdatatable" cellspacing="0">
				<tr>
					<th <?php 
            echo $tags;
            ?>
><?php 
            echo $jLang['_COM_GAME_' . strtoupper($left)];
            ?>
</th>
			<?php 
            if ($this->jSeason->team_starts) {
                ?>
                <th <?php 
                echo $tags;
                ?>
><?php 
                echo $jLang['_COM_TIPS_' . strtoupper($left) . 'START'];
                ?>
</th>
                <?php 
            }
            if ($this->jSeason->pick_score == 1) {
                ?>
					<th <?php 
                echo $tags;
                ?>
><?php 
                echo $jLang['_COM_TIPS_' . strtoupper($left) . 'SCORE'];
                ?>
</th>
				<?php 
            }
            ?>
					<th <?php 
            echo $tags;
            ?>
>
					<?php 
            if ($this->jSeason->pick_draw == 1 and ($this->jSeason->pick_score and !$jTips['HideTeamSelect'] or !$this->jSeason->pick_score)) {
                echo "&nbsp;" . $jLang['_COM_GAME_DRAW'] . "&nbsp;";
            } else {
                echo "&nbsp;";
            }
            ?>
</th>
			<?php 
            if ($this->jSeason->pick_score == 1) {
                ?>
					<th <?php 
                echo $tags;
                ?>
><?php 
                echo $jLang['_COM_TIPS_' . strtoupper($right) . 'SCORE'];
                ?>
</th>
				<?php 
            }
            if ($this->jSeason->team_starts) {
                ?>
                <th <?php 
                echo $tags;
                ?>
><?php 
                echo $jLang['_COM_TIPS_' . strtoupper($right) . 'START'];
                ?>
</th>
                <?php 
            }
            ?>
					<th <?php 
            echo $tags;
            ?>
><?php 
            echo $jLang['_COM_GAME_' . strtoupper($right)];
            ?>
</th>
			<?php 
            if ($this->jSeason->pick_margin == 1) {
                ?>
					<th <?php 
                echo $tags;
                ?>
><?php 
                echo $jLang['_COM_TIPS_MARGIN'];
                ?>
</th>
				<?php 
            }
            if ($this->jSeason->pick_bonus >= 1) {
                ?>
					<th <?php 
                echo $tags;
                ?>
><?php 
                echo $jLang['_COM_TIPS_BONUS'];
                ?>
</th>
				<?php 
            }
            if ($this->jSeason->game_times) {
                ?>
					<th <?php 
                echo $tags;
                ?>
><?php 
                echo $jLang['_COM_TIPS_TIME'];
                ?>
</th>
				<?php 
            }
            if ($this->jRound->scored == 1) {
                ?>
					<th <?php 
                echo $tags;
                ?>
><?php 
                echo $jLang['_COM_TIPS_RESULT'];
                ?>
</th>
				<?php 
            }
            ?>
				<th <?php 
            echo $tags;
            ?>
>&nbsp;</th>
				</tr>
			<?php 
            // BUG 316 - have TimeDate::toDatabaseDateTime around jRound->start_time was deducting an offset from a GMT time - bad
            if ($this->jRound->start_time < gmdate('Y-m-d H:i:s') or $jTipsCurrentUser->hasTipped($this->jRound->id) and $jTips['TipLockout'] == 1) {
                $disabled = "disabled";
            } else {
                $disabled = '';
            }
            $hasTipped = count($jTipss) > 0;
            $rowIndex = 0;
            foreach ($jGames as $jGame) {
                $leftTeam = new jTeam($database);
                $rightTeam = new jTeam($database);
                $jTipParams = array('user_id' => $jTipsCurrentUser->id, 'game_id' => $jGame->id);
                $jTip->loadByParams($jTipParams);
                $left_id_field = $left . '_id';
                $right_id_field = $right . '_id';
                $leftLoaded = $rightLoaded = false;
                if ($jGame->{$left_id_field}) {
                    $leftTeam->load($jGame->{$left_id_field});
                    $leftLoaded = true;
                }
                if ($jGame->{$right_id_field}) {
                    $rightTeam->load($jGame->{$right_id_field});
                    $rightLoaded = true;
                }
                if (!$leftLoaded and $rightLoaded) {
                    $this->byes[] = $rightTeam;
                }
                if ($leftLoaded and !$rightLoaded) {
                    $this->byes[] = $leftTeam;
                }
                if (!$leftLoaded or !$rightLoaded) {
                    continue;
                }
                if ($jGame->winner_id == $leftTeam->id) {
                    $left_style = "font-weight:bold;";
                    $right_style = "";
                } else {
                    if ($jGame->winner_id == -1) {
                        $left_style = "font-style:italics;";
                        $right_style = "font-style:italics;";
                    } else {
                        if ($jGame->winner_id == $rightTeam->id) {
                            $left_style = "";
                            $right_style = "font-weight:bold;";
                        } else {
                            $left_style = "";
                            $right_style = "";
                        }
                    }
                }
                $rowClasses = "class='sectiontableentry" . ($rowIndex % 2 + 1) . " jtablerow" . ($rowIndex % 2 + 1) . "'";
                if ($this->jSeason->pick_score and $jGame->has_score) {
                    $onClick = 'onClick="switchScore(' . $jGame->id . ');"';
                } else {
                    $onClick = '';
                }
                ?>
				<tr <?php 
                echo $rowClasses;
                ?>
>
					<td style='text-align:right;<?php 
                echo $left_style;
                ?>
'><label for="<?php 
                echo $left;
                ?>
_game<?php 
                echo $jGame->id;
                ?>
"><?php 
                echo $leftTeam->getDisplayLogoName('right');
                ?>
</label>&nbsp;
						<?php 
                if ($this->jSeason->pick_score and !$jTips['HideTeamSelect'] or !$this->jSeason->pick_score) {
                    ?>
							<input type='radio' <?php 
                    echo $onClick;
                    ?>
 class="inputbox" name='game<?php 
                    echo $jGame->id;
                    ?>
' id='<?php 
                    echo $left;
                    ?>
_game<?php 
                    echo $jGame->id;
                    ?>
' value='<?php 
                    echo $leftTeam->id;
                    ?>
' <?php 
                    echo $jTip->tip_id == $leftTeam->id ? 'checked="checked"' : '';
                    ?>
 <?php 
                    echo $disabled;
                    ?>
 />
							<?php 
                }
                ?>
					</td>
					<?php 
                if ($this->jSeason->team_starts) {
                    $left_start_field = $left . '_start';
                    $leftStart = $jGame->{$left_start_field} + 0;
                    if ($jGame->{$left_start_field} > 0) {
                        $leftStart = "+{$leftStart}";
                    } else {
                        if ($leftStart == 0) {
                            $leftStart = "&nbsp;";
                        }
                    }
                    ?>
                        <td style='text-align:center;'><?php 
                    echo $leftStart;
                    ?>
</td>
                        <?php 
                }
                if ($this->jSeason->pick_score == 1) {
                    ?>
						<td style='text-align:center;'>
						<?php 
                    if ($jGame->has_score == 1) {
                        ?>
							<input type='text' onKeyUp="this.value=this.value.replace(/[^\d]+/, '');" class="inputbox" id="<?php 
                        echo $left . $jGame->id;
                        ?>
" name='<?php 
                        echo $left . $jGame->id;
                        ?>
' style='text-align:center;' maxLength='5' size='5' value='<?php 
                        $left_score_field = $left . '_score';
                        echo $jTip->{$left_score_field};
                        ?>
' <?php 
                        echo $disabled;
                        ?>
 onBlur="setSelectedTeam(<?php 
                        echo $jGame->id;
                        ?>
);" />
							<?php 
                    } else {
                        ?>
&nbsp;<?php 
                    }
                    ?>
						</td>
						<?php 
                }
                if ($this->jSeason->pick_draw == 1 and ($this->jSeason->pick_score and !$jTips['HideTeamSelect'] or !$this->jSeason->pick_score)) {
                    ?>
						<td style='text-align:center;'>&nbsp;<input class="inputbox" type='radio' name='game<?php 
                    echo $jGame->id;
                    ?>
' id="draw_game<?php 
                    echo $jGame->id;
                    ?>
" value='-1' <?php 
                    echo $jTip->tip_id == -1 ? 'checked="checked"' : '';
                    ?>
 <?php 
                    echo $disabled;
                    ?>
 <?php 
                    echo $onClick;
                    ?>
/></td>
						<?php 
                } else {
                    ?>
						<td style='text-align:center;'>&nbsp;<?php 
                    echo $jLang['_COM_TEAM_VS'];
                    ?>
&nbsp;</td>
						<?php 
                }
                if ($this->jSeason->pick_score == 1) {
                    ?>
						<td style='text-align:center;'>
						<?php 
                    if ($jGame->has_score == 1) {
                        ?>
							<input type='text' onKeyUp="this.value=this.value.replace(/[^\d]+/, '');" class="inputbox" id="<?php 
                        echo $right . $jGame->id;
                        ?>
" name='<?php 
                        echo $right . $jGame->id;
                        ?>
' style='text-align:center;' maxLength='5' size='5' value='<?php 
                        $right_score_field = $right . '_score';
                        echo $jTip->{$right_score_field};
                        ?>
' <?php 
                        echo $disabled;
                        ?>
 onBlur="setSelectedTeam(<?php 
                        echo $jGame->id;
                        ?>
);" />
							<?php 
                    } else {
                        ?>
&nbsp;<?php 
                    }
                    ?>
						</td>
						<?php 
                }
                $right_start_field = $right . '_start';
                if ($this->jSeason->team_starts) {
                    $rightStart = $jGame->{$right_start_field} + 0;
                    if ($jGame->{$right_start_field} > 0) {
                        $rightStart = "+{$rightStart}";
                    } else {
                        if ($rightStart == 0) {
                            $rightStart = "&nbsp;";
                        }
                    }
                    ?>
                        <td style='text-align:center;'><?php 
                    echo $rightStart;
                    ?>
</td>
                        <?php 
                }
                ?>
					<td style='text-align:left;<?php 
                echo $right_style;
                ?>
'>
						<?php 
                if ($this->jSeason->pick_score and !$jTips['HideTeamSelect'] or !$this->jSeason->pick_score) {
                    ?>
							<input type='radio' <?php 
                    echo $onClick;
                    ?>
  class="inputbox" name='game<?php 
                    echo $jGame->id;
                    ?>
' value='<?php 
                    echo $rightTeam->id;
                    ?>
' <?php 
                    echo $jTip->tip_id == $rightTeam->id ? 'checked="checked"' : '';
                    ?>
 <?php 
                    echo $disabled;
                    ?>
 id="<?php 
                    echo $right;
                    ?>
_game<?php 
                    echo $jGame->id;
                    ?>
"/>
							<?php 
                }
                ?>
						&nbsp;<label for="<?php 
                echo $right;
                ?>
_game<?php 
                echo $jGame->id;
                ?>
"><?php 
                echo $rightTeam->getDisplayLogoName('left');
                ?>
</label>
					</td>
					<?php 
                if ($this->jSeason->pick_margin == 1) {
                    ?>
						<td style='text-align:center;'>
						<?php 
                    if ($jGame->has_margin == 1) {
                        ?>
							<input type='text' onKeyUp="this.value=this.value.replace(/[^\d]+/, '');" class="inputbox" name='margin<?php 
                        echo $jGame->id;
                        ?>
' style='text-align:center;' maxLength='5' size='5' value='<?php 
                        echo $jTip->margin;
                        ?>
' <?php 
                        echo $disabled;
                        ?>
 />
							<?php 
                    } else {
                        ?>
&nbsp;<?php 
                    }
                    ?>
						</td>
						<?php 
                }
                if ($this->jSeason->pick_bonus > 0) {
                    if ($jGame->has_bonus == 1) {
                        // BUG 302 - awayTeam and homeTeam do not exist anymore
                        $bonusTeams = array('' => $jLang['_ADMIN_CONF_NONE'], $jGame->{$left_id_field} => $leftTeam->getName(), $jGame->{$right_id_field} => $rightTeam->getName());
                        if ($this->jSeason->pick_bonus == 2) {
                            $bonusTeams['-2'] = $jLang['_ADMIN_SEASON_EPTB_BOT'];
                        }
                        ?>
							<td style='text-align:center;'><?php 
                        echo makeSelectList($bonusTeams, 'bonus' . $jGame->id, "{$disabled} class='inputbox'", $jTip->bonus_id);
                        ?>
</td>
							<?php 
                    } else {
                        ?>
							<td style='text-align:center;'>&nbsp;</td>
							<?php 
                    }
                }
                //show the game time
                if ($this->jSeason->game_times) {
                    ?>
<td><?php 
                    if ($jGame->start_time) {
                        echo TimeDate::toDisplayDateTime($jGame->start_time, false);
                    } else {
                        echo "&nbsp;";
                    }
                    ?>
</td><?php 
                }
                if ($this->jRound->scored == 1) {
                    $left_score_field = $left . '_score';
                    $right_score_field = $right . '_score';
                    ?>
							<th <?php 
                    echo $tags;
                    ?>
><?php 
                    echo $jGame->{$left_score_field} . " - " . $jGame->{$right_score_field};
                    ?>
&nbsp;</th>
						<?php 
                }
                ?>
<td><?php 
                if (!empty($jGame->description)) {
                    $description = nl2br(stripslashes($jGame->description));
                    echo jTipsToolTip($description, $jLang['_COM_GAME_ADDITIONAL_INFO']);
                } else {
                    echo "&nbsp;";
                }
                ?>
</td>
				</tr>
				<?php 
                $rowIndex++;
            }
            ?>
			</table>
			<div>
			<?php 
            $this->renderByes();
            ?>
			<table width="100%" cellspacing="10">
			<?php 
            if ($jTips['DoubleUp'] == 1) {
                if ($jTipsCurrentUser->doubleup > 0 && $jTipsCurrentUser->doubleup < $this->jRound->id || $disabled == 'disabled') {
                    $disable_doubleup = 'disabled';
                } else {
                    $disable_doubleup = '';
                }
                ?>
				<tr>
					<td style='text-align:center'><h4><label for="doubleup"><?php 
                echo $jLang['_COM_GAME_USEDOUBLE'];
                ?>
</label>&nbsp;<input type='checkbox' class="inputbox" id="doubleup" name='doubleup' value='<?php 
                echo $this->jRound->id;
                ?>
' <?php 
                echo $jTipsCurrentUser->doubleup == $this->jRound->id ? "checked" : "";
                ?>
 <?php 
                echo $disable_doubleup;
                ?>
 /></h4></td>
				</tr>
				<?php 
            }
            if ($jTips['EnableComments'] == 1) {
                if ($disabled == 'disabled') {
                    $commentArea = "<em>";
                    if (strlen($this->jComment->comment) > 0) {
                        $commentArea .= $this->jComment->comment;
                    } else {
                        $commentArea .= $jLang['_ADMIN_CONF_NONE'];
                    }
                    $commentArea .= "</em>";
                } else {
                    $comment = str_replace('"', "'", $this->jComment->comment);
                    $commentArea = '
					<input name="comment" id="comment" size="50" class="inputbox" value="' . $comment . '" />
					';
                }
                ?>
				<tr>
					<td style="text-align:center;"><?php 
                echo $jLang['_COM_DASH_COMMENT'];
                ?>
: <?php 
                echo $commentArea;
                ?>
</td>
				</tr>
				<?php 
            }
            ?>
			<tr>
				<td style='text-align:center' id='submittipsbuttonarea'><?php 
            echo $disabled != "disabled" ? "<input type='button' class='button' name='submittips' id='submittips' value='" . $jLang['_COM_TIPS_SAVE'] . "' {$checkComment} />" : "";
            ?>
</td>
			</tr>
			<tr>
				<td style='text-align:center; padding-top:5px; display:none;' id='ajaxloading'></td>
			</tr>
			</table>
			</div>
			<input type='hidden' name='round_id' value='<?php 
            echo $this->jRound->id;
            ?>
' />
			</form>
			<?php 
        } else {
            if ($this->jRound->exists() and TimeDate::toDatabaseDateTime($this->jRound->start_time) > gmdate('Y-m-d H:i:s')) {
                ?>
			<h2 style='text-align:center'><?php 
                echo $jLang['_COM_DASH_ROUND'] . " " . $this->jRound->round;
                ?>
</h2>
			<h2 style='text-align:center'><?php 
                echo $jLang['_COM_ROUND_CLOSED'];
                ?>
</h2>
			<?php 
            } else {
                if ($this->jRound->exists()) {
                    ?>
				<h2 style='text-align:center'><?php 
                    echo $jLang['_COM_DASH_ROUND'] . " " . $this->jRound->round;
                    ?>
</h2>
				<?php 
                } else {
                    ?>
				<h2 style='text-align:center'><?php 
                    echo $jLang['_COM_ROUND_NOGAMES'];
                    ?>
</h2>
				<?php 
                }
            }
        }
        if ($this->jRound->getStatus() === false and !empty($jTipsCurrentUser->id)) {
            $userTime = strtotime($this->jRound->start_time) - TimeDate::getOffset(false);
            $targetTime = date('Y-m-d H:i:s', $userTime);
            if ($jTips['ShowJSCountdown'] == 1) {
                $field = "'countdown'";
            } else {
                $field = "false";
            }
            ?>
			<script type='text/javascript'>
				window.addEvent('domready', function(){
					var year = <?php 
            echo TimeDate::format($targetTime, '%Y', true, false);
            ?>
;
					var month = <?php 
            echo TimeDate::format($targetTime, '%m', true, false) - 1;
            ?>
;
					var day = <?php 
            echo TimeDate::format($targetTime, '%d', true, false);
            ?>
;
					var hour = <?php 
            echo TimeDate::format($targetTime, '%H', true, false);
            ?>
;
					var min = <?php 
            echo TimeDate::format($targetTime, '%M', true, false);
            ?>
;
					var sec = 0;
					jTipsCountdown(year, month, day, hour, min, 1, <?php 
            echo $field;
            ?>
);
				});
			</script>
			<?php 
        }
    }
示例#20
0
 function getUsers($round_id = FALSE)
 {
     global $database;
     if ($round_id === FALSE) {
         // BUG 304 - join with users table to avoid trying to load ids with no matching user
         $params = array('#__jtips_users.season_id' => $this->id, '#__jtips_users.status' => 1, 'join' => array('type' => 'join', 'join_table' => '#__users', 'lhs_table' => '#__jtips_users', 'lhs_key' => 'user_id', 'rhs_table' => '#__users', 'rhs_key' => 'id'));
     } else {
         $params = array('#__jtips_users.id' => array('type' => 'in', 'query' => 'SELECT #__jtips_history.user_id FROM #__jtips_history WHERE #__jtips_history.round_id = ' . $round_id), '#__jtips_users.season_id' => $this->id, '#__jtips_users.status' => 1);
     }
     $jTipsUser = new jTipsUser($database);
     $jTipsUsers = forceArray($jTipsUser->loadByParams($params));
     $this->users = $jTipsUsers;
     return $jTipsUsers;
 }
示例#21
0
文件: edit.php 项目: joomux/jTips
require_once 'components/com_jtips/classes/jseason.class.php';
require_once 'components/com_jtips/classes/jteam.class.php';
$jTeam = new jTeam($database);
$ids = jTipsGetParam($_REQUEST, 'cid', array());
//Do we have an existing Season?
$id = array_shift($ids);
if (is_numeric($id)) {
    $jTeam->load($id);
}
//set the page title
$title = $jLang['_ADMIN_TEAM_TITLE'] . ": " . ($jTeam->exists() ? $jLang['_ADMIN_OTHER_EDIT'] : $jLang['_ADMIN_OTHER_NEW']);
//set the custom javascripts
$mainframe->addCustomHeadTag("<script type='text/javascript' src='components/com_jtips/modules/Teams/Teams.js'></script>");
//what seasons are there
$jSeason = new jSeason($database);
$jSeasons = forceArray($jSeason->loadByParams(array()));
$jSeasonOptions = array(jTipsHTML::makeOption('', $jLang['_ADMIN_CONF_NONE']));
jTipsSortArrayObjects($jSeasons, 'name', 'ASC');
foreach ($jSeasons as $season) {
    $jSeasonOptions[] = jTipsHTML::makeOption($season->id, $season->name);
}
//build the field definitions
$formData = array('basic' => array('legend' => '_ADMIN_BASIC_INFORMATION', 'fields' => array('id' => array('field' => array('type' => 'hidden', 'attributes' => array('type' => 'hidden', 'name' => 'id', 'id' => 'id', 'value' => $jTeam->id))), 'season' => array('label' => '_ADMIN_TEAM_SEASON', 'field' => array('type' => 'select', 'attributes' => array('name' => 'season_id', 'id' => 'season_id', 'class' => 'inputbox'), 'options' => $jSeasonOptions, 'selected' => $jTeam->season_id)), 'name' => array('label' => '_ADMIN_TEAM_NAME', 'field' => array('type' => 'text', 'attributes' => array('name' => 'name', 'id' => 'name', 'class' => 'inputbox', 'size' => '50', 'type' => 'text', 'value' => $jTeam->name))), 'location' => array('label' => '_ADMIN_TEAM_LOCATION', 'field' => array('type' => 'text', 'attributes' => array('name' => 'location', 'id' => 'location', 'class' => 'inputbox', 'size' => '50', 'type' => 'text', 'value' => $jTeam->location))), 'website' => array('label' => '_ADMIN_TEAM_URL', 'field' => array('type' => 'text', 'attributes' => array('name' => 'url', 'id' => 'url', 'class' => 'inputbox', 'size' => '50', 'type' => 'text', 'value' => $jTeam->url))), 'about' => array('label' => '_ADMIN_TEAM_ABOUT', 'field' => array('type' => 'editor', 'attributes' => array('name' => 'about', 'id' => 'about', 'class' => 'inputbox', 'value' => jTipsStripslashes($jTeam->about)))))));
$formData['image'] = array('legend' => '_ADMIN_TEAM_LOGO', 'fields' => array('logo' => array('label' => '_ADMIN_TEAM_LOGO', 'field' => array('type' => 'file', 'attributes' => array('size' => '50', 'type' => 'file', 'class' => 'inputbox', 'name' => 'logo', 'id' => 'logo')))));
if ($jTeam->logo) {
    $formData['image']['fields']['current_logo'] = array('label' => '_ADMIN_TEAM_CURRENT_LOGO', 'field' => array('type' => 'img', 'attributes' => array('alt' => 'Logo', 'id' => 'current_logo', 'src' => $mosConfig_live_site . '/' . getJtipsImage($jTeam->logo, 100))));
    $formData['image']['fields']['remove_logo'] = array('label' => '_ADMIN_TEAM_REMOVE_LOGO', 'field' => array('type' => 'checkbox', 'attributes' => array('class' => 'inputbox', 'name' => 'remove_logo', 'value' => '1', 'type' => 'checkbox', 'onClick' => 'if (this.checked){$("logo").disabled=true;}else{$("logo").disabled=false}')), 'description' => '_ADMIN_TEAM_REMOVE_LOGO_DEF');
}
// BUG 287 - can no longer edit team points
/*$formData['points'] = array(
	'legend' => '_ADMIN_TEAM_POINTS_ADJUST',
示例#22
0
 /**
  * Updates the team points based on the round passed in
  */
 static function updateLadder($jRound, $jSeason)
 {
     jTipsLogger::_log('updating team ladder for round ' . $jRound->id);
     global $database;
     $params = array('round_id' => $jRound->id);
     $jGame = new jGame($database);
     $jGames = forceArray($jGame->loadByParams($params));
     $byeTeams = array();
     foreach ($jGames as $jGame) {
         $home = new jTeam($database);
         $away = new jTeam($database);
         $homeLoaded = $awayLoaded = false;
         if ($jGame->home_id) {
             $home->load($jGame->home_id);
             $homeLoaded = true;
         }
         if ($jGame->away_id) {
             $away->load($jGame->away_id);
             $awayLoaded = true;
         }
         if (!$homeLoaded and $awayLoaded) {
             $byeTeams[] = $away;
         }
         if ($homeLoaded and !$awayLoaded) {
             $byeTeams[] = $home;
         }
         if (!$homeLoaded or !$awayLoaded) {
             continue;
         }
         // nothing to process here
         $home->wins = $home->_getNumberOfWins();
         $home->losses = $home->_getNumberOfLosses();
         $home->draws = $home->_getNumberOfDraws();
         $home->points_for = $home->_getPointsFor();
         $home->points_against = $home->_getPointsAgainst();
         $home->points = $home->_getTotalPoints();
         $away->wins = $away->_getNumberOfWins();
         $away->losses = $away->_getNumberOfLosses();
         $away->draws = $away->_getNumberOfDraws();
         $away->points_for = $away->_getPointsFor();
         $away->points_against = $away->_getPointsAgainst();
         $away->points = $away->_getTotalPoints();
         $home->save();
         $away->save();
     }
     if (!empty($byeTeams)) {
         foreach ($byeTeams as $team) {
             $team->wins = $team->_getNumberOfWins();
             $team->losses = $team->_getNumberOfLosses();
             $team->draws = $team->_getNumberOfDraws();
             $team->points_for = $team->_getPointsFor();
             $team->points_against = $team->_getPointsAgainst();
             $team->points = $team->_getTotalPoints();
             $team->points += $jSeason->team_bye;
             $team->save();
         }
     }
 }
示例#23
0
    $data = JFile::read(dirname(__FILE__) . '/installer.xml');
    JFile::write(dirname(__FILE__) . '/mod_jtips_dash_comp_ladder.xml', $data);
    JFile::delete(dirname(__FILE__) . '/installer.xml');
}
$jSeason = new jSeason($database);
$season_id = getSeasonID();
if (is_numeric($season_id)) {
    $jSeason->load($season_id);
} else {
    $date = gmdate('Y-m-d');
    //Bug 33.4 - Extended params array to default to season for current user
    $objParams = array('end_time' => array('type' => 'query', 'query' => "> '{$date}'"), 'left_join' => array('type' => 'left_join', 'join_table' => '#__jtips_users', 'lhs_table' => '#__jtips_seasons', 'lhs_key' => 'id', 'rhs_table' => '#__jtips_users', 'rhs_key' => 'season_id'));
    if (isset($jTipsUser->user_id) and !empty($jTipsUser->user_id)) {
        $objParams['#__jtips_users.user_id'] = $jTipsUser->user_id;
    }
    $jSeasons = forceArray($jSeason->loadByParams($objParams));
    if (count($jSeasons) > 0) {
        $jSeason =& array_shift($jSeasons);
    }
}
$jRound = new jRound($database);
$round_id = $jSeason->getCurrentRound();
$jRound->load($round_id);
if ($jRound->scored == 0) {
    $prev_round_id = $jSeason->getLastRound();
    $prev_round = new jRound($database);
    $prev_round->load($prev_round_id);
    $jRound =& $prev_round;
    $load_round = $prev_round_id;
} else {
    $load_round = $jRound->id;
示例#24
0
文件: edit.php 项目: joomux/jTips
//Do we have an existing Season?
$id = array_shift($ids);
if (is_numeric($id)) {
    $jComment->load($id);
}
if (!$jComment->exists()) {
    mosRedirect('index2.php?option=com_jtips&task=list&module=Comments', $jLang['_ADMIN_COMMENT_LOAD_ERROR']);
}
$jTipsUser = new jTipsUser($database);
$jTipsUser->load($jComment->user_id);
$title = $jLang['_ADMIN_DASH_COMMENT_MANAGER'] . ": " . $jLang['_ADMIN_OTHER_EDIT'];
$mainframe->addCustomHeadTag("<script type='text/javascript' src='components/com_jtips/modules/Comments/Comments.js'></script>");
//what seasons are there
$jSeason = new jSeason($database);
$jSeasons = forceArray($jSeason->loadByParams(array()));
$jSeasonOptions = array(jTipsHTML::makeOption('', $jLang['_ADMIN_CONF_NONE']));
jTipsSortArrayObjects($jSeasons, 'name', 'ASC');
foreach ($jSeasons as $season) {
    $jSeasonOptions[] = jTipsHTML::makeOption($season->id, $season->name);
}
//which season is this in?
$jRound = new jRound($database);
$jRound->load($jComment->round_id);
$jRounds = forceArray($jRound->loadByParams(array('season_id' => $jRound->season_id)));
$jRoundOptions = array(jTipsHTML::makeOption('', $jLang['_ADMIN_CONF_NONE']));
jTipsSortArrayObjects($jSeasons, 'name', 'ASC');
foreach ($jRounds as $round) {
    $jRoundOptions[] = jTipsHTML::makeOption($round->id, $round->round);
}
$formData = array('basic' => array('legend' => '_ADMIN_COMM_EDIT_COMMENT', 'fields' => array('id' => array('field' => array('type' => 'hidden', 'attributes' => array('type' => 'hidden', 'name' => 'id', 'id' => 'id', 'value' => $jComment->id))), 'orig_round_id' => array('field' => array('type' => 'hidden', 'attributes' => array('type' => 'hidden', 'name' => 'orig_round_id', 'id' => 'orig_round_id', 'value' => $jComment->round_id))), 'user_id' => array('label' => '_COM_DASH_USER', 'field' => array('type' => 'hidden', 'attributes' => array('type' => 'hidden', 'name' => 'user_id', 'id' => 'user_id', 'value' => $jComment->user_id))), 'user' => array('label' => '_COM_DASH_USER', 'field' => array('type' => 'label', 'attributes' => array('type' => 'label', 'value' => $jTipsUser->getUserField('name') . " (" . $jTipsUser->getUserField('username') . ")"))), 'season_id' => array('label' => '_ADMIN_ROUND_SEASON', 'field' => array('type' => 'select', 'attributes' => array('name' => 'season_id', 'id' => 'season_id', 'class' => 'inputbox', 'onChange' => 'getTheRounds(this);'), 'options' => $jSeasonOptions, 'selected' => $jRound->season_id)), 'round_id' => array('label' => '_ADMIN_ROUND_ROUND', 'field' => array('type' => 'select', 'attributes' => array('name' => 'round_id', 'id' => 'round_id', 'class' => 'inputbox'), 'options' => $jRoundOptions, 'selected' => $jComment->round_id)), 'comment' => array('label' => '_ADMIN_COMM_EDIT_COMMENT', 'field' => array('type' => 'text', 'attributes' => array('size' => 50, 'name' => 'comment', 'id' => 'comment', 'class' => 'inputbox', 'type' => 'text', 'value' => jTipsStripslashes(htmlentities($jComment->comment, ENT_QUOTES))))), 'updatedlabel' => array('label' => '_COM_TIPS_LASTUP', 'field' => array('type' => 'label', 'attributes' => array('type' => 'label', 'value' => TimeDate::toDisplayDateTime($jComment->updated))), 'description' => '_ADMIN_COMMENTS_UDPATED_DESCRIPTION'))));
jTipsAdminDisplay::EditView($title, $formData, 'comments');