-
Notifications
You must be signed in to change notification settings - Fork 1
/
delete.php
69 lines (69 loc) · 1.44 KB
/
delete.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
65
66
67
68
69
<?php
/**
*
* @Name : ExtractWord/delete.php
* @Version : 1.0
* @Programmer : Max
* @Date : 2019-04-15
* @Released under : https://github.com/BaseMax/ExtractWord/blob/master/LICENSE
* @Repository : https://github.com/BaseMax/ExtractWord
*
**/
if(isset($_POST['srt'])) {
header("Content-Type: text/plain");
$srt=$_POST['srt'];
$filter=$_POST['filter'];
$lines=explode("\n", $srt);
$output="";
// file_put_contents("s".rand(1000,9999).".txt",$srt);
foreach($lines as $line) {
$line=trim($line);
if($line=="") {
continue;
}
$index=(int) $_POST['index'];
$words=explode(" ",$line);
$words=array_filter($words);
$words=array_values($words);
// print_r($words);
if($index < 0) {
$index=count($words) - (-1*($index));
}
else if($index > 0) {
$index--;
}
$line="";
foreach($words as $_index => $word) {
if($_index != $index) {
$line.=$word." ";
}
}
$line=trim($line);
if($filter != "none") {
if($filter == "up") {
$line=strtoupper($line);
}
else if($filter == "low") {
$line=strtolower($line);
}
}
if($line != "") {
$output.=$line."\n";
}
}
print $output;
}
else {
?>
<form action="" method="POST">
<textarea cols="13" rows="20" name="srt"></textarea><br>
<input value="1" name="index" type="number"><br>
<select name="filter">
<option value="none">None</option>
<option value="low">Low</option>
<option value="up">Up</option>
</select>
<button>Check</button>
</form>
<?php
}