【发布时间】:2013-04-07 13:14:57
【问题描述】:
我制作了一些类,其中包含许多使用 PHP 正确记录的方法(类似于库)。
现在,其他开发人员要做的只是需要我在他们的代码中创建的 PHP 库并使用其中的预定义函数。
是否可以向其他 PHP 开发人员(需要文件)隐藏 PHP 代码(我创建的库),只向他们显示函数名称、参数及其文档而不显示其中的代码?我不是在谈论可以可逆的混淆,我是在谈论防止用户实际看到任何代码。
例如。
/**
*
* CREATE A NEW THREAD
* @param unknown_type $uid User ID of person who is creating the thread
* @param unknown_type $participant An array having collection of UID of people who are participating in this conversation
* @param unknown_type $msgtype Message Type Flags (1-normal, 2-chat, 3-sent as email, 4-profile post, 5-group post, 6-customer support)
* @param unknown_type $subject Subject of the thread
* @param unknown_type $tname Thread Name
* @param unknown_type $tpic Thread Cover Picture (Defaults to "")
* @param unknown_type $tflag Thread Flag (1-allowed,2-under review,3-blocked) (Defaults to 1)
* @return string|Ambigous <string, unknown> Thread ID on success, "" on failure
*/
public function createthread($uid,$participant,$msgtype,$subject,$tname,$tpic="",$tflag="1")
{
$randobj=new uifriend();
$tid=$randobj->randomstring(30,DB_MESSAGE,MSG_OUTLINE,msgoutline_tid);
$socialobj=new socialoperations();
$listid=$socialobj->createlist("threadlist_".$tid, "2",$msgtype,"1",$uid);
if($socialobj->addtolist($participant, $listid, $uid)!="SUCCESS")
{
return "";
}
if($listid=="")
{
$lasterror="An error occured in creating thread! Unable to Create Lists!";return "";
}
$dbobj=new dboperations();
$res=$dbobj->dbinsert("INSERT INTO ".MSG_OUTLINE." (".msgoutline_tid.",".msgoutline_subject.",".msgoutline_fid.",".msgoutline_participantid.",".msgoutline_msgtype.",".msgoutline_threadpic.",".msgoutline_threadflag.") VALUES
('$tid','$subject','$uid',$listid,'$msgtype','$tpic','$tflag')",DB_MESSAGE);
if($res=="SUCCESS")
{
return $tid;
}
else
{
$lasterror="Unable to create Thread!";return "";
}
}
其他开发者必须只能看到我在函数上面写的带有函数名和参数的文档,但不能以任何方式访问代码。
为什么我想要这个:我的 PHP 文件中有很多安全代码,我不想向其他开发人员展示,但仍然允许他们调用函数并读取返回值。
【问题讨论】:
-
您不能隐藏要包含的代码,因为 PHP 解释器也无法读取文件的内部文本。
-
如果您允许他们说
include 'yourfile.php';,您就是授予 PHP 访问该文件的权限,否则无法包含该文件。如果您授予它这样做的权限,开发人员所要做的就是readfile('yourfile.php');并获取它的内容。 -
这个问题不是重复的。至少不是关于代码混淆的 2 个相关问题。这显然是不显示任何代码。任何有权这样做的人,请重新打开它。
-
@vignesh,答案现在已经关闭,this comment is too narrow to contain the answer 但我会尝试:另一种方法是在单独的网站中制作某种 API。例如,如果您的开发人员输入
apiforweb.org/functionname?v1=5&v2=7,那么您可以将其链接到具有两个参数的函数functionname(),v1和v2,其值为5和7,并回显返回的值 (他们会拿来的)。如您所见,这会带来很多麻烦、额外的开发人员时间和更长的页面加载时间,但它可能会根据您的需要进行调整。 -
@FrankPresenciaFandos 如果您想将您的 cmets 移到答案中,该问题已重新打开 :)
标签: php