<?
    $cutoffHour 
"23";    //EST hour to cutoff all entries at
    
$wordsPerDay "5";    //Number of words that must be entered each day
    
$minWordLength "4";    //Custom Variable used in this file

    //HTML Text to output on entry page describing these rules.
    
$rulesText "<ul>
<li>Words must be $minWordLength or more letters long.</li>
<li>Words must be valid SOWPODS scrabble words.</li>
<li>You can't use the same word more than once.</li>
<li>Scoring is based on scrabble score of word + bonus points for more popular words.</li>
<li><a href='include/rules.d/normal.phps' target='_blank'>source</a></li>
</ul>"
;

    
//Function for word validation.  Must return false if invalid word, true if valid
    //Takes one argument, a strtolower'd word submitted on entry page.
    
function checkWord($chkWord)
    {
        global 
$minWordLength$previousWords,$wordDayHash;

        if ( 
strlen($chkWord) < $minWordLength )
        {
            echo 
"Word must be at least $minWordLength letters long<br>";
            return 
false;
        }

        if ( 
in_array($chkWord$previousWords) )
        {
            
$dayUsed '';
            
$DAYS = array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
            foreach(
$DAYS as $_day) {
                if (
array_key_exists($_day,$wordDayHash) && in_array($chkWord,$wordDayHash[$_day])) {
                    
$dayUsed $_day;
                    break;
                }
            }
            echo 
"$chkWord already used this round for day: $dayUsed<br>";
            return 
false;
        }

        
$valid sowpodsCheck($chkWord);
        if ( 
$valid === false )
        {
            echo 
"$chkWord not in SOWPODS<br>";
            return 
false;
        }

        return 
true;
    }

    
//Function for scoring each word.  Must return the score of the word, always >= 0
    //Takes two arguments, the word to score and the number of times it was in the timeline
    
function checkScore($theWord$used$popularity true)
    {
        
$points["a"] = 1;
        
$points["b"] = 3;
        
$points["c"] = 3;
        
$points["d"] = 2;
        
$points["e"] = 1;
        
$points["f"] = 4;
        
$points["g"] = 2;
        
$points["h"] = 4;
        
$points["i"] = 1;
        
$points["j"] = 8;
        
$points["k"] = 5;
        
$points["l"] = 1;
        
$points["m"] = 3;
        
$points["n"] = 1;
        
$points["o"] = 1;
        
$points["p"] = 3;
        
$points["q"] = 10;
        
$points["r"] = 1;
        
$points["s"] = 1;
        
$points["t"] = 1;
        
$points["u"] = 1;
        
$points["v"] = 4;
        
$points["w"] = 4;
        
$points["x"] = 8;
        
$points["y"] = 4;
        
$points["z"] = 10;

        
$score 0;
        if ( 
$used != )
        {
            
$letters str_split($theWord);
            while ( list(,
$letter) = each($letters) )
            {
                if ( 
ereg("[a-z]"$letter) )
                {
                    
$score += $points[$letter];
                }
            }
        }
        if ( 
$popularity )
        {
            
$score += ($used 100);
        }
        return 
$score;
    }
?>