Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <sscanf2>
- #include <regex>
- public OnFilterScriptInit(){
- printf("(mailed) Emial marcincotoejst@wp.pl jest %s a email lubie@i. jest %s",(mailed("marcincotoejst@wp.pl") == 1) ? ("Dobry"): ("Zył"), (mailed("lubie@i.") == 1) ? ("Dobry"): ("Zły"));
- printf("(IsMail) Emial marcincotoejst@wp.pl jest %s a email lubie@i. jest %s",(IsMail("marcincotoejst@wp.pl") == 1) ? ("Dobry"): ("Zył"), (IsMail("lubie@i.") == 1) ? ("Dobry"): ("Zły"));
- printf("(IsEmail) Emial marcincotoejst@wp.pl jest %s a email lubie@i. jest %s",(IsEmail("marcincotoejst@wp.pl") == 1) ? ("Dobry"): ("Zył"), (IsEmail("lubie@i.") == 1) ? ("Dobry"): ("Zły"));
- new time;
- time = GetTickCount();
- for( new i; i<5000; i++ ) mailed("marcincotoejst@wp.pl");
- printf("[mailed][dobrze] czas wykonywania %d ms", GetTickCount() - time);
- time = GetTickCount();
- for( new i; i<5000; i++ ) mailed("lubie@i.");
- printf("[mailed][źle] czas wykonywania %d ms", GetTickCount() - time);
- printf(" ");printf(" ");
- time = GetTickCount();
- for( new i; i<5000; i++ ) IsMail("marcincotoejst@wp.pl");
- printf("[IsMail][dobrze] czas wykonywania %d ms", GetTickCount() - time);
- time = GetTickCount();
- for( new i; i<5000; i++ ) IsMail("lubie@i.");
- printf("[IsMail][źle] czas wykonywania %d ms", GetTickCount() - time);
- printf(" ");printf(" ");
- time = GetTickCount();
- for( new i; i<5000; i++ ) IsEmail("marcincotoejst@wp.pl");
- printf("[IsEmail][dobrze] czas wykonywania %d ms", GetTickCount() - time);
- time = GetTickCount();
- for( new i; i<5000; i++ ) IsEmail("lubie@i.");
- printf("[IsEmail][źle] czas wykonywania %d ms", GetTickCount() - time);
- return 1;
- }
- stock mailed(buffer_mail[]) //by drzymalsw
- {
- static mail[2][20];
- if( !sscanf( buffer_mail, "p<@>s[30]s[10]", mail[0], mail[1] ) ){
- if( !sscanf( mail[1], "p<.>s[30]s[10]", mail[0], mail[1] ) ){
- if( strlen(mail[0]) > 1 && strlen( mail[1] ) > 1 ) return 1;
- }
- else return 0;
- } else return 0;
- return 0;
- }
- stock IsMail(const text[])
- {
- static
- RegEx:rMail;
- if(!rMail) rMail = regex_build("[a-zA-Z0-9_\\.]+@([a-zA-Z0-9\\-]+\\.)+[a-zA-Z]{2,4}");
- return regex_match_exid(text, rMail);
- }
- stock IsEmail(txt[]) //by drzymalsw
- {
- new g[5];
- for(new c; txt[c]; c++)
- {
- if(txt[c] == '@')
- {
- if(c==0) return 0;
- if(g[1]) return 0;
- if(g[0]) return 0;
- g[0] = 1;
- continue;
- }
- if(g[0] && txt[c] != '.') g[2] ++;
- if(txt[c] == '.')
- {
- if(c==0) return 0;
- if(c==strlen(txt)) return 0;
- if(!g[0])
- {
- if(g[4]) return 0;
- else
- {
- g[4] = 1;
- continue;
- }
- }
- if(g[1]) return 0;
- if(!g[2]) return 0;
- g[1] = 1;
- continue;
- }
- if(g[1])
- {
- g[3] ++;
- if(g[3] > 3) return 0;
- }
- if(((txt[c] < 65 && (txt[c] > 57 || txt[c] < 48)) || txt[c] > 122 || (txt[c] > 90 && txt[c] < 97)) && txt[c] != '_') return 0;
- }
- if(!g[0] || !g[1]) return 0;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement