- <html>
- <head>
- <style>
- body {
- font-family: Arial;
- }
- .main {
- padding: 5px;
- }
- td {
- padding-left: 10px;
- }
- </style>
- </head>
- <body>
- <table class='main' width='100%'>
- <tr>
- <td>
- <form action="index.php" method="POST">
- <input type="text" placeholder="Insert a link or URL" name="link">
- <input type="text" placeholder="Name" name="name">
- <input type="text" placeholder="Category" name="category">
- <input type="submit" name="submit">
- <a href='index.php'>Home</a>
- </form>
- </td>
- <td>
- <div align='right'>
- <form action="index.php" method="POST">
- <input type="text" placeholder="Search" name="search">
- <input type="submit" value="Search">
- </form>
- </div>
- </td>
- </tr>
- </table>
- <?php
- $link = $_POST['link'];
- $name = $_POST['name'];
- $category = $_POST['category'];
- if(!$name){
- }
- if(!$category){
- $category = "others";
- }
- // Avoid write files in not allowed directories
- // Avoid write javascript in the files
- // Get the last occurrence of '.' and the remaining text
- if ($lastDotIndex) {
- } else {
- $filetype = "others";
- }
- }
- }
- $result = "<br><a href='categories/$category/$name' target='_blank'>Sent with success!</a>";
- } else {
- $result = "<br>File already exists!";
- }
- }
- $start = $_GET['start'];
- if (!$start){$start = 0;}
- $search = $_POST['search'];
- if ($search == ""){$search = $_GET['search'];}
- // Avoid accessing the above directories
- $c = 0;
- $limit = 20;
- $ini = $start * $limit;
- $end = $ini + $limit;
- $entry = 0;
- echo "<hr>$result <table width='100%'>";
- if ($search != "" ){
- $dir = 'categories';
- // Open the directory
- // Loop through each subdirectory
- // Open the subdirectory
- // Loop through each file in the subdirectory
- $filename_written = $file;
- // Find the occurrence in lower or uppercase
- //if ($subdir == $search){echo 'ok';}
- // Check if the filename contains the string
- // If there is a category with the searched name all the files within that category will be displayed
- // Pagination
- if($entry >= $ini and $entry < $end){
- if ($file == "." || $file == ".."){continue;}
- // Display the filename
- //echo $dir.'/'.$subdir.'/'.$file . "<br>";
- $td_color = $entry % 2 == 0 ? '#EEE' : '#FFF';
- $file_path = $dir.'/'.$subdir.'/'.$file;
- // Checks if is a binary file or text content
- if($filesize > 500){
- $contents = $file_path;
- } else {
- }
- if ($lastDotIndex) {
- }
- // Don't show characters or variables after the file extension
- echo "<tr style='background-color: $td_color;'><td><a href='$contents' target='_blank'>$filename_written</a></td><td>$subdir</td><td>$filetype</td><td><a href='comment.php?comment_file=$file' target='_blank'>Comment</a></td>";
- // Show case be a picture extension
- if($filetype == "png" || $filetype == "jpg" || $filetype == "jpeg" || $filetype == "gif"){
- echo "<td><div align='center'><a href='$contents' target='_blank'><img src='$contents' width='184px'></a></div></td>";
- }
- // Show a thumbnail case exists
- echo "<td><div align='center'><a href='thumbs/$subdir/$filename_written.jpg' target='_blank'><img src='thumbs/$subdir/$filename_written.jpg' width='184px'></a></div></td>";
- }
- $search_break++;
- }
- $entry++;
- // Skip the files of the directory when reached the total results
- if($search_break == $end){break;}
- }
- }
- if($search_break == $end){break;}
- // Close the subdirectory
- }
- }
- }
- // Close the directory
- }
- if ($entry == 0){
- echo "<br>Not found.";
- }
- }
- echo "</table>";
- if (!$search && !$start && !$result){
- echo "Hello!";
- }
- echo "<br><br><div align='center'>";
- if ($entry){
- for ($i = $start; $i < $start + 20; $i++) {
- echo "<a href='index.php?start=$i&search=$search'>$i </a>";
- }
- }
- echo "</div>";
- ?>
search without SQL (PHP)
Posted by Anonymous on Wed 15th Mar 2023 14:27
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.