Esempio n. 1
0
function getBestMatch($conn, $userID)
{
    $firstPlayer = getPlayerInfo($conn, $userID);
    $desiredRatio = $firstPlayer['ratio'];
    $sql = "SELECT * FROM players ORDER BY abs(ratio - {$desiredRatio}) LIMIT 2";
    $stmt = $conn->prepare($sql);
    $stmt->execute();
    $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
    return $rows[1];
}
Esempio n. 2
0
<?php

define('DIRECT', true);
$configs = (require_once 'config.php');
require 'functions.php';
$conn = buildConn($configs);
if (empty($_GET)) {
    die;
}
if (empty($_GET['m'])) {
    $playerInfo = getPlayerInfo($conn, $_GET['id']);
} else {
    $playerInfo = getBestMatch($conn, $_GET['id']);
}
echo '<p class="muted text-center">';
echo "Wins: " . $playerInfo['wins'] . "</br>";
echo "Losses: " . $playerInfo['losses'] . "</br>";
echo '</p>';
		<!-- page spec css -->
		<link href="assets/css/individualstats.css" rel="stylesheet">
		<!-- pergame vs season js-->
		<script src="assets/js/playerstats_statdeterm.js"></script>

	</head>
	<body id="player_body">

		<div class="container-fluid" id="averagestats">
			<div class="row">
			<!-- this is not good, but I couldn't find out how to get just 2 columns centered, so I put 4 columns total so the spacing looks good-->
			     <div class="col-sm-0 col-md-2 col-lg-3"></div>
			     <div class="col-sm-6 col-md-4 col-lg-3" id="playerinfo">
			     	<div class = "text-center">
     					<?php 
getPlayerInfo();
?>
     				</div>
			     </div>
			     <div class="col-sm-6 col-md-4 col-lg-3" id="avgplayerstats">
			     	<div class = "col">
			     		<div class = "text-center">
	     					<?php 
getSeasonOverview();
?>
	     				</div>
	     			</div>
			     </div>
  			     <div class="col-sm-0 col-md-2 col-lg-3"></div>
		    </div>
		</div>
    //$result = mysql_query($insert);
    $id = mysql_insert_id();
    /***********************
    	///awards section
    	/***********************/
    getAwards($id, $player_page->find('td p font.bio', 0));
    //->find('a[href^=/awards]')
}
$con = mysql_connect("localhost", "root", "");
if (!$con) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("player_profile_backup", $con);
$players_url = "http://databasefootball.com/players/playerlist.htm";
$letter = $_GET['letter'];
echo "Get letter {$letter}<br>";
$url = $players_url . "?lt={$letter}";
$letter_page = file_get_html($url);
//echo $letter_page;
//find all <a href> elements on the page
$links = $letter_page->find("a[href^=playerpage]");
//limit to 10 right now for testing
echo sizeof($links) . " links found for letter: {$letter}<br>";
$i = 0;
foreach ($links as $link) {
    if ($i > 25) {
        break;
    }
    getPlayerInfo($link->href);
    $i = $i + 1;
}
    $first = $name_array[0];
    $last = $name_array[1];
    //echo "trs: ".var_dump($player_page->find('table tr[onmouseover]'));
    $teams = getTeams($player_page->find('table tbody tr td table tbody tr[onmouseover]'));
    //echo "Name: $fullName<br>";
    if ($debug) {
        echo "plaintext: {$plaintext}<br>";
        echo "nickName: {$nickname}<br>";
        echo "Position: '{$position}'<br>";
        echo "height: {$height}<br>";
        echo "weight: {$weight}<br>";
        echo "dob: {$dob}<br>";
        echo "hometown: {$hometown}<br>";
        echo "college: {$college}<br>";
        echo "drafted: {$drafted}<br>";
        echo "teams: {$teams}<br><br>";
    }
    $insert = "INSERT INTO players (\r\n\t\t\t\tfirst_name, last_name, height, weight, dob, position, team, college, hometown, drafted, nickname) \r\n\t\t\t\tVALUES('{$first}', '{$last}', '{$height}', {$weight}, '{$dob}', '{$position}', '{$teams}', '{$college}', '{$hometown}', '{$drafted}', '{$nickname}')";
    preg_replace("/''/", "'", $insert);
    echo $insert . "<br>";
    //$result = mysql_query($insert);
    $id = mysql_insert_id();
    /***********************
    	///awards section
    	/***********************/
    getAwards($id, $player_page->find('td p font.bio', 0));
    //->find('a[href^=/awards]')
}
$href = $_GET['href'];
getPlayerInfo($href);
Esempio n. 6
0
<?php

include 'Functions.php';
include 'PlayerFunctions.php';
//handles call from ajax from player.php
if (isset($_POST['aPlayerID'])) {
    //get player info
    $playerID = $_POST['aPlayerID'];
    echo getPlayerInfo($playerID);
    //get player info table
    echo getPlayerBatting($playerID);
    //get plater batting table
    echo getPlayerFielding($playerID);
    //get player fielding table
    echo getPlayerPitching($playerID);
    // get player pitching table
}
Esempio n. 7
0
$pitchingTable = "";
$playerTable = "";
$error = "";
if (isset($_POST['submit'])) {
    $connection = mysqli_connect("localhost", "root", "", "baseball");
    $playerFirstname = mysqlsafe($_POST['PlayerFirstname'], $connection);
    $playerLastname = mysqlsafe($_POST['PlayerLastname'], $connection);
    $query = mysqli_query($connection, "SELECT playerID, nameFirst, nameLast, weight, height, bats, throws, debut, finalGame, birthCity, birthState FROM master WHERE nameFirst='{$playerFirstname}' AND nameLast='{$playerLastname}'");
    $rowCount = mysqli_num_rows($query);
    if ($rowCount == 0) {
        $error = "Player name not contained in database.";
    } else {
        if ($rowCount == 1) {
            $row = mysqli_fetch_assoc($query);
            $playerID = $row['playerID'];
            $playerInfo = getPlayerInfo($playerID);
            $battingTable = getPlayerBatting($playerID);
            $fieldingTable = getPlayerFielding($playerID);
            $pitchingTable = getPlayerPitching($playerID);
        } else {
            if ($rowCount > 1) {
                $playerTable = "<table >\n";
                $playerTable .= "\t<tr>\n";
                $playerTable .= "\t\t<th>Name</th>\n";
                //rows will contain first and lastname
                $playerTable .= "\t\t<th>Weight(Pounds)</th>\n";
                $playerTable .= "\t\t<th>Height(Inches)</th>\n";
                $playerTable .= "\t\t<th>Birthplace</th>\n";
                // row will contain city and state of birth
                $playerTable .= "\t\t<th>Debut(YYYY-MM-DD)</th>\n";
                $playerTable .= "\t\t<th>Final Game(YYYY-MM-DD)</th>\n";
        echo "dob: {$dob}<br>";
        echo "hometown: {$hometown}<br>";
        echo "college: {$college}<br>";
        echo "drafted: {$drafted}<br>";
        echo "teams: {$teams}<br><br>";
    }
    $insert = "INSERT INTO players (\r\n\t\t\t\tfirst_name, last_name, height, weight, dob, position, team, college, hometown, drafted, nickname) \r\n\t\t\t\tVALUES('{$first}', '{$last}', '{$height}', {$weight}, '{$dob}', '{$position}', '{$teams}', '{$college}', '{$hometown}', '{$drafted}', '{$nickname}')";
    preg_replace("/''/", "'", $insert);
    echo $insert . "<br>";
    $result = mysql_query($insert);
    $id = mysql_insert_id();
    if ($id == 0) {
        echo "<span style='color:red;'>FAILED to INSERT Player</span><br>{$plaintext}<br>{$insert}<br>";
    }
    /***********************
    	///awards section
    	/***********************/
    getAwards($id, $player_page->find('td p font.bio', 0));
    $player_page->clear();
    unset($player_page);
}
$con = mysql_connect("localhost", "root", "");
if (!$con) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("staging", $con);
$select_links = "Select link from unique_links";
$result = mysql_query($select_links);
while ($link = mysql_fetch_assoc($result)) {
    $link = getPlayerInfo($link['link']);
}
Esempio n. 9
0
$app->error('handleError');
function myErrorHandler($errorCode, $errorMessage, $errorFile, $errorLinenumber)
{
    handleError($errorMessage);
}
set_error_handler("myErrorHandler");
set_exception_handler("myErrorHandler");
$app->get('/points/:user', function ($user) use($app) {
    try {
        $urlSoapWSDL = 'http://www.comunio.co.uk/soapservice.php?wsdl';
        $soapClient = new SoapClient($urlSoapWSDL);
        $userId = $soapClient->getuserid($user);
        $lineup = getLineup($userId);
        $playersInfo = [];
        for ($i = 0; $i < count($lineup); $i++) {
            array_push($playersInfo, getPlayerInfo($lineup[$i]));
        }
        $dates = explode(',', $app->request()->get('dates'));
        $ratings = [];
        for ($k = 0; $k < count($playersInfo); $k++) {
            array_push($ratings, getPlayerRating($playersInfo[$k], $dates));
        }
        echo json_encode($ratings);
    } catch (Exception $e) {
        throw $e;
    }
});
function getLineup($id)
{
    $client = new Client();
    $urlLineup = 'http://www.comunio.co.uk/playerInfo.phtml?pid=' . $id;