Picasa had been banned in Mainland China yesterday. I don't know if it is temporary or persistent. Lots of pictures on my blog are stored in Picasa. Unlike Flickr, I found it difficult to replace domain name or IP to pass the URL/IP filter. So I choose another way: download pictures from Picasa server to my Godaddy host, and replace the picture links in my posts from Picasa to my host. I wrote Imagoxy, a tiny PHP toolkit and Imagoxy-WP, a wordpress plug-in to implement this automatically and dynamically. This mechanism will certainly apply additional overhead and occupy more bandwidth. However, it is sustainable for my small website. Experiment shows it works well with wordpress 2.8.1. I make it open-source under a BSD license and you can get it from https://sourceforge.net/projects/imagoxy/.
Security issues should be considered carefully before it being used in significant applications. Some measures had been taken, but I hope you to review my codes and eliminate the hidden dangers. If you are interested in Imagoxy, welcome to join the small project at SourceForge and contribute your codes! Thanks.
Imagoxy Version 0.51 – Update: 2009/07/20
Imagoxy-WP Version 0.5 – Update: 2009/07/17
Imagoxy
Imagoxy ("image proxy") is a tiny PHP toolkit. It downloads pictures from remote server to local server and relocate corresponding http requests to the local one. It is used to access pictures when the remote server is banned or slow from the network of clients (e.g. Download pictures from Picasa on an unbanned US server and tranfer them to China's viewers where Picasa is banned sometimes).
Licensed under a BSD license.
Install:
1. Modify Imagoxy 'getimg.php' file:
* Set '$work_dir' to the location you wish Imagoxy works at.
* Set '$cache_dir' to the location you wish files downloaded to. (default is OK in most cases)
* Set '$error_file' as the file relocated to when access control denied. (default is OK in most cases)
* Set '$reffer_list' as the legal HTTP_REFERER prefix list.
* Set '$legal_type' as the legal file extension name list. (default is OK in most cases)
2. Update the 'imagoxy' directory to your '$work_dir' and make the '$cache_dir' writable.
3. Configure and deploy Imagoxy front-ends such as Imagoxy-WP.Usage:
1. [ http://www.example.com/imagoxy/getimg.php?s={original URL} ] In this format (we called 'Imagoxy URL'), the http request will be relocated to a file on local server which is downloaded from the original URL. You can embed the Imagoxy URL into your <img src="…"> label. 'http://' in original URL is omissible and the other protocols are not allowed. Notice: as a parameter, original URL should be url-encoded again even if it has been url-encoded. e.g. 'Pic%20A.jpg' -> 'Pic%2520A.jpg'.
2. [ http://www.example.com/imagoxy/getimg.php?u={encoded URL} ] Also does downloading and relocation. However, you should base64-encode, reverse and then url-encode the original URL. In PHP, these are done by 'urlencode(strrev(base64_encode($original_url)))'. This encoding method can pass the URL filter in certain regions.Test:
You can write a html page with an Imagoxy URL in <img src="…"> label. Open it locally, you should see the '$error_file'; after uploading it to the server with the URL prefix in '$reffer_list', you will see the relocated picture correctly.
Enjoy it!
Imagoxy-WP
Imagoxy-WP is a wordpress front-end for Imagoxy. Imagoxy downloads pictures from remote server to local server and relocate corresponding http requests to the local one. It is used to access pictures when the remote server is banned or slow from the network of clients. Imagoxy-WP now converts Picasa URLs to local Imagoxy URLs, and you can also add your customed conversion.
Licensed under a BSD license.
Install:
1. Download Imagoxy. Imagoxy is available at https://sourceforge.net/projects/imagoxy/.
2. Configure and deploy Imagoxy on your server as Imagoxy's README file described.
3. Modify Imagoxy-WP 'imagoxy-wp.php' file:
* Set '$imagoxy_dir' to your Imagoxy location, which is the same as '$work_dir' in Imagoxy.
4. Upload Imagoxy-WP php file or the whole directory to your wordpress '/wp-content/plugins' directory.
5. Enable it in the dashboard.After that, You will see:
<img src="http://lhX.ggpht.com/_WWW/XXX/YYY/ZZZ/sMMM/IMG_NNN.JPG" />
in your blog posts now becomes:
<img src="http://www.example.com/imagoxy/getimg.php?u=AABBCCDDEEFFGGHH" />
Since pictures are downloaded from your own server, it won't be banned then.Enjoy it!
没有评论:
发表评论