cvs: php4 /ext/iisfunc .cvsignore errors.txt iisfunc.cpp iisfunc.dsp iisfunc.h setup.c setup.h
| From: | Frank M. Kromann | Date: | Sun, 22 Oct 2000 23:06:06 +0000 |
| Subject: | cvs: php4 /ext/iisfunc .cvsignore errors.txt iisfunc.cpp iisfunc.dsp iisfunc.h setup.c setup.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-2229@lists.php.net to get a copy of this message | ||
fmk Sun Oct 22 16:06:06 2000 EDT
Added files:
/php4/ext/iisfunc .cvsignore errors.txt iisfunc.cpp iisfunc.dsp
iisfunc.h setup.c setup.h
Log:
Adding new extention used to manage IIS webservers on NT4 and Windows 2000
@ IIS Admin mudule added
Index: php4/ext/iisfunc/.cvsignore +++ php4/ext/iisfunc/.cvsignore Makefile *.lo *.la libs *.plg Release Release_TS Debug Debug_TS Makefile.am deps libs.mk Index: php4/ext/iisfunc/errors.txt +++ php4/ext/iisfunc/errors.txt Errors number is IISFUNC: -101: Problem with OpenSCManager. -102: Problem with OpenService. -103: Problem with Stop Service. -104: Problem with Start Service. -105: Problem with Get Service State. -501: Can't open Web Service! -502: Can't add new key! -503: Can't configure key to WebServer! -504: Can't configure Server Comment! -505: Can't configure Server Bindings! -506: Can't configure web server to path! -507: Can't set rights on web server! -508: Can't start web server! -509: Can't set dir security on web server! Index: php4/ext/iisfunc/iisfunc.cpp +++ php4/ext/iisfunc/iisfunc.cpp /* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Frank M. Kromann <fmk@swwwing.com> | +----------------------------------------------------------------------+ */ /* $Id: iisfunc.cpp,v 1.1 2000/10/22 23:06:05 fmk Exp $ */ /* iisfunc.cpp : Defines the entry point for the DLL application. */ #define UNICODE #define INITGUID #include <windows.h> #include <stdio.h> #define _ATL_DLL_IMPL #include <ks.h> #include <atlbase.h> // ATL support #include <iadmw.h> // COM Interface header #include "iisfunc.h" extern "C" IISFUNC_API int fnIisGetServerByPath(char * ServerPath) { HRESULT hRes = 0, hResSub = 0; DWORD buffer = 0; DWORD dwBuffer = 65535; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; PBYTE pbBuffer = new BYTE[dwBuffer]; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; WCHAR KeyName[METADATA_MAX_NAME_LEN]; WCHAR TestKey[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; DWORD indx = 0; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); while (SUCCEEDED(hRes)){ hRes = pIMeta->EnumKeys(MyHandle, L"/", SubKeyName, indx); if (SUCCEEDED(hRes)) { MyRecord.dwMDIdentifier = MD_VR_PATH; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = ALL_METADATA; MyRecord.dwMDDataLen = dwBuffer; MyRecord.pbMDData = pbBuffer; swprintf(KeyName, L"/%s/ROOT", SubKeyName); hResSub = pIMeta->GetData(MyHandle, KeyName, &MyRecord, &buffer); if (SUCCEEDED(hResSub)) { memset(KeyName , 0, sizeof(KeyName)); swprintf(KeyName, L"%s", MyRecord.pbMDData); memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey, L"%S", ServerPath); if (wcscmp(_wcsupr(KeyName),_wcsupr(TestKey))==0) return wcstol(SubKeyName,NULL,10); } } indx++; } pIMeta->CloseKey(MyHandle); return 0; } extern "C" IISFUNC_API int fnIisGetServerByComment(char * ServerComment) { HRESULT hRes = 0, hResSub = 0; DWORD buffer = 0; DWORD dwBuffer = 65535; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; PBYTE pbBuffer = new BYTE[dwBuffer]; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; WCHAR KeyName[METADATA_MAX_NAME_LEN]; WCHAR TestKey[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; DWORD indx = 0; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); while (SUCCEEDED(hRes)){ hRes = pIMeta->EnumKeys(MyHandle, L"/", SubKeyName, indx); if (SUCCEEDED(hRes)) { MyRecord.dwMDIdentifier = MD_SERVER_COMMENT; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = ALL_METADATA; MyRecord.dwMDDataLen = dwBuffer; MyRecord.pbMDData = pbBuffer; swprintf(KeyName, L"/%s/ROOT", SubKeyName); hResSub = pIMeta->GetData(MyHandle, KeyName, &MyRecord, &buffer); if (SUCCEEDED(hResSub)) { memset(KeyName , 0, sizeof(KeyName)); swprintf(KeyName, L"%s", MyRecord.pbMDData); memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey, L"%S", ServerComment); if (wcscmp(_wcsupr(KeyName),_wcsupr(TestKey))==0) return wcstol(SubKeyName,NULL,10); } } indx++; } pIMeta->CloseKey(MyHandle); return 0; } extern "C" IISFUNC_API int fnIisAddServer(char * ServerPath, char * ServerComment, char * ServerIp, char * ServerPort, char * ServerHost, DWORD ServerRights, DWORD StartServer) { HRESULT hRes = 0; DWORD dwBuffer = 65535; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; PBYTE pbBuffer = new BYTE[dwBuffer]; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; WCHAR KeyName[METADATA_MAX_NAME_LEN]; WCHAR TestKey[METADATA_MAX_NAME_LEN]; DWORD ServerInstance; CComPtr <IMSAdminBase> pIMeta; DWORD indx = 0; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; swprintf(TestKey,L"1"); hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); while (SUCCEEDED(hRes)){ hRes = pIMeta->EnumKeys(MyHandle, L"/", SubKeyName, indx); if (SUCCEEDED(hRes)) if (wcstol(SubKeyName,NULL,10)>wcstol(TestKey,NULL,10)) { memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey,L"%ld",wcstol(SubKeyName,NULL,10)); } indx++; } pIMeta->CloseKey(MyHandle); ServerInstance = wcstol(TestKey,NULL,10)+1; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_WRITE, 20, &MyHandle); if (SUCCEEDED(hRes)) { swprintf(SubKeyName,L"/%ld/ROOT",ServerInstance); hRes = pIMeta->AddKey(MyHandle, SubKeyName); if (SUCCEEDED(hRes)) { memset(KeyName , 0, sizeof(KeyName)); swprintf(KeyName, L"/%ld", ServerInstance); memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey,L"IIsWebServer"); MyRecord.dwMDIdentifier = MD_KEY_TYPE; MyRecord.dwMDAttributes = METADATA_INSERT_PATH; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = STRING_METADATA; MyRecord.pbMDData=(PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR); if(!SUCCEEDED(pIMeta->SetData(MyHandle, KeyName, &MyRecord))) return -503; memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey,L"%S",ServerComment); MyRecord.dwMDIdentifier = MD_SERVER_COMMENT; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = STRING_METADATA; MyRecord.pbMDData=(PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR); if(!SUCCEEDED(pIMeta->SetData(MyHandle, KeyName, &MyRecord))) return -504; memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey,L"%S:%S:%S",ServerIp,ServerPort,ServerHost); MyRecord.dwMDIdentifier = MD_SERVER_BINDINGS; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = MULTISZ_METADATA; MyRecord.pbMDData=(PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR) + 1 * sizeof(WCHAR); if(!SUCCEEDED(pIMeta->SetData(MyHandle, KeyName, &MyRecord))) return -505; memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey,L"%S", ServerPath); MyRecord.dwMDIdentifier = MD_VR_PATH; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = STRING_METADATA; MyRecord.pbMDData=(PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR); if(!SUCCEEDED(pIMeta->SetData(MyHandle, SubKeyName, &MyRecord))) return -506; MyRecord.dwMDIdentifier = MD_ACCESS_PERM; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)&ServerRights; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->SetData(MyHandle, KeyName, &MyRecord))) return -507; MyRecord.dwMDIdentifier = MD_SERVER_COMMAND; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)&StartServer; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->SetData(MyHandle, KeyName, &MyRecord))) return -508; } else return -502; } else return -501; pIMeta->CloseKey(MyHandle); return ServerInstance; } extern "C" IISFUNC_API int fnIisRemoveServer(DWORD ServerInstance) { HRESULT hRes = 0; DWORD dwBuffer = 65535; METADATA_HANDLE MyHandle; PBYTE pbBuffer = new BYTE[dwBuffer]; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_WRITE, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld", ServerInstance); hRes = pIMeta->DeleteChildKeys(MyHandle, SubKeyName); if (!SUCCEEDED(hRes)) return -602; hRes = pIMeta->DeleteAllData(MyHandle, SubKeyName, ALL_METADATA, ALL_METADATA); if (!SUCCEEDED(hRes)) return -603; hRes = pIMeta->DeleteKey(MyHandle, SubKeyName); if (!SUCCEEDED(hRes)) return -604; } else return -601; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisSetDirSecurity(DWORD ServerInstance, char * VirtualPath, DWORD DirFlags) { HRESULT hRes = 0; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_WRITE, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld/ROOT%S", ServerInstance, VirtualPath); MyRecord.dwMDIdentifier = MD_AUTHORIZATION; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)&DirFlags; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->SetData(MyHandle, SubKeyName, &MyRecord))) return -509; } else return -501; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisGetDirSecurity(DWORD ServerInstance, char * VirtualPath, DWORD * DirFlags) { HRESULT hRes = 0; DWORD buffer = 0; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld/ROOT%S", ServerInstance, VirtualPath); MyRecord.dwMDIdentifier = MD_AUTHORIZATION; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)DirFlags; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->GetData(MyHandle, SubKeyName, &MyRecord, &buffer))) return -509; } else return -501; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisSetServerRight(DWORD ServerInstance, char * VirtualPath, DWORD ServerRights) { HRESULT hRes = 0; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_WRITE, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld/ROOT%S", ServerInstance, VirtualPath); MyRecord.dwMDIdentifier = MD_ACCESS_PERM; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)&ServerRights; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->SetData(MyHandle, SubKeyName, &MyRecord))) return -507; } else return -501; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisGetServerRight(DWORD ServerInstance, char * VirtualPath, DWORD * ServerRights) { HRESULT hRes = 0; DWORD buffer = 0; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld/ROOT%S", ServerInstance, VirtualPath); MyRecord.dwMDIdentifier = MD_ACCESS_PERM; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)ServerRights; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->GetData(MyHandle, SubKeyName, &MyRecord, &buffer))) return -507; } else return -501; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisSetServerStatus(DWORD ServerInstance, DWORD StartServer) { HRESULT hRes = 0; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_WRITE, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld", ServerInstance); MyRecord.dwMDIdentifier = MD_SERVER_COMMAND; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)&StartServer; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->SetData(MyHandle, SubKeyName, &MyRecord))) return -508; } else return -501; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisSetScriptMap(DWORD ServerInstance, char * VirtualPath, char * ScriptMap) { HRESULT hRes = 0; DWORD buffer = 0; DWORD dwBuffer = 65535; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; PBYTE pbBuffer = new BYTE[dwBuffer]; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; WCHAR NewData[65535]; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld/ROOT%S", ServerInstance, VirtualPath); MyRecord.dwMDIdentifier = MD_SCRIPT_MAPS; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = MULTISZ_METADATA; MyRecord.pbMDData = pbBuffer; MyRecord.dwMDDataLen = dwBuffer; hRes = pIMeta->GetData(MyHandle, SubKeyName, &MyRecord, &buffer); if (SUCCEEDED(hRes)) { pIMeta->ChangePermissions(MyHandle, 1000, METADATA_PERMISSION_WRITE); memset(NewData, 0, sizeof(NewData)); swprintf(NewData, L"%S", ScriptMap); memcpy(NewData + (wcslen(NewData) + 1), pbBuffer, MyRecord.dwMDDataLen); MyRecord.dwMDIdentifier = MD_SCRIPT_MAPS; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = MULTISZ_METADATA; MyRecord.pbMDData = (PBYTE)&NewData; MyRecord.dwMDDataLen += (wcslen(NewData) + 1) * sizeof(WCHAR) + sizeof(WCHAR); if(!SUCCEEDED(pIMeta->SetData(MyHandle, SubKeyName, &MyRecord))) return -509; } } else return -501; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisGetScriptMap(DWORD ServerInstance, char * VirtualPath, char * ScriptExtention, char * ReturnValue) { HRESULT hRes = 0; DWORD buffer = 0; DWORD dwBuffer = 65535; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; PBYTE pbBuffer = new BYTE[dwBuffer]; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; PBYTE temp; char extBuffer[256]; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName,L"/%ld/ROOT%S",ServerInstance,VirtualPath); MyRecord.dwMDIdentifier = MD_SCRIPT_MAPS; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = MULTISZ_METADATA; MyRecord.pbMDData = pbBuffer; MyRecord.dwMDDataLen = dwBuffer; hRes = pIMeta->GetData(MyHandle, SubKeyName, &MyRecord, &buffer); temp = pbBuffer; while (*temp) { memset(extBuffer, 0, sizeof(extBuffer)); sprintf(extBuffer, "%ls\n", temp); if (!strncmp(extBuffer, ScriptExtention, strlen(ScriptExtention))) strcpy(ReturnValue, extBuffer); temp += (wcslen((wchar_t *)temp) + 1) * sizeof(WCHAR); } } pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisSetAppSettings(DWORD ServerInstance, char * VirtualPath, char * AppName) { HRESULT hRes = 0; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; WCHAR TestKey[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; DWORD isolated = 0; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_WRITE, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld/ROOT%S", ServerInstance, VirtualPath); memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey, L"%S", AppName); MyRecord.dwMDIdentifier = MD_APP_FRIENDLY_NAME; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_WAM; MyRecord.dwMDDataType = STRING_METADATA; MyRecord.pbMDData = (PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR); hRes = pIMeta->SetData(MyHandle, SubKeyName, &MyRecord); memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey, L"/LM/W3SVC/%ld/ROOT%S", ServerInstance, VirtualPath); MyRecord.dwMDIdentifier = MD_APP_ROOT; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_WAM; MyRecord.dwMDDataType = STRING_METADATA; MyRecord.pbMDData = (PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR); hRes = pIMeta->SetData(MyHandle, SubKeyName, &MyRecord); memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey, L"%S", "{465E38DF-66E8-11D3-847C-006097B892CD}"); MyRecord.dwMDIdentifier = MD_APP_WAM_CLSID; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_WAM; MyRecord.dwMDDataType = STRING_METADATA; MyRecord.pbMDData = (PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR); hRes = pIMeta->SetData(MyHandle, SubKeyName, &MyRecord); MyRecord.dwMDIdentifier = MD_APP_ISOLATED; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_WAM; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData = (PBYTE)&isolated; MyRecord.dwMDDataLen = sizeof(DWORD); hRes = pIMeta->SetData(MyHandle, SubKeyName, &MyRecord); } pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnStopService(LPCTSTR ServiceId) { SC_HANDLE hnd,hsvc; SERVICE_STATUS ss; hnd = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); if (hnd) { hsvc = OpenService(hnd,ServiceId,SERVICE_STOP); if (hsvc) if (ControlService(hsvc,SERVICE_CONTROL_STOP,&ss)) return 1; else return -103; else return -102; } else return -101; } extern "C" IISFUNC_API int fnStartService(LPCTSTR ServiceId) { SC_HANDLE hnd,hsvc; hnd = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); if (hnd) { hsvc = OpenService(hnd,ServiceId,SERVICE_START); if (hsvc) if (StartService(hsvc,0, NULL)) return 1; else return -104; else return -102; } else return -101; } extern "C" IISFUNC_API int fnGetServiceState(LPCTSTR ServiceId) { SC_HANDLE hnd,hsvc; SERVICE_STATUS ss; hnd = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); if (hnd) { hsvc = OpenService(hnd,ServiceId,SERVICE_QUERY_STATUS); if (hsvc) if (QueryServiceStatus(hsvc,&ss)) return ss.dwCurrentState; else return -105; else return -102; } else return -101; } Index: php4/ext/iisfunc/iisfunc.dsp +++ php4/ext/iisfunc/iisfunc.dsp # Microsoft Developer Studio Project File - Name="iisfunc" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=iisfunc - Win32 Debug_TS !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "iisfunc.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "iisfunc.mak" CFG="iisfunc - Win32 Debug_TS" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "iisfunc - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "iisfunc - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "iisfunc - Win32 Release_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release_TS" # PROP BASE Intermediate_Dir "Release_TS" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "IISfunc_Release_TS" # PROP Intermediate_Dir "IISfunc_Release_TS" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IISFUNC_EXPORTS" /Yu"stdafx.h" /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "_WIN32" /D "NDEBUG" /D "IISFUNC_EXPORTS" /D "COMPILE_DL_IISFUNC" /D HAVE_IISFUNC=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D ZEND_DEBUG=0 /FD /c # SUBTRACT CPP /Fr /YX /Yc /Yu # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release_TS/php_imap.dll" /libpath:"..\..\Release_TS" !ELSEIF "$(CFG)" == "iisfunc - Win32 Debug_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug_TS" # PROP BASE Intermediate_Dir "Debug"_TS" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug_TS" # PROP Intermediate_Dir "Debug_TS" # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IISFUNC_EXPORTS" /Yu"stdafx.h" /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IISFUNC_EXPORTS" /Yu"stdafx.h" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 php.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\Debug_TS" !ENDIF # Begin Target # Name "iisfunc - Win32 Release_TS" # Name "iisfunc - Win32 Debug_TS" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\iisfunc.cpp # End Source File # Begin Source File SOURCE=.\setup.c !IF "$(CFG)" == "iisfunc - Win32 Release_TS" # SUBTRACT CPP /YX /Yc /Yu !ELSEIF "$(CFG)" == "iisfunc - Win32 Debug_TS" !ENDIF # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\iisfunc.h # End Source File # Begin Source File SOURCE=.\setup.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\errors.txt # End Source File # End Target # End Project Index: php4/ext/iisfunc/iisfunc.h +++ php4/ext/iisfunc/iisfunc.h /* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Frank M. Kromann <fmk@swwwing.com> | +----------------------------------------------------------------------+ */ /* $Id: iisfunc.h,v 1.1 2000/10/22 23:06:05 fmk Exp $ */ #include <iiscnfg.h> // MD_ & IIS_MD_ #defines #ifdef __cplusplus extern "C" { #endif #ifdef IISFUNC_EXPORTS #define IISFUNC_API __declspec(dllexport) #else #define IISFUNC_API __declspec(dllimport) #endif extern "C" IISFUNC_API int fnIisGetServerByPath(char * ServerPath); extern "C" IISFUNC_API int fnIisGetServerByComment(char * ServerComment); extern "C" IISFUNC_API int fnIisAddServer(char * ServerPath, char * ServerComment, char * ServerIp, char * ServerPort, char * ServerHost, DWORD ServerRights, DWORD StartServer); extern "C" IISFUNC_API int fnIisSetServerRight(DWORD ServerInstance, char * VirtualPath, DWORD ServerRights); extern "C" IISFUNC_API int fnIisSetDirSecurity(DWORD ServerInstance, char * VirtualPath, DWORD DirFlags); extern "C" IISFUNC_API int fnStopService(LPCTSTR ServiceId); extern "C" IISFUNC_API int fnStartService(LPCTSTR ServiceId); extern "C" IISFUNC_API int fnGetServiceState(LPCTSTR ServiceId); #ifdef __cplusplus } #endif Index: php4/ext/iisfunc/setup.c +++ php4/ext/iisfunc/setup.c /* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Frank M. Kromann <fmk@swwwing.com> | +----------------------------------------------------------------------+ */ /* $Id: setup.c,v 1.1 2000/10/22 23:06:05 fmk Exp $ */ #ifdef COMPILE_DL_IISFUNC #define HAVE_IISFUNC 1 #endif #include "php.h" #include "php_globals.h" #include "ext/standard/info.h" #include "setup.h" #if HAVE_IISFUNC function_entry iisfunc_functions[] = { PHP_FE(iis_getserverbypath, NULL) PHP_FE(iis_getserverbycomment, NULL) PHP_FE(iis_addserver, NULL) PHP_FE(iis_removeserver, NULL) PHP_FE(iis_setdirsecurity, NULL) PHP_FE(iis_getdirsecurity, NULL) PHP_FE(iis_setserverright, NULL) PHP_FE(iis_getserverright, NULL) PHP_FE(iis_startserver, NULL) PHP_FE(iis_stopserver, NULL) PHP_FE(iis_setscriptmap, NULL) PHP_FE(iis_getscriptmap, NULL) PHP_FE(iis_setappsettings, NULL) PHP_FE(iis_stopservice, NULL) PHP_FE(iis_startservice, NULL) PHP_FE(iis_getservicestate, NULL) {NULL, NULL, NULL} }; zend_module_entry iisfunc_module_entry = { "iisfunc", iisfunc_functions, PHP_MINIT(iisfunc), PHP_MSHUTDOWN(iisfunc), PHP_RINIT(iisfunc), PHP_RSHUTDOWN(iisfunc), PHP_MINFO(iisfunc), STANDARD_MODULE_PROPERTIES }; #ifdef COMPILE_DL_IISFUNC ZEND_GET_MODULE(iisfunc) #endif PHP_MINIT_FUNCTION(iisfunc) { REGISTER_LONG_CONSTANT("IIS_READ", 0x1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IIS_WRITE", 0x2, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IIS_EXECUTE", 0x4, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IIS_SCRIPT", 0x200, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IIS_ANONYMOUS", 0x1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IIS_BASIC", 0x2, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IIS_NTLM", 0x4, CONST_CS | CONST_PERSISTENT); return SUCCESS; } PHP_MSHUTDOWN_FUNCTION(iisfunc) { return SUCCESS; } PHP_RINIT_FUNCTION(iisfunc) { return SUCCESS; } PHP_RSHUTDOWN_FUNCTION(iisfunc) { return SUCCESS; } PHP_MINFO_FUNCTION(iisfunc) { php_info_print_table_start(); php_info_print_table_header(2, "IIS Admin Functions support", "enabled"); php_info_print_table_end(); } /* {{{ proto int iis_GetServerByPath(string Path) Return the instance number associated with the Path*/ PHP_FUNCTION(iis_getserverbypath) { pval *ServerPath; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServerPath) == FAILURE) WRONG_PARAM_COUNT; convert_to_string(ServerPath); rc = fnIisGetServerByPath(ServerPath->value.str.val); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_GetServerByComment(string Comment) Return the instance number associated with the Comment*/ PHP_FUNCTION(iis_getserverbycomment) { pval *ServerComment; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServerComment) == FAILURE) WRONG_PARAM_COUNT; convert_to_string(ServerComment); rc = fnIisGetServerByComment(ServerComment->value.str.val); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_AddServer(string Path, string Comment, string ServerIP, int ServerPort, string HostName, int ServerRights, int StartServer) Creates a new virtual web server*/ PHP_FUNCTION(iis_addserver) { pval *ServerPath, *ServerComment, *ServerIp, *ServerPort, *ServerHost, *ServerRights, *StartServer; int argc, rc; argc = ARG_COUNT(ht); if (argc != 7 || getParameters(ht, argc, &ServerPath, &ServerComment, &ServerIp, &ServerPort, &ServerHost, &ServerRights, &StartServer) == FAILURE) WRONG_PARAM_COUNT; convert_to_string(ServerPath); convert_to_string(ServerComment); convert_to_string(ServerIp); convert_to_string(ServerPort); convert_to_string(ServerHost); convert_to_long(ServerRights); convert_to_long(StartServer); rc = fnIisAddServer(ServerPath->value.str.val, ServerComment->value.str.val, ServerIp->value.str.val, ServerPort->value.str.val, ServerHost->value.str.val, ServerRights->value.lval, StartServer->value.lval); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_RemoveServer(int ServerInstance) Removes the virtual web server indicated by ServerInstance*/ PHP_FUNCTION(iis_removeserver) { pval *ServerInstance; int argc, rc; argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServerInstance) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); rc = fnIisRemoveServer(ServerInstance->value.lval); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_SetDirectorySecurity(int ServerInstance, string VirtualPath, int DirectoryFlags) Sets Directory Security*/ PHP_FUNCTION(iis_setdirsecurity) { pval *ServerInstance, *VirtualPath, *DirFlags; int argc, rc; argc = ARG_COUNT(ht); if (argc != 3 || getParameters(ht, argc, &ServerInstance, &VirtualPath, &DirFlags) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); convert_to_long(DirFlags); rc = fnIisSetDirSecurity(ServerInstance->value.lval, VirtualPath->value.str.val, DirFlags->value.lval); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_DirectorySecurity(int ServerInstance, string VirtualPath) Gets Directory Security*/ PHP_FUNCTION(iis_getdirsecurity) { pval *ServerInstance, *VirtualPath; int argc, rc; DWORD DirFlags = 0; argc = ARG_COUNT(ht); if (argc != 2 || getParameters(ht, argc, &ServerInstance, &VirtualPath) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); rc = fnIisGetDirSecurity(ServerInstance->value.lval, VirtualPath->value.str.val, &DirFlags); if (rc) { RETVAL_LONG(DirFlags); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_SetServerRights(int ServerInstance, string VirtualPath, int ServerFlags) Sets server rights*/ PHP_FUNCTION(iis_setserverright) { pval *ServerInstance, *VirtualPath, *ServerFlags; int argc, rc; argc = ARG_COUNT(ht); if (argc != 3 || getParameters(ht, argc, &ServerInstance, &VirtualPath, &ServerFlags) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); convert_to_long(ServerFlags); rc = fnIisSetServerRight(ServerInstance->value.lval, VirtualPath->value.str.val, ServerFlags->value.lval); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_GetServerRights(int ServerInstance, string VirtualPath) Gets Directory Security*/ PHP_FUNCTION(iis_getserverright) { pval *ServerInstance, *VirtualPath; int argc, rc; DWORD DirFlags = 0; argc = ARG_COUNT(ht); if (argc != 2 || getParameters(ht, argc, &ServerInstance, &VirtualPath) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); rc = fnIisGetServerRight(ServerInstance->value.lval, VirtualPath->value.str.val, &DirFlags); if (rc) { RETVAL_LONG(DirFlags); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_SetScriptMap(int ServerInstance, string VirtualPath, string EnginePath, int AllowScripting) Sets script mapping on a virtual directory*/ PHP_FUNCTION(iis_setscriptmap) { pval *ServerInstance, *VirtualPath, *ScriptExtention, *EnginePath, *Scripting; int argc, rc; char ScriptingValue[256]; argc = ARG_COUNT(ht); if (argc != 5 || getParameters(ht, argc, &ServerInstance, &VirtualPath, &ScriptExtention, &EnginePath, &Scripting) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); convert_to_string(ScriptExtention); convert_to_string(EnginePath); convert_to_long(Scripting); sprintf(ScriptingValue, "%s,%s,%li", ScriptExtention->value.str.val, EnginePath->value.str.val, Scripting->value.lval); rc = fnIisSetScriptMap(ServerInstance->value.lval, VirtualPath->value.str.val, ScriptingValue); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_GetScriptMap(int ServerInstance, string VirtualPath) Gets script mapping on a virtual directory for a specific extention*/ PHP_FUNCTION(iis_getscriptmap) { pval *ServerInstance, *VirtualPath, *ScriptExtention; int argc, rc; DWORD DirFlags = 0; char *strSetting = emalloc(512); memset(strSetting, 0, 512); argc = ARG_COUNT(ht); if (argc != 3 || getParameters(ht, argc, &ServerInstance, &VirtualPath, &ScriptExtention) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); convert_to_string(ScriptExtention); rc = fnIisGetScriptMap(ServerInstance->value.lval, VirtualPath->value.str.val, ScriptExtention->value.str.val, strSetting); if (rc == 1 && strlen(strSetting)) { RETVAL_STRING(strSetting, 1); } else { RETVAL_STRING("", 1); } efree(strSetting); } /* }}} */ /* {{{ proto int iis_SetAppSetings(int ServerInstance, string VirtualPath, string Name) Creates application scope for a virtual directory*/ PHP_FUNCTION(iis_setappsettings) { pval *ServerInstance, *VirtualPath, *Name; int argc, rc; argc = ARG_COUNT(ht); if (argc != 3 || getParameters(ht, argc, &ServerInstance, &VirtualPath, &Name) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); convert_to_string(Name); rc = fnIisSetAppSettings(ServerInstance->value.lval, VirtualPath->value.str.val, Name->value.str.val); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_StartServer(int ServerInstance) Starts the virtual web server*/ PHP_FUNCTION(iis_startserver) { pval *ServerInstance; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServerInstance) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); rc = fnIisSetServerStatus(ServerInstance->value.lval, 1); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_StopServer(int ServerInstance) Stops the virtual web server*/ PHP_FUNCTION(iis_stopserver) { pval *ServerInstance; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServerInstance) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); rc = fnIisSetServerStatus(ServerInstance->value.lval, 0); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_StopService(string ServiceId) Stops the service defined by ServiceId*/ PHP_FUNCTION(iis_stopservice) { pval *ServiceId; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServiceId) == FAILURE) WRONG_PARAM_COUNT; convert_to_string(ServiceId); rc = fnStopService(ServiceId->value.str.val); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_StartService(string ServiceId) Starts the service defined by ServiceId*/ PHP_FUNCTION(iis_startservice) { pval *ServiceId; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServiceId) == FAILURE) WRONG_PARAM_COUNT; convert_to_string(ServiceId); rc = fnStartService(ServiceId->value.str.val); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_GetServiceState(string ServiceId) Returns teh state for the service defined by ServiceId*/ PHP_FUNCTION(iis_getservicestate) { pval *ServiceId; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServiceId) == FAILURE) WRONG_PARAM_COUNT; convert_to_string(ServiceId); rc = fnGetServiceState(ServiceId->value.str.val); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ #endif Index: php4/ext/iisfunc/setup.h +++ php4/ext/iisfunc/setup.h /* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Frank M. Kromann <fmk@swwwing.com> | +----------------------------------------------------------------------+ */ /* $Id: setup.h,v 1.1 2000/10/22 23:06:05 fmk Exp $ */ #ifndef PHP_IIS_SETUP_H #define PHP_IIS_SETUP_H #if HAVE_IISFUNC #ifdef PHP_WIN32 #define PHP_IISFUNC_API __declspec(dllexport) #else #define PHP_IISFUNC_API #endif #ifdef __ZTS #include "TSRM.h" #endif extern zend_module_entry iisfunc_module_entry; #define iisfunc_module_ptr &iisfunc_module_entry extern PHP_MINIT_FUNCTION(iisfunc); extern PHP_MSHUTDOWN_FUNCTION(iisfunc); extern PHP_RINIT_FUNCTION(iisfunc); extern PHP_RSHUTDOWN_FUNCTION(iisfunc); PHP_MINFO_FUNCTION(iisfunc); PHP_FUNCTION(iis_getserverbypath); PHP_FUNCTION(iis_getserverbycomment); PHP_FUNCTION(iis_addserver); PHP_FUNCTION(iis_removeserver); PHP_FUNCTION(iis_setdirsecurity); PHP_FUNCTION(iis_getdirsecurity); PHP_FUNCTION(iis_setserverright); PHP_FUNCTION(iis_getserverright); PHP_FUNCTION(iis_startserver); PHP_FUNCTION(iis_stopserver); PHP_FUNCTION(iis_setscriptmap); PHP_FUNCTION(iis_getscriptmap); PHP_FUNCTION(iis_setappsettings); PHP_FUNCTION(iis_stopservice); PHP_FUNCTION(iis_startservice); PHP_FUNCTION(iis_getservicestate); int fnIisGetServerByPath(char * ServerPath); int fnIisGetServerByComment(char * ServerComment); int fnIisAddServer(char * ServerPath, char * ServerComment, char * ServerIp, char * ServerPort, char * ServerHost, DWORD ServerRights, DWORD StartServer); int fnIisRemoveServer(DWORD ServerInstance); int fnIisSetDirSecurity(DWORD ServerInstance, char * VirtualPath, DWORD DirFlags); int fnIisGetDirSecurity(DWORD ServerInstance, char * VirtualPath, DWORD * DirFlags); int fnIisSetServerRight(DWORD ServerInstance, char * VirtualPath, DWORD ServerRights); int fnIisGetServerRight(DWORD ServerInstance, char * VirtualPath, DWORD * ServerRights); int fnIisSetServerStatus(DWORD ServerInstance, DWORD StartServer); int fnIisSetScriptMap(DWORD ServerInstance, char * VirtualPath, char * ScriptMap); int fnIisGetScriptMap(DWORD ServerInstance, char * VirtualPath, char * SeciptExtention, char * ReturnValue); int fnIisSetAppSettings(DWORD ServerInstance, char * VirtualPath, char * AppName); int fnStopService(LPSTR ServiceId); int fnStartService(LPTSTR ServiceId); int fnGetServiceState(LPTSTR ServiceId); #else #define iisfunc_module_ptr NULL #endif /* HAVE_IISFUNC */ #define phpext_iisfunc_ptr iisfunc_module_ptr #endif
Index: php4/ext/iisfunc/.cvsignore +++ php4/ext/iisfunc/.cvsignore Makefile *.lo *.la libs *.plg Release Release_TS Debug Debug_TS Makefile.am deps libs.mk Index: php4/ext/iisfunc/errors.txt +++ php4/ext/iisfunc/errors.txt Errors number is IISFUNC: -101: Problem with OpenSCManager. -102: Problem with OpenService. -103: Problem with Stop Service. -104: Problem with Start Service. -105: Problem with Get Service State. -501: Can't open Web Service! -502: Can't add new key! -503: Can't configure key to WebServer! -504: Can't configure Server Comment! -505: Can't configure Server Bindings! -506: Can't configure web server to path! -507: Can't set rights on web server! -508: Can't start web server! -509: Can't set dir security on web server! Index: php4/ext/iisfunc/iisfunc.cpp +++ php4/ext/iisfunc/iisfunc.cpp /* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Frank M. Kromann <fmk@swwwing.com> | +----------------------------------------------------------------------+ */ /* $Id: iisfunc.cpp,v 1.1 2000/10/22 23:06:05 fmk Exp $ */ /* iisfunc.cpp : Defines the entry point for the DLL application. */ #define UNICODE #define INITGUID #include <windows.h> #include <stdio.h> #define _ATL_DLL_IMPL #include <ks.h> #include <atlbase.h> // ATL support #include <iadmw.h> // COM Interface header #include "iisfunc.h" extern "C" IISFUNC_API int fnIisGetServerByPath(char * ServerPath) { HRESULT hRes = 0, hResSub = 0; DWORD buffer = 0; DWORD dwBuffer = 65535; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; PBYTE pbBuffer = new BYTE[dwBuffer]; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; WCHAR KeyName[METADATA_MAX_NAME_LEN]; WCHAR TestKey[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; DWORD indx = 0; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); while (SUCCEEDED(hRes)){ hRes = pIMeta->EnumKeys(MyHandle, L"/", SubKeyName, indx); if (SUCCEEDED(hRes)) { MyRecord.dwMDIdentifier = MD_VR_PATH; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = ALL_METADATA; MyRecord.dwMDDataLen = dwBuffer; MyRecord.pbMDData = pbBuffer; swprintf(KeyName, L"/%s/ROOT", SubKeyName); hResSub = pIMeta->GetData(MyHandle, KeyName, &MyRecord, &buffer); if (SUCCEEDED(hResSub)) { memset(KeyName , 0, sizeof(KeyName)); swprintf(KeyName, L"%s", MyRecord.pbMDData); memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey, L"%S", ServerPath); if (wcscmp(_wcsupr(KeyName),_wcsupr(TestKey))==0) return wcstol(SubKeyName,NULL,10); } } indx++; } pIMeta->CloseKey(MyHandle); return 0; } extern "C" IISFUNC_API int fnIisGetServerByComment(char * ServerComment) { HRESULT hRes = 0, hResSub = 0; DWORD buffer = 0; DWORD dwBuffer = 65535; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; PBYTE pbBuffer = new BYTE[dwBuffer]; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; WCHAR KeyName[METADATA_MAX_NAME_LEN]; WCHAR TestKey[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; DWORD indx = 0; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); while (SUCCEEDED(hRes)){ hRes = pIMeta->EnumKeys(MyHandle, L"/", SubKeyName, indx); if (SUCCEEDED(hRes)) { MyRecord.dwMDIdentifier = MD_SERVER_COMMENT; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = ALL_METADATA; MyRecord.dwMDDataLen = dwBuffer; MyRecord.pbMDData = pbBuffer; swprintf(KeyName, L"/%s/ROOT", SubKeyName); hResSub = pIMeta->GetData(MyHandle, KeyName, &MyRecord, &buffer); if (SUCCEEDED(hResSub)) { memset(KeyName , 0, sizeof(KeyName)); swprintf(KeyName, L"%s", MyRecord.pbMDData); memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey, L"%S", ServerComment); if (wcscmp(_wcsupr(KeyName),_wcsupr(TestKey))==0) return wcstol(SubKeyName,NULL,10); } } indx++; } pIMeta->CloseKey(MyHandle); return 0; } extern "C" IISFUNC_API int fnIisAddServer(char * ServerPath, char * ServerComment, char * ServerIp, char * ServerPort, char * ServerHost, DWORD ServerRights, DWORD StartServer) { HRESULT hRes = 0; DWORD dwBuffer = 65535; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; PBYTE pbBuffer = new BYTE[dwBuffer]; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; WCHAR KeyName[METADATA_MAX_NAME_LEN]; WCHAR TestKey[METADATA_MAX_NAME_LEN]; DWORD ServerInstance; CComPtr <IMSAdminBase> pIMeta; DWORD indx = 0; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; swprintf(TestKey,L"1"); hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); while (SUCCEEDED(hRes)){ hRes = pIMeta->EnumKeys(MyHandle, L"/", SubKeyName, indx); if (SUCCEEDED(hRes)) if (wcstol(SubKeyName,NULL,10)>wcstol(TestKey,NULL,10)) { memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey,L"%ld",wcstol(SubKeyName,NULL,10)); } indx++; } pIMeta->CloseKey(MyHandle); ServerInstance = wcstol(TestKey,NULL,10)+1; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_WRITE, 20, &MyHandle); if (SUCCEEDED(hRes)) { swprintf(SubKeyName,L"/%ld/ROOT",ServerInstance); hRes = pIMeta->AddKey(MyHandle, SubKeyName); if (SUCCEEDED(hRes)) { memset(KeyName , 0, sizeof(KeyName)); swprintf(KeyName, L"/%ld", ServerInstance); memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey,L"IIsWebServer"); MyRecord.dwMDIdentifier = MD_KEY_TYPE; MyRecord.dwMDAttributes = METADATA_INSERT_PATH; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = STRING_METADATA; MyRecord.pbMDData=(PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR); if(!SUCCEEDED(pIMeta->SetData(MyHandle, KeyName, &MyRecord))) return -503; memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey,L"%S",ServerComment); MyRecord.dwMDIdentifier = MD_SERVER_COMMENT; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = STRING_METADATA; MyRecord.pbMDData=(PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR); if(!SUCCEEDED(pIMeta->SetData(MyHandle, KeyName, &MyRecord))) return -504; memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey,L"%S:%S:%S",ServerIp,ServerPort,ServerHost); MyRecord.dwMDIdentifier = MD_SERVER_BINDINGS; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = MULTISZ_METADATA; MyRecord.pbMDData=(PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR) + 1 * sizeof(WCHAR); if(!SUCCEEDED(pIMeta->SetData(MyHandle, KeyName, &MyRecord))) return -505; memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey,L"%S", ServerPath); MyRecord.dwMDIdentifier = MD_VR_PATH; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = STRING_METADATA; MyRecord.pbMDData=(PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR); if(!SUCCEEDED(pIMeta->SetData(MyHandle, SubKeyName, &MyRecord))) return -506; MyRecord.dwMDIdentifier = MD_ACCESS_PERM; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)&ServerRights; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->SetData(MyHandle, KeyName, &MyRecord))) return -507; MyRecord.dwMDIdentifier = MD_SERVER_COMMAND; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)&StartServer; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->SetData(MyHandle, KeyName, &MyRecord))) return -508; } else return -502; } else return -501; pIMeta->CloseKey(MyHandle); return ServerInstance; } extern "C" IISFUNC_API int fnIisRemoveServer(DWORD ServerInstance) { HRESULT hRes = 0; DWORD dwBuffer = 65535; METADATA_HANDLE MyHandle; PBYTE pbBuffer = new BYTE[dwBuffer]; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_WRITE, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld", ServerInstance); hRes = pIMeta->DeleteChildKeys(MyHandle, SubKeyName); if (!SUCCEEDED(hRes)) return -602; hRes = pIMeta->DeleteAllData(MyHandle, SubKeyName, ALL_METADATA, ALL_METADATA); if (!SUCCEEDED(hRes)) return -603; hRes = pIMeta->DeleteKey(MyHandle, SubKeyName); if (!SUCCEEDED(hRes)) return -604; } else return -601; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisSetDirSecurity(DWORD ServerInstance, char * VirtualPath, DWORD DirFlags) { HRESULT hRes = 0; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_WRITE, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld/ROOT%S", ServerInstance, VirtualPath); MyRecord.dwMDIdentifier = MD_AUTHORIZATION; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)&DirFlags; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->SetData(MyHandle, SubKeyName, &MyRecord))) return -509; } else return -501; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisGetDirSecurity(DWORD ServerInstance, char * VirtualPath, DWORD * DirFlags) { HRESULT hRes = 0; DWORD buffer = 0; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld/ROOT%S", ServerInstance, VirtualPath); MyRecord.dwMDIdentifier = MD_AUTHORIZATION; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)DirFlags; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->GetData(MyHandle, SubKeyName, &MyRecord, &buffer))) return -509; } else return -501; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisSetServerRight(DWORD ServerInstance, char * VirtualPath, DWORD ServerRights) { HRESULT hRes = 0; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_WRITE, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld/ROOT%S", ServerInstance, VirtualPath); MyRecord.dwMDIdentifier = MD_ACCESS_PERM; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)&ServerRights; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->SetData(MyHandle, SubKeyName, &MyRecord))) return -507; } else return -501; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisGetServerRight(DWORD ServerInstance, char * VirtualPath, DWORD * ServerRights) { HRESULT hRes = 0; DWORD buffer = 0; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld/ROOT%S", ServerInstance, VirtualPath); MyRecord.dwMDIdentifier = MD_ACCESS_PERM; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)ServerRights; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->GetData(MyHandle, SubKeyName, &MyRecord, &buffer))) return -507; } else return -501; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisSetServerStatus(DWORD ServerInstance, DWORD StartServer) { HRESULT hRes = 0; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_WRITE, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld", ServerInstance); MyRecord.dwMDIdentifier = MD_SERVER_COMMAND; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_SERVER; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData=(PBYTE)&StartServer; MyRecord.dwMDDataLen = sizeof(DWORD); if(!SUCCEEDED(pIMeta->SetData(MyHandle, SubKeyName, &MyRecord))) return -508; } else return -501; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisSetScriptMap(DWORD ServerInstance, char * VirtualPath, char * ScriptMap) { HRESULT hRes = 0; DWORD buffer = 0; DWORD dwBuffer = 65535; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; PBYTE pbBuffer = new BYTE[dwBuffer]; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; WCHAR NewData[65535]; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld/ROOT%S", ServerInstance, VirtualPath); MyRecord.dwMDIdentifier = MD_SCRIPT_MAPS; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = MULTISZ_METADATA; MyRecord.pbMDData = pbBuffer; MyRecord.dwMDDataLen = dwBuffer; hRes = pIMeta->GetData(MyHandle, SubKeyName, &MyRecord, &buffer); if (SUCCEEDED(hRes)) { pIMeta->ChangePermissions(MyHandle, 1000, METADATA_PERMISSION_WRITE); memset(NewData, 0, sizeof(NewData)); swprintf(NewData, L"%S", ScriptMap); memcpy(NewData + (wcslen(NewData) + 1), pbBuffer, MyRecord.dwMDDataLen); MyRecord.dwMDIdentifier = MD_SCRIPT_MAPS; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = MULTISZ_METADATA; MyRecord.pbMDData = (PBYTE)&NewData; MyRecord.dwMDDataLen += (wcslen(NewData) + 1) * sizeof(WCHAR) + sizeof(WCHAR); if(!SUCCEEDED(pIMeta->SetData(MyHandle, SubKeyName, &MyRecord))) return -509; } } else return -501; pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisGetScriptMap(DWORD ServerInstance, char * VirtualPath, char * ScriptExtention, char * ReturnValue) { HRESULT hRes = 0; DWORD buffer = 0; DWORD dwBuffer = 65535; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; PBYTE pbBuffer = new BYTE[dwBuffer]; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; PBYTE temp; char extBuffer[256]; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_READ, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName,L"/%ld/ROOT%S",ServerInstance,VirtualPath); MyRecord.dwMDIdentifier = MD_SCRIPT_MAPS; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_FILE; MyRecord.dwMDDataType = MULTISZ_METADATA; MyRecord.pbMDData = pbBuffer; MyRecord.dwMDDataLen = dwBuffer; hRes = pIMeta->GetData(MyHandle, SubKeyName, &MyRecord, &buffer); temp = pbBuffer; while (*temp) { memset(extBuffer, 0, sizeof(extBuffer)); sprintf(extBuffer, "%ls\n", temp); if (!strncmp(extBuffer, ScriptExtention, strlen(ScriptExtention))) strcpy(ReturnValue, extBuffer); temp += (wcslen((wchar_t *)temp) + 1) * sizeof(WCHAR); } } pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnIisSetAppSettings(DWORD ServerInstance, char * VirtualPath, char * AppName) { HRESULT hRes = 0; METADATA_HANDLE MyHandle; METADATA_RECORD MyRecord; WCHAR SubKeyName[METADATA_MAX_NAME_LEN]; WCHAR TestKey[METADATA_MAX_NAME_LEN]; CComPtr <IMSAdminBase> pIMeta; DWORD isolated = 0; CoInitialize(NULL); hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL, IID_IMSAdminBase, (void **) &pIMeta); if (FAILED(hRes)) return hRes; hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, L"/LM/W3SVC", METADATA_PERMISSION_WRITE, 20, &MyHandle); if (SUCCEEDED(hRes)) { memset(SubKeyName , 0, sizeof(SubKeyName)); swprintf(SubKeyName, L"/%ld/ROOT%S", ServerInstance, VirtualPath); memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey, L"%S", AppName); MyRecord.dwMDIdentifier = MD_APP_FRIENDLY_NAME; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_WAM; MyRecord.dwMDDataType = STRING_METADATA; MyRecord.pbMDData = (PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR); hRes = pIMeta->SetData(MyHandle, SubKeyName, &MyRecord); memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey, L"/LM/W3SVC/%ld/ROOT%S", ServerInstance, VirtualPath); MyRecord.dwMDIdentifier = MD_APP_ROOT; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_WAM; MyRecord.dwMDDataType = STRING_METADATA; MyRecord.pbMDData = (PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR); hRes = pIMeta->SetData(MyHandle, SubKeyName, &MyRecord); memset(TestKey , 0, sizeof(TestKey)); swprintf(TestKey, L"%S", "{465E38DF-66E8-11D3-847C-006097B892CD}"); MyRecord.dwMDIdentifier = MD_APP_WAM_CLSID; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_WAM; MyRecord.dwMDDataType = STRING_METADATA; MyRecord.pbMDData = (PBYTE)&TestKey; MyRecord.dwMDDataLen = (wcslen(TestKey) + 1) * sizeof(WCHAR); hRes = pIMeta->SetData(MyHandle, SubKeyName, &MyRecord); MyRecord.dwMDIdentifier = MD_APP_ISOLATED; MyRecord.dwMDAttributes = METADATA_INHERIT; MyRecord.dwMDUserType = IIS_MD_UT_WAM; MyRecord.dwMDDataType = DWORD_METADATA; MyRecord.pbMDData = (PBYTE)&isolated; MyRecord.dwMDDataLen = sizeof(DWORD); hRes = pIMeta->SetData(MyHandle, SubKeyName, &MyRecord); } pIMeta->CloseKey(MyHandle); return 1; } extern "C" IISFUNC_API int fnStopService(LPCTSTR ServiceId) { SC_HANDLE hnd,hsvc; SERVICE_STATUS ss; hnd = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); if (hnd) { hsvc = OpenService(hnd,ServiceId,SERVICE_STOP); if (hsvc) if (ControlService(hsvc,SERVICE_CONTROL_STOP,&ss)) return 1; else return -103; else return -102; } else return -101; } extern "C" IISFUNC_API int fnStartService(LPCTSTR ServiceId) { SC_HANDLE hnd,hsvc; hnd = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); if (hnd) { hsvc = OpenService(hnd,ServiceId,SERVICE_START); if (hsvc) if (StartService(hsvc,0, NULL)) return 1; else return -104; else return -102; } else return -101; } extern "C" IISFUNC_API int fnGetServiceState(LPCTSTR ServiceId) { SC_HANDLE hnd,hsvc; SERVICE_STATUS ss; hnd = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); if (hnd) { hsvc = OpenService(hnd,ServiceId,SERVICE_QUERY_STATUS); if (hsvc) if (QueryServiceStatus(hsvc,&ss)) return ss.dwCurrentState; else return -105; else return -102; } else return -101; } Index: php4/ext/iisfunc/iisfunc.dsp +++ php4/ext/iisfunc/iisfunc.dsp # Microsoft Developer Studio Project File - Name="iisfunc" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=iisfunc - Win32 Debug_TS !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "iisfunc.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "iisfunc.mak" CFG="iisfunc - Win32 Debug_TS" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "iisfunc - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "iisfunc - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "iisfunc - Win32 Release_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release_TS" # PROP BASE Intermediate_Dir "Release_TS" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "IISfunc_Release_TS" # PROP Intermediate_Dir "IISfunc_Release_TS" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IISFUNC_EXPORTS" /Yu"stdafx.h" /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "_WIN32" /D "NDEBUG" /D "IISFUNC_EXPORTS" /D "COMPILE_DL_IISFUNC" /D HAVE_IISFUNC=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D ZEND_DEBUG=0 /FD /c # SUBTRACT CPP /Fr /YX /Yc /Yu # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"Release_TS/php_imap.dll" /libpath:"..\..\Release_TS" !ELSEIF "$(CFG)" == "iisfunc - Win32 Debug_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug_TS" # PROP BASE Intermediate_Dir "Debug"_TS" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug_TS" # PROP Intermediate_Dir "Debug_TS" # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IISFUNC_EXPORTS" /Yu"stdafx.h" /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IISFUNC_EXPORTS" /Yu"stdafx.h" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 php.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\Debug_TS" !ENDIF # Begin Target # Name "iisfunc - Win32 Release_TS" # Name "iisfunc - Win32 Debug_TS" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\iisfunc.cpp # End Source File # Begin Source File SOURCE=.\setup.c !IF "$(CFG)" == "iisfunc - Win32 Release_TS" # SUBTRACT CPP /YX /Yc /Yu !ELSEIF "$(CFG)" == "iisfunc - Win32 Debug_TS" !ENDIF # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\iisfunc.h # End Source File # Begin Source File SOURCE=.\setup.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # Begin Source File SOURCE=.\errors.txt # End Source File # End Target # End Project Index: php4/ext/iisfunc/iisfunc.h +++ php4/ext/iisfunc/iisfunc.h /* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Frank M. Kromann <fmk@swwwing.com> | +----------------------------------------------------------------------+ */ /* $Id: iisfunc.h,v 1.1 2000/10/22 23:06:05 fmk Exp $ */ #include <iiscnfg.h> // MD_ & IIS_MD_ #defines #ifdef __cplusplus extern "C" { #endif #ifdef IISFUNC_EXPORTS #define IISFUNC_API __declspec(dllexport) #else #define IISFUNC_API __declspec(dllimport) #endif extern "C" IISFUNC_API int fnIisGetServerByPath(char * ServerPath); extern "C" IISFUNC_API int fnIisGetServerByComment(char * ServerComment); extern "C" IISFUNC_API int fnIisAddServer(char * ServerPath, char * ServerComment, char * ServerIp, char * ServerPort, char * ServerHost, DWORD ServerRights, DWORD StartServer); extern "C" IISFUNC_API int fnIisSetServerRight(DWORD ServerInstance, char * VirtualPath, DWORD ServerRights); extern "C" IISFUNC_API int fnIisSetDirSecurity(DWORD ServerInstance, char * VirtualPath, DWORD DirFlags); extern "C" IISFUNC_API int fnStopService(LPCTSTR ServiceId); extern "C" IISFUNC_API int fnStartService(LPCTSTR ServiceId); extern "C" IISFUNC_API int fnGetServiceState(LPCTSTR ServiceId); #ifdef __cplusplus } #endif Index: php4/ext/iisfunc/setup.c +++ php4/ext/iisfunc/setup.c /* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Frank M. Kromann <fmk@swwwing.com> | +----------------------------------------------------------------------+ */ /* $Id: setup.c,v 1.1 2000/10/22 23:06:05 fmk Exp $ */ #ifdef COMPILE_DL_IISFUNC #define HAVE_IISFUNC 1 #endif #include "php.h" #include "php_globals.h" #include "ext/standard/info.h" #include "setup.h" #if HAVE_IISFUNC function_entry iisfunc_functions[] = { PHP_FE(iis_getserverbypath, NULL) PHP_FE(iis_getserverbycomment, NULL) PHP_FE(iis_addserver, NULL) PHP_FE(iis_removeserver, NULL) PHP_FE(iis_setdirsecurity, NULL) PHP_FE(iis_getdirsecurity, NULL) PHP_FE(iis_setserverright, NULL) PHP_FE(iis_getserverright, NULL) PHP_FE(iis_startserver, NULL) PHP_FE(iis_stopserver, NULL) PHP_FE(iis_setscriptmap, NULL) PHP_FE(iis_getscriptmap, NULL) PHP_FE(iis_setappsettings, NULL) PHP_FE(iis_stopservice, NULL) PHP_FE(iis_startservice, NULL) PHP_FE(iis_getservicestate, NULL) {NULL, NULL, NULL} }; zend_module_entry iisfunc_module_entry = { "iisfunc", iisfunc_functions, PHP_MINIT(iisfunc), PHP_MSHUTDOWN(iisfunc), PHP_RINIT(iisfunc), PHP_RSHUTDOWN(iisfunc), PHP_MINFO(iisfunc), STANDARD_MODULE_PROPERTIES }; #ifdef COMPILE_DL_IISFUNC ZEND_GET_MODULE(iisfunc) #endif PHP_MINIT_FUNCTION(iisfunc) { REGISTER_LONG_CONSTANT("IIS_READ", 0x1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IIS_WRITE", 0x2, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IIS_EXECUTE", 0x4, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IIS_SCRIPT", 0x200, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IIS_ANONYMOUS", 0x1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IIS_BASIC", 0x2, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("IIS_NTLM", 0x4, CONST_CS | CONST_PERSISTENT); return SUCCESS; } PHP_MSHUTDOWN_FUNCTION(iisfunc) { return SUCCESS; } PHP_RINIT_FUNCTION(iisfunc) { return SUCCESS; } PHP_RSHUTDOWN_FUNCTION(iisfunc) { return SUCCESS; } PHP_MINFO_FUNCTION(iisfunc) { php_info_print_table_start(); php_info_print_table_header(2, "IIS Admin Functions support", "enabled"); php_info_print_table_end(); } /* {{{ proto int iis_GetServerByPath(string Path) Return the instance number associated with the Path*/ PHP_FUNCTION(iis_getserverbypath) { pval *ServerPath; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServerPath) == FAILURE) WRONG_PARAM_COUNT; convert_to_string(ServerPath); rc = fnIisGetServerByPath(ServerPath->value.str.val); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_GetServerByComment(string Comment) Return the instance number associated with the Comment*/ PHP_FUNCTION(iis_getserverbycomment) { pval *ServerComment; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServerComment) == FAILURE) WRONG_PARAM_COUNT; convert_to_string(ServerComment); rc = fnIisGetServerByComment(ServerComment->value.str.val); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_AddServer(string Path, string Comment, string ServerIP, int ServerPort, string HostName, int ServerRights, int StartServer) Creates a new virtual web server*/ PHP_FUNCTION(iis_addserver) { pval *ServerPath, *ServerComment, *ServerIp, *ServerPort, *ServerHost, *ServerRights, *StartServer; int argc, rc; argc = ARG_COUNT(ht); if (argc != 7 || getParameters(ht, argc, &ServerPath, &ServerComment, &ServerIp, &ServerPort, &ServerHost, &ServerRights, &StartServer) == FAILURE) WRONG_PARAM_COUNT; convert_to_string(ServerPath); convert_to_string(ServerComment); convert_to_string(ServerIp); convert_to_string(ServerPort); convert_to_string(ServerHost); convert_to_long(ServerRights); convert_to_long(StartServer); rc = fnIisAddServer(ServerPath->value.str.val, ServerComment->value.str.val, ServerIp->value.str.val, ServerPort->value.str.val, ServerHost->value.str.val, ServerRights->value.lval, StartServer->value.lval); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_RemoveServer(int ServerInstance) Removes the virtual web server indicated by ServerInstance*/ PHP_FUNCTION(iis_removeserver) { pval *ServerInstance; int argc, rc; argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServerInstance) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); rc = fnIisRemoveServer(ServerInstance->value.lval); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_SetDirectorySecurity(int ServerInstance, string VirtualPath, int DirectoryFlags) Sets Directory Security*/ PHP_FUNCTION(iis_setdirsecurity) { pval *ServerInstance, *VirtualPath, *DirFlags; int argc, rc; argc = ARG_COUNT(ht); if (argc != 3 || getParameters(ht, argc, &ServerInstance, &VirtualPath, &DirFlags) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); convert_to_long(DirFlags); rc = fnIisSetDirSecurity(ServerInstance->value.lval, VirtualPath->value.str.val, DirFlags->value.lval); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_DirectorySecurity(int ServerInstance, string VirtualPath) Gets Directory Security*/ PHP_FUNCTION(iis_getdirsecurity) { pval *ServerInstance, *VirtualPath; int argc, rc; DWORD DirFlags = 0; argc = ARG_COUNT(ht); if (argc != 2 || getParameters(ht, argc, &ServerInstance, &VirtualPath) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); rc = fnIisGetDirSecurity(ServerInstance->value.lval, VirtualPath->value.str.val, &DirFlags); if (rc) { RETVAL_LONG(DirFlags); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_SetServerRights(int ServerInstance, string VirtualPath, int ServerFlags) Sets server rights*/ PHP_FUNCTION(iis_setserverright) { pval *ServerInstance, *VirtualPath, *ServerFlags; int argc, rc; argc = ARG_COUNT(ht); if (argc != 3 || getParameters(ht, argc, &ServerInstance, &VirtualPath, &ServerFlags) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); convert_to_long(ServerFlags); rc = fnIisSetServerRight(ServerInstance->value.lval, VirtualPath->value.str.val, ServerFlags->value.lval); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_GetServerRights(int ServerInstance, string VirtualPath) Gets Directory Security*/ PHP_FUNCTION(iis_getserverright) { pval *ServerInstance, *VirtualPath; int argc, rc; DWORD DirFlags = 0; argc = ARG_COUNT(ht); if (argc != 2 || getParameters(ht, argc, &ServerInstance, &VirtualPath) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); rc = fnIisGetServerRight(ServerInstance->value.lval, VirtualPath->value.str.val, &DirFlags); if (rc) { RETVAL_LONG(DirFlags); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_SetScriptMap(int ServerInstance, string VirtualPath, string EnginePath, int AllowScripting) Sets script mapping on a virtual directory*/ PHP_FUNCTION(iis_setscriptmap) { pval *ServerInstance, *VirtualPath, *ScriptExtention, *EnginePath, *Scripting; int argc, rc; char ScriptingValue[256]; argc = ARG_COUNT(ht); if (argc != 5 || getParameters(ht, argc, &ServerInstance, &VirtualPath, &ScriptExtention, &EnginePath, &Scripting) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); convert_to_string(ScriptExtention); convert_to_string(EnginePath); convert_to_long(Scripting); sprintf(ScriptingValue, "%s,%s,%li", ScriptExtention->value.str.val, EnginePath->value.str.val, Scripting->value.lval); rc = fnIisSetScriptMap(ServerInstance->value.lval, VirtualPath->value.str.val, ScriptingValue); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_GetScriptMap(int ServerInstance, string VirtualPath) Gets script mapping on a virtual directory for a specific extention*/ PHP_FUNCTION(iis_getscriptmap) { pval *ServerInstance, *VirtualPath, *ScriptExtention; int argc, rc; DWORD DirFlags = 0; char *strSetting = emalloc(512); memset(strSetting, 0, 512); argc = ARG_COUNT(ht); if (argc != 3 || getParameters(ht, argc, &ServerInstance, &VirtualPath, &ScriptExtention) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); convert_to_string(ScriptExtention); rc = fnIisGetScriptMap(ServerInstance->value.lval, VirtualPath->value.str.val, ScriptExtention->value.str.val, strSetting); if (rc == 1 && strlen(strSetting)) { RETVAL_STRING(strSetting, 1); } else { RETVAL_STRING("", 1); } efree(strSetting); } /* }}} */ /* {{{ proto int iis_SetAppSetings(int ServerInstance, string VirtualPath, string Name) Creates application scope for a virtual directory*/ PHP_FUNCTION(iis_setappsettings) { pval *ServerInstance, *VirtualPath, *Name; int argc, rc; argc = ARG_COUNT(ht); if (argc != 3 || getParameters(ht, argc, &ServerInstance, &VirtualPath, &Name) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); convert_to_string(VirtualPath); convert_to_string(Name); rc = fnIisSetAppSettings(ServerInstance->value.lval, VirtualPath->value.str.val, Name->value.str.val); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_StartServer(int ServerInstance) Starts the virtual web server*/ PHP_FUNCTION(iis_startserver) { pval *ServerInstance; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServerInstance) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); rc = fnIisSetServerStatus(ServerInstance->value.lval, 1); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_StopServer(int ServerInstance) Stops the virtual web server*/ PHP_FUNCTION(iis_stopserver) { pval *ServerInstance; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServerInstance) == FAILURE) WRONG_PARAM_COUNT; convert_to_long(ServerInstance); rc = fnIisSetServerStatus(ServerInstance->value.lval, 0); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_StopService(string ServiceId) Stops the service defined by ServiceId*/ PHP_FUNCTION(iis_stopservice) { pval *ServiceId; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServiceId) == FAILURE) WRONG_PARAM_COUNT; convert_to_string(ServiceId); rc = fnStopService(ServiceId->value.str.val); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_StartService(string ServiceId) Starts the service defined by ServiceId*/ PHP_FUNCTION(iis_startservice) { pval *ServiceId; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServiceId) == FAILURE) WRONG_PARAM_COUNT; convert_to_string(ServiceId); rc = fnStartService(ServiceId->value.str.val); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ /* {{{ proto int iis_GetServiceState(string ServiceId) Returns teh state for the service defined by ServiceId*/ PHP_FUNCTION(iis_getservicestate) { pval *ServiceId; int argc, rc; // Get and check parameters argc = ARG_COUNT(ht); if (argc != 1 || getParameters(ht, argc, &ServiceId) == FAILURE) WRONG_PARAM_COUNT; convert_to_string(ServiceId); rc = fnGetServiceState(ServiceId->value.str.val); if (rc) { RETVAL_LONG(rc); } else { RETVAL_LONG(0); } } /* }}} */ #endif Index: php4/ext/iisfunc/setup.h +++ php4/ext/iisfunc/setup.h /* +----------------------------------------------------------------------+ | PHP version 4.0 | +----------------------------------------------------------------------+ | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Frank M. Kromann <fmk@swwwing.com> | +----------------------------------------------------------------------+ */ /* $Id: setup.h,v 1.1 2000/10/22 23:06:05 fmk Exp $ */ #ifndef PHP_IIS_SETUP_H #define PHP_IIS_SETUP_H #if HAVE_IISFUNC #ifdef PHP_WIN32 #define PHP_IISFUNC_API __declspec(dllexport) #else #define PHP_IISFUNC_API #endif #ifdef __ZTS #include "TSRM.h" #endif extern zend_module_entry iisfunc_module_entry; #define iisfunc_module_ptr &iisfunc_module_entry extern PHP_MINIT_FUNCTION(iisfunc); extern PHP_MSHUTDOWN_FUNCTION(iisfunc); extern PHP_RINIT_FUNCTION(iisfunc); extern PHP_RSHUTDOWN_FUNCTION(iisfunc); PHP_MINFO_FUNCTION(iisfunc); PHP_FUNCTION(iis_getserverbypath); PHP_FUNCTION(iis_getserverbycomment); PHP_FUNCTION(iis_addserver); PHP_FUNCTION(iis_removeserver); PHP_FUNCTION(iis_setdirsecurity); PHP_FUNCTION(iis_getdirsecurity); PHP_FUNCTION(iis_setserverright); PHP_FUNCTION(iis_getserverright); PHP_FUNCTION(iis_startserver); PHP_FUNCTION(iis_stopserver); PHP_FUNCTION(iis_setscriptmap); PHP_FUNCTION(iis_getscriptmap); PHP_FUNCTION(iis_setappsettings); PHP_FUNCTION(iis_stopservice); PHP_FUNCTION(iis_startservice); PHP_FUNCTION(iis_getservicestate); int fnIisGetServerByPath(char * ServerPath); int fnIisGetServerByComment(char * ServerComment); int fnIisAddServer(char * ServerPath, char * ServerComment, char * ServerIp, char * ServerPort, char * ServerHost, DWORD ServerRights, DWORD StartServer); int fnIisRemoveServer(DWORD ServerInstance); int fnIisSetDirSecurity(DWORD ServerInstance, char * VirtualPath, DWORD DirFlags); int fnIisGetDirSecurity(DWORD ServerInstance, char * VirtualPath, DWORD * DirFlags); int fnIisSetServerRight(DWORD ServerInstance, char * VirtualPath, DWORD ServerRights); int fnIisGetServerRight(DWORD ServerInstance, char * VirtualPath, DWORD * ServerRights); int fnIisSetServerStatus(DWORD ServerInstance, DWORD StartServer); int fnIisSetScriptMap(DWORD ServerInstance, char * VirtualPath, char * ScriptMap); int fnIisGetScriptMap(DWORD ServerInstance, char * VirtualPath, char * SeciptExtention, char * ReturnValue); int fnIisSetAppSettings(DWORD ServerInstance, char * VirtualPath, char * AppName); int fnStopService(LPSTR ServiceId); int fnStartService(LPTSTR ServiceId); int fnGetServiceState(LPTSTR ServiceId); #else #define iisfunc_module_ptr NULL #endif /* HAVE_IISFUNC */ #define phpext_iisfunc_ptr iisfunc_module_ptr #endif