diff --git a/.htaccess b/.htaccess index ad9f221..1f22b02 100644 --- a/.htaccess +++ b/.htaccess @@ -1,3 +1,3 @@ RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^(.*)$ index.php?URI=$1 [L,QSA] \ No newline at end of file +RewriteRule ^(.*)$ index.php?URI=$1 [L,QSA] diff --git a/LICENSE b/LICENSE index 810991d..53f99ae 100644 --- a/LICENSE +++ b/LICENSE @@ -29,4 +29,4 @@ create one? Use it to do whatever you want, it may break the website or it may not, it's up to you and the fact that it is provided empty. Only a suggestion: if you don't populate the config file, -what part of the website you think that will work properly? \ No newline at end of file +what part of the website you think that will work properly? diff --git a/lib/css/login.css b/lib/css/login.css index 0e76b86..5262922 100644 --- a/lib/css/login.css +++ b/lib/css/login.css @@ -49,4 +49,4 @@ body { min-width: 100%; margin-top: 5px; } -} \ No newline at end of file +} diff --git a/lib/css/manage.css b/lib/css/manage.css new file mode 100644 index 0000000..734087e --- /dev/null +++ b/lib/css/manage.css @@ -0,0 +1,28 @@ +.urlContainer { + width:100%; + margin:0 auto; + display:inline-block; +} +.urlContainer .urlId, .urlContainer .urlLink, .urlContainer .urlControl { + display: inline; +} +.urlContainer .urlLink { + border: none; + background-color: transparent; + padding: 10px; + font-family: "Consolas", "Lucida Console", "monospace"; + width: 50ch; +} +.urlContainer .urlLink:hover { + border: 2px; + border-radius: 10px; + border-color: aqua; + background-color: lightgrey; +} +.urlContainer .urlLink:focus { + border: none; + border-radius: 10px; + background-color: transparent; + outline: none; + box-shadow: 0px 0px 3px blue; +} diff --git a/lib/errors/404.html b/lib/errors/404.html index 70bc758..045bb8e 100644 --- a/lib/errors/404.html +++ b/lib/errors/404.html @@ -8,4 +8,4 @@

404: Page not found!

- \ No newline at end of file + diff --git a/lib/js/manage.js b/lib/js/manage.js index c70718b..3b6b667 100644 --- a/lib/js/manage.js +++ b/lib/js/manage.js @@ -39,3 +39,56 @@ function insertNewURL() { data.append('url', url); xhr.send( data ); } +function editURL(node) { + var url = node.childNodes[3].value; + var url_id = node.childNodes[1].innerHTML + var xhr = new XMLHttpRequest ( ); + xhr.open ( "POST", 'edit', true ); + xhr.onreadystatechange = function ( ) { + if ( xhr.status == 200 ) { + if ( xhr.readyState == XMLHttpRequest.DONE ) { + var response = xhr.responseText; + response = JSON.parse ( response ); + if ( response [ 'status' ] == 200 ) { + document.getElementById ( "responsetext" ).innerHTML = response [ 'message' ]; + setTimeout( function( ) { + document.getElementById ( 'responsetext' ).innerHTML = "" + }, 1500 ); + } + else { + document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ]; + setTimeout( function( ) { + document.getElementById ( 'responsetext' ).innerHTML = "" + }, 1500 ); + } + } + } + else { + document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ]; + setTimeout( function( ) { + document.getElementById ( 'responsetext' ).innerHTML = "" + }, 1500 ); + } + } + data = new FormData ( ); + data.append('url', url); + data.append('url_id', url_id); + xhr.send( data ); +} +(function(){ + var URLs = document.getElementsByClassName("urlLink"); + for(i=0;iReset your password here - Placeholder

- \ No newline at end of file + diff --git a/lib/php/login.php b/lib/php/login.php index 910223d..22ff460 100644 --- a/lib/php/login.php +++ b/lib/php/login.php @@ -71,7 +71,7 @@ - + diff --git a/lib/php/manage.php b/lib/php/manage.php index 769f9c6..4916183 100644 --- a/lib/php/manage.php +++ b/lib/php/manage.php @@ -13,10 +13,12 @@ Management Panel | <?=$GLOBALS['config']['website_name']?> + + -
+
rowCount ( ) == 0 ) { echo ( "You have not created any URL yet.
" ); @@ -24,7 +26,14 @@ else { $rows = $result->fetchAll ( PDO::FETCH_ASSOC ); foreach ( $rows as $row ) { - echo ( "\t\t\t" . '
' . $row [ 'ID' ] . " | " . $row [ 'URL' ] . "
\n" ); + echo ( "\t\t\t
" ); + echo ( "\t\t\t\t
" . $row [ 'ID' ] . "
" ); + echo ( "\t\t\t\t" ); + echo ( "\t\t\t\t
" ); + echo ( "\t\t\t\t\t" ); + echo ( "\t\t\t\t\t" ); + echo ( "\t\t\t\t
" ); + echo ( "\t\t\t
" ); } } ?> @@ -32,8 +41,8 @@
+ - diff --git a/lib/php/management/edit.php b/lib/php/management/edit.php new file mode 100644 index 0000000..8783794 --- /dev/null +++ b/lib/php/management/edit.php @@ -0,0 +1,33 @@ + 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;