예제 #1
0
파일: index.php 프로젝트: nicholasmr/obblm
    if (get_magic_quotes_gpc()) {
        $_POST['coach'] = stripslashes($_POST['coach']);
        $_POST['passwd'] = stripslashes($_POST['passwd']);
    }
    if (!Coach::login($_POST['coach'], $_POST['passwd'], isset($_POST['remember']))) {
        $_GET['section'] = 'login';
    }
}
// Logout?
if ($_VISSTATE['POST_OUT'] = isset($_GET['logout'])) {
    $_GET['section'] = 'main';
    # Redirect logged out users to the main page.
    Coach::logout();
}
if ($_VISSTATE['COOCKIE'] || $_VISSTATE['POST_IN'] || $_VISSTATE['POST_OUT']) {
    setupGlobalVars(T_SETUP_GLOBAL_VARS__POST_COACH_LOGINOUT);
}
HTMLOUT::frame_begin(isset($_SESSION['logged_in']) ? $coach->settings['theme'] : $settings['stylesheet']);
# Make page frame, banner and menu.
MTS('Header loaded, login auth, html frame generated');
// Check if a menu-link was picked, and execute section code from sections.php accordingly.
switch ($_GET['section']) {
    case 'login':
        sec_login();
        break;
    case 'admin':
        sec_admin();
        break;
    case 'teamlist':
        sec_teamlist();
        break;
예제 #2
0
 public function isJMLimitReached()
 {
     global $rules;
     setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS, array('lid' => $this->f_lid));
     // Load correct $rules for league.
     return $rules['journeymen_limit'] <= (int) SQLFetchField("SELECT COUNT(*) FROM players WHERE owned_by_team_id = {$this->team_id} AND date_sold IS NULL AND date_died IS NULL AND status = " . NONE);
 }
예제 #3
0
    private function _newTeam($ALLOW_EDIT)
    {
        global $lng, $settings, $raceididx, $rules;
        global $leagues, $divisions;
        // Form posted? -> Create team.
        if (isset($_POST['type']) && $_POST['type'] == 'newteam' && $ALLOW_EDIT) {
            if (get_magic_quotes_gpc()) {
                $_POST['name'] = stripslashes($_POST['name']);
            }
            @(list($lid, $did) = explode(',', $_POST['lid_did']));
            setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS, array('lid' => (int) $lid));
            // Load correct $rules for league.
            list($exitStatus, $tid) = Team::create(array('name' => $_POST['name'], 'owned_by_coach_id' => (int) $this->coach_id, 'f_race_id' => (int) $_POST['rid'], 'treasury' => $rules['initial_treasury'], 'apothecary' => 0, 'rerolls' => $rules['initial_rerolls'], 'ff_bought' => $rules['initial_fan_factor'], 'ass_coaches' => $rules['initial_ass_coaches'], 'cheerleaders' => $rules['initial_cheerleaders'], 'won_0' => 0, 'lost_0' => 0, 'draw_0' => 0, 'played_0' => 0, 'wt_0' => 0, 'gf_0' => 0, 'ga_0' => 0, 'imported' => 0, 'f_lid' => (int) $lid, 'f_did' => isset($did) ? (int) $did : Team::T_NO_DIVISION_TIE));
            status(!$exitStatus, $exitStatus ? Team::$T_CREATE_ERROR_MSGS[$exitStatus] : null);
        }
        // Show new team form.
        ?>
    <br><br>
    <div class='boxCommon'>
        <h3 class='boxTitle<?php 
        echo T_HTMLBOX_COACH;
        ?>
'><?php 
        echo $lng->getTrn('cc/new_team');
        ?>
</h3>
        <div class='boxBody'>
        
    <form method="POST">
    <?php 
        echo $lng->getTrn('common/name');
        ?>
<br>
    <input type="text" name="name" size="20" maxlength="50">
    <br><br>
    <?php 
        echo $lng->getTrn('common/race');
        ?>
<br>
    <select name="rid">
        <?php 
        // We need to sort the array manually because of the translation
        foreach ($raceididx as $rid => &$rname) {
            $rname = $lng->getTrn('race/' . strtolower(str_replace(' ', '', $rname)));
        }
        unset($rname);
        // very important !
        asort($raceididx);
        // The, we display as usual
        foreach ($raceididx as $rid => $rname) {
            echo "<option value='{$rid}'>{$rname}</option>\n";
        }
        ?>
    </select>
    <br><br>
    <?php 
        echo $lng->getTrn('common/league') . '/' . $lng->getTrn('common/division');
        ?>
<br>
    <select name="lid_did">
        <?php 
        foreach ($leagues = Coach::allowedNodeAccess(Coach::NODE_STRUCT__TREE, $this->coach_id, array(T_NODE_LEAGUE => array('tie_teams' => 'tie_teams'))) as $lid => $lstruct) {
            if ($lstruct['desc']['tie_teams']) {
                echo "<OPTGROUP LABEL='" . $lng->getTrn('common/league') . ": " . $lstruct['desc']['lname'] . "'>\n";
                foreach ($lstruct as $did => $dstruct) {
                    if ($did != 'desc') {
                        echo "<option value='{$lid},{$did}'>" . $lng->getTrn('common/division') . ": " . $dstruct['desc']['dname'] . "</option>";
                    }
                }
                echo "</OPTGROUP>\n";
            } else {
                echo "<option value='{$lid}'>" . $lng->getTrn('common/league') . ": " . $lstruct['desc']['lname'] . "</option>";
            }
        }
        ?>
    </select>
    <br><br>    
    <input type='hidden' name='type' value='newteam'>
    <input type="submit" name="new_team" value="<?php 
        echo $lng->getTrn('common/create');
        ?>
" <?php 
        echo count($leagues) == 0 ? 'DISABLED' : '';
        ?>
>
    </form>
        </div>
    </div>
    <?php 
    }
예제 #4
0
 public static function main($argv)
 {
     global $pdf;
     global $DEA;
     global $skillarray;
     global $rules;
     global $inducements;
     define("MARGINX", 20);
     define("MARGINY", 20);
     define("DEFLINECOLOR", '#000000');
     define("HEADLINEBGCOLOR", '#c3c3c3');
     // Custom settings for inducements.
     define('MAX_STARS', 2);
     define('MERC_EXTRA_COST', 30000);
     define('MERC_EXTRA_SKILL_COST', 50000);
     // Color codes.
     define('COLOR_ROSTER_NORMAL', COLOR_HTML_NORMAL);
     define('COLOR_ROSTER_READY', COLOR_HTML_READY);
     define('COLOR_ROSTER_MNG', COLOR_HTML_MNG);
     define('COLOR_ROSTER_DEAD', COLOR_HTML_DEAD);
     define('COLOR_ROSTER_SOLD', COLOR_HTML_SOLD);
     define('COLOR_ROSTER_STARMERC', COLOR_HTML_STARMERC);
     define('COLOR_ROSTER_JOURNEY', COLOR_HTML_JOURNEY);
     define('COLOR_ROSTER_JOURNEY_USED', COLOR_HTML_JOURNEY_USED);
     define('COLOR_ROSTER_NEWSKILL', COLOR_HTML_NEWSKILL);
     //-----
     define('COLOR_ROSTER_CHR_EQP1', COLOR_HTML_CHR_EQP1);
     // Characteristic equal plus one.
     define('COLOR_ROSTER_CHR_GTP1', COLOR_HTML_CHR_GTP1);
     // Characteristic greater than plus one.
     define('COLOR_ROSTER_CHR_EQM1', COLOR_HTML_CHR_EQM1);
     // Characteristic equal minus one.
     define('COLOR_ROSTER_CHR_LTM1', COLOR_HTML_CHR_LTM1);
     // Characteristic less than minus one.
     define('T_PDF_ROSTER_SET_EMPTY_ON_ZERO', true);
     # Prints cp, td etc. as '' (empty string) when field = 0.
     $ind_cost = 0;
     //
     // Most of team and player data is copy/pasted from teams.php
     //
     $team_id = $_GET['team_id'];
     // Is team id valid?
     if (!get_alt_col('teams', 'team_id', $team_id, 'team_id')) {
         fatal("Invalid team ID.");
     }
     $team = new Team($team_id);
     $coach = isset($_SESSION['logged_in']) ? new Coach($_SESSION['coach_id']) : null;
     setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS, array('lid' => $team->f_lid));
     // Load correct $rules for league.
     $players = $team->getPlayers();
     $tmp_players = array();
     foreach ($players as $p) {
         if ($p->is_dead || $p->is_sold) {
             continue;
         }
         array_push($tmp_players, $p);
     }
     $players = $tmp_players;
     // Team specific data
     $rerollcost = $DEA[$team->f_rname]['other']['rr_cost'];
     $pdf = new BB_PDF('L', 'pt', 'A4');
     // Creating a new PDF doc. Landscape, scale=pixels, size A4
     $pdf->SetAutoPageBreak(false, 20);
     // No auto page break to mess up layout
     $pdf->SetAuthor('Daniel Straalman');
     $pdf->SetCreator('OBBLM');
     $pdf->SetTitle('PDF Roster for ' . utf8_decode($team->name));
     $pdf->SetSubject('PDF Roster for ' . utf8_decode($team->name));
     $pdf->AddFont('Tahoma', '', 'tahoma.php');
     // Adding regular font Tahoma which is in font dir
     $pdf->AddFont('Tahoma', 'B', 'tahomabd.php');
     // Adding Tahoma Bold
     // Initial settings
     $pdf->SetFont('Tahoma', 'B', 14);
     $pdf->AddPage();
     $pdf->SetLineWidth(1.5);
     $currentx = MARGINX;
     $currenty = MARGINY;
     $pdf->SetFillColorBB($pdf->hex2cmyk(HEADLINEBGCOLOR));
     $pdf->RoundedRect($currentx, $currenty, 802, 20, 6, 'DF');
     // Filled rectangle around Team headline
     $pdf->SetDrawColorBB($pdf->hex2cmyk(DEFLINECOLOR));
     // Text in headline
     $pdf->SetXY($currentx + 30, $currenty);
     $pdf->Cell(310, 20, utf8_decode($team->name), 0, 0, 'L', false, '');
     $pdf->SetFont('Tahoma', '', 12);
     $pdf->Cell(60, 20, "Race:", 0, 0, 'R', false, '');
     $pdf->Cell(70, 20, $team->f_rname, 0, 0, 'L', false, '');
     $pdf->Cell(300, 20, "Head Coach: " . utf8_decode($team->f_cname), 0, 0, 'R', false, '');
     $currenty += 25;
     $currentx += 6;
     $pdf->SetXY($currentx, $currenty);
     $pdf->SetFillColorBB($pdf->hex2cmyk(HEADLINEBGCOLOR));
     $pdf->SetDrawColorBB($pdf->hex2cmyk(DEFLINECOLOR));
     $pdf->SetFont('Tahoma', 'B', 8);
     $pdf->SetLineWidth(1.5);
     $h = 14;
     // Printing headline for player table
     $pdf->Cell(23, $h, 'Nr', 1, 0, 'C', true, '');
     $pdf->Cell(97, $h, 'Name', 1, 0, 'L', true, '');
     $pdf->Cell(75, $h, 'Position', 1, 0, 'L', true, '');
     $pdf->Cell(18, $h, 'MA', 1, 0, 'C', true, '');
     $pdf->Cell(18, $h, 'ST', 1, 0, 'C', true, '');
     $pdf->Cell(18, $h, 'AG', 1, 0, 'C', true, '');
     $pdf->Cell(18, $h, 'AV', 1, 0, 'C', true, '');
     $pdf->Cell(329, $h, 'Skills and Injuries', 1, 0, 'L', true, '');
     $pdf->Cell(23, $h, 'MNG', 1, 0, 'C', true, '');
     $pdf->Cell(21, $h, 'CP', 1, 0, 'C', true, '');
     $pdf->Cell(21, $h, 'TD', 1, 0, 'C', true, '');
     $pdf->Cell(21, $h, 'Int', 1, 0, 'C', true, '');
     $pdf->Cell(21, $h, 'Cas', 1, 0, 'C', true, '');
     $pdf->Cell(23, $h, 'MVP', 1, 0, 'C', true, '');
     $pdf->Cell(25, $h, 'SPP', 1, 0, 'C', true, '');
     $pdf->Cell(41, $h, 'Value', 1, 0, 'C', true, '');
     $currenty += 17;
     $pdf->SetXY($currentx, $currenty);
     $pdf->SetFont('Tahoma', '', 8);
     $h = 15;
     // Row/cell height for player table
     //
     // Printing player rows
     //
     $sum_spp = 0;
     $sum_pvalue = 0;
     $sum_p_missing_value = 0;
     $sum_avail_players = 0;
     $sum_players = 0;
     $sum_cp = 0;
     $sum_td = 0;
     $sum_int = 0;
     $sum_cas = 0;
     $sum_mvp = 0;
     $i = 0;
     // Looping through the players and printing the rows
     foreach ($players as $p) {
         $i++;
         $mng = '';
         // Journeymen
         if ($p->is_journeyman) {
             $p->position = 'Journeyman';
             $bgc = COLOR_ROSTER_JOURNEY;
             if ($p->is_journeyman_used) {
                 $bgc = COLOR_ROSTER_JOURNEY_USED;
             }
         } else {
             $bgc = COLOR_ROSTER_NORMAL;
         }
         // Concatenate skills, upgrades and injuries
         $skillstr = $p->getSkillsStr(false);
         $injstr = $p->getInjsStr(false);
         if ($skillstr == '') {
             // No skills
             if ($injstr != '') {
                 $skills_injuries = $injstr;
             } else {
                 $skills_injuries = '';
             }
             // No skills nor injuries
         } else {
             if ($injstr != '') {
                 $skills_injuries = $skillstr . ', ' . $injstr;
             } else {
                 $skills_injuries = $skillstr;
             }
             // Only skills, no injuries
         }
         // Colorcoding new skills available
         if ($p->mayHaveNewSkill()) {
             $bgc = COLOR_ROSTER_NEWSKILL;
         }
         if (!$p->is_mng) {
             $sum_avail_players++;
             $inj = "";
         } else {
             $bgc = COLOR_ROSTER_MNG;
             $sum_p_missing_value += $p->value;
             $inj = "MNG";
             // For MNG column
             // Removing MNG from skills and injuries
             $skills_injuries = str_replace(', MNG', '', $skills_injuries);
             $skills_injuries = str_replace('MNG', '', $skills_injuries);
             $skills_injuries = str_replace('  ', ' ', $skills_injuries);
             // Maybe not needed after changes to rest of code?
         }
         // Characteristic's colors, copied and modified from teams.php
         foreach (array('ma', 'ag', 'av', 'st') as $chr) {
             $sub = $p->{$chr} - $p->{"def_{$chr}"};
             if ($sub == 0) {
                 $p->{"{$chr}_color"} = $bgc;
             } elseif ($sub >= 1) {
                 $p->{"{$chr}_color"} = COLOR_ROSTER_CHR_GTP1;
             } elseif ($sub <= -1) {
                 $p->{"{$chr}_color"} = COLOR_ROSTER_CHR_LTM1;
             }
         }
         $pp = array('nr' => $p->nr, 'name' => utf8_decode($p->name), 'pos' => $p->position, 'ma' => $p->ma, 'st' => $p->st, 'ag' => $p->ag, 'av' => $p->av, 'skills' => $skills_injuries, 'inj' => $inj, 'cp' => $p->mv_cp, 'td' => $p->mv_td, 'int' => $p->mv_intcpt, 'cas' => $p->mv_cas, 'mvp' => $p->mv_mvp, 'spp' => $p->mv_spp, 'value' => $pdf->Mf($p->value));
         $sum_spp += $p->mv_spp;
         $sum_pvalue += $p->value;
         $sum_players++;
         $sum_cp += $p->mv_cp;
         $sum_td += $p->mv_td;
         $sum_int += $p->mv_intcpt;
         $sum_cas += $p->mv_cas;
         $sum_mvp += $p->mv_mvp;
         if (T_PDF_ROSTER_SET_EMPTY_ON_ZERO) {
             foreach (array('cp', 'td', 'int', 'cas', 'mvp', 'spp') as $f) {
                 if ($pp[$f] == 0) {
                     $pp[$f] = '';
                 }
             }
         }
         // Printing player row
         $currenty += $pdf->print_prow($pp, $currentx, $currenty, $h, $bgc, DEFLINECOLOR, 0.5, 8, $p->ma_color, $p->st_color, $p->ag_color, $p->av_color);
     }
     // Filling up with empty rows to max number of players
     $pp = array('nr' => '', 'name' => '', 'pos' => '', 'ma' => '', 'st' => '', 'ag' => '', 'av' => '', 'skills' => '', 'inj' => '', 'cp' => '', 'td' => '', 'int' => '', 'cas' => '', 'mvp' => '', 'spp' => '', 'value' => '');
     $bgc = COLOR_ROSTER_NORMAL;
     while ($i < $rules['max_team_players']) {
         $i++;
         $currenty += $pdf->print_prow($pp, $currentx, $currenty, $h, '#FFFFFF', '#000000', 0.5, 8, $bgc, $bgc, $bgc, $bgc);
     }
     // Sums
     $sum_pvalue -= $sum_p_missing_value;
     $pdf->SetXY($currentx = MARGINX + 6 + 23, $currenty += 4);
     $pdf->print_box($currentx, $currenty, 172, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'R', 'Total number of players next game:');
     $pdf->print_box($currentx += 172, $currenty, 30, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'R', $sum_avail_players . '/' . $sum_players);
     $pdf->SetX($currentx = MARGINX + 6 + 559);
     $pdf->print_box($currentx, $currenty, 60, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'R', 'Totals (excl TV for MNG players):');
     $pdf->print_box($currentx += 60, $currenty, 21, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'C', $sum_cp);
     $pdf->print_box($currentx += 21, $currenty, 21, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'C', $sum_td);
     $pdf->print_box($currentx += 21, $currenty, 21, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'C', $sum_int);
     $pdf->print_box($currentx += 21, $currenty, 21, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'C', $sum_cas);
     $pdf->print_box($currentx += 21, $currenty, 23, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'C', $sum_mvp);
     $pdf->print_box($currentx += 23, $currenty, 25, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'C', $sum_spp);
     $pdf->print_box($currentx += 25, $currenty, 41, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'R', $pdf->Mf($sum_pvalue));
     // Stars and Mercs part of roster
     $currentx = MARGINX + 6 + 23;
     $currenty += $h + 2;
     // Draw rounded rectangle around stars and mercs
     // This rectangle has flexible height depending on how high player table is
     $pdf->SetLineWidth(0.6);
     $pdf->RoundedRect(MARGINX + 6, $currenty, 792, 560 - $currenty - 130, 5, 'D');
     $pdf->SetXY($currentx, $currenty += 2);
     $h = 14;
     $pdf->SetFont('Tahoma', 'B', 8);
     $pdf->Cell(97 + 75, $h, 'Induced Stars and Mercenaries', 0, 0, 'L', true, '');
     $pdf->Cell(18, $h, 'MA', 0, 0, 'C', true, '');
     $pdf->Cell(18, $h, 'ST', 0, 0, 'C', true, '');
     $pdf->Cell(18, $h, 'AG', 0, 0, 'C', true, '');
     $pdf->Cell(18, $h, 'AV', 0, 0, 'C', true, '');
     $pdf->Cell(329, $h, 'Skills', 0, 0, 'L', true, '');
     //$pdf->Cell(23, $h, 'MNG', 1, 0, 'C', true, ''); // No MNG stars/mercs. They heal. ;-)
     $pdf->Cell(21, $h, 'CP', 0, 0, 'C', true, '');
     $pdf->Cell(21, $h, 'TD', 0, 0, 'C', true, '');
     $pdf->Cell(21, $h, 'Int', 0, 0, 'C', true, '');
     $pdf->Cell(21, $h, 'Cas', 0, 0, 'C', true, '');
     $pdf->Cell(23, $h, 'MVP', 0, 0, 'C', true, '');
     $pdf->Cell(25, $h, 'SPP', 0, 0, 'C', true, '');
     $pdf->Cell(41, $h, 'Value', 0, 0, 'R', true, '');
     $currenty += 14;
     $pdf->SetXY($currentx, $currenty);
     $h = 13;
     // Printing chosen stars and mercs
     $pdf->SetFont('Tahoma', '', 8);
     $merc = array(0 => 'No Merc');
     $i = 0;
     if ($_POST) {
         foreach ($DEA[$team->f_rname]["players"] as $p => $m) {
             $i++;
             array_push($merc, $m);
             $pos[$i] = $p;
         }
         $postvars = array();
         # initialize.
         foreach ($_POST as $postkey => $postvalue) {
             if ($postkey == "Submit") {
                 continue;
             }
             if ($postvalue == "0") {
                 continue;
             }
             if ($postvalue == "0k") {
                 continue;
             }
             if ($postvalue == "-No Extra Skill-") {
                 continue;
             }
             $postvars[str_replace('_', ' ', $postkey)] = $postvalue;
         }
         $star_array_tmp[0] = 0;
         $merc_array_tmp[0] = 0;
         while (list($key, $val) = each($postvars)) {
             if (strpos($key, 'Star') !== false) {
                 // if POST key is StarX
                 array_push($star_array_tmp, $val);
                 continue;
             } elseif (strpos($key, 'Merc') !== false) {
                 $merc_nr = preg_replace("/[^0-9]/", "", $key);
                 $merc_array_tmp[$merc_nr] = $pos[$val];
                 if (isset($postvars["Extra{$merc_nr}"])) {
                     $extra_array_tmp[$merc_nr] = $postvars["Extra{$merc_nr}"];
                 } else {
                     $extra_array_tmp[$merc_nr] = '';
                 }
                 continue;
             } elseif ($key == 'Bloodweiser Babes') {
                 $ind_babes = (int) $val;
                 continue;
             } elseif ($key == 'Bribes') {
                 $ind_bribes = (int) $val;
                 continue;
             } elseif ($key == 'Card') {
                 $ind_card = (int) str_replace('k', '000', $val);
                 continue;
             } elseif ($key == 'Extra Training') {
                 $ind_rr = (int) $val;
                 continue;
             } elseif ($key == 'Halfling Master Chef') {
                 $ind_chef = (int) $val;
                 continue;
             } elseif ($key == 'Igor') {
                 $ind_igor = (int) $val;
                 continue;
             } elseif ($key == 'Wandering Apothecaries') {
                 $ind_apo = (int) $val;
                 continue;
             } elseif ($key == 'Wizard') {
                 $ind_wiz = (int) $val;
                 continue;
             }
         }
         // Printing stars first
         if (isset($star_array_tmp[1])) {
             unset($star_array_tmp[0]);
             foreach ($star_array_tmp as $sid) {
                 $s = new Star($sid);
                 $s->setSkills(true);
                 $ss = array('name' => utf8_decode($s->name), 'ma' => $s->ma, 'st' => $s->st, 'ag' => $s->ag, 'av' => $s->av, 'skills' => $s->skills, 'cp' => $s->mv_cp, 'td' => $s->mv_td, 'int' => $s->mv_intcpt, 'cas' => $s->mv_cas, 'mvp' => $s->mv_mvp, 'spp' => $s->mv_spp, 'value' => $pdf->Mf($s->cost));
                 $currenty += $pdf->print_srow($ss, $currentx, $currenty, $h, $bgc, DEFLINECOLOR, 0.5, 8);
                 $ind_cost += $s->cost;
             }
         }
         // Then Mercs
         if (is_array($merc_array_tmp)) {
             unset($merc[0]);
             $r = $team->f_rname;
             $i = 0;
             unset($merc_array_tmp[0]);
             foreach ($merc_array_tmp as $mpos) {
                 $i++;
                 $m['name'] = 'Mercenary ' . $mpos;
                 $m['ma'] = $DEA[$r]['players'][$mpos]['ma'];
                 $m['st'] = $DEA[$r]['players'][$mpos]['st'];
                 $m['ag'] = $DEA[$r]['players'][$mpos]['ag'];
                 $m['av'] = $DEA[$r]['players'][$mpos]['av'];
                 $m['skillarr'] = $DEA[$r]['players']["{$mpos}"]['def'];
                 if (!in_array(99, $m['skillarr'])) {
                     array_unshift($m['skillarr'], 99);
                 }
                 // Adding Loner unless already in array
                 $m['skills'] = implode(', ', skillsTrans($m['skillarr']));
                 $m['cost'] = $DEA[$r]['players'][$mpos]['cost'] + MERC_EXTRA_COST;
                 if (isset($postvars["Extra{$i}"])) {
                     $m['cost'] += MERC_EXTRA_SKILL_COST;
                     $m['extra'] = $postvars["Extra{$i}"];
                     if ($m['skills'] == '') {
                         $m['skills'] = $m['extra'];
                     } else {
                         $m['skills'] = $m['skills'] . ', ' . $m['extra'];
                     }
                 }
                 $ss = array('name' => utf8_decode($m['name']), 'ma' => $m['ma'], 'st' => $m['st'], 'ag' => $m['ag'], 'av' => $m['av'], 'skills' => $m['skills'], 'cp' => ' ', 'td' => ' ', 'int' => ' ', 'cas' => ' ', 'mvp' => ' ', 'spp' => ' ', 'value' => $pdf->Mf($m['cost']));
                 $currenty += $pdf->print_srow($ss, $currentx, $currenty, $h, $bgc, DEFLINECOLOR, 0.5, 8);
                 $ind_cost += $m['cost'];
             }
         }
     }
     $h = 13;
     // Printing lower part of roster
     $currentx = MARGINX;
     $currenty = 435;
     //print_box($x, $y, $w, $h, $bgcolor='#FFFFFF', $bordercolor='#000000', $linewidth=1, $borderstyle, $fontsize, $font, $bold=false, $align, $text)
     $h = 13;
     // Height of cells
     $pdf->print_box($currentx, $currenty, 170, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', true, 'R', 'Inducements ');
     $pdf->print_box($currentx += 170, $currenty, 120, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'L', '(for next match)');
     $pdf->print_box($currentx = 630, $currenty, 40, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', true, 'R', 'Team Goods');
     // 156 to margin
     // Checking if Wandering Apothecary should be replaced with Igor
     $r = $team->f_rname;
     if ($r == 'Nurgle' || $r == 'Khemri' || $r == 'Necromantic' || $r == 'Undead') {
         $apo_igor = 'Igor (0-1):';
         unset($inducements['Wandering Apothecaries']);
         if (isset($ind_igor)) {
             $ind_apo_igor_cost = $ind_igor * $inducements['Igor']['cost'];
             $ind_cost += $ind_igor * $ind_apo_igor_cost;
             $ind_apo_igor = $ind_igor;
         } else {
             $ind_apo_igor = '__';
             $ind_apo_igor_cost = $inducements['Igor']['cost'];
         }
     } else {
         $apo_igor = 'Wandering Apothecaries (0-2):';
         unset($inducements['Igor']);
         if (isset($ind_apo)) {
             $ind_apo_igor_cost = $inducements['Wandering Apothecaries']['cost'];
             $ind_cost += $ind_apo * $ind_apo_igor_cost;
             $ind_apo_igor = $ind_apo;
         } else {
             $ind_apo_igor = '__';
             $ind_apo_igor_cost = $inducements['Wandering Apothecaries']['cost'];
         }
     }
     // Checking LRB6 cheaper Chef for Halfling
     $chef_cost = $inducements['Halfling Master Chef'][$r == 'Halfling' ? 'reduced_cost' : 'cost'];
     // Checking LRB6 cheaper bribes for Goblin
     $bribe_cost = $inducements['Bribes'][$r == 'Goblin' ? 'reduced_cost' : 'cost'];
     if (isset($ind_babes)) {
         $ind_cost += $ind_babes * $inducements['Bloodweiser Babes']['cost'];
     } else {
         $ind_babes = '__';
     }
     if (isset($ind_bribes)) {
         $ind_cost += $ind_bribes * $inducements['Bribes']['cost'];
     } else {
         $ind_bribes = '__';
     }
     if (isset($ind_card)) {
         $ind_cost += $ind_card;
     } else {
         $ind_card = '__';
     }
     if (isset($ind_rr)) {
         $ind_cost += $ind_rr * $inducements['Extra Training']['cost'];
     } else {
         $ind_rr = '__';
     }
     if (isset($ind_chef)) {
         $ind_cost += $ind_chef * $chef_cost;
     } else {
         $ind_chef = '__';
     }
     if (isset($ind_wiz)) {
         $ind_cost += $ind_wiz * $inducements['Wizard']['cost'];
     } else {
         $ind_wiz = '__';
     }
     // print_inducements($x, $y, $h, $bgcol, $linecol, $fontsize, $ind_name, $ind_amount, $ind_value)
     $pdf->print_inducements(MARGINX, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 8, 'Bloodweiser Babes (0-2):', $ind_babes, $pdf->Mf($inducements['Bloodweiser Babes']['cost']));
     $pdf->print_inducements(MARGINX, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 8, 'Bribes (0-3):', $ind_bribes, $pdf->Mf($bribe_cost));
     $pdf->print_inducements(MARGINX, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 8, 'Extra Training (0-4):', $ind_rr, $pdf->Mf($inducements['Extra Training']['cost']));
     $pdf->print_inducements(MARGINX, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 8, 'Halfling Master Chef (0-1):', $ind_chef, $pdf->Mf($chef_cost));
     $pdf->print_inducements(MARGINX, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 8, $apo_igor, $ind_apo_igor, $pdf->Mf($ind_apo_igor_cost));
     $pdf->print_inducements(MARGINX, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 8, 'Wizard (0-1):', $ind_wiz, $pdf->Mf($inducements['Wizard']['cost']));
     $pdf->print_inducements(MARGINX, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 8, 'Card budget:', ' ', $pdf->Mf($ind_card));
     $pdf->print_inducements(MARGINX, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 8, 'Gate:', null, '');
     $pdf->print_inducements(MARGINX, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 8, 'FAME:', null, '');
     $currenty = 435;
     $currentx = 630;
     // print_team_goods($x, $y, $h, $bgcol, $linecol, $perm_name, $perm_nr, $perm_value, $perm_total_value, $bold=false)
     $pdf->print_team_goods($currentx, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 'Rerolls:', $team->rerolls, $pdf->Mf($rerollcost), $pdf->Mf($team->rerolls * $rerollcost), false);
     $pdf->print_team_goods($currentx, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 'Fan Factor:', $team->rg_ff, $pdf->Mf($rules['cost_fan_factor']), $pdf->Mf($team->rg_ff * $rules['cost_fan_factor']), false);
     $pdf->print_team_goods($currentx, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 'Assistant Coaches:', $team->ass_coaches, $pdf->Mf($rules['cost_ass_coaches']), $pdf->Mf($team->ass_coaches * $rules['cost_ass_coaches']), false);
     $pdf->print_team_goods($currentx, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 'Cheerleaders:', $team->cheerleaders, $pdf->Mf($rules['cost_cheerleaders']), $pdf->Mf($team->cheerleaders * $rules['cost_cheerleaders']), false);
     if ($r == 'Undead' || $r == 'Necromantic') {
         // Swap Apothecary for Necromancer
         $pdf->print_team_goods($currentx, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 'Necromancer:', 1, 0, 0, false);
     } elseif ($r == 'Nurgle' || $r == 'Khemri') {
         // Remove Apothecary
         $currenty += $h;
     } else {
         // Normal case
         $pdf->print_team_goods($currentx, $currenty += $h, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 'Apothecary:', $team->apothecary, $pdf->Mf($rules['cost_apothecary']), $pdf->Mf($team->apothecary * $rules['cost_apothecary']), false);
     }
     $pdf->print_box($currentx += 70, $currenty += $h, 40, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'R', 'Treasury:');
     $pdf->print_box($currentx += 40, $currenty, 65, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', false, 'R', $pdf->Mf($team->treasury));
     // Team Value, Inducements Value, Match Value
     $h = 13;
     $pdf->print_box($currentx -= 40, $currenty += $h, 40, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', true, 'R', 'Team Value (incl MNGs value):');
     $pdf->print_box($currentx += 40, $currenty, 65, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', true, 'R', $pdf->Mf($team->value + $sum_p_missing_value));
     $pdf->print_box($currentx -= 40, $currenty += $h, 40, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', true, 'R', 'Induced Value:');
     $pdf->print_box($currentx += 40, $currenty, 65, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', true, 'R', $pdf->Mf($ind_cost));
     $pdf->print_box($currentx -= 40, $currenty += $h, 40, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', true, 'R', 'Match Value (TV for match):');
     $pdf->print_box($currentx += 40, $currenty, 65, $h, COLOR_ROSTER_NORMAL, DEFLINECOLOR, 0, 0, 8, 'Tahoma', true, 'R', $pdf->Mf($team->value + $ind_cost));
     // Drawing a rectangle around inducements
     $pdf->SetLineWidth(0.6);
     $pdf->RoundedRect(MARGINX + 6, 435, 792, 130, 5, 'D');
     global $settings;
     if ($settings['enable_pdf_logos']) {
         // Team logo
         // Comment out if you dont have GD 2.x installed, or if you dont want the logo in roster.
         // Not tested with anything except PNG images that comes with OBBLM.
         $img = new ImageSubSys(IMGTYPE_TEAMLOGO, $team->team_id);
         $pdf->Image($img->getPath(), 346, 436, 128, 128, '', '', false, 0);
         // OBBLM text lower left corner as a pic
         $pdf->Image('modules/pdf/OBBLM_pdf_logo.png', MARGINX + 12, 534, 60, 28, '', '', false, 0);
     }
     // Color legends
     $pdf->SetFont('Tahoma', '', 8);
     $currentx = MARGINX + 16;
     $currenty = 572;
     $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_MNG));
     $pdf->SetXY($currentx, $currenty);
     $pdf->Rect($currentx, $currenty, 5, 5, 'DF');
     $pdf->SetXY($currentx += 5, $currenty -= 1);
     $pdf->Cell(20, 8, 'MNG', 0, 0, 'L', false);
     $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_JOURNEY));
     $pdf->Rect($currentx += 22 + 5, $currenty += 1, 5, 5, 'DF');
     $pdf->SetXY($currentx += 5, $currenty -= 1);
     $pdf->Cell(45, 8, 'Journeyman', 0, 0, 'L', false);
     $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_JOURNEY_USED));
     $pdf->Rect($currentx += 47 + 5, $currenty += 1, 5, 5, 'DF');
     $pdf->SetXY($currentx += 5, $currenty -= 1);
     $pdf->Cell(45, 8, 'Used journeyman', 0, 0, 'L', false);
     $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_NEWSKILL));
     $pdf->Rect($currentx += 67 + 5, $currenty += 1, 5, 5, 'DF');
     $pdf->SetXY($currentx += 5, $currenty -= 1);
     $pdf->Cell(70, 8, 'New skill available', 0, 0, 'L', false);
     $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_CHR_GTP1));
     $pdf->Rect($currentx += 70 + 5, $currenty += 1, 5, 5, 'DF');
     $pdf->SetXY($currentx += 5, $currenty -= 1);
     $pdf->Cell(50, 8, 'Stat upgrade', 0, 0, 'L', false);
     $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_CHR_LTM1));
     $pdf->Rect($currentx += 50 + 5, $currenty += 1, 5, 5, 'DF');
     $pdf->SetXY($currentx += 5, $currenty -= 1);
     $pdf->Cell(50, 8, 'Stat downgrade', 0, 0, 'L', false);
     $pdf->SetFont('Tahoma', '', 7);
     $pdf->SetFillColorBB($pdf->hex2cmyk(COLOR_ROSTER_NORMAL));
     $pdf->SetXY($currentx + 160, $currenty + 1);
     $donate = "Please consider donating to the OBBLM project if you enjoy this software and wish to support\n further development and maintenance. For more information visit nicholasmr.dk";
     $pdf->Multicell(300, 8, $donate, 0, 0, 'L', false);
     // Output the PDF document
     $pdf->Output(utf8_decode($team->name) . date(' Y-m-d') . '.pdf', 'I');
 }
예제 #5
0
 public static function profile($tid)
 {
     global $coach, $settings, $rules;
     $t = new self($tid);
     setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS, array('lid' => $t->f_lid));
     // Load correct $rules for league.
     /* Argument(s) passed to generating functions. */
     $ALLOW_EDIT = is_object($coach) && ($t->owned_by_coach_id == $coach->coach_id || $coach->mayManageObj(T_OBJ_TEAM, $tid)) && !$t->is_retired;
     # Show team action boxes?
     $DETAILED = isset($_GET['detailed']) && $_GET['detailed'] == 1;
     # Detailed roster view?
     /* Team pages consist of the output of these generating functions. */
     $t->_handleActions($ALLOW_EDIT);
     # Handles any actions/request sent.
     list($players, $players_backup) = $t->_loadPlayers($DETAILED);
     # Should come after _handleActions().
     $t->_roster($ALLOW_EDIT, $DETAILED, $players);
     $players = $players_backup;
     # Restore the $players array (_roster() manipulates the passed $players array).
     $t->_menu($ALLOW_EDIT, $DETAILED);
     switch (isset($_GET['subsec']) ? $_GET['subsec'] : 'man') {
         case 'hhmerc':
             $t->_HHMerc($DETAILED);
             break;
         case 'hhstar':
             $t->_HHStar($DETAILED);
             break;
         case 'man':
             $t->_actionBoxes($ALLOW_EDIT, $players);
             break;
         case 'about':
             $t->_about($ALLOW_EDIT);
             break;
         case 'news':
             $t->_news($ALLOW_EDIT);
             break;
         case 'games':
             $t->_games();
             break;
     }
     if (isset($_GET['subsec'])) {
         ?>
     <script language="JavaScript" type="text/javascript">
     window.location = "#anc";
     </script>
     <?php 
     }
 }
예제 #6
0
    public static function handlePost($cid)
    {
        global $lng, $_POST, $coach, $raceididx, $DEA, $rules, $racesNoApothecary;
        if (!isset($_POST['action'])) {
            return;
        }
        if (!self::allowEdit($cid, $coach)) {
            status(false, $lng->getTrn('notallowed', 'TeamCreator'));
            return;
        }
        $lid_did = $_POST['lid_did'];
        @(list($lid, $did) = explode(',', $_POST['lid_did']));
        setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS, array('lid' => (int) $lid));
        // Load correct $rules for league.
        if (get_magic_quotes_gpc()) {
            $_POST['tname'] = stripslashes($_POST['tname']);
        }
        $rid = $_POST['raceid'];
        $race = $DEA[$raceididx[$rid]];
        /* Handle or the 'other' stuff around the team - rerolls etc */
        $rerolls = $_POST['qtyo0'];
        $fans = $_POST['qtyo1'];
        $cl = $_POST['qtyo2'];
        $ac = $_POST['qtyo3'];
        $treasury = $rules['initial_treasury'];
        $treasury -= $rerolls * $race['other']['rr_cost'];
        $treasury -= $fans * 10000;
        $treasury -= $cl * 10000;
        $treasury -= $ac * 10000;
        $rerolls += $rules['initial_rerolls'];
        $fans += $rules['initial_fan_factor'];
        $cl += $rules['initial_ass_coaches'];
        $ac += $rules['initial_cheerleaders'];
        if (!in_array($rid, $racesNoApothecary)) {
            $apoth = $_POST['qtyo4'];
            if ($apoth) {
                $treasury -= 50000;
            }
        } else {
            $apoth = 0;
        }
        /* Create an array with all the players in. Do this first to check for sufficient funds */
        $players = array();
        $idx = 0;
        $rosterNum = 1;
        foreach ($race['players'] as $pos => $d) {
            $pid = $_POST['pid' . $idx];
            if ($pid != $d['pos_id']) {
                // mismatched position ID
                status(false, $pid . ' but was ' . $d['pos_id']);
                return;
            }
            $qty = $_POST['qtyp' . $idx];
            for ($i = 0; $i < $qty; $i++) {
                $treasury -= $d['cost'];
                $player = array();
                $player['name'] = "";
                $player['nr'] = $rosterNum++;
                $player['f_pos_id'] = $d['pos_id'];
                $players[] = $player;
            }
            $idx++;
        }
        /* Enforce league rules and common BB ones */
        $errors = array();
        if ($treasury < 0) {
            $errors[] = $lng->getTrn('tooExpensive', 'TeamCreator');
        }
        if (sizeof($players) < 11) {
            $errors[] = $lng->getTrn('tooFewPlayers', 'TeamCreator');
        }
        if (sizeof($players) > $rules['max_team_players']) {
            $errors[] = $lng->getTrn('tooManyPlayers', 'TeamCreator');
        }
        if (self::checkLimit($rules['max_rerolls'], $rerolls)) {
            $errors[] = $lng->getTrn('tooManyRR', 'TeamCreator') . " " . $rerolls . " vs " . $rules['max_rerolls'];
        }
        if (self::checkLimit($rules['max_fan_factor'], $fans)) {
            $errors[] = $lng->getTrn('tooManyFF', 'TeamCreator') . " " . $fans . " vs " . $rules['max_fan_factor'];
        }
        if (self::checkLimit($rules['max_ass_coaches'], $ac)) {
            $errors[] = $lng->getTrn('tooManyAc', 'TeamCreator') . " " . $ac . " vs " . $rules['max_ass_coaches'];
        }
        if (self::checkLimit($rules['max_cheerleaders'], $cl)) {
            $errors[] = $lng->getTrn('tooManyCl', 'TeamCreator') . " " . $cl . " vs " . $rules['max_cheerleaders'];
        }
        /* Actually create the team in the database */
        if (sizeof($errors) == 0) {
            list($exitStatus, $tid) = Team::create(array('name' => $_POST['tname'], 'owned_by_coach_id' => (int) $cid, 'f_race_id' => (int) $rid, 'treasury' => $treasury, 'apothecary' => $apoth, 'rerolls' => $rerolls, 'ff_bought' => $fans, 'ass_coaches' => $ac, 'cheerleaders' => $cl, 'won_0' => 0, 'lost_0' => 0, 'draw_0' => 0, 'played_0' => 0, 'wt_0' => 0, 'gf_0' => 0, 'ga_0' => 0, 'imported' => 0, 'f_lid' => (int) $lid, 'f_did' => isset($did) ? (int) $did : Team::T_NO_DIVISION_TIE));
            if ($exitStatus) {
                $errors[] = Team::$T_CREATE_ERROR_MSGS[$exitStatus];
            }
        }
        /* Actually create all the players in the database */
        if (sizeof($errors) == 0) {
            $opts = array();
            $opts['free'] = 1;
            // already deducted cost from treasry
            foreach ($players as $player) {
                $player['team_id'] = $tid;
                list($exitStatus, $pid) = Player::create($player, $opts);
                if ($exitStatus) {
                    $errors = array_merge($errors, Player::$T_CREATE_ERROR_MSGS[$exitStatus]);
                }
            }
        }
        /* Report errors and reset the form, or redirect to the team page */
        if (sizeof($errors) > 0) {
            $msg = implode(",<br />", $errors);
            status(false, $msg);
            $post = (object) $_POST;
            echo <<<EOQ
   <script type="text/javascript">
      \$(document).ready(function() {
      document.getElementById('rid').value = {$post->rid};
      changeRace({$post->rid});
      document.getElementById('tname').value = '{$post->tname}';
EOQ;
            foreach ($_POST as $element => $value) {
                if (0 == strncmp($element, "qty", 3)) {
                    $idx = substr($element, 4, 1);
                    $type = substr($element, 3, 1);
                    echo <<<EOQ

      document.getElementById('{$element}').selectedIndex = {$value};
      updateQty({$idx}, '{$type}', {$value});
EOQ;
                }
            }
            echo <<<EOQ
      var lid = document.getElementById('lid_did');
      for (var i = 0; i < lid.options.length; i++) {
         if (lid.options[i].value=={$post->lid_did}) {
            lid.selectedIndex = i;
            break;
         }
      }
      });
   </script>
EOQ;
        } else {
            // Everything worked, redirect to the team page
            status(true, $lng->getTrn('created', 'TeamCreator'));
            $teamUrl = "'" . str_replace("amp;", "", urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $tid, false, false)) . "'";
            echo <<<EOQ
   <script type="text/javascript">
      \$(document).ready(function() {
         window.location = {$teamUrl};
      });
   </script>
EOQ;
        }
    }
예제 #7
0
function setupGlobalVars($type, $opts = array())
{
    global $coach, $lng, $leagues, $divisions, $tours, $settings, $rules, $admin_menu;
    switch ($type) {
        case T_SETUP_GLOBAL_VARS__COMMON:
            $coach = isset($_SESSION['logged_in']) ? new Coach($_SESSION['coach_id']) : null;
            # Create global coach object.
            list($leagues, $divisions, $tours) = Coach::allowedNodeAccess(Coach::NODE_STRUCT__FLAT, is_object($coach) ? $coach->coach_id : false, $extraFields = array(T_NODE_TOURNAMENT => array('locked' => 'locked', 'type' => 'type', 'f_did' => 'f_did'), T_NODE_DIVISION => array('f_lid' => 'f_lid'), T_NODE_LEAGUE => array('tie_teams' => 'tie_teams')));
            setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS);
            $_LANGUAGE = is_object($coach) && isset($coach->settings['lang']) ? $coach->settings['lang'] : $settings['lang'];
            if (!is_object($lng)) {
                $lng = new Translations($_LANGUAGE);
            } else {
                $lng->setLanguage($_LANGUAGE);
            }
            break;
        case T_SETUP_GLOBAL_VARS__POST_LOAD_MODULES:
            $admin_menu = is_object($coach) ? $coach->getAdminMenu() : array();
            break;
        case T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS:
            // Local league settings exist?
            $file = "localsettings/settings_ID.php";
            // Update selected node $_SESSION vars if node selector form submission made (will make HTMLOUT::getSelectedNodeLid(), below, catch the correct league straight as opposed to on second page reload).
            HTMLOUT::updateNodeSelectorLeagueVars();
            // Selected
            if (isset($opts['lid']) && is_numeric($opts['lid'])) {
                $id = $opts['lid'];
            } else {
                if ($_lid = HTMLOUT::getSelectedNodeLid()) {
                    $id = $_lid;
                } else {
                    if (is_object($coach) && isset($coach->settings['home_lid'])) {
                        $id = $coach->settings['home_lid'];
                    } else {
                        $id = isset($settings['default_visitor_league']) ? $settings['default_visitor_league'] : '';
                    }
                }
            }
            $settingsFile = str_replace("ID", $id, $file);
            if ($localsettings = file_exists($settingsFile) ? $settingsFile : false) {
                include $localsettings;
            } else {
                include str_replace("ID", 'none', $file);
                # Empty settings file.
            }
            break;
        case T_SETUP_GLOBAL_VARS__POST_COACH_LOGINOUT:
            setupGlobalVars(T_SETUP_GLOBAL_VARS__COMMON);
            setupGlobalVars(T_SETUP_GLOBAL_VARS__POST_LOAD_MODULES);
            break;
    }
}
예제 #8
0
파일: header.php 프로젝트: rythos42/naflm
require_once 'lib/class_race_htmlout.php';
require_once 'lib/class_match_htmlout.php';
require_once 'lib/class_mobile_htmlout.php';
/********************
 *   Final setup
 ********************/
if (!is_writable(IMG)) {
    die('OBBLM needs to be able to write to the <i>images</i> directory in order to work properly. Please check the directory permissions.');
}
sortgamedata();
# Game data files are unsorted, make them pretty for display purposes.
/********************
 *   Globals/Startup
 ********************/
if (defined('T_NO_STARTUP')) {
    Coach::logout();
    require_once 'modules/modsheader.php';
    # Registration of modules.
} else {
    $conn = mysql_up(defined('T_NO_TBL_CHK') ? !T_NO_TBL_CHK : true);
    # MySQL connect.
    setupGlobalVars(T_SETUP_GLOBAL_VARS__COMMON);
    require_once 'modules/modsheader.php';
    # Registration of modules.
    setupGlobalVars(T_SETUP_GLOBAL_VARS__POST_LOAD_MODULES);
    /******************************
    	   Translate skills globally
    	******************************/
    global $lng;
    $lng->TranslateSkills();
}
예제 #9
0
            break;
        case 'mod_tournament':
            $syncPTS = $t->rs != (int) $_POST['rs'];
            $t->rs = $_POST['rs'];
            $t->type = $_POST['tourtype'];
            $t->name = $_POST['name'];
            $t->locked = isset($_POST['locked']) ? $_POST['locked'] : 0;
            $t->allow_sched = isset($_POST['allow_sched']) ? $_POST['allow_sched'] : 0;
            status($t->save());
            if ($syncPTS) {
                $OK = $t->syncPTS();
                status($OK, $OK ? 'Synchronized points for the new ranking system' : 'Failed to Synchronize points for the new ranking system');
            }
            break;
    }
    setupGlobalVars(T_SETUP_GLOBAL_VARS__COMMON);
    # Re-load $leagues, $divisions, $tours
}
title($lng->getTrn('menu/admin_menu/nodes'));
?>
<b>Please note:</b> When deleting any node (i.e. tournaments, divisions or leagues) a "syncAll()" re-synchronisation should be run afterwards from the <a href='index.php?section=admin&amp;subsec=cpanel'>OBBLM core panel</a>.
<table>
    <?php 
if (in_array(T_NODE_TOURNAMENT, $_SHOW)) {
    ?>
    <tr>
        <td valign='top'>
        <div class="boxCommon">
            <div class="boxTitle<?php 
    echo T_HTMLBOX_ADMIN;
    ?>
예제 #10
0
 public static function create(array $input, array $opts)
 {
     /**
      * Creates a new player.
      *
      * Input: nr, f_pos_id, name, team_id
      **/
     global $rules, $DEA, $T_ALL_PLAYER_NR;
     $lid = get_alt_col('teams', 'team_id', $input['team_id'], 'f_lid');
     setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS, array('lid' => (int) $lid));
     // Load correct $rules for league.
     // Do these fixes because we can't define class statics using string interpolation for $rules.
     self::$T_CREATE_ERROR_MSGS[self::T_CREATE_ERROR__TEAM_FULL] .= " You have filled all {$rules['max_team_players']} available positions.";
     self::$T_CREATE_ERROR_MSGS[self::T_CREATE_ERROR__JM_LIMIT_REACHED] .= " Your team is now able to fill {$rules['journeymen_limit']} positions.";
     $JM = isset($opts['JM']) && $opts['JM'];
     $FREE = isset($opts['free']) && $opts['free'];
     $FORCE = isset($opts['force']) && $opts['force'];
     # When forcing ($FORCE is true) we ignore these errors:
     $ignoreableErrors = array(self::T_CREATE_ERROR__TEAM_FULL, self::T_CREATE_ERROR__POS_LIMIT_REACHED, self::T_CREATE_ERROR__INSUFFICIENT_FUNDS, self::T_CREATE_ERROR__NUMBER_OCCUPIED, self::T_CREATE_ERROR__JM_LIMIT_REACHED, self::T_CREATE_ERROR__INVALID_JM_POS);
     $EXPECTED = self::$createEXPECTED;
     sort($EXPECTED);
     ksort($input);
     // Input error handler
     if (!get_alt_col('teams', 'team_id', (int) $input['team_id'], 'team_id')) {
         return array(self::T_CREATE_ERROR__INVALID_TEAM, null);
     } else {
         $team = new Team((int) $input['team_id']);
     }
     $errors = array(self::T_CREATE_ERROR__UNEXPECTED_INPUT => $EXPECTED !== array_keys($input), self::T_CREATE_ERROR__TEAM_FULL => !$JM && $team->isFull(), self::T_CREATE_ERROR__INVALID_POS => !$team->isPlayerPosValid((int) $input['f_pos_id']), self::T_CREATE_ERROR__POS_LIMIT_REACHED => !$team->isPlayerBuyable((int) $input['f_pos_id']), self::T_CREATE_ERROR__INSUFFICIENT_FUNDS => $team->treasury - ($price = $JM || $FREE ? 0 : self::price((int) $input['f_pos_id'])) < 0, self::T_CREATE_ERROR__INVALID_NUMBER => !in_array($input['nr'], $T_ALL_PLAYER_NR), self::T_CREATE_ERROR__NUMBER_OCCUPIED => $team->isPlayerNumberOccupied((int) $input['nr']), self::T_CREATE_ERROR__JM_LIMIT_REACHED => $JM && $team->isJMLimitReached(), self::T_CREATE_ERROR__INVALID_JM_POS => $JM && $DEA[$team->f_rname]['players'][get_alt_col('game_data_players', 'pos_id', (int) $input['f_pos_id'], 'pos')]['qty'] < 12);
     foreach ($errors as $exitStatus => $halt) {
         if ($halt && !($FORCE && in_array($exitStatus, $ignoreableErrors))) {
             return array($exitStatus, null);
         }
     }
     $input['owned_by_team_id'] = (int) $input['team_id'];
     unset($input['team_id']);
     $input['name'] = "'" . mysql_real_escape_string($input['name']) . "'";
     $input['date_bought'] = 'NOW()';
     $input['type'] = $JM ? PLAYER_TYPE_JOURNEY : PLAYER_TYPE_NORMAL;
     foreach (array('ach_ma', 'ach_st', 'ach_ag', 'ach_av', 'extra_spp') as $f) {
         $input[$f] = 0;
     }
     $query = "INSERT INTO players (" . implode(',', array_keys($input)) . ") VALUES (" . implode(',', array_values($input)) . ")";
     if (mysql_query($query)) {
         $pid = mysql_insert_id();
         $team->dtreasury(-1 * $price);
     } else {
         self::$T_CREATE_SQL_ERROR['query'] = $query;
         self::$T_CREATE_SQL_ERROR['error'] = mysql_error();
         return array(self::T_CREATE_ERROR__SQL_QUERY_FAIL, null);
     }
     SQLTriggers::run(T_SQLTRIG_PLAYER_NEW, array('id' => $pid, 'obj' => (object) array('player_id' => $pid, 'owned_by_team_id' => (int) $input['owned_by_team_id'])));
     # Update PV and TV.
     return array(self::T_CREATE_SUCCESS, $pid);
 }