Example #1
0


<?php 
include "MainFunctions.php";
$allowedExts = array("html", "HTML", "Html");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ($_FILES["file"]["size"] < 200000000 && in_array($extension, $allowedExts)) {
    if ($_FILES["file"]["error"] > 0) {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    } else {
        if (file_exists("DB/" . $_FILES["file"]["name"])) {
            echo $_FILES["file"]["name"] . " already exists. ";
        } else {
            move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
            updateDocInDB($db, $_FILES["file"]["name"]);
            rename("upload/" . $_FILES["file"]["name"], "DB/" . $_FILES["file"]["name"]);
            echo '<br/><a>The file has been uploaded</a>';
        }
    }
} else {
    echo "Invalid file";
}
header('Location: http://localhost/TheBigBangTheory/AdminPanel.php?dir=DB');
?>



Example #2
0
<?php

include "MainFunctions.php";
//Gets all the html files in the directory
$directory = $_GET['dir'] . "/*.{html}";
$files = glob($directory, GLOB_BRACE);
$db = initDB();
if (is_writable('DataBase.json')) {
    unlink('DataBase.json');
    $db = initDB();
}
//Update files DB
foreach ($files as $file) {
    $meta = get_meta_tags($file);
    $file = $meta['key'] . '.html';
    rename("DB/" . $file, "upload/" . $file);
    updateDocInDB($db, $file);
    rename("upload/" . $file, "DB/" . $file);
}
//end
header('Location: http://localhost/TheBigBangTheory/AdminPanel.php?dir=DB');