简体   繁体   English

在PHP中创建和保护电子表格的最简单的解决方案是什么?

[英]What is the simplest solution for creating & securing a spreadsheet in PHP?

I need to create a daily report for a third party with sensitive information included and email over night. 我需要为第三方创建每日报告,其中包含敏感信息并整夜发送电子邮件。

What is easier: creating a xls and password protecting that in PHP, or creating either a csv or xls and zipping that file and password protecting it? 更简单的方法是:在PHP中创建一个xls和密码来保护它,还是创建一个csv或xls并压缩该文件和密码来保护它?

Ideally one excel class would take care of the creation and security? 理想情况下,一个excel类将负责创建和安全性?

If anyone can point me in the right direction I'd really appreciate it. 如果有人能指出正确的方向,我将非常感激。

I wouldn't recommend emailing sensitive information. 我不建议通过电子邮件发送敏感信息。 I think you better email a link (https), let the user click the link that brings to a login page that asks for password. 我认为您最好通过电子邮件发送链接(https),让用户单击该链接,该链接会转到要求输入密码的登录页面。 The page then can generate the XLS on the fly if the user authenticated correctly. 如果用户正确认证,则页面可以即时生成XLS。

The Excel password is exploitable, once you have the file. 拥有文件后,即可利用Excel密码。 Another story is trying to exploit a secure PHP login. 另一个故事是试图利用安全的PHP登录名。

https://www.google.com/search?q=recover+Excel+file+password&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb https://www.google.com/search?q=recover+Excel+file+password&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:zh-CN:official&client=firefox-a&channel=sb

Generating the XLS on the fly may mean, either dumping a prapared file (keep it outside of the document root, so it is not accessible via www) or better, read yesterday report data on the fly and dump it out as cells. 即时生成XLS可能意味着,要么转储一份普通文件(将其保留在文档根目录之外,以便无法通过www对其进行访问),要么更好,即时读取昨天的报告数据并将其作为单元转储。 At this point using CSV or Excel is your choice. 此时,您可以选择使用CSV或Excel。

For generating Excel files (both on the fly or to save on disk) you can use the excellent PHPExcel https://phpexcel.codeplex.com/ 为了生成Excel文件(即时生成或保存在磁盘上),您可以使用出色的PHPExcel https://phpexcel.codeplex.com/

To let the user download a file, you have to set the correct headers before any PHP output: 要让用户下载文件,必须在任何PHP输出之前设置正确的标头:

header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename=REPORT.XLS');

then output (echo) the file contents (either reading it from disk or generating on the fly) and exit. 然后输出(回显)文件内容(从磁盘读取文件或动态生成文件)并退出。 In PHPExcel to download an Excel5 doc you would: 在PHPExcel中下载Excel5文档,您将:

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');

If those really are sensitive information neither of those two options. 如果这些确实是sensitive information ,则这两个选项都不是。

The file You generate have to be not accessible from network and only be served by full authentication server on PHP side. 您生成的文件必须不能通过网络访问,并且只能由PHP端的完全身份验证服务器提供。 You cant just email the file cause its already dangerous, just provide user a link to file-download service on server. 您不能仅通过电子邮件发送文件,因为它已经很危险,只需向用户提供服务器上文件下载服务的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在PHP中创建SOAP服务器的最佳解决方案是什么? - What is the best solution for creating a SOAP Server in PHP? 使用PHP即时创建Excel电子表格 - Creating Excel spreadsheet on the fly with PHP 在表中存储数据但随机ID检索的最简单数据库解决方案是什么? - What is the simplest Database solution for storing data in tables, but randomised ID retrieval? 在PHP中实现Parallel cURL的最简单方法是什么? - What is the simplest way to implement Parallel cURL in PHP? 在PHP中引用多字节字符串的最简单方法是什么? - What is the simplest way to reference a Multibyte string in PHP? 将php代码定义为变量-最简单的方法是什么? - Defining php code as a variable - what is the simplest way? 使用PHP和cURL通过Google电子表格API从XLS创建电子表格 - Creating spreadsheet from XLS through Google spreadsheet API with PHP and cURL 什么是创建带有右键单击功能的网格的免费的AJAX PHP好的解决方案? - What is a good, free, AJAX PHP solution for creating a grid with right-click functionality? 在自定义的magento 2模块中使用外部php库的最简单方法是什么? - What is the simplest way to use an external php library in a custom magento 2 module? 什么是最简单的检查PHP中字符串的第一个和最后一个字符 - What is the simplest of checking first and last character of a string in php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM