Tag: php

Drupal module Feed Aggregator escapes HTML tags in feeds

Drupal’s Feed aggregator has a problem displaying some of the escaped tags in Google Alerts Feeds. For example, see the screenshot below:

Picture 31.jpeg

The fix is to alter the code in
modules/aggregator/aggregator.module

Search for

 function aggregator_save_item($edit)

In both the UPDATE statement and the INSERT statement:

replace $edit['title']

with

strip_tags($edit['title'])
Continue reading

dotProject Recipe: speeding up DotProject

I run a dotproject site on a hosted server. Once more than a few people began using the site at once, we found that peformance was dropping enough to warrant looking into optimization possibilities. So far, it seems that there are two main steps to take: turn on caching, and add indexes to several tables in the database.

1. Turn on caching in gacl.class.php

In the file gacl.class.php, change the following settings to TRUE and FALSE as shown:

/** @var boolean Caches queries if true */
var $_caching = TRUE;

/** @var boolean Force cache to expire */
var $_force_cache_expire = FALSE;

Continue reading

Cleaning up and Preventing HTTP Injection Attacks

I recently had the (undesired) opportunity to learn about HTTP and SQL injection attacks. It took a great deal of effort to diagnose and clean up, but hopefully what I learned from the experience may help you prevent these attacks on your own site or clean up after such an attack.

I first found out my site had been compromised because one of the subdomains started displaying “403” errors (permission denied) and one of the users notified me that the site could no longer be reached. At this time, the rest of the site seemed fine, so I had not noticed anything was wrong with it myself.

On examining the subdomain files, it turned out that the .htaccess file had some new directives written into it, which had the effect of blocking all access to the site. When I further examined the file, it appeared that the actual intent had been to redirect only the users that arrived at the site through a search engine, while allowing direct visitors to see the site as usual.

Continue reading

Dealing with comment spam on Gallery 2

Finally! I found a query that effectively deletes the comment spam from the Gallery 2 database. These can be run through phpMyAdmin, but my next task is to turn this into a php script that can be run as a cron job.

To delete comments posted by an IP, or a few IPs, run this SQL statement:

delete ce, e, co from g2_ChildEntity ce, g2_Entity e, g2_Comment co where ce.g_id=e.g_id and e.g_id=co.g_id and e.g_entityType='GalleryComment' and (co.g_host='67.104.112.176' or co.g_host='209.31.123.128')

To delete comments based on the comment itself, run this SQL statement:

delete ce, e, co from g2_ChildEntity ce, g2_Entity e, g2_Comment co where ce.g_id=e.g_id and e.g_id=co.g_id and e.g_entityType='GalleryComment' and (co.g_comment like '%[url=http://%')
Continue reading

Construct navigation for your Amazon aStore using php and YUI

Amazon “aStores” are very easy to set up, but you will probably find you want to customize the navigation, particularly if you want to integrate the store into your own site. I’m in the process of doing just that, and decided to construct my own navigation system for the DesignSpace book shop.. The php script that creates the tabs for the store is based on the YUI (Yahoo UI) “Tab View Control” and can be easily adapted to your own site.

This is just a down and dirty approach but it is a good start for you to build from.

Continue reading

Construct a variable name in PHP from a string and another variable

The “Shop” page of this site is a php page which displays an amazon a-store category and the second level tabs appropriate to that category, using a “node id”.

The html for the tabs is defined in an included page like this:

<?php
//-------------//
$tabs6= '<ul class="yui-navset bd">';
$tabs6.='<li class="first selected" id="tab6"><a href="shop.php?tab=6" >Web Development</a></li>';
$tabs6.='<li class="" id="tab180"><a href="shop.php?tab=180" >CSS</a></li>';
$tabs6.='<li class=" " id="tab183"><a href="shop.php?tab=183">Javascript</a></li>';
$tabs6.='<li class="last" id="tab181"><a href="shop.php?tab=181">DHTML</a></li>';
$tabs6.='</ul>';

$tabs180= '<ul class="yui-navset bd">';
$tabs180.='<li class="first " id="tab6"><a href="shop.php?tab=6" >Web Development</a></li>';
$tabs180.='<li class="selected" id="tab180"><a href="shop.php?tab=180" >CSS</a></li>';
$tabs180.='<li class=" " id="tab183"><a href="shop.php?tab=183">Javascript</a></li>';
$tabs183.='<li class="last" id="tab181"><a href="shop.php?tab=181">DHTML</a></li>';
$tabs180.='</ul>';

$tabs183= '<ul class="yui-navset bd">';
$tabs183.='<li class="first " id="tab6"><a href="shop.php?tab=6" >Web Development</a></li>';
$tabs183.='<li class="" id="tab180"><a href="shop.php?tab=180" >CSS</a></li>';
$tabs183.='<li class=" selected" id="tab183"><a href="shop.php?tab=183">Javascript</a></li>';
$tabs183.='<li class="last" id="tab181"><a href="shop.php?tab=181">DHTML</a></li>';
$tabs183.='</ul>';

?>
Continue reading