-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.php
More file actions
101 lines (73 loc) · 2.46 KB
/
Copy patheditor.php
File metadata and controls
101 lines (73 loc) · 2.46 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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
include "inc/header.php";
include "lib/Editor.php";
?>
<?php
$editor = new Editor();
$format = new Format();
$filename = "filename";
$files = "No File Selected";
$content = "No content";
//For opening file
if(isset($_POST['openfile'])){
//upload photo
$photoname = $_FILES['file']['name'];
$tmp_name = $_FILES['file']['tmp_name'];
$location="file_temp/$photoname";
$new_name = $location.time()."-".rand(1000, 9999)."-".$photoname;
move_uploaded_file($tmp_name,$new_name);
$filename = $new_name;
$content = $_POST['content'];
$files = $editor->GetContent($new_name);
}
//End For opening file
/*
if(isset($_POST['saveContent'])){
$content = $format->Stext($_POST['content']);
$file = $editor->SaveContent($filename, $content);
echo "file save successfully";
}
*/
?>
<h3>Web File Editor</h3>
<h2 id="suc">working</h2>
<div class="container">
<div class="row">
<form action="" method="post" enctype="multipart/form-data">
<div class="card-header">
<input type="file" name="file">
<input class="btn btn-secondary" type="submit" name="openfile" value="Open">
</div>
<textarea name="content" class="form-control" style="height:auto; width:auto;" cols="120" rows="20"><?php
echo $files; ?></textarea>
<input class="btn btn-primary" id="saveContent" name="saveContent" onclick="javascript:showUser(<?php echo $filename; ?>, <?php echo $content; ?>)" type="button" value="Save">
</form>
</div>
</div>
<script>
//ajax code here
function showUser(str, content) {
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("suc").innerHTML = this.responseText;
}
};
xmlhttp.open("GET","savefile.php?q="+str+"&c="+content, true);
xmlhttp.send();
}
}
</script>
<?php
include "inc/footer.php";
?>