bool login() { string post=getPara(); if (post=="") return false; FILE * fp=fopen(tfilename,"w+"); //curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); //curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl"); //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "nbut.cookie"); curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "nbut.cookie"); curl_easy_setopt(curl, CURLOPT_URL, "http://acm.nbut.cn/User/chklogin.xhtml"); post=post+"username="******"&password="******"1") return false; return true; }
bool login() { string post=getPara(); if (post=="") return false; FILE * fp=fopen(tfilename,"w+"); //curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_REFERER, "http://livearchive.onlinejudge.org/"); curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl"); //curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "uvalive.cookie"); curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "uvalive.cookie"); curl_easy_setopt(curl, CURLOPT_URL, "http://livearchive.onlinejudge.org/index.php?option=com_comprofiler&task=login"); post=post+"username="******"&passwd="+escapeURL(password)+"&remember=yes&Submit=Login"; curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } fclose(fp); if (res) return false; string ts=getAllFromFile(tfilename); //cout<<ts; if (ts.find("alert(\"")!=string::npos||ts.find("<div class='error'>")!=string::npos||ts.find("You are not authorized to view this page!")!=string::npos) return false; return true; }
void Dispatch::Do() { log.write("in StartVM::Do", Log::INFO); //参数检查 if( getPara() == false) { ackCode = "ACK:GET BEST NC:RETN=4,DESC=参数错误"; return; } if( getVMRamSize() == false ) { ackCode = "ACK:GET BEST NC:RETN=8,DESC=数据库内部错误"; return; } if( iRamSize == 0 ) { ackCode = "ACK:GET BEST NC:RETN=1002,DESC=没有找到此虚拟机"; return; } if( findFirstCapableNC() == false ) { ackCode = "ACK:GET BEST NC:RETN=8,DESC=数据库内部错误"; return; } //cout<<"IP:"<<capableNCIP<<endl; if( capableNCIP.size() != 0 ) ackCode = "ACK:GET BEST NC:RETN=0,DESC=成功,IP=" + capableNCIP; else ackCode = "ACK:GET BEST NC:RETN=1001,DESC=未找到合适的NC节点"; }
/**********************************running the clustering algorithem starts from here******************************************************/ int DlgOtherAlgo::runMl() { if(!bDataLoad) { AfxMessageBox(TEXT("Plz load data at first!")); return -1; } getPara(); //getPreprocessMethod(); pOtherAlgo->setPara(para); //train data pOtherAlgo->executeAlgo(); return 0; }
void ExpandVMMem::Do() { //参数检查 if( getPara() == false) { ackCode = "ACK:EXPAND VM:RETN=4,DESC=para error"; return; } /* int vmmem = getVMMemory(); if( vmmem == 0 ) { ackCode = "ACK:EXPAND VM:RETN=1001,DESC=get vm memory info failed"; return; } vmmem = (int)(vmmem * 1.2);*/ int cpuCnt = getVMCPUCnt(); if( cpuCnt == 0 ) { ackCode = "ACK:EXPAND VM:RETN=1001,DESC=get vm cpu info failed"; return; } if( expandFlag == 0 ) cpuCnt++; else cpuCnt--; char buff[1024]; memset(buff,0,sizeof(buff)); sprintf(buff,"xm vcpu-set %s %d",vmName.c_str(),cpuCnt); system(buff); if( getVMCPUCnt() == cpuCnt ) ackCode = "ACK:EXPAND VM:RETN=0,DESC=success"; else ackCode = "ACK:EXPAND VM:RETN=8,DESC=error"; }
void Auth::Do() { log.write("begin Auth::Do.", Log::INFO); //参数检查 log.write("begin process parameter.", Log::INFO); if( getPara() == false) { ackCode = "ACK:LOGIN:RETN=4,DESC=parameter error"; return; } log.write("end process parameter.", Log::INFO); //检查用户名密码是否正确 log.write("begin check user name and password.", Log::INFO); if( checkPass() == false) { ackCode = "ACK:LOGIN:RETN=1001,DESC=user name or pass is error"; return; } log.write("end check user name and password.", Log::INFO); if( userType == 0 ) { ackCode = "ACK:LOGIN:RETN=0,DESC=success,RESULT=-1|-1"; return; } //////////////////////获取权限数据 log.write("begin get permission data.", Log::INFO); if( getPermissionData() == false) { ackCode = "ACK:LOGIN:RETN=8,DESC=system internal error,cannot get permissionData from database."; return; } log.write("end get permission data.", Log::INFO); ackCode = "ACK:LOGIN:RETN=0,DESC=success,RESULT=" + permissionData; log.write("end Auth::Do.", Log::INFO); }
void DeleteVM::Do() { String logContent; log.write("begin DeleteVM::Do().", Log::INFO); //参数检查 log.write("begin process parameter.", Log::INFO); if( getPara() == false) { ackCode = "ACK:DELETE VM:RETN=4,DESC=parameters error"; return; } log.write("end process parameter.", Log::INFO); //检测虚拟机是否存在 if( isVMExist() == false) { ackCode = "ACK:DELETE VM:RETN=1001,DESC=vm is not exist"; return; } //鉴权 if( checkRight( vmID ) == false ) { ackCode = "ACK:DELETE VM:RETN=14,DESC=no right"; return; } if( isVMStarted() == true ) { ackCode = "ACK:DELETE VM:RETN=1002,DESC=vm is running,please close it first"; return; } if( getNFSInfo() == false ) { ackCode = "ACK:DELETE VM:RETN=8,DESC=system internal error"; return; } if( mountNFS() == 1 ) { ackCode = "ACK:DELETE VM:RETN=8,DESC=system internal error"; return; } if ( deleteNATRule() == false ) { ackCode = "ACK:DELETE VM:RETN=8,DESC=system internal error,delete nat rule failed."; return; } if( delVMFile() == false ) { ackCode = "ACK:DELETE VM:RETN=8,DESC=system internal error,delete vm files error."; return; } if( applySC2FreeDisk() == false ) { ackCode = "ACK:DELETE VM:RETN=8,DESC=system internal error,free disk space error."; return; } delVMFromDB(); ackCode = "ACK:DELETE VM:RETN=0,DESC=success"; }
unsigned long generate_parameter(char *in){ unsigned long hinjRetParam; char *hinjNext; char *hinjToken; int hinjCounter = 0; int hinjCounter2 = 0; unsigned long hinjValue[10] = {0}; /* User-specified values in configuration (e.g., minimal and maximal range values, fixed parameter values) for struct parameter members, pro hypercall */ char hinjToAppend[LOG_MAX]; /* String used for logging purposes */ hinjNext = in; if(in == NULL) { return -1; } if(strstr(hinjNext, "!") != NULL) { /* Processing user-defined struct hypercall parameter */ hinjCounter = 0; strcpy(hinjToAppend, ":struct:");strcat(hinjLog, hinjToAppend); while((hinjToken=strsep(&hinjNext,"!")) != NULL) { hinjCounter++; if (hinjCounter!=1 && hinjCounter!=2) { /* If hinjCounter is 1 or 2, hinjToken does not store struct member value (hinjCounter == 2 --- the name of the struct passed as a parameter) */ if((hinjCounter%2) == 1) { strncpy(hinjMembers[hinjCounter-3-hinjCounter2],hinjToken,20); strcpy(hinjToAppend, hinjToken);strcat(hinjToAppend, ":");strcat(hinjLog, hinjToAppend); hinjCounter2++; } else { hinjValue[hinjCounter-3-hinjCounter2] = getPara(hinjToken); snprintf(hinjToAppend,LOG_MAX+1,"%lu:",hinjValue[hinjCounter-3-hinjCounter2]); strcat(hinjLog, hinjToAppend); } } } /* Constructing struct parameters for a given hypercall */ /* TODO: strcmp with struct name, i.e., hinjToken when hinjcCounter ==2 */ /* struct trap_info */ if(strcmp(hinjMembers[0],"vector") == 0 && strcmp(hinjMembers[1],"flags") == 0 && strcmp(hinjMembers[2],"cs") == 0 && strcmp(hinjMembers[3],"address") == 0) { FILL_STRUCTARGS4(trap_info, vector, hinjValue[0], flags, hinjValue[1], cs, hinjValue[2], address, hinjValue[3]) } /* struct physdev_get_free_pirq */ else if(strcmp(hinjMembers[0],"type") == 0) { FILL_STRUCTARGS1(physdev_get_free_pirq, type, hinjValue[0]) } /* struct gnttab_set_version */ else if(strcmp(hinjMembers[0],"version") == 0) { FILL_STRUCTARGS1(gnttab_set_version, version, hinjValue[0]) } /* struct xen_memory_exchange */ else if(strcmp(hinjMembers[0],"in.nr_extents") == 0 && strcmp(hinjMembers[1],"in.extent_order") == 0 && strcmp(hinjMembers[2],"in.extent_start") == 0 && strcmp(hinjMembers[3],"in.domid") == 0 && strcmp(hinjMembers[4],"out.nr_extents") == 0 && strcmp(hinjMembers[5],"out.extent_order") == 0 && strcmp(hinjMembers[6],"out.extent_start") == 0 && strcmp(hinjMembers[7],"out.domid") == 0) { FILL_STRUCTARGS8(xen_memory_exchange, in.nr_extents, hinjValue[0], in.extent_order, hinjValue[1], in.extent_start, hinjValue[2], in.domid, hinjValue[3], out.nr_extents, hinjValue[4], out.extent_order, hinjValue[5], out.extent_start, hinjValue[6], out.domid, hinjValue[7]) } else { printk(KERN_ERR "Failed to allocate struct as hypercall parameter. Probably invalid user input.\n"); printk(KERN_ERR "0 member: %s value: %lu\n", hinjMembers[0], hinjValue[0]); printk(KERN_ERR "1 member: %s value: %lu\n", hinjMembers[1], hinjValue[1]); printk(KERN_ERR "2 member: %s value: %lu\n", hinjMembers[2], hinjValue[2]); printk(KERN_ERR "3 member: %s value: %lu\n", hinjMembers[3], hinjValue[3]); hinjStructAddr = 0; /* 0x0 virtual memory address in case struct allocation has failed */ } hinjRetParam = hinjStructAddr; }