Example #1
0
 /**
  * fetches the configuration from the database
  *
  * @access public
  */
 public function fetch()
 {
     $this->config = array();
     $query = 'SELECT `index`,`value` FROM `PREFIX_config`';
     $result;
     try {
         $result = $this->db->getData($query);
     } catch (DBException $e) {
         trigger_error('Config could not be fetched!', E_USER_ERROR);
         Debug::log_error('exception', $e->getMessage());
     }
     foreach ($result as $row) {
         if (is_numeric($row->value)) {
             if (mb_substr_count($row->value, '.') < 1) {
                 $row->value = (int) $row->value;
             } else {
                 $row->value = (double) $row->value;
             }
             $this->config[$row->index] = $row->value;
             continue;
         }
         $this->config[$row->index] = $row->value;
     }
     $this->log->write(2, 'info', 'Config fetched: ' . count($this->config) . ' entries');
 }
Example #2
0
 public function createAndServe($id, $msg = '')
 {
     $db = new Database();
     $data = $db->getData($id);
     $template = new Template($id, $data);
     $template->serve();
     $logs = new Logger();
     //        $logs->log("Create a page for ID {$id}");
     $logs->log($msg);
 }
 function getData()
 {
     $data = parent::getData();
     foreach ($data as $k => $array) {
         foreach ($array as $key => $value) {
             foreach ($data as $k2 => $array2) {
                 if (!isset($data[$k2][$key])) {
                     $data[$k2][$key] = 0;
                 }
             }
         }
     }
     foreach ($data as $k => $v) {
         ksort($data[$k]);
     }
     return $data;
 }
 public function makeScoreboard()
 {
     $bdb = new Database();
     // get the week of the season
     $this->week = getWeek();
     // get all the area games from that week
     $getGames = "SELECT\n\t\t            (SELECT name FROM schools WHERE schedule_2015.away_id = schools.school_id) AS away_team, \n\t\t            (SELECT name FROM schools WHERE schedule_2015.home_id = schools.school_id) AS home_team,\n\t\t             game_date,\n\t\t             game_time,\n\t\t             q1_away,q2_away,q3_away,q4_away,ot_away,\n\t\t             q1_home,q2_home,q3_home,q4_home,ot_home,\n\t\t             winner,\n\t\t             facility,\n\t\t             week,\n\t\t             away_final,\n\t\t             home_final\n\t\t             FROM schedule_2015 \n\t\t             WHERE week = {$this->week} AND area = 1\n\t\t             ORDER BY winner DESC, game_date, game_time";
     $games = $bdb->getData($getGames);
     /* take array and build scoreboard */
     $scores = $this->buildScoreboard($games);
     /* p2p api key */
     $P2Paccesstoken = '874ai9840kqvuyojkyqp4k49o6q56yyfa35';
     /* slug of story to update */
     $P2Pslug = 'hc-hs-boys-bball-scores-2015';
     /* p2p api location of item to update */
     $P2Purl = 'http://content-api.p2p.tribuneinteractive.com/content_items/' . $P2Pslug . '.json';
     /* update body of array */
     $data = array('content_item' => array('body' => $scores));
     $data_string = json_encode($data);
     /* Build the authentication array for CURLOPT_HTTPHEADER. */
     $headr = array();
     $headr[] = 'Authorization: Bearer ' . $P2Paccesstoken;
     $headr[] = 'Content-type: application/json';
     /* End authentication.  */
     /* Initiate cURL.  */
     $ch = curl_init($P2Purl);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headr);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
     $response = curl_exec($ch);
     if ((string) $response == '') {
         //date_default_timezone_set('EST');
         $this->barker_message = ' Updated ' . $P2Pslug . ', ' . date('F j, Y, g:i a');
     } else {
         $this->barker_message = ' Error updating ' . $P2Pslug . ' please try again.';
     }
     /* End cURL call. */
 }
Example #5
0
 /**
  * Do a minimal engine load
  *
  * @return void
  */
 protected function setupSimplecache()
 {
     if (!empty($this->config->dataroot) && isset($this->config->simplecache_enabled)) {
         return;
     }
     $db_config = new Database\Config($this->config);
     $db = new Database($db_config, new Logger(new PluginHooksService()));
     try {
         $rows = $db->getData("\n\t\t\t\tSELECT `name`, `value`\n\t\t\t\tFROM {$db->getTablePrefix()}datalists\n\t\t\t\tWHERE `name` IN ('dataroot', 'simplecache_enabled')\n\t\t\t");
         if (!$rows) {
             $this->send403('Cache error: unable to get the data root');
         }
     } catch (\DatabaseException $e) {
         if (0 === strpos($e->getMessage(), "Elgg couldn't connect")) {
             $this->send403('Cache error: unable to connect to database server');
         } else {
             $this->send403('Cache error: unable to connect to Elgg database');
         }
         exit;
         // unnecessary, but helps PhpStorm understand
     }
     foreach ($rows as $row) {
         $this->config->{$row->name} = $row->value;
     }
     if (empty($this->config->dataroot)) {
         $this->send403('Cache error: unable to get the data root');
     }
 }
function getStandings($allSchools)
{
    $all_records = [];
    $all_leagues = [];
    $brk = [];
    $ccc_nrw = [];
    $ccc_nrb = [];
    $ccc_crw = [];
    $ccc_crb = [];
    $ccc_srw = [];
    $ccc_srb = [];
    $cra = [];
    $csc_west = [];
    $csc_central = [];
    $csc_east = [];
    $ecc_lg = [];
    $ecc_md = [];
    $ecc_sm = [];
    $fciac_east = [];
    $fciac_central = [];
    $fciac_west = [];
    $nvl_brass = [];
    $nvl_copper = [];
    $nccc = [];
    $scc_ham = [];
    $scc_hou = [];
    $scc_oro = [];
    $scc_qui = [];
    $shr = [];
    $swc_colonial = [];
    $swc_patriot = [];
    $db_standings = new Database();
    //
    foreach ($allSchools as $team) {
        $getTeamRecord = "CALL getRecord('{$team['0']}')";
        $record = $db_standings->getData($getTeamRecord);
        $record = getRecords($record, $team);
        if ($record[1] == 'Berkshire') {
            array_push($brk, $record);
        } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'North Region White') {
            array_push($ccc_nrw, $record);
        } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'North Region Blue') {
            array_push($ccc_nrb, $record);
        } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Central Region White') {
            array_push($ccc_crw, $record);
        } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Central Region Blue') {
            array_push($ccc_crb, $record);
        } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'South Region White') {
            array_push($ccc_srw, $record);
        } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'South Region Blue') {
            array_push($ccc_srb, $record);
        } elseif ($record[1] == 'Capital Region Athletic') {
            array_push($cra, $record);
        } elseif ($record[1] == 'Constitution State' && $record[2] == 'West') {
            array_push($csc_west, $record);
        } elseif ($record[1] == 'Constitution State' && $record[2] == 'Central') {
            array_push($csc_central, $record);
        } elseif ($record[1] == 'Constitution State' && $record[2] == 'East') {
            array_push($csc_east, $record);
        } elseif ($record[1] == 'Eastern Connecticut' && $record[2] == 'Large') {
            array_push($ecc_lg, $record);
        } elseif ($record[1] == 'Eastern Connecticut' && $record[2] == 'Medium') {
            array_push($ecc_md, $record);
        } elseif ($record[1] == 'Eastern Connecticut' && $record[2] == 'Small') {
            array_push($ecc_sm, $record);
        } elseif ($record[1] == 'Fairfield County Interscholastic Athletic' && $record[2] == 'East') {
            array_push($fciac_east, $record);
        } elseif ($record[1] == 'Fairfield County Interscholastic Athletic' && $record[2] == 'Central') {
            array_push($fciac_central, $record);
        } elseif ($record[1] == 'Fairfield County Interscholastic Athletic' && $record[2] == 'West') {
            array_push($fciac_west, $record);
        } elseif ($record[1] == 'Naugatuck Valley' && $record[2] == 'Brass') {
            array_push($nvl_brass, $record);
        } elseif ($record[1] == 'Naugatuck Valley' && $record[2] == 'Copper') {
            array_push($nvl_copper, $record);
        } elseif ($record[1] == 'North Central Connecticut') {
            array_push($nccc, $record);
        } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Hammonasset') {
            array_push($scc_ham, $record);
        } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Housatonic') {
            array_push($scc_hou, $record);
        } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Oronoque') {
            array_push($scc_oro, $record);
        } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Quinnipiac') {
            array_push($scc_qui, $record);
        } elseif ($record[1] == 'Shoreline') {
            array_push($shr, $record);
        } elseif ($record[1] == 'South West' && $record[2] == 'Colonial') {
            array_push($swc_colonial, $record);
        } elseif ($record[1] == 'South West' && $record[2] == 'Patriot') {
            array_push($swc_patriot, $record);
        } else {
            array_push($all_records, $record);
        }
        //
        usort($brk, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort ccc arrays by overal w, l
        usort($ccc_nrw, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ccc_nrb, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ccc_crw, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ccc_crb, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ccc_srw, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ccc_srb, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort cra arrays by overal w, l
        usort($cra, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort csc arrays by overal w, l
        usort($csc_west, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($csc_central, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($csc_east, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort ecc arrays by overal w, l
        usort($ecc_lg, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ecc_md, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ecc_sm, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort fcica arrays by overal w, l
        usort($fciac_east, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($fciac_central, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($fciac_west, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort nccc arrays by overal w, l
        usort($nccc, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort nvl arrays by overal w, l
        usort($nvl_brass, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($nvl_copper, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort scc arrays by overal w, l
        usort($scc_ham, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($scc_hou, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($scc_oro, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($scc_qui, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort shr arrays by overal w, l
        usort($shr, make_comparer([9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort swc arrays by overal w, l
        usort($swc_colonial, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($swc_patriot, make_comparer([4, SORT_DESC], [5, SORT_ASC], [7, SORT_DESC], [9, SORT_DESC], [10, SORT_ASC], [12, SORT_DESC], [14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Combine divisions into league array
        $ccc = [$ccc_nrw, $ccc_nrb, $ccc_crw, $ccc_crb, $ccc_srw, $ccc_srb];
        $csc = [$csc_west, $csc_central, $csc_east];
        $ecc = [$ecc_lg, $ecc_md, $ecc_sm];
        $fciac = [$fciac_west, $fciac_central, $fciac_east];
        $nvl = [$nvl_brass, $nvl_copper];
        $scc = [$scc_ham, $scc_hou, $scc_oro, $scc_qui];
        $swc = [$swc_colonial, $swc_patriot];
        // Combine sorted divisions into all leagues array
        $all_leagues = ['berkshire' => $brk, 'capital region athletic' => $cra, 'central connecticut' => $ccc, 'constitution state' => $csc, 'eastern connecticut' => $ecc, 'fairfield county interscholastic athletic' => $fciac, 'north central connecticut' => $nccc, 'naugatuck valley' => $nvl, 'shoreline' => $shr, 'southern connecticut' => $scc, 'south west' => $swc];
    }
    return $all_leagues;
}
Example #7
0
<?php

class Database
{
    public static $shouldCache = true;
    public function getData()
    {
        return self::$shouldCache == true ? 'From cache' : 'From DB';
    }
}
$mysql = new Database();
echo 'Mysql Data: ' . $mysql->getData();
echo "\n\n\n";
Database::$shouldCache = false;
$oracle = new Database();
echo 'oracle data:' . $oracle->getData();
echo "\n\n\n";
$postgres = new Database();
echo 'postgres data:' . $postgres->getData();
echo "\n\n\n";
function getStandings($allSchools)
{
    $all_records = [];
    $all_leagues = [];
    $ccc_d1e = [];
    $ccc_d1w = [];
    $ccc_d2e = [];
    $ccc_d2w = [];
    $ccc_d3e = [];
    $ccc_d3w = [];
    $csc = [];
    $ecc_d1 = [];
    $ecc_d2 = [];
    $fciac_d1 = [];
    $fciac_d2 = [];
    $nvl_brass = [];
    $nvl_copper = [];
    $nvl_iron = [];
    $peq_east = [];
    $peq_south = [];
    $peq_west = [];
    $scc_d1e = [];
    $scc_d1w = [];
    $scc_d2e = [];
    $scc_d2w = [];
    $swc_colonial = [];
    $swc_patriot = [];
    $db_standings = new Database();
    //
    foreach ($allSchools as $team) {
        $getTeamRecord = "CALL getRecord('{$team['0']}')";
        $record = $db_standings->getData($getTeamRecord);
        $record = getRecords($record, $team);
        if ($record[1] == 'Central Connecticut' && $record[2] == 'Div I East') {
            array_push($ccc_d1e, $record);
        } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Div I West') {
            array_push($ccc_d1w, $record);
        } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Div II East') {
            array_push($ccc_d2e, $record);
        } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Div II West') {
            array_push($ccc_d2w, $record);
        } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Div III East') {
            array_push($ccc_d3e, $record);
        } elseif ($record[1] == 'Central Connecticut' && $record[2] == 'Div III West') {
            array_push($ccc_d3w, $record);
        } elseif ($record[1] == 'Constitution State') {
            array_push($csc, $record);
        } elseif ($record[1] == 'Eastern Connecticut' && $record[2] == 'Div I') {
            array_push($ecc_d1, $record);
        } elseif ($record[1] == 'Eastern Connecticut' && $record[2] == 'Div II') {
            array_push($ecc_d2, $record);
        } elseif ($record[1] == 'Fairfield County Interscholastic Athletic' && $record[2] == 'Div I') {
            array_push($fciac_d1, $record);
        } elseif ($record[1] == 'Fairfield County Interscholastic Athletic' && $record[2] == 'Div II') {
            array_push($fciac_d2, $record);
        } elseif ($record[1] == 'Naugatuck Valley' && $record[2] == 'Brass') {
            array_push($nvl_brass, $record);
        } elseif ($record[1] == 'Naugatuck Valley' && $record[2] == 'Copper') {
            array_push($nvl_copper, $record);
        } elseif ($record[1] == 'Naugatuck Valley' && $record[2] == 'Iron') {
            array_push($nvl_iron, $record);
        } elseif ($record[1] == 'Pequot' && $record[2] == 'East') {
            array_push($peq_east, $record);
        } elseif ($record[1] == 'Pequot' && $record[2] == 'South') {
            array_push($peq_south, $record);
        } elseif ($record[1] == 'Pequot' && $record[2] == 'West') {
            array_push($peq_west, $record);
        } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Div I East') {
            array_push($scc_d1e, $record);
        } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Div I West') {
            array_push($scc_d1w, $record);
        } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Div II East') {
            array_push($scc_d2e, $record);
        } elseif ($record[1] == 'Southern Connecticut' && $record[2] == 'Div II West') {
            array_push($scc_d2w, $record);
        } elseif ($record[1] == 'South West' && $record[2] == 'Colonial') {
            array_push($swc_colonial, $record);
        } elseif ($record[1] == 'South West' && $record[2] == 'Patriot') {
            array_push($swc_patriot, $record);
        } else {
            array_push($all_records, $record);
        }
        // Sort ccc arrays by overal w, l
        usort($ccc_d1e, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ccc_d1w, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ccc_d2e, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ccc_d2w, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ccc_d3e, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ccc_d3w, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort csc arrays by overal w, l
        usort($csc, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort ecc arrays by overal w, l
        usort($ecc_d1, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($ecc_d2, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort fcica arrays by overal w, l
        usort($fciac_d1, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($fciac_d2, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort nvl arrays by overal w, l
        usort($nvl_brass, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($nvl_copper, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($nvl_iron, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort peq arrays by overal w, l
        usort($peq_east, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($peq_south, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($peq_west, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort scc arrays by overal w, l
        usort($scc_d1e, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($scc_d1w, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($scc_d2e, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($scc_d2w, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Sort swc arrays by overal w, l
        usort($swc_colonial, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        usort($swc_patriot, make_comparer([14, SORT_DESC], [15, SORT_ASC], [17, SORT_DESC], [0, SORT_ASC]));
        // Combine divisions into league array
        $ccc = [$ccc_d1e, $ccc_d1w, $ccc_d2e, $ccc_d2w, $ccc_d3e, $ccc_d3w];
        $ecc = [$ecc_d1, $ecc_d2];
        $fciac = [$fciac_d1, $fciac_d2];
        $nvl = [$nvl_brass, $nvl_copper, $nvl_iron];
        $peq = [$peq_east, $peq_south, $peq_west];
        $scc = [$scc_d1e, $scc_d1w, $scc_d2e, $scc_d2w];
        $swc = [$swc_colonial, $swc_patriot];
        // Combine sorted divisions into all leagues array
        $all_leagues = ['central connecticut' => $ccc, 'constitution state' => $csc, 'eastern connecticut' => $ecc, 'fairfield county interscholastic athletic' => $fciac, 'naugatuck valley' => $nvl, 'pequot' => $peq, 'southern connecticut' => $scc, 'south west' => $swc];
    }
    return $all_leagues;
}
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
date_default_timezone_set('UTC');
include 'config/config.php';
include 'classes/Database.php';
include 'classes/Utils.php';
$db = new Database();
// get all schools
$getAllSchools = "SELECT school_id, name, (SELECT league_name FROM leagues WHERE league_id = league) AS league, division, class FROM schools WHERE league != 0 ORDER BY league, division";
$allSchools = $db->getData($getAllSchools);
// get all area schools
$getAreaSchools = "SELECT school_id, name FROM schools";
// WHERE area = 1
$areaSchools = $db->getData($getAreaSchools);
// get all league names
$getLeagues = "SELECT league_id, league_name, league_nick, layout FROM leagues";
$leagues = $db->getData($getLeagues);
// get all of the standings
$all_leagues = getStandings($allSchools);
// the weeks of the basketball season
$periods = [['2015-12-14', '2015-12-20'], ['2015-12-21', '2015-12-27'], ['2015-12-28', '2016-01-03'], ['2016-01-04', '2016-01-10'], ['2016-01-11', '2016-01-17'], ['2016-01-18', '2016-01-24'], ['2016-01-25', '2016-01-31'], ['2016-02-01', '2016-02-07'], ['2016-02-08', '2016-02-14'], ['2016-02-15', '2016-02-21'], ['2016-02-22', '2016-02-29']];
?>

<html>

<?php 
include 'layouts/header.htm';
?>
session_start();
/* Aquire neccessary libs */
require_once "external/class.auth.module.core.php";
require_once "external/class.database.mysql.external.php";
/* Declare classes */
$Auth = new BasicAuth();
$DB = new Database($config['db_host'], $config['db_user'], $config['db_pass'], $config['db_name']);
$sessionCurrentStatus = false;
/* Handle login request */
if (isset($_POST['login']) and isset($_POST['password'])) {
    $providedName = $_POST['login'];
    $providedPassword = $_POST['password'];
    /* Find if users exists */
    $userName = $DB->escapeData($providedName);
    $userParameters = $DB->getData("users", "WHERE login='******'");
    if (count($userParameters) == 0) {
        /* DO SOMETHING IN THAT CASE */
    } else {
        $Authenticated = $Auth->AuthOnSSHA($providedPassword, $userParameters[0]['password']);
        if ($Authenticated) {
            $Auth->sessionEstablish($userParameters[0]);
            unset($_POST);
            header("Location: " . $config['system_root']);
            die;
        } else {
            /* DO SOMETHING IN THAT CASE */
        }
    }
}
/* If this is not index.php and request was not authorized, cut it loose */
Example #11
0
    require_once "external/class.database.mysql.external.php";
    $DB = new Database($config['db_host'], $config['db_user'], $config['db_pass'], $config['db_name']);
}
require_once "core/class.ansible.abstraction.core.php";
$Ansible = new Ansible($DB);
/* IF-Event - Create user */
if (isset($_GET['create'])) {
    $loadFormUsers = "users.create.tpl";
} elseif (isset($_POST['login']) and isset($_POST['password-one']) and isset($_POST['password-two']) and isset($_POST['class'])) {
    $createUser = true;
    $newUserName = $DB->escapeData($_POST['login']);
    /* Check */
    if ($_POST['password-one'] != $_POST['password-two']) {
        $createUser = false;
    }
    if (count($DB->getData("users", "WHERE login='******'")) > 0) {
        $createUser = false;
    }
    /* Construct */
    $newUser['login'] = $_POST['login'];
    $newUser['name'] = $_POST['name'];
    $newUser['password'] = $Auth->construct_SSHA($_POST['password-one']);
    $newUser['class'] = $_POST['class'];
    /* IF - OK - Send create */
    $userCreated = $DB->insertData("users", $newUser);
    if ($userCreated) {
        $spawnSuccess = true;
        $spawnSuccessText = "User <strong>" . $newUser['login'] . "</strong> has been created successfully.";
    } else {
        $spawnError = true;
        $spawnErrorText = "Unable to comply. User <strong>" . $newUser['login'] . "</strong> was NOT created.";
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
date_default_timezone_set('America/New_York');
require_once 'config/config.php';
require_once 'classes/Database.php';
require_once 'classes/Utils.php';
require_once 'classes/MakeBarker.php';
$db = new Database();
$mb = new MakeBarker();
// get all schools
$getAllSchools = "SELECT school_id, name, (SELECT league_name FROM leagues WHERE league_id = league), division, class FROM schools WHERE league != 0 ORDER BY league, division";
$allSchools = $db->getData($getAllSchools);
// get all schools
$getNavSchools = "SELECT school_id, name FROM schools WHERE league != 0 ORDER BY name";
$navSchools = $db->getData($getNavSchools);
// get all schools for just updating teams
$getUpdateSchools = "SELECT school_id, name FROM schools ORDER BY name";
$updateSchools = $db->getData($getUpdateSchools);
// get all area schools
$getAreaSchools = "SELECT school_id, name FROM schools WHERE area = 1";
$areaSchools = $db->getData($getAreaSchools);
// get all league names
$getLeagues = "SELECT league_id, league_name, league_nick FROM leagues";
$leagues = $db->getData($getLeagues);
//
$getDays = "SELECT DISTINCT game_date FROM schedule_2015";
$days = $db->getData($getDays);
if (isset($_GET['team_schedule'])) {
    // get school id from form
Example #13
0
<html>
<head>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
	<script src="https://code.highcharts.com/highcharts.js"></script>
</head>
<body>
<?php 
require_once 'lib/Database.class.php';
require_once 'lib/Mesh_1D.class.php';
require_once 'lib/FEA.class.php';
require_once 'lib/Utilities.class.php';
$elementIndex = 4;
$db = new Database();
$data = $db->getData(104);
// $beam = new Beam($data, 500);
// $beam -> runAnalysis();
$fea = new FEA($data, 500);
$F = $fea->generateF();
Utilities::showArray($F, count($F), 1, "<br />");
echo "<br />\$k_e checking for element {$elementIndex}:";
echo "<br />\$k_e first approach checking:<br />";
$k_e1 = $fea->generateKE_1($fea->mesh->connections[$elementIndex]);
Utilities::showArray($k_e1, 4, 4, "<br />", "&nbsp;&nbsp;&nbsp;&nbsp;");
echo "<br /><br />\$k_e second approach checking (polynomial):<br />";
$k_e2 = $fea->generateKE_2($fea->mesh->connections[$elementIndex]);
Utilities::showArray($k_e2, 4, 4, "<br />", "&nbsp;&nbsp;&nbsp;&nbsp;");
echo "<br /><br />\$K checking:<br />";
$K = $fea->assembleKMatrix();
Utilities::showArray($K, count($K), count($K[0]), "<br />", "&nbsp;&nbsp;");
echo "<br /><br />K\\F <br />";
$FK = $fea->runAnalysis();
Example #14
0
<?php

error_reporting(E_ALL);
require_once 'lib/Database.class.php';
require_once 'lib/Mesh_1D.class.php';
// predefined variables
$userscalcPK = 104;
$el_max = 500;
// data gathering and calculation
$db = new Database();
$data = $db->getData($userscalcPK);
$beam = new Mesh_1D($data, $el_max);
$beam->run();
?>

<html>
<head>
	<title>PHP Processing Data</title>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous" />
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
	<script src="https://code.highcharts.com"></script>
</head>
<body>
<style type='text/css'>
.loading {
	text-align: center;
	position: absolute;
	top: 50%;
	left: 50%;
}
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
date_default_timezone_set('America/New_York');
require_once 'config/config.php';
require_once 'classes/Database.php';
require_once 'classes/Utils.php';
require_once 'classes/MakeBarker.php';
$db = new Database();
$mb = new MakeBarker();
// get all schools
$getAllSchools = "SELECT school_id, name, (SELECT league_name FROM leagues WHERE league_id = league), division, class FROM schools WHERE league != 0 ORDER BY league, division";
$allSchools = $db->getData($getAllSchools);
// get all schools for just updating teams
$getUpdateSchools = "SELECT school_id, name FROM schools ORDER BY name";
$updateSchools = $db->getData($getUpdateSchools);
// get all area schools
$getAreaSchools = "SELECT school_id, name FROM schools WHERE area = 1";
$areaSchools = $db->getData($getAreaSchools);
// get all league names
$getLeagues = "SELECT league_id, league_name, league_nick FROM leagues";
$leagues = $db->getData($getLeagues);
//
$getDays = "SELECT DISTINCT game_date FROM schedule_2015";
$days = $db->getData($getDays);
//
if (isset($_GET['admin_schedule'])) {
    //
    $game_id = '';
    //