-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovenote.php
More file actions
executable file
·31 lines (26 loc) · 1.01 KB
/
movenote.php
File metadata and controls
executable file
·31 lines (26 loc) · 1.01 KB
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
27
28
29
30
31
<?php
$sqlpath = $_SERVER['DOCUMENT_ROOT'];
$sqlpath .= "/sql-connect.php";
include_once($sqlpath);
$id = $_REQUEST['moveID']; // 138
$movelineage = $_REQUEST['moveLineage']; // 122 or ''
$sql = "SELECT id, lineage FROM notes WHERE lineage LIKE '%-$id-%' OR lineage LIKE '$id-%' OR lineage LIKE '%-$id' OR lineage LIKE '$id'";
$sqldata = mysqli_query($dbcon, $sql) or die('error getting data');
while($row = mysqli_fetch_array($sqldata, MYSQLI_ASSOC)) {
$tempid = $row['id']; // 138
$oldlineage = $row['lineage']; // 23-138
$oldlineage = strstr($oldlineage, $id); // 138
// Trim leading hyphen if present
$oldlineage = ltrim($oldlineage, '-');
// Construct newlineage based on movelineage
if ($movelineage == '') {
$newlineage = $oldlineage;
} else {
$newlineage = $movelineage . '-' . $oldlineage;
}
$sql1 = "UPDATE notes SET lineage='$newlineage' WHERE id LIKE '$tempid'";
if ($dbcon->query($sql1) === TRUE) {
echo $id;
}
}
?>