• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

如何在PHP WEB页面点击链接执行SHELL脚本

php 搞代码 3年前 (2022-01-23) 24次浏览 已收录 0个评论
文章目录[隐藏]

如题,做了个PHP生成EXL的程序,想在页面点击链接能调用这个PHP生成EXL,如何实现?

我现在做法是在WEB页面做了个链接,链到getexl.php,如下:

WEB调用代码:
生成EXL

getexl.php代码:
<?php
system(“/usr/local/bin/php /www/xxxx/exllfile.php”);//生成EXL程序
?>

点链接后IE下边进度条非常慢,执行不了。 /www/xxxx/exllfile.php这个程序一点问题没有,LINUX下运行只有几秒钟,这是什么问题?

回复讨论(解决方案)

没有权限了吧

需要什么权限?我目录和文件都已经是777了

需要服务器对WEB执行的权限配置?

需要服务器设置对WEB执行的权限配置?

点链接后IE下边进度条非常慢,执行不了。
是没有生成文件还是生成了文件不能下载。
如果是生成了文件不能下载。/usr/local/bin/php /www/xxxx/exllfile.php
生成exl文件后,有设置header与echo 文件内容吗?

例如生成的文件名是1.xls。
因为你是需要通知浏览器下载的,需要设置header。

header('content-type:application/octet-stream');header('content-disposition:attachment;filename=1.xls');header('content-length:'.filesize('1.xls'));readfile('1.xls');

是执行不了system里的php,system(“/usr/local/bin/php /www/xxxx/exllfile.php”);内容只有一句echo也执行不了

是否是php关闭了system函数。 disabled_function参数

disabled_function参数是php.ini里配吗?

是把这个参数设成on就可以吧,这样disable_functions = on?

是把这个参数设成on就可以吧,这样disable_functions = on?

不是,这个位置是填写想禁用的方法。例如:
dis*本文来@源gao@daima#com搞(%代@#码@网2

搞代gaodaima码

able_functions = system,exec,shell_exec,passthru,proc_open,proc_close, proc_get_status,checkdnsrr,getmxrr,getservbyname,getservbyport, syslog,popen,show_source,highlight_file,dl,socket_listen,socket_create,socket_bind,socket_accept, socket_connect, stream_socket_server, stream_socket_accept,stream_socket_client,ftp_connect, ftp_login,ftp_pasv,ftp_get,sys_getloadavg,disk_total_space, disk_free_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname

那打开PHP的system函数应该怎么设呢?

那打开PHP的system函数应该怎么设呢?

把 system 函数从 配置文件中 disable_functions 段中删除

检查安全模式。。。。

另外,生成exl也不用这样吧?

已经解决,谢谢大家!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在PHP WEB页面点击链接执行SHELL脚本

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址