-
Notifications
You must be signed in to change notification settings - Fork 1
/
_.php
67 lines (45 loc) · 965 Bytes
/
_.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
<?php
$info = file_get_contents('_info.ass');
$styles = file_get_contents('_styles.ass');
foreach(scandir('.') as $fn)
{
if(!preg_match('/\\Hikaru no Go - (\d+).ass/i', $fn, $m)) continue;
echo $fn.PHP_EOL;
$episode = sprintf("%02d", (int)$m[1]);
$orgass = file_get_contents($fn);
$rows = explode("\n", $orgass);
$output = false;
$ass = $episode.'.ass';
@unlink($ass);
$fp = fopen($ass, "w");
fputs($fp, chr(239).chr(187).chr(191));
fputs($fp, str_replace('__EPISODE__', $episode, $info).PHP_EOL);
fputs($fp, $styles.PHP_EOL);
foreach($rows as $row)
{
$row = trim($row);
if(empty($row)) continue;
if($row == '[Events]')
{
$output = true;
}
if($output)
{
fputs($fp, $row.PHP_EOL);
}
}
fclose($fp);
file_get_contents($ass);
$cmp = strcmp($orgass, $ass);
if(strcmp($orgass, $ass) != 0)
{
echo 'replace'.PHP_EOL;
unlink($fn);
rename($ass, $fn);
}
else
{
unlink($ass);
}
}
?>