* * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ /** * Galaxy map * * @author Mauri Kujala <*****@*****.**> * @copyright Copyright (C) 2016, Mauri Kujala * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 */ //http://ed-board.net/3Dgalnet/ $pagetitle = "Galaxy Map & Neighborhood Map"; require_once "" . $_SERVER["DOCUMENT_ROOT"] . "/style/header.php"; if (valid_coordinates($curSys["x"], $curSys["y"], $curSys["z"])) { $ucoordx = $curSys["x"]; $ucoordy = $curSys["y"]; $ucoordz = -$curSys["z"]; } else { // get last known coordinates $last_coords = last_known_system(); $ucoordx = $last_coords["x"]; $ucoordy = $last_coords["y"]; $ucoordz = -$last_coords["z"]; $is_unknown = " *"; } ?> <div style="display:none" id="curx"><?php echo $ucoordx; ?>
$log_coordx = $lb_arr["x"] == "" ? "" : $lb_arr["x"]; $log_coordy = $lb_arr["y"] == "" ? "" : $lb_arr["y"]; $log_coordz = $lb_arr["z"] == "" ? "" : $lb_arr["z"]; } if (valid_coordinates($log_coordx, $log_coordy, $log_coordz)) { $log_date = $log_row["stardate"]; $date = date_create($log_date); $log_added = date_modify($date, "+1286 years"); $text = $log_row["log_entry"]; if (mb_strlen($text) > 40) { $text = "" . substr($text, 0, 40) . "..."; } $cat = ',"cat":[11]'; $info .= '<div class="map_info"><span class="map_info_title">Logged System</span><br />'; $info .= '<strong>Log entry</strong><br /><a href="/log.php?system=' . urlencode($log_system) . '" style="color:inherit;font-weight:bold" title="View the log for this system">' . $text . ' </a><br /><br />'; $info .= '<strong>Added</strong><br />' . date_format($log_added, "j M Y, H:i") . ''; $info .= '</div>'; $data = '{"name":"' . $log_system . '"' . $cat . ',"coords":{"x":' . $log_coordx . ',"y":' . $log_coordy . ',"z":' . $log_coordz . '},"infos":' . json_encode($info) . '}' . $last_row . ''; $last_row = "," . $data . ""; } } //$info = '</div>'; $cur_sys_data = ""; if (strtolower($last_system_name) == strtolower($curSys["name"]) && valid_coordinates($curSys["x"], $curSys["y"], $curSys["z"])) { $comma = !empty($data) ? "," : ""; $cur_sys_data = $comma . '{"name":"' . $curSys["name"] . '","cat":[5],"coords":{"x":' . $curSys["x"] . ',"y":' . $curSys["y"] . ',"z":' . $curSys["z"] . '}}'; } $data = $data_start . $data . $cur_sys_data . "]}"; $map_json = $_SERVER["DOCUMENT_ROOT"] . "/map_points.json"; file_put_contents($map_json, $data); edtb_common("last_map_update", "unixtime", true, time());
$c_rares_data .= "- "; $c_rares_data .= $rare_arr["max_landing_pad_size"]; $c_rares_data .= "</span><br /><br />"; $actual_num_res++; } } } else { $c_rares_data .= "No rares nearby"; } $c_rares_data .= "</div>"; // check if system has screenshots $si_screenshots = has_screenshots($si_system_name) ? '<a href="/gallery.php?spgmGal=' . urlencode($si_system_name) . '" title="View image gallery"><img src="/style/img/image.png" alt="Gallery" style="margin-left:5px;vertical-align:top" /></a>' : ""; // check if system is logged $si_loglink = is_logged($si_system_name) ? '<a href="log.php?system=' . urlencode($si_system_name) . '" style="color:inherit" title="System has log entries"><img src="/style/img/log.png" style="margin-left:5px" /></a>' : ""; $num_visits = mysqli_num_rows(mysqli_query($GLOBALS["___mysqli_ston"], "SELECT id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM user_visited_systems\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE system_name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $si_system_name) . "'")); if ($actual_num_res > 0 && valid_coordinates($curSys["x"], $curSys["y"], $curSys["z"])) { $rare_text = " <span onclick='\$(\"#rares\").fadeToggle(\"fast\");'><a href='javascript:void(0);' title'Click for more info'>[ Rares within " . $settings["rare_range"] . " ly: " . $actual_num_res . " ]</a>" . $c_rares_data . "</span>"; } $data['si_name'] .= "" . $si_system_display_name . "" . $si_loglink . $si_screenshots . " <span style='font-size:11px;text-transform:uppercase;vertical-align:middle;'>[ State: " . $si_system_state . " - Security: " . $si_system_security . " - Visits: " . $num_visits . " ]" . $rare_text . "" . $user_dists . "</span>"; /* * station info for system.php */ $si_res = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT SQL_CACHE *\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM edtb_stations\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE system_id = '" . $si_system_id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY -ls_from_star DESC, name") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__); $station_exists = mysqli_num_rows($si_res); if ($station_exists == 0) { $data['si_stations'] = "No station data available"; } else { while ($sarr2 = mysqli_fetch_assoc($si_res)) { $s_name = $sarr2["name"]; $s_explode = explode(" ", $s_name); $count = count($s_explode);
/** * Return distance from current to $system * * @param string|int $system * @return string $distance * @author Mauri Kujala <*****@*****.**> */ function get_distance($system) { global $mysqli; /** * fetch target coordinates */ $esc_sys = $mysqli->real_escape_string($system); $query = " (SELECT\n edtb_systems.x AS target_x,\n edtb_systems.y AS target_y,\n edtb_systems.z AS target_z\n FROM edtb_systems\n WHERE edtb_systems.name = '{$esc_sys}')\n UNION\n (SELECT\n user_systems_own.x AS target_x,\n user_systems_own.y AS target_y,\n user_systems_own.z AS target_z\n FROM user_systems_own\n WHERE user_systems_own.name = '{$esc_sys}')\n LIMIT 1"; $result = $mysqli->query($query) or write_log($mysqli->error, __FILE__, __LINE__); $obj = $result->fetch_object(); $target_x = $obj->target_x; $target_y = $obj->target_y; $target_z = $obj->target_z; $result->close(); // figure out what coords to calculate from $usable_coords = usable_coords(); $usex = $usable_coords["x"]; $usey = $usable_coords["y"]; $usez = $usable_coords["z"]; $exact = $usable_coords["current"] === true ? "" : " *"; if (valid_coordinates($target_x, $target_y, $target_z)) { $dist = number_format(sqrt(pow($target_x - $usex, 2) + pow($target_y - $usey, 2) + pow($target_z - $usez, 2)), 2); $distance = $dist . ' ly' . $exact; } else { $distance = ''; } return $distance; }
/** * Make item table * * @param resource $res * @param string $type * @return string * @author Mauri Kujala <*****@*****.**> */ function maketable($res, $type) { global $curSys; $num = mysqli_num_rows($res); echo '<table>'; if ($num > 0) { if (!valid_coordinates($curSys["x"], $curSys["y"], $curSys["z"])) { echo "<tr><td class='dark' style='min-width:420px;max-width:500px;'><p><strong>No coordinates for current location, last known location used.</strong></p></td></tr>"; } $i = 0; $to_last = array(); while ($arr = mysqli_fetch_assoc($res)) { echo makeitem($arr, $type, $i); } } else { if ($type == "Poi") { echo '<tr><td class="dark" style="min-width:420px;max-width:500px"><strong>No points of interest.<br />Click the "Points of Interest" text to add one.</strong></td></tr>'; } else { echo '<tr><td class="dark" style="min-width:420px;max-width:500px"><strong>No bookmarks.<br />Click the allegiance icon on the top left corner to add one.</strong></td></tr>'; } } echo '</table>'; }
function show_list() { # message after add or edit $this->content_saved = $_SESSION['content_saved']; $_SESSION['content_saved'] = ''; # default sort (a = ascending) $ad = 'a'; if ($_GET['sort'] && in_array($_GET['sort'], $this->fields_in_list_view)) { if ($_GET['ad'] == 'a') { $asc_des = 'ASC'; } if ($_GET['ad'] == 'd') { $asc_des = 'DESC'; } $order_by = "ORDER by " . $_GET['sort'] . ' ' . $asc_des; } else { $order_by = "ORDER by {$this->primary_key} DESC"; } # navigation 1/3 $start = $_GET["start"]; if (!$start) { $start = 0; } else { $start *= 1; } // build query_string // query_joomla_component (joomla) if ($this->query_joomla_component) { $query_string = '&option=' . $this->query_joomla_component; } // navigation $query_string .= '&start=' . $start; // sorting $query_string .= '&ad=' . $_GET['ad'] . '&sort=' . $_GET['sort']; // searching $query_string .= '&s=' . $_GET['s'] . '&f=' . $_GET['f']; //table $query_string .= '&table=' . $_GET['table'] . ''; # search if ($_GET['s'] && $_GET['f']) { $in_search = addslashes(stripslashes($_GET['s'])); $in_search_field = $_GET['f']; if ($in_search_field == $this->primary_key) { $where_search = "WHERE {$in_search_field} = '{$in_search}' "; } else { $where_search = "WHERE {$in_search_field} LIKE '%{$in_search}%' "; } } # select $sql = "SELECT * FROM `{$this->table}` {$where_search} {$order_by}"; /* * if sorting by distance */ if ($_GET['sort'] && $_GET['sort'] == "distance") { if ($_GET['ad'] == 'a') { $asc_des = 'DESC'; } if ($_GET['ad'] == 'd') { $asc_des = 'ASC'; } // figure out what coords to calculate from $usable_coords = usable_coords(); $rusex = $usable_coords["x"]; $rusey = $usable_coords["y"]; $rusez = $usable_coords["z"]; $res2 = mysqli_query($GLOBALS["___mysqli_ston"], "\tSHOW COLUMNS\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `{$this->table}`") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__); while ($rij3 = mysqli_fetch_assoc($res2)) { $fields[] = $this->table . '.' . $rij3["Field"]; } $fieldss = join(",", $fields); if ($asc_des == "DESC") { $order_by = "ORDER BY -(sqrt(pow((ritem_coordx-(" . $rusex . ")),2)+pow((ritem_coordy-(" . $rusey . ")),2)+pow((ritem_coordz-(" . $rusez . ")),2)))" . $asc_des; } else { $order_by = "ORDER BY sqrt(pow((ritem_coordx-(" . $rusex . ")),2)+pow((ritem_coordy-(" . $rusey . ")),2)+pow((ritem_coordz-(" . $rusez . ")),2)) DESC"; } if ($this->table == "edtb_systems") { $sql = "SELECT " . $fieldss . ",edtb_systems.x AS ritem_coordx,\n\t\t\t\t\t\t\t\t\t\t\t\tedtb_systems.y AS ritem_coordy,\n\t\t\t\t\t\t\t\t\t\t\t\tedtb_systems.z AS ritem_coordz\n\t\t\t\t\t\t\t\t\t\t\t\tFROM {$this->table}\n\t\t\t\t\t\t\t\t\t\t\t\t{$order_by}"; } elseif ($this->table == "edtb_stations") { $sql = "SELECT " . $fieldss . ",edtb_systems.x AS ritem_coordx,\n\t\t\t\t\t\t\t\t\t\t\t\tedtb_systems.y AS ritem_coordy,\n\t\t\t\t\t\t\t\t\t\t\t\tedtb_systems.z AS ritem_coordz\n\t\t\t\t\t\t\t\t\t\t\t\tFROM {$this->table}\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN edtb_systems ON {$this->table}.system_id = edtb_systems.id\n\t\t\t\t\t\t\t\t\t\t\t\t{$order_by}"; } else { $sql = "SELECT " . $fieldss . ",IFNULL(edtb_systems.x, user_systems_own.x) AS ritem_coordx,\n\t\t\t\t\t\t\t\t\t\t\t\tIFNULL(edtb_systems.y, user_systems_own.y) AS ritem_coordy,\n\t\t\t\t\t\t\t\t\t\t\t\tIFNULL(edtb_systems.z, user_systems_own.z) AS ritem_coordz\n\t\t\t\t\t\t\t\t\t\t\t\tFROM {$this->table}\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN edtb_systems ON {$this->table}.system_name = edtb_systems.name\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN user_systems_own ON {$this->table}.system_name = user_systems_own.name\n\t\t\t\t\t\t\t\t\t\t\t\t{$order_by}"; } //write_log($sql); } $result = mysqli_query($GLOBALS["___mysqli_ston"], $sql); # navigation 2/3 $hits_total = mysqli_num_rows($result); $sql .= " LIMIT {$start}, {$this->num_rows_list_view}"; $result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__); if (mysqli_num_rows($result) > 0) { $result2 = mysqli_query($GLOBALS["___mysqli_ston"], "SHOW COLUMNS FROM `{$this->table}`") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__); while ($rij2 = mysqli_fetch_assoc($result2)) { extract($rij2); $field_type[$Field] = $Type; } $count = 0; while ($rij = mysqli_fetch_assoc($result)) { $count++; $this_row = ''; if ($background == '#38484F') { $background = '#273238'; } else { $background = '#38484F'; } $dist = false; $dist1 = false; $exact = ""; $d_x = ""; $d_y = ""; $d_z = ""; if (array_key_exists("x", $rij) && array_key_exists("y", $rij) && array_key_exists("z", $rij) || array_key_exists("system_name", $rij) || array_key_exists("system_id", $rij)) { $dist = true; $dist1 = true; if (isset($rij["x"]) && isset($rij["y"]) && isset($rij["z"])) { $d_x = $rij["x"]; $d_y = $rij["y"]; $d_z = $rij["z"]; } elseif (isset($rij["system_id"])) { $sys_res = mysqli_query($GLOBALS["___mysqli_ston"], "\tSELECT x, y, z\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM edtb_systems\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE id = '" . $rij["system_id"] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1"); $found = mysqli_num_rows($sys_res); if ($found > 0) { $sys_arr = mysqli_fetch_assoc($sys_res); $d_x = $sys_arr["x"]; $d_y = $sys_arr["y"]; $d_z = $sys_arr["z"]; } } elseif (isset($rij["system_name"]) || $found == 0) { if (valid_coordinates($rij["ritem_coordx"], $rij["ritem_coordy"], $rij["ritem_coordz"])) { $d_x = $rij["ritem_coordx"]; $d_y = $rij["ritem_coordy"]; $d_z = $rij["ritem_coordz"]; } else { $sys_res = mysqli_query($GLOBALS["___mysqli_ston"], "\tSELECT x, y, z\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM edtb_systems\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $rij["system_name"]) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1"); $found = mysqli_num_rows($sys_res); if ($found > 0) { $sys_arr = mysqli_fetch_assoc($sys_res); $d_x = $sys_arr["x"]; $d_y = $sys_arr["y"]; $d_z = $sys_arr["z"]; } else { $sys_own_res = mysqli_query($GLOBALS["___mysqli_ston"], "\tSELECT x, y, z\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM user_systems_own\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $rij["system_name"]) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1"); $own_found = mysqli_num_rows($sys_own_res); if ($own_found > 0) { $sys_own_arr = mysqli_fetch_assoc($sys_own_res); $d_x = $sys_own_arr["x"]; $d_y = $sys_own_arr["y"]; $d_z = $sys_own_arr["z"]; } else { $d_x = ""; $d_y = ""; $d_z = ""; } } } } else { $d_x = ""; $d_y = ""; $d_z = ""; } } $ii = 0; foreach ($rij as $key => $value) { $field_kind = $field_type[$key]; $enum = false; $align = ""; if ($field_kind == "enum('','0','1')" || $field_kind == "enum('0','1')") { $align = "text-align:center;"; $enum = true; } //echo $field_kind; $sort_image = ''; if (in_array($key, $this->fields_in_list_view)) { if ($count == 1) { // show nice text of a value if ($this->show_text[$key]) { $show_key = $this->show_text[$key]; } else { $show_key = $key; } // sorting if ($_GET['sort'] == $key && $_GET['ad'] == 'a') { $sort_image = "<img src='/style/img/sort_a.png' style='width:9px;height:8px;border:none' alt=''>"; $ad = 'd'; } if ($_GET['sort'] == $key && $_GET['ad'] == 'd') { $sort_image = "<img src='/style/img/sort_d.png' style='width:9px;height:8px;border:none' alt=''>"; $ad = 'a'; } // remove sort and ad and add new ones $query_sort = preg_replace('/&(sort|ad)=[^&]*/', '', $query_string) . "&sort={$key}&ad={$ad}"; // if (isset($this->skip)) { if (!in_array($key, $this->skip)) { $head .= "<td style='white-space:nowrap;padding:10px;" . $align . "'><a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_sort}' class='mte_head'>{$show_key}</a> {$sort_image}</td>"; } } else { $head .= "<td style='white-space:nowrap;padding:10px;" . $align . "'><a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_sort}' class='mte_head'>{$show_key}</a> {$sort_image}</td>"; } // add distance if x,y,z are defined if ($dist1 !== false) { if ($_GET['sort'] == "distance" && $_GET['ad'] == 'a') { $sort_image = "<img src='/style/img/sort_a.png' style='width:9px;height:8px;border:none' alt=''>"; $ad = 'd'; } if ($_GET['sort'] == "distance" && $_GET['ad'] == 'd') { $sort_image = "<img src='/style/img/sort_d.png' style='width:9px;height:8px;border:none' alt=''>"; $ad = 'a'; } $query_sort_d = preg_replace('/&(sort|ad)=[^&]*/', '', $query_string) . "&sort=distance&ad={$ad}"; $head .= "<td style='white-space:nowrap;padding:10px'><a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_sort_d}' class='mte_head'>Distance</a> {$sort_image}</td>"; $dist1 = false; } } if ($key == $this->primary_key) { if (substr($this->table, 0, 4) == "edtb") { $buttons = "<td style='width:1%;white-space:nowrap;padding:10px;vertical-align:middle'></td>"; } else { $buttons = "<td style='width:1%;white-space:nowrap;padding:10px;vertical-align:middle'><a href='javascript:void(0)' onclick='del_confirm({$value})' title='Delete {$this->show_text[$key]} {$value}'><img src='/style/img/del.png' style='width:16px;height:16px;border:none' alt=''></a> <a href='?{$query_string}&mte_a=edit&id={$value}' title='Edit {$this->show_text[$key]} {$value}'><img src='/style/img/edit.png' style='width:16px;height:16px;border:none' alt='Edit'></a></td>"; } if ($key == "id" && $this->table == "edtb_systems") { $this_row .= "<td style='width:1%;padding:10px;vertical-align:middle'><a href='/system.php?system_id=" . $value . "'>" . $value . "</a></td>"; } else { $this_row .= "<td style='width:1%;padding:10px;vertical-align:middle'>{$value}</td>"; } } else { if (isset($this->skip)) { if (!in_array($key, $this->skip)) { $this_row .= set_data($key, $value, $d_x, $d_y, $d_z, $dist, $this->table, $enum); } } else { $this_row .= set_data($key, $value, $d_x, $d_y, $d_z, $dist, $this->table, $enum); } } $ii++; } } $rows .= "<tr style='border-bottom:1px solid #000;background:{$background}'>{$buttons} {$this_row}</tr>"; } } else { $head = "<td style='padding:40px'>{$this->text['Nothing_found']}...</td>"; } # navigation 3/3 # remove start= from url $query_nav = preg_replace('/&(start|mte_a|id)=[^&]*/', '', $query_string); # this page $this_page = ($this->num_rows_list_view + $start) / $this->num_rows_list_view; # last page $last_page = ceil($hits_total / $this->num_rows_list_view); # navigatie numbers if ($this_page > 10) { $vanaf = $this_page - 10; } else { $vanaf = 1; } if ($last_page > $this_page + 10) { $tot = $this_page + 10; } else { $tot = $last_page; } for ($f = $vanaf; $f <= $tot; $f++) { $nav_toon = $this->num_rows_list_view * ($f - 1); if ($f == $this_page) { $navigation .= "<td class='mte_nav' style='color:#fffffa;background-color:#808080;font-weight:bold'>{$f}</td> "; } else { $navigation .= "<td class='mte_nav' style='background-color:#0e0e11'><a data-replace='true' data-target='.rightpanel' class='mtelink' href='{$this->url_script}?{$query_nav}&start={$nav_toon}'>{$f}</a></td>"; } } if ($hits_total < $this->num_rows_list_view) { $navigation = ''; } # Previous if if ($this_page > 1) { $last = ($this_page - 1) * $this->num_rows_list_view - $this->num_rows_list_view; $last_page_html = "<a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_nav}&start={$last}' class='mte_nav_prev_next'>{$this->text['Previous']}</a>"; } # Next if: if ($this_page != $last_page && $hits_total > 1) { $next = $start + $this->num_rows_list_view; $next_page_html = "<a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_nav}&start={$next}' class='mte_nav_prev_next'>{$this->text['Next']}</a>"; } $this->nav_bottom = '<span class="right" style="padding-top:6px">Number of entries: '; $this->nav_bottom .= number_format($hits_total); $this->nav_bottom .= '</span>'; if ($navigation) { $nav_table = "\n\t\t\t\t<table style='border-collapse:separate;border-spacing:5px;margin-left:35%;margin-right:auto'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td style='padding-right:6px;vertical-align:middle'>{$last_page_html}</td>\n\t\t\t\t\t\t{$navigation}\n\t\t\t\t\t\t<td style='padding-left:6px;vertical-align:middle'>{$next_page_html}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t"; $this->nav_top = "\n\t\t\t\t<div style='margin-bottom:5px;margin-top:-20px;width:{$this->width_editor}'>\n\t\t\t\t\t\t{$nav_table}\n\t\t\t\t</div>\n\t\t\t"; $this->nav_bottom .= "\n\t\t\t\t<div style='margin-top:20px;width:100%;text-align:center'>\n\t\t\t\t\t\t{$nav_table}\n\t\t\t\t</div>\n\t\t\t"; } # Search form + Add Record button foreach ($this->fields_in_list_view as $option) { if ($this->show_text[$option]) { $show_option = $this->show_text[$option]; } else { $show_option = $option; } if ($option == $in_search_field) { $options .= "<option selected value='{$option}'>{$show_option}</option>"; } else { $options .= "<option value='{$option}'>{$show_option}</option>"; } } $in_search_value = htmlentities(trim(stripslashes($_GET['s'])), ENT_QUOTES); $seach_form = "\n\t\t\t<table style='margin-left:0;padding-left:0;border-collapse:collapse;border-spacing:0'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td style='white-space:nowrap;padding-bottom:20px'>\n\t\t\t\t\t\t<form method=get action='{$this->url_script}'>\n\t\t\t\t\t\t\t<input type='hidden' name='table' value='" . $_GET["table"] . "'>\n\t\t\t\t\t\t\t<select class='selectbox' name='f'>{$options}</select>\n\t\t\t\t\t\t\t<input class='textbox' type='text' name='s' value='{$in_search_value}' style='width:220px'>\n\t\t\t\t\t\t\t<input class='button' type='submit' value='{$this->text['Search']}' style='width:80px'>\n\t\t\t\t"; if ($this->query_joomla_component) { $seach_form .= "<input type='hidden' value='{$this->query_joomla_component}' name='option'>"; } $seach_form .= "</form>"; if ($_GET['s'] && $_GET['f']) { if ($this->query_joomla_component) { $add_joomla = '?option=' . $this->query_joomla_component; } $seach_form .= "<button class='button' style='margin-left:0;margin-top:6px' onclick='window.location=\"{$this->url_script}{$add_joomla}\"' style='margin: 0 0 10px 10px'>{$this->text['Clear_search']}</button>"; } $seach_form .= "\n\t\t\t\t\t</td>\n\n\t\t\t\t\t<td style='text-align:right;width:{$this->width_editor}'>"; if (substr($this->table, 0, 4) != "edtb") { $seach_form .= "<button class='button' onclick='window.location=\"{$this->url_script}?{$query_string}&mte_a=new\"' style='margin: 0 0 10px 10px'>{$this->text['Add_Record']}</button>"; } else { $seach_form .= " "; } $seach_form .= "</td>\n\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t"; // $this->javascript = " // function del_confirm(id) { // if (confirm('{$this->text['Delete']} record {$this->show_text[$this->primary_key]} ' + id + '...?')) { // window.location='$this->url_script?$query_string&mte_a=del&id=' + id // } // } // "; $this->javascript = "\n\t\t\tfunction del_confirm(id) {\n\t\t\t\tif (confirm('{$this->text['Delete']} record {$this->show_text[$this->primary_key]} ' + id + '...?')) {\n\t\t\t\t\twindow.location=window.location.href + '&mte_a=del&id=' + id\n\t\t\t\t}\n\t\t\t}\n\t\t"; # page content $this->content = "\n\t\t\t<div style='width: {$this->width_editor};background:transparent;margin:0;border:none'>{$seach_form}</div>\n\t\t\t<table style='text-align:left;margin:0;border-collapse:collapse;border-spacing:0;width:{$this->width_editor}'>\n\t\t\t\t<tr style='background:#0e0e11; color: #fff'><td></td>{$head}</tr>\n\t\t\t\t{$rows}\n\t\t\t</table>\n\n\t\t\t{$this->nav_bottom}\n\t\t"; }
/** * Parse data for Data Point * * @param string $key field name * @param string $value field value * @param float $d_x x coordinate * @param float $d_y y coordinate * @param float $d_z z coordinate * @param bool $dist * @param string $table table name * @param bool $enum * * @return string $this_row parsed html td tag * @author Mauri Kujala <*****@*****.**> */ function set_data($key, $value, $d_x, $d_y, $d_z, &$dist, $table, $enum) { $this_row = ""; // Regular Expression filter for links $reg_exUrl = "/(http|https|ftp|ftps)\\:\\/\\/[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(\\/\\S*)?/"; $value = $value == "" ? "n/a" : $value; /** * show distances */ if ($dist !== false) { // figure out what coords to calculate from $usable_coords = usable_coords(); $usex = $usable_coords["x"]; $usey = $usable_coords["y"]; $usez = $usable_coords["z"]; $exact = $usable_coords["current"] === true ? "" : " *"; if (valid_coordinates($d_x, $d_y, $d_z)) { $distance = number_format(sqrt(pow($d_x - $usex, 2) + pow($d_y - $usey, 2) + pow($d_z - $usez, 2)), 2); $this_row .= '<td class="datapoint_td" style="white-space:nowrap">' . $distance . $exact . '</td>'; } else { $this_row .= '<td class="datapoint_td">n/a</td>'; } $dist = false; } /** * make a link for systems with an id */ if ($key == "system_id" && $value != "0") { $this_row .= '<td class="datapoint_td">'; $this_row .= '<a href="/System?system_id=' . $value . '">' . $value . '</a>'; $this_row .= '</td>'; } elseif (strpos($key, "system_name") !== false && $value != "0" || $key == "name" && $table == "edtb_systems") { /** * provide crosslinks to screenshot gallery, log page, etc */ $item_crosslinks = System::crosslinks($value); $this_row .= '<td class="datapoint_td">'; $this_row .= '<a href="/System?system_name=' . urlencode($value) . '">' . $value . $item_crosslinks . '</a>'; $this_row .= '</td>'; } elseif (strpos($key, "price") !== false || strpos($key, "ls") !== false || strpos($key, "population") !== false || strpos($key, "distance") !== false) { if (is_numeric($value) && $value != null) { $this_row .= '<td class="datapoint_td">' . number_format($value) . '</td>'; } else { $this_row .= '<td class="datapoint_td">n/a</td>'; } } elseif (preg_match($reg_exUrl, $value, $url)) { if (mb_strlen($value) >= 80) { $urli = substr($value, 0, 80) . "..."; } else { $urli = $value; } $this_row .= '<td class="datapoint_td">'; $this_row .= preg_replace($reg_exUrl, '<a href="' . $url[0] . '" target="_blank">' . $urli . '</a> ', $value); $this_row .= '</td>'; } elseif ($enum !== false) { switch ($value) { case "0": $real_value = '<span class="enum_no">⨯</span>'; break; case "1": $real_value = '<span class="enum_yes">✓</span>'; break; default: $real_value = "n/a"; } $this_row .= '<td class="datapoint_td" style="text-align:center">' . $real_value . '</td>'; } else { $this_row .= '<td class="datapoint_td">' . substr(strip_tags($value), 0, 100) . '</td>'; } /** * parse log entries */ if ($key == "log_entry") { if (mb_strlen($value) >= 100) { $this_row = '<td class="datapoint_td">' . substr(strip_tags($value), 0, 100) . '...</td>'; } else { $this_row = '<td class="datapoint_td">' . $value . '</td>'; } } return $this_row; }
/** * Return distance from current to $system * * @param string|int $system * @param bool $is_id * @return string $distance * @author Mauri Kujala <*****@*****.**> */ function get_distance($system, $is_id = false) { // fetch target coordinates $res = mysqli_query($GLOBALS["___mysqli_ston"], "\t(SELECT\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tedtb_systems.x AS target_x,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tedtb_systems.y AS target_y,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tedtb_systems.z AS target_z\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM edtb_systems\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE edtb_systems.name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $system) . "')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(SELECT\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tuser_systems_own.x AS target_x,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tuser_systems_own.y AS target_y,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tuser_systems_own.z AS target_z\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM user_systems_own\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE user_systems_own.name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $system) . "')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__); $arr = mysqli_fetch_assoc($res); $target_x = $arr["target_x"]; $target_y = $arr["target_y"]; $target_z = $arr["target_z"]; // figure out what coords to calculate from $usable_coords = usable_coords(); $usex = $usable_coords["x"]; $usey = $usable_coords["y"]; $usez = $usable_coords["z"]; $exact = $usable_coords["current"] === true ? "" : " *"; if (valid_coordinates($target_x, $target_y, $target_z)) { $dist = number_format(sqrt(pow($target_x - $usex, 2) + pow($target_y - $usey, 2) + pow($target_z - $usez, 2)), 2); $distance = $dist . ' ly' . $exact; } else { $distance = ''; } return $distance; }
/** * NearestSystems constructor. */ public function __construct() { global $server, $user, $pwd, $db; /** * connect to database */ $this->mysqli = new mysqli($server, $user, $pwd, $db); if ($this->mysqli->connect_errno) { echo "Failed to connect to MySQL: " . $this->mysqli->connect_error; } /** * determine what coordinates to use */ $this->system = isset($_GET["system"]) ? $_GET["system"] + 0 : ""; if (!empty($this->system)) { $query = " SELECT name, id, x, y, z\n FROM edtb_systems\n WHERE id = '{$this->system}'\n LIMIT 1"; $result = $this->mysqli->query($query) or write_log($this->mysqli->error, __FILE__, __LINE__); $sys_obj = $result->fetch_object(); $sys_name = $sys_obj->name; $sys_id = $sys_obj->id; $this->usex = $sys_obj->x; $this->usey = $sys_obj->y; $this->usez = $sys_obj->z; $result->close(); $this->text .= ' (to <a href="/System?system_id=' . $sys_id . '">' . $sys_name . '</a>) '; $this->power_params .= "&system=" . $this->system; $this->allegiance_params .= "&system=" . $this->system; $this->hidden_inputs .= '<input type="hidden" name="system" value="' . $sys_id . '" />'; } elseif (valid_coordinates($curSys["x"], $curSys["y"], $curSys["z"]) && empty($this->system)) { $this->usex = $curSys["x"]; $this->usey = $curSys["y"]; $this->usez = $curSys["z"]; } else { // get last known coordinates $last_coords = last_known_system(); $this->usex = $last_coords["x"]; $this->usey = $last_coords["y"]; $this->usez = $last_coords["z"]; $this->is_unknown = " *"; } /** * If we still don't have valid coordinates, center on Sol */ if (!valid_coordinates($this->usex, $this->usey, $this->usez)) { $this->usex = "0"; $this->usey = "0"; $this->usez = "0"; $this->is_unknown = " *"; } }
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ if (isset($_GET["do"])) { /** @require config */ require_once $_SERVER["DOCUMENT_ROOT"] . "/source/config.inc.php"; /** @require functions */ require_once $_SERVER["DOCUMENT_ROOT"] . "/source/functions.php"; /** @require MySQL */ require_once $_SERVER["DOCUMENT_ROOT"] . "/source/MySQL.php"; $data = json_decode($_REQUEST["input"], true); $p_system = $data["poi_system_name"]; $p_name = $data["poi_name"]; $p_x = $data["poi_coordx"]; $p_y = $data["poi_coordy"]; $p_z = $data["poi_coordz"]; if (valid_coordinates($p_x, $p_y, $p_z)) { $addc = ", x = '" . $p_x . "', y = '" . $p_y . "', z = '" . $p_z . "'"; $addb = ", '" . $p_x . "', '" . $p_y . "', '" . $p_z . "'"; } else { $addc = ", x = null, y = null, z = null"; $addb = ", null, null, null"; } $p_entry = $data["poi_text"]; $p_id = $data["poi_edit_id"]; $category_id = $data["category_id"]; if ($p_id != "") { mysqli_query($GLOBALS["___mysqli_ston"], "\tUPDATE user_poi SET\n\t\t\t\t\t\t\t\t\t\t\t\t\tpoi_name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $p_name) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\tsystem_name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $p_system) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\ttext = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $p_entry) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\tcategory_id = '" . $category_id . "'" . $addc . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE id = '" . $p_id . "'") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__); } elseif (isset($_GET["deleteid"])) { mysqli_query($GLOBALS["___mysqli_ston"], "\tDELETE FROM user_poi\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE id = '" . $_GET["deleteid"] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__); } else { mysqli_query($GLOBALS["___mysqli_ston"], "\tINSERT INTO user_poi (poi_name, system_name, text, category_id, x, y, z)\n\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t('" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $p_name) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $p_system) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $p_entry) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $category_id . "'" . $addb . ")") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__);
$add = ""; $hidden_inputs = ""; // determine what coordinates to use if (!empty($system)) { $sys_res = mysqli_query($GLOBALS["___mysqli_ston"], "\tSELECT name, id, x, y, z\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM edtb_systems\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE id = '" . $system . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__); $sys_arr = mysqli_fetch_assoc($sys_res); $sys_name = $sys_arr["name"]; $sys_id = $sys_arr["id"]; $usex = $sys_arr["x"]; $usey = $sys_arr["y"]; $usez = $sys_arr["z"]; $text .= " (to <a href='system.php?system_id=" . $sys_id . "'>" . $sys_name . "</a>) "; $addtolink .= "&system=" . $system . ""; $addtolink2 .= "&system=" . $system . ""; $hidden_inputs .= '<input type="hidden" name="system" value="' . $sys_id . '" />'; } elseif (valid_coordinates($curSys["x"], $curSys["y"], $curSys["z"]) && empty($system)) { $usex = $curSys["x"]; $usey = $curSys["y"]; $usez = $curSys["z"]; } else { // get last known coordinates $last_coords = last_known_system(); $usex = $last_coords["x"]; $usey = $last_coords["y"]; $usez = $last_coords["z"]; $is_unknown = " *"; } $ship_name = isset($_GET["ship_name"]) ? $_GET["ship_name"] : ""; $facility = isset($_GET["facility"]) ? $_GET["facility"] : ""; $only = isset($_GET["allegiance"]) ? $_GET["allegiance"] : ""; $system_allegiance = isset($_GET["system_allegiance"]) ? $_GET["system_allegiance"] : "";
/** * determine coordinates for the map distance calculations */ if (valid_coordinates($curSys["x"], $curSys["y"], $curSys["z"])) { $ucoordx = $curSys["x"]; $ucoordy = $curSys["y"]; $ucoordz = -$curSys["z"]; } else { // get last known coordinates $last_coords = last_known_system(); $ucoordx = $last_coords["x"]; $ucoordy = $last_coords["y"]; $ucoordz = -$last_coords["z"]; $is_unknown = " *"; } if (!valid_coordinates($ucoordx, $ucoordy, $ucoordz)) { $ucoordx = "0"; $ucoordy = "0"; $ucoordz = "0"; $is_unknown = " *"; } ?> <!-- Three.js --> <script src="/source/Vendor/three.min.js"></script> <!-- ED3D-Galaxy-Map --> <link href="Vendor/ED3D-Galaxy-Map/css/styles.css?ver=<?php echo $settings["edtb_version"]; ?> " rel="stylesheet" type="text/css" /> <script src="Vendor/ED3D-Galaxy-Map/js/ed3dmap.js"></script>
/** * Show records */ private function show_list() { // message after add or edit $this->content_saved = $_SESSION["content_saved"]; $_SESSION["content_saved"] = ""; // default sort (a = ascending) $ad = "a"; if ($_GET["sort"] && in_array($_GET["sort"], $this->fields_in_list_view)) { if ($_GET["ad"] == "a") { $asc_des = "ASC"; } if ($_GET["ad"] == "d") { $asc_des = "DESC"; } $this->order_by = "ORDER by " . $_GET["sort"] . " " . $asc_des; } else { $this->order_by = "ORDER by {$this->primary_key} DESC"; } // navigation 1/3 $start = $_GET["start"]; if (!$start) { $start = 0; } else { $start *= 1; } /** * build query_string */ // navigation $query_string .= "&start=" . $start; // sorting $query_string .= "&ad=" . $_GET["ad"] . "&sort=" . $_GET["sort"]; // searching $query_string .= "&s=" . $_GET["s"] . "&f=" . $_GET["f"]; //table $query_string .= "&table=" . $_GET["table"]; /** * search */ if ($_GET["s"] && $_GET["f"]) { $in_search = addslashes(stripslashes($_GET["s"])); $in_search_field = $_GET["f"]; if ($in_search_field == $this->primary_key) { $this->where_search = "WHERE {$in_search_field} = '{$in_search}' "; } else { $this->where_search = "WHERE {$in_search_field} LIKE '%{$in_search}%' "; } } /** * get sql query */ $sql = $this->get_sql(); $hits = $this->mysqli->query($sql) or write_log($this->mysqli->error, __FILE__, __LINE__); // navigation 2/3 $hits_total = $hits->num_rows; $hits->close(); $sql .= " LIMIT {$start}, {$this->num_rows_list_view}"; $result = $this->mysqli->query($sql) or write_log($this->mysqli->error, __FILE__, __LINE__); if ($result->num_rows > 0) { $query = "SHOW COLUMNS FROM `{$this->table}`"; $cols = $this->mysqli->query($query) or write_log($this->mysqli->error, __FILE__, __LINE__); while ($obj = $cols->fetch_object()) { $Field = $obj->Field; $Type = $obj->Type; $field_type[$Field] = $Type; } $cols->close(); $count = 0; while ($data = $result->fetch_object()) { $count++; $this_row = ""; $background = $background == "#38484f" ? "#273238" : "#38484f"; $dist = false; $dist1 = false; $d_x = ""; $d_y = ""; $d_z = ""; $esc_sys_name = $this->mysqli->real_escape_string($data->system_name); if (property_exists($data, "x") && property_exists($data, "y") && property_exists($data, "z") || property_exists($data, "system_name") || property_exists($data, "system_id")) { $dist = true; $dist1 = true; if (isset($data->x) && isset($data->y) && isset($data->z)) { $d_x = $data->x; $d_y = $data->y; $d_z = $data->z; } elseif (isset($data->system_id)) { $query = " SELECT x, y, z\n FROM edtb_systems\n WHERE id = '{$data->system_id}'\n LIMIT 1"; $coord_result = $this->mysqli->query($query); $found = $coord_result->num_rows; if ($found > 0) { $obj = $coord_result->fetch_object(); $d_x = $obj->x; $d_y = $obj->y; $d_z = $obj->z; } $coord_result->close(); } elseif (isset($data->system_name) || $found == 0) { if (valid_coordinates($data->ritem_coordx, $data->ritem_coordy, $data->ritem_coordz)) { $d_x = $data->ritem_coordx; $d_y = $data->ritem_coordy; $d_z = $data->ritem_coordz; } else { $query = " SELECT x, y, z\n FROM edtb_systems\n WHERE name = '{$esc_sys_name}'\n LIMIT 1"; $coord_result = $this->mysqli->query($query); $found = $coord_result->num_rows; if ($found > 0) { $obj = $coord_result->fetch_object(); $d_x = $obj->x; $d_y = $obj->y; $d_z = $obj->z; } else { $query = " SELECT x, y, z\n FROM user_systems_own\n WHERE name = '{$esc_sys_name}'\n LIMIT 1"; $coord_result = $this->mysqli->query($query); $own_found = $coord_result->num_rows; if ($own_found > 0) { $obj = $coord_result->fetch_object(); $d_x = $obj->x; $d_y = $obj->y; $d_z = $obj->z; } else { $d_x = ""; $d_y = ""; $d_z = ""; } } $coord_result->close(); } } else { $d_x = ""; $d_y = ""; $d_z = ""; } } $ii = 0; foreach ($data as $key => $value) { $field_kind = $field_type[$key]; $enum = false; $align = ""; if ($field_kind == "enum('','0','1')" || $field_kind == "enum('0','1')") { $align = "text-align:center;"; $enum = true; } //echo $field_kind; $sort_image = ""; if (in_array($key, $this->fields_in_list_view)) { if ($count == 1) { // show nice text of a value if ($this->show_text[$key]) { $show_key = $this->show_text[$key]; } else { $show_key = $key; } // sorting if ($_GET["sort"] == $key && $_GET["ad"] == "a") { $sort_image = "<img src='/style/img/sort_a.png' style='width:9px;height:8px;border:none' alt='Asc' id='sort_a'>"; $ad = "d"; } if ($_GET["sort"] == $key && $_GET["ad"] == "d") { $sort_image = "<img src='/style/img/sort_d.png' style='width:9px;height:8px;border:none' alt='Desc' id='sort_d'>"; $ad = "a"; } // remove sort and ad and add new ones $query_sort = preg_replace('/&(sort|ad)=[^&]*/', '', $query_string) . "&sort={$key}&ad={$ad}"; // if (isset($this->skip)) { if (!in_array($key, $this->skip)) { $head .= "<td style='white-space:nowrap;padding:10px;" . $align . "'><a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_sort}' class='mte_head'>{$show_key}</a> {$sort_image}</td>"; } } else { $head .= "<td style='white-space:nowrap;padding:10px;" . $align . "'><a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_sort}' class='mte_head'>{$show_key}</a> {$sort_image}</td>"; } // add distance if x,y,z are defined if ($dist1 !== false) { if ($_GET["sort"] == "distance" && $_GET["ad"] == "a") { $sort_image = "<img src='/style/img/sort_a.png' style='width:9px;height:8px;border:none' alt=''>"; $ad = "d"; } if ($_GET["sort"] == "distance" && $_GET["ad"] == "d") { $sort_image = "<img src='/style/img/sort_d.png' style='width:9px;height:8px;border:none' alt=''>"; $ad = "a"; } $query_sort_d = preg_replace('/&(sort|ad)=[^&]*/', '', $query_string) . "&sort=distance&ad={$ad}"; $head .= "<td style='white-space:nowrap;padding:10px'><a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_sort_d}' class='mte_head'>Distance</a> {$sort_image}</td>"; $dist1 = false; } } if ($key == $this->primary_key) { if (substr($this->table, 0, 4) == "edtb") { $buttons = "<td style='width:1%;white-space:nowrap;padding:10px;vertical-align:middle'></td>"; } else { $buttons = "<td style='width:1%;white-space:nowrap;padding:10px;vertical-align:middle'><a href='javascript:void(0)' onclick='del_confirm({$value})' class='delete_record' title='Delete {$this->show_text[$key]} {$value}' id='delete_" . $value . "'><img src='/style/img/del.png' style='width:16px;height:16px;border:none' alt='Delete' class='data_point_delete'></a> <a href='?{$query_string}&mte_a=edit&id={$value}' class='edit_record' title='Edit {$this->show_text[$key]} {$value}' id='edit_" . $value . "'><img src='/style/img/edit.png' style='width:16px;height:16px;border:none' alt='Edit' class='data_point_edit'></a></td>"; } if ($key == "id" && $this->table == "edtb_systems") { $this_row .= "<td style='width:1%;padding:10px;vertical-align:middle'><a href='/System?system_id=" . $value . "'>" . $value . "</a></td>"; } else { $this_row .= "<td style='width:1%;padding:10px;vertical-align:middle'>{$value}</td>"; } } else { if (isset($this->skip)) { if (!in_array($key, $this->skip)) { $this_row .= set_data($key, $value, $d_x, $d_y, $d_z, $dist, $this->table, $enum); } } else { $this_row .= set_data($key, $value, $d_x, $d_y, $d_z, $dist, $this->table, $enum); } } $ii++; } } unset($value); $rows .= "<tr style='border-bottom:1px solid #000;background:{$background}'>{$buttons} {$this_row}</tr>"; } } else { $head = "<td style='padding:40px'>{$this->text['Nothing_found']}...</td>"; } // navigation 3/3 // remove start= from url $query_nav = preg_replace('/&(start|mte_a|id)=[^&]*/', '', $query_string); // this page $this_page = ($this->num_rows_list_view + $start) / $this->num_rows_list_view; // last page $last_page = ceil($hits_total / $this->num_rows_list_view); // navigatie numbers if ($this_page > 10) { $vanaf = $this_page - 10; } else { $vanaf = 1; } if ($last_page > $this_page + 10) { $tot = $this_page + 10; } else { $tot = $last_page; } for ($f = $vanaf; $f <= $tot; $f++) { $nav_toon = $this->num_rows_list_view * ($f - 1); if ($f == $this_page) { $navigation .= "<td class='mte_nav' style='color:#fffffa;background-color:#808080;font-weight:700'>{$f}</td> "; } else { $navigation .= "<td class='mte_nav' style='background-color:#0e0e11'><a data-replace='true' data-target='.rightpanel' class='mtelink' href='{$this->url_script}?{$query_nav}&start={$nav_toon}'>{$f}</a></td>"; } } if ($hits_total < $this->num_rows_list_view) { $navigation = ""; } // Previous if if ($this_page > 1) { $last = ($this_page - 1) * $this->num_rows_list_view - $this->num_rows_list_view; $last_page_html = "<a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_nav}&start={$last}' class='mte_nav_prev_next'>{$this->text['Previous']}</a>"; } // Next if: if ($this_page != $last_page && $hits_total > 1) { $next = $start + $this->num_rows_list_view; $next_page_html = "<a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_nav}&start={$next}' class='mte_nav_prev_next'>{$this->text['Next']}</a>"; } $this->nav_bottom = '<span class="right" style="padding-top:6px">Number of entries: '; $this->nav_bottom .= number_format($hits_total); $this->nav_bottom .= "</span>"; if ($navigation) { $nav_table = "\n <table style='border-collapse:separate;border-spacing:5px;margin-left:35%;margin-right:auto'>\n <tr>\n <td style='padding-right:6px;vertical-align:middle'>{$last_page_html}</td>\n {$navigation}\n <td style='padding-left:6px;vertical-align:middle'>{$next_page_html}</td>\n </tr>\n </table>\n "; $this->nav_top = "\n <div style='margin-bottom:5px;margin-top:-20px;width:{$this->width_editor}'>\n {$nav_table}\n </div>\n "; $this->nav_bottom .= "\n <div style='margin-top:20px;width:100%;text-align:center'>\n {$nav_table}\n </div>\n "; } /** * Search form + Add Record button */ foreach ($this->fields_in_list_view as $option) { $show_option = $this->show_text[$option] ? $this->show_text[$option] : $option; $options .= $option == $in_search_field ? '<option selected value="' . $option . '">' . $show_option . '</option>' : '<option value="' . $option . '">' . $show_option . '</option>'; } unset($option); $in_search_value = htmlentities(trim(stripslashes($_GET["s"])), ENT_QUOTES); $seach_form = "\n <table style='margin-left:0;padding-left:0;border-collapse:collapse;border-spacing:0;width:100%'>\n <tr>\n <td style='white-space:nowrap;padding-bottom:20px'>\n <form method=get action='{$this->url_script}' id='search_form'>\n <input type='hidden' name='table' value='" . $_GET["table"] . "'>\n <select class='selectbox' name='f'>{$options}</select>\n <input class='textbox' type='text' name='s' value='{$in_search_value}' style='width:220px'>\n <input class='button' type='submit' value='{$this->text['Search']}' style='width:80px'>\n "; $seach_form .= "</form>"; if ($_GET["s"] && $_GET["f"]) { $seach_form .= "<button class='button button_clear' onclick='window.location=\"{$this->url_script}\"' style='margin: 0 0 10px 10px'>{$this->text['Clear_search']}</button>"; } $seach_form .= ' </td> <td style="text-align:right">'; if (substr($this->table, 0, 4) != "edtb") { $seach_form .= "<button class='button button_add' onclick='window.location=\"{$this->url_script}?{$query_string}&mte_a=new\"' style='margin: 0 0 10px 10px'>{$this->text['Add_Record']}</button>"; } else { $seach_form .= " "; } $seach_form .= "</td>\n\n </tr>\n </table>\n "; $this->javascript = "\n function del_confirm(id) {\n if (confirm('{$this->text['Delete']} record {$this->show_text[$this->primary_key]} ' + id + '...?')) {\n window.location=window.location.href + '&mte_a=del&id=' + id\n }\n }\n "; // page content $this->content = "\n <div style='width: {$this->width_editor};background:transparent;margin:0;border:none'>{$seach_form}</div>\n <table style='text-align:left;margin:0;border-collapse:collapse;border-spacing:0;width:{$this->width_editor}'>\n <tr style='background:#0e0e11; color: #fff'><td></td>{$head}</tr>\n {$rows}\n </table>\n\n {$this->nav_bottom}\n "; }
/** * Add, update or delete poi from the database * * @param object $data */ public function add_poi($data) { $p_system = $data->{"poi_system_name"}; $p_name = $data->{"poi_name"}; $p_x = $data->{"poi_coordx"}; $p_y = $data->{"poi_coordy"}; $p_z = $data->{"poi_coordz"}; if (valid_coordinates($p_x, $p_y, $p_z)) { $addc = ", x = '{$p_x}', y = '{$p_y}', z = '{$p_z}'"; $addb = ", '{$p_x}', '{$p_y}', '{$p_z}'"; } else { $addc = ", x = null, y = null, z = null"; $addb = ", null, null, null"; } $p_entry = $data->{"poi_text"}; $p_id = $data->{"poi_edit_id"}; $category_id = $data->{"category_id"}; $esc_name = $this->mysqli->real_escape_string($p_name); $esc_sysname = $this->mysqli->real_escape_string($p_system); $esc_entry = $this->mysqli->real_escape_string($p_entry); if ($p_id != "") { $stmt = " UPDATE user_poi SET\n poi_name = '{$esc_name}',\n system_name = '{$esc_sysname}',\n text = '{$esc_entry}',\n category_id = '{$category_id}'" . $addc . "\n WHERE id = '{$p_id}'"; } elseif (isset($_GET["deleteid"])) { $stmt = " DELETE FROM user_poi\n WHERE id = '" . $_GET["deleteid"] . "'\n LIMIT 1"; } else { $stmt = " INSERT INTO user_poi (poi_name, system_name, text, category_id, x, y, z, added_on)\n VALUES\n ('{$esc_name}',\n '{$esc_sysname}',\n '{$esc_entry}',\n '{$category_id}'" . $addb . ",\n UNIX_TIMESTAMP())"; } $this->mysqli->query($stmt) or write_log($this->mysqli->error, __FILE__, __LINE__); }