USA Linux Users Group Forum Index
Log in Register FAQ Memberlist Search USA Linux Users Group Forum Index Album

URL Woes No More!

 
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Shell Scripting and Programming
View previous topic :: View next topic  
Author Message
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Thu Apr 30, 2024 2:14 pm    Post subject: URL Woes No More! Reply with quote

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
View user's profile Send private message Visit poster's website
mmmna
. . . .


Joined: 21 Apr 2024
Posts: 7224

PostPosted: Wed Jul 15, 2024 9:51 pm    Post subject: Reply with quote

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 2024 LXDE on EeePC 900A with Atom n270 (modded with 32G SATA drive and 2G ram).


Last edited by mmmna on Wed Jul 15, 2024 9:58 pm; edited 1 time in total
Back to top
View user's profile Send private message
mmmna
. . . .


Joined: 21 Apr 2024
Posts: 7224

PostPosted: Wed Jul 15, 2024 9:57 pm    Post subject: Reply with quote

BTW, Server #1 does not connect.



_________________
-Kubuntu 10.04 LTS Beta2 on Celeron D desktop
-PCLinuxOS 2024 LXDE on EeePC 900A with Atom n270 (modded with 32G SATA drive and 2G ram).
Back to top
View user's profile Send private message
mmmna
. . . .


Joined: 21 Apr 2024
Posts: 7224

PostPosted: Wed Jul 15, 2024 10:05 pm    Post subject: Reply with quote

Umm, I need to convert %3B, %3F, %26, %3d etc.



_________________
-Kubuntu 10.04 LTS Beta2 on Celeron D desktop
-PCLinuxOS 2024 LXDE on EeePC 900A with Atom n270 (modded with 32G SATA drive and 2G ram).
Back to top
View user's profile Send private message
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Wed Jul 15, 2024 10:24 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Thu Jul 16, 2024 2:59 am    Post subject: Reply with quote

mmmna wrote:
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?


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
View user's profile Send private message Visit poster's website
mmmna
. . . .


Joined: 21 Apr 2024
Posts: 7224

PostPosted: Wed Jul 22, 2024 1:57 am    Post subject: Reply with quote

Oh. I'm php illiterate.


Back to top
View user's profile Send private message
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Wed Jul 22, 2024 2:21 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Shell Scripting and Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All content © 2024-2009 - Usa Linux Users Group
This forum is powered by phpBB. © 2024-2009 phpBB Group
Theme created by phpBBStyles.com and modified by Crouse