forked from phpinternalsbook/PHP-Internals-Book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_php5_redirects.php
executable file
·59 lines (51 loc) · 1.62 KB
/
generate_php5_redirects.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
<?php
// generates html redirect files so that urls do not break with the addition of the php5 folder
$files = [
'introduction.html',
'build_system.html',
'classes_objects.html',
'hashtables.html',
'introduction.html',
'zvals.html',
'build_system/building_extensions.html',
'build_system/building_php.html',
'classes_objects/custom_object_storage.html',
'classes_objects/implementing_typed_arrays.html',
'classes_objects/internal_structures_and_implementation.html',
'classes_objects/iterators.html',
'classes_objects/magic_interfaces_comparable.html',
'classes_objects/object_handlers.html',
'classes_objects/serialization.html',
'classes_objects/simple_classes.html',
'hashtables/array_api.html',
'hashtables/basic_structure.html',
'hashtables/hash_algorithm.html',
'hashtables/hashtable_api.html',
'zvals/basic_structure.html',
'zvals/casts_and_operations.html',
'zvals/memory_management.html',
];
$template = '<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1; url=_URL_">
<script>
window.location.href = "_URL_"
</script>
</head>
<body>
<title>Page Redirection</title>
If you are not redirected automatically, follow <a href="_URL_">this link.</a>
</body>
</html>';
$basePath = __DIR__ . '/BookHTML/';
$baseURL = '/php5/';
foreach ($files as $file) {
$fileName = $basePath . $file;
if (!file_exists(dirname($fileName))) {
mkdir(dirname($fileName));
}
$content = str_replace('_URL_', $baseURL . $file, $template);
file_put_contents($fileName, $content);
}