コード例 #1
0
ファイル: picks.php プロジェクト: jeffmoreland/football
                 //echo "<span style=\"color:green;\">Correct</span>";
                 // add point to picks table for user and gsis_id
                 addPoint($db, $pick['pick_id'], 1, false);
                 updatePoints($db, $this_user_id, $this_group_id, $this_season_year, $this_season_type, $this_week, false);
             } else {
                 $result_str = "winning";
                 //echo "<span style=\"color:green;\">Winning</span>";
             }
         } elseif (getGameWinner($this_gsis_id) == "tied") {
             $result_str = "tied";
             //echo "<span style=\"color:blue;\">Tied</span>";
         } else {
             if ($this_finished == "t") {
                 $result_str = "incorrect";
                 //echo "<span style=\"color:red;\">Loser</span>";
                 addPoint($db, $pick['pick_id'], 0, false);
                 updatePoints($db, $this_user_id, $this_group_id, $this_season_year, $this_season_type, $this_week, false);
             } else {
                 $result_str = "losing";
                 //echo "<span style=\"color:red;\">Losing</span>";
             }
         }
     } else {
         $result_str = "not started";
     }
     break;
 } else {
     $home_style = "notPicked";
     $away_style = "notPicked";
     $result_str = "not picked";
     $this_score = "";
コード例 #2
0
ファイル: request.php プロジェクト: raprasad/iem
if (strlen($day) == 0) {
    $day = date('d');
}
$ts = mktime(0, 0, 0, $month, $day, 2000);
$sqlDate = strftime('%Y-%m-%d', $ts);
$filePre = strftime('%m%d', $ts) . "_coop";
$pgcon = iemdb("coop");
$rs = pg_exec($pgcon, "select c.*, \n   to_char(c.valid, 'YYYYMMDD') as cvalid from \n   climate c WHERE c.valid = '" . $sqlDate . "' ");
pg_close($pgcon);
@mkdir("/tmp/cli2shp");
chdir("/tmp/cli2shp");
$shpFname = $filePre;
$shpFile = ms_newShapeFileObj($shpFname, MS_SHP_POINT);
$dbfFile = dbase_create($shpFname . ".dbf", array(array("SITE", "C", 6), array("NAME", "C", 50), array("CRECORD", "N", 5, 0), array("DATE", "D"), array("AVG_HIGH", "N", 3, 0), array("AVG_LOW", "N", 3, 0), array("AVG_PREC", "N", 8, 2), array("MAX_PREC", "N", 8, 2), array("MAX_PR_YR", "N", 4, 0), array("MAX_HIGH", "N", 3, 0), array("MAX_LOW", "N", 3, 0), array("MIN_HIGH", "N", 3, 0), array("MIN_LOW", "N", 3, 0), array("MAX_HI_YR", "N", 4, 0), array("MAX_LO_YR", "N", 4, 0), array("MIN_HI_YR", "N", 4, 0), array("MIN_LO_YR", "N", 4, 0)));
for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) {
    addPoint($row, $cities[strtoupper($row["station"])]["lon"], $cities[strtoupper($row["station"])]["lat"], $cities[strtoupper($row["station"])]["name"]);
}
// End of for
$shpFile->free();
dbase_close($dbfFile);
// Generate zip file
copy("/mesonet/www/apps/iemwebsite/data/gis/meta/4326.prj", $filePre . ".prj");
popen("zip " . $filePre . ".zip " . $filePre . ".shp " . $filePre . ".shx " . $filePre . ".dbf " . $filePre . ".prj", 'r');
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename={$filePre}.zip");
readfile("{$filePre}.zip");
unlink("{$filePre}.zip");
unlink("{$filePre}.shp");
unlink("{$filePre}.prj");
unlink("{$filePre}.dbf");
unlink("{$filePre}.shx");
コード例 #3
0
/**
 * Causes a Google map to be printed based on the gps data in all the images in the album
 * @param  string $zoomlevel the zoom in for the map. NULL will use the default
 * @param string $defaultmaptype the starting display of the map valid values are G_NORMAL_MAP | G_SATELLITE_MAP | G_HYBRID_MAP | G_PHYSICAL_MAP | G_SATELLITE_3D_MAP
 * @param int $width is the image width of the map. NULL will use the default
 * @param int $height is the image height of the map. NULL will use the default
 * @param string $text text for the pop-up link
 * @param bool $toggle set to true to hide initially
 * @param string $id DIV id
 * @param int $firstPageImages the number of images on transition pages.
 * @param array $mapselections array of the maps to be used.
 * @param bool $addphysical Adds physical map.
 * @param bool $addwiki Adds wikipedia georeferenced data on your maps
 * @param string $background the background color for the map
 * @param string $mapcontrol values None | Small | Large
 * @param string $maptypecontrol values Buttons | List
 * @param string $customJS the extra javascript needed by the theme
 */
function printAlbumMap($zoomlevel = NULL, $defaultmaptype = NULL, $width = NULL, $height = NULL, $text = '', $toggle = true, $id = 'googlemap', $firstPageImages = 0, $mapselections = NULL, $addwiki = NULL, $background = NULL, $mapcontrol = NULL, $maptypecontrol = NULL, $customJS = NULL)
{
    global $_zp_phoogle, $_zp_images, $_zp_current_album, $_zp_current_image;
    if (getOption('gmaps_apikey') != '') {
        $foundLocation = false;
        $defaultmaptype = setupAllowedMaps($defaultmaptype, $mapselections);
        if ($zoomlevel) {
            $_zp_phoogle->zoomLevel = $zoomlevel;
        }
        if (!is_null($width)) {
            $_zp_phoogle->setWidth($width);
        } else {
            $_zp_phoogle->setWidth(getOption('gmaps_width'));
        }
        if (!is_null($height)) {
            $_zp_phoogle->setHeight($height);
        } else {
            $_zp_phoogle->setHeight(getOption('gmaps_height'));
        }
        if (!is_null($mapcontrol)) {
            $_zp_phoogle->setControlMap($mapcontrol);
        } else {
            $_zp_phoogle->setControlMap(getOption('gmaps_control'));
        }
        if (!is_null($maptypecontrol)) {
            $_zp_phoogle->setControlMapType($maptypecontrol);
        } else {
            $_zp_phoogle->setControlMapType(getOption('gmaps_control_maptype'));
        }
        if (!is_null($background)) {
            $_zp_phoogle->setBackGround($background);
        } else {
            $_zp_phoogle->setBackGround(getOption('gmaps_background'));
        }
        if (!is_null($customJS)) {
            $_zp_phoogle->customJS = $customJS;
        }
        resetCurrentAlbum();
        // start from scratch
        while (next_image(getOption('gmaps_show_all_album_points'), $firstPageImages)) {
            $exif = getImageEXIFData();
            if (!empty($exif['EXIFGPSLatitude']) && !empty($exif['EXIFGPSLongitude'])) {
                $foundLocation = true;
                $lat = $exif['EXIFGPSLatitude'];
                $long = $exif['EXIFGPSLongitude'];
                if ($exif['EXIFGPSLatitudeRef'] == 'S') {
                    $lat = '-' . $lat;
                }
                if ($exif['EXIFGPSLongitudeRef'] == 'W') {
                    $long = '-' . $long;
                }
                $infoHTML = '<a href="' . pathurlencode(getImageLinkURL()) . '"><img src="' . pathurlencode(getImageThumb()) . '" alt="' . getImageDesc() . '" ' . 'style=" margin-left: 30%; margin-right: 10%; border: 0px; "/></a>' . '<p>' . getImageDesc() . '</p>';
                addPoint($lat, $long, js_encode($infoHTML));
            }
        }
        resetCurrentAlbum();
        // clear out any 'damage'
        if ($foundLocation) {
            $dataid = $id . '_data';
            //to avoid problems with google earth and the toggle options, the toggle option is removed from here when GE is activated
            //it is possible to have both functionnality work but the toogle option should then be integrated in the phoogle map class dirctly within the script
            //that calls the map and should alos trigger a map type change. check Sobre theme or  have alook at www.kaugite.com for an example
            $toggle = $toggle && $defaultmaptype != 'G_SATELLITE_3D_MAP';
            if (is_null($text)) {
                $text = gettext('Google Map');
            }
            echo "<a href=\"javascript: vtoggle('{$dataid}');\" title=\"" . gettext('Display or hide the Google Map.') . "\">";
            echo $text;
            echo "</a>\n";
            echo "  <div id=\"{$dataid}\"" . ($toggle ? " style=\"color:black; visibility: hidden;position:absolute;left: -3000px;top: -3000px\"" : '') . ">\n";
            $_zp_phoogle->showMap(is_null($zoomlevel));
            echo "  </div>\n";
        }
    }
}
コード例 #4
0
ファイル: request.php プロジェクト: muthulatha/iem
if (strlen($day) == 0) {
    $day = date('d');
}
$ts = mktime(0, 0, 0, $month, $day, 2000);
$sqlDate = strftime('%Y-%m-%d', $ts);
$filePre = strftime('%m%d', $ts) . "_coop";
$pgcon = iemdb("coop");
$rs = pg_exec($pgcon, "select c.*, ST_X(s.geom) as lon, ST_Y(s.geom) as lat,\n\t\ts.name,\n   to_char(c.valid, 'YYYYMMDD') as cvalid from \n   climate c JOIN stations s ON (c.station = s.id)\n   WHERE c.valid = '" . $sqlDate . "' and s.network ~* 'CLIMATE'");
pg_close($pgcon);
@mkdir("/tmp/cli2shp");
chdir("/tmp/cli2shp");
$shpFname = $filePre;
$shpFile = ms_newShapeFileObj($shpFname, MS_SHP_POINT);
$dbfFile = dbase_create($shpFname . ".dbf", array(array("SITE", "C", 6), array("NAME", "C", 50), array("CRECORD", "N", 5, 0), array("DATE", "D"), array("AVG_HIGH", "N", 3, 0), array("AVG_LOW", "N", 3, 0), array("AVG_PREC", "N", 8, 2), array("MAX_PREC", "N", 8, 2), array("MAX_PR_YR", "N", 4, 0), array("MAX_HIGH", "N", 3, 0), array("MAX_LOW", "N", 3, 0), array("MIN_HIGH", "N", 3, 0), array("MIN_LOW", "N", 3, 0), array("MAX_HI_YR", "N", 4, 0), array("MAX_LO_YR", "N", 4, 0), array("MIN_HI_YR", "N", 4, 0), array("MIN_LO_YR", "N", 4, 0)));
for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) {
    addPoint($row, $row["lon"], $row["lat"], $row["name"]);
}
// End of for
$shpFile->free();
dbase_close($dbfFile);
// Generate zip file
copy("/mesonet/www/apps/iemwebsite/data/gis/meta/4326.prj", $filePre . ".prj");
popen("zip " . $filePre . ".zip " . $filePre . ".shp " . $filePre . ".shx " . $filePre . ".dbf " . $filePre . ".prj", 'r');
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename={$filePre}.zip");
readfile("{$filePre}.zip");
unlink("{$filePre}.zip");
unlink("{$filePre}.shp");
unlink("{$filePre}.prj");
unlink("{$filePre}.dbf");
unlink("{$filePre}.shx");
コード例 #5
0
    if ($has_started) {
        if ($game['home_score'] > $game['away_score']) {
            $winning_team = $game['home_team'];
        } elseif ($game['home_score'] == $game['away_score']) {
            $winning_team = "tied";
        } else {
            $winning_team = $game['away_team'];
        }
        if ($has_finished) {
            if ($winning_team == $user_winner) {
                //pick correct
                addPoint($db, $user_pick_id, 1, FALSE);
                updatePoints($db, $user_user_id, $user_group_id, $user_season_year, $user_season_type, $user_week, false);
            } else {
                //($winning_team != $user_winner || $winning_team == 'tied')
                addPoint($db, $user_pick_id, 0, FALSE);
                updatePoints($db, $user_user_id, $user_group_id, $user_season_year, $user_season_type, $user_week, false);
            }
            //reconcile to prevent future changes
            $sql = "UPDATE picks SET reconciled=1 WHERE pick_id='{$user_pick_id}'";
            if (mysqli_query($db, $sql)) {
                // echo "Point $user_pick_id Reconciled for User $user_user_id.\n";
            } else {
                echo mysqli_error($db);
            }
        }
    }
}
echo "Picks reconciled. ";
//--RECONCILE WIINERS
//get all non-reconciled PICKS
コード例 #6
0
ファイル: functions.php プロジェクト: jeffmoreland/football
function reconcileWeeklyPoints($db, $group_id, $season_year, $season_type, $week)
{
    // get users from mysql db that belong to the group
    $users = getUsers($db, $group_id);
    foreach ($users as $user) {
        $this_user_id = $user['user_id'];
        echo "<p>User " . $user['user_name'] . "(id {$this_user_id})</p>";
        // Get all of the users picks for the season year type week
        //$pick_result = mysqli_query($db, "SELECT * FROM picks WHERE user_id='$this_user_id' AND group_id='$group_id' AND season_year='$season_year' AND season_type='$season_type' AND week='$week'");
        //$sql = "SELECT * FROM picks WHERE user_id='$this_user_id' AND group_id='$group_id' AND season_year='$season_year' AND season_type='$season_type' AND week='$week'";
        $sql = "SELECT picks.pick_id, picks.game_id, picks.winner, points.reconciled\n" . "FROM picks \n" . "LEFT JOIN points \n" . "ON points.user_id=picks.user_id\n" . "WHERE picks.user_id='{$this_user_id}' AND picks.group_id='{$group_id}' AND picks.season_year='{$season_year}' AND picks.season_type='{$season_type}' AND picks.week='{$week}' AND points.reconciled is NULL";
        echo "<p>{$sql}</p>";
        $pick_result = mysqli_query($db, $sql) or die(mysqli_error($db));
        while ($user_pick = mysqli_fetch_array($pick_result)) {
            $user_picks[] = $user_pick;
        }
        // Performing SQL query for all games
        $query = "SELECT * FROM game WHERE season_year='{$season_year}' AND season_type='{$season_type}' AND week='{$week}'";
        $result = pg_query($query) or die('Query failed: ' . pg_last_error());
        while ($games = pg_fetch_array($result, null, PGSQL_ASSOC)) {
            extract($games, EXTR_PREFIX_ALL, "this");
            //load all game variables from db_array
            if (strtotime($this_start_time) < time()) {
                $has_started = true;
            } else {
                $has_started = false;
            }
            if ($this_finished == "t") {
                $has_finished = true;
            } else {
                $has_finished = false;
            }
            if (isset($user_picks)) {
                //at least some picks in db
                foreach ($user_picks as $pick) {
                    if ($pick['game_id'] == $this_gsis_id) {
                        //user has already picked game so set winner
                        $this_winner = $pick['winner'];
                        // pass this_winner to a script that checks the actual_winner for the jesus_id in the nfl_db
                        // if it returns true, print correct or add to score,,,,
                        // if false, print LOSER and don't ++score
                        if (strtotime($this_start_time) < time()) {
                            //game started
                            if (getGameWinner($this_gsis_id) == $this_winner) {
                                if ($this_finished == "t") {
                                    //echo "<span style=\"color:green;\">Correct</span>";
                                    // add point to picks table for user and gsis_id
                                    addPoint($db, $pick['pick_id'], 1, true);
                                    reconcilePoints($db, $this_user_id, $group_id, $this_season_year, $this_season_type, $this_week, true);
                                }
                            } else {
                                if ($this_finished == "t") {
                                    //echo "<span style=\"color:red;\">Loser</span>";
                                    addPoint($db, $pick['pick_id'], 0, true);
                                    reconcilePoints($db, $this_user_id, $group_id, $this_season_year, $this_season_type, $this_week, true);
                                }
                            }
                        }
                    }
                }
                //End Foreach pick
            }
        }
        //End While
    }
    //End User Foreach
}