<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Totti的部落格]]></title> 
<link>https://iam.ittot.com/index.php</link> 
<description><![CDATA[记录我的生活，收集我的收集]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Totti的部落格]]></copyright>
<item>
<link>https://iam.ittot.com/read.php/659.htm</link>
<title><![CDATA[简易的base64编码和解码]]></title> 
<author>Totti &lt;totti5116@163.com&gt;</author>
<category><![CDATA[收集]]></category>
<pubDate>Wed, 28 Feb 2007 15:33:22 +0000</pubDate> 
<guid>https://iam.ittot.com/read.php/659.htm</guid> 
<description>
<![CDATA[ 
	转自：BO-BLOG<br/><br/>之前曾经说过，侧边栏项目支持PHP代码，而不仅仅是html。但是为了保险起见，程序要求所有出现在侧边栏项目中的PHP代码全部用base64编码。以侧边模板切换器的代码为例：<br/><div class="code">&lt;php&gt;Z2xvYmFsICRsYW5nZnJvbnQsICR0ZW1wbGF0ZTsNCiRsYW5nZm<br/>(中间省略)<br/>&lt;/php&gt;</div><br/>这一部分，也就是被 <php></php>包围起来的部分，就是base64_encode后的php代码。<br/><br/>不过这样一来，改写代码和编码就显得比较麻烦。以下是我自己写的一个小程序，非常简陋，用于快速base64_encode与base64_decode。贴出来给需要的插件开发者使用。（顺便测试代码高亮功能）<br/><br/>以下请另存为 decodephp.php，直接打开就能用了。<br/><div class="code" style="overflow: auto;"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?PHP<br />error_reporting</span><span style="color: #007700">(</span><span style="color: #0000BB">E_ERROR&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">E_WARNING&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">E_PARSE</span><span style="color: #007700">);<br />@</span><span style="color: #0000BB">set_magic_quotes_runtime&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />@</span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">"Content-Type:&nbsp;text/html;&nbsp;charset=utf-8"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$code</span><span style="color: #007700">=</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'code'</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">$action</span><span style="color: #007700">=</span><span style="color: #0000BB">$_REQUEST</span><span style="color: #007700">[</span><span style="color: #DD0000">'action'</span><span style="color: #007700">];<br />if&nbsp;(</span><span style="color: #0000BB">get_magic_quotes_gpc</span><span style="color: #007700">())&nbsp;</span><span style="color: #0000BB">$code</span><span style="color: #007700">=</span><span style="color: #0000BB">stripslashes</span><span style="color: #007700">(</span><span style="color: #0000BB">$code</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">$action</span><span style="color: #007700">==</span><span style="color: #DD0000">'decode'</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$code</span><span style="color: #007700">=</span><span style="color: #0000BB">base64_decode</span><span style="color: #007700">(</span><span style="color: #0000BB">$code</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$code</span><span style="color: #007700">=</span><span style="color: #0000BB">nl2br</span><span style="color: #007700">(</span><span style="color: #0000BB">htmlspecialchars</span><span style="color: #007700">(</span><span style="color: #0000BB">$code</span><span style="color: #007700">));<br />}<br />else&nbsp;</span><span style="color: #0000BB">$code</span><span style="color: #007700">=</span><span style="color: #0000BB">base64_encode</span><span style="color: #007700">(</span><span style="color: #0000BB">$code</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;<br /></span><br />&lt;html&gt;<br />&lt;body&nbsp;style="text-align:&nbsp;center;"&gt;<br />&lt;div&nbsp;style="text-align:&nbsp;left;&nbsp;width:&nbsp;90%;&nbsp;font-family:&nbsp;Verdana;&nbsp;font-size:&nbsp;14px;&nbsp;margin:&nbsp;auto;&nbsp;background:&nbsp;#EFEFEF;&nbsp;color:&nbsp;#000;"&gt;&lt;b&gt;Result:&nbsp;&lt;/b&gt;&lt;br&gt;&lt;br&gt;<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;(</span><span style="color: #0000BB">$code</span><span style="color: #007700">);</span><span style="color: #0000BB">?&gt;</span>&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;br&gt;&lt;br&gt;<br />&lt;form&nbsp;action="decodephp.php"&nbsp;method='post'&gt;<br />&lt;textarea&nbsp;name='code'&nbsp;cols='100'&nbsp;rows='16'&gt;&lt;/textarea&gt;&lt;br&gt;<br />&lt;input&nbsp;type='radio'&nbsp;name='action'&nbsp;value='decode'&nbsp;checked&gt;DECODE&nbsp;&amp;nbsp;&nbsp;&amp;nbsp;&nbsp;&lt;input&nbsp;type='radio'&nbsp;name='action'&nbsp;value='encode'&gt;ENCODE&lt;br&gt;&lt;br&gt;<br />&lt;input&nbsp;type='submit'&gt;&nbsp;&amp;nbsp;&nbsp;&amp;nbsp;&nbsp;&lt;input&nbsp;type='reset'&gt;<br />&lt;/form&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;</span>
</code></div><br/><br/>将侧边栏模板切换器的编码部分（不包含<php>和</php>）拷贝到输入框内，解码后的结果为：<br/><div class="code" style="overflow: auto;"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?<br /></span><span style="color: #007700">global&nbsp;</span><span style="color: #0000BB">$langfront</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$template</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$langforselskin</span><span style="color: #007700">=(</span><span style="color: #0000BB">$langfront</span><span style="color: #007700">==</span><span style="color: #DD0000">'zh-tw'</span><span style="color: #007700">)&nbsp;?&nbsp;</span><span style="color: #DD0000">'恢復預設'&nbsp;</span><span style="color: #007700">:&nbsp;</span><span style="color: #DD0000">'恢复默认'</span><span style="color: #007700">;<br />include_once&nbsp;(</span><span style="color: #DD0000">"data/cache_skinlist.php"</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">is_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$skinset</span><span style="color: #007700">))&nbsp;{<br />foreach&nbsp;(</span><span style="color: #0000BB">$skinset&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$skin</span><span style="color: #007700">)&nbsp;{<br />@list(</span><span style="color: #0000BB">$skid</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$skname</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$skauthor</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$skintro</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$skdir</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$skthumbnail</span><span style="color: #007700">)=@</span><span style="color: #0000BB">explode</span><span style="color: #007700">(</span><span style="color: #DD0000">'|'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$skin</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$skid</span><span style="color: #007700">==</span><span style="color: #0000BB">$template</span><span style="color: #007700">[</span><span style="color: #DD0000">'id'</span><span style="color: #007700">])&nbsp;</span><span style="color: #0000BB">$optionskinlist</span><span style="color: #007700">.=</span><span style="color: #DD0000">"&lt;option&nbsp;value='</span><span style="color: #007700">{</span><span style="color: #0000BB">$skdir</span><span style="color: #007700">}</span><span style="color: #DD0000">'&nbsp;selected='selected'&gt;</span><span style="color: #007700">{</span><span style="color: #0000BB">$skname</span><span style="color: #007700">}</span><span style="color: #DD0000">&lt;/option&gt;"</span><span style="color: #007700">;<br />else&nbsp;</span><span style="color: #0000BB">$optionskinlist</span><span style="color: #007700">.=</span><span style="color: #DD0000">"&lt;option&nbsp;value='</span><span style="color: #007700">{</span><span style="color: #0000BB">$skdir</span><span style="color: #007700">}</span><span style="color: #DD0000">'&gt;</span><span style="color: #007700">{</span><span style="color: #0000BB">$skname</span><span style="color: #007700">}</span><span style="color: #DD0000">&lt;/option&gt;"</span><span style="color: #007700">;<br />}<br />}<br /></span><span style="color: #0000BB">$phpreturn</span><span style="color: #007700">=</span><span style="color: #DD0000">"&lt;form&nbsp;action='index.php'&nbsp;method='post'&nbsp;id='skinselector'&gt;&lt;select&nbsp;name='tem'&nbsp;onchange="</span><span style="color: #0000BB">document</span><span style="color: #007700">.</span><span style="color: #0000BB">getElementById</span><span style="color: #007700">(</span><span style="color: #DD0000">'skinselector'</span><span style="color: #007700">).</span><span style="color: #0000BB">submit</span><span style="color: #007700">();</span><span style="color: #DD0000">"&gt;&lt;option&nbsp;value='____'&gt;</span><span style="color: #007700">{</span><span style="color: #0000BB">$langforselskin</span><span style="color: #007700">}</span><span style="color: #DD0000">&lt;/option&gt;</span><span style="color: #007700">{</span><span style="color: #0000BB">$optionskinlist</span><span style="color: #007700">}</span><span style="color: #DD0000">&lt;/select&gt;&lt;/form&gt;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div><br/>Tags - <a href="https://iam.ittot.com/go.php/tags/bo-blog/" rel="tag">bo-blog</a>
]]>
</description>
</item><item>
<link>https://iam.ittot.com/read.php/659.htm#blogcomment1429</link>
<title><![CDATA[[评论] 简易的base64编码和解码]]></title> 
<author>haha &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Mar 2007 05:32:40 +0000</pubDate> 
<guid>https://iam.ittot.com/read.php/659.htm#blogcomment1429</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item><item>
<link>https://iam.ittot.com/read.php/659.htm#blogcomment1434</link>
<title><![CDATA[[评论] 简易的base64编码和解码]]></title> 
<author>伊朵可儿 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 03 Mar 2007 08:15:09 +0000</pubDate> 
<guid>https://iam.ittot.com/read.php/659.htm#blogcomment1434</guid> 
<description>
<![CDATA[ 
	你好啊，无意中看到你的博客，好可爱的……顶一下
]]>
</description>
</item><item>
<link>https://iam.ittot.com/read.php/659.htm#blogcomment1435</link>
<title><![CDATA[[评论] 简易的base64编码和解码]]></title> 
<author>robbi &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 03 Mar 2007 16:36:26 +0000</pubDate> 
<guid>https://iam.ittot.com/read.php/659.htm#blogcomment1435</guid> 
<description>
<![CDATA[ 
	好可爱~~我汗
]]>
</description>
</item>
</channel>
</rss>