-
Notifications
You must be signed in to change notification settings - Fork 4
/
export.php
executable file
·48 lines (36 loc) · 1.41 KB
/
export.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
<?php
require_once "Go.php";
$file = "\\\\scout\\C$\\Inetpub\\go.";
$institutions = array("middlebury.edu", "miis.edu");
global $connection;
foreach($institutions as $institution) {
$lines = array();
$chars = "/([\(\)\$\\\?:])/";
$replace = "\\\\$1";
$select = $connection->prepare("SELECT name, url FROM code WHERE institution = :institution");
$select->bindValue(":institution", $institution);
$select->execute();
while ($row = $select->fetch(PDO::FETCH_LAZY, PDO::FETCH_ORI_NEXT)) {
$lines[$row->name] = "RewriteRule ^/" . str_replace("?", "\\?", $row->name) . "/? ". preg_replace($chars, $replace, $row->url) . " [I,R]\r\n";
}
$alias = $connection->prepare("SELECT alias.name AS name, code.url AS url, code.description AS description FROM alias JOIN code ON (alias.code = code.name) WHERE alias.institution = :institution");
$alias->bindValue(":institution", $institution);
$alias->execute();
while ($row = $alias->fetch(PDO::FETCH_LAZY, PDO::FETCH_ORI_NEXT)) {
$lines[$row->name] = "RewriteRule ^/" . str_replace("?", "\\?", $row->name) . "/? ". preg_replace($chars, $replace, $row->url) . " [I,R]\r\n";
}
ksort($lines);
$httpd = "";
foreach($lines as $name => $line) {
$httpd .= $line;
}
if (!$handle = fopen($file . $institution . "\\httpd.ini.diesel", 'wb')) {
echo "Cannot open file!";
exit;
}
if (!fwrite($handle, $httpd)) {
echo "Cannot write to file!";
exit;
}
fclose($handle);
}