#!/usr/bin/perl use DBI; use CGI; use locale; #Needed for the lc and ucfirst functions use strict; use Digest::MD5 qw(md5 md5_hex md5_base64); use POSIX; use URI::Escape; use mysql; use errorcapture; require 'common.pl'; my $myid = "teamNames.html"; my $myversion = "2014.8.10.1.11910"; my ($errMsg, $focus); my $query = new CGI; my $errorobj = new errorcapture(); $errorobj->setFile($myid.$myversion); my ($dbh, $sth, $sql, $rows); my $sqlobj = new mysql(); $dbh = $sqlobj->MySqlLogon(); ################ #User Verification my %cookies = &getCookies; # store cookies in %cookies my $cookieID = $cookies{uid}; my $key = $cookies{key}; if ("teamNames.html" eq "login.pl") { if ($cookieID && $key) { if (defined $dbh) { $sql = qq{ SELECT userKey FROM session WHERE userKey = ? AND cookieID = ? AND logoutTime >= now() }; eval { $rows = $dbh->selectrow_array($sql, {}, $key, $cookieID); }; if ($@) { $errorobj->writeerror($@, $sql); } if ($rows != 0){ print $query->redirect(-location => '/cgi-bin/datapages/welcome.pl'); $sqlobj->MySqlLogoff(); exit; } ################ } else { print $query->header(); $errorobj->writeerror($sqlobj->errorstring); $errorobj->webFatal("An error log has been started. A fatal program error occurred and halted the application."); } } } print $query->header(); my $search = substr($query->param('searchText'), 0, 50); my $sportKey = substr($query->param('sportKey'), 0, 4); my $start = substr($query->param('start'), 0, 4); my $rows = substr($query->param('rows'), 0, 4); my $errMsg1 = "Only text values A to Z, numbers 0 to 9, the underscore, period, space and hyphen are allowed"; my $errMsg2 = "An unrecoverable error has occured. Please search again."; if ($sportKey =~ /[^\d]/g) { $errMsg = $errMsg2; } elsif ($start =~ /[^\d]/g) { $errMsg = $errMsg2; } elsif ($rows =~ /[^\d]/g) { $errMsg = $errMsg2; } my $queryLimit; if ($start) { $queryLimit = "LIMIT ".($start*100-100).",".($start*100); } my @queryCriteria = (); my ($fixsearch, $likesearch, $sql_clause); my ($searcharr, $sportarr); if (!$errMsg) { if ($search) { $likesearch = $dbh->quote("%".$search."%"); } if ( $search ) { push @queryCriteria, " (ls.teamName LIKE ".$likesearch.")"; } if ($sportKey) { push @queryCriteria, "ls.sportKey = ".$sportKey; } $sql_clause = join(" AND ", @queryCriteria); if ($sql_clause) { $sql_clause = "AND (".$sql_clause.")"; } $sql = qq{ SELECT ls.teamName, sp.sportName FROM teamNameList ls, sport sp WHERE sp.sportKey = ls.sportKey $sql_clause ORDER BY ls.teamName $queryLimit }; eval { $sth = $dbh->prepare($sql); $sth->execute(); if (!$start) { $rows = $sth->rows; } $searcharr = $sth->fetchall_arrayref(); $sth->finish(); }; if ($@) { $errorobj->writeerror($@, $sql); } $sql = qq{ SELECT DISTINCT sp.sportKey, CONCAT(sp.sportName, ' (', COUNT(*), ')') FROM teamNameList tnl LEFT JOIN sport sp ON sp.sportKey = tnl.sportKey GROUP BY sp.sportKey ORDER BY sp.sportName }; eval { $sth = $dbh->prepare($sql); $sth->execute(); $sportarr = $sth->fetchall_arrayref(); $sth->finish(); }; if ($@) { $errorobj->writeerror($@, $sql); } } print < Giant List of Sport Team Names, Sports management, team websites, find players, teams and leagues A Good List of Sports Team Names for all types of sports
 
GO























}; print qq{
SPORTS TEAM NAME SEARCH
Looking for a teams that play }; print <
A good well rounded list of team names for various sports that is easily searchable. We are sure that within a few clicks you will have the perfect team name for whatever sport you play.
This list of sport team names have been compiled over a number of years and provides a central way to locate that perfect name for your new team. If you have name suggestions please send them in we are always looking for new suggestions for new team names that can be added to the generator.

Search Results
EOT my $pageDisplay; if ($rows == 0) { print qq{ }; } else { print qq{ \n"; my $hirowcnt = nhimult(100, $rows) / 100; if ($hirowcnt > 1) { $pageDisplay = qq{ \n"; } else { print qq{\n}; } print qq{\n}; } print qq{
 
Sorry, no team nanes found.
 
Team Names found: $rows
}; if (!$start) { $start=1; my $endRow = 100; $endRow = $rows if ($endRow > $rows); print qq{
Displaying Rows: 1-$endRow
}; } else { my $endRow = $start*100; $endRow = $rows if ($endRow > $rows); my $startrow = $start * 100 - 99; print qq{
Displaying Rows: $startrow-$endRow
}; } print "
Results Page: }; my $dispStart; #Display start is the number that starts the search results. ex. 1 2 3 4 5, or 3 4 5 6 7 if ($start <= 4) { $dispStart = 1; } else { $dispStart = $start - 4; if ($hirowcnt-$dispStart < 10) { $dispStart = $hirowcnt - 9; if ($dispStart < 1) { $dispStart = 1}; } } my $lstlen = 1; if ($start != 1) { my $pstart = $start-1; $pageDisplay .= qq{Previous  }; } for (my $y=$dispStart;$y<=$hirowcnt;++$y) { if ($y == $start) { $pageDisplay .= qq{$y  }; } else { $pageDisplay .= "".$y."  "; } ++$lstlen; if ($lstlen > 10) { last; } } if ($start != $hirowcnt) { my $pstart = $start+1; $pageDisplay .= qq{Next  }; } $pageDisplay .= qq{
}; my $tmpDisplay = $pageDisplay; $tmpDisplay =~ s//imgtopPRE/g; $tmpDisplay =~ s//imgtopNEX/g; print $tmpDisplay; print "

}; my $i=1; foreach my $row (@$searcharr) { my ($teamName, $sportName) = @$row; print qq{}; if ($i%4 == 0) { print qq{\n}; } ++$i; if ($i > 100) { last; } } $pageDisplay =~ s//imgbotPRE/g; $pageDisplay =~ s//imgbotNEX/g; print <
  $teamName  
$pageDisplay
 
Copyright © 2014 SpareSports Productions.
All Rights Reserved.
Team/Spare Search Version 7 Build 12.22
EOT $sqlobj->MySqlLogoff(); 1;