Skip navigation.

php

Drupal php code snippet to find stealth spam

Another friend of mine was deeply affected by the stealth-spam problem that I described in the previous page in this booklet.

In order to help them find affected comments, I wrote the following php code snippet for their Drupal 5 web site (the code should work as is for Drupal 6).

<?php
$result = db_query("SELECT c.cid, c.nid, c.uid, c.subject, c.timestamp, u.name, n.title FROM {comments} c
JOIN {users} u ON u.uid = c.uid
JOIN {node} n ON n.nid = c.nid
WHERE c.comment LIKE '%%href%%' AND c.status = 0 ORDER BY c.timestamp DESC");

Lean PHP with a Drupal developer

Introduction

I have no intention of writing a PHP tutorial. Many already exist around the web including, obviously at php.net.

However, as I develop Drupal sites, I often share some PHP scripts with webmasters. One has expressed the desire to learn PHP. This article is then a small guide on how to make the most of what's already available on the web, and also using my PHP code snippets as a basis for the curriculum.

Identifying various elements within a script

A PHP script that I write for a Drupal site would typically contain several of the following elements:

Syndicate content