-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrename.php
executable file
·68 lines (51 loc) · 1.41 KB
/
rename.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
if(isset($_FILES)):
$pid_file = $_FILES['pid_file']['name'];
$dir_name = str_replace('.txt', '',$pid_file);
$mods_dir = $_POST['pid_dir'];
//var_dump($mods_dir);
if(!file_exists($pid_file)):
move_uploaded_file($_FILES['pid_file']['tmp_name'], $pid_file);
$fh = fopen($pid_file, 'r');
$pids;
if(!file_exists($dir_name)) {
mkdir($dir_name, 0777, true);
}
while($line = fgets($fh)) {
if(strpos($line, 'has child: ')):
$line = explode('has child: ', $line);
$parent = $line[0];
$child = $line[1];
$pids[] = array(
'parent' => trim($parent),
'child' => trim($child),
);
endif;
}
foreach($pids as $pid) {
$parent_file = str_replace(':', '_', $pid['parent']);
$parent_file = $parent_file.'_MODS.xml';
$child_file = str_replace(':', '_', $pid['child']) .'_MODS.xml';
if(file_exists($mods_dir . '/' . $parent_file)) {
copy($mods_dir .'/'.$parent_file, $dir_name . '/' . $child_file);
} else {
print $parent_file . ' does not exist';
}
}
unlink($pid_file);
endif;
else:
echo 'You did not select a file.';
endif;
?>
<form action="" name="upload_form" method="POST" enctype="multipart/form-data">
<fieldset>
<lable>PID file</lable>
<input type="file" name="pid_file" />
</fieldset>
<fieldset>
<lable>Mods directory</lable>
<input type="text" name="pid_dir" />
</fieldset>
<input type="submit" />
</form>