An Open Source Content Management System (CMS)

Code Snippet: Wrapping content from another site on your site


Some time ago, there was a question on the Drupal forums about wrapping content from another site to your site.

Here is a basic PHP code snippet that would do just that. You may need to fiddle with the HTML to make the paths absolute to the site that you are wrapping.

If you have improvements, please let me know. 

Also, please do not use this to leech content from other sites, and obey their copyright rules. 

Method 1: Using fopen on a URL 

$url = "http://example.com";

$handle = @fopen ( $url, "r" );
if ( $handle ) {
while ( true ) {
$data = fgets ( $handle, 4096 );
print $data;

if ( true == feof( $handle ) ) {

fclose ( $handle );
else {
$result .= t("Could not contact host: ") . $url;

Method 2: Using fopen on a URL - more concise way

After writing the above, Drupal hacker par excellance, Karoly Negyesi (a.k.a. chx), found  a much more elegant and simple solution:

How to protect a Drupal web site that is under development


Those who like sausages should not see how they are made -- Anonymous

When you are in the midst of developing a web site, you often do not want anyone to see it while it is work in progress. Things are often broken, look ugly, ...etc.

Keeping humans off is not the only reason as well: you also need to keep out search engine crawlers, comment spam bots, email harvesters, Internet Archiver, ...etc.

At the same time, you want specific people to be able to access the site, such as the theme designer, fellow developers, someone from the client's company, ...etc. 

Drupal Planet: Aggregator for Drupal developers and enthusiasts


I occasionally check Technorati to see if somebody cared to link to something they read on my web site. Two days ago, I was doing the random spot checking, and found that my site is linked to from Drupal.org. This is not out of the norm, since I have been using Drupal and contributing to it for some time. What was surprising was to see that a new aggregator was put in, and called Drupal Planet. Althought I frequent Drupal.org daily, I sometimes miss checking the front page, and go to the tracker directly!

Drupal Proxy/Spamming Attempts Can Cause Trouble


A few weeks back, a client was facing a severe problem: their database disk space consumption was steadily going up for no apparent reason. I was called in to help, and provided with the hosting control panel password as well as the Drupal admin password.

Investigation and Findings 

Upon investigation, I found out two things quickly:

  • They were using an old Drupal version based on CivicSpace. It was a 4.4 or earlier version.
  • The cache was growing very fast. For such a relatively small site, cache was 184 MB alone! Larger than the content of anything else on the side (including comments, node, and accesslog).

When I emptied the cache table, it started to grow again almost immediately.

Drupal Open Source community exceeds target in fundraising for new server


A few days ago, Drupal.org server went down, including the forums, the mailing lists, and the CVS repository. Two days passed before a message appeared on the main page asking for 3,000$ in donations to buy a new server. It turns out that for years they were hosted on a shared server that did not keep up with the growth. Last month it did serve 3 million pages, and 100 Gb of bandwidth.When I saw this message it was a few hours old, and asking for money in Euros. About 700$ or so were raised. I donated 80 Euros (about 100$US). After 7 hours, it switched to dollars, and 1,897$ were donated by 56 people.

How to get rid of PHPSESSID in Drupal and other PHP applications


I have a client who uses DreamHost for their Drupal powered web site. They are happy with their service overall, and intend to stay with them. The client is on Drupal 4.6. Although this article focuses on Drupal, much of it applies to about any PHP application you use.

One issue surfaced a short while ago, where randomly, where a string like ?PHPSESSID= would appear in the URLs while users are browsing, like http://example.com/node?PHPSESSID=7dd1d5d1471fa8be2fea8f163cce3257.

Drupal Module: Node Vote


I've written a new Drupal module to allow users to vote on various types of node, as defined by the site admin.The votes are registered, and an overall average score is displayed, as well as the number of votes for that node. Sidebar blocks can be configured to show the top rated nodes, most voted for node, as well as most voting users.An extended version is available that allows voting for multiple criteria for each node, and not just one vote. More information on the Node Vote project page. 


Subscribe to RSS - Drupal