Example #1
0
function userInfoText()
{
    global $username, $id;
    ?>
        <div class="col-xs-4 col-xs-offset-1 whiteBackground bordered">
            <div class="row">
                <div class="col-sm-4">
                    <img src="../graphics/<?php 
    echo $id % 10;
    ?>
.png" alt="User<?php 
    echo $id;
    ?>
" style="width:70px;height:70px;border-radius: 10px;">
                </div>
                <div class="col-sm-8">
                    <h3> <?php 
    echo $username;
    ?>
 <br></h3>
                </div>  
            </div>  
            <div class="col-sm-4">
                POINTS <br> <?php 
    getPoints();
    ?>
   <!--<?php 
    echo numOfTweets($username);
    ?>
-->
            </div>
            
            <?php 
    if (!empty($_SESSION['bikeid'])) {
        ?>
                <div class="col-sm-4">
                    CURRENT BIKE <br> <?php 
        echo $_SESSION['bikeid'];
        ?>
 
                </div>  
            <?php 
    }
    ?>
 
            <div class="col-sm-4">
                REDEEM <br> <?php 
    getRedeemCount();
    ?>
   <!--<?php 
    echo numOfTweets($username);
    ?>
-->
            </div>
            
        </div>
        <?php 
}
    }
    //exit(0);
    foreach ($mrows as $row) {
        if (!is_null($rek1)) {
            $rek2 = array("stock" => $row["stock"], "date" => $row["date"], "rec" => $row["rec"]);
            $points += getPoints($rek1, $rek2);
        }
        $rek1 = array("stock" => $row["stock"], "date" => $row["date"], "rec" => $row["rec"]);
    }
    // nuvarande
    if ($rek1 == null) {
        print_r("avbryter, inga rekar<br />");
        continue;
    }
    $rek_now = array("stock" => $stock, "date" => "2012-04-27");
    $points += getPoints($rek1, $rek_now);
    print_r("poäng: " . $points . "<br /><hr />");
    if ($i == 4) {
        var_dump($search_maklare);
        exit(0);
    }
}
function getPoints($rek1, $rek2)
{
    // tips sparat från föregående loop
    $kurs1 = getKurs($rek1["stock"], $rek1["date"]);
    $kurs2 = getKurs($rek2["stock"], $rek2["date"]);
    $points = 0;
    $p = ($kurs2 - $kurs1) / $kurs1;
    if ($rek1["rec"] > 0 && $kurs2 > $kurs1 * 1.05) {
        $points = $p;
Example #3
0
function handle_WP_GPX_Maps_Shortcodes($attr, $content = '')
{
    $error = '';
    $gpx = findValue($attr, "gpx", "", "");
    $w = findValue($attr, "width", "wpgpxmaps_width", "100%");
    $mh = findValue($attr, "mheight", "wpgpxmaps_height", "450px");
    $mt = findValue($attr, "mtype", "wpgpxmaps_map_type", "HYBRID");
    $gh = findValue($attr, "gheight", "wpgpxmaps_graph_height", "200px");
    $showCad = findValue($attr, "showcad", "wpgpxmaps_show_cadence", false);
    $showHr = findValue($attr, "showhr", "wpgpxmaps_show_hr", false);
    $showAtemp = findValue($attr, "showatemp", "wpgpxmaps_show_atemp", false);
    $showW = findValue($attr, "waypoints", "wpgpxmaps_show_waypoint", false);
    $showEle = findValue($attr, "showele", "wpgpxmaps_show_elevation", "true");
    $showSpeed = findValue($attr, "showspeed", "wpgpxmaps_show_speed", false);
    $showGrade = findValue($attr, "showgrade", "wpgpxmaps_show_grade", false);
    $zoomOnScrollWheel = findValue($attr, "zoomonscrollwheel", "wpgpxmaps_zoomonscrollwheel", false);
    $donotreducegpx = findValue($attr, "donotreducegpx", "wpgpxmaps_donotreducegpx", false);
    $pointsoffset = findValue($attr, "pointsoffset", "wpgpxmaps_pointsoffset", 10);
    $uom = findValue($attr, "uom", "wpgpxmaps_unit_of_measure", "0");
    $uomspeed = findValue($attr, "uomspeed", "wpgpxmaps_unit_of_measure_speed", "0");
    $color_map = findValue($attr, "mlinecolor", "wpgpxmaps_map_line_color", "#3366cc");
    $color_graph = findValue($attr, "glinecolor", "wpgpxmaps_graph_line_color", "#3366cc");
    $color_graph_speed = findValue($attr, "glinecolorspeed", "wpgpxmaps_graph_line_color_speed", "#ff0000");
    $color_graph_hr = findValue($attr, "glinecolorhr", "wpgpxmaps_graph_line_color_hr", "#ff77bd");
    $color_graph_atemp = findValue($attr, "glinecoloratemp", "wpgpxmaps_graph_line_color_atemp", "#ff77bd");
    $color_graph_cad = findValue($attr, "glinecolorcad", "wpgpxmaps_graph_line_color_cad", "#beecff");
    $color_graph_grade = findValue($attr, "glinecolorgrade", "wpgpxmaps_graph_line_color_grade", "#beecff");
    $chartFrom1 = findValue($attr, "chartfrom1", "wpgpxmaps_graph_offset_from1", "");
    $chartTo1 = findValue($attr, "chartto1", "wpgpxmaps_graph_offset_to1", "");
    $chartFrom2 = findValue($attr, "chartfrom2", "wpgpxmaps_graph_offset_from2", "");
    $chartTo2 = findValue($attr, "chartto2", "wpgpxmaps_graph_offset_to2", "");
    $startIcon = findValue($attr, "starticon", "wpgpxmaps_map_start_icon", "");
    $endIcon = findValue($attr, "endicon", "wpgpxmaps_map_end_icon", "");
    $currentIcon = findValue($attr, "currenticon", "wpgpxmaps_map_current_icon", "");
    $waypointIcon = findValue($attr, "waypointicon", "wpgpxmaps_map_waypoint_icon", "");
    $ngGalleries = findValue($attr, "nggalleries", "wpgpxmaps_map_ngGalleries", "");
    $ngImages = findValue($attr, "ngimages", "wpgpxmaps_map_ngImages", "");
    // folgende Zeile hinzugefügt:
    $attachments = findValue($attr, "attachments", "wpgpxmaps_map_attachments", false);
    $download = findValue($attr, "download", "wpgpxmaps_download", "");
    $dtoffset = findValue($attr, "dtoffset", "wpgpxmaps_dtoffset", 0);
    $distanceType = findValue($attr, "distanceType", "wpgpxmaps_distance_type", 0);
    $skipcache = findValue($attr, "skipcache", "wpgpxmaps_skipcache", "");
    $summary = findValue($attr, "summary", "wpgpxmaps_summary", "");
    $p_tot_len = findValue($attr, "summarytotlen", "wpgpxmaps_summary_tot_len", false);
    $p_max_ele = findValue($attr, "summarymaxele", "wpgpxmaps_summary_max_ele", false);
    $p_min_ele = findValue($attr, "summaryminele", "wpgpxmaps_summary_min_ele", false);
    $p_total_ele_up = findValue($attr, "summaryeleup", "wpgpxmaps_summary_total_ele_up", false);
    $p_total_ele_down = findValue($attr, "summaryeledown", "wpgpxmaps_summary_total_ele_down", false);
    $p_avg_speed = findValue($attr, "summaryavgspeed", "wpgpxmaps_summary_avg_speed", false);
    $p_total_time = findValue($attr, "summarytotaltime", "wpgpxmaps_summary_total_time", false);
    $usegpsposition = findValue($attr, "usegpsposition", "wpgpxmaps_usegpsposition", false);
    $currentpositioncon = findValue($attr, "currentpositioncon", "wpgpxmaps_currentpositioncon", "");
    $colors_map = "\"" . implode("\",\"", explode(" ", $color_map)) . "\"";
    $gpxurl = $gpx;
    // Add file modification time to cache filename to catch new uploads with same file name
    $mtime = sitePath() . str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, trim($gpx));
    if (file_exists($mtime)) {
        $mtime = filemtime($mtime);
    } else {
        $mtime = 0;
    }
    $cacheFileName = "{$gpx},{$mtime},{$w},{$mh},{$mt},{$gh},{$showEle},{$showW},{$showHr},{$showAtemp},{$showCad},{$donotreducegpx},{$pointsoffset},{$showSpeed},{$showGrade},{$uomspeed},{$uom},{$distanceType},v1.3.9";
    $cacheFileName = md5($cacheFileName);
    $gpxcache = gpxCacheFolderPath();
    if (!(file_exists($gpxcache) && is_dir($gpxcache))) {
        @mkdir($gpxcache, 0755, true);
    }
    $gpxcache .= DIRECTORY_SEPARATOR . $cacheFileName . ".tmp";
    // Try to load cache
    if (file_exists($gpxcache) && !($skipcache == true)) {
        try {
            $cache_str = file_get_contents($gpxcache);
            $cache_obj = unserialize($cache_str);
            $points_maps = $cache_obj["points_maps"];
            $points_x_time = $cache_obj["points_x_time"];
            $points_x_lat = $cache_obj["points_x_lat"];
            $points_x_lon = $cache_obj["points_x_lon"];
            $points_graph_dist = $cache_obj["points_graph_dist"];
            $points_graph_ele = $cache_obj["points_graph_ele"];
            $points_graph_speed = $cache_obj["points_graph_speed"];
            $points_graph_hr = $cache_obj["points_graph_hr"];
            $points_graph_atemp = $cache_obj["points_graph_atemp"];
            $points_graph_cad = $cache_obj["points_graph_cad"];
            $points_graph_grade = $cache_obj["points_graph_grade"];
            $waypoints = $cache_obj["waypoints"];
            $max_ele = $cache_obj["max_ele"];
            $min_ele = $cache_obj["min_ele"];
            $max_time = $cache_obj["max_time"];
            $min_time = $cache_obj["min_time"];
            $total_ele_up = $cache_obj["total_ele_up"];
            $total_ele_down = $cache_obj["total_ele_down"];
            $avg_speed = $cache_obj["avg_speed"];
            $tot_len = $cache_obj["tot_len"];
        } catch (Exception $e) {
            $points_maps = '';
            $points_x_time = '';
            $points_x_lat = '';
            $points_x_lon = '';
            $points_graph_dist = '';
            $points_graph_ele = '';
            $points_graph_speed = '';
            $points_graph_hr = '';
            $points_graph_atemp = '';
            $points_graph_cad = '';
            $points_graph_grade = '';
            $waypoints = '';
            $max_ele = 0;
            $min_ele = 0;
            $max_time = 0;
            $min_time = 0;
            $total_ele_up = 0;
            $total_ele_down = 0;
            $avg_speed = 0;
            $tot_len = 0;
        }
    }
    $isGpxUrl = preg_match('/^(http(s)?\\:\\/\\/)/', trim($gpx)) == 1;
    if ((!isset($points_maps) || $points_maps == '') && $gpx != '') {
        //if (true)	{
        $sitePath = sitePath();
        $gpx = trim($gpx);
        if ($isGpxUrl == true) {
            $gpx = downloadRemoteFile($gpx);
        } else {
            $gpx = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $gpx);
            $gpx = $sitePath . $gpx;
        }
        if ($gpx == '') {
            return "No gpx found";
        }
        $points = getPoints($gpx, $pointsoffset, $donotreducegpx, $distanceType);
        $points_maps = '';
        $points_graph_dist = '';
        $points_graph_ele = '';
        $points_graph_speed = '';
        $points_graph_hr = '';
        $points_graph_atemp = '';
        $points_graph_cad = '';
        $points_graph_grade = '';
        $waypoints = '';
        $points_x_time = $points->dt;
        $points_x_lat = $points->lat;
        $points_x_lon = $points->lon;
        $max_ele = $points->maxEle;
        $min_ele = $points->minEle;
        $max_time = $points->maxTime;
        $min_time = $points->minTime;
        $total_ele_up = $points->totalEleUp;
        $total_ele_down = $points->totalEleDown;
        $avg_speed = $points->avgSpeed;
        $tot_len = $points->totalLength;
        if (is_array($points_x_lat)) {
            foreach (array_keys($points_x_lat) as $i) {
                $_lat = (double) $points_x_lat[$i];
                $_lon = (double) $points_x_lon[$i];
                if ($_lat == 0 && $_lon == 0) {
                    $points_maps .= 'null,';
                    $points_graph_dist .= 'null,';
                    $points_graph_ele .= 'null,';
                    if ($showSpeed == true) {
                        $points_graph_speed .= 'null,';
                    }
                    if ($showHr == true) {
                        $points_graph_hr .= 'null,';
                    }
                    if ($showAtemp == true) {
                        $points_graph_atemp .= 'null,';
                    }
                    if ($showCad == true) {
                        $points_graph_cad .= 'null,';
                    }
                    if ($showGrade == true) {
                        $points_graph_grade .= 'null,';
                    }
                } else {
                    $points_maps .= '[' . number_format((double) $points_x_lat[$i], 7, '.', '') . ',' . number_format((double) $points_x_lon[$i], 7, '.', '') . '],';
                    $_ele = (double) $points->ele[$i];
                    $_dist = (double) $points->dist[$i];
                    if ($uom == '1') {
                        // Miles and feet
                        $_dist *= 0.000621371192;
                        $_ele *= 3.2808399;
                    } else {
                        if ($uom == '2') {
                            // meters / kilometers
                            $_dist = (double) ($_dist / 1000);
                        } else {
                            if ($uom == '3') {
                                // meters / kilometers / nautical miles
                                $_dist = (double) ($_dist / 1000 / 1.852);
                            } else {
                                if ($uom == '4') {
                                    // meters / miles
                                    $_dist *= 0.000621371192;
                                } else {
                                    if ($uom == '5') {
                                        // meters / kilometers / nautical miles and feet
                                        $_dist = (double) ($_dist / 1000 / 1.852);
                                        $_ele *= 3.2808399;
                                    }
                                }
                            }
                        }
                    }
                    $points_graph_dist .= number_format($_dist, 2, '.', '') . ',';
                    $points_graph_ele .= number_format($_ele, 2, '.', '') . ',';
                    if ($showSpeed == true) {
                        $_speed = (double) $points->speed[$i];
                        $points_graph_speed .= convertSpeed($_speed, $uomspeed) . ',';
                    }
                    if ($showHr == true) {
                        $points_graph_hr .= number_format($points->hr[$i], 2, '.', '') . ',';
                    }
                    if ($showAtemp == true) {
                        $points_graph_atemp .= number_format($points->atemp[$i], 1, '.', '') . ',';
                    }
                    if ($showCad == true) {
                        $points_graph_cad .= number_format($points->cad[$i], 2, '.', '') . ',';
                    }
                    if ($showGrade == true) {
                        $points_graph_grade .= number_format($points->grade[$i], 2, '.', '') . ',';
                    }
                }
            }
        }
        if ($uom == '1') {
            // Miles and feet
            $tot_len = round($tot_len * 0.000621371192, 2) . " mi";
            $max_ele = round($max_ele * 3.2808399, 0) . " ft";
            $min_ele = round($min_ele * 3.2808399, 0) . " ft";
            $total_ele_up = round($total_ele_up * 3.2808399, 0) . " ft";
            $total_ele_down = round($total_ele_down * 3.2808399, 0) . " ft";
        } else {
            if ($uom == '2') {
                // meters / kilometers
                $tot_len = round($tot_len / 1000, 2) . " km";
                $max_ele = round($max_ele, 0) . " m";
                $min_ele = round($min_ele, 0) . " m";
                $total_ele_up = round($total_ele_up, 0) . " m";
                $total_ele_down = round($total_ele_down, 0) . " m";
            } else {
                if ($uom == '3') {
                    // meters / kilometers / nautical miles
                    $tot_len = round($tot_len / 1000 / 1.852, 2) . " NM";
                    $max_ele = round($max_ele, 0) . " m";
                    $min_ele = round($min_ele, 0) . " m";
                    $total_ele_up = round($total_ele_up, 0) . " m";
                    $total_ele_down = round($total_ele_down, 0) . " m";
                } else {
                    if ($uom == '4') {
                        // meters / kilometers / nautical miles
                        $tot_len = round($tot_len * 0.000621371192, 2) . " mi";
                        $max_ele = round($max_ele, 0) . " m";
                        $min_ele = round($min_ele, 0) . " m";
                        $total_ele_up = round($total_ele_up, 0) . " m";
                        $total_ele_down = round($total_ele_down, 0) . " m";
                    } else {
                        if ($uom == '5') {
                            // meters / kilometers / nautical miles and feet
                            $tot_len = round($tot_len / 1000 / 1.852, 2) . " NM";
                            $max_ele = round($max_ele * 3.2808399, 0) . " ft";
                            $min_ele = round($min_ele * 3.2808399, 0) . " ft";
                            $total_ele_up = round($total_ele_up * 3.2808399, 0) . " ft";
                            $total_ele_down = round($total_ele_down * 3.2808399, 0) . " ft";
                        } else {
                            // meters / meters
                            $tot_len = round($tot_len, 0) . " m";
                            $max_ele = round($max_ele, 0) . " m";
                            $min_ele = round($min_ele, 0) . " m";
                            $total_ele_up = round($total_ele_up, 0) . " m";
                            $total_ele_down = round($total_ele_down, 0) . " m";
                        }
                    }
                }
            }
        }
        $avg_speed = convertSpeed($avg_speed, $uomspeed, true);
        $waypoints = '[]';
        if ($showW == true) {
            $wpoints = getWayPoints($gpx);
            /*
            foreach ($wpoints as $p) {
            	$waypoints .= '['.number_format ( (float)$p[0] , 7 , '.' , '' ).','.number_format ( (float)$p[1] , 7 , '.' , '' ).',\''.unescape($p[4]).'\',\''.unescape($p[5]).'\',\''.unescape($p[7]).'\'],';
            }
            */
            $waypoints = json_encode($wpoints);
        }
        if ($showEle == "false") {
            $points_graph_ele = "";
        }
        $p = "/(,|,null,)\$/";
        $points_maps = preg_replace($p, "", $points_maps);
        $points_graph_dist = preg_replace($p, "", $points_graph_dist);
        $points_graph_ele = preg_replace($p, "", $points_graph_ele);
        $points_graph_speed = preg_replace($p, "", $points_graph_speed);
        $points_graph_hr = preg_replace($p, "", $points_graph_hr);
        $points_graph_atemp = preg_replace($p, "", $points_graph_atemp);
        $points_graph_cad = preg_replace($p, "", $points_graph_cad);
        $points_graph_grade = preg_replace($p, "", $points_graph_grade);
        $waypoints = preg_replace($p, "", $waypoints);
        if (preg_match("/^(0,?)+\$/", $points_graph_dist)) {
            $points_graph_dist = "";
        }
        if (preg_match("/^(0,?)+\$/", $points_graph_ele)) {
            $points_graph_ele = "";
        }
        if (preg_match("/^(0,?)+\$/", $points_graph_speed)) {
            $points_graph_speed = "";
        }
        if (preg_match("/^(0,?)+\$/", $points_graph_hr)) {
            $points_graph_hr = "";
        }
        if (preg_match("/^(0,?)+\$/", $points_graph_hr)) {
            $points_graph_hr = "";
        }
        if (preg_match("/^(0,?)+\$/", $points_graph_atemp)) {
            $points_graph_atemp = "";
        }
        if (preg_match("/^(0,?)+\$/", $points_graph_grade)) {
            $points_graph_grade = "";
        }
    }
    $ngimgs_data = '';
    if ($ngGalleries != '' || $ngImages != '') {
        //print_r($points);
        $ngimgs = getNGGalleryImages($ngGalleries, $ngImages, $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error);
        $ngimgs_data = '';
        foreach ($ngimgs as $img) {
            $data = $img['data'];
            $data = str_replace("\n", "", $data);
            $ngimgs_data .= '<span lat="' . $img['lat'] . '" lon="' . $img['lon'] . '">' . $data . '</span>';
        }
    }
    // Folgende Zeilen hinzugefügt
    if ($attachments == true) {
        $attimgs = getAttachedImages($points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error);
        foreach ($attimgs as $img) {
            $data = $img['data'];
            $data = str_replace("\n", "", $data);
            $ngimgs_data .= '<span lat="' . $img['lat'] . '" lon="' . $img['lon'] . '">' . $data . '</span>';
        }
    }
    if (!($skipcache == true)) {
        @file_put_contents($gpxcache, serialize(array("points_maps" => $points_maps, "points_x_time" => $points_x_time, "points_x_lat" => $points_x_lat, "points_x_lon" => $points_x_lon, "points_graph_dist" => $points_graph_dist, "points_graph_ele" => $points_graph_ele, "points_graph_speed" => $points_graph_speed, "points_graph_hr" => $points_graph_hr, "points_graph_atemp" => $points_graph_atemp, "points_graph_cad" => $points_graph_cad, "points_graph_grade" => $points_graph_grade, "waypoints" => $waypoints, "max_ele" => $max_ele, "min_ele" => $min_ele, "total_ele_up" => $total_ele_up, "total_ele_down" => $total_ele_down, "avg_speed" => $avg_speed, "tot_len" => $tot_len, "max_time" => $max_time, "min_time" => $min_time)), LOCK_EX);
        @chmod($gpxcache, 0755);
    }
    $hideGraph = $gh == "0" || $gh == "0px";
    global $post;
    $r = $post->ID . "_" . rand(1, 5000000);
    $output = '
		<div id="wpgpxmaps_' . $r . '" class="wpgpxmaps">
			<div id="map_' . $r . '_cont" style="width:' . $w . '; height:' . $mh . ';position:relative" >
				<div id="map_' . $r . '" style="width:' . $w . '; height:' . $mh . '"></div>
				<div id="wpgpxmaps_' . $r . '_osm_footer" class="wpgpxmaps_osm_footer" style="display:none;"><span> &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors</span></div>			
			</div>
			<div id="hchart_' . $r . '" class="plot" style="width:' . $w . '; height:' . $gh . '"></div>
			<div id="ngimages_' . $r . '" class="ngimages" style="display:none">' . $ngimgs_data . '</div>
			<div id="report_' . $r . '" class="report"></div>
		</div>
		' . $error . '
		<script type="text/javascript">
			jQuery(document).ready(function() {
				jQuery("#wpgpxmaps_' . $r . '").wpgpxmaps({ 
					targetId    : "' . $r . '",
					mapType     : "' . $mt . '",
					mapData     : [' . $points_maps . '],
					graphDist   : [' . ($hideGraph ? '' : $points_graph_dist) . '],
					graphEle    : [' . ($hideGraph ? '' : $points_graph_ele) . '],
					graphSpeed  : [' . ($hideGraph ? '' : $points_graph_speed) . '],
					graphHr     : [' . ($hideGraph ? '' : $points_graph_hr) . '],
					graphAtemp  : [' . ($hideGraph ? '' : $points_graph_atemp) . '],
					graphCad    : [' . ($hideGraph ? '' : $points_graph_cad) . '],
					graphGrade  : [' . ($hideGraph ? '' : $points_graph_grade) . '],
					waypoints   : ' . $waypoints . ',
					unit        : "' . $uom . '",
					unitspeed   : "' . $uomspeed . '",
					color1      : [' . $colors_map . '],
					color2      : "' . $color_graph . '",
					color3      : "' . $color_graph_speed . '",
					color4      : "' . $color_graph_hr . '",
					color5      : "' . $color_graph_cad . '",
					color6      : "' . $color_graph_grade . '",
					color7      : "' . $color_graph_atemp . '",
					chartFrom1  : "' . $chartFrom1 . '",
					chartTo1    : "' . $chartTo1 . '",
					chartFrom2  : "' . $chartFrom2 . '",
					chartTo2    : "' . $chartTo2 . '",
					startIcon   : "' . $startIcon . '",
					endIcon     : "' . $endIcon . '",
					currentIcon : "' . $currentIcon . '",
					waypointIcon : "' . $waypointIcon . '",
					currentpositioncon : "' . $currentpositioncon . '",
					usegpsposition : "' . $usegpsposition . '",
					zoomOnScrollWheel : "' . $zoomOnScrollWheel . '", 
					ngGalleries : [' . $ngGalleries . '],
					ngImages : [' . $ngImages . '],
					pluginUrl : "' . plugins_url() . '",
					langs : { altitude              : "' . __("Altitude", "wp-gpx-maps") . '",
							  currentPosition       : "' . __("Current Position", "wp-gpx-maps") . '",
							  speed                 : "' . __("Speed", "wp-gpx-maps") . '", 
							  grade                 : "' . __("Grade", "wp-gpx-maps") . '", 
							  heartRate             : "' . __("Heart rate", "wp-gpx-maps") . '", 
							  atemp             	: "' . __("Temperature", "wp-gpx-maps") . '", 
							  cadence               : "' . __("Cadence", "wp-gpx-maps") . '",
							  goFullScreen          : "' . __("Go Full Screen", "wp-gpx-maps") . '",
							  exitFullFcreen        : "' . __("Exit Full Screen", "wp-gpx-maps") . '",
							  hideImages            : "' . __("Hide Images", "wp-gpx-maps") . '",
							  showImages            : "' . __("Show Images", "wp-gpx-maps") . '",
							  backToCenter		    : "' . __("Back to center", "wp-gpx-maps") . '"
							}
				});
			});
		</script>';
    // print summary
    if ($summary == 'true' && ($points_graph_speed != '' || $points_graph_ele != '' || $points_graph_dist != '')) {
        $output .= "<div id='wpgpxmaps_summary_" . $r . "' class='wpgpxmaps_summary'>";
        if ($points_graph_dist != '' && $p_tot_len == 'true') {
            $output .= "<span class='totlen'><span class='summarylabel'>" . __("Total distance", "wp-gpx-maps") . ":</span><span class='summaryvalue'> {$tot_len}</span></span><br />";
        }
        if ($points_graph_ele != '') {
            if ($p_max_ele == 'true') {
                $output .= "<span class='maxele'><span class='summarylabel'>" . __("Max elevation", "wp-gpx-maps") . ":</span><span class='summaryvalue'> {$max_ele}</span></span><br />";
            }
            if ($p_min_ele == 'true') {
                $output .= "<span class='minele'><span class='summarylabel'>" . __("Min elevation", "wp-gpx-maps") . ":</span><span class='summaryvalue'> {$min_ele}</span></span><br />";
            }
            if ($p_total_ele_up == 'true') {
                $output .= "<span class='totaleleup'><span class='summarylabel'>" . __("Total climbing", "wp-gpx-maps") . ":</span><span class='summaryvalue'> {$total_ele_up}</span></span><br />";
            }
            if ($p_total_ele_down == 'true') {
                $output .= "<span class='totaleledown'><span class='summarylabel'>" . __("Total descent", "wp-gpx-maps") . ":</span><span class='summaryvalue'> {$total_ele_down}</span></span><br />";
            }
        }
        if ($points_graph_speed != '' && $p_avg_speed == 'true') {
            $output .= "<span class='avgspeed'><span class='summarylabel'>" . __("Average speed", "wp-gpx-maps") . ":</span><span class='summaryvalue'> {$avg_speed}</span></span><br />";
        }
        if ($p_total_time == 'true' && $max_time > 0) {
            $time_diff = date("H:i:s", $max_time - $min_time);
            $output .= "<span class='totaltime'><span class='summarylabel'>" . __("Total Time", "wp-gpx-maps") . ":</span><span class='summaryvalue'> {$time_diff}</span></span><br />";
        }
        $output .= "</div>";
    }
    // print download link
    if ($download == 'true' && $gpxurl != '') {
        if ($isGpxUrl == true) {
        } else {
            // wpml fix
            $dummy = defined('WP_SITEURL') ? WP_SITEURL : get_bloginfo('url');
            $gpxurl = $dummy . $gpxurl;
        }
        $output .= "<a href='{$gpxurl}' target='_new'>" . __("Download", "wp-gpx-maps") . "</a>";
    }
    return $output;
}
Example #4
0
function pointConversion($conn, $total, $id)
{
    $before = getPoints($conn, $id);
    $points = 0;
    if ($total >= 49000 && $total <= 69999) {
        $points = 10;
    } else {
        if ($total >= 70000 && $total <= 90999) {
            $points = 15;
        } else {
            if ($total >= 91000 && $total <= 111999) {
                $points = 20;
            } else {
                if ($total >= 112000 && $total <= 132999) {
                    $points = 25;
                } else {
                    if ($total >= 133000) {
                        $points = 30;
                    }
                }
            }
        }
    }
    $after = $before + $points;
    setPoints($conn, $id, $after);
}
Example #5
0
    $offered = $row['fcn_from_origin'];
}
// TODO: ditch all these cryptic codes/magic numbers that have equivalent meanings
if ($approvalAction == "a") {
    // 1 = accept trade
    $approved = "1";
} elseif ($approvalAction == "r") {
    // 0 = reject trade
    $approved = "0";
} elseif ($approvalAction == "tC") {
    // 2 = cancel trade (as originator); -1 = pending response
    $approved = "2";
}
if ($approvalAction == "a") {
    // If there's money involved, make sure the responsible parties have enough...
    if ($requested > getPoints($uuid)) {
        // TODO: Secondary verification of trade $ here -- we do it on the marketplace module,
        // but need to double-check
    }
}
// Record the acceptance/rejection in the trade table
$stmt = $dbh->prepare("UPDATE trades SET accepted = ? WHERE id = ?");
$stmt->bindValue(1, $approved);
$stmt->bindValue(2, $tid);
$stmt->execute();
if ($approved == "1") {
    // The user approved the trade, so move works into/out of his collection.
    $originTable = $origin . "_" . $gameinstance . "_coll";
    $destTable = $destination . "_" . $gameinstance . "_coll";
    $worksOffered = explode(' ', trim($workOfferedByOrigin));
    $worksRequested = explode(' ', trim($workRequestedFromDestination));
Example #6
0
        case 'matchCityId':
            if (empty($_GET['from']['city_id'])) {
                throw new Exception('from city_id is missing');
            }
            if (empty($_GET['from']['dob'])) {
                throw new Exception('from dob is missing');
            }
            if (empty($_GET['to']['city_id'])) {
                throw new Exception('to city_id is missing');
            }
            if (empty($_GET['to']['dob'])) {
                throw new Exception('to dob is missing');
            }
            $return['data']['points'] = array();
            $dataFrom2 = $return['data']['from'] = findCity($_GET['from']['city_id']);
            $dataFrom2['dob'] = $_GET['from']['dob'];
            $return['data']['from']['horo'] = findHoroInfo($dataFrom2);
            $dataTo2 = $return['data']['to'] = findCity($_GET['to']['city_id']);
            $dataTo2['dob'] = $_GET['to']['dob'];
            $return['data']['to']['horo'] = findHoroInfo($dataTo2);
            $return['data']['points'] = getPoints($return['data']['from']['horo'][9], $return['data']['to']['horo'][9]);
            break;
    }
} catch (Exception $e) {
    $return['success'] = 0;
    $return['error'] = 1;
    $return['errorMessage'] = $e->getMessage();
}
$return['get'] = $_GET;
//$return['actions'] = array('findcitybyid' => array('city_id'), 'nearby' => array('lat', 'lng'), 'cityMatch' => array('lat', 'lng'), 'match' => array('from', 'to'), 'findCity' => array('q'), 'matchMultiple' => array('data'), 'naks' => array('lat', 'lng', 'dob'), 'naksMatch' => array('naks1', 'naks2'));
echo json_encode($return);
Example #7
0
        $_SESSION['gameResult'] = RESULT_WRONG;
        echo RESULT_WRONG;
    }
}
$method = $_POST['method'];
if (is_null($method)) {
    exit;
}
switch ($method) {
    case 'getQuestion':
        $question = getQuestion();
        if ($question !== false) {
            include __DIR__ . '/Views/question.php';
        } else {
            $_SESSION['gameResult'] = RESULT_OK;
            echo RESULT_LIMIT_REACHED;
        }
        break;
    case 'getPoints':
        echo getPoints();
        break;
    case 'checkAnswer':
        checkAnswer();
        break;
    case 'endGame':
        $points = getPoints();
        clearPoints();
        $_SESSION['givenQuestions'] = [];
        include __DIR__ . '/Views/gameResult.php';
        break;
}
Example #8
0
function defineImage($rid, $sid, $id)
{
    $points = getPoints($sid, $id);
    $returnStr = '<div id="' . $rid . 'go" style="position:absolute; left:-180; top:-25; z-index:1; visibility:hidden;">
      <table bgcolor=black>
      <tr>
        <td>' . getResearchStat(name, $rid) . ' [';
    //Define the color for the points
    if ($points < $pointcost) {
        $returnStr .= '<font color=red>';
    } else {
        $returnStr .= '<font color=lime>';
    }
    $returnStr .= getResearchStat(points, $rid) . '</font>]</td></tr>
    <tr>
      <td>' . getResearchStat(description, $rid) . '</td>
    </tr>
      </table>
    </div>';
    return $returnStr;
}
Example #9
0
    });
}
function arrayLetraCount($str)
{
    $tengo = array();
    foreach (count_chars($str, 1) as $i => $val) {
        $tengo[chr($i)] = $val;
    }
    return $tengo;
}
$fd = fopen('descrambler_wordlist.txt', 'r');
$words = array();
while (!feof($fd)) {
    $word = trim(fgets($fd));
    if (!empty($word)) {
        $words[] = array('w' => $word, 'p' => getPoints($word, $letterValues), 'c' => arrayLetraCount($word));
    }
}
fclose($fd);
usort($words, function ($a, $b) {
    return $a['p'] > $b['p'] || $a['p'] == $b['p'] && $a['w'] < $b['w'] ? -1 : 1;
});
function mejorPalabra($fichas, $puntos = 0)
{
    global $words;
    $tengo = arrayLetraCount(implode('', $fichas));
    $tengoC = array_sum($tengo) + 1;
    foreach ($words as $key => $valor) {
        if ($valor['p'] < $puntos) {
            return false;
        }
Example #10
0
    }
    return [0, 0];
}
$c = new \esee\ChainBuilder([]);
foreach ($fonts as $font) {
    foreach ($chars as $char) {
        //6,7,8,
        $size = [9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24];
        foreach ($size as $s) {
            $im = imagecreatetruecolor(40, 40);
            $white = imagecolorallocate($im, 0xff, 0xff, 0xff);
            $black = imagecolorallocate($im, 0x0, 0x0, 0x0);
            imagefill($im, 0, 0, $white);
            //echo $fontDir .  $font . "\n"; exit();
            imagefttext($im, $s, 0, 5, 30, $black, $fontDir . $font, $char);
            $points = getPoints($im, 40, 40);
            list($x, $y) = getFirst($points);
            $c->reset($points);
            $chain = $c->makeChain2($x, $y);
            //\esee\Helper::view2($chain);
            //print_r($chain->path);	//  exit();
            if (is_null($chain)) {
                //echo $char . ' '.  $font . "\n";
                //\esee\Helper::view($points); if($i > 3) exit();
                continue;
            }
            $hash = join('', $chain->path);
            $hashs[strlen($hash)][] = [$hash, $char];
            //imagepng($im, './images/'.md5($font). '_' .$char. '_' . $s . '.png');
            imagedestroy($im);
        }
Example #11
0
        echo "(No works requested)";
    }
    echo "</div>";
    // See if any cash is involved in this proposal
    if ($row['fcn_from_origin'] > 0) {
        echo "<p style=\"display:block;clear:both;margin-left:10px;\">In addition to any works shown above, " . $row['origin_name'] . " offers you " . $CURRENCY_SYMBOL . $row['fcn_from_origin'] . " as part of this trade.";
    } else {
        if ($row['fcn_from_destination'] > 0) {
            echo "<p/>In addition to any works shown above, " . $row['origin_name'] . " requests " . $CURRENCY_SYMBOL . $row['fcn_from_destination'] . " from you as part of this trade.";
        }
    }
    // And finally print the form with accept/reject buttons.  The trade data are hidden
    // inputs; the form is processed by tradeApproval.php.
    echo "<p/><form style=\"display:block;clear:both;padding:5px;margin-left:10px;\"><input type=\"hidden\" name=\"originId\" value=\"" . $row['origin'] . "\"/><input type=\"hidden\" name=\"destinationId\" value=\"" . $row['destination'] . "\"/><input type=\"hidden\" name=\"offered\" value=\"" . $row['work_from_origin'] . "\"/><input type=\"hidden\" name=\"traded_for\" value=\"" . $row['work_from_destination'] . "\"/><input type=\"hidden\" name=\"tid\" value=\"" . $row['tid'] . "\"/>";
    // But first make sure we have enough money to accept the trade :o
    if ($row['fcn_from_destination'] > getPoints($uuid)) {
        echo "You can't approve this trade until you have at least " . $CURRENCY_SYMBOL . $row['fcn_from_destination'] . ".<p/>";
    } else {
        echo "<button class=\"tradeApproval\" name=\"a\">Approve</button>";
    }
    echo "<button class=\"tradeApproval\" name=\"r\">Reject</button> with message (optional):<input type=\"text\" class=\"tradeComment\" size=\"50\" name=\"tradeComment\"/></form></div>\n";
}
?>
              
</ul>
        <hr/>

        <h2>Trades Pending Another Player's Approval:</h2>

<?php 
$stmt = $dbh->prepare("SELECT origin,destination,fcn_from_origin,fcn_from_destination,gameinstance,date,trades.id as tid,work_from_origin,work_from_destination,c1.name AS origin_name,c2.name AS destination_name,accepted FROM trades LEFT OUTER JOIN collectors AS c1 ON c1.id = trades.origin LEFT OUTER JOIN collectors AS c2 ON c2.id = trades.destination WHERE trades.origin = ? AND accepted = -1 ORDER BY trades.date ASC LIMIT 10");
Example #12
0
							<select id="Rewards_15" name="selectRewards">
								<?php 
echo getRewards();
?>
							</select>
					</td>
					<td>
						Letter 
							<select id="Letter_16" name="selectLetter">
								<?php 
echo $letters = getLetters();
?>
							</select>
							Points <select id="Points_16" name="selectPoints">
								<?php 
echo getPoints();
?>
							</select>
							Rewards 
							<select id="Rewards_16" name="selectRewards">
								<?php 
echo getRewards();
?>
							</select>
					</td>
				</tr>
			</table>
			<div style="" align="center"><input id="showGame"  type="button" value="Show Game" style="font-size:18px; color:#000000; padding:10px 15px; "></div>
		</div>
		
		<!-- front panel -->
Example #13
0
}
$uname = $_SESSION['uname'];
$uuid = $_SESSION['uuid'];
ob_start();
// These resources are almost certainly already included by the parent
// script, so use require to avoid unnecessary reload
require 'functions.php';
require 'db.php';
ob_end_clean();
?>
     
<div xmlns:xi="http://www.w3.org/2001/XInclude" id="topBar">
<div class="topNavLeft">
<span class="topNav">
<a href="home.php" class="navHref"><img src="resources/icons/home_32x32.png" style="height:24px;"class="navBarIcon"/></a> | 
<a href="userHome.php" class="navHref"><?php 
echo $uname;
?>
's Collection<?php 
echo " (" . $CURRENCY_SYMBOL . getPoints($uuid) . ")";
?>
</a></span>
<span class="topNav">| <a href="collections.php" class="navHref">All Collections</a> | <a href="marketplace.php" class="navHref">Marketplace</a> |
<a href="mail.php" class="navHref"><img src="mail-icon.png" class="navBarIcon"/></a></span>
</div>

<div class="topNavRight">
<span class="topNav"><a href="#"><img id="bug" src="resources/icons/bug.png" style="height:24px;margin-right:15px;" class="navBarIcon"/></a><a href="logout.php" class="navHref">Sign Out</a></span>
</div>
</div>
Example #14
0
<?php

require_once './www.playconquest.com/db_connect.php';
//require_once('./db_connect.php');
$servercount = getServerNumber();
for ($x = 1; $x < $servercount + 1; $x++) {
    $query = "SELECT researchmod,ownerid FROM planets{$x} WHERE researchmod>0";
    $result = mysql_query($query);
    while ($row = mysql_fetch_array($result)) {
        $points = getPoints($x, $row[ownerid]);
        $points += $row[researchmod];
        setPoints($points, $x, $row[ownerid]);
    }
}
Example #15
0
		$query->execute( );
		echo( "You have placed an absentee bid of " . $CURRENCY_SYMBOL . $bidAmt . ".");	
		exit;
	}
	*/
// Series of sanity checks: did the user enter a positive integer as his/her bid?
if (!is_numeric($bidAmt) || $bidAmt < 1) {
    echo $bidAmt . " isn't an acceptable bid.  Please bid only positive integers.";
    // Is the auction still active?  And is the user bidding an acceptable minimum?  (Current high bid + 5 FCG)
} elseif (isAuctionStillActiveFixedEnd($auctionId) && $bidAmt < getHighBidAmountForAuction($auctionId) + 5) {
    echo "Please bid at least " . $CURRENCY_SYMBOL . (getHighBidAmountForAuction($auctionId) + 5) . ".";
    echo "<p/><button id=\"dismiss\" class=\"ui-widget ui-button ui-state-default ui-corner-all ui-button-text-only\" style=\"width:100px;height:40px;\" onClick=\"window.parent.Shadowbox.close( );\">Okay</button>";
    // Is the attempted bid less than the minimum bid for the auction?
} elseif (isAuctionStillActiveFixedEnd($auctionId) && $bidAmt < getMinimumBidForAuction($auctionId)) {
    echo "Sorry, but the minimum bid for this auction is " . getMinimumBidForAuction($auctionId) . ".";
    echo "<p/><button id=\"dismiss\" class=\"ui-widget ui-button ui-state-default ui-corner-all ui-button-text-only\" style=\"width:100px;height:40px;\" onClick=\"window.parent.Shadowbox.close( );\">Okay</button>";
    // Does the user have enough money to place this bid?  If so, place it.
} elseif (isAuctionStillActiveFixedEnd($auctionId) && $bidAmt <= getPoints($uuid)) {
    placeBidFixedEnd($auctionId, $uuid, $bidAmt, $gameinstance);
    echo "You have bid " . $CURRENCY_SYMBOL . $bidAmt . " on this work.";
    echo "<p/><button id=\"dismiss\" class=\"ui-widget ui-button ui-state-default ui-corner-all ui-button-text-only\" style=\"width:100px;height:40px;\" onClick=\"window.parent.Shadowbox.close( );\">Okay</button>";
    // Logically, this should come first so we don't call the function 3 times in a row for other checks... FIXME
} elseif (!isAuctionStillActiveFixedEnd($auctionId)) {
    echo "The auction has already ended!";
    echo "<p/><button id=\"dismiss\" class=\"ui-widget ui-button ui-state-default ui-corner-all ui-button-text-only\" style=\"width:100px;height:40px;\" onClick=\"window.parent.Shadowbox.close( );\">Okay</button>";
} else {
    // Almost certainly due to a lack of points -- "place bid" button disappears when the auction ends.
    // Still, we should be a little more nuanced with the error state here.
    echo "You don't have " . $CURRENCY_SYMBOL . $bidAmt . "!";
    echo "<p/><button id=\"dismiss\" class=\"ui-widget ui-button ui-state-default ui-corner-all ui-button-text-only\" style=\"width:100px;height:40px;\" onClick=\"window.parent.Shadowbox.close( );\">Okay</button>";
}
Example #16
0
        //check you have requirements
        $query = "SELECT id FROM tech{$sid} WHERE techid={$sub} AND ownerid={$id}";
        $result = mysql_query($query);
        if ($row = mysql_fetch_array($result) || $pass) {
            //This checks points
            if (addResearch($rid, $sid, $id)) {
                echo 'You have researched ' . getResearchStat(name, $rid) . '.<br><br>';
            } else {
                echo 'You do not have enough rp to research that.<br><br>';
            }
        } else {
            echo 'You need to research ' . getResearchStat(name, $sub) . ' before you can research this.<br><br>';
        }
    }
}
echo 'Research Points: ' . getPoints($sid, $id) . ' [' . rph($sid, $id) . '/hr]<br><br>';
//Start Javascript
echo '<Script language="Javascript">';
//Define Javascript Array
//Id, name, x, y, owner
//define the system class
echo 'var systems = new Array();';
echo '
function system(id,name,x,level,desc,tree,points,tech,has){
  this.x = x;
  this.name=name;
  this.level = level;
  this.id = id;
  this.desc = desc;
  this.tree = tree;
  this.points = points;
Example #17
0
	$(document).ready( function( ) {
		// Set upt he dimsiss button
		$("#goHome").button( );
		$("#goHome").click( function( ) {
			Shadowbox.close();
		} );
	} );
	var Shadowbox = window.parent.Shadowbox;
</script>
<title>Confirm Trade Request</title>
</head>
<body style="background-color:#fff">
<?php 
// First, make sure we can actually offer this much money as part of a trade...
if ($fcgs > 0 && $fcgs > getPoints($uuid) && $direction === 'offer') {
    echo "<h1>Error</h1>You can't offer more " . $CURRENCY_SYMBOL . " than you currently have (" . $CURRENCY_SYMBOL . getPoints($uuid) . ").";
    echo "<p/><button id=\"goHome\">Okay</button>\n";
    exit;
}
// If that checks out, then record the proposed trade in the database.
$query = $dbh->prepare("INSERT INTO trades( origin, destination, gameinstance, work_from_origin, work_from_destination, accepted, fcn_from_origin, fcn_from_destination ) VALUES( ?, ?, ?, ?, ?, ?, ?, ? )");
$query->bindValue(1, $uuid);
$query->bindValue(2, $_SESSION['last_trade_with']);
// Why is this a session var again?
$query->bindValue(3, $gameinstance);
$query->bindValue(4, $offers);
$query->bindValue(5, $requests);
$query->bindValue(6, '-1');
if ($direction === 'request') {
    $query->bindValue(7, '0');
    $query->bindValue(8, $fcgs);