Category: PHP

Drupal: Take back control of a folder from Drupal and password protecting it

error.jpeg

By default, Drupal takes control of all subdirectories within its root folder. If Drupal resides within the web root of your site, you will not be able to get to any subdirectories that are non-Drupal related. Drupal will give a “Page Not Found” error on any page that doesn’t have Drupal content associated with it.

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

dotProject Recipe: Add journal entries from the project view page

NOTE (07-02-08): The modified Journal module has now been updated to work with v. 2.x of dotProject.

J. Christopher Pereira created a journal module which is quite handy: it lets you add notes to projects – any type of note, without creating a task.

The module is very useful, but a coworker requested that we modify it so you could add a journal note without ever leaving the project view page. Instead of a new window opening to enter the journal note, you simply enter the note into a text box that is always visible on the project view page.

You just enter text in the new text field, hit “save”…

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

Drupal admin: Changing the default Open or Collapsed state of filters and fieldsets in Node editing screens

As you add modules to Drupal, the “Edit” screen of each node can start piling up a lot of optional filters and settings that you can apply to the node. These include comment settings, input filters, image pickers and browsers, authoring settings, etc. The general term for all these added features on the node edit screen is “fieldsets.”

Most of them are collapsed when you first open the screen, which makes it easy to scroll down to the “submit” button or the lower fieldsets. However some modules set themselves to be open by default. This can be a problem if you have to edit a lot of nodes – it causes a lot of extra scrolling and is visually confusing.

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