Szerző Téma: IP szûrõ  (Megtekintve 1399 alkalommal)

IP szûrõ
« Dátum: 2011. Szeptember 02. - 19:58:50 »
+6 Show voters
Írtam egy függvényt, mellyel a szövegen belül elvileg elég jól meg lehet találni az IP helyét. Mellékeltem egy szkriptet is.
ipfind
Paraméterek:
 
  • string[] - a szöveg, amelyen belül keresni szeretnénk

  • start - ahonnan a keresést indítani szeretnénk

  • &iplen - ha szükségünk van az ip hosszára, akkor ebbe írja bele


Visszatérés:
 
  • Ha található IP a szövegben, akkor annak kezdõkaraktere, ha pedig nem, akkor -1.

 
stock ipfind(const string[], start = 0, &iplen = -1)
{
new
    pos = -1,
ch = start,
Float:nums = 0,
Float:dots = 0;
while(string[ch++])
{
    if(string[ch] == \'\\0\' || string[ch] == \' \')
{
   continue;
}
if(\'0\' <= string[ch] <= \'9\')
{
    if(pos < 0)
   {
      pos = ch;
   }
   if(dots >= 3)
   {
       iplen = ch - pos;
   }
   nums++;
   if(nums > 3)
   {
            if(floatround(nums / dots) < 2)
      {
          nums = 0;
           dots = 0;
         pos = -1;
         iplen = -1;
         continue;
      }
   }
   continue;
}
else if(string[ch] == \'.\')
{
   if(nums > 0)
   {
      dots++;
      if(dots > 3)
      {
          nums = 0;
            dots = 0;
         pos = -1;
         iplen = -1;
         continue;
      }
      if(nums > 3)
      {
         if((floatround(nums / dots) < 2))
          {
              nums = 0;
              dots = 0;
            pos = -1;
            iplen = -1;
            continue;
         }
      }
   }
   else
   {
       if(dots > 0)
       {
           nums = 0;
            dots = 0;
         pos = -1;
         iplen = -1;
         continue;
      }
   }
   continue;
}
else
{
           if(0 < nums < 8 || 0 < dots < 3)
    {
         nums = 0;
          dots = 0;
      pos = -1;
      iplen = -1;
            }
            continue;
        }
}
if(nums >= 8)
{
if(floatround(nums / dots) < 2)
{
    nums = 0;
     dots = 0;
   pos = -1;
   iplen = -1;
}
}
else
{
    nums = 0;
dots = 0;
pos = -1;
iplen = -1;
}
if(iplen) iplen++;
return pos;
}

 
Szkript:
[pawn]// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
// ipfind függvényt ide másold
stock replacestring(source[], string1[], string2[])
{
new
    pos;
    pos = strfind(source, string1);
while(pos != -1)
{
   strdel(source, pos, pos + strlen(string1));
   strins(source, string2, pos, strlen(string2));
   pos = strfind(source, string1);
}
return 1;
}
public OnPlayerText(playerid, text[])
{
new
    len,
   pos = ipfind(text, 0, len);
if(pos > -1)
{
    new
        ip[32];
   strmid(ip, text, pos, pos + len, sizeof(ip));
   replacestring(text, ip, \"[REKLÁM NINCS]\");
}
return 1;
}[/pawn]
« Utoljára szerkesztve: 2011. November 12. - 18:23:17 írta APC »

IP szûrõ
« Válasz #1 Dátum: 2011. Szeptember 02. - 20:07:45 »
0 Show voters
szép munka :P
GRT GRT..
Ment a +! :D

herban

  • Vendég
IP szûrõ
« Válasz #2 Dátum: 2011. Szeptember 03. - 00:48:11 »
0 Show voters
hasznos jó lett

IP szûrõ
« Válasz #3 Dátum: 2011. Szeptember 03. - 07:00:14 »
0 Show voters
Szép Munka! :D Grat! ;D

Nem elérhető JackBronson

  • 1499
  • ??
    • Profil megtekintése
IP szûrõ
« Válasz #4 Dátum: 2011. Szeptember 05. - 16:32:03 »
0 Show voters
Ha nem baj én eszt felhasználom  :P
Am jólett gratulálok.

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal