} $perms = array(); $query = "SELECT HEX(map) AS map, perm FROM risk_maps"; if ($result = $conn->Execute($query)) { while (!$result->EOF) { $perms[$result->fields['map']][$result->fields['perm']]++; $result->MoveNext(); } } $query = "SELECT HEX(map) AS map, perm, name FROM risk_maps"; $result = $conn->Execute($query); while (!$result->EOF) { $perms[$result->fields['map']] = $result->fields['perm']; $result->MoveNext(); } if (strlen($perms[$map]) > 0 && !is_map_allowed($perms[$map])) { echo ossim_error(_("You don't have permission to see Map {$map}."), AV_NOTICE); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo _('Risk Maps'); ?> - <?php echo _('View'); ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
//Getting the permissions and the name of the map to show as tittle $query = "SELECT name, perm FROM risk_maps WHERE map = ?"; $result = $conn->Execute($query, array($n)); $map_name = $ico; $map_perm = array(); if (!$result->EOF) { $map_name = $result->fields['name'] == '' ? $ico : $result->fields['name']; $map_perm[] = $result->fields['perm'] == '' ? '' : $result->fields['perm']; $result->fields['perm']; } /* Showing the map icon for the 'Link to map' option just in case whe have permission: Either the SQL query is empty, this mean that the map in the directory and not in the sql, so it's a default map, or we have permission after checking it out in the mapAllowed function. */ if (count($map_perm) == 0 || is_map_allowed($map_perm)) { $linkmaps .= "<td class='noborder'><a href='javascript:;' onclick='select_map(\"{$n}\");'>\n <img src='maps/{$ico}' id='{$n}' class='map_list' border='0' width='45' height='45' alt='{$ico}' title='{$map_name}'></a>\n </td>"; $i++; if ($i % 4 == 0) { $linkmaps .= "</tr><tr>"; } } } ?> <tr> <td valign='top' class='ne1 new_indicator_cell' nowrap='nowrap'> <form name="f" action="modify.php"> <div id='changes_made' style='position: relative; margin:15px auto; white-space:normal;'></div> <table id="new_indicator" cellpadding="0" cellspacing="0">
/** * This function gets the first allowed map available * * @param object $conn Database access object * * @return string */ function get_first_map_available($conn) { $map = NULL; Ossim_db::check_connection($conn); $query = "SELECT HEX(map) AS map, perm, name FROM risk_maps"; $rs = $conn->Execute($query); while (!$rs->EOF) { if (file_exists("maps/map" . $rs->fields['map'] . ".jpg") && is_map_allowed($rs->fields['perm'])) { $map = $rs->fields['map']; break; } $rs->MoveNext(); } return $map; }
<tr> <td> <table style="border:0px;margin-top: 20px"> <tr> <?php $i = 0; $n = 0; $txtmaps = ''; $maps = explode("\n", `ls -tr 'maps' | grep -v CVS`); foreach ($maps as $ico) { if (trim($ico) == '' || !getimagesize("maps/" . $ico)) { continue; } $n = strtoupper(str_replace('map', '', str_replace('.jpg', '', $ico))); //Checking the permission to see a map: If we have permissions to see it, the map will appear, otherwise it will be skipped. if (strlen($perms[$n]) == 0 || !is_map_allowed($perms[$n])) { continue; } $headerclass = $n == $default_map ? " class='headerpr' " : " class='u_headerpr'"; //Shorting the name of the map to avoid too big names. In the title will appear the whole name. $map_name = strlen($map_names[$n]) > 20 ? substr($map_names[$n], 0, 17) . '...' : $map_names[$n]; $map_title = $map_names[$n] . ($n == $default_map ? ' - ' . _('DEFAULT MAP') : ''); ?> <td> <table> <tr> <td> <table class="map_header" id='<?php echo $n; ?> '>
function get_map($conn, $map, $edit = FALSE) { $filename = "maps/map" . $map . ".jpg"; if (file_exists($filename)) { return $map; } $query = "SELECT HEX(map) AS map, perm, name FROM risk_maps"; $result = $conn->Execute($query); while (!$result->EOF) { if ($edit) { if (file_exists("maps/map" . $result->fields['map'] . ".jpg") && can_i_edit_maps($conn, $result->fields['perm'])) { return $result->fields['map']; } } else { if (file_exists("maps/map" . $result->fields['map'] . ".jpg") && is_map_allowed($result->fields['perm'])) { return $result->fields['map']; } } $result->MoveNext(); } return ''; }