Web Shop

Results 1 to 2 of 2
  1. #1
    Proficient Member Sedrika is offline
    MemberRank
    Sep 2009 Join Date
    162Posts

    Web Shop

    Web Shop Preview

    Download Web Shop 1.0.1
    Download Web Shop 1.0

    Setup: Step 1 (Source)
    Spoiler:

    Open DbItemUpdate.cpp and search for:
    Code:
    void CDbManager::ChangeItemUpdate( CQuery* pQuery )
    Replace the whole function with this one:
    Code:
    void CDbManager::ChangeItemUpdate( CQuery* pQuery )
    {
    	char szSQL[4096] = {0,};
    	
    	sprintf( szSQL, "ITEM_STR 'D1'" );
    	
    	if( FALSE == pQuery->Exec( szSQL ) )
    	{
    		WriteLog( szSQL );
    		return;		
    	}
    
    	for( int i = 0; i < prj.m_aPropItem.GetSize(); i++ )
    	{
    		ItemProp* pItemProp =  prj.GetItemProp( i );
    		if( pItemProp && pItemProp->dwItemKind3 != IK3_VIRTUAL && pItemProp->dwID != 0 )
    		{
    			CString	strItem	= pItemProp->szName;
    			strItem.Replace( "'", "" );
    			CString strItemCommand = pItemProp->szCommand;
    			strItemCommand.Replace( "'", "" );
    			sprintf( szSQL, "ITEM_STR 'I1',"
    				"%d, '%s', %d, %d, %d, %d,"	// 0
    				"%d, %d, %d, %d, %d, %d,"	// 1
    				"%d, %d, %d, %d, %d, %d,"	// 2
    				"%d, %d, %d, %d, %d, %f,"	// 3
    				"%d, %d, %d, %d, %d, %d,"	// 4
    				"%d, %d, %d, %d, %d, %d,"	// 5
    				"%d, %d, %d, %d, %d, %d,"	// 6
    				"%d, %d, %d, %d, %d, %d,"	// 7
    				"%d, %d, %d, %d, %d, %d,"	// 8
    				"%d, %d, %f, %d, %d, %d,"	// 9
    				"%d, '%s', '%s'",			// 10
    
    				pItemProp->dwID, strItem, pItemProp->dwPackMax, pItemProp->dwItemKind1, pItemProp->dwItemKind2, pItemProp->dwItemKind3, // 0
    				pItemProp->dwItemJob, pItemProp->dwItemSex, pItemProp->dwCost, pItemProp->dwHanded, pItemProp->dwFlag, pItemProp->dwParts, // 1
    				pItemProp->dwPartsub, pItemProp->dwExclusive, pItemProp->dwItemLV, pItemProp->dwItemRare, pItemProp->dwShopAble, pItemProp->bCharged, // 2
    				pItemProp->dwAbilityMin, pItemProp->dwAbilityMax, pItemProp->eItemType, pItemProp->dwWeaponType, pItemProp->nAdjHitRate, pItemProp->fAttackSpeed, // 3
    				pItemProp->dwAttackRange, pItemProp->nProbability, pItemProp->dwDestParam[0], pItemProp->dwDestParam[1], pItemProp->dwDestParam[2], pItemProp->nAdjParamVal[0], // 4
    				pItemProp->nAdjParamVal[1], pItemProp->nAdjParamVal[2], pItemProp->dwChgParamVal[0], pItemProp->dwChgParamVal[1], pItemProp->dwChgParamVal[2], pItemProp->nDestData1[0], // 5
    				pItemProp->nDestData1[1], pItemProp->nDestData1[2], pItemProp->dwReqMp, pItemProp->dwReqFp, pItemProp->dwReqDisLV, pItemProp->dwCircleTime, // 6
    				pItemProp->dwSkillTime, pItemProp->dwReferStat1, pItemProp->dwReferStat2, pItemProp->dwReferTarget1, pItemProp->dwReferTarget2, pItemProp->dwReferValue1, // 7
    				pItemProp->dwReferValue2, pItemProp->dwSkillType, pItemProp->nItemResistElecricity, pItemProp->nItemResistFire, pItemProp->nItemResistWind, pItemProp->nItemResistWater, // 8
    				pItemProp->nItemResistEarth, pItemProp->dwExp, pItemProp->fFlightSpeed, pItemProp->dwFlightLimit, pItemProp->dwFFuelReMax, pItemProp->dwAFuelReMax, // 9
    				pItemProp->dwLimitLevel1, pItemProp->szIcon, strItemCommand // 10
    				);
    			if( FALSE == pQuery->Exec( szSQL ) )
    			{
    				WriteLog( szSQL );
    				return;
    			}
    		}	// if
    	}	// for
    	TRACE( "ChangeItemUpdate Complete\n" );
    }
    Open ProjectCmn.cpp and search for:
    Code:
    BOOL CProject::LoadPropItem( LPCTSTR lpszFileName, CFixedArray< ItemProp >* apObjProp )
    Search and replace this:
    Code:
    #ifdef __CLIENT	
    	_tcsncpy( prop.szIcon, scanner.token, sizeof(prop.szIcon)-1 );
    	prop.szCommand[sizeof(prop.szIcon)-1] = 0;
    #endif
    with this:
    Code:
    #if defined(__CLIENT) || defined(__DBSERVER)	
    	_tcsncpy( prop.szIcon, scanner.token, sizeof(prop.szIcon)-1 );
    	prop.szCommand[sizeof(prop.szIcon)-1] = 0;
    #endif
    Search and replace this:
    Code:
    #ifdef __CLIENT	
    	_tcsncpy( prop.szCommand, scanner.token, sizeof(prop.szCommand)-1 );
    	prop.szCommand[sizeof(prop.szCommand)-1] = 0;
    #endif
    with this:
    Code:
    #if defined(__CLIENT) || defined(__DBSERVER)	
    	_tcsncpy( prop.szCommand, scanner.token, sizeof(prop.szCommand)-1 );
    	prop.szCommand[sizeof(prop.szCommand)-1] = 0;
    #endif
    Open ProjectCmn.h and search for:
    Code:
    #ifdef __CLIENT
        TCHAR	szIcon[64];
    	TCHAR	szCommand[256];
    #endif
    and replace it with this:
    Code:
    #if defined(__CLIENT) || defined(__DBSERVER)
        TCHAR	szIcon[64];
    	TCHAR	szCommand[256];
    #endif
    Open DPSrvr.cpp and search for:
    Code:
    void CDPSrvr::OnBuyingInfo( CAr & ar, DPID dpidCache, DPID dpidUser, LPBYTE lpBuf, u_long uBufSize )
    and replace the whole function with this:
    Code:
    void CDPSrvr::OnBuyingInfo( CAr & ar, DPID dpidCache, DPID dpidUser, LPBYTE lpBuf, u_long uBufSize )
    {
    	BUYING_INFO2 bi2;
    	ar.Read( (void*)&bi2, sizeof(BUYING_INFO2) );
    
    	CWorld* pWorld;
    	CUser* pUser	= g_UserMng.GetUser( dpidCache, dpidUser );
    
    	/*
    		100 - Save Player
    		101 - Create Item
    	*/
        
        if( IsValidObj( pUser )  && ( pWorld = pUser->GetWorld() ) )
        {
    		if( bi2.dwParam4 != 0000000 || bi2.dwParam5 != 0000000 )
    				return;
    		if( bi2.dwCommand == 100 ) // Save Player
    		{
    			g_dpDBClient.SavePlayer( pUser, pWorld->GetID(), pUser->GetPos(), pUser->GetLayer() );
    		}
    		else if( bi2.dwCommand == 101 ) // Create Item
    		{
    			SERIALNUMBER iSerialNumber	= 0;
    			CItemElem itemElem;
    			itemElem.m_dwItemId        = bi2.dwParam1;
    			itemElem.m_nItemNum        = (short)bi2.dwParam2;
    			itemElem.m_bCharged        = TRUE;
    			BYTE nId;
    			bi2.dwParam3    = pUser->CreateItem( &itemElem, &nId );
    			if( bi2.dwParam3 )
    			{
    				CItemElem* pItemElem    = pUser->m_Inventory.GetAtId( nId );
    				if( pItemElem )
    				{
    					iSerialNumber    = pItemElem->GetSerialNumber();
    					pItemElem->m_bCharged    = TRUE;
    					if( bi2.dwTargetId > 0 )
    						pUser->AddDefinedText( TID_EVE_REAPITEM, "\"%s\"", itemElem.GetName() );
    				}
    			}
    			else
    			{
    				LogItemInfo aLogItem;
    				aLogItem.Action = "S";
    				aLogItem.SendName = pUser->GetName();
    				aLogItem.WorldId = pUser->GetWorld()->GetID();
    				aLogItem.Gold = aLogItem.Gold2 = pUser->GetGold();
    
    				g_dpDBClient.SendQueryPostMail( pUser->m_idPlayer, 0, itemElem, 0, "WebShop", "" );
    				aLogItem.RecvName = "HOMEPAGE_SHOP";
    				g_DPSrvr.OnLogItem( aLogItem, &itemElem, itemElem.m_nItemNum );
    			}
    			g_dpDBClient.SendBuyingInfo( &bi2, iSerialNumber );
    			g_dpDBClient.SavePlayer( pUser, pWorld->GetID(), pUser->GetPos(), pUser->GetLayer() );
    		}
    	}
    }
    Open buyinginfo.h and replace the while file with this:
    Code:
    #ifndef __CHARGEDITEM_H__
    #define	__CHARGEDITEM_H__
    
    typedef struct _BUYING_INFO
    {
    	DWORD	dwServerIndex;
    	DWORD	dwPlayerId;
    	DWORD	dwTargetId;
    	DWORD	dwCommand;
    	DWORD	dwParam1;
    	DWORD	dwParam2;
    	DWORD	dwParam3;
    	DWORD	dwParam4;
    	DWORD	dwParam5;
    
    	_BUYING_INFO()
    	{
    		dwServerIndex	= 0;
    		dwPlayerId		= 0;
    		dwTargetId		= 0;
    		dwCommand		= 0;
    		dwParam1		= 0;
    		dwParam2		= 0;
    		dwParam3		= 0;
    		dwParam4		= 0;
    		dwParam5		= 0;
    	}
    }
    BUYING_INFO, *PBUYING_INFO;
    
    typedef struct _BUYING_INFO2: public _BUYING_INFO
    {
    	DWORD	dpid;
    	DWORD	dwKey;
    	_BUYING_INFO2() : _BUYING_INFO()
    		{
    			dpid	= 0xFFFFFFFF;
    			dwKey	= 0;
    		}
    }
    BUYING_INFO2, *PBUYING_INFO2;
    
    typedef struct _BUYING_INFO3: public _BUYING_INFO2
    {
    	DWORD	dwTickCount;
    	_BUYING_INFO3() : _BUYING_INFO2()
    		{
    //			dwTickCount		= GetTickCount();
    		}
    }
    BUYING_INFO3, *PBUYING_INFO3;
    
    #endif	// __CHARGEDITEM_H__
    Open dpadbill.h and search for:
    Code:
    void	Process( void )
    and replace the whole function with this:
    Code:
    void	Process( void )
    {
    	DWORD dwTickCount	= GetTickCount();
    //	static DWORD adwKey[1024];
    	vector<DWORD>	adwKey;
    			
    	int nSize	= 0;
    			
    	m_AddRemoveLock.Enter();
    	for( map<DWORD, PBUYING_INFO3>::iterator i = m_mapPbi3.begin(); i != m_mapPbi3.end(); ++i )
    	{
    		PBUYING_INFO3 pbi3	= i->second;
    		if( dwTickCount - pbi3->dwTickCount > SEC( 3 ) )
    		{
    			CDPAdbill::GetInstance()->Send( pbi3, sizeof(BUYING_INFO), pbi3->dpid );
    //			adwKey[nSize++]	= pbi3->dwKey;
    			adwKey.push_back( pbi3->dwKey );
    		}
    	}
    			
    //	Remove
    //	for( int j = 0; j < nSize; j++ )
    	for( DWORD j = 0; j < adwKey.size(); j++ )
    	{
    //		PBUYING_INFO3 ptr	= CBuyingInfoMng::GetInstance()->Get( adwKey[j] );
    		PBUYING_INFO3 ptr	= CBuyingInfoMng::GetInstance()->Get( adwKey[j] );
    		if( ptr )
    		{
    			BUYING_INFO2	bi2;
    			DWORD sn = 0;
    
    			bi2.dwServerIndex	= ptr->dwServerIndex;
    			bi2.dwPlayerId		= ptr->dwPlayerId;
    			bi2.dwTargetId		= ptr->dwTargetId;
    			bi2.dwCommand		= ptr->dwCommand;
    			bi2.dwParam1		= ptr->dwParam1;
    			bi2.dwParam2		= ptr->dwParam2;
    			bi2.dwParam3		= ptr->dwParam3;
    			bi2.dwParam4		= ptr->dwParam4;
    			bi2.dwParam5		= ptr->dwParam5;
    
    			CAr ar;
    			ar.Write( (void*)&bi2, sizeof(BUYING_INFO2) );
    			ar << sn;
    
    			int nBufSize;
    			LPBYTE lpData	= ar.GetBuffer( &nBufSize );
    			LPDB_OVERLAPPED_PLUS lpDbOverlappedPlus		= g_DbManager.m_pDbIOData->Alloc();
    			memcpy( lpDbOverlappedPlus->lpBuf, lpData, nBufSize );
    			lpDbOverlappedPlus->uBufSize	= nBufSize;
    			lpDbOverlappedPlus->nQueryMode	= LOG_SM_ITEM;
    			PostQueuedCompletionStatus( g_DbManager.m_hDbCompletionPort, 1, NULL, &lpDbOverlappedPlus->Overlapped );
    		}
    		Remove( adwKey[j] );
    		SAFE_DELETE( ptr );
    	}
    
    	m_AddRemoveLock.Leave();
    
    	adwKey.clear();
    }
    Open WebBox.cpp and search for:
    Code:
    void CWebBox::Refresh_Web()
    and replace the whole function with this:
    Code:
    void CWebBox::Refresh_Web()
    {
    	char address[512], postdata[WEB_STR_LEN], header[WEB_STR_LEN];
    	ZeroMemory( address, 512 );
    	wsprintf( address, GetAddress() );
    	char out[260]	= { 0, };
    	char in[260]	= { 0, };
    	CString hash = "gaajgussfdbfhjq";
    	sprintf( in, "%s%d%d%s", m_szUser, m_nPlayer, m_nServer, hash );
    	::md5( out, in );
    	wsprintf( postdata, WEB_POSTDATA, m_szUser, m_nPlayer, m_nServer, out, g_Neuz.m_szPassword );
    	wsprintf( header, WEB_HEADER, lstrlen( postdata ) );
    	ChangeWebAddress( address, postdata, header );
    }
    Search for:
    Code:
    bool CWebBox::Process(HWND hWnd,HINSTANCE hInstance, char* szUser, u_long nPlayer, DWORD nServer, int nLevel, int nJob, int nSex, const char* szName )
    and replace the whole function with this:
    Code:
    bool CWebBox::Process(HWND hWnd,HINSTANCE hInstance, char* szUser, u_long nPlayer, DWORD nServer, int nLevel, int nJob, int nSex, const char* szName )
    {
    	char address[512], postdata[WEB_STR_LEN], header[WEB_STR_LEN];
    	ZeroMemory( address, 512 );
    	ZeroMemory( postdata, WEB_STR_LEN );
    	ZeroMemory( header, WEB_STR_LEN );
    
    	if( m_bStart && m_bStartWeb )
    	{
    		lstrcpy( m_szUser, szUser );
    		m_nPlayer	= nPlayer;
    		m_nServer	= nServer;
    		m_nLevel	= nLevel;
    		m_nJob	= nJob;
    		m_nSex	= nSex;
    		lstrcpy( m_szName, szName );
    
    		D3DDEVICE->SetDialogBoxMode( TRUE );
    		Start_WebBox( hWnd, hInstance, WEB_DEFAULT_X, WEB_DEFAULT_Y, NULL );
    
    		wsprintf( address, GetAddress() );
    		
    		char out[260]	= { 0, };
    		char in[260]	= { 0, };
    		CString hash = "gjgusdbfjq";
    		sprintf( in, "%s%d%d%s", m_szUser, m_nPlayer, m_nServer, hash );
    			
    		::md5( out, in );
    		wsprintf( postdata, WEB_POSTDATA, m_szUser, m_nPlayer, m_nServer, out, g_Neuz.m_szPassword );
    		
    		wsprintf( header, WEB_HEADER, lstrlen( postdata ) );
    		ChangeWebAddress( address, postdata, header );
    		Show( TRUE );
    		m_bStart	= false;
    		m_bEnd	= false;
    		return true;
    	}
    	else if( m_bEnd )
    	{
    		End_WebBox();
    		m_bEnd	= false;
    		m_bStart	= false;
    		m_bStartWeb	= false;
    		return false;
    	}
    	else if( m_bStartWeb )
    	{
    		if( GetAsyncKeyState( VK_F5 ) )
    			Refresh_Web();
    	}
    
    	return false;
    }


    Setup: Step 2 (Database)
    Spoiler:

    Execute WebShop.sql and ITEM_DBF.sql


    Setup: Step 3 (Server File Config)
    Spoiler:

    Open DatabaseServer.ini and add this if it's not already there:
    Code:
    ITEMUPDATE
    
    DSN_NAME_ITEMUPDATE    "item" 
    DB_ADMIN_ID_ITEMUPDATE     "item"
    DB_PWD_ITEMUPDATE	""


    Setup: Step 4 (ODBC Config)
    Spoiler:

    Create a new entry with the following settings:
    Name: item
    Default Database: ITEM_DBF


    Setup: Step 5 (Web Shop Config)
    Spoiler:

    Open include/config.php and change the following settings:

    BILLING_IP Don't change this if the web site is on the same root server as the server files.
    BILLING_PORT Default is 29000. You can change this just search for PN_ADBILL in your source files.
    BILLING_CHECK1 This one is the first check key. This have to be a number and the same as bi2.dwParam4 in CDPSrvr::OnBuyingInfo.
    BILLING_CHECK2 This one is the second check key. This have to be a number and the same as bi2.dwParam5 in CDPSrvr::OnBuyingInfo.

    $hash_shop This is a hash value for validation and have to be the same as hash in CWebBox::Refresh_Web and CWebBox::Process.


    Setup: Step 6 (Add items to shop)
    Spoiler:

    Open DONATE_SHOP_TBL in MSSQL and add the items there:

    dwCategory A-H belongs on which category you want to add an item.
    dwItemId Id of the item.
    dwCost Item price.
    dwAmount Amount of items.
    dwGender 1 => Male, 2 => Female, 3 => Sexless
    dwSale 0 => Hide, 1 => Show
    dwPurchase How often this item has been bought. Default is 0 .


    Epilogue:

    I will gradually integrate new functions and make them more user friendly.
    I hope you enjoy using this shop system i've created from the original design used by Webzen.

    Credits:
    - Webzen - Design
    - Sedrika - Everytihing else
    Last edited by Sedrika; 06-10-14 at 08:02 PM.


  2. #2
    (つ•̀ᴥ•́)つ Marvinoo is offline
    MemberRank
    Feb 2009 Join Date
    245Posts

    Re: Web Shop

    Looks pretty cool, but there were other ways to use the webshop in the client so it's not realy necessary. But again it still looks pretty awesome so thanks for this release.



Advertisement