在我的网站上登录的用户可以创建文档,就像在 Google Docs 上一样。该文档可以由用户公开,或私有(默认)。文档存储在这样的数据库表中:
| id | title | content | public | owner |
| 1 | asd | asd | 1 | 1 |
| 2 | asd | asd | 0 | 1 |
| 3 | asd | asd | 0 | 2 |
如果 public 等于 1,它是一个公共文档,可以通过任何用户的链接查看:site.com/documents/id
问题是,即使文档可以公开,我也不希望用户能够一直将 url ID 增加 1 以访问所有公开文档:
- site.com/documents/1
- site.com/documents/2
- site.com/documents/3
等等...
所以也许我应该散列 ID 或类似的东西?像这样:
<?php echo 'site.com/documents/'.md5($id); ?>
问题是,我无法弄清楚它在服务器端是哪个ID,因为它是散列的......
我能做些什么来解决我的问题?