-
Notifications
You must be signed in to change notification settings - Fork 1
/
ajaxModal_EditMessage.php
64 lines (48 loc) · 2.3 KB
/
ajaxModal_EditMessage.php
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
require_once("config.php");
$keyId = sanitize($_GET['keyId'],'alphaNum');
$remoteJid = sanitize($_GET['remoteJid'],'remoteJid');
newEcho(appendTerminal("/*Building modal - Edit Message*/"));
$fromMe = "error";
$message = "error";
$timestamp = time();
if(file_exists($CFG['whatsappDir']."com.whatsapp/databases/msgstore.db")){
newEcho(appendTerminal("Loading msgstore.db"));
loadMsgstore($CFG['whatsappDir']."com.whatsapp/databases/msgstore.db");
$stmt = $DB['msgstore']->prepare("SELECT text_data,timestamp,from_me FROM message_view WHERE key_id = '{$keyId}' limit 1");
$stmt->execute();
$row = $stmt->fetch();
if(empty($row['timestamp'])){
newEcho('alert("message not found")');
}else{
$message=sanitize($row['text_data']);
$timestamp = substr($row['timestamp'], 0, -3);
if($row['from_me']){
$fromMe ="true";
}else{
$fromMe ="false";
}
}
newEcho(appendTerminal("closing msgstore.db"));
closeMsgstore();
}else{
newEcho(appendTerminal("<b>Need to import before running this</b>"));
}
newEcho('document.getElementById("modalTitle").innerHTML="Edit Message";');
$modalBody = '<div class="form-group"><label for="data">Message:</label> <textarea class="form-control" id="dataEdit">'.$message.'</textarea></div>';
$modalBody .= 'From me : '.$fromMe;
$modalBody .= '<input type="hidden" name="keyId" value="'.$keyId.'" id="keyId">';
$modalBody .= '<input type="hidden" name="remoteJid" value="'.$remoteJid.'" id="remoteJidEdit">';
$timestamp = date("Y/m/d H:i:s",$timestamp);
$modalBody .= '<div class="form-group"> <label for="timestamp">Message Timestamp (GMT 0)</label> <input type="text" value="'.$timestamp.'" class="form-control" id="timestamp" disabled></div>';
$modalBody = sanitize($modalBody,"slash");
$modalBody = sanitize($modalBody,"removeLines");
newEcho('document.getElementById("modalBody").innerHTML="'.$modalBody.'";');
$buttons = '<button type="button" onclick="saveMessage()" class="btn btn-success" data-dismiss="modal">Save</button>';
$buttons .= '<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>';
$buttons = sanitize($buttons,"slash");
newEcho('document.getElementById("modalButtons").innerHTML="'.$buttons.'";');
newEcho(appendTerminal("/*End Building Modal*/"));
if($CFG['noAjax']){
newEcho('document.getElementById("loader").src = "";');
}