PHP:用于嵌入另一个网址的URL缩短/掩盖编码? [英] PHP: Shorter/obscured encoding for a URL embedded in another URL?

查看:198
本文介绍了PHP:用于嵌入另一个网址的URL缩短/掩盖编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写我自己的脚本,基本上让我在一个GET请求的查询字符串发送URL和两个整数维度。我使用Base64为en code,但它的pretty该死的长,我担心的网址可能会太大。

I'm writing myself a script which basically lets me send a URL and two integer dimensions in the querystring of a single get request. I'm using base64 to encode it, but its pretty damn long and I'm concerned the URL may get too big.

有谁知道另一种选择,这样做的短的方法?它需要在一个GET请求收到时是去code-能力,所以MD5 / SHA1是不可能的。

Does anyone know an alternative, shorter method of doing this? It needs to be decode-able when received in a get request, so md5/sha1 are not possible.

感谢您的时间。

修改的:对不起 - 我应该解释的更好:好的,我们的网站,我们显示了才能发布为评论网站截图。我们有我们自己的缩略图/截图服务器。我基本上会被具有图像标签包含一个存储的URL采取截图的连接codeD字符串,而图像的宽度/高度显示。我不希望但它原始文本世界看。很明显的base64可以由任何人来决定,但我们不希望您的普通人拿起URL路径。我真的需要获取:URL,宽度,高度在一个GET请求

Edit: Sorry - I should have explained better: Ok, on our site we display screenshots of websites that get posted up for review. We have our own thumbnail/screenshot server. I'm basically going to be having the image tag contain an encoded string that stores the URL to take a screenshot of, and the width/height of the image to show. I dont however want it in 'raw-text' for the world to see. Obviously base64 can be decided by anyone, but we dont want your average joe picking up the URL path. Really I need to fetch: url, width, height in a single GET request.

推荐答案

网址是注定不会被发送数据的长字符串,EN codeD或不带codeD。某一点后,当你处理如此大量的数据被通过URL发送你应该开始使用POST或某种形式的本地存储。仅供参考,IE浏览器的2038个字符的URL限制。

URLs are not meant to be sending long strings of data, encoded or not encoded. After a certain point, when you're dealing with such large amounts of data being sent through the URL you should just start using POST or some form of local storage. FYI, IE has a URL limit of 2038 characters.

编辑:
我不明白的一件事。你为什么不缓存屏幕截图?它似乎非常耗费资源不得不采取新的截图每次有人浏览网页与IMG链接到该网址。

I don't understand one thing. Why aren't you caching the screen shots? It seems awfully resource intensive to have to take a new screenshot every time somebody views a page with an IMG link to that url.

也许你的受众群体规模较小,而资源是不是一个问题。但是,如果是相反的,实际上它是一个公共网站,不会很好地进行缩放。我知道,我会超越你原来的问题问了,但是这将解决你的问题,等等。

Maybe your audience is small, and resources are not an issue. However, if it is the opposite and in fact it is a public website-that will not scale very well. I know I'm going beyond what your original question asked, but this will solve your question and more.

只要网站是贴上去的,pferably存储URL某种形式的本地存储,$ P $ sql中。我将继续这个例子,如果你选择SQL,但当然你的实现是你的选择。我想有一个主键,网址栏,并LAST_UPDATED时间戳​​,还可以选择图像的缩略图路径。

As soon as the website is posted up, store the url in some sort of local storage, preferably in sql. I am going to continue this example as if you choose SQL, but of course your implementation is your choice. I would have a primary key, url field, and last_updated timestamp, and optionally an image thumbnail path.

通过使用本地存储,你现在可以拉断的图像每次请求的缩略图页面时在服务器上存储在本地的缓存副本。资源的显著量被保存,因为机会是,这些网站不会被经常更新,你可以有一个cron作业或运行时间每x量刷新屏幕截图在整个数据库的脚本。现在,所有你所要做的就是直接链接(这同样取决于你的实现)的图像和没有这庞大的URL字符串的东西会发生。

By utilizing local storage, you can now pull the image off a cached copy stored locally on the server every time the page with the thumbnail is requested. A significant amount of resources is saved, and since chances are that those websites aren't going to be updated very often, you can have a cron job or a script that runs every x amount of time to refresh the screenshots in the entire database. Now, all you have to do is directly link (again this depends on your implementation) to the image and none of this huge url string stuff will happen.

OR,只是采取简单的方法,并做客户端 http://www.snap.com/

OR, just take the easy way and do it client side with http://www.snap.com/

这篇关于PHP:用于嵌入另一个网址的URL缩短/掩盖编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆