本文整理汇总了PHP中parseFilter函数的典型用法代码示例。如果您正苦于以下问题:PHP parseFilter函数的具体用法?PHP parseFilter怎么用?PHP parseFilter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseFilter函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ucfirst
//
if (!canEdit('Events')) {
$view = "error";
return;
}
$selectName = "filterName";
$newSelectName = "new" . ucfirst($selectName);
foreach (dbFetchAll("select * from Filters order by Name") as $row) {
$filterNames[$row['Name']] = $row['Name'];
if ($_REQUEST['filterName'] == $row['Name']) {
$filterData = $row;
}
}
$focusWindow = true;
$filter = $_REQUEST['filter'];
parseFilter($filter);
xhtmlHeaders(__FILE__, translate('SaveFilter'));
?>
<body>
<div id="page">
<div id="header">
<h2><?php
echo translate('SaveFilter');
?>
</h2>
</div>
<div id="content">
<form name="contentForm" id="contentForm" method="post" action="<?php
echo $_SERVER['PHP_SELF'];
?>
">
示例2: executeFilter
}
if (!empty($_REQUEST['execute'])) {
executeFilter($tempFilterName);
}
$countSql = 'SELECT count(E.Id) AS EventCount FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE';
$eventsSql = 'SELECT E.Id,E.MonitorId,M.Name AS MonitorName,M.DefaultScale,E.Name,E.Width,E.Height,E.Cause,E.Notes,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived FROM Monitors AS M INNER JOIN Events AS E on (M.Id = E.MonitorId) WHERE';
if ($user['MonitorIds']) {
$user_monitor_ids = ' M.Id in (' . $user['MonitorIds'] . ')';
$countSql .= $user_monitor_ids;
$eventsSql .= $user_monitor_ids;
} else {
$countSql .= " 1";
$eventsSql .= " 1";
}
parseSort();
parseFilter($_REQUEST['filter']);
$filterQuery = $_REQUEST['filter']['query'];
if ($_REQUEST['filter']['sql']) {
$countSql .= $_REQUEST['filter']['sql'];
$eventsSql .= $_REQUEST['filter']['sql'];
}
$eventsSql .= " ORDER BY {$sortColumn} {$sortOrder}";
if (isset($_REQUEST['page'])) {
$page = validInt($_REQUEST['page']);
} else {
$page = 0;
}
if (isset($_REQUEST['limit'])) {
$limit = validInt($_REQUEST['limit']);
} else {
$limit = 0;
示例3: getNearEvents
function getNearEvents()
{
global $user, $sortColumn, $sortOrder;
$eventId = $_REQUEST['id'];
$event = dbFetchOne('select * from Events where Id = ?', NULL, array($eventId));
parseFilter($_REQUEST['filter']);
parseSort();
if ($user['MonitorIds']) {
$midSql = " and MonitorId in (" . join(",", preg_split('/["\'\\s]*,["\'\\s]*/', $user['MonitorIds'])) . ")";
} else {
$midSql = '';
}
$sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where {$sortColumn} " . ($sortOrder == 'asc' ? '<=' : '>=') . " '" . $event[$_REQUEST['sort_field']] . "'" . $_REQUEST['filter']['sql'] . $midSql . " order by {$sortColumn} " . ($sortOrder == 'asc' ? 'desc' : 'asc');
$result = dbQuery($sql);
while ($id = dbFetchNext($result, 'Id')) {
if ($id == $eventId) {
$prevEvent = dbFetchNext($result);
break;
}
}
$sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where {$sortColumn} " . ($sortOrder == 'asc' ? '>=' : '<=') . " '" . $event[$_REQUEST['sort_field']] . "'" . $_REQUEST['filter']['sql'] . $midSql . " order by {$sortColumn} {$sortOrder}";
$result = dbQuery($sql);
while ($id = dbFetchNext($result, 'Id')) {
if ($id == $eventId) {
$nextEvent = dbFetchNext($result);
break;
}
}
$result = array('EventId' => $eventId);
$result['PrevEventId'] = empty($prevEvent) ? 0 : $prevEvent['Id'];
$result['NextEventId'] = empty($nextEvent) ? 0 : $nextEvent['Id'];
$result['PrevEventDefVideoPath'] = empty($prevEvent) ? 0 : getEventDefaultVideoPath($prevEvent);
$result['NextEventDefVideoPath'] = empty($nextEvent) ? 0 : getEventDefaultVideoPath($nextEvent);
return $result;
}
示例4: parseFilter
function parseFilter($filter, $table, $operator = "=")
{
global $postgisObject;
global $postgisschema;
global $srs;
$table = dropAllNameSpaces($table);
//die($table);
$st = \app\inc\Model::explodeTableName($table);
if (!$st['schema']) {
$st['schema'] = $postgisschema;
}
$primeryKey = $postgisObject->getPrimeryKey($st['schema'] . "." . $st['table']);
$serializer_options = array('indent' => ' ');
$Serializer =& new XML_Serializer($serializer_options);
if (!is_array($filter[0]) && isset($filter) && !(isset($filter['And']) or isset($filter['Or']) or isset($filter['Not']))) {
$filter = array(0 => $filter);
}
$sridOfTable = $postgisObject->getGeometryColumns($table, "srid");
$i = 0;
foreach ($filter as $key => $arr) {
if ($key == "And" || $key == "Or") {
$BoolOperator = $key;
}
if (isset($arr['Not'])) {
//$where[] = parseFilter($arr['Not'],$table,"<>");
}
if (isset($arr['And']) || isset($arr['Or'])) {
// Recursive call
$where[] = parseFilter($arr, $table);
}
// PropertyIsEqualTo
$arr['PropertyIsEqualTo'] = addDiminsionOnArray($arr['PropertyIsEqualTo']);
if (is_array($arr['PropertyIsEqualTo'])) {
foreach ($arr['PropertyIsEqualTo'] as $value) {
$where[] = $value['PropertyName'] . "=" . $postgisObject->quote($value['Literal']);
}
}
// PropertyIsNotEqualTo
$arr['PropertyIsNotEqualTo'] = addDiminsionOnArray($arr['PropertyIsNotEqualTo']);
if (is_array($arr['PropertyIsNotEqualTo'])) {
foreach ($arr['PropertyIsNotEqualTo'] as $value) {
$where[] = $value['PropertyName'] . "<>'" . $value['Literal'] . "'";
}
}
// PropertyIsLessThan
$arr['PropertyIsLessThan'] = addDiminsionOnArray($arr['PropertyIsLessThan']);
if (is_array($arr['PropertyIsLessThan'])) {
foreach ($arr['PropertyIsLessThan'] as $value) {
$where[] = $value['PropertyName'] . "<'" . $value['Literal'] . "'";
}
}
// PropertyIsGreaterThan
$arr['PropertyIsGreaterThan'] = addDiminsionOnArray($arr['PropertyIsGreaterThan']);
if (is_array($arr['PropertyIsGreaterThan'])) {
foreach ($arr['PropertyIsGreaterThan'] as $value) {
$where[] = $value['PropertyName'] . ">'" . $value['Literal'] . "'";
}
}
// PropertyIsLessThanOrEqualTo
$arr['PropertyIsLessThanOrEqualTo'] = addDiminsionOnArray($arr['PropertyIsLessThanOrEqualTo']);
if (is_array($arr['PropertyIsLessThanOrEqualTo'])) {
foreach ($arr['PropertyIsLessThanOrEqualTo'] as $value) {
$where[] = $value['PropertyName'] . "<='" . $value['Literal'] . "'";
}
}
//PropertyIsGreaterThanOrEqualTo
$arr['PropertyIsGreaterThanOrEqualTo'] = addDiminsionOnArray($arr['PropertyIsGreaterThanOrEqualTo']);
if (is_array($arr['PropertyIsGreaterThanOrEqualTo'])) {
foreach ($arr['PropertyIsGreaterThanOrEqualTo'] as $value) {
$where[] = $value['PropertyName'] . ">='" . $value['Literal'] . "'";
}
}
//PropertyIsLike
$arr['PropertyIsLike'] = addDiminsionOnArray($arr['PropertyIsLike']);
if (is_array($arr['PropertyIsLike'])) {
foreach ($arr['PropertyIsLike'] as $value) {
$where[] = $value['PropertyName'] . " LIKE '%" . $value['Literal'] . "%'";
}
}
//PropertyIsBetween
$arr['PropertyIsBetween'] = addDiminsionOnArray($arr['PropertyIsBetween']);
if (is_array($arr['PropertyIsBetween'])) {
foreach ($arr['PropertyIsBetween'] as $value) {
if ($value['LowerBoundary']) {
$w[] = $value['PropertyName'] . " > '" . $value['LowerBoundary']['Literal'] . "'";
}
if ($value['UpperBoundary']) {
$w[] = $value['PropertyName'] . " < '" . $value['UpperBoundary']['Literal'] . "'";
}
}
$where[] = implode(" AND ", $w);
}
// FeatureID
if (!is_array($arr['FeatureId'][0]) && isset($arr['FeatureId'])) {
$arr['FeatureId'] = array(0 => $arr['FeatureId']);
}
if (is_array($arr['FeatureId'])) {
foreach ($arr['FeatureId'] as $value) {
$value['fid'] = preg_replace("/{$table}\\./", "", $value['fid']);
// remove table name
//.........这里部分代码省略.........
示例5: parseFilter
/**
*
*
* @param unknown $arr
* @return unknown
*/
function parseFilter($filter, $table, $operator = "=")
{
global $postgisObject;
global $postgisschema;
//global $forUseInSpatialFilter;
global $srs;
$st = postgis::explodeTableName($table);
if (!$st['schema']) {
$st['schema'] = $postgisschema;
}
$primeryKey = $postgisObject->getPrimeryKey($st['schema'] . "." . $st['table']);
$serializer_options = array('indent' => ' ');
$Serializer =& new XML_Serializer($serializer_options);
if (!is_array($filter[0]) && isset($filter) && !(isset($filter['And']) or isset($filter['Or']) or isset($filter['Not']))) {
$filter = array(0 => $filter);
}
$sridOfTable = $postgisObject->getGeometryColumns($table, "srid");
$i = 0;
foreach ($filter as $key => $arr) {
if ($key == "And" || $key == "Or") {
$BoolOperator = $key;
}
if (isset($arr['Not'])) {
//$where[] = parseFilter($arr['Not'],$table,"<>");
}
if (isset($arr['And']) || isset($arr['Or'])) {
// Recursive call
$where[] = parseFilter($arr, $table);
}
// PropertyIsEqualTo
$arr['PropertyIsEqualTo'] = addDiminsionOnArray($arr['PropertyIsEqualTo']);
if (is_array($arr['PropertyIsEqualTo'])) {
foreach ($arr['PropertyIsEqualTo'] as $value) {
$where[] = $value['PropertyName'] . "=" . $postgisObject->quote($value['Literal']);
}
}
// PropertyIsNotEqualTo
$arr['PropertyIsNotEqualTo'] = addDiminsionOnArray($arr['PropertyIsNotEqualTo']);
if (is_array($arr['PropertyIsNotEqualTo'])) {
foreach ($arr['PropertyIsNotEqualTo'] as $value) {
$where[] = $value['PropertyName'] . "<>'" . $value['Literal'] . "'";
}
}
// FeatureID
if (!is_array($arr['FeatureId'][0]) && isset($arr['FeatureId'])) {
$arr['FeatureId'] = array(0 => $arr['FeatureId']);
}
if (is_array($arr['FeatureId'])) {
foreach ($arr['FeatureId'] as $value) {
$value['fid'] = preg_replace("/{$table}\\./", "", $value['fid']);
// remove table name
$where[] = "{$primeryKey['attname']}=" . $value['fid'];
}
}
// GmlObjectId
$arr['GmlObjectId'] = addDiminsionOnArray($arr['GmlObjectId']);
if (is_array($arr['GmlObjectId'])) {
foreach ($arr['GmlObjectId'] as $value) {
$value['id'] = preg_replace("/{$table}\\./", "", $value['id']);
// remove table name
$where[] = "{$primeryKey['attname']}=" . $value['id'];
}
}
//Intersects
$arr['Intersects'] = addDiminsionOnArray($arr['Intersects']);
if (is_array($arr['Intersects'])) {
foreach ($arr['Intersects'] as $value) {
$status = $Serializer->serialize($value);
$gmlCon = new gmlConverter();
//logfile::write($Serializer->getSerializedData()."\n\n");
$wktArr = $gmlCon->gmlToWKT($Serializer->getSerializedData(), array());
$sridOfFilter = $wktArr[1][0];
if (!$sridOfFilter) {
$sridOfFilter = $srs;
}
// If no filter on BBOX we think it must be same as the requested srs
if (!$sridOfFilter) {
$sridOfFilter = $sridOfTable;
}
// If still no filter on BBOX we set it to native srs
$where[] = "intersects" . "(public.transform(public.GeometryFromText('" . $wktArr[0][0] . "'," . $sridOfFilter . "),{$sridOfTable})," . $value['PropertyName'] . ")";
unset($gmlCon);
unset($wktArr);
}
}
//BBox
if ($arr['BBOX']) {
if (is_array($arr['BBOX']['Box']['coordinates'])) {
$arr['BBOX']['Box']['coordinates']['_content'] = str_replace(" ", ",", $arr['BBOX']['Box']['coordinates']['_content']);
$coordsArr = explode(",", $arr['BBOX']['Box']['coordinates']['_content']);
} else {
$arr['BBOX']['Box']['coordinates'] = str_replace(" ", ",", $arr['BBOX']['Box']['coordinates']);
$coordsArr = explode(",", $arr['BBOX']['Box']['coordinates']);
}
//.........这里部分代码省略.........
示例6: parseTreeToQuery
function parseTreeToQuery($tree)
{
$filter = parseTreeToFilter($tree);
parseFilter($filter, false, '&');
return $filter['query'];
}
示例7: doParse
function doParse($arr)
{
global $postgisObject;
global $user;
global $version;
global $postgisschema;
global $parts;
$serializer_options = array('indent' => ' ');
$Serializer =& new XML_Serializer($serializer_options);
foreach ($arr as $key => $featureMember) {
if ($key == "Insert") {
if (!is_array($featureMember[0]) && isset($featureMember)) {
$featureMember = array(0 => $featureMember);
}
foreach ($featureMember as $hey) {
foreach ($hey as $typeName => $feature) {
if (is_array($feature)) {
// Skip handles
foreach ($feature as $field => $value) {
$fields[] = $field;
if (is_array($value)) {
// Must be geom if array
// We serialize the geometry back to XML for parsing
$status = $Serializer->serialize($value);
logfile::write("GML " . $Serializer->getSerializedData() . "\n\n");
$gmlCon = new gmlConverter();
$wktArr = $gmlCon->gmlToWKT($Serializer->getSerializedData(), array());
$values[] = array("{$field}" => $wktArr[0][0], "srid" => $wktArr[1][0]);
unset($gmlCon);
unset($wktArr);
//logfile::write($Serializer->getSerializedData()."\n\n");
} else {
$values[] = pg_escape_string($value);
}
}
$forSql['tables'][] = $typeName;
$forSql['fields'][] = $fields;
$forSql['values'][] = $values;
$fields = array();
$values = array();
$field = "";
$value = "";
// Start HTTP basic authentication
//if(!$_SESSION["oauth_token"]) {
$auth = $postgisObject->getGeometryColumns($postgisschema . "." . $typeName, "authentication");
if ($auth == "Write" or $auth == "Read/write") {
include '../inc/http_basic_authen.php';
}
// }
// End HTTP basic authentication
}
}
}
}
if ($key == "Update") {
if (!is_array($featureMember[0]) && isset($featureMember)) {
$featureMember = array(0 => $featureMember);
}
$fid = 0;
foreach ($featureMember as $hey) {
$the_geom = $postgisObject->getGeometryColumns($postgisschema . "." . $hey['typeName'], "f_geometry_column");
if (!is_array($hey['Property'][0]) && isset($hey['Property'])) {
$hey['Property'] = array(0 => $hey['Property']);
}
foreach ($hey['Property'] as $pair) {
$fields[$fid][] = $pair['Name'];
if ($pair['Name'] == $the_geom) {
// We serialize the geometry back to XML for parsing
$status = $Serializer->serialize($pair['Value']);
logfile::write($Serializer->getSerializedData() . "\n\n");
$gmlCon = new gmlConverter();
$wktArr = $gmlCon->gmlToWKT($Serializer->getSerializedData(), array());
$values[$fid][] = array("{$pair['Name']}" => current($wktArr[0]), "srid" => current($wktArr[1]));
unset($gmlCon);
unset($wktArr);
} else {
$values[$fid][] = $pair['Value'];
}
}
$forSql2['tables'][$fid] = $hey['typeName'];
$forSql2['fields'] = $fields;
$forSql2['values'] = $values;
$forSql2['wheres'][$fid] = parseFilter($hey['Filter'], $hey['typeName']);
$fid++;
// Start HTTP basic authentication
//if(!$_SESSION["oauth_token"]) {
$auth = $postgisObject->getGeometryColumns($postgisschema . "." . $hey['typeName'], "authentication");
if ($auth == "Write" or $auth == "Read/write") {
include '../inc/http_basic_authen.php';
}
// }
// End HTTP basic authentication
}
$pair = array();
$values = array();
$fields = array();
}
if ($key == "Delete") {
if (!is_array($featureMember[0]) && isset($featureMember)) {
$featureMember = array(0 => $featureMember);
//.........这里部分代码省略.........
示例8: translate
?>
">
<input type="button" value="<?php
echo translate('Refresh');
?>
" onclick="location.reload(true);"/>
<?php
echo makePopupButton('?view=monitor', 'zmMonitor0', 'monitor', translate('AddNewMonitor'), canEdit('Monitors') && !$user['MonitorIds']);
?>
<?php
echo makePopupButton('?view=filter&filter[terms][0][attr]=DateTime&filter[terms][0][op]=%3c&filter[terms][0][val]=now', 'zmFilter', 'filter', translate('Filters'), canView('Events'));
?>
</td>
<?php
for ($i = 0; $i < count($eventCounts); $i++) {
parseFilter($eventCounts[$i]['filter']);
?>
<td class="colEvents"><?php
echo makePopupLink('?view=' . $eventsView . '&page=1' . $eventCounts[$i]['filter']['query'], $eventsWindow, $eventsView, $eventCounts[$i]['total'], canView('Events'));
?>
</td>
<?php
}
?>
<td class="colZones"><?php
echo $zoneCount;
?>
</td>
<td class="colRightButtons" colspan="<?php
echo canEdit('Monitors') ? 2 : 1;
?>
示例9: doParse
//.........这里部分代码省略.........
$hey["Property"][] = array("Name" => "gc2_version_start_date", "Value" => null);
}
if (!$gc2_status_flag && $tableObj->workflow) {
$hey["Property"][] = array("Name" => "gc2_status", "Value" => null);
}
if (!$gc2_workflow_flag && $tableObj->workflow) {
$hey["Property"][] = array("Name" => "gc2_workflow", "Value" => null);
}
//makeExceptionReport(print_r($hey, true));
foreach ($hey['Property'] as $pair) {
$fields[$fid][] = $pair['Name'];
$roleObj = $layerObj->getRole($postgisschema, $hey['typeName'], $user);
$role = $roleObj["data"][$user];
if ($tableObj->workflow && ($role == "none" && $parentUser == false)) {
makeExceptionReport("You don't have a role in the workflow of '{$hey['typeName']}'");
}
if (is_array($pair['Value'])) {
// Must be geom if array
// We serialize the geometry back to XML for parsing
$Serializer->serialize($pair['Value']);
Log::write($Serializer->getSerializedData() . "\n\n");
$gmlCon = new gmlConverter();
$wktArr = $gmlCon->gmlToWKT($Serializer->getSerializedData(), array());
$values[$fid][] = array("{$pair['Name']}" => current($wktArr[0]), "srid" => current($wktArr[1]));
unset($gmlCon);
unset($wktArr);
} else {
$values[$fid][] = $pair['Value'];
}
}
$forSql2['tables'][$fid] = $hey['typeName'];
$forSql2['fields'] = $fields;
$forSql2['values'] = $values;
$forSql2['wheres'][$fid] = parseFilter($hey['Filter'], $hey['typeName']);
$fid++;
// Start HTTP basic authentication
$auth = $postgisObject->getGeometryColumns($postgisschema . "." . $hey['typeName'], "authentication");
if ($auth == "Write" or $auth == "Read/write") {
$HTTP_FORM_VARS["TYPENAME"] = $hey['typeName'];
include 'inc/http_basic_authen.php';
}
// End HTTP basic authentication
}
$pair = array();
$values = array();
$fields = array();
}
if ($key == "Delete") {
if (!is_array($featureMember[0]) && isset($featureMember)) {
$featureMember = array(0 => $featureMember);
}
foreach ($featureMember as $hey) {
$hey['typeName'] = dropAllNameSpaces($hey['typeName']);
$forSql3['tables'][] = $hey['typeName'];
$forSql3['wheres'][] = parseFilter($hey['Filter'], $hey['typeName']);
$roleObj = $layerObj->getRole($postgisschema, $hey['typeName'], $user);
$role = $roleObj["data"][$user];
$tableObj = new table($postgisschema . "." . $hey["typeName"]);
if ($tableObj->workflow && ($role == "none" && $parentUser == false)) {
makeExceptionReport("You don't have a role in the workflow of '{$hey['typeName']}'");
}
// Start HTTP basic authentication
$auth = $postgisObject->getGeometryColumns($postgisschema . "." . $hey['typeName'], "authentication");
if ($auth == "Write" or $auth == "Read/write") {
$HTTP_FORM_VARS["TYPENAME"] = $hey['typeName'];
include 'inc/http_basic_authen.php';
示例10: parseFilter
if (isset($_REQUEST["sld_form_element_id"]) && isset($_REQUEST["sld_objects_rule_id"])) {
$first_load = 1;
$sld_form_element_id = $_REQUEST["sld_form_element_id"];
$_SESSION["sld_form_element_id"] = $sld_form_element_id;
$sld_objects_rule_id = $_REQUEST["sld_objects_rule_id"];
$_SESSION["sld_objects_rule_id"] = $sld_objects_rule_id;
$filter = $sld_objects[$sld_objects_rule_id]->filter;
$_SESSION["sld_filter"] = $filter;
} else {
$first_load = 0;
$sld_form_element_id = $_SESSION["sld_form_element_id"];
$sld_objects_rule_id = $_SESSION["sld_objects_rule_id"];
$filter = $_SESSION["sld_filter"];
}
//Parse the Filter Expression
$filterObj = parseFilter($filter);
if ($filterObj == "") {
//$filterObj = new Filter();
}
//Function handling
if (isset($_REQUEST["function"])) {
$function = $_REQUEST["function"];
//Handle the requested functions
if ($function == "addoperation") {
if (isset($_REQUEST["id"]) && isset($_REQUEST["operation"])) {
$operation = $_REQUEST["operation"];
switch (strtoupper($operation)) {
case "OR":
$_SESSION["sld_filter_objects"][$_REQUEST["id"]]->operations[] = new BinaryLogicOp("Or");
break;
case "AND":
示例11: makeLink
<?php
}
if ($cycleCount > 1) {
?>
<td><?php
echo makeLink("?view=montage", translate('Montage'), $running && canView('Stream'));
?>
</td>
<?php
} else {
?>
<td> </td>
<?php
}
for ($i = 0; $i < count($eventCounts); $i++) {
parseFilter($eventCounts[$i]['filter'], false, '&');
?>
<td class="colEvents"><?php
echo makeLink("?view=events&page=1" . $eventCounts[$i]['filter']['query'], $eventCounts[$i]['total'], canView('Events'));
?>
</td>
<?php
}
?>
</tr>
</table>
</div>
</div>
</body>
</html>
示例12: in
return;
}
$midSql = '';
if ($user['MonitorIds']) {
$midSql = " and MonitorId in (" . join(",", preg_split('/["\'\\s]*,["\'\\s]*/', $user['MonitorIds'])) . ")";
}
$sql = 'select E.*,M.Name as MonitorName,M.Width,M.Height from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = ?' . $midSql;
$event = dbFetchOne($sql, NULL, array($_REQUEST['eid']));
if (!empty($_REQUEST['fid'])) {
$frame = dbFetchOne('SELECT * FROM Frames WHERE EventID = ? AND FrameId = ?', NULL, array($_REQUEST['eid'], $_REQUEST['fid']));
} elseif (isset($_REQUEST['fid'])) {
$frame = dbFetchOne('SELECT * FROM Frames WHERE EventID = ? AND Score = ?', NULL, array($_REQUEST['eid'], $event['MaxScore']));
$_REQUEST['fid'] = $frame['FrameId'];
}
parseSort(true, '&');
parseFilter($_REQUEST['filter'], true, '&');
$filterQuery = $_REQUEST['filter']['query'];
if ($sortOrder == 'asc') {
$sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where {$sortColumn} <= ?" . $_REQUEST['filter']['sql'] . $midSql . " order by {$sortColumn} desc";
} else {
$sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where {$sortColumn} >= ?" . $_REQUEST['filter']['sql'] . $midSql . " order by {$sortColumn} asc";
}
$result = dbQuery($sql, array($event[$_REQUEST['sort_field']]));
while ($row = dbFetchNext($result)) {
if ($row['Id'] == $_REQUEST['eid']) {
$prevEvent = dbFetchNext($result);
break;
}
}
$sql = "select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where {$sortColumn} " . ($sortOrder == 'asc' ? '>=' : '<=') . ' ?' . $_REQUEST['filter']['sql'] . $midSql . " order by {$sortColumn} {$sortOrder}";
$result = dbQuery($sql, array($event[$_REQUEST['sort_field']]));
示例13: wfs_server
function wfs_server()
{
// Manually tested this piece of code in order to check the requests.
// Code based on a similar idea but build in Java
header('Content-Type:text/xml; charset=UTF-8', TRUE);
header('Connection:close', TRUE);
//$userFromUri = "mhoegh"; // for testing
logfile::write($userFromUri . "\n\n");
// We connect to the users db
$postgisdb = $userFromUri;
$srs = $srsFromUri;
$postgisschema = $schemaFromUri;
$postgisObject = new postgis();
//$user = new users($userFromUri);
//$version = new version($user);
$geometryColumnsObj = new GeometryColumns();
function microtime_float()
{
list($utime, $time) = explode(" ", microtime());
return (double) $utime + (double) $time;
}
$startTime = microtime_float();
//ini_set("display_errors", "On");
$thePath = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REDIRECT_URL'];
//$thePath= "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
$server = "http://" . $_SERVER['SERVER_NAME'];
$BBox = null;
//end added
$currentTable = null;
$currentTag = null;
$gen = array();
$gen[0] = "";
$level = 0;
$depth = 0;
$tables = array();
$fields = array();
$wheres = array();
$limits = array();
logfile::write("\nRequest\n\n");
logfile::write($HTTP_RAW_POST_DATA . "\n\n");
$unserializer_options = array('parseAttributes' => TRUE, 'typeHints' => FALSE);
$unserializer = new XML_Unserializer($unserializer_options);
/*$HTTP_RAW_POST_DATA = '<?xml version="1.0" encoding="utf-8"?><wfs:Transaction service="WFS" version="1.0.0" xmlns="http://www.opengis.net/wfs" xmlns:mrhg="http://twitter/mrhg" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wfs:Insert idgen="GenerateNew"><mrhg:hej><the_geom><gml:MultiPolygon srsName="urn:x-ogc:def:crs:EPSG:6.9:4326"><gml:polygonMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:coordinates>5.0657329559,-41.1107215881 8.4824724197,-39.3435783386 4.3241734505,-34.6001853943 5.0657329559,-41.1107215881 </gml:coordinates></gml:LinearRing></gml:exterior></gml:Polygon></gml:polygonMember></gml:MultiPolygon></the_geom></mrhg:hej></wfs:Insert></wfs:Transaction>';*/
/*$HTTP_RAW_POST_DATA = '<?xml version="1.0"?><DescribeFeatureType version="1.1.0" service="WFS" xmlns="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"> <TypeName>california_coastline</TypeName></DescribeFeatureType>';
*/
// Post method is used
if ($HTTP_RAW_POST_DATA) {
//$forUseInSpatialFilter = $HTTP_RAW_POST_DATA; // We store a unaltered version of the raw request
$HTTP_RAW_POST_DATA = dropNameSpace($HTTP_RAW_POST_DATA);
logfile::write($HTTP_RAW_POST_DATA . "\n\n");
$status = $unserializer->unserialize($HTTP_RAW_POST_DATA);
$arr = $unserializer->getUnserializedData();
$request = $unserializer->getRootName();
//print_r($arr);
switch ($request) {
case "GetFeature":
if (!is_array($arr['Query'][0])) {
$arr['Query'] = array(0 => $arr['Query']);
}
for ($i = 0; $i < sizeof($arr['Query']); $i++) {
if (!is_array($arr['Query'][$i]['PropertyName'])) {
$arr['Query'][$i]['PropertyName'] = array(0 => $arr['Query'][$i]['PropertyName']);
}
}
$HTTP_FORM_VARS["REQUEST"] = "GetFeature";
foreach ($arr['Query'] as $queries) {
$HTTP_FORM_VARS["TYPENAME"] .= $queries['typeName'] . ",";
if ($queries['PropertyName'][0]) {
foreach ($queries['PropertyName'] as $PropertyNames) {
// We check if typeName is prefix and add it if its not
if (strpos($PropertyNames, ".")) {
$HTTP_FORM_VARS["PROPERTYNAME"] .= $PropertyNames . ",";
} else {
$HTTP_FORM_VARS["PROPERTYNAME"] .= $queries['typeName'] . "." . $PropertyNames . ",";
}
}
}
if (is_array($queries['Filter']) && $arr['version'] == "1.0.0") {
@($checkXml = simplexml_load_string($queries['Filter']));
if ($checkXml === FALSE) {
makeExceptionReport("Filter is not valid");
}
$wheres[$queries['typeName']] = parseFilter($queries['Filter'], $queries['typeName']);
}
}
$HTTP_FORM_VARS["TYPENAME"] = dropLastChrs($HTTP_FORM_VARS["TYPENAME"], 1);
$HTTP_FORM_VARS["PROPERTYNAME"] = dropLastChrs($HTTP_FORM_VARS["PROPERTYNAME"], 1);
break;
case "DescribeFeatureType":
$HTTP_FORM_VARS["REQUEST"] = "DescribeFeatureType";
$HTTP_FORM_VARS["TYPENAME"] = $arr['TypeName'];
//if (!$HTTP_FORM_VARS["TYPENAME"]) $HTTP_FORM_VARS["TYPENAME"] = $arr['typeName'];
break;
case "GetCapabilities":
$HTTP_FORM_VARS["REQUEST"] = "GetCapabilities";
break;
case "Transaction":
$HTTP_FORM_VARS["REQUEST"] = "Transaction";
if (isset($arr["Insert"])) {
$transactionType = "Insert";
//.........这里部分代码省略.........