├── .gitignore
├── LICENSE
├── README.md
├── admin
├── controller.php
└── view.blade.php
├── conf.yml
├── private
├── install.sh
├── scripts
│ ├── addRedirect.sh
│ ├── listRedirect.sh
│ └── removeRedirect.sh
└── storage
│ ├── redirect.html
│ └── redirects
│ └── .gitkeep
├── public
└── .gitkeep
└── redirect.jpg
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | .DS_Store
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023-2024 Emma (prpl.wtf)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
Redirect
2 |
3 |
4 | blueprint ·
5 | pterodactyl
6 |
7 |
8 | Create URL redirects within seconds, right within your admin panel.
9 |
10 |
11 |
12 | > [!IMPORTANT]
13 | > This tool may not be maintained and might break with new releases of both Pterodactyl and Blueprint. Please use at your own risk, little to no support is provided with this extension.
14 |
15 |
16 |
17 | ### Installation
18 | To install this extension, download the latest release of Redirect and drag the `redirect.blueprint` file over to your Pterodactyl installation folder. Then, run `blueprint -install redirect` to finish the installation process.
19 |
20 | If you're using NGINX as your webserver, assuming you followed the Pterodactyl installation instructions, you will also need to modify your config file. Apache and Caddy should work without additional configuration.
21 |
22 | #### NGINX Configuration
23 | - Open your NGINX server config file, typically located in `/etc/nginx/sites-available/`
24 | - Within your `server` block that contains the `index` line (the second server block, if you followed the Pterodactyl guide), change `index index.php` to `index index.php index.html`
25 | - Save the file, then test your config with `nginx -t`
26 | - If the test completes without issue, restart NGINX with `sudo systemctl restart nginx`
27 |
28 |
29 |
30 | ### Usage
31 | Within the extension's page, acessible via the puzzle piece on the admin page, you will see a few different panels:
32 | - Redirects: A list of all of your active redirects
33 | - Add Redirect: Used to add a new redirect
34 | - Name: The link extension that you would like to use as your redirect. E.g. `test` as the name would create a redirect on the URL `yourserver.com/test`
35 | - Destination: The URL you would like the link to redirect to
36 | - Remove Redirect: used to remove a redirect
37 | - Name: The name must match **EXACTLY** that of the link you'd like to remove.
38 |
39 | After adding a redirect, you can visit \/\ to be redirected.
40 |
41 | For example, with the website `serverhost.net` and a redirect named `myvideo`, you would visit `serverhost.net/myvideo`
42 |
43 |
44 |
45 | ### Removal
46 | To remove Redirect from your Pterodactyl panel, run `blueprint -remove redirect`. This might not remove all of your redirects, so remove them before removing Redirect.
47 |
48 |
49 |
50 | ### Screenshots
51 | 
52 |
--------------------------------------------------------------------------------
/admin/controller.php:
--------------------------------------------------------------------------------
1 | 'string|not_regex:/\//',
23 | 'rurl' => 'string|url:http,https',
24 | 'rdel' => 'string',
25 | ];
26 | }
27 |
28 | public function attributes(): array
29 | {
30 | return [
31 | 'rname' => 'Redirect Name',
32 | 'rurl' => 'Redirect URL',
33 | 'rdel' => 'Redirect to Remove',
34 | ];
35 | }
36 | }
37 |
38 | class __identifier__ExtensionController extends Controller
39 | {
40 |
41 | /**
42 | * ^#identifier#^ExtensionController constructor.
43 | */
44 | public function __construct(
45 | private BlueprintExtensionLibrary $blueprint,
46 |
47 | private ViewFactory $view,
48 | private ConfigRepository $config,
49 | private SettingsRepositoryInterface $settings,
50 | ) {
51 | }
52 |
53 | /**
54 | * Return the admin index view.
55 | */
56 | public function index(): View
57 | {
58 | if($this->blueprint->dbGet('^#identifier#^', 'rname') == null) {$this->blueprint->dbSet('^#identifier#^', 'rname', '');}
59 | if($this->blueprint->dbGet('^#identifier#^', 'rurl') == null) {$this->blueprint->dbSet('^#identifier#^', 'rurl', '');}
60 | if($this->blueprint->dbGet('^#identifier#^', 'rdel') == null) {$this->blueprint->dbSet('^#identifier#^', 'rdel', '');}
61 |
62 | # ADD REDIRECT
63 | if($this->blueprint->dbGet('^#identifier#^', 'rname') != "" && $this->blueprint->dbGet('^#identifier#^', 'rurl') != "") {
64 | shell_exec("cd ^#path#^;bash ^#datapath#^/scripts/addRedirect.sh ".$this->blueprint->dbGet('^#identifier#^', 'rname')." ".$this->blueprint->dbGet('^#identifier#^', 'rurl'));
65 | $this->blueprint->dbSet('^#identifier#^', 'rname', '');
66 | $this->blueprint->dbSet('^#identifier#^', 'rurl', '');
67 | };
68 |
69 | # REMOVE REDIRECT
70 | if($this->blueprint->dbGet('^#identifier#^', 'rdel') != "") {
71 | shell_exec("cd ^#path#^;bash ^#datapath#^/scripts/removeRedirect.sh ".$this->blueprint->dbGet('^#identifier#^', 'rdel'));
72 | $this->blueprint->dbSet('^#identifier#^', 'rdel', '');
73 | };
74 |
75 | # LIST REDIRECTS
76 | $redirs=shell_exec("cd ^#path#^;bash ^#datapath#^/scripts/listRedirect.sh");
77 | if($redirs == "") {
78 | $redirs="You don't have any redirects, time to make one!";
79 | };
80 |
81 | return $this->view->make(
82 | 'admin.extensions.^#identifier#^.index', [
83 | 'blueprint' => $this->blueprint,
84 | 'redirects' => $redirs,
85 | 'root' => "/admin/extensions/blueprint",
86 | ]
87 | );
88 | }
89 |
90 | /**
91 | * @throws \Pterodactyl\Exceptions\Model\DataValidationException
92 | * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
93 | */
94 | public function update(__identifier__SettingsFormRequest $request): RedirectResponse
95 | {
96 | foreach ($request->normalize() as $key => $value) {
97 | $this->settings->set('^#identifier#^::' . $key, $value);
98 | }
99 |
100 | return redirect()->route('admin.extensions.^#identifier#^.index');
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/admin/view.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 | {{ $redirects }}
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
43 |
44 |
45 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/conf.yml:
--------------------------------------------------------------------------------
1 | # Thank you for developing with Blueprint.
2 | # For documentation about conf.yml, refer to ptero.shop/dev/conf.
3 |
4 | info:
5 | name: "Redirect"
6 | identifier: "redirect"
7 | description: "Create URL redirects in seconds."
8 | flags: "hasInstallScript"
9 | version: "1.3.2"
10 | target: "alpha-IPS"
11 | author: "prplwtf"
12 | icon: "redirect.jpg"
13 | website: "github.com/prplwtf/blueprint-redirect"
14 |
15 | admin:
16 | view: "admin/view.blade.php"
17 | controller: "admin/controller.php"
18 | css: ""
19 |
20 | data:
21 | directory: "private"
22 | public: "public"
23 |
24 | database:
25 | migrations: ""
26 |
--------------------------------------------------------------------------------
/private/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | chown -R www-data:www-data "^#datapath#^/"*;
4 |
--------------------------------------------------------------------------------
/private/scripts/addRedirect.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # REDIRECT NAME $1
4 | # REDIRECT URL $2
5 |
6 | cp ^#datapath#^/storage/redirect.html ^#datapath#^/storage/redirects/$1;
7 | sed -i "s~redr~$2~g" ^#datapath#^/storage/redirects/$1;
8 | mkdir public/$1;
9 | ln ^#datapath#^/storage/redirects/$1 public/$1/index.html;
--------------------------------------------------------------------------------
/private/scripts/listRedirect.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ls ^#datapath#^/storage/redirects/;
4 |
--------------------------------------------------------------------------------
/private/scripts/removeRedirect.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # REDIRECT NAME $1
4 |
5 | rm ^#datapath#^/storage/redirects/$1;
6 | rm -R public/$1;
--------------------------------------------------------------------------------
/private/storage/redirect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | If you are not being redirected, click here.
6 |
--------------------------------------------------------------------------------
/private/storage/redirects/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prplwtf/Redirect/c9c373d51d7733fedd801e0d475550a177d9109f/private/storage/redirects/.gitkeep
--------------------------------------------------------------------------------
/public/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prplwtf/Redirect/c9c373d51d7733fedd801e0d475550a177d9109f/public/.gitkeep
--------------------------------------------------------------------------------
/redirect.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/prplwtf/Redirect/c9c373d51d7733fedd801e0d475550a177d9109f/redirect.jpg
--------------------------------------------------------------------------------