-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
86 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,79 @@ | ||
<?php | ||
session_name('__Secure-notes'); | ||
session_start(); | ||
|
||
if (isset($_SESSION['nom'], $_SESSION['userId'], $_POST['noteId']) === false) { | ||
http_response_code(403); | ||
return; | ||
} | ||
|
||
require_once __DIR__ . '/config/config.php'; | ||
|
||
$nom = $_SESSION['nom']; | ||
$noteId = $_POST['noteId']; | ||
$noteLink = $_POST['noteLink']; | ||
$key = $_SESSION['key']; | ||
$title = $_POST['title']; | ||
$desc = $_POST['desc']; | ||
|
||
try { | ||
$query = $PDO->prepare("UPDATE notes SET link=:NoteLink, clearTitle=:ClearTitle, clearContent=:ClearContent WHERE id=:NoteId AND user=:CurrentUser AND link IS NULL"); | ||
$query->execute( | ||
[ | ||
':NoteLink' => $noteLink, | ||
':NoteId' => $noteId, | ||
':CurrentUser' => $nom, | ||
':ClearTitle' => $title, | ||
':ClearContent' => $desc | ||
] | ||
); | ||
$query->closeCursor(); | ||
$PDO = null; | ||
} catch (Exception $e) { | ||
http_response_code(500); | ||
return; | ||
} | ||
|
||
$directoryPath = '../../share/' . $noteLink; | ||
if (!file_exists($directoryPath)) { | ||
if (mkdir($directoryPath, 0755, true)) { | ||
$index = fopen($directoryPath . '/index.php', 'w'); | ||
$indexContent = | ||
<<<EOT | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="robots" content="noindex, nofollow"> | ||
<title>Bloc-notes – Léo SEGUIN</title> | ||
<link rel="shortcut icon" href="../../favicon.ico" type="image/x-icon"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="theme-color" content="#272727" id="themecolor"> | ||
<meta name="apple-mobile-web-app-capable" content="yes"> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="#272727"> | ||
<link rel="stylesheet" href="../stylePublic.css"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"> | ||
</head> | ||
<body> | ||
<main data-link="%s"></main> | ||
<footer> | ||
<a href="../../" target="_blank" rel="noreferrer" aria-label="Vers le site"> | ||
Bloc-notes – Léo SEGUIN | ||
</a> | ||
<span class="license">GPL-3.0 ©<?= date('Y') ?></span> | ||
</footer> | ||
<script src="../../assets/js/showdown.min.js" defer></script> | ||
<script src="../scriptPublic.js" defer></script> | ||
</body> | ||
</html> | ||
EOT; | ||
$indexContent = sprintf($indexContent, $noteLink); | ||
fwrite($index, $indexContent); | ||
} else { | ||
http_response_code(403); | ||
return; | ||
} | ||
} else { | ||
http_response_code(500); | ||
return; | ||
} | ||
<?php | ||
session_name('__Secure-notes'); | ||
session_start(); | ||
|
||
if (isset($_SESSION['nom'], $_SESSION['userId'], $_POST['noteId'], $_POST['noteLink']) === false) { | ||
http_response_code(403); | ||
return; | ||
} | ||
|
||
require_once __DIR__ . '/config/config.php'; | ||
|
||
$nom = $_SESSION['nom']; | ||
$noteId = $_POST['noteId']; | ||
$title = $_POST['title']; | ||
$desc = $_POST['desc']; | ||
$noteLink = htmlspecialchars($_POST['noteLink'], ENT_QUOTES); | ||
|
||
try { | ||
$query = $PDO->prepare("UPDATE notes SET link=:NoteLink, clearTitle=:ClearTitle, clearContent=:ClearContent WHERE id=:NoteId AND user=:CurrentUser AND link IS NULL"); | ||
$query->execute( | ||
[ | ||
':NoteLink' => $noteLink, | ||
':NoteId' => $noteId, | ||
':CurrentUser' => $nom, | ||
':ClearTitle' => $title, | ||
':ClearContent' => $desc | ||
] | ||
); | ||
$query->closeCursor(); | ||
$PDO = null; | ||
} catch (Exception $e) { | ||
http_response_code(500); | ||
return; | ||
} | ||
|
||
$directoryPath = '../../share/' . $noteLink; | ||
if (is_dir($directoryPath) === false) { | ||
if (mkdir($directoryPath)) { | ||
$index = fopen($directoryPath . '/index.php', 'w'); | ||
$indexContent = | ||
<<<EOT | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="robots" content="noindex, nofollow"> | ||
<title>Bloc-notes – Léo SEGUIN</title> | ||
<link rel="shortcut icon" href="../../favicon.ico" type="image/x-icon"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="theme-color" content="#272727"> | ||
<meta name="apple-mobile-web-app-capable" content="yes"> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="#272727"> | ||
<link rel="stylesheet" href="../stylePublic.css"> | ||
<link rel="stylesheet" href="/assets/fontawesome/css/all.min.css"> | ||
</head> | ||
<body> | ||
<main data-link="%s"></main> | ||
<footer> | ||
<a href="../../" target="_blank" rel="noreferrer"> | ||
Bloc-notes – Léo SEGUIN | ||
</a> | ||
GPL-3.0 ©<?= date('Y') ?> | ||
</footer> | ||
<script src="../../assets/js/showdown.min.js" defer></script> | ||
<script src="../scriptPublic.js" defer></script> | ||
</body> | ||
</html> | ||
EOT; | ||
$indexContent = sprintf($indexContent, $noteLink); | ||
fwrite($index, $indexContent); | ||
fclose($index); | ||
} else { | ||
http_response_code(403); | ||
return; | ||
} | ||
} else { | ||
http_response_code(500); | ||
return; | ||
} |