spaces, quotes extra braces

This commit is contained in:
Isaac Connor 2019-09-25 10:13:32 -04:00
parent 80710e6551
commit afd10e49d6
1 changed files with 189 additions and 191 deletions

View File

@ -185,18 +185,18 @@ $statusData = array(
'permission' => 'Events', 'permission' => 'Events',
'func' => 'getNearEvents()' 'func' => 'getNearEvents()'
) )
); );
function collectData() { function collectData() {
global $statusData; global $statusData;
$entitySpec = &$statusData[strtolower(validJsStr($_REQUEST['entity']))]; $entitySpec = &$statusData[strtolower(validJsStr($_REQUEST['entity']))];
#print_r( $entitySpec ); #print_r( $entitySpec );
if ( !canView( $entitySpec['permission'] ) ) if ( !canView($entitySpec['permission']) )
ajaxError('Unrecognised action or insufficient permissions'); ajaxError('Unrecognised action or insufficient permissions');
if ( !empty($entitySpec['func']) ) { if ( !empty($entitySpec['func']) ) {
$data = eval( 'return( '.$entitySpec['func']." );" ); $data = eval('return('.$entitySpec['func'].');');
} else { } else {
$data = array(); $data = array();
$postFuncs = array(); $postFuncs = array();
@ -249,12 +249,12 @@ function collectData() {
$groupSql[] = $elementData['group']; $groupSql[] = $elementData['group'];
} }
} }
} } # end foreach element
if ( count($fieldSql) ) { if ( count($fieldSql) ) {
$sql = 'select '.join( ', ', $fieldSql ).' from '.$entitySpec['table']; $sql = 'SELECT '.join(', ', $fieldSql).' FROM '.$entitySpec['table'];
if ( $joinSql ) if ( $joinSql )
$sql .= ' '.join( ' ', array_unique( $joinSql ) ); $sql .= ' '.join(' ', array_unique($joinSql));
if ( $id && !empty($entitySpec['selector']) ) { if ( $id && !empty($entitySpec['selector']) ) {
$index = 0; $index = 0;
$where = array(); $where = array();
@ -270,10 +270,10 @@ function collectData() {
} }
$index++; $index++;
} }
$sql .= ' WHERE '.join( ' AND ', $where ); $sql .= ' WHERE '.join(' AND ', $where);
} }
if ( $groupSql ) if ( $groupSql )
$sql .= ' GROUP BY '.join( ',', array_unique( $groupSql ) ); $sql .= ' GROUP BY '.join(',', array_unique($groupSql));
if ( !empty($_REQUEST['sort']) ) { if ( !empty($_REQUEST['sort']) ) {
$sql .= ' ORDER BY '; $sql .= ' ORDER BY ';
$sort_fields = explode(',',$_REQUEST['sort']); $sort_fields = explode(',',$_REQUEST['sort']);
@ -335,31 +335,29 @@ if ( !isset($_REQUEST['layout']) ) {
switch( $_REQUEST['layout'] ) { switch( $_REQUEST['layout'] ) {
case 'xml NOT CURRENTLY SUPPORTED' : case 'xml NOT CURRENTLY SUPPORTED' :
{ header('Content-type: application/xml');
header("Content-type: application/xml" ); echo('<?xml version="1.0" encoding="iso-8859-1"?>'."\n");
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
echo '<'.strtolower($_REQUEST['entity']).">\n"; echo '<'.strtolower($_REQUEST['entity']).">\n";
foreach ( $data as $key=>$value ) { foreach ( $data as $key=>$value ) {
$key = strtolower( $key ); $key = strtolower($key);
echo "<$key>".htmlentities($value)."</$key>\n"; echo "<$key>".htmlentities($value)."</$key>\n";
} }
echo '</'.strtolower($_REQUEST['entity']).">\n"; echo '</'.strtolower($_REQUEST['entity']).">\n";
break; break;
}
case 'json' : case 'json' :
{ {
$response = array( strtolower(validJsStr($_REQUEST['entity'])) => $data ); $response = array( strtolower(validJsStr($_REQUEST['entity'])) => $data );
if ( isset($_REQUEST['loopback']) ) if ( isset($_REQUEST['loopback']) )
$response['loopback'] = validJsStr($_REQUEST['loopback']); $response['loopback'] = validJsStr($_REQUEST['loopback']);
ajaxResponse( $response ); ajaxResponse($response);
break; break;
} }
case 'text' : case 'text' :
{
header('Content-type: text/plain' ); header('Content-type: text/plain' );
echo join( ' ', array_values( $data ) ); echo join( ' ', array_values( $data ) );
break; break;
} default:
ZM\Error('Unsupported layout: '. $_REQUEST['layout']);
} }
function getFrameImage() { function getFrameImage() {