static function getEventsByTarget($deviceDS)
 {
     $where = array('e_code LIKE ?', 'e_code LIKE ?', 'e_code LIKE ?');
     $searchPatterns = array('%' . $deviceDS['d_id'] . '%', '%' . @first($deviceDS['d_alias'], 'NOMATCH') . '%');
     return o(db)->get('SELECT * FROM #events WHERE
     ' . implode(' OR ', $where), $searchPatterns);
 }
 public function render()
 {
     if (!$this->value_is_valid) {
         $this->attribute("ERROR");
     }
     $output = "<div class='form-element-wrapper'>";
     if ($this->label && $this->attributes['id']) {
         $output .= "<span id='" . o($this->attributes['id']) . "'>" . o($this->label) . ": </span>";
     }
     $output .= "<span " . $this->getAttributeString() . ">";
     foreach ($this->options as $value => $option) {
         $option = o($option);
         $value = o($value);
         $output .= "<span class='form-element-radio-option'>";
         if ($option) {
             $output .= "<label for='" . o($this->attributes['id']) . "-{$value}'>{$option}: </label>";
         }
         if ($value == $this->selected_option) {
             $output .= "<input type='radio' name='" . o($this->name) . "' id='" . o($this->attributes['id']) . "-{$value}' value='{$value}' checked='checked' />";
         } else {
             $output .= "<input type='radio' name='" . o($this->name) . "' id='" . o($this->attributes['id']) . "-{$value}' value='{$value}' />";
         }
         $output .= "</span>";
     }
     $output .= "</span>";
     $output .= "</div>";
     return $output;
 }
function showBody()
{
    #----------------------------------------------------------------------
    global $chosenPersonId;
    // simple validation first...
    if (!preg_match('/\\d{4}\\w{4}\\d{2}/', $chosenPersonId)) {
        showErrorMessage('Invalid WCA id Format <strong>[</strong>' . o($chosenPersonId) . '<strong>]</strong>');
        print '<p><a href="persons.php">Click here to search for people.</a></p>';
        return;
    }
    #--- Get all incarnations of the person.
    $persons = dbQuery("\n    SELECT person.name personName, country.name countryName, day, month, year, gender\n    FROM Persons person, Countries country\n    WHERE person.id = '{$chosenPersonId}' AND country.id = person.countryId\n    ORDER BY person.subId\n  ");
    #--- If there are none, show an error and do no more.
    if (!count($persons)) {
        showErrorMessage('Unknown person id <strong>[</strong>' . o($chosenPersonId) . '<strong>]</strong>');
        $namepart = substr($chosenPersonId, 4, 4);
        print '<p><a href="persons.php?pattern=' . urlEncode($namepart) . '">Click to search for people with `' . o($namepart) . '` in their name.</a></p>';
        return;
    }
    #--- Get and show the current incarnation.
    $currentPerson = array_shift($persons);
    extract($currentPerson);
    echo "<h1>{$personName}</h1>";
    #--- Show previous incarnations if any.
    if (count($persons)) {
        echo "<p class='subtitle'>(previously ";
        foreach ($persons as $person) {
            $previous[] = "{$person['personName']}/{$person['countryName']}";
        }
        echo implode(', ', $previous) . ")</p>";
    }
    #--- Show the picture if any.
    $picture = getCurrentPictureFile($chosenPersonId);
    if ($picture) {
        echo "<center><img class='person' src='{$picture}' /></center>";
    }
    #--- Show the In Memoriam if any.
    $inMemoriamArray = array("2008COUR01" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=2028", "2003LARS01" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=1982", "2012GALA02" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=1044", "2008LIMR01" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=945", "2008KIRC01" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=470");
    if (array_key_exists($chosenPersonId, $inMemoriamArray)) {
        echo "<center><a target='_blank' href='{$inMemoriamArray[$chosenPersonId]}'>In Memoriam</a></center>";
    }
    #--- Show the details.
    tableBegin('results', 4);
    tableCaption(false, 'Details');
    tableHeader(explode('|', 'Country|WCA Id|Gender|Competitions'), array(3 => 'class="f"'));
    $gender_text = genderText($gender);
    $numberOfCompetitions = dbValue("SELECT count(distinct competitionId) FROM Results where personId='{$chosenPersonId}'");
    tableRow(array($countryName, $chosenPersonId, $gender_text, $numberOfCompetitions));
    tableEnd();
    #--- Try the cache for the results
    # tryCache( 'person', $chosenPersonId );
    #--- Now the results.
    require 'includes/person_personal_records_current.php';
    require 'includes/person_world_championship_podiums.php';
    require 'includes/person_world_records_history.php';
    require 'includes/person_continent_records_history.php';
    require 'includes/person_events.php';
}
 function ajax_getstate()
 {
     $r = array();
     foreach (o(db)->get('SELECT * FROM devices
   ORDER BY d_room, d_key') as $d) {
         $r['d' . $d['d_id']] = array('id' => $d['d_id'], 'state' => $d['d_state'], 'd_name' => $d['d_name']);
     }
     print json_encode($r);
 }
Beispiel #5
0
 function getData()
 {
     $this->fields = o(db)->fields($this->props['table']);
     $this->prepareFieldProperties();
     if (sizeof($this->props['cols']) == 0) {
         $this->makeAutoColumns();
     }
     $this->data = o(db)->get('SELECT * FROM ?', array('$' . $this->props['table']));
     return $this;
 }
 public function render()
 {
     $output = parent::render();
     $output .= "<div class='form-element-wrapper'>";
     if ($this->label && $this->attributes['id']) {
         $output .= "<label for='" . o($this->attributes['id']) . "'>" . o($this->label) . ": </label>";
     }
     $output .= "<input" . $this->getAttributeString() . "/>";
     $output .= "</div>";
     return $output;
 }
 static function getGroupsByDevice($deviceDS)
 {
     $matchingGroups = array();
     foreach (o(db)->get('SELECT * FROM #nvstore WHERE nv_key LIKE "group/%" ORDER BY nv_key') as $grpData) {
         $gName = $grpData['nv_key'];
         CutSegment('/', $gName);
         $gList = json_decode($grpData['nv_data']);
         if (is_array($gList) && array_search($deviceDS['d_key'], $gList) !== false) {
             $matchingGroups[] = $gName;
         }
     }
     return $matchingGroups;
 }
Beispiel #8
0
 public function newRow($data = array())
 {
     $object = o(sha1(time() . $this->settings['entity'] . session_id() . Utils::token()));
     $object->thin_litedb = $this;
     $object->id = null;
     if (count($data) && Arrays::isAssoc($data)) {
         foreach ($this->settings['modelFields'] as $field => $infos) {
             $value = ake($field, $data) ? $data[$field] : null;
             $object->{$field} = $value;
         }
     }
     return $object;
 }
    function signin()
    {
        if ($_POST['fid'] == sha1($_SESSION['fid'])) {
            $uds = o(db)->getDSMatch('accounts', array('a_username' => trim($_POST['username']), 'a_password' => sha1($_POST['password'])));
            if ($uds['a_key'] > 0) {
                WriteToFile('log/account.log', date('Y-m-d H:i:s') . ' (i) ' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ' : ' . $_SERVER['REMOTE_ADDR'] . ' sign in with ' . trim($_POST['username']) . '/***' . chr(10));
                $_SESSION['uid'] = $uds['a_key'];
                $_SESSION['ds'] = $uds;
                header('location: ./?');
                die;
            } else {
                WriteToFile('log/account.log', date('Y-m-d H:i:s') . ' (f) ' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ' : ' . $_SERVER['REMOTE_ADDR'] . ' sign in failed with ' . trim($_POST['username']) . '/***' . chr(10));
                ?>
<div style="text-align: center">Error signing in, try again.</div><?php 
            }
        } else {
            WriteToFile('log/account.log', date('Y-m-d H:i:s') . ' (a) ' . $_SERVER['HTTP_X_FORWARDED_FOR'] . ' : ' . gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']) . ' signin page ' . chr(10));
        }
    }
Beispiel #10
0
 function initController($controllerName)
 {
     $controllerName = first($controllerName, cfg('service/defaultcontroller'));
     $this->controllerName = safeName($controllerName);
     $this->controllerFile = 'mvc/' . strtolower($this->controllerName) . '/' . strtolower($this->controllerName) . '.controller.php';
     if (!file_exists($this->controllerFile)) {
         header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
         header('Status: 404 Not Found');
         die('File not found at: ' . $_SERVER['REQUEST_URI'] . '<br/>Controller: ' . $this->controllerName);
     }
     require_once $this->controllerFile;
     $this->controllerClassName = $this->controllerName . 'Controller';
     $this->controller = o(new $this->controllerClassName($this->controllerName), 'controller');
     if (is_callable(array($this->controller, '__init'))) {
         $this->controller->__init();
     }
     $_REQUEST['controller'] = $this->controllerName;
     profile_point('H2Dispatcher.initController(' . $this->controllerName . ')');
     return $this;
 }
 public function render()
 {
     $output = parent::render();
     $output .= "<div class='form-element-wrapper'>";
     if ($this->label && $this->attributes['id']) {
         $output .= "<label for='" . o($this->attributes['id']) . "'>" . o($this->label) . ": </label>";
     }
     $output .= "<select" . $this->getAttributeString() . ">";
     foreach ($this->options as $value => $option) {
         $option = o($option);
         $value = o($value);
         if ($value == $this->selected_option) {
             $output .= "<option selected value='{$value}'>{$option}</option>";
         } else {
             $output .= "<option value='{$value}'>{$option}</option>";
         }
     }
     $output .= "</select>";
     $output .= "</div>";
     return $output;
 }
 function group_delete()
 {
     o(db)->remove('groups', $_REQUEST['id']);
     $this->viewName = 'groups';
 }
function listCompetitions () {
#----------------------------------------------------------------------
  global $chosenEventId, $chosenYears, $chosenRegionId, $chosenPatternHtml;
  global $chosenList, $chosenMap;
  global $chosenCompetitions;

  $chosenCompetitions = getCompetitions( $chosenList );

  tableBegin( 'results', 5 );
  tableCaption( false, spaced(array( eventName($chosenEventId), chosenRegionName(), $chosenYears, $chosenPatternHtml ? "\"$chosenPatternHtml\"" : '' )));

  if( $chosenList ){ 

    tableHeader( explode( '|', 'Year|Date|Name|Country, City|Venue' ),
                 array( 4 => 'class="f"' ));

    foreach( $chosenCompetitions as $competition ){
      extract( $competition );

      if( isset( $previousYear )  &&  $year != $previousYear )
        tableRowEmpty();
      $previousYear = $year;

      $isPast = wcaDate( 'Ymd' ) > (10000*$year + 100*$month + $day);

      tableRow( array(
        $year,
        competitionDate( $competition ),
        $isPast ? competitionLink( $id, $cellName ) : (( $showPreregForm || $showPreregList ) ? competitionLinkClassed( 'rg', $id, $cellName ) : competitionLinkClassed( 'fc', $id, $cellName )),
        "<b>$countryName</b>, $cityName",
        processLinks( $venue )
      ));
    }
  }

  tableEnd();


  if( $chosenMap ) {
    // create map markers
    $markers = array();
    foreach($chosenCompetitions as $comp) {
      $markers[$comp['id']] = array();
      $markers[$comp['id']]['latitude'] = $comp['latitude'];
      $markers[$comp['id']]['longitude'] = $comp['longitude'];
      $markers[$comp['id']]['info'] = "<a href='c.php?i=".$comp['id']."'>" . o($comp['cellName']) . "</a><br />"
        . date("M j, Y", mktime(0,0,0,$comp['month'],$comp['day'],$comp['year']))
        . " - " . o($comp['cityName']);
    }
    displayMap($markers);
  }
}
Beispiel #14
0
/**
 * Logs an error message to the error log. A newline character is appended to the message.
 * The given message is also echoed to the console.
 *
 * @param $message string the message to log.
 */
function log_error(string $message)
{
    global $board;
    o($message);
    file_put_contents($board . '.error', date("c: ") . $message . PHP_EOL, FILE_APPEND);
}
Beispiel #15
0
 function container()
 {
     return o('thinContainer');
 }
    <td style="text-align:right">
      <span class="faint">Direction</span>   
    </td>
    <td width="*">
      <?php 
$dirText = array(0 => 'None', 1 => 'Sender', 2 => 'Receiver');
print $dirText[$dev['DIRECTION']];
?>
</div>
    </td>  
  </tr>
  <?php 
$related = array();
$idnr = $ds['d_id'];
$idroot = CutSegment(':', $idnr);
foreach (o(db)->get('SELECT d_key,d_id,d_alias,d_type FROM devices WHERE d_id LIKE "' . $idroot . '%" ORDER BY d_id') as $dds) {
    $related[] = '<a href="' . actionUrl('params', 'devices', array('key' => $dds['d_key'])) . '" style="' . ($dds['d_key'] == $ds['d_key'] ? 'font-weight:bold;' : '') . '">' . htmlspecialchars(first($dds['d_alias'], $dds['d_type'])) . ' ' . $dds['d_id'] . '</a>';
    //array($ds['d_id'] => $ds['d_id'].' ('.first($ds['d_alias'], $ds['d_id']).')');
}
print '<tr><td valign="top" style="text-align:right"><span class="faint">Compound</span></td><td>' . implode(', ', $related) . '</td></tr></table>';
function showParam($val, $p, $k)
{
    global $actionEvents;
    switch ($p['TYPE']) {
        case 'BOOL':
            if ($p['WRITABLE'] && $p['ID'] != 'AES_ACTIVE') {
                return '<select name="' . $p['ID'] . '"><option' . ($val === true ? ' selected' : '') . '>Yes</option><option' . ($val != true ? ' selected' : '') . '>No</option></select>';
            } else {
                return $val === true ? 'Yes' : 'No';
            }
            break;
Beispiel #17
0
function convertType($value, $type)
{
    if ($value === NULL) {
        return $value;
    }
    $type = s($type)->parse_type();
    if ($type->isArray) {
        if (is_array($value)) {
            $newVal = array();
            foreach ($value as $key => $item) {
                if ($type->key !== NULL) {
                    $newVal[convertType($key, $type->key)] = convertType($item, $type->value);
                } else {
                    $newVal[] = convertType($item, $type->value);
                }
            }
            return $newVal;
        }
    } else {
        switch ($type->value) {
            case "void":
                return NULL;
            case "bool":
            case "boolean":
                return (bool) $value;
            case "FALSE":
            case "false":
                return FALSE;
            case "int":
            case "integer":
                return intval($value);
            case "float":
            case "double":
                return floatval($value);
            case "string":
                return strval($value);
            case "mixed":
                return $value;
            case "resource":
                return is_resource($value) ? $value : NULL;
            case "object":
                return is_object($value) ? $value : o($value)->cast();
            default:
                return o($value)->cast($type->value);
        }
    }
    return NULL;
}
Beispiel #18
0
<p>Welcome to the exciting app template thinger!</p>
<p><?php 
o($test);
?>
</p>
<a href='<?php 
o($web_root);
?>
/example/test'>example</a><br />
<a href='<?php 
o($web_root);
?>
/app/this/is/a/test/omg/win'>test routes</a><br />
<a href='<?php 
o($web_root);
?>
/app/error'>generate a fatal error</a><br />
<a href='<?php 
o($web_root);
?>
/app/error2'>generate a fatal error with handlers</a><br />
Beispiel #19
0
        <meta property="og:type" content="Science"/>
        <meta name="viewport" content="width=device-width">
        <link rel="stylesheet" href="css/bootstrap.min.css">
        <link rel="stylesheet" href="css/expdb.css">
        <link rel="stylesheet" href="css/share.css">
        <link rel="stylesheet" href="css/docs.css">
        <link rel="shortcut icon" href="img/favicon.ico">
        <link href="//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css" rel="stylesheet">
	<link href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700' rel='stylesheet' type='text/css'>
    </head>
    <body>
            <div class="modal-body">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	    <?php 
if (false !== strpos($_SERVER['REQUEST_URI'], '/r/')) {
    o('run');
} elseif (false !== strpos($_SERVER['REQUEST_URI'], '/t/')) {
    o('task');
}
?>
	    </div>            <!-- /modal-body -->
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>            <!-- /modal-footer --> 
        <script src="js/libs/bootstrap.min.js"></script>
        <script src="js/plugins.js"></script>
        <script src="js/application.js"></script>
     </body>
</html>

Beispiel #20
0
            break;
        case 'BLIND':
        case 'SWITCH':
            if (!isset($this->devices['HM:' . $h['ADDRESS']])) {
                // unknown device, make new dataset
                $dds = array('d_bus' => 'HM', 'd_type' => $h['TYPE'] == 'BLIND' ? 'Blinds' : 'Light', 'd_room' => 'unknown', 'd_name' => 'New ' . ($h['TYPE'] == 'BLIND' ? 'Blinds' : 'Switch') . ' ' . date('Y-m-d H:i:s'), 'd_id' => $h['ADDRESS']);
                $dds['d_key'] = o(db)->commit('devices', $dds);
                $this->devices['HM:' . $h['ADDRESS']] = $dds;
            }
            $this->devices['HM:' . $h['ADDRESS']]['info'] = $h;
            break;
        default:
            if (!isset($this->devices['HM:' . $h['ADDRESS']])) {
                // unknown device, make new dataset
                $dds = array('d_bus' => 'HM', 'd_type' => $h['TYPE'], 'd_room' => 'unknown', 'd_name' => 'New ' . $h['TYPE'] . ' ' . date('Y-m-d H:i:s'), 'd_id' => $h['ADDRESS']);
                $dds['d_key'] = o(db)->commit('devices', $dds);
                $this->devices['HM:' . $h['ADDRESS']] = $dds;
            }
            $this->devices['HM:' . $h['ADDRESS']]['info'] = $h;
            break;
    }
}
foreach ($this->devices as $d) {
    $di = array();
    foreach ($d as $k => $v) {
        $di[] = $k . '=' . $v;
    }
    ?>
<div><?php 
    echo implode(', ', $di);
    ?>
         $wcadb_conn->boundCommand("INSERT INTO InboxResults\n                    (competitionId, eventId, roundId, formatId, personId,\n                      pos, value1, value2, value3, value4, value5, best, average)\n                    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", array('sssssiiiiiiii', &$compId, &$eventId, &$roundId, &$formatId, &$personId, &$position, &$value1, &$value2, &$value3, &$value4, &$value5, &$best, &$average));
     } else {
         $round_errors['bad_results'] = "Result data incomplete: some data was not imported.  Please make sure all result metadata was included.";
     }
 }
 // check to make sure groups exist for round
 if (!property_exists($round, 'groups')) {
     $round_errors[] = "Round has no group/scramble data: `" . o($roundId) . "`.";
     $round->groups = array();
 }
 // store scrambles
 foreach ($round->groups as $group) {
     $groupId = property_exists($group, 'group') ? $group->group : false;
     // Store normal scrambles
     if (!property_exists($group, 'scrambles')) {
         $round_errors[] = "Group has no scramble data: `" . o($eventId) . "`:`" . o($roundId) . "`:`" . o($groupId) . "`.";
         $group->scrambles = array();
     }
     $num = 1;
     foreach ($group->scrambles as $scramble) {
         $wcadb_conn->boundCommand("INSERT INTO Scrambles\n                  (competitionId, eventId, roundId, groupId, isExtra, scrambleNum, scramble)\n                  VALUES (?, ?, ?, ?, 0, ?, ?)", array('ssssis', &$compId, &$eventId, &$roundId, &$groupId, &$num, &$scramble));
         $num++;
     }
     // Store extra scrambles
     if (property_exists($group, 'extraScrambles')) {
         // no alert if these don't exist
         $num = 1;
         foreach ($group->extraScrambles as $scramble) {
             $wcadb_conn->boundCommand("INSERT INTO Scrambles\n                    (competitionId, eventId, roundId, groupId, isExtra, scrambleNum, scramble)\n                    VALUES (?, ?, ?, ?, 1, ?, ?)", array('ssssis', &$compId, &$eventId, &$roundId, &$groupId, &$num, &$scramble));
             $num++;
         }
Beispiel #22
0
 public function row(array $data, $recursive = true, $extends = array())
 {
     if (Arrays::isAssoc($data)) {
         $obj = o(sha1(serialize($data)));
         $obj->db_instance = $this;
         if (count($extends)) {
             foreach ($extends as $name => $instance) {
                 $closure = function ($object) use($name, $instance) {
                     $idx = $object->is_thin_object;
                     $objects = Utils::get('thinObjects');
                     return $instance->{$name}($objects[$idx]);
                 };
                 $obj->_closures[$name] = $closure;
             }
         }
         $fields = $this->fields();
         foreach ($fields as $field) {
             $hasFk = $this->hasFk($field);
             if (false === $hasFk) {
                 $obj->{$field} = $data[$field];
             } else {
                 extract($hasFk);
                 $ar = ar($foreignEntity, $foreignTable);
                 $one = contain('toone', Inflector::lower($type));
                 if ($one && $recursive) {
                     $foreignObj = $ar->findBy($foreignKey, $data[$field], $one);
                     $obj->{$relationKey} = $foreignObj;
                 }
             }
         }
         $hasFk = ake('relationships', $this->_settings);
         if (true === $hasFk && $recursive) {
             $rs = $this->_settings['relationships'];
             if (count($rs)) {
                 foreach ($rs as $field => $infos) {
                     extract($infos);
                     $ar = ar($foreignEntity, $foreignTable);
                     if (!Arrays::in($field, $fields)) {
                         $pk = $this->pk();
                         $obj->{$field} = $ar->findBy($foreignKey, $obj->{$pk}, false, false);
                     }
                 }
             }
         }
         return $obj;
     }
     return null;
 }
Beispiel #23
0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <title>Condor</title>
        <?php 
o(include_stylesheet('app'));
?>
        <?php 
o(include_script('app'));
?>
        <style>
        body {
           background-color: blue;
           color: white;
         }
         a {
            color: white;
         }
        </style>
    </head>
    <body>
    <div id='content'>
      <?php 
echo sys()->flash->render();
?>
      <?php 
echo sys()->content;
?>
    </div>
    </body>
Beispiel #24
0
restrict();
top();
?>


<h2>Users</h2>
<?
$users = redis()->hgetall('users');

function sort_users($a, $b) { return $a['name'] > $b['name']; }

usort(array_values($users), 'sort_users');

table();
foreach ($users as $user) {
	$user = json_decode($user, true);
	row(
		format_user($user),
		o($user, 'phone'),
		_href('/users/' . o($user, 'phone') . '/edit', '(edit)'),
		_href('javascript:if(confirm("Are you sure you want to delete ' . o($user, 'name') . '?")) window.location="/users/' . o($user, 'phone') . '/delete"', '(delete)')
	);
}
endtable();

href('/users/create', 'Create New User');

bottom();

?>
Beispiel #25
0
 public static function create($name = null, $array = array())
 {
     $name = null === $name ? sha1(time()) : $name;
     $o = o($name);
     return $o->populate($array);
 }
/**
 * Google maps: search for location coordinates
 */
function displayGeocode($address, $lat, $lng)
{
    global $chosenCompetitionId, $chosenPassword;
    ?>

<div id='map-canvas' style='width: 900px; height: 400px; margin: 10px auto;'></div>
<input id="pac-input" autofocus="autofocus" class="controls" type="text" placeholder="Search Box" value="<?php 
    print o($address);
    ?>
" style='width: 500px; height: 20px; font-size: 16px; padding: 5px; margin: 10px;'>

<script>
function initialize() {

  var map = new google.maps.Map(document.getElementById('map-canvas'), {
    mapTypeId: google.maps.MapTypeId.ROADMAP
  });

  // Create the search box and link it to the UI element.
  var input = document.getElementById('pac-input');
  map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
  var searchBox = new google.maps.places.SearchBox(input);

  var image = {
    url: "/results/images/violet-dotp.png",
    size: new google.maps.Size(20, 34),
    origin: new google.maps.Point(0, 0),
    anchor: new google.maps.Point(10, 34),
    scaledSize: new google.maps.Size(20, 34)
  };

  // create the marker
  <?php 
    if ($lat * 1 && $lng * 1) {
        ?>
    // Coordinates have already been specified
    var latlng = new google.maps.LatLng({
      lat: <?php 
        print number_format($lat, 9, '.', '');
        ?>
,
      lng: <?php 
        print number_format($lng, 9, '.', '');
        ?>
    });
    var marker = new google.maps.Marker({
      map: map,
      icon: image,
      draggable: true,
      position: {lat: <?php 
        print number_format($lat, 9, '.', '');
        ?>
, lng: <?php 
        print number_format($lng, 9, '.', '');
        ?>
}
    });
    var defaultBounds = new google.maps.LatLngBounds(
      new google.maps.LatLng(<?php 
        print number_format($lat, 9, '.', '');
        ?>
-.1, <?php 
        print number_format($lng, 9, '.', '');
        ?>
-.1),
      new google.maps.LatLng(<?php 
        print number_format($lat, 9, '.', '');
        ?>
+.1, <?php 
        print number_format($lng, 9, '.', '');
        ?>
+.1)
    );

  <?php 
    } else {
        ?>

    // Coordinates have not been specified
    var marker = new google.maps.Marker({
      map: map,
      icon: image,
      draggable: true,
      position: {lat: 0, lng: 0}
    });
    var defaultBounds = new google.maps.LatLngBounds(
      new google.maps.LatLng(-60, -90),
      new google.maps.LatLng(60, 90)
    );

    <?php 
        if ($address) {
            ?>
      // Perform an initial search using the existing address
      var request = {
        query: '<?php 
            print o($address);
            ?>
'
      };
      var service = new google.maps.places.PlacesService(map);
      service.textSearch(request, function(places, status) {
        if (status == google.maps.places.PlacesServiceStatus.OK) {
          if(places.length > 0) {
            marker.setPosition(places[0].geometry.location);
          }
        }
      });
    <?php 
        }
        ?>

  <?php 
    }
    ?>
  map.fitBounds(defaultBounds);

  // Have the marker listen for changes to the place.
  google.maps.event.addListener(marker, 'dragend', function() {
    document.getElementById('latitude').value = this.getPosition().lat();
    document.getElementById('longitude').value = this.getPosition().lng();
  });

  // [START region_getplaces]
  // Listen for the event fired when the user selects an item from the
  // pick list. Retrieve the matching places for that item.
  google.maps.event.addListener(searchBox, 'places_changed', function() {
    // Only use the first place - get the icon, place name, and location.
    var places = searchBox.getPlaces();
    var place = places[0];

    marker.setPosition(place.geometry.location);
    map.panTo(place.geometry.location);
    map.setZoom(12);

    document.getElementById('latitude').value = place.geometry.location.lat();
    document.getElementById('longitude').value = place.geometry.location.lng();
  });
  // [END region_getplaces]

  // Bias the SearchBox results towards places that are within the bounds of the
  // current map's viewport.
  google.maps.event.addListener(map, 'bounds_changed', function() {
    var bounds = map.getBounds();
    searchBox.setBounds(bounds);
  });
}

google.maps.event.addDomListener(window, 'load', initialize);

</script>

<form method="post">
    <input type="hidden" name="competitionId" value="<?php 
    print o($chosenCompetitionId);
    ?>
" />
    <input type="hidden" name="password" value="<?php 
    print o($chosenPassword);
    ?>
" />
    <input type="hidden" name="rand" value="<?php 
    echo rand();
    ?>
" />
    Latitude : <input type="text" id="latitude" name="latitude" value="<?php 
    print number_format($lat, 9, '.', '');
    ?>
" size="20" />
    Longitude : <input type="text" id="longitude" name="longitude" value="<?php 
    print number_format($lng, 9, '.', '');
    ?>
" size="20" />
    <input type="submit" name="save" value="Save" />
    </form>

<?php 
}
Beispiel #27
0
<?php

echo H2Configuration::getAdminMenu();
?>

<table class="devicetable"><thead>
  <tr>
    <th>Action</th>
    <th>Reverse</th>
    <th>Skript</th>
  </tr>
</thead><?php 
foreach (o(db)->get('SELECT * FROM events ORDER BY e_address') as $evt) {
    ?>
<tr onclick="document.location.href='<?php 
    echo actionUrl('edit', 'events', array('id' => $evt['e_key']));
    ?>
'">
    <td><?php 
    echo htmlspecialchars($evt['e_address']);
    ?>
</td>
    <td><?php 
    echo htmlspecialchars($evt['e_address_rev']);
    ?>
</td>
    <td><?php 
    echo htmlspecialchars(substr($evt['e_code'], 0, 60));
    ?>
</td>
  </tr><?php 
Beispiel #28
0
 public function __construct($name)
 {
     $tree = o($name);
     $tree->setSelf($this);
     $this->tree = $tree;
 }
<?php

echo $this->_getSubmenu2('groups');
?>
<ul><?php 
$GLOBALS['pagetitle'] = 'Device Groups';
if ($_POST['name']) {
    H2NVStore::set('group/' . $_POST['name'], array());
}
if ($_REQUEST['remove']) {
    db()->get('DELETE FROM nvstore WHERE nv_key = ?', array('group/' . $_REQUEST['remove']));
}
foreach (o(db)->get('SELECT * FROM nvstore 
  WHERE nv_key LIKE "group/%"
  ORDER BY nv_key') as $g) {
    $gname = substr($g['nv_key'], 6);
    ?>
<li><a href="<?php 
    echo actionUrl('group', 'devices', array('id' => $gname));
    ?>
">
    <?php 
    echo htmlspecialchars($gname);
    ?>
    </a> &nbsp; 
    | <a href="<?php 
    echo actionUrl('groups', 'devices', array('remove' => $gname));
    ?>
">delete</a>
  </li><?php 
}
Beispiel #30
0
 public function object()
 {
     $o = o('browser');
     return $o->setName($this->name)->setVersion($this->shortversion)->setPlatform($this->platform)->setUserAgent($this->user_agent)->setEngine($this->engine);
 }