Search Results

Search found 168 results on 7 pages for 'strcmp'.

Page 4/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • Programmatically closing a dialog box - win32 [migrated]

    - by user1697579
    I'm working on an application to detect a pop-up dialog and then automatically dismiss it. I'm writing this as a C++/Win32 app. The dialog box is generated by IE 7 and I can detect the window, but several methods to get the OK button to "click" have failed. Doing searches for other people's solutions, sending these messages to the button handle seems to have worked in a lot of situations: PostMessage( handle, WM_LBUTTONDOWN, 0, 0 ); PostMessage( handle, WM_LBUTTONUP, 0, 0 ); PostMessage( handle, BM_SETSTATE, 1, 0 ); It has no effect on the button state in my tests though. I can send tab characters to the main window and see that the OK button gets focus, but then sending return characters does nothing. To learn more about this I used Spy++ to get information about the window hierarchy and what messages are delievered when I manually click the OK button. Looking at the message log and reading about WM_MOUSEACTIVATE seamed to offer a solution. The log info shows that 0002166C was the button window. So in my code I tried this: GetClassNameA( handle, str, str_size ); if( strcmp( str, "Internet Explorer_Server" ) != 0 ) return TRUE; // Not the window we're interested in. // Send a message to activate the button window and have it process a mouse click. PostMessage( handle, WM_MOUSEACTIVATE, (WPARAM) dialog_handle, MAKELPARAM( HTCLIENT, WM_LBUTTONDOWN ); Based on the window hierarchy and message log, I think the window with the class name "Internet Explorer_Server" is the button. Maybe I'm wrong, because it does seem like an odd class name for a button... Below is a link to the window hierarchy image, message log when I manually click the OK button. Last is the code that's executed on a 1 second timer ticket, looking for the window. Any insight and help is appreciated! Image of the window hierarchy, source, window messages, and test dialog source are available here: https://sites.google.com/site/matthewmillersmiscellanea/Home/

    Read the article

  • a c++ program for task scheduling [closed]

    - by scheduling
    This is the code which I made but I am not able to correct the mistake in the code. Please correct the mistake in my code. #include<unistd.h> #include<stdio.h> #include<stdlib.h> #include<time.h> #include<string.h> int main() { char *timetoken; char currtime[7]; char schedtime[7]; int i; struct tm *localtimeptr; strcpy(schedtime,"15:25:00"); while(6!=9) { time_t lt; sleep(1); lt = time(NULL); localtimeptr = localtime(<); timetoken=strtok(asctime(localtimeptr)," "); for(i=1;i<5;i++) timetoken=strtok('\0'," "); if(i==3) { strcpy(currtime,timetoken); } } printf("The current time is: %s\n",currtime); printf("We are waiting for: %s\n",schedtime); if(!strcmp(currtime,schedtime)) { printf("Time to do stuff \n"); system("C:\PROJECT X"); } getch(); return 0; }

    Read the article

  • a c++ code for scheduling tasks [closed]

    - by scheduling
    This code has no errors but then when i execute it, there is no output and the program automatically shuts down saying the program has stopped working. #include<unistd.h> #include<stdio.h> #include<stdlib.h> #include<time.h> #include<string.h> int main() { char *timetoken; char currtime[7]; char schedtime[7]; int i; struct tm *localtimeptr; strcpy(schedtime,"15:25:00"); while(6!=9) { time_t lt; sleep(1); lt = time(NULL); localtimeptr = localtime(lt); timetoken=strtok(asctime(localtimeptr)," "); for(i=1;i<5;i++) timetoken=strtok('\0'," "); if(i==3) { strcpy(currtime,timetoken); } } printf("The current time is: %s\n",currtime); printf("We are waiting for: %s\n",schedtime); if(!strcmp(currtime,schedtime)) { printf("Time to do stuff \n"); system("C:\PROJECT X"); } getch(); return 0; }

    Read the article

  • Display problem after deletion in linked list in C

    - by LuckySlevin
    Hi, actually this was another problem but it changed so I decided to open a new question. My code is typedef struct inner_list { int count; char word[100]; inner_list*next; } inner_list; typedef struct outer_list { char word [100]; inner_list * head; int count; outer_list * next; } outer_list; void delnode(outer_list **head,char num[100])//thanks to both Nir Levy and Jeremy P. { outer_list *temp, *m; m=temp=*head; /*FIX #1*/ while(temp!=NULL) { if(strcmp(temp->word,num)==0) { if(temp==*head) { delinner(temp->head); /* FIX#2 */ *head=temp->next; free(temp); return; } else { delinner(temp->head); /* FIX#2 */ m->next=temp->next; free(temp); return; } } else { m=temp; temp= temp->next; } } printf(" ELEMENT %s NOT FOUND ", num); } void delinner(inner_list *head) { /* FIX#2 */ inner_list *temp; temp=head; while(temp!=NULL) { head=temp->next; free(temp); temp=head; } } void delnode2(outer_list *up,inner_list **head,char num[100]) { inner_list *temp2,*temp, *m; outer_list *p; p = up; while(p!=NULL){m=temp=temp2=p->head; while(temp!=NULL) { if(strcmp(temp->word,num)==0) { if(temp==(*head)) { *head=temp->next; free(temp); return; } else { m->next=temp->next; free(temp); return; } } else { m=temp; temp= temp->next; } } p=p->next; } printf(" ELEMENT %s NOT FOUND ", num); } void print_node(outer_list *parent_node) { while(parent_node!=NULL){ printf("%s\t%d\t", parent_node->word, parent_node->count); inner_list *child_node = parent_node->head; printf("list: "); if(child_node ==NULL){printf("BUARADA");} while (child_node != NULL) { printf("%s-%d", child_node->word,child_node->count); child_node = child_node->next; if (child_node != NULL) { printf("->"); } } printf("\n"); parent_node = parent_node->next; } } While deleting an element from outer list I am also trying the delete the same element from inner_list too. For example: - Let's say aaa is an element of outer_list linked list and let's point it with outer_list *p - This aaa can also be in an inner_list linked list too. (it can be in p-head or another innerlist.) Now, the tricky part again. I tried to apply the same rules with outer_list deletion but whenever i delete the head element of inner_list it gives an error. Where is the wrong thing in print_node or delnode2?

    Read the article

  • Merge Sort issue when removing the array copy step

    - by Ime Prezime
    I've been having an issue that I couldn't debug for quite some time. I am trying to implement a MergeSort algorithm with no additional steps of array copying by following Robert Sedgewick's algorithm in "Algorithm's in C++" book. Short description of the algorithm: The recursive program is set up to sort b, leaving results in a. Thus, the recursive calls are written to leave their result in b, and we use the basic merge program to merge those files from b into a. In this way, all the data movement is done during the course of the merges. The problem is that I cannot find any logical errors but the sorting isn't done properly. Data gets overwritten somewhere and I cannot determine what logical error causes this. The data is sorted when the program is finished but it is not the same data any more. For example, Input array: { A, Z, W, B, G, C } produces the array: { A, G, W, W, Z, Z }. I can obviously see that it must be a logical error somewhere, but I have been trying to debug this for a pretty long time and I think a fresh set of eyes could maybe see what I'm missing cause I really can't find anything wrong. My code: static const int M = 5; void insertion(char** a, int l, int r) { int i,j; char * temp; for (i = 1; i < r + 1; i++) { temp = a[i]; j = i; while (j > 0 && strcmp(a[j-1], temp) > 0) { a[j] = a[j-1]; j = j - 1; } a[j] = temp; } } //merging a and b into c void merge(char ** c,char ** a, int N, char ** b, int M) { for (int i = 0, j = 0, k = 0; k < N+M; k++) { if (i == N) { c[k] = b[j++]; continue; } if (j == M) { c[k] = a[i++]; continue; } c[k] = strcmp(a[i], b[j]) < 0 ? a[i++] : b[j++]; } } void mergesortAux(char ** a, char ** b, int l, int r) { if(r - l <= M) { insertion(a, l, r); return; } int m = (l + r)/2; mergesortAux(b, a, l, m); //merge sort left mergesortAux(b, a, m+1, r); //merge sort right merge(a+l, b+l, m-l+1, b+m+1, r-m); //merge } void mergesort(char ** a,int l, int r, int size) { static char ** aux = (char**)malloc(size * sizeof(char*)); for(int i = l; i < size; i++) aux[i] = a[i]; mergesortAux(a, aux, l, r); free(aux); }

    Read the article

  • Custom array sorting based on instance properties

    - by St. John Johnson
    I'm trying to perform a usort on an array inside an instance of a class. But the sort is dependent on the properties of said instance. Code (which doesn't work): class foo { private $array; private $key; private $dir; function sort() { usort($this->array, array("foo", "orderArray")); } function orderArray($a, $b) { return strcmp($a[$this->key], $b[$this->key]) * $this->dir; } } From the orderArray class, you can't access $key or $dir. The question is, how can I write this so I can?

    Read the article

  • C - array count, strtok, etc

    - by Pedro
    Hi... i have a little problem on my code... HI open a txt that have this: LEI;7671;Maria Albertina da silva;[email protected]; 9;8;12;9;12;11;6;15;7;11; LTCGM;6567;Artur Pereira Ribeiro;[email protected]; 6;13;14;12;11;16;14; LEI;7701;Ana Maria Carvalho;[email protected]; 8;13;11;7;14;12;11;16;14; LEI, LTCGM are the college; 7671, 6567, 7701 is student number; Maria, Artur e Ana are the students name; [email protected], ...@gmail are emails from students; the first number of every line is the total of classes that students have; after that is students school notes; example: College: LEI Number: 7671 Name: Maria Albertina da Silva email: [email protected] total of classes: 9 Classe Notes: 8 12 9 12 11 6 15 7 11. My code: typedef struct aluno{ char sigla[5];//college char numero[80];//number char nome[80];//student name char email[20];//email int total_notas;// total of classes char tot_not[40]; // total classes char notas[20];// classe notes int nota; //class notes char situacao[80]; //situation (aproved or disaproved) }ALUNO; void ordena(ALUNO*alunos, int tam)//bubble sort { int i=0; int j=0; char temp[100]; for( i=0;i<tam;i++) for(j=0;j<tam-1;j++) if(strcmp( alunos[i].sigla[j], alunos[i].sigla[j+1])>0){ strcpy(temp, alunos[i].sigla[j]); strcpy(alunos[i].sigla[j],alunos[i].sigla[j+1]); strcpy(alunos[i].sigla[j+1], temp); } } void xml(ALUNO*alunos, int tam){ FILE *fp; char linha[60];//line int soma, max, min, count;//biggest note and lowest note and students per course count float media; //media of notes fp=fopen("example.txt","r"); if(fp==NULL){ exit(1); } else{ while(!(feof(fp))){ soma=0; media=0; max=0; min=0; count=0; fgets(linha,60,fp); if(linha[0]=='L'){ if(ap_dados=strtok(linha,";")){ strcpy(alunos[i].sigla,ap_dados);//copy to struct // i need to call bubble sort here, but i don't know how printf("College: %s\n",alunos[i].sigla); if(ap_dados=strtok(NULL,";")){ strcpy(alunos[i].numero,ap_dados);//copy to struct printf("number: %s\n",alunos[i].numero); if(ap_dados=strtok(NULL,";")){ strcpy(alunos[i].nome, ap_dados);//copy to struct printf("name: %s\n",alunos[i].nome); if(ap_dados=strtok(NULL,";")){ strcpy(alunos[i].email, ap_dados);//copy to struct printf("email: %s\n",alunos[i].email); } } } }i++; } if(isdigit(linha[0])){ if(info_notas=strtok(linha,";")){ strcpy(alunos[i].tot_not,info_notas); alunos[i].total_notas=atoi(alunos[i].tot_not);//total classes for(z=0;z<=alunos[i].total_notas;z++){ if(info_notas=strtok(NULL,";")){ strcpy(alunos[i].notas,info_notas); alunos[i].nota=atoi(alunos[i].notas); // student class notes } soma=soma + alunos[i].nota; media=soma/alunos[i].total_notas;//doesn't work if(alunos[i].nota>max){ max=alunos[i].nota;;//doesn't work } else{ if(min<alunos[i].nota){ min=alunos[i].nota;;//doesn't work } } //now i need to count the numbers of students in the same college, but doesn't work /*If(strcmp(alunos[i].sigla, alunos[i+1].sigla)=0){ count ++; printf("%d\n", count); here for LEI should appear 2 students and for LTCGM appear 1, don't work }*/ //Now i need to see if student is aproved or disaproved // Student is disaproved if he gets 3 notes under 10, how can i do that? } printf("media %d\n",media); //media printf("Nota maxima %d\n",max);// biggest note printf("Nota minima %d\n",min); //lowest note }i++; } } } fclose(fp); } int main(int argc, char *argv[]){ ALUNO alunos; FILE *fp; int tam; fp=fopen(nomeFicheiro,"r"); alunos = (ALUNO*) calloc (tam, sizeof(ALUNO)); xml(alunos,nomeFicheiro, tam); system("PAUSE"); return 0; }

    Read the article

  • How does Qt implement signals and slots?

    - by anton
    Can someone explain to me the basic idea of Qt signals&slots mechanism IMPLEMENTATION? I want to know what all those Q_OBJECT macros do "in plain C++". This question is NOT about signals&slots usage. added: I know that Qt uses moc compiler to transform Qt-C++ in plain C++. But what does moc do? I tried to read "moc_filename.cpp" files but I have no idea what can something like this mean void *Widget::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_Widget)) return static_cast<void*>(const_cast< Widget*>(this)); return QDialog::qt_metacast(_clname); } Thanks in Advance, anton

    Read the article

  • mysql retrieve duplicate entry

    - by Cypher
    I have a huge text file that I'm importing into a mysql database. The four important tables that I'm using are -- schools (id,name) variables (id, name) var_entries (id, var_id, data) with unique( var_id, data) data (id, school_id, var_ent_id) I have a file that I'm importing into this database. I want every variable to have a unique set of values (hence the unique call) but I also then want to associate the appropriate var_entrie with a school in data. So my question is is there a way to get the appropriate var_ent_id when you a duplicate var_entry is added? I know I can do this with storing the values and using a strcmp but it'd be messy.

    Read the article

  • C++: set of C-strings

    - by Nicholas
    I want to create one so that I could check whether a certain word is in the set using set::find However, C-strings are pointers, so the set would compare them by the pointer values by default. To function correctly, it would have to dereference them and compare the strings. I could just pass the constructor a pointer to the strcmp() function as a comparator, but this is not exactly how I want it to work. The word I might want to check could be part of a longer string, and I don't want to create a new string due to performance concerns. If there weren't for the set, I would use strncmp(a1, a2, 3) to check the first 3 letters. In fact, 3 is probably the longest it could go, so I'm fine with having the third argument constant. Is there a way to construct a set that would compare its elements by calling strncmp()? Code samples would be greatly appreciated.

    Read the article

  • Problem with operator ==

    - by CPPDev
    I am facing some problem with use of operator == in the following c++ program. #include < iostream> using namespace std; class A { public: A(char *b) { a = b; } A(A &c) { a = c.a; } bool operator ==(A &other) { return strcmp(a, other.a); } private: char *a; }; int main() { A obj("test"); A obj1("test1"); if(obj1 == A("test1")) { cout<<"This is true"<<endl; } } What's wrong with if(obj1 == A("test1")) line ?? Any help is appreciated.

    Read the article

  • need identical string comparison function in php and java

    - by steelbytes
    I have sorted list of strings that I move between php and java. to be able to bsearch on this data, I need the same comparison function. any idea what string compare functions I can use that will always give the same result in both? eg php's strcmp() vs java's String.compareTo() yes I know I could make my own string compare that does char by char carefully, but I was hoping there's a simple answer. PS, don't care if case sensitive or not, as long as it is consistant.

    Read the article

  • [C] Signed Hexadecimal string to long int function

    - by Ben
    I am trying to convert a 24bit Hexadecimal string (6 characters) signed in two's complement to a long int in C. This is the function I have come up with: long int hex2li (char string[]) { char *pEnd; long int result = strtol (string, &pEnd, 16); if (strcmp (pEnd, "") == 0) { if (toupper (string[0]) == 'F') { return result - 16777216; } else { return result; } } return LONG_MIN; } Is it valid? Is there a better way of doing this?

    Read the article

  • C Check Substring of a String C

    - by user69514
    I'm trying to check whether or not the second argument in my program is a substring of the first argument. The problem is that it only work if the substring starts with the same letter of the string. EDIT: It must be done in C, not C++. Sorry #include <stdio.h> #include <string.h> int my_strstr( char const *s, char const *sub ) { char const *ret = sub; while ( ret = strchr( ret, *sub ) ) { if ( strcmp( ++ret, sub+1 ) == 0 ) return 1; } return 0; } int main(int argc, char **argv){ if (argc != 3) { printf ("Usage: check <string one> <string two>\n"); } int result = my_strstr(argv[1], argv[2]); if(result == 1){ printf("%s is a substring of %s\n", argv[2], argv[1]); } else{ printf("%s is not a substring of %s\n", argv[2], argv[1]); } return 0; }

    Read the article

  • Valid signed Hex to long function

    - by Ben
    I am trying to convert a 24bit Hexadecimal string (6 characters) signed in two's complement to a long int in C. This is the function I have come up with: long int hex2li (char string[]) { char *pEnd; long int result = strtol (string, &pEnd, 16); if (strcmp (pEnd, "") == 0) { if (toupper (string[0]) == 'F') { return result - 16777216; } else { return result; } } return LONG_MIN; } Is it valid? Is there a better way of doing this?

    Read the article

  • paypal IPN php script

    - by pol
    I just realized that my paypal ipn handler in php doesn't work anymore (and I change nothing), I use the sample php script provided by paypal. I tried to isolate the problem by making several test, and at this time I can say that the problem is not the "VERIFIED" or the "INVALID" thing but comes from these lines: [...] fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { // check the payment_status is Completed [...] Anyone know if paypal change something or why it doesn't work? thanks' ps: if I put my code before all the paypal tests (before the line "if (!$fp)") it just works fine

    Read the article

  • C: getopt with list of acceptable optarg. What is the best practise ?

    - by Xavier Maillard
    Hi, I am writing a C program which is a frontend to a myriad tools. This fronted will be launched like this: my-frontend --action <AN ACTION> As all the tools have the same prefix, let say for this example this prefix is "foo". I want to concatenate "AN ACTION" to this prefix and exec this (if the tool exists). I have written something but my implementation uses strcmp to test that "AN ACTION" is a valid action. Even if this works, I do not like it. So I am looking for a nicer solution that would do the same. The list of possibilities is pretty small (less than 10) and static (the list is "hardcoded") but I am sure there is a more "C-ish" way to do this (using a struct or something like that). As I am not a C expert, I am asking for your help. Regards

    Read the article

  • Sorting array of structs

    - by mrblippy
    Hi, i am having trouble making a method to sort an array of structs. i am tring to sort them in ascending order based on classcode. any help you could give would be appreciated struct unit { char classcode[4]; char *classname; }; void insertion_sort(struct unit u[], int n) { int j, p; struct unit tmp[1]; for(p = 1; p < n; p++) { tmp[0] = u[p]; for(j = p; j > 0 && (strcmp(tmp[j-1].classcode, tmp[p].classcode) > 0); j--) u[j] = u[j-1]; u[j] = tmp[0]; } }

    Read the article

  • Order object simplexml_load_file by field of this.

    - by ronsandova
    Hi i have a problems with simplexml_load_file, i'm not pretty sure how to do to order my array by a $item-padre. I need to do foreach and order by $item-padre.=, i don't know how to do this. function create_sitemap($sitemap){ $xml = file_exists('sitemap.xml') ? $xml = simplexml_load_file('sitemap.xml'): exit('Failed to open sitemal.xml.'); $xml = uasort($xml, function($a,$b){ return strcmp($a-padre, $b-padre); }); foreach ($xml-url as $item) { echo "" . $item-loc. ""; echo "" . $item-padre . ""; } } Thanks in advance.

    Read the article

  • Handling user input in C

    - by Stuart
    In C, I am writing a program which is taking in user input than comparing it to see which output it should use. I am finding it problomatic and was wondering if someone could give me a hand. So far I have: while(cmd[0] != EOF){ fgets(cmd, sizeof(cmd), stdin); /** Takes in user input and stores it in cmd **/ if(cmd[0] == '\n') printf("%s> ", cwd); else if(strcmp(cmd, "ls") == 0) printf("I will list everything"); } Any ideas? Basically it is just ignoring any user input when there is some. P.S. The variable cwd is just a string.

    Read the article

  • Is this considered as using private functions in iPhone dev, and thus illegal?

    - by user153231
    I'm trying to disable scrolling for a UIWebView and the only way i found is using this way: #import <objc/runtime.h> id scroller = [[Webview subviews] lastObject]; int count; Method *method = class_copyMethodList([scroller class], &count); int i; for (i=0; i<count; i++) { if (strcmp(method_getName(method[i]), "setScrollingEnabled:") == 0) break; } IMP test = method_getImplementation(method[i]); test(scroller, @selector(setScrollingEnabled:), NO); Is this considered to be an illegal way of using the iPhone SDK? Can this cause my application to be rejected for the App store?

    Read the article

  • IntelliSense: expression must have integral or enum type

    - by user1743737
    Guys i need someone fix this problem ? when i compile that code i have this error: Error: IntelliSense: expression must have integral or enum type i have problem in this part: Console(0, V("seta sv_hostname " + servername + ";\n")); so how i can fix that if (strncmp(command, V("exec config_mp"), 14) == 0) { if (GAME_MODE == 'D') { CIniReader iniReader(V(".\\teknogods.ini")); char *servername = iniReader.ReadString(V("Settings"),V("Servername"),""); if (strcmp(servername,"") == 0) { info("Server name set to defult."); } else { //Console(0, V("seta scr_teambalance 1;\n")); Console(0, V("seta sv_hostname " + servername + ";\n")); info("server name set to: %s.", servername); } } }

    Read the article

  • C++ shifting bits

    - by Bobby
    I am new to shifting bits, but I am trying to debug the following snippet: if (!(strcmp(arr[i].GetValType(), "f64"))) { dem_content_buff[BytFldPos] = tmp_data; dem_content_buff[BytFldPos + 1] = tmp_data >> 8; dem_content_buff[BytFldPos + 2] = tmp_data >> 16; dem_content_buff[BytFldPos + 3] = tmp_data >> 24; dem_content_buff[BytFldPos + 4] = tmp_data >> 32; dem_content_buff[BytFldPos + 5] = tmp_data >> 40; dem_content_buff[BytFldPos + 6] = tmp_data >> 48; dem_content_buff[BytFldPos + 7] = tmp_data >> 56; } I am getting a warning saying the lines with "32" to "56" have a shift count that is too large. The "f64" in the predicate just means that the data should be 64bit data. How should this be done?

    Read the article

  • Are there any security vulnerabilities in this PHP code?

    - by skorned
    Hi. I just got a site to manage, but am not too sure about the code the previous guy wrote. I'm pasting the login procedure below, could you have a look and tell me if there are any security vulnerabilities? At first glance, it seems like one could get in through SQL injection or manipulating cookies and the ?m= parameter. define ( 'CURRENT_TIME', time ()); / / Current time. define ( 'ONLINE_TIME_MIN', (CURRENT_TIME - BOTNET_TIMEOUT)); / / Minimum time for the status of "Online". define ( 'DEFAULT_LANGUAGE', 'en'); / / Default language. define ( 'THEME_PATH', 'theme'); / / folder for the theme. / / HTTP requests. define ( 'QUERY_SCRIPT', basename ($ _SERVER [ 'PHP_SELF'])); define ( 'QUERY_SCRIPT_HTML', QUERY_SCRIPT); define ( 'QUERY_VAR_MODULE', 'm'); / / variable contains the current module. define ( 'QUERY_STRING_BLANK', QUERY_SCRIPT. '? m ='); / / An empty query string. define ( 'QUERY_STRING_BLANK_HTML', QUERY_SCRIPT_HTML. '? m ='); / / Empty query string in HTML. define ( 'CP_HTTP_ROOT', str_replace ( '\ \', '/', (! empty ($ _SERVER [ 'SCRIPT_NAME'])? dirname ($ _SERVER [ 'SCRIPT_NAME']):'/'))); / / root of CP. / / The session cookie. define ( 'COOKIE_USER', 'p'); / / Username in the cookies. define ( 'COOKIE_PASS', 'u'); / / user password in the cookies. define ( 'COOKIE_LIVETIME', CURRENT_TIME + 2592000) / / Lifetime cookies. define ( 'COOKIE_SESSION', 'ref'); / / variable to store the session. define ( 'SESSION_LIVETIME', CURRENT_TIME + 1300) / / Lifetime of the session. ////////////////////////////////////////////////// ///////////////////////////// / / Initialize. ////////////////////////////////////////////////// ///////////////////////////// / / Connect to the database. if (! ConnectToDB ()) die (mysql_error_ex ()); / / Connecting topic. require_once (THEME_PATH. '/ index.php'); / / Manage login. if (! empty ($ _GET [QUERY_VAR_MODULE])) ( / / Login form. if (strcmp ($ _GET [QUERY_VAR_MODULE], 'login') === 0) ( UnlockSessionAndDestroyAllCokies (); if (isset ($ _POST [ 'user']) & & isset ($ _POST [ 'pass'])) ( $ user = $ _POST [ 'user']; $ pass = md5 ($ _POST [ 'pass']); / / Check login. if (@ mysql_query ( "SELECT id FROM cp_users WHERE name = '". addslashes ($ user). "' AND pass = '". addslashes ($ pass). "' AND flag_enabled = '1 'LIMIT 1") & & @ mysql_affected_rows () == 1) ( if (isset ($ _POST [ 'remember']) & & $ _POST [ 'remember'] == 1) ( setcookie (COOKIE_USER, md5 ($ user), COOKIE_LIVETIME, CP_HTTP_ROOT); setcookie (COOKIE_PASS, $ pass, COOKIE_LIVETIME, CP_HTTP_ROOT); ) LockSession (); $ _SESSION [ 'Name'] = $ user; $ _SESSION [ 'Pass'] = $ pass; / / UnlockSession (); header ( 'Location:'. QUERY_STRING_BLANK. 'home'); ) else ShowLoginForm (true); die (); ) ShowLoginForm (false); die (); ) / / Output if (strcmp ($ _GET [ 'm'], 'logout') === 0) ( UnlockSessionAndDestroyAllCokies (); header ( 'Location:'. QUERY_STRING_BLANK. 'login'); die (); ) ) ////////////////////////////////////////////////// ///////////////////////////// / / Check the login data. ////////////////////////////////////////////////// ///////////////////////////// $ logined = 0, / / flag means, we zalogininy. / / Log in session. LockSession (); if (! empty ($ _SESSION [ 'name']) & &! empty ($ _SESSION [ 'pass'])) ( if (($ r = @ mysql_query ( "SELECT * FROM cp_users WHERE name = '". addslashes ($ _SESSION [' name'])."' AND pass = ' ". addslashes ($ _SESSION [' pass']). " 'AND flag_enabled = '1' LIMIT 1 ")))$ logined = @ mysql_affected_rows (); ) / / Login through cookies. if ($ logined! == 1 & &! empty ($ _COOKIE [COOKIE_USER]) & &! empty ($ _COOKIE [COOKIE_PASS])) ( if (($ r = @ mysql_query ( "SELECT * FROM cp_users WHERE MD5 (name )='". addslashes ($ _COOKIE [COOKIE_USER ])."' AND pass = '". addslashes ($ _COOKIE [COOKIE_PASS]). " 'AND flag_enabled = '1' LIMIT 1 ")))$ logined = @ mysql_affected_rows (); ) / / Unable to login. if ($ logined! == 1) ( UnlockSessionAndDestroyAllCokies (); header ( 'Location:'. QUERY_STRING_BLANK. 'login'); die (); ) / / Get the user data. $ _USER_DATA = @ Mysql_fetch_assoc ($ r); if ($ _USER_DATA === false) die (mysql_error_ex ()); $ _SESSION [ 'Name'] = $ _USER_DATA [ 'name']; $ _SESSION [ 'Pass'] = $ _USER_DATA [ 'pass']; / / Connecting language. if (@ strlen ($ _USER_DATA [ 'language'])! = 2 | |! SafePath ($ _USER_DATA [ 'language']) | |! file_exists ( 'system / lng .'.$_ USER_DATA [' language '].' . php'))$_ USER_DATA [ 'language'] = DEFAULT_LANGUAGE; require_once ( 'system / lng .'.$_ USER_DATA [' language'].'. php '); UnlockSession ();

    Read the article

  • Detect if an instance is running with kernel32::CreateMutexA

    - by moz
    Hello. I'm working on an NSIS installer, and trying to check if a certain application is running before uninstalling. So, I use kernel32::CreateMutexA call. Here is the chunk: System::Call 'kernel32::CreateMutexA(i 0, i 0, t "cmd.exe") i .r1 ?e' Pop $R0 StrCmp $R0 0 +3 MessageBox MB_USERICON "The application is already running." Abort I put it into un.onInit. Trouble is, the process (cmd.exe here) is never detected. Did I miss something? Tx.

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >