Example #1
0
/**
 * 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">&#10799;</span>';
                break;
            case "1":
                $real_value = '<span class="enum_yes">&#10003;</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;
}
Example #2
0
File: coord.php Project: DBnR1/EDTB
        $reference_2 = explode(",", $reference_2_coordinates);
        $reference_3 = explode(",", $reference_3_coordinates);
        $reference_4 = explode(",", $reference_4_coordinates);
        $system1 = array($reference_1[0], $reference_1[1], $reference_1[2], $reference_1_distance);
        $system2 = array($reference_2[0], $reference_2[1], $reference_2[2], $reference_2_distance);
        $system3 = array($reference_3[0], $reference_3[1], $reference_3[2], $reference_3_distance);
        $system4 = array($reference_4[0], $reference_4[1], $reference_4[2], $reference_4_distance);
        $coords_calc = new Trilateration();
        $newcoords = $coords_calc->trilateration3d($system1, $system2, $system3, $system4);
        $newcoords_x = $newcoords[0];
        $newcoords_y = $newcoords[1];
        $newcoords_z = $newcoords[2];
        $esc_target_system = $mysqli->real_escape_string($target_system);
        $esc_reference_distances = $mysqli->real_escape_string($reference_distances);
        $esc_edsm_msg = $mysqli->real_escape_string($edsm_msg);
        $system_exists = System::exists($target_system, true);
        if (!$system_exists) {
            $stmt = "   INSERT INTO user_systems_own\n                        (name, x, y, z, reference_distances, edsm_message)\n                        VALUES\n                        ('{$esc_target_system}',\n                        '{$newcoords_x}',\n                        '{$newcoords_y}',\n                        '{$newcoords_z}',\n                        '{$esc_reference_distances}',\n                        '{$esc_edsm_msg}')";
        } else {
            $stmt = "   UPDATE user_systems_own\n                        SET name = '{$esc_target_system}',\n                            x = '{$newcoords_x}',\n                            y = '{$newcoords_y}',\n                            z = '{$newcoords_z}',\n                            reference_distances = '{$esc_reference_distances}',\n                            edsm_message = '{$esc_edsm_msg}'\n                        WHERE name = '{$esc_target_system}'\n                        LIMIT 1";
        }
        $mysqli->query($stmt) or write_log($mysqli->error, __FILE__, __LINE__);
    } else {
        write_log("Error: Distances not numeric or all distances not given.", __FILE__, __LINE__);
    }
    exit;
}
?>
<script>
    var clipboard = new Clipboard(".btn");
Example #3
0
    /**
     * Display the results
     *
     * @param mysqli_result $main_result
     */
    private function results($main_result)
    {
        $count = $main_result->num_rows;
        if ($count > 0) {
            $last_system = "";
            $ii = 0;
            $tdclass = "";
            while ($obj = $main_result->fetch_object()) {
                $system = $obj->system;
                $system_id = $obj->system_id;
                $sys_population = number_format($obj->population);
                $sys_economy = empty($obj->economy) ? "n/a" : $obj->economy;
                $sys_government = $obj->government;
                $sys_security = empty($obj->security) ? "None" : $obj->security;
                $allegiance = $obj->allegiance;
                $station_name = $obj->station_name;
                /**
                 * provide crosslinks to screenshot gallery, log page, etc
                 */
                $ns_crosslinks = System::crosslinks($system);
                $ss_coordx = $obj->coordx;
                $ss_coordy = $obj->coordy;
                $ss_coordz = $obj->coordz;
                $distance = sqrt(pow($ss_coordx - $this->usex, 2) + pow($ss_coordy - $this->usey, 2) + pow($ss_coordz - $this->usez, 2));
                /**
                 * get allegiance icon for system
                 */
                $pic = get_allegiance_icon($allegiance);
                if ($system != $last_system) {
                    $tdclass = $tdclass == "light" ? "dark" : "light";
                    ?>
                    <tr>
                    <td class="<?php 
                    echo $tdclass;
                    ?>
" style="text-align:center">
                        <img src="/style/img/<?php 
                    echo $pic;
                    ?>
" class="allegiance_icon"
                             alt="<?php 
                    echo $allegiance;
                    ?>
" style="margin:0"/>
                    </td>
                    <td class="<?php 
                    echo $tdclass;
                    ?>
">
                        <?php 
                    echo number_format($distance, 2);
                    ?>
 ly<?php 
                    echo $this->is_unknown;
                    ?>
                    </td>
                    <td class="<?php 
                    echo $tdclass;
                    ?>
">
                        <a class="send" href="javascript:void(0)" data-send="<?php 
                    echo $system;
                    ?>
"
                           data-id="<?php 
                    echo $system_id;
                    ?>
">
                            <img class="icon" src="/style/img/magic.png" alt="Send"
                                 style="margin-bottom:7px;margin-right:0"
                                 onmouseover="to_view('sysinfo', event)"
                                 onmouseout="$('#sysinfo').fadeToggle('fast')"/>
                        </a>
                        <a href="/System?system_id=<?php 
                    echo $system_id;
                    ?>
">
                            <?php 
                    echo $system;
                    ?>
                        </a>
                        <?php 
                    echo $ns_crosslinks;
                    ?>
                    </td>
                    <td class="<?php 
                    echo $tdclass;
                    ?>
"><?php 
                    echo $sys_population;
                    ?>
</td>
                    <td class="<?php 
                    echo $tdclass;
                    ?>
"><?php 
                    echo $sys_economy;
                    ?>
</td>
                    <td class="<?php 
                    echo $tdclass;
                    ?>
"><?php 
                    echo $sys_government;
                    ?>
</td>
                    <td class="<?php 
                    echo $tdclass;
                    ?>
"><?php 
                    echo $sys_security;
                    ?>
</td>
                    <?php 
                } else {
                    ?>
                    <tr>
                    <td class="transparent" colspan="7" style="height:45px">&nbsp;</td>
                    <?php 
                }
                /**
                 * display station info if necessary
                 */
                if (!empty($station_name)) {
                    $this->station_info($station_name, $obj, $tdclass);
                }
                ?>
                </tr>
                <?php 
                $last_system = $system;
                $ii++;
            }
            // end of while
        } else {
            $colspan = $this->stations !== false ? "10" : "7";
            ?>
            <tr>
                <td class="light" colspan="<?php 
            echo $colspan;
            ?>
">None found!</td>
            </tr>
            <?php 
        }
    }
Example #4
0
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */
/** @require functions */
require_once $_SERVER["DOCUMENT_ROOT"] . "/source/functions.php";
/** @require MySQL */
require_once $_SERVER["DOCUMENT_ROOT"] . "/source/MySQL.php";
use EDTB\source\System;
$system = isset($_GET["system"]) ? $_GET["system"] : "";
if (empty($system)) {
    exit;
}
$esc_system = $mysqli->real_escape_string($system);
/**
 * check if system has screenshots
 */
$screenshots = System::has_screenshots($system) ? '<a href="/Gallery?spgmGal=' . urlencode(strip_invalid_dos_chars($system)) . '" title="View image gallery"><img src="/style/img/image.png" alt="Gallery" class="icon" style="margin-left:5px;vertical-align:top" /></a>' : "";
/**
 * check if system is in the bookmarks
 */
$query = "  SELECT user_bookmarks.comment, user_bookmarks.added_on\n            FROM user_bookmarks\n            WHERE user_bookmarks.system_name = '{$esc_system}'\n            LIMIT 1";
$result = $mysqli->query($query) or write_log($mysqli->error, __FILE__, __LINE__);
$count2 = $result->num_rows;
if ($count2 > 0) {
    $obj = $result->fetch_object();
    $comment = $obj->comment;
    $added_on = $obj->added_on;
    if ($comment != "") {
        echo 'Bookmark comment: ' . $comment . ' - ';
    }
    echo 'Bookmark added: ' . get_timeago($added_on, false);
    echo '<br />';
Example #5
0
File: spgm.php Project: DBnR1/EDTB
function spgm_DisplayGalleryHierarchy($strGalleryId, $iGalleryDepth, $strFilterFlags)
{
    global $spgm_cfg;
    $strPathToGallery = DIR_GAL . $strGalleryId;
    spgm_Trace('<p>function spgm_DisplayGalleryHierarchy</p>' . "\n" . 'strGalleryId: ' . $strGalleryId . '<br />' . "\n" . 'iGalleryDepth: ' . $iGalleryDepth . '<br />' . "\n" . 'strFilterFlags: ' . $strFilterFlags . '<br />' . "\n" . 'strPathToGallery: ' . $strPathToGallery . '<br />' . "\n");
    $strHtmlOffset = '';
    // check for super gallery.
    if ($strGalleryId == '') {
        $strPathToSuperGallery = '';
    } else {
        $strPathToSuperGallery = $strGalleryId . '/';
        for ($i = 0; $i < $iGalleryDepth; $i++) {
            $strHtmlOffset .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
        }
    }
    # 'new' label tuning according to the actual new item
    if ($spgm_cfg['theme']['newItemIcon'] != '') {
        $strHtmlNewGallery = $spgm_cfg['theme']['newItemIcon'];
        $strHtmlNewPictures = $spgm_cfg['theme']['newItemIcon'];
        $strNewPicture = $spgm_cfg['theme']['newItemIcon'];
    } else {
        $strHtmlSpanNewItem = '<span style="color: #ffd600">';
        $strHtmlNewGallery = $strHtmlSpanNewItem . $spgm_cfg['locale']['newGallery'] . '</span>';
        $strHtmlNewPictures = $strHtmlSpanNewItem . $spgm_cfg['locale']['newPictures'] . '</span>';
        $strNewPicture = $strHtmlSpanNewItem . $spgm_cfg['locale']['newPicture'] . '</span>';
    }
    $arrSubGalleryFilenames = spgm_CreateGalleryArray($strGalleryId, true);
    $_max = count($arrSubGalleryFilenames);
    if ($iGalleryDepth == 1 && $_max > 0) {
        echo '<table class="' . CLASS_TABLE_GALLISTING_GRID . '">' . "\n";
        echo '<tr>' . "\n";
    }
    for ($i = 0; $i < $_max; $i++) {
        $strGalleryName = $arrSubGalleryFilenames[$i];
        //**
        $strPathToSubGallery = $strPathToSuperGallery . $strGalleryName;
        //**
        $strPathToGalleryTitle = $strPathToGallery . '/' . $strGalleryName . '/' . FILE_GAL_TITLE;
        $strGalleryThumbnailBasename = DIR_GAL . urlencode($strPathToSuperGallery) . PREF_THUMB . urlencode($strGalleryName);
        $strHtmlGalleryName = '';
        if (spgm_CheckPerms($strPathToGalleryTitle)) {
            $arrTitle = file($strPathToGalleryTitle);
            $strHtmlGalleryName = $arrTitle[0];
        } else {
            $strHtmlGalleryName = str_replace('_', ' ', $strGalleryName);
        }
        $arrPictureFilenames = spgm_CreatePictureArray($strPathToSubGallery, '', false);
        // no filter is provided to get all the pictures
        $arrGalleryInfo = spgm_GetGalleryInfo($strPathToSubGallery, $arrPictureFilenames);
        $iPictureNumber = $arrGalleryInfo[0];
        $iNewPictureNumber = $arrGalleryInfo[1];
        $strRandomPictureFilename = $arrGalleryInfo[2];
        // should never happen
        if ($iPictureNumber < 0 || $iNewPictureNumber < 0) {
            spgm_Error('Error while generating gallery ' . ERRMSG_INVALID_NUMBER_OF_PICTURES);
        } else {
            if ($spgm_cfg['conf']['thumbnailsPerPage'] > 0) {
                $strUrlParamPage = '&amp;' . PARAM_NAME_PAGE . '=1';
            }
            if ($iPictureNumber == 0) {
                $strHtmlPictureNumber = '';
            } else {
                if ($iPictureNumber > 1) {
                    $strHtmlPictureNumber = '&nbsp;&nbsp;[' . $iPictureNumber . ' ' . $spgm_cfg['locale']['pictures'];
                } else {
                    $strHtmlPictureNumber = '&nbsp;&nbsp;[' . $iPictureNumber . ' ' . $spgm_cfg['locale']['picture'];
                }
                $bAllPicturesNew = $iPictureNumber == $iNewPictureNumber;
                if ($bAllPicturesNew) {
                    $strHtmlPictureNumber = $strHtmlNewGallery . ' ' . $strHtmlPictureNumber;
                }
                if ($iNewPictureNumber > 0 && !$bAllPicturesNew) {
                    $strHtmlPictureNumber .= ' - ' . $iNewPictureNumber . ' ';
                    $filters = '';
                    if ($spgm_cfg['global']['propagateFilters']) {
                        $filters = str_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags);
                    }
                    if (!strstr($strFilterFlags, PARAM_VALUE_FILTER_NEW)) {
                        $filters .= PARAM_VALUE_FILTER_NEW;
                    }
                    if ($iNewPictureNumber == 1) {
                        $strHtmlPictureNumber .= spgm_BuildLink($strNewPicture, '', '', $strPathToSubGallery, -1, -1, $filters);
                    } else {
                        $strHtmlPictureNumber .= spgm_BuildLink($strHtmlNewPictures, '', '', $strPathToSubGallery, -1, -1, $filters);
                    }
                }
                $strHtmlPictureNumber .= ']';
            }
            if ($iGalleryDepth <= 1) {
                if ($i % $spgm_cfg['conf']['galleryListingCols'] == 0 && $i != 0) {
                    echo '      </tr>' . "\n" . '      <tr>' . "\n";
                }
                echo '  <td class="' . CLASS_TD_GALLISTING_CELL . '">' . "\n";
            }
            echo '  <table class="' . CLASS_TABLE_GALITEM . '">' . "\n";
            echo '      <tr>' . "\n";
            // display the gallery icon
            $iRowSpan = $spgm_cfg['conf']['galleryCaptionPos'] == BOTTOM ? 1 : 2;
            echo '      <td rowspan="' . $iRowSpan . '" style="vertical-align:top" class="' . CLASS_TD_GALITEM_ICON . '">' . "\n";
            if ($strHtmlOffset != '') {
                echo '      ' . $strHtmlOffset . "\n";
            }
            // look for the icon...
            $strHtmlIcon = '';
            $bNeedDropShadows = true;
            // only default icons don't need them
            // find out if there is a fixed thumbnail
            $bGalleryThumbnailFound = false;
            $iSupportedExtensionNumber = count($spgm_cfg['global']['supportedExtensions']);
            for ($j = 0; $j < $iSupportedExtensionNumber; $j++) {
                $strGalleryThumbnailFilename = $strGalleryThumbnailBasename . $spgm_cfg['global']['supportedExtensions'][$j];
                if (spgm_CheckPerms($strGalleryThumbnailFilename)) {
                    $arrPictureSize = getimagesize($strGalleryThumbnailFilename);
                    $strHtmlIcon = '<img src="' . $strGalleryThumbnailFilename . '" width="';
                    $strHtmlIcon .= $arrPictureSize[0] . '" height="' . $arrPictureSize[1];
                    $strHtmlIcon .= '" alt="" class="' . CLASS_IMG_GALICON . '" />';
                    $bGalleryThumbnailFound = true;
                    break;
                }
            }
            if (!$bGalleryThumbnailFound) {
                // random thumbnails are used
                if ($strRandomPictureFilename != '') {
                    if (defined('DIR_THUMBS')) {
                        $strGalleryThumbnailFilename = DIR_GAL . $strPathToSubGallery . '/' . DIR_THUMBS;
                        $strGalleryThumbnailFilename .= PREF_THUMB . $strRandomPictureFilename;
                    } else {
                        $strGalleryThumbnailFilename = DIR_GAL . $strPathToSubGallery . '/';
                        $strGalleryThumbnailFilename .= PREF_THUMB . $strRandomPictureFilename;
                    }
                    $arrPictureSize = getimagesize($strGalleryThumbnailFilename);
                    if ($spgm_cfg['conf']['galleryIconHeight'] != ORIGINAL_SIZE) {
                        $strHtmlHeight = 'height="' . $spgm_cfg['conf']['galleryIconHeight'] . '"';
                    } else {
                        if ($spgm_cfg['conf']['galleryIconWidth'] != ORIGINAL_SIZE) {
                            $iHeight = (int) $arrPictureSize[1] * ($spgm_cfg['conf']['galleryIconWidth'] / $arrPictureSize[0]);
                            $strHtmlHeight = 'height="' . $iHeight . '"';
                        } else {
                            $strHtmlHeight = 'height="' . $arrPictureSize[1] . '"';
                        }
                    }
                    if ($spgm_cfg['conf']['galleryIconWidth'] != ORIGINAL_SIZE) {
                        $strHtmlWidth = 'width="' . $spgm_cfg['conf']['galleryIconWidth'] . '"';
                    } else {
                        if ($spgm_cfg['conf']['galleryIconHeight'] != ORIGINAL_SIZE) {
                            $iWidth = (int) $arrPictureSize[0] * ($spgm_cfg['conf']['galleryIconHeight'] / $arrPictureSize[1]);
                            $strHtmlWidth = 'width="' . $iWidth . '"';
                        } else {
                            $strHtmlWidth = 'width="' . $arrPictureSize[0] . '"';
                        }
                    }
                    $strHtmlIcon = '<img src="' . $strGalleryThumbnailFilename . '" ';
                    $strHtmlIcon .= $strHtmlHeight . ' ' . $strHtmlWidth . ' alt="" class="';
                    $strHtmlIcon .= CLASS_IMG_GALICON . '" />';
                } else {
                    $bNeedDropShadows = false;
                    if ($spgm_cfg['conf']['galleryIconType'] == GALICON_NONE) {
                        $fnameGalleryIcon = $spgm_cfg['theme']['gallerySmallIcon'];
                    } else {
                        $fnameGalleryIcon = $spgm_cfg['theme']['galleryBigIcon'];
                    }
                    $strHtmlIcon = $fnameGalleryIcon != '' ? $fnameGalleryIcon : '&raquo;';
                }
            }
            // display the link
            if ($bNeedDropShadows == true) {
                spgm_DropShadowsBeginWrap();
            }
            $filters = '';
            if ($spgm_cfg['global']['propagateFilters']) {
                $filters = str_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', str_replace(PARAM_VALUE_FILTER_NEW, '', $strFilterFlags));
            }
            echo '          ' . spgm_BuildLink($strHtmlIcon, CLASS_TD_GALITEM_TITLE, '', $strPathToSubGallery, -1, -1, $filters) . "\n";
            if ($bNeedDropShadows == true) {
                spgm_DropShadowsEndWrap();
            }
            echo '      </td>' . "\n";
            if ($spgm_cfg['conf']['galleryCaptionPos'] == BOTTOM) {
                echo '      </tr>' . "\n" . '      <tr>' . "\n";
            }
            /**
             * provide crosslinks to screenshot gallery, log page, etc
             */
            $g2_crosslinks = System::crosslinks($strHtmlGalleryName, false, false);
            // display the gallery title
            echo '      <td class="' . CLASS_TD_GALITEM_TITLE . '">' . "\n";
            echo '          ' . spgm_BuildLink($strHtmlGalleryName, CLASS_TD_GALITEM_TITLE, '', $strPathToSubGallery, -1, -1, $filters);
            echo ' ' . $g2_crosslinks . $strHtmlPictureNumber . ' ' . "\n";
            echo '      </td>' . "\n";
            echo '      </tr>' . "\n";
            // display the gallery caption
            echo '      <tr>' . "\n";
            echo '      <td class="' . CLASS_TD_GALITEM_CAPTION . '">' . "\n";
            $strPathToGalleryCaption = $strPathToGallery . '/' . $strGalleryName . '/' . FILE_GAL_CAPTION;
            if (spgm_CheckPerms($strPathToGalleryCaption)) {
                // check perms
                echo '          ';
                include $strPathToGalleryCaption;
            }
            echo '      </td>' . "\n";
            echo '      </tr>' . "\n";
            echo '  </table>' . "\n";
        }
        // TODO check this: one test ?
        if ($spgm_cfg['conf']['subGalleryLevel'] == 0) {
            spgm_DisplayGalleryHierarchy($strPathToSubGallery, $iGalleryDepth + 1, $strFilterFlags);
        } elseif ($iGalleryDepth < $spgm_cfg['conf']['subGalleryLevel'] - 1) {
            spgm_DisplayGalleryHierarchy($strPathToSubGallery, $iGalleryDepth + 1, $strFilterFlags);
        }
        if ($iGalleryDepth <= 1) {
            echo '  </td>' . "\n";
        }
    }
    // endfor
    if ($iGalleryDepth == 1 && $_max > 0) {
        echo ' </tr>' . "\n";
        echo '</table>' . "\n";
    }
}
Example #6
0
 /**
  * Make log entries
  *
  * @param \mysqli_result $log_res
  * @param string $type
  * @return string $logdata
  * @author Mauri Kujala <*****@*****.**>
  */
 public function make_log_entries($log_res, $type)
 {
     $this_system = "";
     $this_id = "";
     $i = 0;
     while ($obj = $log_res->fetch_object()) {
         if ($this_id != $obj->id) {
             $system_name = $obj->system_name == "" ? $obj->log_system_name : $obj->system_name;
             $log_station_name = $obj->station_name;
             $log_text = $obj->log_entry;
             $date = date_create($obj->stardate);
             $log_added = date_modify($date, "+1286 years");
             $distance = $obj->distance != "" ? number_format($obj->distance, 1) : "";
             if ($this_system != $system_name && $type != "general") {
                 $add = $distance != 0 ? " (distance " . $distance . " ly)" : "";
                 $sortable = "";
                 if ($i == 0 && $type != "log") {
                     $sssort = $this->get_sort("slog");
                     $sortable = '<span class="right">';
                     $sortable .= '<a href="/?slog_sort=' . $sssort . '" title="Sort by date asc/desc">';
                     $sortable .= '<img class="icon" src="/style/img/sort.png" alt="Sort" style="margin-right:0" />';
                     $sortable .= '</a></span>';
                 }
                 /**
                  * provide crosslinks to screenshot gallery, log page, etc
                  */
                 $l_crosslinks = System::crosslinks($system_name, true, false, false);
                 $logdata .= '<header><h2><img class="icon" src="/style/img/system_log.png" alt="log" />';
                 $logdata .= 'System log for <a href="/System?system_name=' . urlencode($system_name) . '">';
                 $logdata .= $system_name;
                 $logdata .= '</a>' . $l_crosslinks . $add . $sortable . '</h2></header>';
                 $logdata .= '<hr>';
             } elseif ($type == "general" && $i == 0) {
                 $gssort = $this->get_sort("glog");
                 $sortable = '<span class="right">';
                 $sortable .= '<a href="/?glog_sort=' . $gssort . '" title="Sort by date asc/desc">';
                 $sortable .= '<img class="icon" src="/style/img/sort.png" alt="Sort" style="margin-right:0" />';
                 $sortable .= '</a></span>';
                 $logdata .= '<header><h2><img class="icon" src="/style/img/log.png" alt="log" />Commander\'s Log' . $sortable . '</h2></header>';
                 $logdata .= '<hr>';
             }
             /**
              * get title icons
              */
             $title_icons = $this->title_icons($obj);
             $log_title = !empty($obj->title) ? '&nbsp;&ndash;&nbsp;' . $obj->title : "";
             $logdata .= '<h3>' . $title_icons;
             $logdata .= '<a href="javascript:void(0)" onclick="toggle_log_edit(\'' . $obj->id . '\')" style="color:inherit" title="Edit entry">';
             $logdata .= date_format($log_added, "j M Y, H:i");
             if (!empty($log_station_name)) {
                 $logdata .= '&nbsp;[Station: ' . htmlspecialchars($log_station_name) . ']';
             }
             $logdata .= $log_title;
             $logdata .= '</a></h3>';
             $logdata .= '<pre class="entriespre" style="margin-bottom:20px">';
             if (!empty($obj->audio)) {
                 $logdata .= $this->get_audio($obj);
             }
             $logdata .= $log_text;
             $logdata .= '</pre>';
         }
         $this_system = $system_name;
         $this_id = $obj->id;
         $i++;
     }
     return $logdata;
 }
Example #7
0
    }
    $rare_result->close();
} else {
    $c_rares_data .= "No rares nearby";
}
$c_rares_data .= "</div>";
/**
 * provide crosslinks to screenshot gallery, log page, etc
 */
$si_crosslinks = System::crosslinks($si_system_name);
if (!System::is_mapped($si_system_name)) {
    $si_crosslinks .= '<a href="/SystemMap/?system=' . urlencode($si_system_name) . '" style="color:inherit" title="Map this system">';
    $si_crosslinks .= '<img src="/style/img/grid_g.png" class="icon" style="margin-left:5px;margin-right:0" />';
    $si_crosslinks .= '</a>';
}
$num_visits = System::num_visits($si_system_name);
if ($actual_num_res > 0 && valid_coordinates($curSys["x"], $curSys["y"], $curSys["z"])) {
    $rare_text = '&nbsp;&nbsp;<span onclick="$(\'#rares\').fadeToggle(\'fast\')">';
    $rare_text .= '<a href="javascript:void(0)" title="Click for more info">[ Rares within ' . $settings["rare_range"] . ' ly: ' . $actual_num_res . ' ]</a>';
    $rare_text .= $c_rares_data . '</span>';
}
$data["si_name"] .= $si_system_display_name . $si_crosslinks;
$data["si_name"] .= '&nbsp;&nbsp;<span style="font-size:11px;text-transform:uppercase;vertical-align:middle">';
$data["si_name"] .= '[ State: ' . $si_system_state . ' - Security: ' . $si_system_security . ' - Visits: ' . $num_visits . ' ]';
$data["si_name"] .= $rare_text . $user_dists . '</span>';
/**
 * station info for System.php
 */
$query = "  SELECT SQL_CACHE *\n            FROM edtb_stations\n            WHERE system_id = '{$si_system_id}'\n            ORDER BY -ls_from_star DESC, name";
$station_result = $mysqli->query($query) or write_log($mysqli->error, __FILE__, __LINE__);
$station_exists = $station_result->num_rows;
Example #8
0
        $sys_short = $curSys["name"];
    }
    echo tts_override($sys_short);
    exit;
}
/**
 * distance to X
 */
if (isset($_GET["dist"])) {
    $to = $_GET["dist"];
    $distance = "";
    $to = str_replace("system", "", $to);
    if (!valid_coordinates($curSys["x"], $curSys["y"], $curSys["z"])) {
        $distance = "How can I calculate distances if I don't even know where we are?";
    } else {
        if (System::exists($to)) {
            $esc_to = $mysqli->real_escape_string($to);
            $query = "  SELECT\n                        sqrt(pow((IFNULL(edtb_systems.x, user_systems_own.x)-(" . $curSys["x"] . ")),2)+pow((IFNULL(edtb_systems.y, user_systems_own.y)-(" . $curSys["y"] . ")),2)+pow((IFNULL(edtb_systems.z, user_systems_own.z)-(" . $curSys["z"] . ")),2))\n                        AS distance\n                        FROM edtb_systems\n                        LEFT JOIN user_systems_own ON edtb_systems.name = user_systems_own.name\n                        WHERE edtb_systems.name = '{$esc_to}'\n                        LIMIT 1";
            $result = $mysqli->query($query) or write_log($mysqli->error, __FILE__, __LINE__);
            $obj = $result->fetch_object();
            $distance = $obj->distance == "" ? "Not available" : number_format($obj->distance, 1);
            $result->close();
        } else {
            $distance = "I'm sorry, I didn't get that.";
        }
    }
    echo $distance;
    exit;
}
/**
 * curSys access, added the cSys variable because VA has oddly short limit on the url
Example #9
0
File: PoiBm.php Project: DBnR1/EDTB
 /**
  * Make items
  *
  * @param object $obj
  * @param string $type
  * @param int $i
  * @return string
  * @author Mauri Kujala <*****@*****.**>
  */
 private function make_item($obj, $type, &$i)
 {
     $item_id = $obj->id;
     $item_text = $obj->text;
     $item_name = $obj->item_name;
     $item_system_name = $obj->system_name;
     $item_system_id = $obj->system_id;
     $item_cat_name = $obj->catname;
     $item_added_on = $obj->added_on;
     $item_added_ago = "";
     if (!empty($item_added_on)) {
         $item_added_ago = get_timeago($item_added_on, false);
         $item_added_on = new \DateTime(date("Y-m-d\\TH:i:s\\Z", $item_added_on + $this->time_difference * 60 * 60));
         $item_added_on = date_modify($item_added_on, "+1286 years");
         $item_added_on = $item_added_on->format("j M Y, H:i");
     }
     $item_coordx = $obj->item_coordx;
     $item_coordy = $obj->item_coordy;
     $item_coordz = $obj->item_coordz;
     $distance = "n/a";
     if (valid_coordinates($item_coordx, $item_coordy, $item_coordz)) {
         $distance = number_format(sqrt(pow($item_coordx - $this->usex, 2) + pow($item_coordy - $this->usey, 2) + pow($item_coordz - $this->usez, 2)), 1) . " ly";
     }
     /**
      * if visited, change border color
      */
     $visited = System::num_visits($item_system_name);
     $style_override = $visited ? ' style="border-left: 3px solid #3da822"' : "";
     $tdclass = $i % 2 ? "dark" : "light";
     /**
      * provide crosslinks to screenshot gallery, log page, etc
      */
     $item_crosslinks = System::crosslinks($item_system_name);
     echo '<tr>';
     echo '<td class="' . $tdclass . ' poi_minmax">';
     echo '<div class="poi"' . $style_override . '>';
     echo '<a href="javascript:void(0)" onclick="update_values(\'/Bookmarks/get' . $type . 'EditData.php?' . $type . '_id=' . $item_id . '\', \'' . $item_id . '\');tofront(\'add' . $type . '\')" style="color:inherit" title="Click to edit entry">';
     echo $distance . ' &ndash;';
     if (!empty($item_system_id)) {
         echo '</a>&nbsp;<a title="System information" href="/System?system_id=' . $item_system_id . '" style="color:inherit">';
     } elseif ($item_system_name != "") {
         echo '</a>&nbsp;<a title="System information" href="/System?system_name=' . urlencode($item_system_name) . '" style="color:inherit">';
     } else {
         echo '</a>&nbsp;<a href="#" style="color:inherit">';
     }
     if (empty($item_name)) {
         echo $item_system_name;
     } else {
         echo $item_name;
     }
     echo '</a>' . $item_crosslinks . '<span class="right" style="margin-left:5px">' . $item_cat_name . '</span><br />';
     if (!empty($item_added_on)) {
         echo 'Added: ' . $item_added_on . ' (' . $item_added_ago . ')<br /><br />';
     }
     echo nl2br($item_text);
     echo '</div>';
     echo '</td>';
     echo '</tr>';
     $i++;
 }