/** * Initialize OpenSSL * * @param array $params Configuration parameters * @return void */ protected function _openssl_initialize($params) { if (!empty($params['cipher'])) { $params['cipher'] = strtolower($params['cipher']); $this->_cipher_alias($params['cipher']); $this->_cipher = $params['cipher']; } if (!empty($params['mode'])) { $params['mode'] = strtolower($params['mode']); if (!isset($this->_modes['openssl'][$params['mode']])) { log_message('error', 'Encryption: OpenSSL mode ' . strtotupper($params['mode']) . ' is not available.'); } else { $this->_mode = $this->_modes['openssl'][$params['mode']]; } } if (isset($this->_cipher, $this->_mode)) { // This is mostly for the stream mode, which doesn't get suffixed in OpenSSL $handle = empty($this->_mode) ? $this->_cipher : $this->_cipher . '-' . $this->_mode; if (!in_array($handle, openssl_get_cipher_methods(), TRUE)) { $this->_handle = NULL; log_message('error', 'Encryption: Unable to initialize OpenSSL with method ' . strtoupper($handle) . '.'); } else { $this->_handle = $handle; log_message('debug', 'Encryption: OpenSSL initialized with method ' . strtoupper($handle) . '.'); } } }
function checkAnswerComparison($variablename, $var, $answer) { /* error checks numeric comparison */ $at = $var->getAnswerType(); if (inArray($at, array(ANSWER_TYPE_SETOFENUMERATED, ANSWER_TYPE_MULTIDROPDOWN))) { $answerstring = implode(SEPARATOR_SETOFENUMERATED, sort(explode(SEPARATOR_SETOFENUMERATED, $answer))); $eq = trim($this->getFill($variable, $var, SETTING_COMPARISON_EQUAL_TO)); if ($eq != "") { $arr = explode(SEPARATOR_COMPARISON, $eq); foreach ($arr as $a) { $arrstring = implode(SEPARATOR_SETOFENUMERATED, sort(explode(SEPARATOR_SETOFENUMERATED, $a))); if ($arrstring != $answerstring) { return INVALID_ASSIGNMENT; } } } $neq = trim($this->getFill($variable, $var, SETTING_COMPARISON_NOT_EQUAL_TO)); if ($neq != "") { $arr = explode(SEPARATOR_COMPARISON, $neq); foreach ($arr as $a) { $arrstring = implode(SEPARATOR_SETOFENUMERATED, sort(explode(SEPARATOR_SETOFENUMERATED, $a))); if ($arrstring == $answerstring) { return INVALID_ASSIGNMENT; } } } $answers = explode(SEPARATOR_SETOFENUMERATED, $answer); $geq = trim($this->getFill($variable, $var, SETTING_COMPARISON_GREATER_EQUAL_TO)); if ($geq != "") { $arr = explode(SEPARATOR_COMPARISON, $geq); foreach ($arr as $a) { foreach ($answers as $b) { if ($b < $a) { return INVALID_ASSIGNMENT; } } } } $gr = trim($this->getFill($variable, $var, SETTING_COMPARISON_GREATER)); if ($gr != "") { $arr = explode(SEPARATOR_COMPARISON, $gr); foreach ($arr as $a) { foreach ($answers as $b) { if ($b <= $a) { return INVALID_ASSIGNMENT; } } } } $seq = trim($this->getFill($variable, $var, SETTING_COMPARISON_SMALLER_EQUAL_TO)); if ($seq != "") { $arr = explode(SEPARATOR_COMPARISON, $seq); foreach ($arr as $a) { foreach ($answers as $b) { if ($b > $a) { return INVALID_ASSIGNMENT; } } } } $sm = trim($this->getFill($variable, $var, SETTING_COMPARISON_SMALLER)); if ($sm != "") { $arr = explode(SEPARATOR_COMPARISON, $sm); foreach ($arr as $a) { foreach ($answers as $b) { if ($b >= $a) { return INVALID_ASSIGNMENT; } } } } return $this->checkAnswerSetOfEnumeratedChecks($variablename, $var, $answer); } else { if (inArray($at, array(ANSWER_TYPE_CUSTOM, ANSWER_TYPE_RANGE, ANSWER_TYPE_DOUBLE, ANSWER_TYPE_INTEGER, ANSWER_TYPE_ENUMERATED, ANSWER_TYPE_DROPDOWN, ANSWER_TYPE_SLIDER))) { $eq = trim($this->getFill($variable, $var, SETTING_COMPARISON_EQUAL_TO)); if ($eq != "") { $arr = explode(SEPARATOR_COMPARISON, $eq); foreach ($arr as $a) { if (is_numeric(trim($a))) { if (trim($a) != $answer) { return INVALID_ASSIGNMENT; } } } } $neq = trim($this->getFill($variable, $var, SETTING_COMPARISON_NOT_EQUAL_TO)); if ($neq != "") { $arr = explode(SEPARATOR_COMPARISON, $neq); foreach ($arr as $a) { if (is_numeric(trim($a))) { if (trim($a) == $answer) { return INVALID_ASSIGNMENT; } } } } $geq = trim($this->getFill($variable, $var, SETTING_COMPARISON_GREATER_EQUAL_TO)); if ($geq != "") { $arr = explode(SEPARATOR_COMPARISON, $geq); foreach ($arr as $a) { if (is_numeric(trim($a))) { if ($answer < trim($a)) { return INVALID_ASSIGNMENT; } } } } $gr = trim($this->getFill($variable, $var, SETTING_COMPARISON_GREATER)); if ($gr != "") { $arr = explode(SEPARATOR_COMPARISON, $gr); foreach ($arr as $a) { if (is_numeric(trim($a))) { if ($answer <= trim($a)) { return INVALID_ASSIGNMENT; } } } } $seq = trim($this->getFill($variable, $var, SETTING_COMPARISON_SMALLER_EQUAL_TO)); if ($seq != "") { $arr = explode(SEPARATOR_COMPARISON, seq); foreach ($arr as $a) { if (is_numeric(trim($a))) { if ($answer > trim($a)) { return INVALID_ASSIGNMENT; } } } } $sm = trim($this->getFill($variable, $var, SETTING_COMPARISON_SMALLER)); if ($sm != "") { $arr = explode(SEPARATOR_COMPARISON, $sm); foreach ($arr as $a) { if (is_numeric(trim($a))) { if ($answer >= trim($a)) { return INVALID_ASSIGNMENT; } } } } } else { if (inArray($at, array(ANSWER_TYPE_CUSTOM, ANSWER_TYPE_STRING, ANSWER_TYPE_OPEN))) { $eq = trim($this->getFill($variable, $var, SETTING_COMPARISON_EQUAL_TO)); if ($eq != "") { $arr = explode(SEPARATOR_COMPARISON, $eq); foreach ($arr as $a) { $variable = str_replace(" ", "", $a); $vartemp = $this->getVariableDescriptive($variable); if ($vartemp->getVsid() == "") { // if not a variable, then we assume it is a literal text if ($answer != trim($a)) { return INVALID_ASSIGNMENT; } } } } $neq = trim($this->getFill($variable, $var, SETTING_COMPARISON_NOT_EQUAL_TO)); if ($neq != "") { $arr = explode(SEPARATOR_COMPARISON, $neq); foreach ($arr as $a) { $variable = str_replace(" ", "", $a); $vartemp = $this->getVariableDescriptive($variable); if ($vartemp->getVsid() == "") { // if not a variable, then we assume it is a literal text if ($answer == trim($a)) { return INVALID_ASSIGNMENT; } } } } $eq = trim($this->getFill($variable, $var, SETTING_COMPARISON_EQUAL_TO_IGNORE_CASE)); if ($eq != "") { $arr = explode(SEPARATOR_COMPARISON, $eq); foreach ($arr as $a) { $variable = str_replace(" ", "", $a); $vartemp = $this->getVariableDescriptive($variable); if ($vartemp->getVsid() == "") { // if not a variable, then we assume it is a literal text if (strtoupper($answer) != strtotupper(trim($a))) { return INVALID_ASSIGNMENT; } } } } $neq = trim($this->getFill($variable, $var, SETTING_COMPARISON_NOT_EQUAL_TO_IGNORE_CASE)); if ($neq != "") { $arr = explode(SEPARATOR_COMPARISON, $neq); foreach ($arr as $a) { $variable = str_replace(" ", "", $a); $vartemp = $this->getVariableDescriptive($variable); if ($vartemp->getVsid() == "") { // if not a variable, then we assume it is a literal text if (strtoupper($answer) == strtoupper(trim($a))) { return INVALID_ASSIGNMENT; } } } } } else { if (inArray($at, array(ANSWER_TYPE_DATE, ANSWER_TYPE_DATETIME, ANSWER_TYPE_TIME))) { $eq = trim($this->getFill($variable, $var, SETTING_COMPARISON_EQUAL_TO)); if ($eq != "") { $arr = explode(SEPARATOR_COMPARISON, $eq); foreach ($arr as $a) { $variable = str_replace(" ", "", $a); $vartemp = $this->getVariableDescriptive($variable); if ($vartemp->getVsid() == "") { // if not a variable, then we assume it is a literal text if ($at == ANSWER_TYPE_TIME) { $a = date("Y-m-d") . " " . $a; } if ($t = strtotime($a)) { if (strtotime($answer) != $t) { return INVALID_ASSIGNMENT; } } } } } $neq = trim($this->getFill($variable, $var, SETTING_COMPARISON_NOT_EQUAL_TO)); if ($neq != "") { $arr = explode(SEPARATOR_COMPARISON, $neq); foreach ($arr as $a) { $variable = str_replace(" ", "", $a); $vartemp = $this->getVariableDescriptive($variable); if ($vartemp->getVsid() == "") { // if not a variable, then we assume it is a literal text if ($at == ANSWER_TYPE_TIME) { $a = date("Y-m-d") . " " . $a; } if ($t = strtotime($a)) { if (strtotime($answer) == $t) { return INVALID_ASSIGNMENT; } } } } } $geq = trim($this->getFill($variable, $var, SETTING_COMPARISON_GREATER_EQUAL_TO)); if ($geq != "") { $arr = explode(SEPARATOR_COMPARISON, $geq); foreach ($arr as $a) { $variable = str_replace(" ", "", $a); $vartemp = $this->getVariableDescriptive($variable); if ($vartemp->getVsid() == "") { // if not a variable, then we assume it is a literal text if ($at == ANSWER_TYPE_TIME) { $a = date("Y-m-d") . " " . $a; } if ($t = strtotime($a)) { if (strtotime($answer) < $t) { return INVALID_ASSIGNMENT; } } } } } //echo 'yyyyy'; $gr = trim($this->getFill($variable, $var, SETTING_COMPARISON_GREATER)); //echo "<hr>" . $var->getComparisonGreater() . '----' . $gr; if ($gr != "") { $arr = explode(SEPARATOR_COMPARISON, $gr); foreach ($arr as $a) { $variable = str_replace(" ", "", $a); $vartemp = $this->getVariableDescriptive($variable); if ($vartemp->getVsid() == "") { // if not a variable, then we assume it is a literal text if ($at == ANSWER_TYPE_TIME) { $a = date("Y-m-d") . " " . $a; } if ($t = strtotime($a)) { if (strtotime($answer) <= $t) { return INVALID_ASSIGNMENT; } } } } } $seq = trim($this->getFill($variable, $var, SETTING_COMPARISON_SMALLER_EQUAL_TO)); if ($seq != "") { $arr = explode(SEPARATOR_COMPARISON, $seq); foreach ($arr as $a) { $variable = str_replace(" ", "", $a); $vartemp = $this->getVariableDescriptive($variable); if ($vartemp->getVsid() == "") { // if not a variable, then we assume it is a literal text if ($at == ANSWER_TYPE_TIME) { $a = date("Y-m-d") . " " . $a; } if ($t = strtotime($a)) { if (strtotime($answer) > $t) { return INVALID_ASSIGNMENT; } } } } } $sm = trim($this->getFill($variable, $var, SETTING_COMPARISON_SMALLER)); if ($sm != "") { $arr = explode(SEPARATOR_COMPARISON, $sm); foreach ($arr as $a) { $variable = str_replace(" ", "", $a); $vartemp = $this->getVariableDescriptive($variable); if ($vartemp->getVsid() == "") { // if not a variable, then we assume it is a literal text if ($at == ANSWER_TYPE_TIME) { $a = date("Y-m-d") . " " . $a; } if ($t = strtotime($a)) { if (strtotime($answer) >= $t) { return INVALID_ASSIGNMENT; } } } } } } } } } return VALID_ASSIGNMENT; }
function cmp_league($a,$b){ $sports = array('NFL' => 0, 'NBA' => 1, 'MLB' => 2, 'CFB' => 3, 'NHL' => 4, 'PGA' => 5, 'CBB' => 6); $compare = 0; if( $compare === 0 && $a->priority != $b->priority ) { $compare = $a->priority > $b->priority ? -1 : +1; } if( $compare === 0 && $a->first_game_cutoff != $b->first_game_cutoff ) { $compare = $a->first_game_cutoff < $b->first_game_cutoff ? -1 : +1; } if( 0 && $compare === 0 ) { if( isset( $sports[ strtotupper($a->sport) ] ) ) { $a->sport_priority = $sports[ strtotupper($a->sport) ]; }else { $a->sport_priority = 7; } if( isset( $sports[ strtotupper($b->sport) ] ) ) { $b->sport_priority = $sports[ strtotupper($b->sport) ]; }else { $b->sport_priority = 7; } if( $a->sport_priority != $b->sport_priority ) { $compare = $a->sport_priority < $b->sport_priority ? -1 : +1; } } if( $compare === 0 && $a->entry_fee != $b->entry_fee ) { $compare = $a->entry_fee < $b->entry_fee ? -1 : +1; } return $compare; }