View previous topic :: View next topic |
Author |
Message |
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 607 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Thu Apr 30, 2025 2:14 pm Post subject: URL Woes No More! |
|
|
Lo! And behold! The Lord of Fixed URLs has created an automated tool for fixing those pesky broken URLs. No more will you be stuck with ugly, unclickable links! All the world, rejoice with me!
This tool is located on two different servers for your URL fixing pleasure.
Server #1
Server #2
And the code is listed below for the interested. I'm not proud of that switch statement there, but i just couldn't get the regexp working right.
Code: | <?php
function url_fixer ($url) // Fix the URL so that BBCode doesn't flub it
{
$url_temp = str_split($url);
$url_fixed = "";
for ( $i = 0 ;$i < count($url_temp); $i++)
{
$t=ord($url_temp[$i]);
switch ($t)
{
case (($t >= 65 && $t<=90)||($t>=97&&$t<=122)): // letters
case ($t >= 48&& $t<=57): //numbers
case (35): // #
case (36): // $
case (37): // %
case (38): // &
case (43): // +
case (45): // -
case (46): // .
case (47): // /
case (58): // :
case (61): // =
case (63): // ?
case (95): // _
case (126): // ~
$url_fixed .= $url_temp[$i];
break;
default:
$url_fixed .= sprintf("%%%X", ord($url_temp[$i]));
}
}
return $url_fixed;
}
if ($_POST['DO_WORK'] == "true" )
{
echo '<html>
<head><title>URL Fixer</title></head>
<body>
<center>
<h2>URL Fixer 1.0</h2>
<p>Your formatted results are as follows:</p>
</center>
<table align=center>
<tr><td>Plain URL:</td><td>';
echo url_fixer($_POST['URL']);
echo'</td></tr>
<tr><td>Pretty URL:</td><td>[url=';
echo url_fixer($_POST['URL']);
echo ']';
echo $_POST['LINK'];
echo '[/url]</td></tr>
<tr><td colspan=2 align=center><a href="';
echo htmlspecialchars($_SERVER['PHP_SELF']);
echo '">Try another one</a></td></tr>
</table>
</form>
</body>
</html>';
}
else {
echo '<html>
<head><title>URL Fixer</title></head>
<body>
<center>
<h2>URL Fixer 1.0</h2>
<p>Enter a URL and I will transform it into a valid BBCode URL</p>
</center>
<form action="';
echo htmlspecialchars($_SERVER['PHP_SELF']);
echo '" method="post">
<table align=center>
<tr><td>URL:</td><td><input type="text" name="URL" /></td></tr>
<tr><td>Link Name:</td><td><input type="text" name="LINK" /></td></tr>
<tr><td colspan="2" align="center"><input type="submit" /></td></tr>
</table>
<input type=hidden name="DO_WORK" value="true" />
</form>
</body>
</html>';
}
?> |
_________________ ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)
PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
|
|
Back to top |
|
mmmna . . . .

Joined: 21 Apr 2025 Posts: 7224
|
Posted: Wed Jul 15, 2025 9:51 pm Post subject: |
|
|
You are amazzzzzing.
http://usalug.org/phpBB2/viewtopic.html?t=14663
saved your code as "URL Fixer.htm", but Firefox 3.0.11 makes it look broken. Did I break it?
_________________ -Kubuntu 10.04 LTS Beta2 on Celeron D desktop
-PCLinuxOS 2025 LXDE on EeePC 900A with Atom n270 (modded with 32G SATA drive and 2G ram).
Last edited by mmmna on Wed Jul 15, 2025 9:58 pm; edited 1 time in total |
|
Back to top |
|
mmmna . . . .

Joined: 21 Apr 2025 Posts: 7224
|
Posted: Wed Jul 15, 2025 9:57 pm Post subject: |
|
|
BTW, Server #1 does not connect.
_________________ -Kubuntu 10.04 LTS Beta2 on Celeron D desktop
-PCLinuxOS 2025 LXDE on EeePC 900A with Atom n270 (modded with 32G SATA drive and 2G ram).
|
|
Back to top |
|
mmmna . . . .

Joined: 21 Apr 2025 Posts: 7224
|
Posted: Wed Jul 15, 2025 10:05 pm Post subject: |
|
|
Umm, I need to convert %3B, %3F, %26, %3d etc.
_________________ -Kubuntu 10.04 LTS Beta2 on Celeron D desktop
-PCLinuxOS 2025 LXDE on EeePC 900A with Atom n270 (modded with 32G SATA drive and 2G ram).
|
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 607 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Wed Jul 15, 2025 10:24 pm Post subject: |
|
|
mmmna wrote: | BTW, Server #1 does not connect. |
thats cause the server blew up last week and i did a reinstall. havent gotten around to putting apache back up. expect that tonight or tomorrow.
(i do have streaming music for it already, listen at: http://www.darkstaranime.com:8000/ if you are curious)
mmmna wrote: | Umm, I need to convert %3B, %3F, %26, %3d etc. |
to or from url encoding? i never intended to go from, would have probably written in asp.net if i did (nifty builtin functions for that there).
_________________ ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)
PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
|
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 607 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Thu Jul 16, 2025 2:59 am Post subject: |
|
|
it's a php script, it needs a server so.... yeah probably.
server #1 is back up.
_________________ ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)
PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
|
|
Back to top |
|
mmmna . . . .

Joined: 21 Apr 2025 Posts: 7224
|
Posted: Wed Jul 22, 2025 1:57 am Post subject: |
|
|
Oh. I'm php illiterate.
|
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 607 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Wed Jul 22, 2025 2:21 am Post subject: |
|
|
wait... %3B, %3F, %26, %3d
that is (in order): k, o, &, m
those don't need to be URL encoded.... Decoded yes, but thats not what this script does....
_________________ ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)
PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
|
|
Back to top |
|
|