Reset Cacti Password, step by step

My other staff  ask me password for username admin. Yes, its administrator level in cacti.

After hardy trying to remember I gave up, I decide to reset it to other value but how?

I try to find out using database approach :

Here’s my steps :

1. Checking for cacti location and see db setting.

monitor# pwd

/usr/local/share/cacti/include

see setting dbnya.

monitor# cat db-settings.php

<?php
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";

$database_port = "3306";
?>

2. Enter database with information taken from db-settings.php information.

monitor# mysql -ucacti -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8343
Server version: 5.0.45 FreeBSD port: mysql-server-5.0.45_1

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>

mysql> use cacti;

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select * from auth_user;

ERROR 1146 (42S02): Table ‘cacti.auth_user’ doesn’t exist

Ups, my bad 🙂

mysql> select * from user_auth;

+—-+———-+————-———————+——-+—————+————–——–+———–+———–+————–+—————-+————+—————+————–+———–—+————————+
| id | username | password                         | realm | full_name     | must_change_password | show_tree | show_list | show_preview | graph_settings | login_opts | policy_graphs | policy_trees | policy_hosts | policy_graph_templates |
+—-+———-+————-———————+——-+—————+————–——–+———–+———–+————–+—————-+————+—————+————–+———–—+————————+
|  1 | admin    | 7a40008b8368b684bec2286db1b073e2 |     0 | Administrator |                      | on        | on        | on           | on             |          1 |             1 |            1 |            1 |                      1 |
|  3 | monitor  | 719daab8833968dc805a345c58545ea6 |     0 | monitoring    |                      | on        | on        | on           | on             |          3 |             1 |            1 |            1 |                      1 |
|  7 | crash    | ac43724f16e9241d990427ab7c8f4228 |     0 | Nsun T        |                      | on        | on        | on           | on             |          3 |             1 |            1 |            1 |                      1 |
+—-+———-+————-———————+——-+—————+————–——–+———–+———–+————–+—————-+————+—————+————–+———–—+————————+
3 rows in set (0.00 sec)

mysql>exit

3. Generate new password with md5 utility.

monitor# md5 -s mypassword

MD5 ("mypassword") = 34819d7beeabb9260a5c854bc85b3e44

4. Update database value with new created password string.

monitor# mysql -ucacti -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8344
Server version: 5.0.45 FreeBSD port: mysql-server-5.0.45_1

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>

mysql> update auth_user set password=’34819d7beeabb9260a5c854bc85b3e44′ where username=’admin’

done 🙂

PHP OO tutorials

Best way to learn scripting / program is easy. Just write the code and see the result.

With the progress of OOP approach in field recently for our team make its ‘hard’ to adapt such change in mindset :

Procedural vs Object Oriented Programming

With case codeiginter,  we must learn the basic of OOP in PHP. Starting by dumping php4 and use php5 for production release.

Thanks to a lot of tutorial about OO in internet world, some of them are :

  1. Tutorialized
  2. Codewalkers
  3. Massassi
  4. KillerPHP, very good. With video too.

I myself more familiar with book, as I can carry it whenever I want and read it in my bed. When I feel I like to practice I’ll dive to my laptop and try to code.

Some books ( I ordered some in Amazon ) are :

  1. PHP 5 Objects, Patterns, and Practice
  2. CodeIgniter for Rapid PHP Application Development

From amazon description :

CodeIgniter (CI) is a powerful open-source PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. CodeIgniter is an MVC framework, similar in some ways to the Rails framework for Ruby, and is designed to enable, not overwhelm.

Continue reading

in PHP | 774 Words

nl2br, new line to br

I just forget this function when my friend ask me about strangeness in his data he store in mysql.

He has address data in <textarea></textarea>, new line not converted to br as he thing. He just see all the input just store in single line.

After search for a while I remember this gold function :

nl2br () , new line to br

just make temporary variable before as :

$address=nl2br($address);

now $address will contain <br> tag in mysql database.

This post for remind me in future 😉

 

in PHP | 96 Words

php explode() and wordwrap()

Whats the different of explode() and wordwrap() ?

Answer :

just see this example for explode()

<?php

$birthday=’1998-12-11′;

//we need to split the component to date, month and year

$day_parts=explode(‘-‘,$birthday);

// we use – as tool to separate, now print

$date_component=$day_parts[2];

$month_component=$day_parts[1];

$year_component=$day_parts[0];

?>

Wordwrap will ‘wrapping’ user input, like formatting crazy user who type ‘aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa’ till he satisfied and brake our guestbook table.

Just make sure to add number bigger than 0 to enable wordwrap.

in PHP | 90 Words

101 CodeIgniter Resources

CodeIgniter already attract my attention since version 1.5, we even try to build application based on it.

Beside its clear documentation, their user support awesome too.

I’ll try to collect every resource that might useful to share with others who want to learn codeigniter.

This post will be update regularly as soon as I get another resource 🙂

CodeIgniter Main Page

1. Download site

2. User Guide

3. Wiki

4. Forum

CodeIgniter Video Tutorials

1. Hello world, introduction to CodeIgniter

2. Create a blog in 20 minutes

3. Derek Allard Video

CodeIgniter Books

1. CodeIgniter for Rapid PHP Application Development

CodeIgniter Tutorials

1. Introduction to Code Igniter: Part 1 by Godbit, learn about CI structure. starting the case of making form.

2. Introduction to Code Igniter: Part 2 by Godbit, form continued.

3. Introduction to Code Igniter: Part 3 by Godbit, CI interact with database.

4. Pagination with Code Igniter by Godbit, make navigation easy with paging in CI.

5. Code Igniter Template Tutorial by Eric Barnes, separate logic with presentation.

6. Templating with CodeIgniter, templating study case.

7. Using Zend Framework components in Code Igniter, integration zend framework into CI.

8. Building an RSS Feed in Code Igniter, Derek Allard show howto build RSS with CI.

9. Using Oracle with PHP and CodeIgniter, Oracle and CI teamed together. I use oracle xe instead.

10. Forms in CodeIgniter Views, use don’t repeat yourself concept 🙂

11. Checking CodeIgniter out of the Subversion Repository, Derek show how to use subversion of CI.

12. SimplePie RSS class and CodeIgniter, simplepie and CI work together.

13. Building a Complete CodeIgniter Application: Part 1, by Jim O’Halloran. Build feedignitation from scratch.

14. Building a Complete CodeIgniter Application: Part 2, by Jim O’Halloran.

15. Building a Complete CodeIgniter Application: Part 3, by Jim O’Halloran. Eliminate security problems.

Last Update : January 09 2008

Latest news : Code Igniter 1.6 released!, read more from DerekAllard blog.

in PHP | 287 Words