0
0
This repository has been archived on 2020-11-15. You can view files and clone it, but cannot push or open issues or pull requests.
OpenShorte.old/lib/php/manage.php

54 lines
2.5 KiB
PHP

<?php
if ( ! isset ( $_SESSION [ 'user_id' ] ) ) {
header ( "Location: " . $GLOBALS [ 'config' ] [ 'installation_path' ] . "/login" );
}
$database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
$database->connect ( );
$database->prepare ( "SELECT links.ID, links.URL FROM links WHERE links.created_by = " . $_SESSION [ 'user_id' ] );
$database->execute ( );
$result = $database->get_result ( );
?>
<!DOCTYPE html>
<html>
<head>
<title>Management Panel | <?=$GLOBALS['config']['website_name']?></title>
<link href="<?=$GLOBALS['config']['installation_path']?>/favicon.ico" rel="icon" type="image/x-icon">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css" integrity="sha256-39jKbsb/ty7s7+4WzbtELS4vq9udJ+MDjGTD5mtxHZ0=" crossorigin="anonymous" />
<link href="<?=$GLOBALS['config']['installation_path']?>/lib/css/manage.css" rel="stylesheet">
</head>
<body>
<button onclick="logout()">Logout</button>
<div class="urlList">
<?php
if ( $result->rowCount ( ) == 0 ) {
echo ( "You have not created any URL yet.<br>" );
}
else {
$rows = $result->fetchAll ( PDO::FETCH_ASSOC );
foreach ( $rows as $row ) {
echo ( "\t\t\t<div class=\"urlContainer\">\n" );
echo ( "\t\t\t\t<div class=\"urlId\">" . $row [ 'ID' ] . "</div>\n" );
echo ( "\t\t\t\t<input type=\"text\" class=\"urlLink\" value=\"" . $row [ 'URL' ] . "\">\n" );
echo ( "\t\t\t\t<div class=\"urlControl\" style=\"display: none;\">\n" );
echo ( "\t\t\t\t\t<button><i class=\"fas fa-check\"></i></button>\n" );
echo ( "\t\t\t\t\t<button><i class=\"fas fa-times\"></i></button>\n" );
echo ( "\t\t\t\t</div>\n" );
echo ( "\t\t\t</div>\n" );
}
}
?>
</div>
<input type="text" id="form-url" placeholder="URL:">
<button onclick="insertNewURL()">Insert new URL</button><br>
<div id="responsetext"></div>
<script>
var script_name = "<?=$GLOBALS['config']['installation_path']?>";
</script>
<script src="<?=$GLOBALS['config']['installation_path']?>/lib/js/manage.js"></script>
<script src="<?=$GLOBALS['config']['installation_path']?>/lib/js/logout.js"></script>
</body>
</html>