Pages

How to change Joomla Admin Folder Name or Path

how to protect your admin side of website. Rename Joomla administrator directory without having to modify any Joomla code.

1. Create a new directory in your root directory (eg. "newadmin")
2. Create an index.php file in your "newadmin" directory

## newadmin/index.php

$admin_cookie_code="1234567890";
setcookie("JoomlaAdminSession",$admin_cookie_code,0,"/");
header("Location: ../administrator/index.php");

3. Add this to the beginning of index.php in real administrator folder

if ($_COOKIE['JoomlaAdminSession'] != "1234567890")
{
header("Location: ../index.php");
}


To login Joomla administration page, go to "http://yoursite.com/newadmin/". The php code will set a cookie that expires at the end of the session and redirect you to your real administration page. No one will be able to load anything from the administrator directory without having gone through the "newadmin" directory first.

Load Flash Video Before Load Front Page Joomla

Create a .htaccess file which contains the following code:

DirectoryIndex index.html index.php

Then create a index.html where you include the flash. If you make the flash linkable and have it go to the index.php it should work.

web page is not cached, across all browsers

set of headers which works in all of the mentioned browsers is the following:


Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0

The PHP way would look like:


header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1.
header('Pragma: no-cache'); // HTTP 1.0.
header('Expires: 0'); // Proxies.

The Java/Servlet way would look like:


response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setDateHeader("Expires", 0); // Proxies.

The ASP.NET way would look like:


Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0.
Response.AppendHeader("Expires", "0"); // Proxies.

The plain HTML way would look lile:


<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">


The Cache-Control is per the HTTP 1.1 spec for clients (and implicitly required by some browsers next to Expires),
the Pragma is per the HTTP 1.0 spec for clients and proxies and Expires is per the HTTP 1.1 spec for clients and proxies. Other Cache-Control parameters are irrelevant if the abovementioned three are specified. The Last-Modified header is only intersting if you actually want to cache the request.

Change suffix from html to htm in Joomla

Goto includes/router.php
Line 57 : Replace the current code there with ,


if($suffix = pathinfo($path, PATHINFO_EXTENSION))
{
$path = str_replace('.'.$suffix, '', $path);
$vars['format'] = $suffix;
if ($suffix == 'htm')
{
$path = str_replace('.'.$suffix, '', $path); //pair of single quotes inserted
$vars['format'] = 'html';
} else {
$path = str_replace('.'.$suffix, '', $path); //pair of single quotes inserted
$vars['format'] = $suffix;
}
}




Then goto line 101 : Replace the current code there with ,



if($format = $uri->getVar('format', 'html'))
{
$route .= '.htm';
$uri->delVar('format');
}




If you need the suffix to change from .html to .php , then just replace the .htm in the above code by .php and thats it..

if you are still not able to do it, then just download this ,
router.php file and upload it to includes folder.

Virtuemart- Set the number of products per page

Add $limit=5; in line after $ps_product_attribute = new ps_product_attribute;
in /administrator/com_virtuemart/html/shop.browse.php

CSS Hacks for Different Versions of Firefox

CSS hacks targeting different versions of Firefox. Some of these CSS Firefox hacks are organized according to version number and presented with ease of copying and pasting in mind. That said, here are some notes that apply to all of the hacks in this article.
  • For each hack, change only #selector, .selector, and of course the declaration blocks.
  • Hacks that do not validate as CSS are designated with [!] in the associated comment.
  • If you discover any inconsistencies, incompatibilities, or inoperabilities, please leave a comment.
  • This post is a work in progress. Please share any Firefox hacks that are not on the list.

Types of CSS hacks


1. target -
We are referring to the application of CSS styles to a particular, targeted browser (or set of browsers) at the exclusion of all others.

2. filtering
We are referring to the application of CSS styles to every browser except a particular browser (or set of browsers).

CSS Hacks targeting all Firefox


/* Target all Firefox */
#selector[id=selector] { color: red; }
/* Target all Firefox */
@-moz-document url-prefix() { .selector { color: red; } }

/* Target all Gecko (includes Firefox) */
*>.selector { color: red; }

CSS Hacks targeting Firefox 1.5 and newer


/* Target Firefox 1.5 and newer [!] */
.selector, x:-moz-any-link, x:only-child { color: red; }

CSS Hacks targeting Firefox 2 and older


/* Target Firefox 2 and older [!] */
body:empty .selector { color: red; }

/* Target Firefox 2 and older */
#selector[id=SELECTOR] { color: red; }

/* Target FireFox 2 and older [!] */
html>/**/body .selector, x:-moz-any-link { color: red; }


CSS Hacks targeting Firefox 3


/* Target FireFox 3 [!] */
html>/**/body .selector, x:-moz-any-link, x:default { color: red; }

Unzip an uploaded file using php

If you dont have shell access to your server and need to unzip a file on your php server you can use the script below:

Example 1. Extract all entries


<?php
$zip = new ZipArchive;
if ($zip->open('test.zip') === TRUE) {
$zip->extractTo('/my/destination/dir/');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
?>

Example 2. Extract only two entries


<?php
$zip = new ZipArchive;
$res = $zip->open('test_im.zip');
if ($res === TRUE) {
$zip->extractTo('/my/destination/dir/', array('pear_item.gif',
'testfromfile.php'));
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
?>


ZipArchive::extractTo

ZipArchive::extractTo -- Extract the archive contents

Description

mixed ZipArchive::extractTo ( string destination [, mixed entries] )
Extract the complete archive or the given files to the specified destination.

Parameters

destination - Location where to extract the files.
entries - The entries to extract. It accepts either a single entry name or an array of names.
Return Values - Returns TRUE on success or FALSE on failure.