-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_loaders.php
More file actions
104 lines (84 loc) · 2.89 KB
/
install_loaders.php
File metadata and controls
104 lines (84 loc) · 2.89 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
*
* @Name: php-installer-ioncube-sourceguardian
* @Repository: https://github.com/BaseMax/php-installer-ioncube-sourceguardian
* @Author: Max Base
* @Date: 07/23/2025
*
**/
main();
function main(): void {
$loaders = [
[
'json_url' => 'https://basemax.github.io/ioncube-loaders-linux-x86-64/data.json',
'prefix' => 'ioncube_loader_lin_',
'ini_file' => '00-ioncube.ini',
],
[
'json_url' => 'https://basemax.github.io/sourceguardian-loader-linux-x86-64/data.json',
'prefix' => 'ixed.',
'ini_file' => '01-sourceguardian.ini',
],
];
foreach ($loaders as $loader) {
install_loader(
$loader['json_url'],
$loader['prefix'],
$loader['ini_file']
);
}
echo "[✓] All loaders installed successfully.\n";
}
function install_loader(string $jsonUrl, string $prefix, string $iniFilename): void {
$phpVersion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;
$extDir = ini_get('extension_dir');
$isZts = (bool) (defined('ZEND_THREAD_SAFE') && ZEND_THREAD_SAFE);
output("\n[*] Installing loader for PHP $phpVersion (" . ($isZts ? 'ZTS' : 'non-ZTS') . ")");
output("[*] Extension directory: $extDir");
if (!is_dir($extDir) || !is_writable($extDir)) {
error("[!] Extension directory is not writable: $extDir");
}
$loaders = fetch_json($jsonUrl);
$downloadUrl = select_loader($loaders, $phpVersion, $isZts);
if (!$downloadUrl) {
error("[!] No loader available for PHP $phpVersion (" . ($isZts ? 'ZTS' : 'non-ZTS') . ")");
}
$soFilename = basename(parse_url($downloadUrl, PHP_URL_PATH));
$destination = rtrim($extDir, '/') . '/' . $soFilename;
output("[*] Downloading: $downloadUrl");
$result = @file_put_contents($destination, fopen($downloadUrl, 'r'));
if (!$result) {
error("[!] Failed to download: $downloadUrl");
}
output("[*] Saved $soFilename to $destination");
$iniPath = "/usr/local/etc/php/conf.d/$iniFilename";
if (!file_put_contents($iniPath, "zend_extension=$soFilename\n")) {
error("[!] Failed to write ini file: $iniPath");
}
output("[*] Created ini file: $iniPath");
}
function fetch_json(string $url): array {
$json = @file_get_contents($url);
if (!$json) {
error("[!] Failed to fetch JSON: $url");
}
$data = json_decode($json, true);
if (!is_array($data)) {
error("[!] Invalid JSON content at: $url");
}
return $data;
}
function select_loader(array $loaders, string $version, bool $isZts): ?string {
if ($isZts && isset($loaders["$version-ts"])) {
return $loaders["$version-ts"];
}
return $loaders[$version] ?? null;
}
function output(string $msg): void {
echo $msg . "\n";
}
function error(string $msg): void {
fwrite(STDERR, $msg . "\n");
exit(1);
}