SF.net SVN: phpwiki:[10807] trunk/lib/plugin/UpLoad.php

vargenau--- via phpwiki-checkins <[email protected]>
Newsgroups gmane.comp.web.wiki.phpwiki.checkins
Message-ID <[email protected]>
Revision: 10807
          http://sourceforge.net/p/phpwiki/code/10807
Author:   vargenau
Date:     2022-01-03 10:48:42 +0000 (Mon, 03 Jan 2022)
Log Message:
-----------
UpLoad plugin: add HTML header to log file

Modified Paths:
--------------
    trunk/lib/plugin/UpLoad.php

Modified: trunk/lib/plugin/UpLoad.php
===================================================================
--- trunk/lib/plugin/UpLoad.php	2022-01-02 14:40:53 UTC (rev 10806)
+++ trunk/lib/plugin/UpLoad.php	2022-01-03 10:48:42 UTC (rev 10807)
@@ -260,11 +260,23 @@
         global $request;
 
         $user = $request->_user;
+        $empty_log = !file_exists($upload_log);
         if (file_exists($upload_log) and (!is_writable($upload_log))) {
             trigger_error(_("The upload logfile exists but is not writable."), E_USER_WARNING);
         } elseif (!$log_handle = fopen($upload_log, "a")) {
             trigger_error(_("Can't open the upload logfile."), E_USER_WARNING);
-        } else { // file size in KB; precision of 0.1
+        } else {
+            if ($empty_log) {
+                fwrite($log_handle,
+                         "<!DOCTYPE html>\n"
+                       . '<html xml:lang="en" lang="en">'."\n"
+                       . "<head>\n"
+                       . "<title>PhpWiki - UpLoad logfile</title>\n"
+                       . "</head>\n"
+                       . "<body>\n"
+                       . "<table>\n");
+            }
+            // file size in KB; precision of 0.1
             $file_size = round(($userfile->getSize()) / 1024, 1);
             if ($file_size <= 0) {
                 $file_size = "&lt; 0.1";
@@ -271,11 +283,10 @@
             }
             $userfile_name = $userfile->getName();
             fwrite($log_handle,
-                "\n"
-                    . "<tr><td><a href=\"$userfile_name\">$userfile_name</a></td>"
-                    . "<td class=\"align-right\">$file_size kB</td>"
-                    . "<td>&nbsp;&nbsp;" . $WikiTheme->formatDate(time()) . "</td>"
-                    . "<td>&nbsp;&nbsp;<em>" . $user->getId() . "</em></td></tr>");
+                      "<tr>\n  <td><a href=\"$userfile_name\">$userfile_name</a></td>\n"
+                    . "  <td class=\"align-right\">$file_size kB</td>\n"
+                    . "  <td>&nbsp;&nbsp;" . $WikiTheme->formatDate(time()) . "</td>\n"
+                    . "  <td>&nbsp;&nbsp;<em>" . $user->getId() . "</em></td>\n</tr>\n");
             fclose($log_handle);
         }
     }

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.