Monday, March 24, 2014

Conduit Search Virus

3/24/14

I have been downloading a lot of files. Somewhere along the way, I picked up the Conduit search virus.

I ran Windows defender: it did not find it.

I ran AVG: it did not find it.

I downloaded AdwCleaner and ran it. It found it and removed it.

11/20/16

Another virus. If I double clicked on a folder, a search started and never finished. I could not open an admin window, I could not run regsvr /i shell32.dll.

Kaspersky did not find it.

AdwCleaner found it and cleaned it.

Insert Key on iMac

I have an iMac with the small, aluminum keyboard. I do not have an insert key. I do not have a help key.

fn+enter simulates the insert key when I use bootcamp and Windows 7.

Sunday, March 16, 2014

Many-to-many Database Relation in Yii

I have three database tables:

Phonebook - employee contact info.
Council - members of the Unit that are in the advisory council.
Offices - titles of all offices in the council

Council has fields for an employee id and the year of council service (and a primary key).
Offices are titles (and a primary key).
Phonebook has a field for employee id (and a primary key). It also has fields such as name, address, phone.

An index table, council_offices, has been created to link Council to Offices. A person on the council can hold many offices. Several people can have the same title. It has a field for the Council primary key and a field for the Offices primary key (and a primary key). A relation has been created for each field.

Each table is represented as a model in Yii. The relations method is of importance here. The Offices table does not have any relations.

CouncilOffices relations

Each record in the CouncilOffices table has a many-to-one relationship with the Council and Offices tables. Council and Offices are related as many-to-many. The way to implement this is with two many-to-one relationships through an intermediate table.

BELONGS-TO indicates that CouncilOffices is the many side and Council is the one side of the relation. The council_index field links to the primary field of the Council table. Create a foreign key in the council_offices table that links to the primary key from the council table.

A similar relationship exists for Offices.

        return array(
                    'councilRelation'=>array(self::BELONGS_TO, 'Council', 'council_index'),
                    'officesRelation'=>array(self::BELONGS_TO, 'Offices', 'offices_index'),
        );
   
Council relations

Council defines the many-to-many relationship to Offices. Offices does not define any relations. The third parameter defines how the relationship works: It uses the council_offices table, tying the council_index to the offices_index. These names are the actual names from the table, including the table name and field names. It is confusing that Offices is the name of the Yii class for the model, while council_offices is the actual name of the table in the database.

Council also defines a relationship to the phonebook. It should actually be one-to-one, but one-to-many will also work.

        return array(
                    'officeRelation'=>;array(self::MANY_MANY, 'Offices',
                        'council_offices(council_index,offices_index)',
                        ),
                    'phonebookRelation'=>;array(self::BELONGS_TO, 'Phonebook',
                        'id',
                        ),
        );

Create a foreign key from the id field of the council table to the phonebook table. In my case, the foreign key is to an index, not to a primary key. I am using mySql with INNODB tables. Yii does not specify this relationship, it only exists in the actual table. Create an index for the target field in the phonebook table and then use SQL to create the foreign key (phpMyAdmin only allows foreign keys to primary keys).

alter table council add foreign key (id) references phonebook(pid);

Phonebook relations

The Phonebook does not need any relations in Yii. It should have an index for the empolyee id (pid) in the phonebook table.

Form that accesses data

The payoff is accessing the relations. In the example below, $data is the CouncilOffices table.



Thursday, March 13, 2014

Using Ping in Windows

The ping command from a Windows command prompt can be used to check the availability of a host:
Windows documentation.

Two options control how many pings to send. The default number is four.
ping -t
Keep sending Echo Requests until interrupted.
ping -n 5
Send the specified number of Echo Requests.
Two options can be used to test the size of the maximum transmission unit. Use one option to specify the size of the message to send and use the other option to prevent the message from being broken into smaller sizes. If the message is too large to send then the router will not send it.
ping -l 1500
Specify the size of the data field in the message to send.
ping -f
Do not fragment the message. The message must be sent as one unit or be rejected.
ping -f -l 1500
Combine both flags to test the size of the transmission unit. Try smaller numbers for the size until the message is sent.
One option can be used to find the time it takes to reach the host. It can also be used to find intermediate relay addresses.
ping -i 10
Specify the time that the message can live - time to live (TTL). If the time expires, then the message will not be sent. It may be that the message makes several hops before the time out is reached. The last name server to process the message may send a response indicating that the request timed out.
Start with a small number for the time to live and increase it until the host can respond.

Start with a TTL of 1 and you will get a response from a close name server to your machine. Increase the TTL by 1 on subsequent requests and you will get responses from different name servers along the route. Some requests may time out, since the name server that received the timed out packet did not forward the failure notification. Other servers will send a message that the request timed out.

The last procedure can also be used to check the name servers along the route. By increasing the TTL, different name servers will respond with messages. The flaw is that name servers are not required to send a response when a message expires. This is the procedure that the tracert command does.

Another option can be used to find the name servers along the route.
ping -r 9
Record the name servers that forward the message. The count must be in the range from 1 to 9.

Followers