Apache报错:Invalid command ‘DAV’

在配置SVN,重启动Apache的时候报错:

Invalid command ‘DAV’, perhaps mis-spelled or defined by a module not
included in the server configuration

原因是只加载了mod_dav_svn,而没有加载mod_dav

这两个module的关系是:You aren’t loading mod_dav. mod_dav_svn just implements the back-end, you
still need to have mod_dav, which implements the dav protocol.

Cannot load mod_dav_svn.so

今天发现:
The Apache service named  reported the following error:
Cannot load mod_dav_svn.so into server: \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3

官方有句:

I am trying to use mod_dav_svn with Apache on Win32 and I'm getting an error saying that the module cannot be found, yet the mod_dav_svn.so file is right there in \Apache\modules.

The error message in this case is a little misleading. Most likely Apache is unable to load one or more DLLs that mod_dav_svn.so relies on. If Apache is running as a service it will not have the same PATH as a regular user. Make sure that libdb4*.dllintl3_svn.dlllibeay32.dll ssleay32.dll are present in either\Apache\bin or \Apache\modules. You can copy them from your Subversion installation directory if they are not there.

If this still does not resolve the problem, you should use a tool like Dependency Walker onmod_dav_svn.so to see if there are any other unresolved dependencies.

拷贝上面提到的DLL还是有问题,最后我是把所有SVN的dll都拷贝过去,解决。

visualsvn推荐目录布局

48d254a1gw1e6usxr9a18j20go0kfmz7.jpg

It's a good practice to create one repository for the entire company or department and store all your projects in this repository. Creating separate repository for each project is not a good idea because in that case you will not be able to perform Subversion operations like copy, diff and merge cross-project.
It's not required but usually each projects has 3 subfolders: trunk, branches, tags. The trunk folder contains the main development branch, the branches folder contains subfolders with temporary copies of trunk for experimental development, release stabilization etc. and the tags folder contains copies of the officially released versions. See the section called "Strategies for Repository Deployment" in SVNBook to read more about project roots.

参考:http://www.visualsvn.com/support/topic/00017

屏蔽视频网站广告的方法

亲自测试了下确实可以完全屏蔽广告!所以发出来大家分享下。 原理是改hosts的! 第一步:找到C:\WINDOWS\system32\drivers\etc里面的hosts文件,双击打开,选用记事本打开。

#优酷
127.0.0.1 atm.youku.com
127.0.0.1 Fvid.atm.youku.com
127.0.0.1 html.atm.youku.com
127.0.0.1 valb.atm.youku.com
127.0.0.1 valf.atm.youku.com
127.0.0.1 valo.atm.youku.com
127.0.0.1 valp.atm.youku.com
127.0.0.1 lstat.youku.com
127.0.0.1 speed.lstat.youku.com
127.0.0.1 urchin.lstat.youku.com
127.0.0.1 stat.youku.com
127.0.0.1 static.lstat.youku.com
127.0.0.1 valc.atm.youku.com
127.0.0.1 vid.atm.youku.com
127.0.0.1 walp.atm.youku.com
#百度:
127.0.0.1 a.baidu.com
127.0.0.1 baidutv.baidu.com
127.0.0.1 bar.baidu.com
127.0.0.1 c.baidu.com
127.0.0.1 cjhq.baidu.com
127.0.0.1 cpro.baidu.com
127.0.0.1 drmcmm.baidu.com
127.0.0.1 e.baidu.com
127.0.0.1 eiv.baidu.com
127.0.0.1 hc.baidu.com
127.0.0.1 hm.baidu.com
127.0.0.1 ma.baidu.com
127.0.0.1 nsclick.baidu.com
127.0.0.1 spcode.baidu.com
127.0.0.1 tk.baidu.com
127.0.0.1 union.baidu.com
127.0.0.1 ucstat.baidu.com
127.0.0.1 utility.baidu.com
127.0.0.1 utk.baidu.com
127.0.0.1 focusbaiduafp.allyes.com
#奇艺
127.0.0.1 afp.qiyi.com
127.0.0.1 focusbaiduafp.allyes.com
#CNTV
127.0.0.1 a.cctv.com
127.0.0.1 a.cntv.cn
127.0.0.1 ad.cctv.com
127.0.0.1 d.cntv.cn
127.0.0.1 adguanggao.eee114.com
127.0.0.1 cctv.adsunion.com
#新浪视频
127.0.0.1 dcads.sina.com.cn
#pptv
127.0.0.1 pp2.pptv.com
#乐视
127.0.0.1 pro.letv.com
#搜狐高清
127.0.0.1 images.sohu.com
@HostsX 国内站点广告/视频类网站
#CNTV
127.0.0.1 a.cctv.com
127.0.0.1 a.cntv.cn
127.0.0.1 ad.cctv.com
127.0.0.1 d.cntv.cn
127.0.0.1 adguanggao.eee114.com
127.0.0.1 cctv.adsunion.com
#我乐网
127.0.0.1 acs.56.com
127.0.0.1 acs.agent.56.com
127.0.0.1 acs.agent.v-56.com
127.0.0.1 bill.agent.56.com
127.0.0.1 bill.agent.v-56.com
127.0.0.1 stat.56.com
127.0.0.1 stat2.corp.56.com
127.0.0.1 union.56.com
127.0.0.1 uvimage.56.com
127.0.0.1 v16.56.com
#6间房
127.0.0.1 pole.6rooms.com
127.0.0.1 shrek.6.cn
127.0.0.1 simba.6.cn
127.0.0.1 union.6.cn
#土豆网
127.0.0.1 adextensioncontrol.tudou.com
127.0.0.1 iwstat.tudou.com
127.0.0.1 nstat.tudou.com
127.0.0.1 stats.tudou.com
127.0.0.1 *.p2v.tudou.com*
127.0.0.1 at-img1.tdimg.com
127.0.0.1 at-img2.tdimg.com
127.0.0.1 at-img3.tdimg.com
127.0.0.1 adplay.tudou.com
127.0.0.1 adcontrol.tudou.com
127.0.0.1 stat.tudou.com
#酷6网
127.0.0.1 1.allyes.com.cn
127.0.0.1 analytics.ku6.com
127.0.0.1 gug.ku6cdn.com
127.0.0.1 ku6.allyes.com
127.0.0.1 ku6afp.allyes.com
127.0.0.1 pq.stat.ku6.com
127.0.0.1 st.vq.ku6.cn
127.0.0.1 stat0.888.ku6.com
127.0.0.1 stat1.888.ku6.com
127.0.0.1 stat2.888.ku6.com
127.0.0.1 stat3.888.ku6.com
127.0.0.1 static.ku6.com
127.0.0.1 v0.stat.ku6.com
127.0.0.1 v1.stat.ku6.com
127.0.0.1 v2.stat.ku6.com
127.0.0.1 v3.stat.ku6.com
#激动网
127.0.0.1 86file.megajoy.com
127.0.0.1 86get.joy.cn
127.0.0.1 86log.joy.cn
#天线视频
127.0.0.1 casting.openv.com
127.0.0.1 m.openv.tv
127.0.0.1 uniclick.openv.com
#迅雷看看屏蔽:
127.0.0.1 mcfg.sandai.net
127.0.0.1 biz5.sandai.net
127.0.0.1 server1.adpolestar.net
127.0.0.1 advstat.xunlei.com
127.0.0.1 mpv.sandai.net

然后就可以痛痛快快的看视频了!

ado数据库读取例子

用appwizard新建一个dialog based的mfc项目,加入项目名字叫“contact”, 在StdAfx.h底部加入代码:

#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")

CContactDlg::OnInitDialog()代码如下

BOOL CContactDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
    // Add "About..." menu item to system menu.
    // IDM_ABOUTBOX must be in the system command range.
    ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
    ASSERT(IDM_ABOUTBOX < 0xF000);
    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
    {
        CString strAboutMenu;
        strAboutMenu.LoadString(IDS_ABOUTBOX);
        if (!strAboutMenu.IsEmpty())
        {
            pSysMenu->AppendMenu(MF_SEPARATOR);
            pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
        }
    }
    // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);            // Set big icon
    SetIcon(m_hIcon, FALSE);        // Set small icon
    // ado数据库操作
    AfxOleInit();
    _ConnectionPtr m_pConnection;
    _RecordsetPtr m_pRecordset;
    _variant_t RecordsAffected;
     HRESULT hr;
    try
    {
        hr = m_pConnection.CreateInstance("ADODB.Connection");
        if(SUCCEEDED(hr))
        {
            m_pConnection->ConnectionTimeout=5;
            if(m_pConnection->State)
                m_pConnection->Close();
            hr = m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=contact.mdb","","",adModeUnknown);
            AfxMessageBox("连接成功");
            m_pRecordset.CreateInstance("ADODB.Recordset");
            m_pRecordset=m_pConnection->Execute("select * from contacts",&RecordsAffected,adCmdText);
            _variant_t vIndex = (long)0;
            _variant_t vCount=m_pRecordset->GetCollect(vIndex);
            _variant_t var;
            char *str;
            try
            {
                if(!m_pRecordset->BOF)
                {
                    m_pRecordset->MoveFirst();
                }
                else
                {
                    AfxMessageBox("表内数据为空");
                    return TRUE;
                }
                while(!m_pRecordset->adoEOF)
                {
                    var = m_pRecordset->GetCollect("position");
                    if(var.vt != VT_NULL)
                    {
                        str=_com_util::ConvertBSTRToString((_bstr_t)var);
                        AfxMessageBox(str);
                        m_pRecordset->MoveNext();
                    }
                }
            }
            catch (_com_error e)
            {
                CString errormessage;
                errormessage.Format("读取错误:%s",e.ErrorMessage());
                AfxMessageBox(errormessage);
            }
            //CString msg;
            //msg.Format("共有%d条记录",vCount.lVal);
            //AfxMessageBox(msg);
        }
    }
    catch(_com_error e)
    {
        CString errormessage;
        errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
        AfxMessageBox(errormessage);
    }
    return TRUE;  // return TRUE  unless you set the focus to a control
}

contact.mdb里面的contacts表的字段有id,name,position,mobile,phone_home,phone_office,email,address。

读写ini文件

WritePrivateProfileString("student","Name","xiaotun","c:\\setting.ini");

WritePrivateProfileString() 是往ini里面写入内容,”student”是section name,”Name”是key,”xiaotun”是value,c:\setting.ini是指定写入的文件,必须是绝对路径,否则搜索%systemroot%目录

写入的文件内容是
[student]
Name=xiaotun

WritePrivateProfileString("student","Name","xiaotun","c:\\setting.ini");
WritePrivateProfileString("student","Age","18","c:\\setting.ini");

写入的内容是:
[student]
Name=xiaotun
Age=18

读取:
DWORD GetPrivateProfileString(
LPCTSTR lpAppName, // points to section name
LPCTSTR lpKeyName, // points to key name
LPCTSTR lpDefault, // points to default string
LPTSTR lpReturnedString, // points to destination buffer
DWORD nSize, // size of destination buffer
LPCTSTR lpFileName // points to initialization filename
);

例如:

GetPrivateProfileString(NULL,NULL,NULL,buf,sizeof(buf),"D:\\Debug\\test.inf");

和Write基本一样,只是第三个参数LPCTSTR lpDefault是当lpKeyName没有找到的时候的默认keyname。

不用MFC AppWizard创建MFC项目

This will describe how to create an MFC application without using the AppWizard. I do not recommend doing this always of course but I think this can be a useful alternative to using a dialog-based application. People often use dialog-based MFC applications when they do not want all the complications of the “MFC Document/View Architecture” yet dialogs have limitations. So in those situations that you want the simplicity of a dialog yet you want the conveniences of a real window you might want to use this solution. You can use the AppWizard to generate a SDI application and yank out and/or override parts you do not need so it is more a matter of personal preference.

There are some MFC experts that would say you are foolish to not use the AppWizard to generate a MFC project initially, as if MFC was designed to only be used in a project generated by the AppWizard. I learned MFC beginning with the first version when the AppWizard was not as powerful as it is now (as if it is really powerful now). I know that there was definitely MFC documentation showing how to make a simple MFC program with only about a dozen lines. It is relatively easy to create a small program that uses MFC without using the AppWizard; the only trick is that it is practically a necessity to have a resource file. Assuming we are not making an application that just has a modal dialog box, then we must have menu and string table resources. Initially our small applications will only have a plain CFrameWnd window without any overrides or handlers or anything like that but I will show how to add a view.

The Project

To create the project:

  • Use the “File | New” menu as usual for creating projects
  • Select the tab for “Projects”
  • Create a “Win32 Application” project
  • Use whatever name you wish to for the project; I am using “TinyMFC”

When the project has been created, in the Project Settings, on the “General” tab, change it from saying not to use MFC to saying to use MFC (for all configurations). You can choose to use MFC in either a static or dynamic library.

The Resource File

The menu can have anything in it; the requirement is that the resource Id for the menu must be IDR_MAINFRAME. The string table can have only one string in it and that string should have a resource Id also of IDR_MAINFRAME. The string is used by CWinApp for the application’s title, such as in message boxes.

To create a Resource Script file, use the “File | New” menu and select the tab for “Files”. Create a “Resource Script” file. Then:

  1. Insert a String Table into the Resource Script.
  2. Add a string to the String Table with an ID of IDR_MAINFRAME; it’s value must be 128 but that value should happen automatically. Set the string to whatever you want for the application title.
  3. Add a menu to the project. Give the menu an id of IDR_MAINFRAME. The menu can consist of a single non-popup item with an id of ID_APP_EXIT and caption of “E&xit”.

The Program

Then add to the project a file (named TinyMFC.cpp or whatever is appropriate for you) containing:

#include <afxwin.h>
#include "resource.h"
class CTinyMFCApp : public CWinApp {
    virtual BOOL InitInstance();
};
CTinyMFCApp TinyMFCApp;
BOOL CTinyMFCApp::InitInstance() {
    CRect Rect(100, 100, 500, 500);
CFrameWnd* pMainFrame = new CFrameWnd;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) {
    AfxMessageBox("LoadFrame failed");
    return FALSE;
    }
pMainFrame->ShowWindow(m_nCmdShow);
m_pMainWnd = pMainFrame;
return TRUE;
}

Using ClassWizard

The following explains how to Create an MFC application without the AppWizard and with ClassWizard support.

Creating the Project and Resource Script File

You could use the same project as the one for the TinyMFC project above but I recommend creating a new project. Create it the same way as for the TinyMFC project. Use whatever name you wish to for the project; I am using “WithoutWizard”. Something else you can change in the project settings is to specify use of pre-compiled headers. Just specify “StdAfx.h” for the “Through Header”. The next thing to do is to create a Resource Script file; it can also be created the same as for the TinyMFC project.

Creating the Header and Implementation Files

Now we create the header and implementation files. I will assume you are familiar with enough of the basics to understand how this works but there might be some things I should explain better. A lot of this can be done a bit differently depending on your preferences and requirements. I am using the standard filenames StdAfx.h and StdAfx.cpp to ensure use of the ClassWizard, although I am not sure how important that is. At least it allows use of precompiled headers in a standard manner, right?

  1. Create the StdAfx.h header file with the following:
#pragma once
#define VC_EXTRALEAN
#include <afxwin.h>
  1. Create the StdAfx.cpp file with the following:
#include "stdafx.h"
  1. Create the header file for your program. Assuming the project is named “WithoutWizard”, the header file would be “WithoutWizard.h”. Put the following in it:
#pragma once
class CWithoutWizardApp : public CWinApp {
public:
    CWithoutWizardApp() {};
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWithoutWizardApp)
public:
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CWithoutWizardApp)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
  1. Create the main cpp file for your program. Assuming the project is named “WithoutWizard”, the cpp file would be “WithoutWizard.cpp”. Put the following in it:
#include "stdafx.h"
#include "resource.h"
#include "WithoutWizard.h"
BEGIN_MESSAGE_MAP(CWithoutWizardApp, CWinApp)
//{{AFX_MSG_MAP(CWithoutWizardApp)
//}}AFX_MSG
END_MESSAGE_MAP()
CWithoutWizardApp WithoutWizardApp;

Override InitInstance

Notice that unlike TinyMFC, we do not have even an InitInstance for our application. We will now add that.

Save all unsaved files in the project. Then try to show the ClassWizard. There will be a message box saying that the ClassWizard file does not exist and it will offer to build it for you; say yes of course. Then use the ClassWizard to add an override for InitInstance for your application.

Add Code That Does Something

Add something to the InitInstance such as:

#ifdef _AFXDLL
    Enable3dControls(); // Call this when using MFC in a shared DLL
#else
    Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(8); // Load standard INI file options (including MRU)
CFrameWnd *pFrameWnd;
pFrameWnd = new CFrameWnd;
if (!pFrameWnd->LoadFrame(IDR_MAINFRAME)) {
    AfxMessageBox("Frame not created");
    return FALSE;
    }
m_pMainWnd = pFrameWnd;
pFrameWnd->ShowWindow(m_nCmdShow);
pFrameWnd->UpdateWindow();

Build the project and test it. This will provide a minimal application.

Making Something Useful

You can use the ClassWizard to add a class derived from CFrameWnd and use that class for your frame, so you can customize the window as needed. You would then have a simple application that could be used for many things. The application would probably be especially useful if you only needed to use GDI with the window.

Making a View

Since we are using CFrameWnd::LoadFrame to create a frame window, it is quite easy to add a view. First derive a class from a view. (You can use CFormView, but if you do then you need to create the dialog box template for it before creating a class derived from CFormView.) Then specify the derived class in an instance of CCreateContext, then pass that to LoadFrame. So your InitInstance could be something like:

BOOL CWithoutWizardApp::InitInstance() {
#ifdef _AFXDLL
    Enable3dControls(); // Call this when using MFC in a shared DLL
#else
    Enable3dControlsStatic();   // Call this when linking to MFC statically
#endif
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(8);  // Load standard INI file options (including MRU)
CFrameWnd *pFrameWnd;
pFrameWnd = new CFrameWnd;
if(!pFrameWnd) {
    AfxMessageBox("Window not made");
    return FALSE;
    }
CCreateContext CreateContext;
CreateContext.m_pNewViewClass = RUNTIME_CLASS(CWithoutWizardView);
CreateContext.m_pCurrentFrame = pFrameWnd;
if (!pFrameWnd->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
        NULL, &CreateContext)) {
    AfxMessageBox("Frame Load Error");
    return FALSE;
    }
m_pMainWnd = pFrameWnd;
pFrameWnd->InitialUpdateFrame(NULL, TRUE);   // Will do ShowWindow
return CWinApp::InitInstance();
}

Additional Notes

I have summarized what CFrameWnd::LoadFrame does in case that helps.

Also, I am not sure if it would work to use CWnd::Create to create a plain window instead of using CFrameWnd::LoadFrame and getting a frame window. I tried but could not get it to work. It is easy enough to try but until I do let me just say that one thing that is important is that the main window object must be allocated in the heap (with “new”). That is because MFC will destroy the main window for you and will use “delete” for the object. It does this for the object that m_pMainWnd points to. If m_pMainWnd  is NULL then InitInstance will exit the application, so it does not work to do that.

Since we are operating with a stripped-down MFC we are missing a few conveniences. One problem is: where is the view? How can the applicaton class communicate with the view? The following is one way for the application to find the view:

CView * CWithoutWizardApp::FindView() {
    const CString ClassName("CWithoutWizardView");
    CRuntimeClass* pRuntimeClass;
    CWnd* pWnd=NULL;
pWnd = m_pMainWnd->GetDescendantWindow(AFX_IDW_PANE_FIRST);
if (!pWnd)
    return NULL;
pRuntimeClass = pWnd->GetRuntimeClass();
if (pRuntimeClass->m_lpszClassName == ClassName)
    return (CView *)pWnd;
return NULL;
}

Notice that using CRuntimeClass to check the class is not necessary and could be removed; at least it is not necessary for a release build. So FindView can be used as in the following:

pWithoutWizardView = (CWithoutWizardView*)FindView();
if (pWithoutWizardView) {
    pWithoutWizardView->OnUpdate(NULL, 1, &MessageText);
}

To use OnUpdate in that manner, put the following in your view class:

friend class CWithoutWizardApp;

via

在线选课系统

在线选课系统

在硬盘里面一个偏僻的角落翻出来的,上大二学《数据库》的课程设计写的在线选课系统,用的php+mysql。那个时候初学php,mysql,代码相当蛋疼,还有报错,但是勾起了很多美好的回忆。下载链接:http://tunps.com/lab/oes.rar

小吞AA制记账系统

小吞AA制记账系统

小吞AA制记账系统 是去年10月份写的个人财务管理系统,采用php+mysql,smarty模板引擎。那个时候和同学合租,因为买菜之类的需要AA,就需要报账,所以需求出来了,就写了一个。可以添加、删除、修改,有公费、私费类别,公费可以结算,私费可以算自己的小帐。可以按比例结算,比如4:6的比例来结算。

安装:下载源码

http://tunps.com/lab/php/aa.zip

比如下载到目录d:\www\aa\,用PMA新建数据库,比如名字是expense,然后导入d:\www\aa\expense.sql,修改d:\www\aa\data\config.php 设置你的mysql数据库的用户名、密码、数据库名信息 就可以使用了。

默认的测试数据里面帐号用户名/密码有:admin/admin cc/cc sj/sj lgy/lgy hk/hk ,密码是 md5(“用户名”) ,你可以自行修改user表来管理用户。

GetVolumeInformation

TCHAR volumeName[MAX_PATH + 1] = { 0 };
TCHAR fileSystemName[MAX_PATH + 1] = { 0 };
DWORD serialNumber = 0;
DWORD maxComponentLen = 0;
DWORD fileSystemFlags = 0;
if (GetVolumeInformation(
    _T("C:\\"),
    volumeName,
    ARRAYSIZE(volumeName),
    &serialNumber,
    &maxComponentLen,
    &fileSystemFlags,
    fileSystemName,
    ARRAYSIZE(fileSystemName)))
{
    _tprintf(_T("Volume Name: %s\n"), volumeName);
    _tprintf(_T("Serial Number: %lu\n"), serialNumber);
    _tprintf(_T("File System Name: %s\n"), fileSystemName);
    _tprintf(_T("Max Component Length: %lu\n"), maxComponentLen);
}

serialNumber是双字,所以%d是正常显示的,所以用了%lu。
ARRAYSIZE 是宏: #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))。
volumeName是卷标名
serialNumber是卷标序列号(表示为0xAAAAAAAA)
maxComponentLen 最长文件名

代码来源:http://www.dreamincode.net/forums/topic/70779-howto-use-msdn-functions-%26gt%3B-getvolumeinformation/page__view__findpost__p__457887