Archive for September, 2008

Joomla Retrieve Admin Password

In this article, let’s see how you can retrieve admin password if you forget it. If you know the email address that was used for the admin user, and you have made the “lost password” feature available on the front end, the simplest thing is to do is to use the “lost password” Front-end function. There are times that when you develop your Joomla! application on localhost and the mail function is not properly set up, so you can’t use email to retrieve your password if you forget.

So for those who can’t use the email to retrieve, you will need access to the MySQL database. You got two options, either add a new super administrator or change the password stored in the data base. To do so you need to go to phpMyAdmin (or use a similar tool) and manually alter the database. Before doing this, back up your entire Joomla! database.

From phpMyAdmin, you can run the following SQL query to create a new user known as adminb.

INSERT INTO `jos_users` VALUES
(62, 'Administrator2', 'adminb', 'your-email@email.com', '21232f297a57a5a743894a0e4a801fc3',
'Super Administrator', 0, 1, 25, '2005-09-28 00:00:00', '2005-09-28 00:00:00', '', '');
INSERT INTO `jos_core_acl_aro` VALUES (10,'users','62',0,'Administrator2',0);
INSERT INTO `jos_core_acl_groups_aro_map` VALUES (25,'',10);

The password will be admin. Immediately log in and change this password and make any other changes to other admin users.

A second option would be to change the password in the table for your admin user. The password is stored in the MySQL database jos_users table password column. (Change this for your table prefix if different.)

Go to the table, find the row for your admin user, and then select that row for editing. The password must be hashed, you cannot simply enter text into this field.

Set the password to one of the known values shown below:

- password = "this is the MD5 hashed password"
------------------------------------------------------
- admin = 21232f297a57a5a743894a0e4a801fc3
- secret = 5ebe2294ecd0e0f08eab7690d2a6ee69
- OU812 = 7441de5382cf4fecbaa9a8c538e76783

Paste the hashed password into the field, save the change, and log in using the new password. Immediately change your password to something more secure!

2 Comments

ComboBox Dropdown Popup List Appears Behind

In Flash, there is a build-in ComboBox component which acts like a dropdown popup menu in HTML. If you use it in the wrong way, you may find that the dropdown popup list appears behind the item below it. Below is an example:

this.createEmptyMovieClip("cb_grp", this.getNextHighestDepth());
cb_grp.createClassObject(mx.controls.ComboBox, "my_cb", 10);
cb_grp.my_cb.addItem({data:1, label:"One"});
cb_grp.my_cb.addItem({data:2, label:"Two"});
cb_grp.createClassObject(mx.controls.ComboBox, "my_cb2", 11);
cb_grp.my_cb2.addItem({data:1, label:"One"});
cb_grp.my_cb2.addItem({data:2, label:"Two"});
cb_grp.my_cb2._y = 30;

The reason why it happens is because Flash get confused with the keyword this, even if you change it to _root, it won’t help. There are two ways to solve this problem. First is to use a specific depth for cb_grp.
this.createEmptyMovieClip("cb_grp", 5);
cb_grp.createClassObject(mx.controls.ComboBox, "my_cb", 10);
cb_grp.my_cb.addItem({data:1, label:"One"});
cb_grp.my_cb.addItem({data:2, label:"Two"});
cb_grp.createClassObject(mx.controls.ComboBox, "my_cb2", 11);
cb_grp.my_cb2.addItem({data:1, label:"One"});
cb_grp.my_cb2.addItem({data:2, label:"Two"});
cb_grp.my_cb2._y = 30;

Another way to work around the problem is to use lockroot,

this.createEmptyMovieClip("cb_grp", this.getNextHighestDepth());
cb_grp._lockroot = true;
cb_grp.createClassObject(mx.controls.ComboBox, "my_cb", 10);
cb_grp.my_cb.addItem({data:1, label:"One"});
cb_grp.my_cb.addItem({data:2, label:"Two"});
cb_grp.createClassObject(mx.controls.ComboBox, "my_cb2", 11);
cb_grp.my_cb2.addItem({data:1, label:"One"});
cb_grp.my_cb2.addItem({data:2, label:"Two"});
cb_grp.my_cb2._y = 30;

No Comments

Slash Backslash

A slash is /, and a backslash is \. To easily remember the two without confuse them with one another is to see the letter v, a letter v is consist of a backslash and a slash.

The reason why slash and backslash symbols are so hard to remember is because the names of them have nothing to do with how they look. There is no back and forward look of the symbols. So it is OK if you have always confused the two. Now with my brand new method: ‘v is made of a backslash and a slash’. It should be a piece of cake to remember and be able to distinguish the two.

No Comments

PHP Regex – Extract Filenames from Full Path

PHP Regular Expression (Regex) can do a lot wonders, one is to extract what looks like a filename from a full path. It makes an assumption that anything after the last directory separator (in this case a slash: / ) is the name of a file.

Below is the code:

<html>
<head><title>Extract Filenames from Full Path</title></head>
<body>
<form action="<?= $_SERVER['PHP_SELF']; ?>" method="post"&amp;amp;amp;amp;amp;amp;amp;
<input type="text" name="value" value="<? print $_POST ['value']; ?>"/><br/>
<input type="submit" value="Submit" /><br/><br/>
<?php
if ( $_SERVER['REQUEST_METHOD'] == "POST" )
{
    $mystr = $_POST['value'];
    if ( ereg( '^\/.*\/([^\/]+)$', $mystr, $matches ) )
    {
        echo "The file is: $matches[1]";
    }
    else
    {
        echo "<b>No file found here.</b>";
    }
}
?>
</form>
</body>
</html>

Regular Expression Explanation:

^

the beginning of the line, followed by

\/

a slash, then

.

any character

+

found one or more times, up to

\/

a slash, followed by

(

the beginning of the group that will capture the filename and contains

[

a character class that contains

^

anything that isn't

\/

a slash

]

the end of the character class

+

found one or more times

)

the end of the group, which goes up to

$

the end of the line

3 Comments

Best Bitorrent Client for Mac 2008 Review

So far as I know, the best Bitorrent Client for Mac users is Transmission. It’s minimalist interface design and superb performance makes it the best Bittorent

Transmission has a clean, almost spartan look, partly thanks to its fresh blue-and-white color scheme, but mostly because Transmission team has removed many of the tabs and bars we’re used to seeing in Vuze (formerly Azureus), BitComet, and BitTorrent 6.

The download can never be smoother, no file crash or broken link problems. It can bypass most firewalls and yet provide a safety layer. In lieu of dual security filter and fast download, Transmission creates a kind of harmony.

If you think the uncluttered design and the high performance are the only advantages Transmission processes, you have to think again. It’s not just a free software to the end users, it’s ope source MIT/GPL license allow developers to constantly improve it’s performance.

No Comments

Google Chrome’s Quick Search Bar

Well I was trying out Google’s new ‘mega hit’ – Google Chrome.

It is simply the best browser for browsing. There was only one thing that bothered me at first, that’s when I was looking for the quick search box inline (or what IE called instant search box). In Firefox, it’s inline with the address bar. In Chrome, it was nowhere on the window. I was a bit disappointed, not until the second day i used it, I took a wild guess and type keyword in the address bar. And oh yeah! It showed me the search results returned by Google. The address bar and quick search are combined as one. What a smart design!

Google is no doubt the master of modern user interface design. This is a bold vision to reshape some of our uncommon behavior that has been ‘commoned’ by the poor software design like Firefox and IE. Hope this daring innovation could be truly accepted by the future users of Chrome.

This minimalist design is not without any problem, one thing to note is that by using this design, it significantly narrowed the options for users to use other search engines. As we all know that in Firefox or IE, people can choose whatever search engine as the default search engine by configuring the quick search box. This freedom to choose search engine for quick search is not possible in Chrome.

4 Comments

Joomla – Link Excerpt Article Title to Full Article

In this article, let’s see in Joomla, how to link an article excerpt title to full article, which is the same as the “Read more…” link.

If you know how to use template file to override the core Joomla functions, in your template folder: create a new folder called ‘html’.
In that folder you create a folder called ‘com_content’.
And in that folder you create the folders called “category”, “homepage”, “section”

Then locate the following files

  • (joomla)/components/com_content/views/category/tmpl/blog_item.php
  • (joomla)/components/com_content/views/homepage/tmpl/default_item.php
  • (joomla)/components/com_content/views/section/tmpl/blog_item.php

Copy the files to your template’s html folders

  • (yourtemplate)/html/com_content/category/blog_item.php
  • (yourtemplate)/html/com_content/frontpage/default_item.php
  • (yourtemplate)/html/com_content/section/blog_item.php

Open these files.
Nearly at the bottom of these files you should be seeing something like:

<a href="<?php echo $this->item->readmore_link; ?>" class="readon<?php echo $this->item->params->get('pageclass_sfx'); ?>">
     <?php if ($this->item->readmore_register) :
          echo JText::_('Register to read more...');
     elseif ($readmore = $this->item->params->get('readmore')) :
          echo $readmore;
     else :
          echo JText::sprintf('Read more...');
     endif; ?></a>

Change the line

echo JText::sprintf('Read more...');

into

echo JText::sprintf('Read more', $this->item->title);

3 Comments

PHP Regex – Validate Email Address

This article is for our friend Josh and all those who might be interested in knowing how to validate email address using PHP Regex (Regular Expression). The script below makes sure an e-mail address looks like a valid address, containing a username, @, and valid hostname. For example, null@example.com is valid, but NOSPAM@spam isn’t valid.

<html>
<head><title>4-11 Validating e-mail addresses</title></head>
<style>
    .err { color : red ; font-weight : bold }
</style>
<body>
<form action="recipe4-11.php" method="post">
<input type="text" name="input" /><br/>
<input type="submit" value="Submit Form" /><br/><br/>
<?php
if ( $_SERVER['REQUEST_METHOD'] == "POST" )
{
    $input = $_POST['input'];
    if ( preg_match( "/^[-\w.]+@([A-z0-9][-A-z0-9]+\.)+[A-z]{2,4}$/", $input ) )
    {
        # Do some processing here - input if valid
    }
    else
    {
        print "<span class=\"err\">Bad e-mail address. Please correct ".
            "and resubmit the form</span><br/>";
    }
}
?>
</form>
</body>
</html>


Regular Expression Explanation:

(

a group that includes

[A-z0-9]

a letter or number

[-A-z0-9]

a letter, number, or hyphen

\.

a literal dot or period

)

the end of the group

+

found one or more times

[A-z]

a letter

{2,4}

found between two and four times.

9 Comments

Make MySQL Connector/J Work with Tomcat

I have been using Tomcat with MySQL for a while, I remember when I first started using Tomcat, it took me a while to make my JSP script connect to MySQL using Connector/J.

1. Locate your Tomcat directory. If you have the recent version of Tomcat installed, you should be able to locate your Tomcat webapps folder:

for my Tomcat 5.5 installation, it looks like: tomcat5.5-webapps/

for my previous Tomcat 5 installation, it looks like: tomcat5/webapps/

2. Create a folder in your webapps, for instance: tomcat5.5-webapps/test/ or tomcat5/webapps/test/

3. Download Connector/J at http://dev.mysql.com/downloads/connector/j/5.1.html

4. Create a directory tomcat5.5-webapps/test/WEB-INF/lib/ or tomcat5/webapps/test/WEB-INF/lib/

5. Unzip or Untar the file, and copy the file mysql-connector-java-5.1.6-bin.jar

6. Paste it inside tomcat5.5-webapps/test/WEB-INF/lib/ or tomcat5/webapps/test/WEB-INF/lib/

7. Now create a test file named sql.jsp inside tomcat5.5-webapps/test/ or tomcat5/webapps/test/

8. Point browser to the url http://localhost:8080/test/sql.jsp, you should be able to see if it’s sucessfully connected to the MySQL database.

1 Comment

JavaScript – Remove the Last Character of a String

To remove the last character of a string can be easily done by combining some build-in JavaScipt functions.

var str = 'hullo world!';
var newStr = str.substring(0, str.length-1);
alert(newStr);
// alert hullo world

In the above example, you got a string ‘hullo world!’, the newStr subtract the string, take the character range from the first to the one before the last, and you will get the new string newStr ‘hullo world’.

Enjoy!

7 Comments