Friday, August 31, 2012

Index PHP Array to use in Javascript / Javascript array

So here is what I wanted, I wanted to the text of check box when clicked on check box like
<input type='checkbox' value='1' name='chkbox'>First chk box</input>

So I wanted 'First chk box' when clicked on it, in here you might be able to simply get it using innerHTML but my case was bit different so I got a php array that had id=>value (1=>'First chk box') array now the issue is you can't use it in javascript

So step 2 is converting php array to javascript array, following are the things you can do

1. Simply make a javascript array and put php values in it
var jsArray = new Array('<?=$phpArr[0]?>',<?=$phpArr[1]?>',....);

That doesn't work in my case because my indexes were different

2. You can have insertion in JS Array using the splice function to insert in mid, you can google that, but the issue with that is you can't have a javascript array like

arr[1] = index1
arr[2] = index2
arr[5] = index5

means you need EACH index defined which is not my case, I could have skipping index so here is solution for me, or you if you have similar issue... or any of above might work for you...

3. var jsArray = <?php echo json_encode($phpArray) ?>;
Now if could do is simply using
jsArray[chkbox.value] 
and it would give me 'First chk box'

Friday, August 24, 2012

Generate Random Password Joomla and PHP

The following few lines creates a random password and puts it into and md5 encrypted format to be saved in joomla database. If you are using non-encrypted password you can just use the first part, or if you are using simple md5 encryption and not looking for key:salt as joomla then you can simply take the $key from first part and encrypt it using the md5 function and store that. :)

        $key = "";
        srand((double)microtime() * rand(1000, 9999));
        $charset = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ0123456789";
        for($len=0; $len<8; $len++)
            $key .= $charset[rand(0, strlen($charset)-1)];
        //End of part 1, you will have a simple random password here in $key
        $salt = JUserHelper::genRandomPassword(32);
        $crypt = JUserHelper::getCryptedPassword($key, $salt);
        $password = $crypt . ':' . $salt;

$password will have the value that you can save into database in users table.

Wednesday, August 8, 2012

Joomla 2.5 - Redirect to login page with return URL

If you have a private page that is supposed to be viewed only by registered users and if URL is accessed directly or is accessed on session expire you want to redirect user to login page and on successful login return him to the requested page then simply make a function named something like 'validateUser' and call it for all such views. Here is the brief and comprehensive function:


function validateUser()
{
        $user = JFactory::getUser();
        $userId = $user->get('id');
        if(!$userId)
        {
            $mainframe = &JFactory::getApplication();
            $return = JFactory::getURI()->toString();
            $url  = 'index.php?option=com_users&view=login';
            $url .= '&return='.base64_encode($return);
            $mainframe->redirect($url, JText::_('You must login first') );
            return false;
        }
        return true;
}

Note: If you are trying to do something similar for Joomla 1.5 note you would have to use 'option=com_user' instead of 'users'.

Wednesday, August 1, 2012

Remove parameter from URL PHP

If you are looking to remove a specific parameter from the URL here is how to do it:

Assume you have URL
http://www.b4blinky.com/index.php?option=com_content&view=article&id=1
And you want to remove the id


$currURL = $_SERVER[QUERY_STRING];
//this will get you option=com_content&view=article&id=1
parse_str($currURL,$params); //Puts the url parameters in key=>value pair
//This will give you option=>com_content, view=>article, id=>1
unset($params[$fieldName]);  //Removes the parameter on which 'x' is clicked
//This will remove the $fieldName from the array e.g. 'id'
$newURL = http_build_query($params); //Rebuilds the query with the remaining parameters
//This will rebuild array excluding id
$newURL = 'index.php?'.$newURL;
//and finally your newURL like
index.php?option=com_content&view=article

That you can modify if relative doesn't work for you.

Hope it helps. Happy coding :)

Friday, July 27, 2012

Difference between find_in_set and in MySQL

If you are confused with these functions then there is short explanation

They are both used for matching a single value again comma separated multiple values

IN: Works when you are looking for database/column value against commas separated list
e.g. WHERE id IN (1,2,3)

FIND_IN_SET: Works the other way around i.e. when you are looking for a single values against a comma separated list stored in a column
e.g. WHERE FIND_IN_SET('name',namesColumn)
where names is a column having value like ('john,paul,richard')

Thursday, July 26, 2012

HTML is stripped in Joomla component configuration / parameters filter

If you are looking to add HTML anywhere in Joomla and 'text filtering' option in 'global configuration' is failing then here is what you need to do

You need to add a filter='safehtml' in your field tag be it your component field or parameter e.g.

<field menu="hide" name="sharethisbtncode" type="textarea"  filter="SAFEHTML" label="Sharethis Buttons Code" description="HTML buttons code of the buttons needed to be displayed" />

Without it Joomla will use the default and strip HTML.

Also know that it will only work for simple HTML like in this example buttons code, if you are looking for including something like javascript like header of analytics or some other you will need to use filter="RAW"

Following is the list of all the filter options:


case 'RULES': // Used for permissions etc
case 'UNSET': // Does nothing.
case 'RAW': // No Filter.
case 'SAFEHTML': // Filter safe HTML.
case 'SERVER_UTC': // Convert a date to UTC based on the server timezone offset.
case 'USER_UTC': // Convert a date to UTC based on the user timezone offset.
default: // Check for a custom callback filter that you can write


For more details refer to:
http://docs.joomla.org/API16:JForm/filter

Include js in head tag Joomla 2.5

If you are looking for how to include javascript in the head tag of html without having to write it in the template for features like sharethis, Google analytics here is how to

Simply use the following two lines:

$document = &JFactory::getDocument();
$document->addCustomTag('<script type="text/javascript">my javascript</script>');

And it will add javascript to the head tag.

You can also include js/css files by using

$document->addStyleSheet('path');
$document->addScript('path');

Wednesday, July 25, 2012

Broken dead links checker php solution

If you want to know how to check for broken or dead links using php, following is a simple script that uses curl to check broken links, you can run it on your database if you have a table of links that you want to check for possible broken links:


            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_HEADER, true);
            curl_setopt($ch, CURLOPT_NOBODY, true);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $data = curl_exec($ch);
            curl_close($ch);

This sets nobody=true which means it doesn't request for the whole page hence speeding up the link checking. There are plenty of ways within curl to check for broken or redirecting links, I personally use this by putting a simple length check on data variable, if its 0 then it means the link is dead.

i.e.
if(strlen($data)==0)
   echo 'dead link=>'.$url;

You can do something else if you like.

Cheers.

Tuesday, July 24, 2012

[Solved] DIV background color not showing

If you have a div tag that has background-color set but it doesn't show at all because there is dynamic content in it with some further tags that have content in it and hence you can not set a fixed height e.g.

<div class="bgcolorRed">
      <div>...content....</div>
      <dl>.....content....</dl>
</div>

Just simply add 'overflow: hidden' along with you background color in CSS and it will work
i.e.

.bgcolorRed {
     background-color: red;
     overflow: hidden;
}

Hope that helps.

Sunday, July 22, 2012

Technorati API Closed

Technorati was one of the most popular used website few years back but as it started to decline sadly the team also seemed not to care much about it. They closed their API that was widely used by people and developers worldwide in 2009 promising for something new but its been three years and there is nothing which leaves a heavy doubt that probably it won't be coming ever again.

Here is the link where the announced the closure of existing API and announcement of new API and features which never came.
http://technorati.com/developers/

Here is an interesting blog article by another person who mentioned that even the founder of Technorati used the API on his blog and I checked it now and there was nothing of Technorati.
http://blog.programmableweb.com/2010/03/04/technorati-api-disappears-no-longer-representing-the-technorati/

Tuesday, July 3, 2012

[Solution] You are not permitted to use that link to directly access that page Joomla 2.5 Error

If you are having the error "You are not permitted to use that link to directly access that page" on clicking on 'cancel' button in joomla admin inside a component then try the following:


Try selecting a row with a check box and then click edit, once the page loads click cancels, if this doesn't give the error and adding a look to title to edit, something like 


index.php?option=com_myschool&view=student&layout=edit&id=1


and clicking on this and then pressing cancel gives you the error then the following is the quick and easy solution, replace the layout edit with task=subcontrollername.edit and leave rest the same, e.g.

index.php?option=com_myschool&view=student&task=student.edit&id=1
or this also works
index.php?option=com_myschool&task=student.edit&id=1

Note: You will be in a view with plural like views/students/tmpl/default.php but you have to use the subcontroller name of the single one i.e. student.

Adding javascript file in Joomla view file

If you want to use a javascript file in a view file (i.e. myComponent/views/student/tmpl/default.php) you will not be able to inlcude using

<script type="text/javascript" src="" />

As you will see it won't load the file and hence won't work. So to include a file you will need to use something like this:


$document = &JFactory::getDocument();
$document->addScript( 'myfilepath/myjsfile.js' );

Thursday, June 21, 2012

Joomla path variables (JPATH)


Following is the list of JPATH variables that you can use while component development in Joomla, do let me know if you find any other.

JURI::Root() = http://localhost/myJoomla or http://www.test.com
JPATH_COMPONENT_ADMINISTRATOR = /var/www/html/myjoomla/administrator/components/com_mycomp
JPATH_COMPONENT_SITE= /var/www/html/myjoomla/components/com_mycomp
JPATH_ROOT = /var/www/html/myjoomla
JPATH_SITE = /var/www/html/myjoomla
JPATH_ADMINISTRATOR = /var/www/html/myjoomla/administrator

JPATH_BASE is the root path for the current requested application, so if you are in the administrator application, JPATH_BASE == JPATH_ADMINISTRATOR... if you are in the site application JPATH_BASE == JPATH_SITE... if you are in the installation application JPATH_BASE == JPATH_INSTALLATION.



Wednesday, June 20, 2012

Joomla 2.5 extend jgrid.published column in custom component


Ever wanted to have a column/field like published in articles for your own component? Well here is how you can make one.
If you go to com_content and see how it is done there you will see that for published it uses the following line of code in views/articles/tmpl/default.php

<?php echo JHtml::_('jgrid.published', $item->state, $i, 'articles.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>


Simplying it you can use it as

<?php echo JHtml::_('jgrid.published', $item->state, $i, 'articles.'); ?>

Which is

<?php echo JHtml::_('jgrid.published', $item->yourFieldName, $i, 'classPrefix.'); ?>

If you just put this one line you will be able to see that your Boolean field will start showing correctly, and especially if you field name is ‘published’ then you are done and you can click on it to toggle between publish and un publish, however if your field name is something other than published e.g. approved or available then you have some work to do.
First you will need to create a new class in com_componentName/helpers/html/className.php
This will be a JFieldClassName class having code like this
<?php
defined('_JEXEC') or die;
abstract class JHtmlClassName
{
                static function approved($value = 0, $i)
                {
                                $states = array(0=> array('disabled.png','tableName.approved','’,'Toggle to approve'),
                    1=> array('tick.png',    'tableName.unapproved', ',        'Toggle to unapprove'), );
                                $state   = JArrayHelper::getValue($states, (int) $value, $states[1]);
                                $html    = JHtml::_('image', 'admin/'.$state[0], JText::_($state[2]), NULL, true);                                                  $html    = '<a href="#" onclick="return listItemTask(\'cb'.$i.'\',\''.$state[1].'\')" title="'.JText::_($state[3]).'">'. $html.'</a>';
                }
                return $html;
                }
} ?>
Now to call this you will have to first register it for both approved/unapproved in controller’s contruct
com_componentName/controllers/classNames.php
                public function __construct($config = array())
                {
                                parent::__construct($config);
                                $this->registerTask('unapproved', 'approved');
                }
Followed by the function which will call the model to update the status:
        function approved()
        {
                                $ids        = JRequest::getVar('cid', array(), '', 'array');
                                $values = array('approved' => 1, 'unapproved' => 0);
                                $task     = $this->getTask();
                                $value   = JArrayHelper::getValue($values, $task, 0, 'int');
                                $model = $this->getModel();
                                if (!$model->approved($ids, $value)) {
                                                                JError::raiseWarning(500, $model->getError());
                                }
                                $this->setRedirect(url to get you back to the same page);
        }
Now its all up are ready and you can just create a function in your respective model which takes the value (which will be 0 or 1) and id and update the status , and finally you can use it by writing the following line in default.php
<?php echo JHtml::_('className.approved', $item->approved, $i, 'tableName.'); ?>
You will need to include the html helper file you created first by putting the following like at the top of default.php
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');


Tuesday, May 1, 2012

Joomla 2.5 Admin Component Multi View Create & Save

To create a field in the Joomla 2.5's administrator part of the component and to store it you have to do the following things:

First to create a multi select drop down field you have to add the following attribute into the xml
multiple="multiple"

like I did in the following:


<field
        name="practice_areas_ids"
        type="list"
        class="inputbox"
        default=""
        label="Practice Area(s)"
        multiple="multiple">
<option value="1">Area 1</option>
<option value="2">Area 2</option>
                        <option value="3">Area 3</option>
</field>


Now you will be able to see and select multiple fields when you click on 'New' or 'Edit' in your component however this won't save the multi selected array into your database and will store just the first value e.g. if you select Area 2 & Area 3 it will only store 2. To save comma separated all values you have to do the following:

Go to your store/bind or whichever function you are using and add an implode line, here is mine for clarity:
$practice_ids = implode(",", $_REQUEST['jform']['practice_areas_ids']);

Now this let's you select multiple fields and store their ids successfully into the database, that leaves us with our last problem which is if you open your row/entry in edit you will see that the selected Area(s) will not show as selected, that is because it is reading the field as comma separated list instead of an array so as we did implode on saving, we need to do explode on displaying. To do that follow the following:

Go to 'models'/modelName.php and look for the function 'loadFormData()'
Go inside it and after you have obtained the $data and before returning, replace the multiple select field with exploded array, like:



         protected function loadFormData() 
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_jobm.edit.italy.data', array());
if (empty($data)) 
{
$data = $this->getItem();
}
                $data->practice_areas_ids = explode(',', $data->practice_areas_ids);
return $data;
}

Joomla redirect from view.html.php

If you ever want to redirect url from view of a component i.e. view.html.php simply use the following two lines:

$app =& JFactory::getApplication(); 
$app->redirect('index.php?option=com_mycomponent&view=default'); 

If else statement in Select MySQL

Ever wanted to show one thing for one value and another for rest as stored in the database? As an easy example if you have a column 'gender' that has 1 for male and 0 for female then instead of having to parse it before displaying you can simply do so using MySQL if statement. Here is the syntax

IF(condition, if true, if false)

SELECT name,IF(gender='1','Male','Female') AS gender
FROM person


Tuesday, April 24, 2012

Get last inserted row id in Joomla

Ever wanted to get the id of the row that you just inserted to use it for update or any other feature? Well its simple to do it, here is how:

$query = "INSERT INTO #__mytable (name,email) VALUES ('john','john@test.com')";
$db->setQuery( $query );
$db->query();

Once you are done with you insert query simply call the following function:

$lastRowId = $db->insertid();

Works for both Joomla 1.5 and Joomla 2.5

And you will have the inserted row id in the variable. Note that if you remove the $db->query() call from above and then try it will return 0 so just in case if you are wondering it only returns the last value of the table and can have problem if multiple users are working then you don't need to worry as it only returns the id of the row inserted currently.

Edit:
Or if you are using $row->bind() mechanism then you can try the following

$row->bind($data);
$row->store();
$lastRowId = $row->id;

NOTE: You will not get the last inserted row id after you run an update query even though that is not an insertion.

Thursday, April 12, 2012

How to get a URL variable in Joomla

If you want to get a variable from URL the command is simply

$id = JRequest::getVar('id');
It will give you the value of 'id' if its in your url like:

http://www.b4blinky.com/index.php?id=1

However if you don't have an 'id' var in URL it will return you NULL, so if you want to have a default value of let's say zero you can use this


$id = JRequest::getVar('id','0');

Especially useful when you want to have some default views etc.

Monday, April 9, 2012

HTTP to HTTPS in PHP not working solutions

While searching for making your URL from http to secured https you will find dozens of links telling you to write the following:


if($_SERVER['HTTPS']!="on")
  {
     $redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
     header("Location:$redirect");
  }



If you haven't even tried that then try it and you will be good to go.
If however that doesn't workas it didn't in my case, , and dumping $_SERVER variable doesn't give you HTTPS element in array either if its http or https then then you can have either of the two problems:

1. Your host is using some shared SSL certificate which uses the same port of 80 as for http and handling security itself, for that you would need to request your host to enable $_SERVER['HTTPS']

2. My case was even different. My client's website is on cloud hosting (something new at this point in time) and apparently it works somewhat different then others and has the array element $_SERVER["HTTP_X_FORWARDED_PROTO"] set to value "https" so the fix for me was:


if (!$_SERVER["HTTP_X_FORWARDED_PROTO"]=="https") {
    $newurl = "https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
    header("Location: $newurl");
    exit();
}

Tuesday, April 3, 2012

How to make POST call in PHP using CURL

Ever wanted to make a POST or GET call to a URL without creating a form and submitting it? Well here is how you can do it using Curl, very simple.



<?php

// Submit those variables to the server
$postVals = urlencode("username")."=".urlencode('TomCruise');
$postVals.= "&";
$postVals.= urlencode("password")."=".urlencode('GhostProtocol');

// Send request to the required URL
$url = "http://www.b4blinky.com/index.php";

$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $url );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt( $curl, CURLOPT_POSTFIELDS,  $postVals);
curl_setopt( $curl, CURLOPT_POST, 1);
$result = curl_exec( $curl );
curl_close( $curl );

?>

Thursday, March 29, 2012

JomSocial Album Privacy Issues

Hi,

I was working with JomSocial and I found some interesting (read: ridiculous) things regarding JomSocial. Here hey are:

1. Even if you set a video view to 'Only me', anyone can view, rate, comment on it if they just know the URL, the URL could also have been indexed by search engine.
2. Same issue with Album
3. But here is what was most amazing, if you are viewing someone else's album if you have rights to view or even if you don't have rights and you have gone through URL, you can change their album covers and even DELETE PICTURES.. yes literally delete pictures.. go try it yourself.




I don't know how it didn't come into notice so far or if it is supposed to be a feature, which clearly it shouldn't be. Maybe they have fixed it in 2.6 otherwise lets hope they do so soon as I have checked in 2.2 and 2.4 and its in both.

Thursday, March 22, 2012

Enable / Add ReCaptcha in Joomla 2.5 form

If you are looking for adding recaptcha to your registration or contact form in Joomla site to have less spam here is how to do it in Joomla 2.5

Login into admin
Go to Global Configuration
Under 'Site' look for option 'Default Captcha' and change it from 'none selected' to 'Captcha ReCaptcha'



Once done you will have captcha enabled but if you open a form in front end you will be having an error of
"
  • ReCaptcha plugin needs a public key to be set in its parameters. Please contact a site administrator.
"
To solve this go to 'Extensions-> Plug-in Manager'
Look for a plug in named 'Captcha - ReCaptcha'

Once you open it you will see to text fields of public key and private key,



now login to 
give the URL of your website and it will give you both the keys. Enter them and save and now you will have recaptcha working on your site.

Tuesday, March 20, 2012

Extending Joomla Article Search

The following tutorial will let you know how to extend joomla's default search to add fields of content that are not searched by default, for example 'created_by_alias'. The files mentioned are from Joomla 2.5, previous versions will be quite same.

Following are the things you need to do:
File: plugins\search\content\content.php

You have to add the field in two places, the 'select', and 'where', to add to 'where' look for swtich option at line 73 having cases 'exact' and then below 'all'/'default', add a line for your field like:
$wheres2[] = 'a.created_by_alias LIKE '.$word;


Then moving to 'select' fields like in line 153 and 210:
$query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created');


and add your field like
$query->select('a.title AS title, a.created_by_alias, a.metadesc, a.metakey, a.created AS created');

And finally you need to add your field in the function "searchHelper::checkNoHTML" at the end of the file:
searchHelper::checkNoHTML($article, $searchText, array('text', 'title','metadesc', 'metakey')
to
searchHelper::checkNoHTML($article, $searchText, array('text', 'title','created_by_alias', 'metadesc', 'metakey')



Sort Articles By Rating In Joomla 2.5

The following tutorial will tell you how to sort articles in Joomla by rating

I needed to sort articles in a list category layout and here are the few changes that I made. I am sure they will be applicable on previous Joomla versions as well, or at least you will get the idea:

Open file 'components\com_content\models\articles.php'

Look for the following line (221 for my Joomla 2.5 version)
$query->select('ROUND(v.rating_sum / v.rating_count,0) AS rating, v.rating_count as rating_count');

It is currently rounding the rating for some unknown reason i.e. if you have 4 ratings that combine to make it 4.25, it will show 4 (rounded) instead of 4.25 so first I fixed this by replacing it with the following line:

$query->select('FORMAT(v.rating_sum / v.rating_count,2) AS rating, v.rating_count as rating_count');

(You can even remove the 'FORMAT' if you are fine with going it up to 4-5 decimals)

Once you are done with this, then comes the sorting part, go to the end of this function and look for the following line (463 for me)

$query->order($this->getState('list.ordering', 'a.ordering').' '.$this->getState('list.direction', 'ASC'));

And replace it with

$query->order(' rating DESC ');

And you are good to go.


Note: You may also want to add a column in the front end to show the ratings. If you want and your are in list view of category you can go to the following file:
'components/com_content/views/category/tmpl/default_articles.php'
and look for a 'foreach' loop at approximately the mid of the file, add  your column of rating along with hits, author columns.

Sunday, March 18, 2012

Removing Pharmacy Hack/Spam from Joomla/PHP website

Hi,

I recently got a chance to fix a site that was related to coffee stuff but was full with some pharmacy, anthrax and medicine links. They showed at the header, footer, completely on pages and made site totally spammy and destroyed its searching ranking. Here is how I removed it:

I would first go through key points how they target and then define in details where I found them:

Key points:
To start of let me tell you that it happens because they somehow get access to your site and change your files, now where to look for changes having so many files:
1. Main index files like /root/index.php, root/templates/my_template/index.php
2. Include files that called by index files or framework and almost always called, in Joomla you can look for /root/includes folder
3. Since generally you don't have changes in files other than components so always look for 'date modified' field of files, that can really help.. all the files will have same date on which you installed joomla, and some will have different, that can mean they are infected
4. Once you point or suspect a file to be infected look for the following things:
    i) files included e.g. include('includes/defaults.php');
       Make sure you compare your code with some other uninfected Joomla installation, preferably fresh before removing any such thing because it can be part of your code.
   ii) eval(gzinflate(base64_decode('9saf45vs64.....'));
       This string be very long and go beyond 100 char easily, it is put so you can't trace for words from source code like the spammy website links or url.


Now following are the issues I found, note you can have many different ones:

- First i see index.php on the root folder and see the following changes/additions:
include('includes/defaults.php');
define ( 'T_TEXT',getlinks());
eval(gzinflate(base64_decode('7VpZk9w4c.....OlzG+fa6++UVvPrt1db5V99eo/AA==')));
(not together)

Then I find a replacement, you have to look for such changes so that you don't mess up Joomla core code.
echo JResponse::toString($mainframe->getCfg('gzip'));
replaced with
echo str_replace('</body>',file_get_contents('includes/footer_t.php').'</body>',JResponse::toString($mainframe->getCfg('gzip')));

I removed the second line and replaced with first.

The first line above including defaults.php which was spam, I looked in first to it before removing it and found it linked to includes/js/extra folder which was full of .htm spammy links so i removed the whole folder.. or u can rename first to make sure it doesn't move something imp

Another found in includes by tracing the date change and then contents of the file it was a jquery.dist.js or something file and looking at the content it was again eval(gzinflate()) sort of content which was definitely not a jQuery file so removed that as well

Then again tracing the dates I find a 'models.php' file inside 'modules' folder, almost all modules do have model files but not on modules main so I looked inside it and found it to be spam as well.

And the last one I found was a defines.php file, also in includes folder which I removed and site was good as before.

Note:
1. This is Joomla specific but you can apply same knowledge on your any PHP website. Wordpress, Drupal etc.
2. Once you are done, make sure you open your infected pages, right click and go to 'view source' and check there is no hidden links inside your html as well.

Hope it helps :)

Thursday, March 8, 2012

Disable article text/description in Joomla 2.5

In category blog layout you see articles with their text / description. If you want to disable articles text in category blog layout what you need to follow the following steps:

1. Go to 'Content'
2. Select 'Options'
3. Switch to tab 'Blog Featured/Layouts'
4. Set first 3 columns to 0 and forth (links) column to whatever value you want which will only show the links to the articles of the category.









PS: I have renamed 'Article' to 'Book' in my site so don't get confused with the image :)

Set Default Article Category Joomla 2.5

Are you wondering how to set default category joomla 2.5 for the article and can't find it in the article options? Well then you are looking at the wrong place. To set the default category for users who are adding articles from the front end, you can set the default category from the 'Menu Item'... Menu item is the options available for all the options/links added into 'Menu(s)' of Joomla.







When you add a new field in lets say main menu named 'Add Article', you will see that a Menu Item has also been created for it in the new tab called 'Menu Items', once you go into its options you can easily set a default category so users add all articles into the specified category. You can have different default categories for different menu options.

Thursday, March 1, 2012

Youtube search / view history privacy

Are you like me who has really been bothered about the google's merging privacy and going public with everything? have you been going to private browsing so that youtube don't automatically get your id and stores everything you do? Well then this post will surely come in handy to you. I found a way to disable youtube's logging of your search as well as video view.. here is how you can set to hide your browsing and at the same time clear and erase your previous history:

1. Open youtube
2. Click on top right box where you will see your username
3. Click on 'Video Manager'
4. Click on 'History' coming onto the left menu
5. Click on 'Pause viewing history'
6* You may also select 'Clear all viewing history' to remove the previous data.

Repeat it for 'Search History' and you are good to go. :)

Who knows they are still saving and just not showing you ... *sigh*

Feedburner API returning 0

Ever used feedburner API to get the number of subscribers against a URL but keep getting 0 for all sites? I had this issue a while ago and didn't find a proper reasoning why was this happening or how to fix it but I found a crack to it.


If you have such an issue like getting 0 against a feedburner url with a link like this: https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=http://feeds.feedburner.com/disparatereflections
Trying adding yesterday's date to it and you will get the value  https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=http://feeds2.feedburner.com/disparatereflections&dates=2012-01-01,2012-03-02

Hope that helps

Javascript Validation

I have been a webdeveloper since a while now however recently I came across an issue with a client's website I was working on, the issue was that I was having invalid submissions that were not possible considering that I had validation over the form submission like authenticating the correctness of URL. The question I finally asked was that was javascript validation enough? And to my surprise disabling (and hence) by passing javascript is fairly simple, once the user disables javascript then he can submit anything and bypass all your javascript checks so make sure you always have validation both at client side as well as server end.

Happy coding.

Tuesday, February 28, 2012

View template module positions tp=1 Joomla 2.5

Hi,

If you are a developer or designer of Joomla 1.5 and have recently moved to Joomla 1.6, 1.7 or Joomla 2.5 you will see that setting the parameter of tp=1 in url doesn't show you module positions anymore. So if you are wondering how to view module positions in Joomla 2.5 its simple, you go to Extensions->Template Manager, click on options and set 'Preview module positions' from disabled to enabled and the old tp=1 will start working.

Hiding home page article title in Joomla 2.5

This article is about how to hide home page/featured/front page article in Joomla 2.5

I have been using Joomla 1.5 since a long now and in it a 'front page' article that shows on home page has a simple configuration of hiding article by going into article and then selecting Parameters(Advanced) from the right side menu and hiding title, author, publish date etc however things are different in Joomla 2.5

If you make a article featured (renamed from 'front page') you will see that it will link to the article and removing  title option from advanced parameters will only hide it in the article page and not home page. For this Joomla 2.5 has new configuration, for that if you go to 'Menus' from the admin panel you will see a new tab named 'Menu Items' going into that and clicking 'Home' (or whatever you have named the home link) you will see 'Article Options' to the right having similar options like 'Parameters (Advanced)' in Content->Articles, changing it here will remove the title from home page.