void WebResourceCacheManager::getCacheOrigins(uint64_t callbackID) const { WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); MemoryCache::SecurityOriginSet origins; memoryCache()->getOriginsWithCache(origins); #if USE(CFURLCACHE) RetainPtr<CFArrayRef> cfURLHosts = cfURLCacheHostNames(); CFIndex size = cfURLHosts ? CFArrayGetCount(cfURLHosts.get()) : 0; String httpString("http"); for (CFIndex i = 0; i < size; ++i) { CFStringRef host = static_cast<CFStringRef>(CFArrayGetValueAtIndex(cfURLHosts.get(), i)); origins.add(SecurityOrigin::create(httpString, host, 0)); } #endif // Create a list with the origins in both of the caches. Vector<SecurityOriginData> identifiers; identifiers.reserveCapacity(origins.size()); MemoryCache::SecurityOriginSet::iterator end = origins.end(); for (MemoryCache::SecurityOriginSet::iterator it = origins.begin(); it != end; ++it) { RefPtr<SecurityOrigin> origin = *it; SecurityOriginData originData; originData.protocol = origin->protocol(); originData.host = origin->host(); originData.port = origin->port(); identifiers.uncheckedAppend(originData); } WebProcess::shared().connection()->send(Messages::WebResourceCacheManagerProxy::DidGetCacheOrigins(identifiers, callbackID), 0); }
//Ok, so here goes nothing... void iohtmlFunc_ajax( ReplyDataPtr cnt ) { #if IRCBOT_SUPPORT ConfigArrayPtr settings[2]; #endif int a, c, id, numbuild; int64_t b; int64_t bsums[CMD_BLDG_NUMUSED+1]; int64_t usums[CMD_UNIT_NUMUSED]; const char *typestring, *idstring, *refer; char CHECKER[256]; char timebuf[512]; dbMainEmpireDef empired; dbBuildPtr build; dbUserMainDef maind; proginfoDef pinfod; urlinfoPtr urlp; cpuInfo cpuinfo; time_t tint; struct sysinfo sysinfod; refer = idstring = typestring = NULL; cpuGetInfo( &cpuinfo ); getsys_infos( &pinfod ); if( sysinfo(&sysinfod) != 0 ) { critical( "Failure getting system infomation... Critical failure." ); sysconfig.shutdown = true; return; } idstring = iohtmlVarsFind( cnt, "id" ); typestring = iohtmlVarsFind( cnt, "typ" ); refer = iohtmlHeaderFind(cnt, "Referer"); if( ( id = iohtmlIdentify( cnt, 2 ) ) >= 0 ) { if( dbUserMainRetrieve( id, &maind ) < 0 ) goto BAILAJAX; else if( dbEmpireGetInfo( maind.empire, &empired ) < 0 ) goto BAILAJAX; } if( ( typestring ) && ( refer ) ) { urlp = parse_url(refer); refer = urlp->path; httpString( cnt, "<?xml version=\"1.0\"?>" ); httpPrintf( cnt, "<xml>" ); //Begin XML generation, we only make one request now... so we have to structure carefully! if( !strcmp(typestring,"ticker") ) { //Send basic tick info, and check if user is loged in. httpPrintf( cnt, "<pass>%d</pass>", ( id != -1 ) ? ( ( bitflag( ((cnt->session)->dbuser)->flags, CMD_USER_FLAGS_ACTIVATED ) ) ? true : false ) : false ); if( refer ) httpPrintf( cnt, "<page>%s</page>", refer ); httpPrintf( cnt, "<u_online>%d</u_online><u_activated>%d</u_activated>", dbRegisteredInfo[DB_TOTALS_USERS_ONLINE], dbRegisteredInfo[DB_TOTALS_USERS_ACTIVATED] ); httpPrintf( cnt, "<time><next>%d</next><week>%d</week><year>%d</year></time>", (int)fmax( 0.0, ( ticks.next - time(0) ) ), ticks.number % 52, ticks.number / 52 ); if( !strcmp(refer,"status") ) { snprintf( CHECKER, sizeof(CHECKER), "%lu bytes ( %5.1f mb )", pinfod.stvsize, pinfod.stvsize / megabyte ); httpString( cnt, "<general>" ); httpPrintf( cnt, "<servpriority>%ld</servpriority>", pinfod.stpriority ); httpPrintf( cnt, "<servthreads>%ld</servthreads>", pinfod.threads ); httpString( cnt, "</general>" ); httpString( cnt, "<memory>" ); httpPrintf( cnt, "<memused>%s</memused>", CHECKER ); httpPrintf( cnt, "<memavbytes>%ld bytes</memavbytes>", sysinfod.freeram ); httpPrintf( cnt, "<memavmeg>( %4.1f mb )</memavmeg>", (sysinfod.freeram / megabyte ) ); httpPrintf( cnt, "<totalswapbytes>%ld bytes</totalswapbytes>", sysinfod.totalswap ); httpPrintf( cnt, "<totalswapmeg>( %5.1f mb )</totalswapmeg>", (sysinfod.totalswap / megabyte ) ); httpPrintf( cnt, "<freeswapbytes>%ld bytes</freeswapbytes>", sysinfod.freeswap ); httpPrintf( cnt, "<freeswapmeg>( %5.1f mb )</freeswapmeg>", (sysinfod.freeswap / megabyte ) ); httpPrintf( cnt, "<bufferbytes>%ld bytes</bufferbytes>", sysinfod.bufferram ); httpPrintf( cnt, "<bufermeg>( %5.1f mb )</bufermeg>", (sysinfod.bufferram / megabyte ) ); httpPrintf( cnt, "<sharedbytes>%ld bytes</sharedbytes>", sysinfod.sharedram ); httpPrintf( cnt, "<sharedmeg>( %5.1f mb )</sharedmeg>", (sysinfod.sharedram / megabyte ) ); time( &tint ); strftime(timebuf,512,"%a, %d %b %G %T %Z", localtime( &tint ) ); httpPrintf( cnt, "<timeserver>%s</timeserver>", timebuf ); strftime(timebuf,512,"%a, %d %b %G %T %Z", gmtime( &tint ) ); httpPrintf( cnt, "<timegmt>%s</timegmt>", timebuf ); httpPrintf( cnt, "<strss>%lu pages</strss>", pinfod.strss ); httpPrintf( cnt, "</memory>" ); httpString( cnt, "<cpu>" ); httpPrintf( cnt, "<cpuprocs>%d</cpuprocs>", sysinfod.procs ); httpPrintf( cnt, "<cpuloads>%f (1 min) - %f (5 mins) - %f (15 mins)</cpuloads>",pinfod.loadavg[0],pinfod.loadavg[1],pinfod.loadavg[2]); httpPrintf( cnt, "<cputotal>%.3f %%</cputotal>", pinfod.userload + pinfod.kernelload ); httpPrintf( cnt, "<cpukernel>%.3f %%</cpukernel>", pinfod.kernelload ); httpPrintf( cnt, "<cpuuser>%.3f %%</cpuuser>", pinfod.userload ); httpString( cnt, "</cpu>" ); #if IRCBOT_SUPPORT if( sysconfig.irc_enabled ) { if( irc_is_connected(sysconfig.irc_session) ) { settings[0] = GetSetting( "IRC Host" ); settings[1] = GetSetting( "IRC Channel" ); snprintf( CHECKER, sizeof(CHECKER), "Enabled (Host:%s, Channel:%s)", settings[0]->string_value, settings[1]->string_value ); } else { snprintf( CHECKER, sizeof(CHECKER), "%s", "Enabled but not connected" ); } } else { snprintf( CHECKER, sizeof(CHECKER), "%s", "Disabled"); } httpPrintf( cnt, "<botstatus>%s</botstatus>", CHECKER ); #endif //End Status block -- Start user block } if( id < 0 ) goto ENDXML; a = dbUserNewsGetFlags( id ); //OK, so they are loged in... time to send some info. Lets start with the header. =) httpString( cnt, "<header>" ); httpPrintf( cnt, "<networth>%lld</networth>", (long long)maind.networth ); httpString( cnt, "<notification>" ); httpPrintf( cnt, "<mail>%d</mail>", ( a & CMD_NEWS_FLAGS_MAIL ) ? true : false ); httpPrintf( cnt, "<build>%d</build>", ( a & CMD_NEWS_FLAGS_BUILD ) ? true : false ); httpPrintf( cnt, "<aid>%d</aid>", ( a & CMD_NEWS_FLAGS_AID ) ? true : false ); httpPrintf( cnt, "<fleet>%d</fleet>", ( a & CMD_NEWS_FLAGS_ATTACK ) ? 1 : ( ( a & CMD_NEWS_FLAGS_FLEET ) ? 2 : false ) ); httpString( cnt, "</notification>" ); httpString( cnt, "<ressources>" ); for( a = 0 ; a < CMD_RESSOURCE_NUMUSED ; a++ ) { snprintf( CHECKER, sizeof(CHECKER),"%s",cmdRessourceName[a]); for(b = 0; CHECKER[b]; b++){ CHECKER[b] = tolower(CHECKER[b]); } httpPrintf( cnt, "<%s>%lld</%s>", CHECKER, (long long)maind.ressource[a], CHECKER ); } httpPrintf( cnt, "<population>%lld</population>", (long long)maind.ressource[CMD_RESSOURCE_POPULATION] ); httpString( cnt, "</ressources>" ); httpString( cnt, "</header>" ); httpPrintf( cnt, "<%s>", refer ); //End Header block -- Start HQ block if( !strcmp(refer,"hq") ) { httpString( cnt, "<readiness>" ); for( a = 0 ; a < CMD_READY_NUMUSED ; a++ ) { httpPrintf( cnt, "<%sready>%d</%sready>", cmdReadyName[a], maind.readiness[a] >> 16, cmdReadyName[a] ); } httpString( cnt, "</readiness>" ); httpPrintf( cnt, "<planets>%d</planets>", maind.planets ); //End HQ block -- Start Council block } else if( !strcmp(refer,"council") ) {
/*This function will be use to approve file uploaded by player to our image server*/ void iohttpFunc_Approve( ReplyDataPtr cnt ) { int nAllow = 0; // == 1 if this user have the right of allowing image int id, nAction; //Action == 1 approve 2 == Disapprove (file deleted, msg send to id) int a; //Because Mal always use a and not i char *szAction; char *szID; char szName[50]; char szPass[50]; char szFileName[50]; char szTemp[50]; FILE *fDesc; if((( id = iohtmlIdentify( cnt, 0 ) ) >= 0 ) && (cnt != NULL)) { if( ((cnt->session)->dbuser)->level >= LEVEL_MODERATOR ) nAllow ++; } //Look for variable here szAction = iohtmlVarsFind( cnt, "action" ); szID = iohtmlVarsFind( cnt, "id" ); iohtmlBase( cnt, 1 ); //Init of the html code for the player iohtmlBodyInit( cnt, "Approving" ); if(nAllow) { //Read all the input given by Post then show link to the file to download it before approving it. if((szAction)&&(szID)) { nAction = atoi(szAction); //Open the desc file of this file ID sprintf(szFileName, "pending/%s.txt", szID); fDesc = fopen(szFileName, "r"); if(fDesc) { if( ( fscanf(fDesc, "%s", szName) || fscanf(fDesc, "%s", szPass) || fscanf(fDesc, "%s", szFileName) ) != 1 ) { fclose(fDesc); return; } //In both case we must check if the user exist and what is his id nAllow = -1; //this if is for formating the user and pass put ' ' instead of + if( strlen( szName ) && strlen( szPass ) ) { for( a = 0 ; szName[a] ; a++ ) { if( szName[a] == '+' ) szName[a] = ' '; else if( ( szName[a] == 10 ) || ( szName[a] == 13 ) ) szName[a] = 0; } for( a = 0 ; szPass[a] ; a++ ) { if( szPass[a] == '+' ) szPass[a] = ' '; else if( ( szPass[a] == 10 ) || ( szPass[a] == 13 ) ) szPass[a] = 0; } if( ( id = dbUserSearch( szName ) ) >= 0 ) { if( dbUserRetrievePassword( id, szTemp ) >= 0 ) { if( ioCompareExact( szPass, szTemp) ) nAllow = id; } } //nAllow will be equal to the id of the user if the good password was supplied } if(nAction == 1) //Approve { httpPrintf(cnt, "The file %s is approved<br>", szID); } else if(nAction == 2) //Disapprove { httpPrintf(cnt, "This file %s is deleted and a message was sent to the user<br>", szID); } fclose(fDesc); } } //List all the file "pending" here } else { httpString(cnt, "Sorry you don't have the necessary right to approve files upload by players!"); } iohtmlBodyEnd( cnt ); return; }