drupal

Recovering a hacked Drupal system

In order to check if your Drupal 7 website has been hacked, install the following modules:

drush dl site_audit
drush dl drupalgeddon

clear drush cache and run:

drush cache-clear drush
drush asec

Some attack does two things: firstly, in creates NEW php files scattered throughout your directory structure. The files are all 494 bytes long, and end in "php" so they are easy to find. Run the following command to see if you have any:


find . -size 494c -name "*.php"

...and then run this command to delete them:

Resetting or updating passwords for Drupal users in command line

The


drush user-login username

command or it's alias


drush uli username

will display a one-time login URL to login the specified account. The output is a URL like:


http:///user/reset/1/1358351267/WvqBsED_WKGeThnoY67SCRddVfpGymDaA1w1GP7ZTtP

After logging in using this URL, the user it NOT required to change the password.

To generate one time login for user #1 fire up just


drush uli

Running


drush sqlq "SELECT name, pass FROM users WHERE uid = 1;"

Impending Drupal Site Launch? Use the List

After months of site development, code, more code, and long hours, launch day arrives. A site launch can come as a relief, create a bittersweet moment, or one filled with pride and a sense of accomplishment, not unlike a parent sending a child off to their first day of kindergarten.

Tags:

Syncing Two Drupal Sites

The drush module for Drupal has a new “sync” option to synchronize two Drupal sites, but it is undocumented and looking at the source code all it does is sync the files, not the mysql database. I haven’t seen any other public solutions that do completely sync 2 drupal sites including the databases.

Tags:

How to disable and enable Drupal 7 blocks programmatically

Sometimes you need to enable and place a Drupal 7 block in a seen region like header, content, footer, etc., and other times you need to disable it programmatically in a custom module. So to do it you just need to create two functions:

function _start_refreshing() {

db_update('block')
->fields(array(
'status' => 1,
'weight' => -10,
'region' => 'footer',
))
->condition('module', 'mymodule')
->condition('delta', 'mymodule_delta')
->execute();

}

and

function _stop_refreshing() {

Tags:

What is stopping Varnish?

Every so often with Pressflow and Varnish you might find that your anonymous users aren't being cached via Varnish.

A quick way to see whether your anonymous pages are being served is to add some debugging headers to Varnish by adding some code like the snippet here to vcl_deliver()

sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Varnish-Cache = "HIT";
}
else {
set resp.http.X-Varnish-Cache = "MISS";
}
}

and hit them with

curl -I http://yoururl.com

How to insert a block or a region in the middle of Drupal node content

The solution for Drupal 7.10:

/** in template.php **/

function THEME_preprocess_node(&$variables) {

//load your adblock
$adblock = block_load('block', '1');
$output .= drupal_render(_block_get_renderable_array(_block_render_blocks(array($adblock))));
$variables['ad'] = $output;
}
/** in node.tpl.php **/

$array = explode("", $body[0]['value']);
$array[1] = $ad. $array[1];
$content['body'] = implode("", $array);
print render($content['body']);

Inserting Adsense Into Content - Drupal 6.X

Tags:

WD cron: Attempting to re-run cron while it is already running.

If you see the following error when running 'drush cron' command:


WD cron: Attempting to re-run cron while it is already running. [warning]
Cron run failed.

then you can try:


drush --yes vset cron_semaphore 0
drush cron

If it doesn't help then fire up:


drush sqlc
DELETE FROM variable WHERE name="cron_semaphore";
DELETE FROM variable WHERE name = "cron_last";
exit
drush cc all
drush cron

Tags:

Drupal Performance Best Practices

As Drupal is used more and more for large, high-traffic websites, it has become very important to focus on performance enhancements to Drupal and the underlying server infrastructure. In doing so, we are looking at improving both the number of requests that a Drupal site can handle, and to decrease the amount of time required to load a particular page, or an entire site in general.

Tags:

Deleting _vti_cnf directories recursively

There are a number of issues concerning Drupal sites suddenly or slowly becoming broken along with error messages that have "_vti" as part of the issue. The certain themes (such as Multi-Flex) will definitely break the entire Drupal site if FrontPage Extensions are turned on, on a site. This is because the FrontPage extensions are somehow creating shortcuts in a directory that is parsed first before the main site files are parsed.

Tags:

Pages

Subscribe to RSS - drupal