Ejemplo n.º 1
0
 /**
  * Convert screenshots to jpg and move to screenhot folder
  *
  * @param string $gallery_name name of the gallery to create (ie. the system name)
  * @author Mauri Kujala <*****@*****.**>
  */
 public function make_gallery($gallery_name)
 {
     global $settings, $system_time, $mysqli;
     /**
      * get visit time for the system so we can tell if the screenshots were taken in that system
      */
     $esc_gallery_name = $mysqli->real_escape_string($gallery_name);
     $query = "  SELECT visit\n                    FROM user_visited_systems\n                    WHERE system_name = '{$esc_gallery_name}'\n                    ORDER BY visit DESC\n                    LIMIT 1";
     $result = $mysqli->query($query) or write_log($mysqli->error, __FILE__, __LINE__);
     $obj = $result->fetch_object();
     $visit_time = isset($obj->visit) ? strtotime($obj->visit) : time();
     $result->close();
     /**
      * scan screenshot directory for bmp files
      */
     $screenshots = glob($settings["old_screendir"] . "/*.bmp");
     /**
      * strip invalid characters from the gallery name
      */
     $gallery_name = strip_invalid_dos_chars($gallery_name);
     /** @var string $newscreendir */
     $newscreendir = $settings["new_screendir"] . "/" . $gallery_name;
     $added = 0;
     foreach ($screenshots as $file) {
         $file_name = str_replace($settings["old_screendir"] . "/", "", $file);
         $old_file_bmp = $file;
         $old_file_og = $settings["old_screendir"] . "/originals/" . $file_name;
         $filetime_o = filemtime($old_file_bmp);
         $filetime = $filetime_o + $system_time * 60 * 60;
         /**
          * if screenshot was taken after entering the system
          */
         if ($filetime > $visit_time) {
             /**
              * create gallery directory
              */
             $this->create_dir($newscreendir);
             $edited = date("Y-m-d_H-i-s", $filetime_o);
             $new_filename = $edited . "-" . $gallery_name . ".jpg";
             $new_file_jpg = $settings["old_screendir"] . "/" . $new_filename;
             $new_screenshot = $newscreendir . "/" . $new_filename;
             /**
              * convert from bmp to jpg
              */
             if (file_exists($old_file_bmp)) {
                 /**
                  * execute ImageMagick convert
                  */
                 $command = "\"" . $settings["install_path"] . "/bin/ImageMagick/convert\" \"" . $old_file_bmp . "\" \"" . $new_file_jpg . "\"";
                 exec($command, $out);
                 if (!empty($out)) {
                     $error = json_encode($out);
                     write_log("Error: " . $error, __FILE__, __LINE__);
                 }
             }
             /**
              * delete original...
              */
             if ($settings["keep_og"] == "false") {
                 $this->remove_file($old_file_bmp);
                 /**
                  * ... or move to "originals" directory
                  */
             } else {
                 $this->create_dir($settings["old_screendir"] . "/originals");
                 if (file_exists($old_file_og)) {
                     $old_file_og = $settings["old_screendir"] . "/originals/" . $filetime . "_" . $file_name;
                 }
                 $this->move_file($old_file_bmp, $old_file_og);
             }
             /**
              * move the converted file to screenshot folder
              */
             $this->move_file($new_file_jpg, $new_screenshot);
             /**
              * add no more than 15 at a time
              */
             $added++;
             if ($added > 15) {
                 break;
             }
         } else {
             /**
              * if screenshot was taken before entering the system, move it to "originals" directory
              * so it doesn't interfere with the script in the future
              */
             $this->create_dir($settings["old_screendir"] . "/originals");
             if (file_exists($old_file_og)) {
                 $old_file_og = $settings["old_screendir"] . "/originals/" . $filetime . "_" . $file_name;
             }
             $this->move_file($old_file_bmp, $old_file_og);
         }
     }
     unset($file);
     /**
      * make thumbnails for the gallery
      */
     if ($added > 0) {
         $this->make_thumbs($newscreendir);
     }
 }
Ejemplo n.º 2
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 />';
Ejemplo n.º 3
0
 /**
  * Return links to screenshots, system log or system map
  *
  * @param string $system
  * @param bool $show_screens
  * @param bool $show_system
  * @param bool $show_logs
  * @param bool $show_map
  * @return string $return
  * @author Mauri Kujala <*****@*****.**>
  */
 static function crosslinks($system, $show_screens = true, $show_system = false, $show_logs = true, $show_map = true)
 {
     $return = "";
     // check if system has screenshots
     if ($show_screens === true && System::has_screenshots($system)) {
         $return .= '<a href="/Gallery?spgmGal=' . urlencode(strip_invalid_dos_chars($system)) . '" title="View image gallery" class="gallery_link">';
         $return .= '<img src="/style/img/image.png" class="icon" alt="Gallery" style="margin-left:5px;margin-right:0;vertical-align:top" />';
         $return .= '</a>';
     }
     // check if system is logged
     if ($show_logs === true && System::is_logged($system)) {
         $return .= '<a href="/Log?system=' . urlencode($system) . '" style="color:inherit" title="System has log entries" class="log_link">';
         $return .= '<img src="/style/img/log.png" class="icon" style="margin-left:5px;margin-right:0" />';
         $return .= '</a>';
     }
     // check if system is mapped
     if ($show_map === true && System::is_mapped($system)) {
         $return .= '<a href="/SystemMap/?system=' . urlencode($system) . '" style="color:inherit" title="System map" class="system_map_link">';
         $return .= '<img src="/style/img/grid.png" class="icon" style="margin-left:5px;margin-right:0" />';
         $return .= '</a>';
     }
     // show link if system exists
     if ($show_system === true && System::exists($system)) {
         $return .= '<a href="/System?system_name=' . urlencode($system) . '" style="color:inherit" title="System info" class="system_info_link">';
         $return .= '<img src="/style/img/info.png" class="icon" alt="Info" style="margin-left:5px;margin-right:0" />';
         $return .= '</a>';
     }
     return $return;
 }