douqiao1983 2012-07-19 04:22
浏览 30
已采纳

PHP函数争夺javascript代码? [重复]

Possible Duplicate:
How can I obfuscate JavaScript?

I was wondering if there's a way to just move javascript around. So let's say I have a javascript file. I like to be able to have the PHP function just move the JS functions, etc around so it's less readable.

  1. Set path to javascript file
  2. Read the JS file
  3. Grab each JS function or jquery selector and move them around and save the file. The hard part is figuring how how to make sure each block of code is complete... hmm... maybe use 2 returns as a separator? Another idea is make each JS block a single sentence and just use PHP line shuffle?

Curious if this is do-able...

Thanks

UPDATE: What do you guys think of this? Using /// between each function and converting everything into array and then I'll randomize array and output it back out again

<?php
$file_content = file_get_contents("js/js.js");
$content = explode("///", $file_content);
echo count($content);
print_r($content);
?>
  • 写回答

1条回答 默认 最新

  • doubeng3216 2012-07-19 04:25
    关注

    Via PHP not sure but you can adapt UglifyJS. It has really good AST parsing, so you should probably read more on AST (abstract syntax tree) which is basically an outline of javascript code.

    Definitely doable.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?