Пример #1
0
function draw_points_table($userinfo)
{
    $points = get_points($userinfo['user_id']);
    echo '<table class="table table-condensed">';
    echo '<tr>';
    echo '<th>Value</th>';
    echo '<th>Note</th>';
    echo '<th>Team Leader</th>';
    echo '<th>Date</th>';
    echo '<th><span class="glyphicon glyphicon-remove-circle btn btn-default btn-progress"></span></th>';
    echo '</tr>';
    while ($point = $points->fetch_array()) {
        //Open with a form, to submit for the removal of this record.
        echo '<form method="post" action="">';
        echo '<input type="hidden" name="removepoints-submit" value="true">';
        echo '<input type="hidden" name="point_id" value="' . $point['point_id'] . '">';
        echo '<tr>';
        echo '<td>' . $point['value'] . '</td>';
        echo '<td>' . ucfirst($point['note']) . '</td>';
        echo '<td>' . $point['tl_fname'] . ', ' . $point['tl_lname'] . '</td>';
        //convert the timestamp to a YYYY-MM-DD date
        echo '<td>' . date('Y-m-d', strtotime($point['timestamp'])) . '</td>';
        echo '<td><button class="btn btn-default btn-progress" onclick="submit()"><span class="glyphicon glyphicon-remove-circle"></span></button></td>';
        //Here's the submit button to remove this record
        echo '</tr>';
        echo '</form>';
        //Close the form we opened above.
    }
    echo '</table>';
}
Пример #2
0
 // задания по модерации новых майнеров
 // ***********************************
 $tpl['data']['type'] = 'votes_miner';
 $tpl['data']['type_id'] = ParseData::findType($tpl['data']['type']);
 $tpl['data']['time'] = time();
 $tpl['data']['user_id'] = $user_id;
 $tpl['user_info'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `" . DB_PREFIX . "miners_data`.`user_id`,\n\t\t\t\t\t\t\t `id` as `vote_id`,\n\t\t\t\t\t\t\t `face_coords`,\n\t\t\t\t\t\t\t `profile_coords`,\n\t\t\t\t\t\t\t `video_type`,\n\t\t\t\t\t\t\t `video_url_id`,\n\t\t\t\t\t\t\t `photo_block_id`,\n\t\t\t\t\t\t\t `photo_max_miner_id`,\n\t\t\t\t\t\t\t `miners_keepers`,\n\t\t\t\t\t\t\t `host`\n\t\t\t\tFROM `" . DB_PREFIX . "votes_miners`\n\t\t\t\tLEFT JOIN `" . DB_PREFIX . "miners_data`\n\t\t\t\t\t\t ON `" . DB_PREFIX . "miners_data`.`user_id` = `" . DB_PREFIX . "votes_miners`.`user_id`\n\t\t\t\tWHERE `votes_end` = 0 AND\n\t\t\t\t\t\t\t `type` = 'user_voting'\n\t\t\t\tORDER BY rand()\n\t\t\t\tLIMIT 1\n\t\t\t\t", 'fetch_array');
 // проверим, не голосовали ли мы за это в последние 30 минут
 $repeated = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `id`\n\t\t\t\tFROM `" . DB_PREFIX . MY_PREFIX . "my_tasks`\n\t\t\t\tWHERE `type` = 'miner' AND\n\t\t\t\t\t\t\t `id` = {$tpl['user_info']['vote_id']} AND\n\t\t\t\t\t\t\t `time` > " . (time() - TASK_TIME) . "\n\t\t\t\t", 'fetch_one');
 //print '<!--'.$db->printsql()."\n".TASK_TIME."-->";
 if ($repeated) {
     //print "<!--repeated-->";
     require_once ABSPATH . 'templates/tasks.tpl';
     break;
 }
 $tpl['user_info']['example_points'] = get_points($db);
 // получим ID майнеров, у которых лежат фото нужного нам юзера
 $miners_ids = ParseData::get_miners_keepers($tpl['user_info']['photo_block_id'], $tpl['user_info']['photo_max_miner_id'], $tpl['user_info']['miners_keepers'], true);
 if ($miners_ids) {
     $hosts = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\t\tSELECT `host`\n\t\t\t\t\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\t\t\t\t\tWHERE `miner_id` IN  (" . implode(',', $miners_ids) . ")\n\t\t\t\t\t\t", 'array');
     for ($i = 0; $i < sizeof($hosts); $i++) {
         $tpl['user_info']['photo_hosts'][] = "{$hosts[$i]}";
     }
 }
 // отрезки майнера, которого проверяем
 $tpl['relations'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT *\n\t\t\t\tFROM `" . DB_PREFIX . "faces`\n\t\t\t\tWHERE `user_id` = {$tpl['user_info']['user_id']}\n\t\t\t\tLIMIT 1\n\t\t\t\t", 'fetch_array');
 // получим допустимые расхождения между точками и совместимость версий
 $data = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `tolerances`,\n\t\t\t\t\t\t\t `compatibility`\n\t\t\t\tFROM `" . DB_PREFIX . "spots_compatibility`\n\t\t\t\t", 'fetch_array');
 $tolerances = json_decode($data['tolerances'], true);
 $compatibility = json_decode($data['compatibility'], true);
 // array(1,2,3)
Пример #3
0
$article_ids = isset($_GET['articles']) ? intvals($_GET['articles']) : null;
$count = is_numeric($_GET['count']) ? intval($_GET['count']) : null;
$offset = is_numeric($_GET['offset']) ? intval($_GET['offset']) : 0;
$js_callback = $response_mime_type == 'text/javascript' && $_GET['callback'] ? sanitize_js_callback($_GET['callback']) : null;
if ($woe_id && $article_id) {
    $url = new Net_URL('http://' . get_domain_name() . get_base_dir() . '/point.php');
    $url->addQueryString('article', $article_id);
    $url->addQueryString('woe', $woe_id);
    $url->addQueryString('format', $response_format);
    header('Location: ' . $url->getURL());
    exit;
} elseif (($article_ids || $woe_ids) && ($article_id || $woe_id)) {
    header('Content-Type: text/plain');
    die_with_code(400, "It's not possible to specify both singular and plural article/WOE ID's.\n");
} else {
    $points = get_points($C, compact('article_id', 'woe_id', 'article_ids', 'woe_ids', 'count', 'offset'));
    $total = get_points_total($C, compact('article_id', 'woe_id', 'article_ids', 'woe_ids'));
    $count = count($points);
}
$C->close();
header("Content-Type: {$response_mime_type}; charset=UTF-8");
switch ($response_format) {
    case 'php':
        print serialize(compact('count', 'offset', 'total', 'points'));
        break;
    case 'json':
        echo json_encode(compact('count', 'offset', 'total', 'points'));
        break;
    case 'js':
        if (is_null($js_callback)) {
            die_with_code(400, "You must provide a javascript callback for format=js.");
Пример #4
0
<?php

if (!defined('DC')) {
    die("!defined('DC')");
}
$photos['user_profile'] = ABSPATH . '/public/' . $_SESSION['user_id'] . '_user_profile.jpg';
$photos['user_face'] = ABSPATH . '/public/' . $_SESSION['user_id'] . '_user_face.jpg';
if (file_exists($photos['user_profile'])) {
    $tpl['user_profile'] = 'public/' . $_SESSION['user_id'] . '_user_profile.jpg';
    $tpl['user_profile_size'] = getimagesize($photos['user_profile']);
}
if (file_exists($photos['user_face'])) {
    $tpl['user_face'] = 'public/' . $_SESSION['user_id'] . '_user_face.jpg';
    $tpl['user_face_size'] = getimagesize($photos['user_face']);
}
// текущий набор точек для шаблонов
$tpl['example_points'] = get_points($db);
// точки, которые юзер уже отмечал
$res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, '
		SELECT `face_coords`,
					 `profile_coords`
		FROM `' . DB_PREFIX . MY_PREFIX . 'my_table`
		');
$row = $db->fetchArray($res);
if ($row) {
    $tpl['face_coords'] = $row['face_coords'];
    $tpl['profile_coords'] = $row['profile_coords'];
}
require_once ABSPATH . 'templates/upgrade_3.tpl';
Пример #5
0
$FLIR = array();
$FStyle = preg_match('#^\\{("[\\w]+":"[^"]*",?)*\\}$#i', $_GET['fstyle']) ? json_decode($_GET['fstyle'], true) : array();
$FLIR['mode'] = isset($FStyle['mode']) ? $FStyle['mode'] : '';
$FLIR['output'] = isset($FStyle['output']) ? $FStyle['output'] == 'jpeg' ? 'jpg' : $FStyle['output'] : 'auto';
$FLIR['bkg_transparent'] = is_transparent($FStyle['cBackground']);
if ($FLIR['output'] == 'auto') {
    $FLIR['output'] = $FLIR['bkg_transparent'] ? 'png' : 'gif';
}
// format not supported, fall back to png
if ($FLIR['output'] == 'gif' && !function_exists('imagegif') || $FLIR['output'] == 'jpg' && !function_exists('imagejpeg')) {
    $FLIR['output'] = 'png';
}
$FLIR['dpi'] = preg_match('#^[0-9]+$#', $FStyle['dpi']) ? $FStyle['dpi'] : 96;
$FLIR['size'] = is_number($FStyle['cSize'], true) ? $FStyle['cSize'] : UNKNOWN_FONT_SIZE;
// pixels
$FLIR['size_pts'] = ENABLE_FONTSIZE_BUG ? $FLIR['size'] : get_points($FLIR['dpi'], $FLIR['size']);
$FLIR['maxheight'] = is_number($_GET['h']) ? $_GET['h'] : UNKNOWN_FONT_SIZE;
// pixels
$FLIR['maxwidth'] = is_number($_GET['w']) ? $_GET['w'] : 800;
// pixels
$font_file = '';
$FStyle['cFont'] = strtolower($FStyle['cFont']);
$FONT_PARENT = false;
if (isset($fonts[$FStyle['cFont']])) {
    $font_file = $fonts[$FStyle['cFont']];
    if (is_array($font_file)) {
        $FONT_PARENT = reset($font_file);
        $font_file = match_font_style($font_file);
        $FONT_PARENT = $fonts_dir . (isset($FONT_PARENT['file']) ? $FONT_PARENT['file'] : $font_file);
    }
} elseif (FONT_DISCOVERY) {
Пример #6
0
<tr>
<th colspan="3">&nbsp</th>
<?php 
// FOR DEBUG
if (array_key_exists('debug', $_GET)) {
    echo '<th class="centre">P</th><th class="centre">M</th><th class="centre">D</th>';
}
echo '<th class="left" colspan="' . ($max['P'] + 1) . '">' . get_string('pass', 'block_progress') . '</th>';
echo '<th class="left" colspan="' . ($max['M'] + 1) . '">' . get_string('merit', 'block_progress') . '</th>';
echo '<th class="left" colspan="' . ($max['D'] + 6) . '">' . get_string('distinction', 'block_progress') . '</th>';
?>
</tr>
<?php 
$points_total = 0;
foreach ($all_courses as $course) {
    $points = get_points($course);
    $points_total += $points;
    if ($points == 0) {
        $points = '&nbsp;';
    }
    //echo '<pre>';
    //print_r($course);
    //echo '</pre>';
    $unit_num = '';
    if (array_key_exists('prefix', $_GET)) {
        $unit_num = '<strong>' . str_replace(strtoupper($_GET['prefix']), '', $course['course']->shortname) . '</strong> ';
    }
    echo '<tr>';
    echo '<td class="right">' . $unit_num . $course['course']->fullname . '</td>';
    $url = 'summary_student_course.php?course=' . $course['course']->id . '&user='******'user'] . '&student=' . $user->id;
    if (array_key_exists('prefix', $_GET)) {
Пример #7
0
function overlap($query)
{
    $html = '';
    $html .= '<!DOCTYPE html>
	<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>Overlap</title>
	</head>
	<body>';
    $html .= '<p><a href=".">Back</a>';
    $html .= '<p>Results for <b>' . $query . '</b></p>';
    // GBIF
    $gbif_pts = array();
    $gbif_csquare = array();
    $data = get_gbif_data($query);
    //print_r($data);exit();
    $gbif_pts = get_points($data);
    /*
    echo '<pre>';
    print_r($gbif_pts);
    echo '</pre>';
    //exit();
    */
    // map
    $html .= '<h3>GBIF</h3>';
    $html .= '<object id="gbif" type="image/svg+xml" width="360" height="180" data="map.php?coordinates=' . json_encode($gbif_pts) . '"></object>';
    $html .= '<p><a href="http://www.gbif.org/species/search?q=' . $query . '" target="_new">View in GBIF</a></p>';
    //echo $html;
    foreach ($gbif_pts as $pt) {
        $csq = lat_lon_2_csquare($pt[0], $pt[1]);
        $gbif_csquare[] = $csq;
    }
    $gbif_csquare = array_unique($gbif_csquare);
    /*
    $url = 'http://data.gbif.org/ws/rest/taxon/list?scientificname=' . urlencode($query) . '&dataresourcekey=1';
    
    $xml = get($url);
    
    $js = '';
    
    if ($xml != '')
    {
    	// Convert GBIF XML to Javascript
    	$xp = new XsltProcessor();
    	$xsl = new DomDocument;
    	$xsl->load('../services/gbif-taxa2json.xsl');
    	$xp->importStylesheet($xsl);
    	
    	$dom = new DOMDocument;
    	$dom->loadXML($xml);
    	$xpath = new DOMXPath($dom);
    
    	$js = $xp->transformToXML($dom);
    }
    
    $obj = json_decode($js);
    
    if (count($obj->taxonConcepts) >= 1)
    {
    	$id = $obj->taxonConcepts[0]->gbifKey;
    	
    	$url = 'http://data.gbif.org/ws/rest/density/list?taxonconceptkey=' . $id;
    
    	$xml = get($url);
    
    	$js = '';
    
    	if ($xml != '')
    	{
    		// Convert GBIF XML to Javascript for Google Maps
    		$xp = new XsltProcessor();
    		$xsl = new DomDocument;
    		$xsl->load('../services/gbif2json.xsl');
    		$xp->importStylesheet($xsl);
    		
    		$dom = new DOMDocument;
    		$dom->loadXML($xml);
    		$xpath = new DOMXPath($dom);
    	
    		$js = $xp->transformToXML($dom);
    		
    		//print_r($js);
    		
    		$map = json_decode($js);
    		
    		//print_r($map);
    		
    		foreach ($map->cells as $cell)
    		{
    			$pt = array();
    			$pt[0] = $cell->minLatitude;
    			$pt[1] = $cell->minLongitude;
    			$gbif_pts[] =  $pt;
    			
    		}
    		
    		//print_r($gbif_pts);
    		
    		// map
    		$html .= '<h3>GBIF</h3>';
    		$html .= '<object id="gbif" type="image/svg+xml" width="360" height="180" data="map.php?coordinates=' . json_encode($gbif_pts) . '"></object>';
    		$html .= '<p><a href="http://data.gbif.org/species/' . $id . '" target="_new">View in GBIF</a></p>';
    		//echo $html;
    		
    		
    		foreach ($gbif_pts as $pt)
    		{
    			$csq = lat_lon_2_csquare($pt[0], $pt[1]);
    			
    			$gbif_csquare[] = $csq;
    		}
    
    		$gbif_csquare = array_unique($gbif_csquare);
    		//print_r($gbif_csquare);
    	}
    	
    }
    
    if (count($obj->taxonConcepts) > 1)
    {
    	$html .= '<p>More than one taxon with this name</p>';
    }
    */
    // Flickr
    $flickr_pts = array();
    $flickr_csquare = array();
    $tag = str_replace(' ', '', $query);
    $tag = strtolower($tag);
    $url = 'http://api.flickr.com/services/feeds/geo/?tags=' . $tag . '&lang=en-us&format=rss_200';
    $xml = get($url);
    //echo $xml;
    // Extract lat and long
    $dom = new DOMDocument();
    $dom->loadXML($xml);
    $xpath = new DOMXPath($dom);
    $xpath->registerNamespace('geo', 'http://www.w3.org/2003/01/geo/wgs84_pos#');
    $xpath->registerNamespace('georss', 'http://www.georss.org/georss');
    $nodeCollection = $xpath->query("//item/georss:point");
    foreach ($nodeCollection as $node) {
        $pt = $node->firstChild->nodeValue;
        $pts = explode(' ', $pt);
        $pts[0] = (double) $pts[0];
        $pts[1] = (double) $pts[1];
        $flickr_pts[] = $pts;
    }
    // make a map
    //print_r($flickr_pts);
    $html .= '<h3>Flicker</h3>';
    $html .= '<object id="map" type="image/svg+xml" width="360" height="180" data="map.php?coordinates=' . json_encode($flickr_pts) . '"></object>';
    $html .= '<p><a href="http://www.flickr.com/photos/tags/' . $tag . '/" target="_new">View in Flickr</a></p>';
    //echo $html;
    // compute overlap with GBIF
    foreach ($flickr_pts as $pt) {
        $csq = lat_lon_2_csquare($pt[0], $pt[1]);
        $flickr_csquare[] = $csq;
    }
    $flickr_csquare = array_unique($flickr_csquare);
    //print_r($flickr_csquare);
    // compute difference
    $html .= '<h3>Summary</h3>';
    $html .= '<p>GBIF has ' . count($gbif_pts) . ' records.</p>';
    $html .= '<p>Flickr has ' . count($flickr_pts) . ' geotagged photos.</p>';
    $html .= '<p>GBIF has records from ' . count($gbif_csquare) . ' csquares.</p>';
    $html .= '<p>Flickr has records from ' . count($flickr_csquare) . ' csquares</p>';
    $html .= '<p>Overlap between GBIF and Flickr = ' . count(array_intersect($gbif_csquare, $flickr_csquare)) . '</p>';
    $html .= '</body>
	</html>';
    echo $html;
}
function content_unlock_satisfies_block_conditions($unlock_system, $courseid, $userid)
{
    global $DB;
    $unlock_system_conditions = $DB->get_records('content_unlock_condition', array('unlocksystemid' => $unlock_system->id));
    $satisfies_conditions = $unlock_system->connective == AND_CONNECTIVE ? true : false;
    if (empty($unlock_system_conditions)) {
        $satisfies_conditions = true;
    } else {
        foreach ($unlock_system_conditions as $unlock_system_condition) {
            if ($unlock_system_condition->type == 0) {
                $points = 0;
                if (isset($unlock_system_condition->prblockid)) {
                    if ($unlock_system_condition->prgrupal) {
                        $user_groups = groups_get_all_groups($courseid, $userid, $unlock_system->groupingid);
                        foreach ($user_groups as $user_group) {
                            $group_points = get_block_group_points($unlock_system_condition->prblockid, $user_group->id);
                            if ($group_points > $points) {
                                $points = $group_points;
                            }
                        }
                    } else {
                        $points = get_points($unlock_system_condition->prblockid, $userid);
                    }
                } else {
                    if ($unlock_system_condition->prgrupal) {
                        $user_groups = groups_get_all_groups($courseid, $userid, $unlock_system->groupingid);
                        foreach ($user_groups as $user_group) {
                            $group_points = get_points_system_group_points($unlock_system_condition->prpointsystemid, $user_group->id);
                            if ($group_points > $points) {
                                $points = $group_points;
                            }
                        }
                    } else {
                        $points = get_points_system_points($unlock_system_condition->prpointsystemid, $userid);
                    }
                }
                if ($points >= $unlock_system_condition->prpoints) {
                    if ($unlock_system->connective == OR_CONNECTIVE) {
                        $satisfies_conditions = true;
                        break;
                    }
                } else {
                    if ($unlock_system->connective == AND_CONNECTIVE) {
                        $satisfies_conditions = false;
                        break;
                    }
                }
            } else {
                if ($unlock_system_condition->type == 1) {
                    $sql = "SELECT count(u.id) as times\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{content_unlock_log} u\n\t\t\t\t\tINNER JOIN {logstore_standard_log} l ON u.logid = l.id\n\t\t\t\t\tWHERE l.userid = :userid\n\t\t\t\t\t\tAND  u.unlocksystemid = :unlocksystemid\n\t\t\t\t\tGROUP BY l.userid";
                    $params['unlocksystemid'] = $unlock_system_condition->urunlocksystemid;
                    $params['userid'] = $userid;
                    $times = $DB->get_field_sql($sql, $params);
                    if (!isset($times)) {
                        $times = 0;
                    }
                    if ($unlock_system_condition->urmust && $times > 0 || !$unlock_system_condition->urmust && $times == 0) {
                        if ($unlock_system->connective == OR_CONNECTIVE) {
                            $satisfies_conditions = true;
                            break;
                        }
                    } else {
                        if ($unlock_system->connective == AND_CONNECTIVE) {
                            $satisfies_conditions = false;
                            break;
                        }
                    }
                } else {
                    $unlocked_achievement = $DB->record_exists('achievements_log', array('userid' => $userid, 'achievementid' => $unlock_system_condition->arachievementid));
                    if ($unlocked_achievement) {
                        if ($unlock_system->connective == OR_CONNECTIVE) {
                            $satisfies_conditions = true;
                            break;
                        }
                    } else {
                        if ($unlock_system->connective == AND_CONNECTIVE) {
                            $satisfies_conditions = false;
                            break;
                        }
                    }
                }
            }
        }
    }
    return $satisfies_conditions;
}
Пример #9
0
function bounding_box($text, $font = NULL, $size = NULL)
{
    global $FLIR;
    if (is_null($font)) {
        $font = $FLIR['postscript'] ? $FLIR['ps']['font'] : $FLIR['font'];
    }
    if (is_null($size)) {
        $size = $FLIR['postscript'] ? $FLIR['size'] : $FLIR['size_pts'];
    } elseif ($FLIR['postscript']) {
        $size = get_points($FLIR['dpi'], $size);
    }
    // convert to points
    if ($FLIR['postscript']) {
        return convertPSBoundingBox(imagepsbbox($text, $font, $size, $FLIR['ps']['space'], $FLIR['ps']['kerning'], 0));
    } else {
        return convertBoundingBox(imagettfbbox($size, 0, $font, $text));
    }
}
Пример #10
0
function draw_map($name)
{
    $data = get_gbif_data($name);
    //print_r($data);exit();
    $points = get_points($data);
    //print_r($points);
    if (count($points) == 0) {
        echo "No data for <b>{$name}</b><br /><a href=\".\">Go back</a>";
        exit;
    }
    $geojson = make_polygon($points);
    $min_long = 180;
    $max_long = -180;
    $min_lat = 90;
    $max_lat = -90;
    foreach ($points as $pt) {
        $min_long = min($min_long, $pt[0]);
        $max_long = max($max_long, $pt[0]);
        $min_lat = min($min_lat, $pt[1]);
        $max_lat = max($max_lat, $pt[1]);
    }
    $polygon = array();
    foreach ($geojson->features as $feature) {
        if ($feature->properties->name == 'Polygon') {
            $polygon = $feature->geometry->coordinates[0];
        }
    }
    $num_cells = 0;
    $num_cells_occupied = 0;
    $size = 1;
    for ($long = $min_long; $long < $max_long; $long += $size) {
        for ($lat = $min_lat; $lat < $max_lat; $lat += $size) {
            $feature = new stdclass();
            $feature->type = 'Feature';
            $feature->properties = new stdclass();
            $feature->properties->name = "Polygon";
            $feature->geometry = new stdclass();
            $feature->geometry->type = 'Polygon';
            $feature->geometry->coordinates = array();
            $box = array();
            $x1 = min($long, $long + $size);
            $x2 = max($long, $long + $size);
            $y1 = min($lat, $lat + $size);
            $y2 = max($lat, $lat + $size);
            $box[] = array($x1, $y2);
            $box[] = array($x2, $y2);
            $box[] = array($x2, $y1);
            $box[] = array($x1, $y1);
            $box[] = array($x1, $y2);
            // note edge case of polygon with spike where none of corners of square are in polygon
            // (e.g, Mehelya nyassae)
            $in_polygon = 0;
            $i = 0;
            while ($i < 4) {
                if (pointInPolyonQ($box[$i], $polygon)) {
                    $in_polygon++;
                }
                $i++;
            }
            if ($in_polygon > 0) {
                $num_cells++;
            }
            $in_cell = 0;
            foreach ($points as $pt) {
                if (pointInPolyonQ($pt, $box)) {
                    $in_cell++;
                }
            }
            if ($in_cell == 0) {
                $in_polygon = 0;
            } else {
                $num_cells_occupied++;
            }
            if ($in_polygon > 0) {
                $feature->geometry->coordinates[] = $box;
                $geojson->features[] = $feature;
            }
        }
    }
    $template = <<<EOT
\t<!DOCTYPE html>
\t<html>
\t  <head>
\t\t<title><NAME></title>
\t\t<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
\t\t<meta charset="utf-8">
\t\t<style>
\t\tbody { font-family: sans-serif; }
\t\t #map-canvas {
\t\t\theight: 500px;
\t\t\tmargin: 0px;
\t\t\tpadding: 20px
\t\t  }
\t\t</style>
\t\t<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
\t\t<script>
\tvar map;
\tfunction initialize() {
\t  // Create a simple map.
\t  map = new google.maps.Map(document.getElementById('map-canvas'), {
\t\tzoom: 4,
\t\tcenter: {lat: <LATITUDE>, lng: <LONGITUDE>}
\t  });
\t
\t  // Load a GeoJSON 
\t  
\t  var j = <GEOJSON>;
\t  
\t  map.data.addGeoJson(j);
\t}
\t
\tgoogle.maps.event.addDomListener(window, 'load', initialize);
\t
\t\t</script>
\t  </head>
\t  <body>
\t\t<h1><NAME></h1>
\t\t<div id="map-canvas"></div>
\t\t<p>Number of cells: <b><NUMCELLS></b>, number occupied: <b><NUMCELLSOCCUPIED></b></p>
\t  </body>
\t</html>
EOT;
    $template = str_replace('<NAME>', $name, $template);
    $template = str_replace('<GEOJSON>', json_encode($geojson), $template);
    $template = str_replace('<LATITUDE>', $min_lat + ($max_lat - $min_lat) / 2, $template);
    $template = str_replace('<LONGITUDE>', $min_long + ($max_long - $min_long) / 2, $template);
    $template = str_replace('<NUMCELLS>', $num_cells, $template);
    $template = str_replace('<NUMCELLSOCCUPIED>', $num_cells_occupied, $template);
    echo $template;
}
Пример #11
0
?>
, <?php 
get_points($conn, $uid, TRUE);
?>
, false, true)'>Average Ratings!</button><br />
			<p style="padding: 0 5px;">Click on 'Heatmap!' button to show a heatmap of all of the available venues!
			This view is a cool way of showing where the venues are gathered on the map!</p>
			<button id="heat-btn" style="padding: 5px; margin: 0px 10px 5px; float: right;" type="button" class="btn btn-default" onclick='getPoints(<?php 
if ($uid != 'GUEST' && $uid != null) {
    echo $uid;
} else {
    echo 0;
}
?>
, <?php 
get_points($conn, $uid, TRUE);
?>
, true, false)'>Heatmap!</button>
		</aside>
		
		<!-- Content >
		<section id="content" >
		</section-->
			<div id="content" class="map-canvas container"></div>
	
	
	<!-- Javascript Libraries -->
	<!-- Bootstrap -->
	<script src="<?php 
echo "{$root}/";
?>
Пример #12
0
$FLIR['output'] = isset($FStyle['output']) ? $FStyle['output'] : 'png';
$FLIR['bkg_transparent'] = is_transparent($CSS['background-color']);
if ($FLIR['output'] == 'auto') {
    $FLIR['output'] = $FLIR['bkg_transparent'] ? 'png' : 'gif';
}
// format not supported, fall back to png
if ($FLIR['output'] == 'gif' && !function_exists('imagegif')) {
    $FLIR['output'] = 'png';
}
$FLIR['dpi'] = preg_match('#^\\d+$#', $_GET['d']) ? $_GET['d'] : 96;
if ($FStyle['hq'] == 'true') {
    $FLIR['dpi'] /= 2;
}
$FLIR['size'] = is_number($CSS['font-size'], true) ? $CSS['font-size'] : UNKNOWN_FONT_SIZE;
// pixels
$FLIR['size_pts'] = get_points($FLIR['dpi'], $FLIR['size']);
$FLIR['maxheight'] = is_number($_GET['h']) ? $_GET['h'] : UNKNOWN_FONT_SIZE;
// pixels
$FLIR['maxwidth'] = is_number($_GET['w']) ? $_GET['w'] : 800;
// pixels
$FLIR['color'] = convert_color($CSS['color']);
if ($FLIR['bkg_transparent']) {
    $FLIR['bkgcolor'] = array('red' => abs($FLIR['color']['red'] - 100), 'green' => abs($FLIR['color']['green'] - 100), 'blue' => abs($FLIR['color']['blue'] - 100));
} else {
    $FLIR['bkgcolor'] = convert_color($CSS['background-color'], false, 'FFFFFF');
}
$FLIR['opacity'] = is_number($CSS['opacity'], true) ? $CSS['opacity'] * 100 : 100;
if ($FLIR['opacity'] > 100 || $FLIR['opacity'] < 0) {
    $FLIR['opacity'] = 100;
}
$FLIR['text_encoded'] = $_GET['t'] != '' ? prepare_text($_GET['t']) : 'null';