engedélyezés beépítve
This commit is contained in:
		
							parent
							
								
									696b0fbb0f
								
							
						
					
					
						commit
						494813a195
					
				
							
								
								
									
										257
									
								
								approval.php
									
									
									
									
									
								
							
							
						
						
									
										257
									
								
								approval.php
									
									
									
									
									
								
							@ -1,257 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
// munkamenet bekapcsolása, ez minden előtt kell legyen
 | 
			
		||||
session_start();
 | 
			
		||||
 | 
			
		||||
// belépés ellenőrzése
 | 
			
		||||
//   jelszó hash generálás: echo password_hash('P@ssw0rd', PASSWORD_DEFAULT);
 | 
			
		||||
define('HASHED_PASSWORD', '$2y$10$mt9434TWI2q9QXhSoywyZephTAIEJHb5e1MK45GakfoEndZBfXn8a');
 | 
			
		||||
if (isset($_POST['password']) && password_verify($_POST['password'], HASHED_PASSWORD)===true) {
 | 
			
		||||
    $_SESSION['logged_in'] = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// kiléptetés
 | 
			
		||||
if (isset($_POST['logout'])){
 | 
			
		||||
    // remove all session variables
 | 
			
		||||
    session_unset();
 | 
			
		||||
    // destroy the session
 | 
			
		||||
    session_destroy(); 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ($_SESSION['logged_in']) {
 | 
			
		||||
 | 
			
		||||
// ezeket majd külön fájba kéne tenni
 | 
			
		||||
include_once "globals.php";
 | 
			
		||||
// olyan szöveget ad vissza, amibe csak angol ABC betűi és számok szerepelnek (KL)
 | 
			
		||||
function only_alpha_numeric($input)
 | 
			
		||||
{
 | 
			
		||||
    return preg_replace("/[^a-zA-Z0-9_]+/", "", $input);
 | 
			
		||||
}
 | 
			
		||||
// csatlakozás az adatbázishoz
 | 
			
		||||
function open_sql_connection()
 | 
			
		||||
{
 | 
			
		||||
    return mysqli_connect(SQL_IP, SQL_USER, SQL_PASS, SQL_DB);
 | 
			
		||||
}
 | 
			
		||||
// Globális SQL-kapcsolat
 | 
			
		||||
$dbconn = open_sql_connection();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function get_images($last_No=-1, $n=10){
 | 
			
		||||
    global $dbconn;
 | 
			
		||||
    
 | 
			
		||||
    // felhasználótól jött paraméterek ellenőrzése
 | 
			
		||||
    $last_No = intval($last_No);
 | 
			
		||||
    $n = intval($n);
 | 
			
		||||
    
 | 
			
		||||
    $query = "SELECT * FROM publish_table";
 | 
			
		||||
    $query .= " WHERE Confirmed=0";
 | 
			
		||||
    $query .= "   AND No>$last_No";
 | 
			
		||||
    $query .= " ORDER BY No";
 | 
			
		||||
    $query .= " LIMIT $n";
 | 
			
		||||
    
 | 
			
		||||
    $result = $dbconn->query($query);
 | 
			
		||||
    $data = [];
 | 
			
		||||
    while ($row = $result->fetch_assoc()) {
 | 
			
		||||
        $data[] = $row;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    return $data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function set_approval($Image_FileName, $approved){
 | 
			
		||||
    global $dbconn;
 | 
			
		||||
    
 | 
			
		||||
    // felhasználótól jött paraméterek ellenőrzése
 | 
			
		||||
    $approved = $approved === 'true' ? 1 : 0;
 | 
			
		||||
    $Image_FileName = $dbconn->real_escape_string($Image_FileName);
 | 
			
		||||
    
 | 
			
		||||
    // jóváhagyás mező beállítása és ellenőrzöttnek jelölés
 | 
			
		||||
    $query = "UPDATE publish_table SET Approved=$approved, Confirmed=1 WHERE Image_FileName='$Image_FileName';";
 | 
			
		||||
    $res = $dbconn->query($query);
 | 
			
		||||
    
 | 
			
		||||
    return $res; // true ha sikeres, false ha valami hiba történt
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    if (isset($_POST["action"])) {
 | 
			
		||||
        $action = only_alpha_numeric($_POST["action"]);
 | 
			
		||||
        
 | 
			
		||||
        // parancs kiválasztása
 | 
			
		||||
        switch ($action) {
 | 
			
		||||
            case "get_images": // kép adatok lekérése
 | 
			
		||||
                if (isset($_POST["last_No"]) && isset($_POST["n"])) {
 | 
			
		||||
                    echo json_encode(get_images($_POST["last_No"], $_POST["n"]));
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case "set_approval": // jováhagyás beállítása
 | 
			
		||||
                if (isset($_POST["Image_FileName"]) && isset($_POST["approved"])) {
 | 
			
		||||
                    echo json_encode(set_approval($_POST["Image_FileName"], $_POST["approved"]));
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        exit(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html lang="hu">
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="utf-8"/>
 | 
			
		||||
    <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'>
 | 
			
		||||
 | 
			
		||||
    <title>képek jóváhagyása - Fotófal</title>
 | 
			
		||||
 | 
			
		||||
    <script src="js/o.js"></script>
 | 
			
		||||
    <script src="js/socket.js"></script>
 | 
			
		||||
    <script src="js/slider.js"></script>
 | 
			
		||||
    <script src="js/phw.js"></script>
 | 
			
		||||
    <script src="js/color.js"></script>
 | 
			
		||||
    <?php if ($_SESSION['logged_in']) { ?>
 | 
			
		||||
    <script>
 | 
			
		||||
        // ezeket lehetne külön tenni
 | 
			
		||||
        function l(msg){console.log(msg);}
 | 
			
		||||
        function request(url, method, data){
 | 
			
		||||
            return new Promise( (resolve,reject) => {
 | 
			
		||||
                var formData;
 | 
			
		||||
                if(data){
 | 
			
		||||
                    formData = new FormData();
 | 
			
		||||
                    for (var k in data) {
 | 
			
		||||
                        formData.append(k, data[k]);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                fetch(url, {
 | 
			
		||||
                    method: method,
 | 
			
		||||
                    body: formData,
 | 
			
		||||
                })
 | 
			
		||||
                .then(response => response.text())
 | 
			
		||||
                .then(data => resolve(data))
 | 
			
		||||
                .catch((error) => {
 | 
			
		||||
                    console.error('Error: ', error);
 | 
			
		||||
                    reject(error);
 | 
			
		||||
                });
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
    </script>
 | 
			
		||||
    <script>
 | 
			
		||||
        const MAX_TABLE_ROWS = 10;
 | 
			
		||||
        
 | 
			
		||||
        document.addEventListener("DOMContentLoaded", () => {
 | 
			
		||||
            fill_table();
 | 
			
		||||
        });
 | 
			
		||||
        
 | 
			
		||||
        function fill_table(){
 | 
			
		||||
            var table_container = o('table_container');
 | 
			
		||||
            var max_new_rows = MAX_TABLE_ROWS - table_container.children.length;
 | 
			
		||||
            var last_No = table_container.children.length ? table_container.children[table_container.children.length-1].details.No : -1;
 | 
			
		||||
            
 | 
			
		||||
            request(
 | 
			
		||||
                'approval.php',
 | 
			
		||||
                'POST',
 | 
			
		||||
                {
 | 
			
		||||
                    action: 'get_images',
 | 
			
		||||
                    last_No: last_No,
 | 
			
		||||
                    n: max_new_rows,
 | 
			
		||||
                }
 | 
			
		||||
            )
 | 
			
		||||
            .then(data => {
 | 
			
		||||
                data = JSON.parse(data);
 | 
			
		||||
                if (data.length) {
 | 
			
		||||
                    data.forEach(image_data => {
 | 
			
		||||
                        table_container.appendChild(render_row(image_data));
 | 
			
		||||
                    });
 | 
			
		||||
                } else if (table_container.innerHTML == '') {
 | 
			
		||||
                    table_container.innerHTML = '<h3>Jelenleg nincs jóváhagyásra váró elem :)</h3>'
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        // 
 | 
			
		||||
        function render_row(image_data){
 | 
			
		||||
            var row_container = document.createElement('div');
 | 
			
		||||
            row_container.innerHTML = `
 | 
			
		||||
                <hr />
 | 
			
		||||
                <div>
 | 
			
		||||
                    <button id="button_approve" onclick="set_approval(event);" >Engedélyez</button>
 | 
			
		||||
                    <button id="button_hide" onclick="set_approval(event);" >Entüntet</button>
 | 
			
		||||
                </div>
 | 
			
		||||
                <img src="ARTWORKS/thumbnails/${image_data["Image_FileName"]}" />
 | 
			
		||||
                <div>
 | 
			
		||||
                    <span>Alkotó: ${image_data["Author"]}</span><br />
 | 
			
		||||
                    <span>Cím: ${image_data["Title"]}</span><br />
 | 
			
		||||
                    <span>Leírás: ${image_data["Description"]}</span><br />
 | 
			
		||||
                    <span>Feltöltés ideje: ${image_data["TS"]}</span><br />
 | 
			
		||||
                </div>
 | 
			
		||||
            `;
 | 
			
		||||
            row_container.details = image_data;
 | 
			
		||||
            return row_container;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        function set_approval(event){
 | 
			
		||||
            var approved = event.target.id === 'button_approve';
 | 
			
		||||
            var row_container = event.target.parentElement.parentElement;
 | 
			
		||||
            var image_data = row_container.details;
 | 
			
		||||
            
 | 
			
		||||
            request(
 | 
			
		||||
                'approval.php',
 | 
			
		||||
                'POST',
 | 
			
		||||
                {
 | 
			
		||||
                    action: 'set_approval',
 | 
			
		||||
                    Image_FileName: image_data['Image_FileName'],
 | 
			
		||||
                    approved: approved,
 | 
			
		||||
                }
 | 
			
		||||
            )
 | 
			
		||||
            .then(data => {
 | 
			
		||||
                if (data==='true') {
 | 
			
		||||
                    // ha sikeres a kérés, a sor eltüntetése
 | 
			
		||||
                    row_container.parentElement.removeChild(row_container);
 | 
			
		||||
                } else {
 | 
			
		||||
                    alert('Valami nem stimmel, kérlek próbáld újra.');
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
                // újabb elem betöltése, ha van
 | 
			
		||||
                fill_table();
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
    </script>
 | 
			
		||||
    <style>
 | 
			
		||||
    .settings_container {
 | 
			
		||||
        padding: 10px;
 | 
			
		||||
        background-color: blue;
 | 
			
		||||
    }
 | 
			
		||||
    #table_container > div > img {
 | 
			
		||||
        margin: 5px;
 | 
			
		||||
    }
 | 
			
		||||
    #table_container > div > div {
 | 
			
		||||
        display: inline-block;
 | 
			
		||||
    }
 | 
			
		||||
    </style>
 | 
			
		||||
    <?php } ?>
 | 
			
		||||
 | 
			
		||||
    <link href="phw.css" rel="stylesheet">
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<?php if ($_SESSION['logged_in']) { ?>
 | 
			
		||||
    <div class="settings_container" >
 | 
			
		||||
        <!-- TODO: valahogy be lehessen állítani,
 | 
			
		||||
            hogy ne csak az jelenjen meg, amit már egyszer leellenőriztek -->
 | 
			
		||||
        <form method="POST" >
 | 
			
		||||
            <input type="submit" name="logout" value="Kilépés" >
 | 
			
		||||
        </form>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div id="table_container" ></div>
 | 
			
		||||
<?php } else { ?>
 | 
			
		||||
    <form method="POST" >
 | 
			
		||||
        <input type="password" name="password" />
 | 
			
		||||
        <input type="submit" value="Belépés" >
 | 
			
		||||
    </form>
 | 
			
		||||
<?php } ?>
 | 
			
		||||
 | 
			
		||||
<!-- TESZTVERZIÓ -->
 | 
			
		||||
<section class="testversion-sign">TESZTVERZIÓ</section>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										312
									
								
								approve.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										312
									
								
								approve.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,312 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
include_once "utils.php";
 | 
			
		||||
 | 
			
		||||
// Globális SQL-kapcsolat
 | 
			
		||||
$dbconn = open_sql_connection();
 | 
			
		||||
 | 
			
		||||
//   jelszó hash generálás: echo password_hash('P@ssw0rd', PASSWORD_DEFAULT);
 | 
			
		||||
 | 
			
		||||
// képek betöltése
 | 
			
		||||
function get_images($last_No = -1, $n = 10)
 | 
			
		||||
{
 | 
			
		||||
    global $dbconn;
 | 
			
		||||
 | 
			
		||||
    // felhasználótól jött paraméterek ellenőrzése
 | 
			
		||||
    $last_No = intval($last_No);
 | 
			
		||||
    $n = intval($n);
 | 
			
		||||
 | 
			
		||||
    $query = "SELECT * FROM publish_table";
 | 
			
		||||
    $query .= " WHERE Confirmed=0";
 | 
			
		||||
    $query .= "   AND No>$last_No";
 | 
			
		||||
    $query .= " ORDER BY No";
 | 
			
		||||
    $query .= " LIMIT $n";
 | 
			
		||||
 | 
			
		||||
    $result = $dbconn->query($query);
 | 
			
		||||
    $data = [];
 | 
			
		||||
    while ($row = $result->fetch_assoc()) {
 | 
			
		||||
        $data[] = $row;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return $data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// kép engedélyezése
 | 
			
		||||
function set_approval($Image_FileName, $approved)
 | 
			
		||||
{
 | 
			
		||||
    global $dbconn;
 | 
			
		||||
 | 
			
		||||
    // felhasználótól jött paraméterek ellenőrzése
 | 
			
		||||
    $approved = $approved === 'true' ? 1 : 0;
 | 
			
		||||
    $Image_FileName = $dbconn->real_escape_string($Image_FileName);
 | 
			
		||||
 | 
			
		||||
    // jóváhagyás mező beállítása és ellenőrzöttnek jelölés
 | 
			
		||||
    $query = "UPDATE publish_table SET Approved=$approved, Confirmed=1 WHERE Image_FileName='$Image_FileName';";
 | 
			
		||||
    $res = $dbconn->query($query);
 | 
			
		||||
 | 
			
		||||
    return $res; // true ha sikeres, false ha valami hiba történt
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// --------------------------------
 | 
			
		||||
 | 
			
		||||
// munkamenet bekapcsolása, ez minden előtt kell legyen
 | 
			
		||||
session_start();
 | 
			
		||||
 | 
			
		||||
// bejelentkezést jelző flag
 | 
			
		||||
$logged_in = false;
 | 
			
		||||
 | 
			
		||||
// ha nincs ilyen változó, akkor létrehozzuk
 | 
			
		||||
if (isset($_SESSION['logged_in'])) {
 | 
			
		||||
    $logged_in = $_SESSION['logged_in'];
 | 
			
		||||
} else {
 | 
			
		||||
    $_SESSION['logged_in'] = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// belépés ellenőrzése
 | 
			
		||||
if (isset($_POST['password']) && password_verify($_POST['password'], HASHED_REVIS_PASSWORD) === true) {
 | 
			
		||||
    $_SESSION['logged_in'] = true;
 | 
			
		||||
    $logged_in = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// kiléptetés
 | 
			
		||||
if (isset($_POST['logout'])) {
 | 
			
		||||
    $_SESSION['logged_in'] = false;
 | 
			
		||||
 | 
			
		||||
    // remove all session variables
 | 
			
		||||
    session_unset();
 | 
			
		||||
    // destroy the session
 | 
			
		||||
    session_destroy();
 | 
			
		||||
 | 
			
		||||
    // nem vagyunk bejelentkezve
 | 
			
		||||
    $logged_in = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ha be vagyunk jelentkezve
 | 
			
		||||
if ($logged_in) {
 | 
			
		||||
    if (isset($_POST["action"])) {
 | 
			
		||||
        $action = only_alpha_numeric($_POST["action"]);
 | 
			
		||||
 | 
			
		||||
        // parancs kiválasztása
 | 
			
		||||
        switch ($action) {
 | 
			
		||||
            case "get_images": // képadatok lekérése
 | 
			
		||||
                if (isset($_POST["last_No"]) && isset($_POST["n"])) {
 | 
			
		||||
                    echo json_encode(get_images($_POST["last_No"], $_POST["n"]));
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case "set_approval": // jóváhagyás beállítása
 | 
			
		||||
                if (isset($_POST["Image_FileName"]) && isset($_POST["approved"])) {
 | 
			
		||||
                    echo json_encode(set_approval($_POST["Image_FileName"], $_POST["approved"]));
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        exit(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html lang="hu">
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="utf-8"/>
 | 
			
		||||
    <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'>
 | 
			
		||||
 | 
			
		||||
    <title>Fotófal :: admin</title>
 | 
			
		||||
 | 
			
		||||
    <script src="js/o.js"></script>
 | 
			
		||||
    <script src="js/socket.js"></script>
 | 
			
		||||
    <script src="js/slider.js"></script>
 | 
			
		||||
    <script src="js/phw.js"></script>
 | 
			
		||||
    <script src="js/color.js"></script>
 | 
			
		||||
    <?php if ($logged_in) { ?>
 | 
			
		||||
        <script>
 | 
			
		||||
            // ezeket lehetne külön tenni
 | 
			
		||||
            function l(msg) {
 | 
			
		||||
                console.log(msg);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            function request(url, method, data) {
 | 
			
		||||
                return new Promise((resolve, reject) => {
 | 
			
		||||
                    var formData;
 | 
			
		||||
                    if (data) {
 | 
			
		||||
                        formData = new FormData();
 | 
			
		||||
                        for (var k in data) {
 | 
			
		||||
                            formData.append(k, data[k]);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    fetch(url, {
 | 
			
		||||
                        method: method,
 | 
			
		||||
                        body: formData,
 | 
			
		||||
                    })
 | 
			
		||||
                        .then(response => response.text())
 | 
			
		||||
                        .then(data => resolve(data))
 | 
			
		||||
                        .catch((error) => {
 | 
			
		||||
                            console.error('Error: ', error);
 | 
			
		||||
                            reject(error);
 | 
			
		||||
                        });
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        </script>
 | 
			
		||||
        <script>
 | 
			
		||||
            const MAX_TABLE_ROWS = 10;
 | 
			
		||||
 | 
			
		||||
            document.addEventListener("DOMContentLoaded", () => {
 | 
			
		||||
                fill_table();
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            function fill_table() {
 | 
			
		||||
                var table_container = o('table_container');
 | 
			
		||||
                var max_new_rows = MAX_TABLE_ROWS - table_container.children.length;
 | 
			
		||||
                var last_No = table_container.children.length ? table_container.children[table_container.children.length - 1].details.No : -1;
 | 
			
		||||
 | 
			
		||||
                request(
 | 
			
		||||
                    'approve.php',
 | 
			
		||||
                    'POST',
 | 
			
		||||
                    {
 | 
			
		||||
                        action: 'get_images',
 | 
			
		||||
                        last_No: last_No,
 | 
			
		||||
                        n: max_new_rows,
 | 
			
		||||
                    }
 | 
			
		||||
                )
 | 
			
		||||
                    .then(data => {
 | 
			
		||||
                        data = JSON.parse(data);
 | 
			
		||||
                        if (data.length) {
 | 
			
		||||
                            data.forEach(image_data => {
 | 
			
		||||
                                table_container.appendChild(render_row(image_data));
 | 
			
		||||
                            });
 | 
			
		||||
                        } else if (table_container.innerHTML === '') {
 | 
			
		||||
                            table_container.innerHTML = '<h3>Jelenleg nincs jóváhagyásra váró elem :)</h3>'
 | 
			
		||||
                        }
 | 
			
		||||
                    });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //
 | 
			
		||||
            function render_row(image_data) {
 | 
			
		||||
                var row_container = document.createElement('section');
 | 
			
		||||
                row_container.style.paddingLeft = "0.5em";
 | 
			
		||||
 | 
			
		||||
                // "(nincs)" kiírása, ha ki van hagyva
 | 
			
		||||
                let desc = image_data["Description"] === "" ? "<i>(nincs)</i>" : image_data["Description"];
 | 
			
		||||
 | 
			
		||||
                row_container.innerHTML = `
 | 
			
		||||
                <hr style="height: 0.5em; border: 0; background-color: lightgray;"/>
 | 
			
		||||
                <img src="ARTWORKS/thumbnails/${image_data["Image_FileName"]}" style="vertical-align: top" />
 | 
			
		||||
                <section style="display: inline-block; margin-left: 1em;">
 | 
			
		||||
                    <section style="display: block">
 | 
			
		||||
                        <span class="label">Alkotó:</span><span class="fill-in-content">${image_data["Author"]} <i>(${image_data["AuthorGroup"]})</i></span><br />
 | 
			
		||||
                        <span class="label">Cím:</span><span class="fill-in-content">${image_data["Title"]}</span><br />
 | 
			
		||||
                        <span class="label">Leírás:</span><span class="fill-in-content">${desc}</span><br />
 | 
			
		||||
                        <span class="label">Feltöltés ideje:</span><span class="fill-in-content">${image_data["TS"]}</span><br />
 | 
			
		||||
                    </section>
 | 
			
		||||
                    <section style="display: block; margin-top: 1em;">
 | 
			
		||||
                        <section class="btn" id="button_approve" onclick="set_approval(event);" >Engedélyez</section>
 | 
			
		||||
                        <section class="btn" id="button_hide" onclick="set_approval(event);" >Elutasít</section>
 | 
			
		||||
                    </section>
 | 
			
		||||
                </section>
 | 
			
		||||
            `;
 | 
			
		||||
                row_container.details = image_data;
 | 
			
		||||
                return row_container;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            function set_approval(event) {
 | 
			
		||||
                var approved = event.target.id === 'button_approve';
 | 
			
		||||
                var row_container = event.target.parentElement.parentElement.parentElement;
 | 
			
		||||
                var image_data = row_container.details;
 | 
			
		||||
 | 
			
		||||
                request(
 | 
			
		||||
                    'approve.php',
 | 
			
		||||
                    'POST',
 | 
			
		||||
                    {
 | 
			
		||||
                        action: 'set_approval',
 | 
			
		||||
                        Image_FileName: image_data['Image_FileName'],
 | 
			
		||||
                        approved: approved,
 | 
			
		||||
                    }
 | 
			
		||||
                )
 | 
			
		||||
                    .then(data => {
 | 
			
		||||
                        if (data === 'true') {
 | 
			
		||||
                            // ha sikeres a kérés, a sor eltüntetése
 | 
			
		||||
                            row_container.parentElement.removeChild(row_container);
 | 
			
		||||
                        } else {
 | 
			
		||||
                            alert('Valami nem stimmel, kérlek próbáld újra.');
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        // újabb elem betöltése, ha van
 | 
			
		||||
                        fill_table();
 | 
			
		||||
                    });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        </script>
 | 
			
		||||
        <style>
 | 
			
		||||
            section.settings_container {
 | 
			
		||||
                padding: 10px;
 | 
			
		||||
                text-align: right;
 | 
			
		||||
                border: 1px dashed var(--PUP-BORDERCOLOR);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            section#table_container {
 | 
			
		||||
                display: block;
 | 
			
		||||
                position: absolute;
 | 
			
		||||
                left: 4px;
 | 
			
		||||
                right: 4px;
 | 
			
		||||
                top: 80px;
 | 
			
		||||
                bottom: 0;
 | 
			
		||||
                overflow: scroll;
 | 
			
		||||
                border: 1px dashed var(--PUP-BORDERCOLOR);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            span.label {
 | 
			
		||||
                color: var(--LABEL-TCOLOR);
 | 
			
		||||
                text-transform: uppercase;
 | 
			
		||||
                margin-right: 0.5em;
 | 
			
		||||
            }
 | 
			
		||||
        </style>
 | 
			
		||||
    <?php } else { ?>
 | 
			
		||||
 | 
			
		||||
        <style>
 | 
			
		||||
            section.login {
 | 
			
		||||
                display: flex;
 | 
			
		||||
                top: 0.5em;
 | 
			
		||||
                left: 0.5em;
 | 
			
		||||
                right: 0.5em;
 | 
			
		||||
                bottom: 0.5em;
 | 
			
		||||
                position: fixed;
 | 
			
		||||
                justify-content: center;
 | 
			
		||||
                align-items: center;
 | 
			
		||||
            }
 | 
			
		||||
        </style>
 | 
			
		||||
    <?php } ?>
 | 
			
		||||
 | 
			
		||||
    <link href="phw.css" rel="stylesheet">
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<!-- BEJELENTKEZVE -->
 | 
			
		||||
<?php if ($logged_in) { ?>
 | 
			
		||||
    <section class="settings_container">
 | 
			
		||||
        <!-- TODO: valahogy be lehessen állítani,
 | 
			
		||||
            hogy ne csak az jelenjen meg, amit már egyszer leellenőriztek -->
 | 
			
		||||
        <form method="POST" id="logoutform">
 | 
			
		||||
            <section class="btn" onclick="o('logoutform').submit()">Kilépés</section>
 | 
			
		||||
            <input type="hidden" name="logout">
 | 
			
		||||
        </form>
 | 
			
		||||
    </section>
 | 
			
		||||
    <section id="table_container"></section>
 | 
			
		||||
 | 
			
		||||
    <!--  KIJELENTKEZVE  -->
 | 
			
		||||
<?php } else { ?>
 | 
			
		||||
    <section class="login">
 | 
			
		||||
        <form method="POST" id="loginform" style="text-align: center; font-weight: bold;">
 | 
			
		||||
            <span style="font-size: 20px; color: var(--LABEL-TCOLOR);">Photowall admin-felület</span><br>
 | 
			
		||||
            <input type="password" name="password" placeholder="Jelszó" style="margin-left: 0"/><br style="margin: 0.8em;">
 | 
			
		||||
            <section class="btn" onclick="o('loginform').submit()">Belépés</section>
 | 
			
		||||
        </form>
 | 
			
		||||
    </section>
 | 
			
		||||
<?php } ?>
 | 
			
		||||
 | 
			
		||||
<!-- TESZTVERZIÓ -->
 | 
			
		||||
<section class="testversion-sign">TESZTVERZIÓ</section>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
@ -3,4 +3,6 @@
 | 
			
		||||
    define("SQL_USER", "photowall_user");
 | 
			
		||||
    define("SQL_PASS", "photowpwd");
 | 
			
		||||
    define("SQL_DB", "photowall_db");
 | 
			
		||||
    define("SQL_IP", "172.28.0.6");
 | 
			
		||||
    define("SQL_IP", "172.28.0.6");
 | 
			
		||||
    define('HASHED_REVIS_PASSWORD', '$2y$10$X9CbRyf3TQ2ka/tucKhPRek3iEi1KX74Wk3XM6jtV4nNt5K6oAc1a');
 | 
			
		||||
    define('DEBUG_MODE', true);
 | 
			
		||||
@ -17,8 +17,10 @@
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<!-- MEGJELENÍTŐ -->
 | 
			
		||||
<section class="display" id="display">
 | 
			
		||||
 | 
			
		||||
<section class="display">
 | 
			
		||||
    <section class="blur-layer" id="blurlayer" shown="false"></section>
 | 
			
		||||
    <section id="display"></section>
 | 
			
		||||
    <footer style="text-align: center; margin: 1em 0; color: gray">© KockAzúr, 2021</footer>
 | 
			
		||||
</section>
 | 
			
		||||
 | 
			
		||||
<!-- FELTÖLTŐABLAK MEGNYITÁSA gomb -->
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,13 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
ini_set("display_errors", "On");
 | 
			
		||||
include_once "utils.php";
 | 
			
		||||
 | 
			
		||||
include_once "globals.php";
 | 
			
		||||
// hibakeresés
 | 
			
		||||
if (DEBUG_MODE) {
 | 
			
		||||
    ini_set("display_errors", "On");
 | 
			
		||||
} else {
 | 
			
		||||
    ini_set("display_errors", "Off");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// feltöltési limit 10 percen belül
 | 
			
		||||
define("UPLOAD_LIMIT_10MIN", 10);
 | 
			
		||||
@ -13,36 +18,6 @@ define("INCOMING_DIR", ARTWORKS_DIR . DIRECTORY_SEPARATOR . "incoming");
 | 
			
		||||
define("PUBLISHED_DIR", ARTWORKS_DIR . DIRECTORY_SEPARATOR . "published");
 | 
			
		||||
define("THUMBNAIL_DIR", ARTWORKS_DIR . DIRECTORY_SEPARATOR . "thumbnails");
 | 
			
		||||
 | 
			
		||||
// olyan szöveget ad vissza, amibe csak angol ABC betűi és számok szerepelnek (KL)
 | 
			
		||||
function only_alpha_numeric($input)
 | 
			
		||||
{
 | 
			
		||||
    return preg_replace("/[^a-zA-Z0-9_]+/", "", $input);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// felhasználó IP címének meghatározása... nem is olyan triviális
 | 
			
		||||
// https://stackoverflow.com/a/2031935
 | 
			
		||||
function get_client_ip()
 | 
			
		||||
{
 | 
			
		||||
    foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED') as $key) {
 | 
			
		||||
        if (array_key_exists($key, $_SERVER) === true) {
 | 
			
		||||
            foreach (explode(',', $_SERVER[$key]) as $ip) {
 | 
			
		||||
                $ip = trim($ip); // just to be safe
 | 
			
		||||
                if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 |
 | 
			
		||||
                        FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) {
 | 
			
		||||
                    return $ip;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return $_SERVER['REMOTE_ADDR'];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// csatlakozás az adatbázishoz
 | 
			
		||||
function open_sql_connection()
 | 
			
		||||
{
 | 
			
		||||
    return mysqli_connect(SQL_IP, SQL_USER, SQL_PASS, SQL_DB);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Globális SQL-kapcsolat
 | 
			
		||||
$dbconn = open_sql_connection();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -193,6 +193,7 @@ function upload_from_device() {
 | 
			
		||||
// feltöltőablak megnyitása
 | 
			
		||||
function open_upload_pup() {
 | 
			
		||||
    show(upload_popup_id);
 | 
			
		||||
    show("blurlayer");
 | 
			
		||||
    let display = o("display");
 | 
			
		||||
    display.style.filter = "blur(10px)";
 | 
			
		||||
    scroll_enable(false);
 | 
			
		||||
@ -203,6 +204,7 @@ function open_upload_pup() {
 | 
			
		||||
// feltöltőablak bezárása
 | 
			
		||||
function close_upload_pup() {
 | 
			
		||||
    hide(upload_popup_id);
 | 
			
		||||
    hide("blurlayer");
 | 
			
		||||
    let display = o("display");
 | 
			
		||||
    display.style.filter = "";
 | 
			
		||||
    scroll_enable(true);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								phw.css
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								phw.css
									
									
									
									
									
								
							@ -51,6 +51,7 @@ section.upload-popup {
 | 
			
		||||
    overflow: hidden;
 | 
			
		||||
    border: 1px dashed var(--PUP-BORDERCOLOR);
 | 
			
		||||
    border-radius: 0.5em;
 | 
			
		||||
    z-index: 10;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
section.upload-popup-slider {
 | 
			
		||||
@ -135,6 +136,8 @@ section.upload-btn {
 | 
			
		||||
    display: none;
 | 
			
		||||
    opacity: 0;
 | 
			
		||||
    transition: 0.3s ease;
 | 
			
		||||
    width: 0;
 | 
			
		||||
    height: 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
*[shown="true"] {
 | 
			
		||||
@ -147,6 +150,7 @@ label {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
input[type="text"],
 | 
			
		||||
input[type="password"],
 | 
			
		||||
textarea {
 | 
			
		||||
    margin-left: 20px;
 | 
			
		||||
    border: 0;
 | 
			
		||||
@ -155,12 +159,14 @@ textarea {
 | 
			
		||||
 | 
			
		||||
@media only screen and (max-width: 600px) {
 | 
			
		||||
    input[type="text"],
 | 
			
		||||
    input[type="password"],
 | 
			
		||||
    textarea {
 | 
			
		||||
        max-width: 80vw;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
input[type="text"]:focus,
 | 
			
		||||
input[type="password"]:focus,
 | 
			
		||||
textarea:focus {
 | 
			
		||||
    border-bottom-color: var(--INPUT-ACT-BORDERCOLOR);
 | 
			
		||||
}
 | 
			
		||||
@ -387,3 +393,12 @@ section.thumbnail-container:hover > span.thumb-title {
 | 
			
		||||
    opacity: 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
section.blur-layer {
 | 
			
		||||
    display: block;
 | 
			
		||||
    position: fixed;
 | 
			
		||||
    top: 0;
 | 
			
		||||
    left: 0;
 | 
			
		||||
    right: 0;
 | 
			
		||||
    bottom: 0;
 | 
			
		||||
    z-index: 1;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										33
									
								
								utils.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								utils.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,33 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
include_once "globals.php";
 | 
			
		||||
 | 
			
		||||
// olyan szöveget ad vissza, amibe csak angol ABC betűi és számok szerepelnek (KL)
 | 
			
		||||
function only_alpha_numeric($input)
 | 
			
		||||
{
 | 
			
		||||
    return preg_replace("/[^a-zA-Z0-9_]+/", "", $input);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// felhasználó IP címének meghatározása... nem is olyan triviális
 | 
			
		||||
// https://stackoverflow.com/a/2031935
 | 
			
		||||
function get_client_ip()
 | 
			
		||||
{
 | 
			
		||||
    foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED') as $key) {
 | 
			
		||||
        if (array_key_exists($key, $_SERVER) === true) {
 | 
			
		||||
            foreach (explode(',', $_SERVER[$key]) as $ip) {
 | 
			
		||||
                $ip = trim($ip); // just to be safe
 | 
			
		||||
                if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 |
 | 
			
		||||
                        FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) {
 | 
			
		||||
                    return $ip;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return $_SERVER['REMOTE_ADDR'];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// csatlakozás az adatbázishoz
 | 
			
		||||
function open_sql_connection()
 | 
			
		||||
{
 | 
			
		||||
    return mysqli_connect(SQL_IP, SQL_USER, SQL_PASS, SQL_DB);
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user