/** * Check to see if this impression contains the valid source. * * @param string $limitation The source limitation * @param string $op The operator (either '==' or '!=') * @param array $aParams An array of additional parameters to be checked * @return boolean Whether this impression's source passes this limitation's test. */ function MAX_checkSite_Source($limitation, $op, $aParams = array()) { if (empty($aParams['source'])) { $aParams['source'] = $GLOBALS['source']; } return MAX_limitationsMatchString('source', $limitation, $op, $aParams); }
/** * Check if a value passed into the ad request (through $_REQUEST (so GET/POST/COOKIE) * via a name=value pair matches the limitation configured * * @param string $limitation The variable limitation * @param string $op The operator * @param array $aParams An array of additional parameters to be checked * @return boolean Whether this impression's channel passes this limitation's test. */ function MAX_checkSite_Variable($limitation, $op, $aParams = array()) { if (empty($aParams)) { $aParams = $_REQUEST; } $key = substr($limitation, 0, strpos($limitation, '|')); $value = substr($limitation, strpos($limitation, '|') + 1); if (!isset($limitation) || !isset($aParams[$key])) { // To be safe, unless the paramters passed in, and configured are avaiable, // return depending on if the $op is considered a 'positive' test return !MAX_limitationsIsOperatorPositive($op); } else { if (MAX_limitationsIsOperatorNumeric($op)) { return MAX_limitationMatchNumeric($key, $value, $op, $aParams); } else { return MAX_limitationsMatchString($key, $value, $op, $aParams); } } }
function test_MAX_limitationsMatchString() { $this->assertTrue(MAX_limitationsMatchString('organisation', 'MS', '==', array('organisation' => 'MS'))); $this->assertFalse(MAX_limitationsMatchString('organisation', 'Google', '==', array('organisation' => 'MS'))); $this->assertFalse(MAX_limitationsMatchString('organisation', 'MSa', '==', array('organisation' => 'MS'))); $this->assertTrue(MAX_limitationsMatchString('organisation', 'MSa', '!=', array('organisation' => 'MS'))); $this->assertFalse(MAX_limitationsMatchString('organisation', 'MS', '!=', array('organisation' => 'MS'))); $this->assertTrue(MAX_limitationsMatchString('organisation', 'MS', '=~', array('organisation' => 'yyMSyy'))); $this->assertTrue(MAX_limitationsMatchString('organisation', 'MS', '=~', array('organisation' => 'MSyy'))); $this->assertTrue(MAX_limitationsMatchString('organisation', 'MS', '=~', array('organisation' => 'yyMS'))); $this->assertFalse(MAX_limitationsMatchString('organisation', 'MSee', '=~', array('organisation' => 'yyMSyy'))); $this->assertFalse(MAX_limitationsMatchString('organisation', 'MS', '!~', array('organisation' => 'MSyy'))); $this->assertTrue(MAX_limitationsMatchString('organisation', 'MSa', '!~', array('organisation' => 'MSyy'))); $this->assertTrue(MAX_limitationsMatchString('organisation', '[a-z0-9]*pl', '=x', array('organisation' => 'pl'))); $this->assertTrue(MAX_limitationsMatchString('organisation', '[a-z0-9]*pl', '=x', array('organisation' => 'blabla81234pl'))); $this->assertFalse(MAX_limitationsMatchString('organisation', '[a-z0-9]*pl$', '=x', array('organisation' => 'blabla81234pldd'))); $this->assertTrue(MAX_limitationsMatchString('organisation', '^A[a-z0-9]*pl$', '=x', array('organisation' => 'Ablabla81234pl'))); $this->assertTrue(MAX_limitationsMatchString('organisation', '#', '=x', array('organisation' => 'blablah#blabblah'))); $this->assertFalse(MAX_limitationsMatchString('organisation', '^A[a-z0-9]*pl$', '!x', array('organisation' => 'Ablabla81234pl'))); $GLOBALS['_MAX']['CLIENT']['ua'] = 'mozilla/5.0 (x11; u; linux i686; en-us; rv:1.8.0.7) gecko/20060915 centos/1.5.0.7-0.1.el4.centos4 firefox/1.5.0.7 pango-text'; $this->assertTrue(MAX_limitationsMatchString('ua', 'x11;', '=~')); }
/** * The shortcut for {@link MAX_limitationsMatchString} with * $namespace set to 'CLIENT_GEO'. Useful for Geo delivery * limitation plugins. * * @param string $paramName * @param string $limitation * @param string $op * @param string $aParams * @return boolean * @see MAX_limitationsMatchString */ function MAX_limitationsMatchStringClientGeo($paramName, $limitation, $op, $aParams = array()) { return MAX_limitationsMatchString($paramName, $limitation, $op, $aParams, 'CLIENT_GEO'); }
/** * Check to see if this impression contains the valid user agent. * * @param string $limitation The user agent limitation * @param string $op The operator (all string operators apply) * @param array $aParams An array of additional parameters to be checked * @return boolean Whether this impression's user agent passes this limitation's test. */ function MAX_checkClient_Useragent($limitation, $op, $aParams = array()) { return MAX_limitationsMatchString('ua', $limitation, $op, $aParams); }