Register
It is currently Thu Feb 22, 2018 12:46 am

URL Woes No More!


All times are UTC


Post new topic Reply to topic  [ 8 posts ] 
Author Message
 PostPosted: Thu Apr 30, 2009 2:14 pm   
Advanced Member
User avatar

Joined: Fri Jul 18, 2008 4:54 pm
Posts: 608
Location: South Portland, Maine, USA, Earth, Sol System
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)


Top
 Profile WWW  
 PostPosted: Wed Jul 15, 2009 9:51 pm   
. . . .
User avatar

Joined: Mon Apr 21, 2003 3:56 pm
Posts: 8284
You are amazzzzzing.
http://usalug.org/phpBB2/viewtopic.php?t=14663

saved your code as "URL Fixer.htm", but Firefox 3.0.11 makes it look broken. Did I break it?

_________________
eMachines T5246 AMD 64 X2 w/Antix 16.2 for AMD64
EeePC 900A w/ Antix 16.2 32 bit
Dell Inspiron 1545 w/ Fedora something recent for 32 bit


Last edited by mmmna on Wed Jul 15, 2009 9:58 pm, edited 1 time in total.

Top
 Profile  
 PostPosted: Wed Jul 15, 2009 9:57 pm   
. . . .
User avatar

Joined: Mon Apr 21, 2003 3:56 pm
Posts: 8284
BTW, Server #1 does not connect.

_________________
eMachines T5246 AMD 64 X2 w/Antix 16.2 for AMD64
EeePC 900A w/ Antix 16.2 32 bit
Dell Inspiron 1545 w/ Fedora something recent for 32 bit


Top
 Profile  
 PostPosted: Wed Jul 15, 2009 10:05 pm   
. . . .
User avatar

Joined: Mon Apr 21, 2003 3:56 pm
Posts: 8284
Umm, I need to convert %3B, %3F, %26, %3d etc.

_________________
eMachines T5246 AMD 64 X2 w/Antix 16.2 for AMD64
EeePC 900A w/ Antix 16.2 32 bit
Dell Inspiron 1545 w/ Fedora something recent for 32 bit


Top
 Profile  
 PostPosted: Wed Jul 15, 2009 10:24 pm   
Advanced Member
User avatar

Joined: Fri Jul 18, 2008 4:54 pm
Posts: 608
Location: South Portland, Maine, USA, Earth, Sol System
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)


Top
 Profile WWW  
 PostPosted: Thu Jul 16, 2009 2:59 am   
Advanced Member
User avatar

Joined: Fri Jul 18, 2008 4:54 pm
Posts: 608
Location: South Portland, Maine, USA, Earth, Sol System
mmmna wrote:
You are amazzzzzing.
http://usalug.org/phpBB2/viewtopic.php?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)


Top
 Profile WWW  
 PostPosted: Wed Jul 22, 2009 1:57 am   
. . . .
User avatar

Joined: Mon Apr 21, 2003 3:56 pm
Posts: 8284
Oh. I'm php illiterate.


Top
 Profile  
 PostPosted: Wed Jul 22, 2009 2:21 am   
Advanced Member
User avatar

Joined: Fri Jul 18, 2008 4:54 pm
Posts: 608
Location: South Portland, Maine, USA, Earth, Sol System
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)


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Jump to:  
cron


Powered by phpBB © 2012 phpBB Group
© 2003 - 2012 USA LINUX USERS GROUP