plugins:jsencode:jsencode_code

Source code: NP_JSEncode.php

NP_JSEncode.php

<?php 
class NP_JSEncode extends NucleusPlugin { 
	function getName() { return 'NP_JSEncode'; }
	function getMinNucleusVersion() { return 220; }
	function getAuthor()  { return 'Katsumi'; }
	function getVersion() { return '0.1.5'; }
	function getURL() {return 'http://hp.vector.co.jp/authors/VA016157/';}
	function getDescription() { return $this->getName().' plugin'; } 
	function supportsFeature($what) { return (int)($what=='SqlTablePrefix'); }
	function doSkinVar($skinType,$type,$info='') {
		switch(strtolower($type)){
		case 'begin':
			$this->num++;
			echo '<span id="nucleus_plugin_jsencode_'.(int)$this->num.'">'.htmlspecialchars($info).'<span style="display:none">';
			ob_start();
			break;
		case 'end':
			$text=ob_get_contents();
			ob_end_clean();
			for ($i=0;$i<strlen($text);$i++) {
				$ascii=ord(substr($text,$i,1));
				if (0x7f<$ascii||$ascii==0xa||$ascii==0xd) echo substr($text,$i,1);
				else if ($ascii) echo '%'.substr('0'.dechex($ascii),-2);
			}
			echo '</span></span>';
?><script type="text/javascript">
/*<![CDATA[*/
  t=document.getElementById('nucleus_plugin_jsencode_<?php echo (int)$this->num; ?>').innerHTML+'';
  i=t.indexOf('>');
  j=t.indexOf('</');
  if (0<=i && 0<=j) document.getElementById('nucleus_plugin_jsencode_<?php echo (int)$this->num; ?>').innerHTML=unescape(t.substr(i+1,j-i-1));
/*]]>*/
</script><?php
			break;
		default:
		}
	}
}
?>
 
plugins/jsencode/jsencode_code.txt · 最終更新: 2011/03/23 21:28 (外部編集)