You've already forked OpenShorte.old
Added new lines at the end of files, added edit functionality
This commit is contained in:
@@ -13,4 +13,4 @@ use the code as is, without explicit permission to do so.
|
||||
Such permissions can be requested at copyright@bryanpedini.it
|
||||
No permissions to do anything against this license is given
|
||||
without an explicit and valid motivation to do so, so please
|
||||
don't email me asking any permission without providing a valid reason.
|
||||
don't email me asking any permission without providing a valid reason.
|
||||
|
@@ -10,6 +10,9 @@
|
||||
case "insert":
|
||||
include ( 'lib/php/management/insert.php' );
|
||||
break;
|
||||
case "edit":
|
||||
include ( 'lib/php/management/edit.php' );
|
||||
break;
|
||||
default:
|
||||
http_response_code ( 404 );
|
||||
include ( 'errors/404.html' );
|
||||
|
@@ -20,4 +20,4 @@
|
||||
<p>Reset your password here - Placeholder</p>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@@ -71,7 +71,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
|
||||
<script src="<?=$GLOBALS['config']['installation_path']?>/lib/js/sha512.min.js"></script>
|
||||
<script src="<?=$GLOBALS['config']['installation_path']?>/lib/js/login.js"></script>
|
||||
<script>var script_name = "<?=$GLOBALS['config']['installation_path']?>";</script>
|
||||
|
@@ -13,10 +13,12 @@
|
||||
<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 id="urllist">
|
||||
<div class="urlList">
|
||||
<?php
|
||||
if ( $result->rowCount ( ) == 0 ) {
|
||||
echo ( "You have not created any URL yet.<br>" );
|
||||
@@ -24,7 +26,14 @@
|
||||
else {
|
||||
$rows = $result->fetchAll ( PDO::FETCH_ASSOC );
|
||||
foreach ( $rows as $row ) {
|
||||
echo ( "\t\t\t" . '<div>' . $row [ 'ID' ] . " | " . $row [ 'URL' ] . "</div>\n" );
|
||||
echo ( "\t\t\t<div class=\"urlContainer\">" );
|
||||
echo ( "\t\t\t\t<div class=\"urlId\">" . $row [ 'ID' ] . "</div>" );
|
||||
echo ( "\t\t\t\t<input type=\"text\" class=\"urlLink\" value=\"" . $row [ 'URL' ] . "\">" );
|
||||
echo ( "\t\t\t\t<div class=\"urlControl\" style=\"display: none;\">" );
|
||||
echo ( "\t\t\t\t\t<button><i class=\"fas fa-check\"></i></button>" );
|
||||
echo ( "\t\t\t\t\t<button><i class=\"fas fa-times\"></i></button>" );
|
||||
echo ( "\t\t\t\t</div>" );
|
||||
echo ( "\t\t\t</div>" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -32,8 +41,8 @@
|
||||
<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>
|
||||
<script>var script_name = "<?=$GLOBALS['config']['installation_path']?>";</script>
|
||||
</body>
|
||||
</html>
|
||||
|
33
lib/php/management/edit.php
Normal file
33
lib/php/management/edit.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
if ( ! isset ( $_SESSION [ 'user_id' ] ) ) {
|
||||
header ( 'Content-Type: application/json' );
|
||||
http_response_code ( 401 );
|
||||
$response = [
|
||||
'status' => 401,
|
||||
'error_message' => 'You either are not logged in or you do not have permissions to edit URLs.'
|
||||
];
|
||||
echo ( json_encode ( $response ) );
|
||||
exit;
|
||||
}
|
||||
if ( ! isset ( $_POST [ 'url' ] ) ) {
|
||||
header ( 'Content-Type: application/json' );
|
||||
http_response_code ( 400 );
|
||||
$response = [
|
||||
'status' => 400,
|
||||
'error_message' => 'You either did not provide a URL or you provided an invalid one.'
|
||||
];
|
||||
echo ( json_encode ( $response ) );
|
||||
exit;
|
||||
}
|
||||
$database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
|
||||
$database->connect ( );
|
||||
$database->prepare ( "UPDATE `links` SET `URL`=:url WHERE `ID`=:url_id;" );
|
||||
$database->bind ( [ ':url' => $_POST [ 'url' ], 'url_id' => $_POST [ 'url_id' ] ] );
|
||||
$database->execute ( );
|
||||
header ( 'Content-Type: application/json' );
|
||||
$response = [
|
||||
'status' => 200,
|
||||
'message' => 'URL edited correctly.'
|
||||
];
|
||||
echo ( json_encode ( $response ) );
|
||||
exit;
|
Reference in New Issue
Block a user