Discuz教程网

php实现Base64在线编码解码

[复制链接]
authicon dly 发表于 2011-1-13 21:30:18 | 显示全部楼层 |阅读模式

  1. <?php
  2. header(\'Content-Type: text/html; charset=gb2312\');
  3. $txt1 = stripslashes(trim( @$_POST[\'text1\']));
  4. $button = @$_POST[\'button\'];
  5. $down = @trim($_GET[\'down\']);
  6. if ($down==1) {
  7. header("Content-type: command");
  8. header("Content-Disposition: attachment; filename=base64_decode.txt");
  9. $contents = file_get_contents(basename($_SERVER[\'PHP_SELF\']));
  10. echo $contents;
  11. exit;
  12. }
  13. ?>
  14. <html xmlns="http://www.w3.org/1999/xhtml">
  15. <head>
  16. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  17. <meta content="Base64在线编码解码" name="keywords">
  18. <title>Base64在线编码解码 gb2312</title>
  19. <style>
  20. P {
  21. FONT-SIZE: 9pt;
  22. line-height:150%;
  23. width:50%;
  24. BORDER:#DDDDDD 1px solid;
  25. padding:5px 5px 5px 5px;text-align:justify;
  26. }
  27. A {
  28. text-decoration: none;
  29. font-size:9pt;
  30. color:blue
  31. }
  32. A:hover {
  33. COLOR: red;
  34. TEXT-DECORATION: underline
  35. }
  36. h1 {
  37. font-size:12pt;
  38. text-align:center;
  39. margin-top:30px;
  40. font-family: 微软雅黑, msyh, Tahoma, Helvetica, sans-serif;
  41. }
  42. .bginput, select {
  43. color:#000000;
  44. vertical-align:middle;
  45. padding:2px;
  46. border:1px solid #BAC0C3;
  47. background:#F9FBFD;
  48. }
  49. .button {
  50. vertical-align:middle;
  51. padding:1px 3px 0px 3px;
  52. background:#F3F4F5;
  53. border:1px solid #B7C0C7;
  54. margin:0px;
  55. width:180px;
  56. }
  57. div {
  58. width:100%;
  59. }
  60. </style>
  61. </head>

  62. <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
  63. <table border="0" width="100%" cellspacing="0" cellpadding="0" height="100%">
  64. <tr><td height="20" bgcolor="#CCCCCC" align =right style="padding-right:5px;">
  65. </td></tr><tr><td valign="top" align =center>

  66. <form name="form1" method="post" action="">
  67. <h1>Base64在线编码解码 gb2312 <a href="?down=1">源码下载</a></h1>
  68. <p>
  69. 请输入转换的地址:
  70. <textarea name="text1" rows="14" class="bginput" style="width:520px;"><?php echo htmlspecialchars($txt1,ENT_QUOTES);?></textarea>
  71. <br>
  72. 请选择转换的方式:
  73. <textarea rows="14" class="bginput" style="width:520px;"><?php
  74. if($button=="编码") echo base64_encode($txt1);
  75. if($button=="解码") echo mb_convert_encoding(base64_decode($txt1),"gb2312","UTF-8");
  76. ?>
  77. </textarea>
  78. <br>
  79. </p>
  80. <input type="submit" name="button" class="button" value="编码" />
  81. <input type="submit" name="button" class="button" value="解码" /><br>
  82. </form>
  83. </td></tr>
  84. <tr><td height="10"></td></tr><tr><td height="20" bgcolor="#CCCCCC" align=center></td>
  85. </tr>
  86. </table>
  87. </body>
  88. </html>
复制代码






上一篇:PHP日期处理函数 整型日期格式
下一篇:pho之Apache的rewrite技术
authicon yuki佳 发表于 2011-6-17 17:59:59 | 显示全部楼层
顶啦,不错吧
authicon fhiejkl 发表于 2011-6-23 09:59:59 | 显示全部楼层
前来看看那
authicon lilac_yao 发表于 2011-6-24 09:59:40 | 显示全部楼层
哈哈  收了你
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-6-18 21:27

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表