uuencode to base64 ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
suhailkaleem
Forum Newbie
Posts: 12
Joined: Thu Nov 07, 2002 9:11 am
Contact:

uuencode to base64 ?

Post by suhailkaleem »

hi !
how can i decode mail attachments uuencode( unix to unix encode ) to base64 encode
any php script ?

Thanks
sk
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

please do not cross post. i have deleted your other post.
suhailkaleem
Forum Newbie
Posts: 12
Joined: Thu Nov 07, 2002 9:11 am
Contact:

Post by suhailkaleem »

ok !
here is what i got

Code: Select all

<?
$filename = "1.txt";
$fd = fopen ($filename, "rb");
$code = fread ($fd, filesize ($filename));
uudecode($code) ;
function uudecode($encode) &#123;
$b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ\
abcdefghijklmnopqrstuvwxyz0123456789+/";

$encode = preg_replace("/^./m","",$encode);
$encode = preg_replace("/\n/m","",$encode);
for($i=0; $i<strlen($encode); $i++) &#123;
if ($encode&#1111;$i] == '`')
$encode&#1111;$i] = ' ';
$encode&#1111;$i] = $b64chars&#1111;ord($encode&#1111;$i])-32];
&#125;

while(strlen($encode) % 4)
$encode .= "=";


$fp = fopen("2.txt" , "w");
fwrite($fp, $encode);


&#125;
?>

but i still get error on this line
$encode[$i] = $b64chars[ord($encode[$i])-32];
error is : Notice: Uninitialized string offset: 76 in D:\maildf\test.php on line 15

Can any one help ?
Thanks
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

try this mate

$encode[$i] = $b64chars[ord($encode['$i'])-32];

hope that works.
Post Reply