Block people from Website if they have a domain name

From Hack Wars Wiki

Jump to: navigation, search
Information for the Editing Block people from Website if they have a domain name Script
Script Editing Block people from Website if they have a domain name
API HTTP
Cost $1,565
Level 40
CPU Usage 10
Description Allows a player to block people who have a domain with .hw at the end from seeing their website.
Output "Player.hw has been blocked from your store for having a domain name!.".


//Programmed by Vengeance
 
int main()
{
 
      string file = "";
 
 
      string IP = getVisitorIP();
      string alphabet[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"  };
 
      boolean alm = false;
 
      int lets = length(alphabet);
      int ipLen = strlen(IP);
 
      IP = toUpper(IP);
      string backup = IP;
      string holder[];
 
     holder = split(backup, char(32));
 
     for(int x = 0; x <= length(holder); x++)
     {
           for (int x1 = 0; x1 <= length(alphabet); x1++)
           {
                  if (holder[x] == alphabet[x1])
                  {
                             alm = true;
                  }
           }
     }
 
    if (alm == true)
    {
           logMessage(IP + " has been blocked from your store for having a domain name!");
           hideStore();
    }
    else
    {
          writeLine(file, getDate() + ":" + IP); 
    }
 
}

--Vengeance 9:43PM 14.December 2009


simpler solution

by werty using ltlwinters isDomain()
added else branch and website content: Silverlight

Information for the Block .hw IP'd people on websites Script
Script Block .hw IP'd people on websites
API HTTP
Cost $1,765
Level 40
CPU Usage 10
Description Allows a player to block people who have a domain with .hw at the end from seeing their website.
Output "Your banned because you have a domain!" or "Hello visitor. lorem ipsum.".


boolean isDomain(string ip){ 
    return (indexOf(ip,".hw",0)!=-1);
}
int main() {
string visitor = getVisitorIP();
string content;
if (isDomain(visitor) == true) { 
content="Your banned because you have a domain!"; //tell the visitor that he is banned
hideStore(); //disallow selling items to domain users.
}
else {
content="Hello visitor. lorem ipsum."; //IP visitors get the usual content
}
replaceContent("key", content);
}

see replaceContent()

Your website will have the following content only:

<?key?>
Personal tools