Ответы пользователя по тегу Linux
  • Как работу echo php в фоне вытащить на html?

    @fastboot Автор вопроса
    HTML
    <?PHP
    
        // Create cache busting version
        $cacheVer = filemtime(__FILE__);
    	
    ?>
    
    <script src="jquery.min.js?v=<?=$cacheVer?>"></script>
    
    <input type="checkbox" checked id="chk1">
    <input type="checkbox" checked id="chk2">
    <pre id="output" style="width: 100%; height: 100%; max-height:650px; overflow-y:scroll;"></pre>
    
    <script src="taillog.js?v=<?=$cacheVer?>"></script>

    taillog.js
    /* Pi-hole: A black hole for Internet advertisements
     *  (c) 2017 Pi-hole, LLC (https://pi-hole.net)
     *  Network-wide ad blocking via your own hardware.
     *
     *  This file is copyright under the latest version of the EUPL.
     *  Please see LICENSE file for your rights under this license. */
    
    var offset,
      timer,
      pre,
      scrolling = true;
    
    // Check every 200msec for fresh data
    var interval = 200;
    
    // Function that asks the API for new data
    function reloadData() {
      clearTimeout(timer);
      $.getJSON("tailLog.php?offset=" + offset, function (data) {
        pre.append(data.lines);
    
        if (scrolling && offset !== data.offset) {
          pre.scrollTop(pre[0].scrollHeight);
        }
    
        offset = data.offset;
      });
    
      timer = setTimeout(reloadData, interval);
    }
    
    $(function () {
      // Get offset at first loading of page
      $.getJSON("tailLog.php", function (data) {
        offset = data.offset;
      });
      pre = $("#output");
      // Trigger function that looks for new data
      reloadData();
    });
    
    $("#chk1").click(function () {
      $("#chk2").prop("checked", this.checked);
      scrolling = this.checked;
    });
    $("#chk2").click(function () {
      $("#chk1").prop("checked", this.checked);
      scrolling = this.checked;
    });

    tailLog.php
    <?php
    /* Pi-hole: A black hole for Internet advertisements
    *  (c) 2017 Pi-hole, LLC (https://pi-hole.net)
    *  Network-wide ad blocking via your own hardware.
    *
    *  This file is copyright under the latest version of the EUPL.
    *  Please see LICENSE file for your rights under this license. */
    
    
    // Not using SplFileObject here, since direct
    // usage of f-streams will be much faster for
    // files as large as the pihole.log
    if(isset($_GET["FTL"]))
    {
    	$file = fopen('A:\php\batch\log.txt',"r");
    }
    else
    {
    	$file = fopen('A:\php\batch\log.txt',"r");
    }
    
    if(!$file)
    {
    	die(json_encode(array("offset" => 0, "lines" => array("Failed to open log file. Check permissions!\n"))));
    }
    
    if(isset($_GET["offset"]))
    {
    	$offset = intval($_GET['offset']);
    	if($offset > 0)
    	{
    		// Seeks on the file pointer where we want to continue reading is known
    		fseek($file, $offset);
    		$lines = [];
    		while (!feof($file))
    			array_push($lines, htmlspecialchars(fgets($file)));
    		die(json_encode(array("offset" => ftell($file), "lines" => $lines)));
    	}
    }
    
    // Locate the current position of the file read/write pointer
    fseek($file, -1, SEEK_END);
    // Add one to skip the very last "\n" in the log file
    die(json_encode(array("offset" => ftell($file)+1)));
    
    ?>
    Ответ написан
    Комментировать
  • Как USB на Linux превратить в туннель TCP IP и подключиться на Windows?

    @fastboot Автор вопроса
    virtualhere
    0. сайт
    https://virtualhere.com/usb_server_software
    1. ARM сервер файл для arm пк.
    wget https://virtualhere.com/sites/default/files/usbserver/vhusbdarm

    2. права файла.
    chmod +x vhusbdarm
    3. запускаем
    ./vhusbdarm
    4. видим вот это
    root@ZeroPi:/tmp# ./vhusbdarm
    VirtualHere USB Server is running...press CTRL-C to stop

    5. Windows клиент
    5ff621a3755c2553871441.png
    6. работает!
    5ff621f50e55d805066503.png
    Ответ написан
    Комментировать
  • Сделал ln /var/www -> /mnt/usb/WWW и если echo test > /var/www/test.txt => Permission denied почему?

    @fastboot Автор вопроса
    ext4 usb
    5feb52d954e34572148635.png5feb528f6aa45121404660.png
    Ответ написан
    Комментировать