poniedziałek, 12 grudnia 2011

[Leraning Yii] How to get current page title, current action, and current model ?

Yii::app()->controller->action->id //current action name
Yii::app()->controller->id //current model name
Yii::app()->controller->pagetitle //page title

środa, 7 grudnia 2011

[Learning Yii] Find by ID - One to rule them all

Yii is fun. If you understand it. I try to understand it everyday, so I will write about it from time to time.

How to get only 1 result from any table in your project using ID?

NameOfTable::model()->search criteria->columne name
ex:
TestPack::model()->findByPk(1)->name //means: in table TestPack find row with id 1 and show it's name
Fun starts, when you need to do more complex requests - then you can chain requests:
TestPack::model()->findByPk(Test::model()->findByPk($_GET['id'])->test_pack_id)->name

piątek, 2 grudnia 2011

How to change MAC address under Linux Debian Squeeze

Changing MAC address should be easy, and it almost is. There are plenty of methods. I like this one - it will work for simple LAN configuration with DHCP, for one session. There is also simple modification to make it permanent. If it will work for WLAN - I have no idea.

In Debian there is something called Networking Manager. Networking Manager, automagically manages your network. So if you want to change MAC addres for card, you must first disable Networking Manager for this card . To do so:

  1. Open /etc/network/interfaces<
  2. Uncomment
    iface eth0 inet dhcp
  3. Add line
    auto eth0
  4. Save

Be sure that Networking Manager doesn't remember about your card and reboot or do:

$ /etc/init.d/network-manager stop
$ /etc/init.d/network-manager start

Now you are ready to change MAC address:

$ ifdown eth0
$ ifconfig eth0 hw ether 01:02:03:04:05:06
$ ifup eth0

If you want to revert to your original MAC address you have to repeat commands, giving your real MAC or reboot computer. I didn't find any method for restoring MAC to original state, without wiritng it again. If you know one, let me know.

Make it permanent

If you want to change MAC for longer than just one session in /etc/network/interfaces add another line, to stated above, under last line:

hwaddress ether 01:02:03:04:05:06

Macchanger

There is also program called macchanger, which does the same, but in one line. It's OK, but it still doesn't have option to restore real MAC address.