TrieuTuanNghia's blog

Vì một ngành công nghệ thông tin phát triển

Lỗi admin kit console

  • Tháng Mười Hai 15, 2011 10:43 sáng

Anh vào C:\Program Files\Kaspersky Lab\Kaspersky Administration Kit trên admin kit xóa file CS Admin Kit

Sau đó vào start run –> MMC -> add console mới cho Kaspersky administration kit.


Lưu lại với tên và đường dẫn file CS Admin Kit cũ.

How to Remove WGA Setup.exe

  • Tháng Mười Hai 9, 2011 9:29 sáng

WGA Setup.exe is the executable system file for the Windows Genuine Advantage Notifications tool or WGA for Windows XP. The WGA application notifies the user if the version of Windows XP they are using is not a genuine copy. Users with a genuine copy of Windows will not receive any notifications from the program. Removing the application can free up hard drive space for users with a valid copy of the operating system. The removal process takes a few steps that can be completed by novice computer users.

1
Stop the WGA processes running in the Task Manager as they will interfere with the removal. Press “Ctrl + Alt + Delete” on the keyboard to access the Task Manager. Click on the “Processes” tab and right-click on the “wgasetup.exe” filename in the list. Click on the “End Process Tree” option in the context menu.

2
Delete the tasks associated with WGAsetup.exe. Click on “Start,” click “All Programs” and choose “Accessories.” Click on “System Tools” and click “Scheduled Tasks.” Right-click on “WGASetup” task and click on the “Delete” option.

3
Right-click on “Start” and choose “Explore” to open the Windows Explorer. Use the folder tree to navigate to the “C:\WINDOWS\system32\KB905474″ folder. Right-click on the folder and click “Delete.” Return to the desktop, right-click on “Recycling Bin” and choose “Empty.”

4
Restart the computer to complete the removal process and save any changes to the system configuration and settings.

Lấy Lại Dữ Liệu Sau Khi Xóa

  • Tháng Mười 14, 2011 9:37 sáng

Bạn đã bao giờ nhỡ tay xóa mất một bảng (DROP TABLE) hoặc xóa sạch dữ liệu trong bảng (DELETE) của một database đang hoạt động rất nhộn nhịp, để rồi giật mình nhận ra mình vừa phạm một lỗi tày đình? Mồ hôi vã ra đầm đìa, nghe chuông điện thoại kêu mà giật mình thon thót, đầu óc quay cuồng nghĩ cách ăn nói thế nào cho phải… Hì hì làm cho kịch tính tí, nhưng quả thật những hoàn cảnh tương tự như vậy không phải hiếm. Đối với các DBA thường xuyên phải làm việc trực tiếp trên dữ liệu, những sự cố xảy ra do nhầm lẫn là không tránh khỏi. Rất may SQL Server đã tính đến tình huống này, và cung cấp các phương tiện cần thiết để lấy lại dữ liệu, với điều kiện database phải có những thiết lập đúng đắn từ trước.
Tuy nhiên bạn có thể thấy là vấn đề đã trở nên phức tạp hơn, câu lệnh không thể ROLLBACK lại được nữa vì SQL Server để chế độ mặc định là AUTO COMMIT. Khôi phục lại từ bản backup từ ngày hôm trước cũng không giải quyết được, vì như thế dữ liệu vừa mới được cập nhật trong ngày cũng sẽ mất tiêu luôn. Vấn đề đặt ra là cần lấy lại dữ liệu giống như thời điểm ngay trước khi chạy lệnh DELETE, chứ không phải từ ngày hôm qua. Một gợi ý cho bạn: log file luôn lưu lại tất cả các hành động diễn ra đối với database, bao gồm cả lệnh DELETE vừa xong. Đây là dấu vết duy nhất và cách làm của ta cũng là dựa vào đó để lần ngược lại.
Để có thể khôi phục lại được đòi hỏi ba điều kiện sau:
- database có chế độ RECOVERY MODE là FULL
- database đã từng được FULL BACKUP và bạn có trong tay file backup gần nhất
- log file chưa từng bị SHRINK kể từ sau lần full backup gần nhất.
Nếu một trong ba điều kiện trên bị vi phạm thì vấn đề kể như hết cách giải cứu.
Giả sử cả ba điều kiện trên được thỏa mãn và lần full backup gần đây nhất là đêm hôm trước. Bạn có thể khôi phục thông qua các bước sau (xem thêm script ở phần dưới):
1. Đóng lại tất cả các kết nối đến database để không tiếp nhận thêm dữ liệu
2. Ghi lại thời điểm xảy ra lệnh DELETE lỗi
3. Thực hiện BACKUP LOG cho database
4. Khôi phục lại database theo trình tự sau:
- RESTORE từ bản full backup đêm hôm trước
- RESTORE từ bản log backup với lựa chọn STOPAT = thời điểm ngay trước khi có sự cố
5. Và khi mọi việc đã hoàn tất, chuyển lại database sang chế độ hoạt động bình thường để các ứng dụng lại có thể kết nối vào database.

Script

Tạo database và bảng:

USE master
GO
IF DB_ID(‘TestDB’) IS NOT NULL DROP DATABASE TestDB
GO
CREATE DATABASE TestDB
GO
USE TestDB
GO
CREATE TABLE dbo.Table1(ID INT IDENTITY, Ten VARCHAR(30) )
GO
INSERT INTO dbo.Table1(Ten)
SELECT ‘Nguyen Van A’ UNION ALL
SELECT ‘Nguyen Van B’ UNION ALL
SELECT ‘Nguyen Van C’
Thực hiện full backup:

BACKUP DATABASE TestDB TO DISK = ‘D:\Backup\TestDB.bak’ WITH INIT
Thêm dữ liệu mới sau khi full backup:

INSERT INTO dbo.Table1(Ten)
SELECT ‘Nguyen Van D’ UNION ALL
SELECT ‘Nguyen Van E’
Ba đoạn lệnh trên mô phỏng tình huống thực tế một database đã có chứa dữ liệu, được backup full lúc nửa đêm hôm trước, và trong ngày đã có thêm dữ liệu mới. Tại một thời điểm nào đó trong ngày bạn xóa mất dữ liệu do sơ suất:

DELETE FROM dbo.Table1
Sau khi xảy ra sự cố, việc tiếp theo đầu tiên bạn cần làm là đóng lại database, để không ai có thể tiếp tục cập nhật dữ liệu đến khi database được khôi phục xong. Bạn làm việc này bằng cách chuyển database về trạng thái SINGLE_USER (một người dùng). Vì bạn đang kết nối vào database, không ai khác có thể kết nối được nữa:

ALTER DATABASE TestDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE
Sau đó ghi lại thời điểm xảy ra sự cố:

SELECT GETDATE()
Khi đang chạy script cho bài viết này, thời điểm hiện tại của tôi là ’2010-12-07 17:51:03.990′.
Việc tiếp theo là backup log:

BACKUP LOG TestDB TO DISK = ‘D:\backup\TestDB.trn’ WITH INIT
Sau đó khôi phục lại database theo thứ tự bản full backup trước rồi đến bản log backup:

USE master
go
RESTORE DATABASE TestDB FROM DISK = ‘D:\backup\TestDB.bak’ WITH NORECOVERY

RESTORE DATABASE TestDB FROM DISK = ‘D:\backup\TestDB.trn’ WITH STOPAT=’2010-12-07 17:50:00′
Điểm mấu chốt trong đoạn lệnh trên là mệnh đề STOPAT ở lệnh RESTORE thứ hai. Mục đích của nó là khôi phục lại database từ log backup nhưng dừng lại tại thời điểm được chỉ định. Khi các hành động xảy ra đối với database được lưu vào log file, nó cũng kèm theo thời điểm xảy ra hành động đó. Khi backup log file thì bản backup cũng chứa y nguyên các thông tin này. Vì thế khi restore từ log file với mệnh đề STOPAT, bạn đã yêu cầu hệ thống “tua” lại các hành động đã được áp dụng đối với database, nhưng dừng lại trước thời điểm có sự cố. Do đó lệnh DELETE trên không được thực hiện lại và bảng đã trở về trạng thái như cũ.

Hãy để ý ở mệnh đề STOPAT, tôi đã đẩy lùi thời gian lại một chút để đảm bảo thời điểm đó là trước khi xảy ra xóa dữ liệu. Khi chạy thử nghiệm bạn cần lưu ý điều này và chọn thời điểm cho thích hợp.
Và dữ liệu đã được khôi phục:

USE TestDB
GO
SELECT * FROM dbo.Table1

ID Ten
———– ——————————
1 Nguyen Van A
2 Nguyen Van B
3 Nguyen Van C
4 Nguyen Van D
5 Nguyen Van E

(5 ROW(s) affected)
Bước cuối cùng là chuyển lại database sang chế độ bình thường

ALTER DATABASE TestDB SET MULTI_USER
Vậy là vấn đề đã được giải quyết (sau khoảng nửa tiếng đến 1 tiếng gián đoạn sử dụng). Bây giờ là một câu hỏi giành cho bạn: Trong ví dụ trên tôi giả sử database chỉ có một backup duy nhất vào nửa đêm, và đó là full backup. Nếu ngoài ra database còn có các log backup định kỳ trong ngày (ví dụ mỗi tiếng 1 lần), thì việc khôi phục cần được thực hiện như thế nào?
Source: http://www.sqlviet.com/blog/lay-lai-du-lieu-sau-khi-xoa

The theme_table function

  • Tháng Chín 19, 2011 10:05 chiều

I come to you as one reformed. I will no longer use foreach loops to build tables. At first, I did not know about theme_table. Then I couldn’t be bothered to learn about it. Then, after feedback from people whose opinion I respect, I felt compelled to bite the bullet. I wish I hadn’t waited so long.

Overview
As the name suggests, theme_table is a Drupal theming function for creating tables. It takes arrays holding the table data and generates the HTML for displaying the table. At their simplest, the input arrays hold text elements. At their most complex, the arrays hold arrays which hold arrays. The various arrays all hold data appropriate to their location, so this isn’t as bad as it sounds.

As with all Drupal functions, there’s documentation at api.drupal.org. For the Drupal 5 theme_table function specifically: api.drupal.org/api/5/function/theme_table. There’s enough there to get you started, but you still have to think a bit. (Which is to say, I had to. Think a bit, that is.) Thinking should be reserved for the problem at hand, not figuring out Drupal, so here’s my “overflowing with examples so you can cut and paste” explanation of theme_table.

The Examples
In each section an example of the PHP code, the HTML output, and the actual table are shown. The HTML output is formatted to fit on the page. The PHP code is deliberately verbose for explanatory purposes. It can be pasted directly into a Drupal node set to the PHP Code input format if you wish to experiment.

The use of inline style is for demonstration only, and not the recommended way to style a table. Use a CSS style sheet and class selectors in the real world.

These examples also show how the Drupal default CSS can impact table styling.

A Simple Table
A very simple table can be defined as follows.

PHP
< ?php
// Table Header
$header = array( 'Header 1', 'Header 2', 'Header 3');

// Table Rows
$row[] = array( 'Row 1 / Column 1', 'Row 1 / Column 2', 'Row 1 / Column 3');
$row[] = array( 'Row 2 / Column 1', 'Row 2 / Column 2', 'Row 2 / Column 3');

// Render Table
$tableHTML = theme('table', $header, $row);

print '

‘ . htmlentities($tableHTML) . ”;
print $tableHTML;
?>
Resulting Table (Displayed)
Header 1	Header 2	Header 3
Row 1 / Column 1	Row 1 / Column 2	Row 1 / Column 3
Row 2 / Column 1	Row 2 / Column 2	Row 2 / Column 3
Resulting Table (HTML)
Header 1 Header 2 Header 3
Row 1 / Column 1 Row 1 / Column 2 Row 1 / Column 3
Row 2 / Column 1 Row 2 / Column 2 Row 2 / Column 3
The cell’s position in the array determines its position in the table. Table ( ) Attributes Attributes are added to the table tag by passing an additional associative array to theme_table to the theme function. Each array element is a table tag attribute, with the array key containing the attribute name and the array value containing the attribute value. We’ll expand the previous example by adding attributes for border, class, cellspacing and cellpadding. PHP < ?php // Table Attributes $attributes = array( 'border' => 1, ‘cellspacing’ => 0, ‘cellpadding’ => 5, ‘class’ => ‘example’ ); // Table Header $header = array( ‘Header 1′, ‘Header 2′, ‘Header 3′); // Table Rows $row[] = array( ‘Row 1 / Column 1′, ‘Row 1 / Column 2′, ‘Row 1 / Column 3′); $row[] = array( ‘Row 2 / Column 1′, ‘Row 2 / Column 2′, ‘Row 2 / Column 3′); // Render Table $tableHTML = theme(‘table’, $header, $row, $attributes); print ‘
' . htmlentities($tableHTML) . '

‘;
print $tableHTML;
?>
Resulting Table (Displayed)
Header 1 Header 2 Header 3
Row 1 / Column 1 Row 1 / Column 2 Row 1 / Column 3
Row 2 / Column 1 Row 2 / Column 2 Row 2 / Column 3
Resulting Table (HTML)

Header 1 Header 2 Header 3
Row 1 / Column 1 Row 1 / Column 2 Row 1 / Column 3
Row 2 / Column 1 Row 2 / Column 2 Row 2 / Column 3

Header Cell ( ) Attributes
Attributes are added to the header cells by changing the text entry to an associative array. The title text moves into a key/value pair with a key name of ‘data’. For example, the following two statements produce the same results:

< ?php
$header = array(
'Title 1',
'Title 2'
);

$header = array(
array('data'=>‘Title 1′),
array(‘data’=>’Title 2′)
);
?>
The tag attributes are defined as additional key/value entries in the array. As with the attribute array of the previous example, the array element key is the attribute name and array element value is the attribute value. In our running example we’ll add a CSS style to the column 1 and 2 titles. Note that the array entries can be mixed, they can be either simple text or an array.

PHP
< ?php
// Table Attributes
$attributes = array(
'border' => 1,
‘cellspacing’ => 0,
‘cellpadding’ => 5,
‘class’ => ‘example’
);

// Table Header
$header_title_1 = array(‘data’ => ‘Header 1′, ‘style’ => ‘color: red;’);
$header_title_2 = array(‘data’ => ‘Header 2′, ‘style’ => ‘color: blue;’);
$header_title_3 = ‘Header 3′;
$header = array( $header_title_1, $header_title_2, $header_title_3);

// Table Rows
$row[] = array( ‘Row 1 / Column 1′, ‘Row 1 / Column 2′, ‘Row 1 / Column 3′);
$row[] = array( ‘Row 2 / Column 1′, ‘Row 2 / Column 2′, ‘Row 2 / Column 3′);

// Render Table
$tableHTML = theme(‘table’, $header, $row, $attributes);

print ‘

' . htmlentities($tableHTML) . '

‘;
print $tableHTML;
?>
Resulting Table (Displayed)
Header 1 Header 2 Header 3
Row 1 / Column 1 Row 1 / Column 2 Row 1 / Column 3
Row 2 / Column 1 Row 2 / Column 2 Row 2 / Column 3
Resulting Table (HTML)

Header 1 Header 2 Header 3
Row 1 / Column 1 Row 1 / Column 2 Row 1 / Column 3
Row 2 / Column 1 Row 2 / Column 2 Row 2 / Column 3

Table Row (
) Attributes
The same method is used to add attributes to individual rows. An associative array is created with the row data in an element with the key name ‘data’. The attribute information is stored as key/value pairs.

In this example we’ll add a style attribute to change the background colour.

There are a number of things to note. theme_table automatically adds class=”even” and class=”odd” to the row tags. In our example, one of the attributes is class=”example”. You’ll note that theme_table combines the classes resulting in class=”example odd”. Once again notice how we can mix the simple and more complex arrays in the row.

PHP
< ?php
// Table tag attributes
$attributes = array(
'border' => 1,
‘cellspacing’ => 0,
‘cellpadding’ => 5,
‘class’ => ‘example’
);

// Table Header
$header_title_1 = array(‘data’ => ‘Header 1′, ‘style’ => ‘color: red;’);
$header_title_2 = array(‘data’ => ‘Header 2′, ‘style’ => ‘color: blue;’);
$header_title_3 = ‘Header 3′;
$header = array( $header_title_1, $header_title_2, $header_title_3);

// Table Rows
$row1_values = array( ‘Row 1 / Column 1′, ‘Row 1 / Column 2′, ‘Row 1 / Column 3′);
$row[] = array(
‘data’ => $row1_values,
‘style’ => ‘background-color: LightGrey;’,
‘class’ => ‘example’
);
$row[] = array( ‘Row 2 / Column 1′, ‘Row 2 / Column 2′, ‘Row 2 / Column 3′);

// Render Table
$tableHTML = theme(‘table’, $header, $row, $attributes);

print ‘

' . htmlentities($tableHTML) . '

‘;
print $tableHTML;
?>
Resulting Table (Displayed)
Header 1 Header 2 Header 3
Row 1 / Column 1 Row 1 / Column 2 Row 1 / Column 3
Row 2 / Column 1 Row 2 / Column 2 Row 2 / Column 3
Resulting Table (HTML)

Header 1 Header 2 Header 3
Row 1 / Column 1 Row 1 / Column 2 Row 1 / Column 3
Row 2 / Column 1 Row 2 / Column 2 Row 2 / Column 3

Table Cell ( ) Attributes
By this time I’m sure you already know how to add table cell attributes. An associative array is created with the cell data in an array element whose key name is ‘data’ and with the attributes as key/value pairs. In this example, we’ll add style attributes to each cell, and a class attribute to the middle cell.
PHP
< ?php
// Table tag attributes
$attributes = array(
'border' => 1,
‘cellspacing’ => 0,
‘cellpadding’ => 5,
‘class’ => ‘example’
);

// Table Header
$header_title_1 = array(‘data’ => ‘Header 1′, ‘style’ => ‘color: red;’);
$header_title_2 = array(‘data’ => ‘Header 2′, ‘style’ => ‘color: blue;’);
$header_title_3 = ‘Header 3′;
$header = array( $header_title_1, $header_title_2, $header_title_3);

// Table Rows
$row1_cell1 = array(
‘data’ => ‘Row 1 / Column 1′,
‘style’ => ‘color: Navy;’
);
$row1_cell2 = array(
‘data’ => ‘Row 1 / Column 2′,
‘style’ => ‘color: SeaGreen;’,
‘class’ => ‘middle-row’
);
$row1_cell3 = ‘Row 1 / Column 3′;

$row1_values = array($row1_cell1, $row1_cell2, $row1_cell3);

$row[] = array(
‘data’ => $row1_values,
‘style’ => ‘background-color: LightGrey;’
);
$row[] = array( ‘Row 2 / Column 1′, ‘Row 2 / Column 2′, ‘Row 2 / Column 3′);

// Render Table
$tableHTML = theme(‘table’, $header, $row, $attributes);

print $tableHTML;
?>
Resulting Table (Displayed)
Header 1 Header 2 Header 3
Row 1 / Column 1 Row 1 / Column 2 Row 1 / Column 3
Row 2 / Column 1 Row 2 / Column 2 Row 2 / Column 3
Resulting Table (HTML)

Header 1 Header 2 Header 3
Row 1 / Column 1 Row 1 / Column 2 Row 1 / Column 3
Row 2 / Column 1 Row 2 / Column 2 Row 2 / Column 3

Conclusion
Although a little involved at first, theme_table quickly becomes straight forward as one recognizes how the data is defined. Using theme_table removes the fiddly and sometimes complex HTML construction loops making code more readable, maintainable and faster to write.

Source: http://www.group42.ca/theming_101_%E2%80%93_theme_table_function

JS CALENDAR

  • Tháng Năm 19, 2011 7:21 sáng

Mot calendar rat dep de lam cong cu chon ngay cho chung ta co tai dia chi :

http://www.dynarch.com

Day la no -> jscalendar-1.0