| 1: | <?php
|
| 2: |
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: |
|
| 9: |
|
| 10: | class EncodeLink extends \Sphp\tools\Component {
|
| 11: |
|
| 12: | protected function onrender() {
|
| 13: | SphpBase::JSServer()->getAJAX();
|
| 14: | $kn = "A8969D2B";
|
| 15: | $this->element->appendAttribute('class', $this->name);
|
| 16: | if($this->element->hasAttribute('key')){
|
| 17: | $kn = $this->getAttribute('key');
|
| 18: | $this->element->removeAttribute('key');
|
| 19: | }
|
| 20: |
|
| 21: | if($this->element->hasAttribute('value')){
|
| 22: | $this->value = $this->getAttribute('value');
|
| 23: | $this->setAttribute('value',SphpBase::sphp_api()->encrypt($this->value,$kn));
|
| 24: | addHeaderJSFunctionCode('ready', 'encodetext1', "function ndecode(t1,key){"
|
| 25: | . ' var result = ""; var strdata = $("#" + t1).attr("value");
|
| 26: | if (strdata.length % 2 == 0) {
|
| 27: | var c = 0;
|
| 28: | for (var i = 0; i < strdata.length; i += 2) {
|
| 29: | var hex = strdata.substr(i, 2);
|
| 30: | var keychar = key.substr((c % key.length) - 1, 1);
|
| 31: | var chara = String.fromCharCode(parseInt(hex, 16) - keychar.charCodeAt(0));
|
| 32: | result += chara;
|
| 33: | c += 1;
|
| 34: | }
|
| 35: | }
|
| 36: | $("." + t1).attr("value","kk");
|
| 37: | $("." + t1).attr("href",$("." + t1).attr("prefix") + result);
|
| 38: | $("." + t1).html($("." + t1).attr("extra") + " " + result);'
|
| 39: | ."}");
|
| 40: | addHeaderJSFunctionCode('ready', $this->name, 'ndecode("'. $this->name .'","'. $kn .'");');
|
| 41: | }
|
| 42: | }
|
| 43: |
|
| 44: |
|
| 45: | }
|
| 46: |
|
| 47: | |