-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfolderpreview.php
More file actions
executable file
·26 lines (20 loc) · 1014 Bytes
/
folderpreview.php
File metadata and controls
executable file
·26 lines (20 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php $sqlpath = $_SERVER['DOCUMENT_ROOT'];
$sqlpath .= "/sql-connect.php";
include_once($sqlpath);
$parent = $_REQUEST['parent'];
$folderpreviews = array();
$sql = "SELECT * FROM notes WHERE lineage LIKE '%$parent%' ORDER BY edited DESC";
$sqldata = mysqli_query($dbcon, $sql) or die('error getting data');
while($row = mysqli_fetch_array($sqldata, MYSQLI_ASSOC)) {
if (str_ends_with($row['lineage'], '-'.$parent.'-'.$row['id']) ||$row['lineage'] == $parent.'-'.$row['id']){
// Define the pattern to search for the <h1> header
$pattern = '/<h1>(.*?)<\/h1>/';
// Define the replacement with an anchor tag
$replacement = '<a href="#" onclick="showpanel(' . $row['id'] . '); return false;" style="color: inherit; text-decoration: inherit;"><h1>$1</h1></a>';
// Perform the replacement
$updatedBody = preg_replace($pattern, $replacement, $row['body']);
array_push($folderpreviews, $updatedBody, $row['id']);
}
}
echo json_encode($folderpreviews);
?>