most userful joomla function to debug database query

// Get a db connection.
$db = JFactory::getDbo();
 
// Create a new query object.
$query = $db->getQuery(true);
 
// Select all articles for users who have a username which starts with 'a'.
// Order it by the created date.
// Note by putting 'a' as a second parameter will generate `#__content` AS `a`
$query
    ->select($db->quoteName(array('a.*', 'b.username', 'b.name')))
    ->from($db->quoteName('#__content', 'a'))
    ->join('INNER', $db->quoteName('#__users', 'b') . ' ON (' . $db->quoteName('a.created_by') . ' = ' . $db->quoteName('b.id') . ')')
    ->where($db->quoteName('b.username') . ' LIKE \'a%\'')
    ->order($db->quoteName('a.created') . ' DESC');

// echo sql query so you can see it and debug it ;)
echo $db->replacePrefix( (string) $query );
 
// Reset the query using our newly populated query object.
$db->setQuery($query);

// Get array with information of the query
$rows = $db->loadAssocList();


С етикет: , , , , , ,
Публикувано в Joomla

Drupal debug

Sometimes is very hard to debug Drupal when you get white screen of death
Very often some module is making the mess
To check which module is breaking the site
Open includes/module.inc and find function module_invoke_all
Add bolded line to the function to check which exactly module is breaking your site

 

function module_invoke_all($hook) {
$args = func_get_args();
// Remove $hook from the arguments.
unset($args[0]);
$return = array();
foreach (module_implements($hook) as $module) {
$function = $module . ‘_’ . $hook;

print „Starting loading $module <br />“;

if (function_exists($function)) {
$result = call_user_func_array($function, $args);
if (isset($result) && is_array($result)) {
$return = array_merge_recursive($return, $result);
}
elseif (isset($result)) {
$return[] = $result;
}
}

print „Finished loading $module <br />“;

}

return $return;
}

If you need to disable module you can make it with phpmyadmin
UPDATE system SET status=’0′ WHERE name=’module_name’;
After this you need to clean cache
DELETE FROM cache_bootstrap WHERE cid=’system_list’;

 

С етикет: ,
Публикувано в Без категория

check for eval(base64 in multiple files

If you have hacked joomla or wordpress site you need to check all your site files
This commans search all files in current dir and subdirs for eval(base64 which is one of most used combination

find * -name '*.php' |xargs grep -lirn "eval(base64"

Публикувано в linux

bash rename file

This is simple script which rename files based on some pattern
For example rename all files AABBBCCC and replace BBB with DDD
./ren „AAABBBCCC“ „BBB“ „DDD“

#!/bin/bash
# renames.sh
# basic file renamer

criteria=$1
re_match=$2
replace=$3

for i in $( ls *$criteria* );
do
src=$i
tgt=$(echo $i | sed -e „s/$re_match/$replace/“)
mv $src $tgt
done

Публикувано в linux, Без категория

no cache website

<meta http-equiv=“expires“ value=“Thu, 16 Mar 2000 11:00:00 GMT“ />
<meta http-equiv=“pragma“ content=“no-cache“ />

Публикувано в Без категория, интернет