public function getCustomVariables($scope)
{
if ($scope == 'visit') {
$parameter = '_cvar';
} else {
$parameter = 'cvar';
}
$customVar = Common::unsanitizeInputValues(Common::getRequestVar($parameter, '', 'json', $this->params));
if (!is_array($customVar)) {
return array();
}
$customVariables = array();
foreach ($customVar as $id => $keyValue) {
$id = (int) $id;
if ($id < 1 || $id > Tracker::MAX_CUSTOM_VARIABLES || count($keyValue) != 2 || !is_string($keyValue[0]) && !is_numeric($keyValue[0])) {
Common::printDebug("Invalid custom variables detected (id={$id})");
continue;
}
if (strlen($keyValue[1]) == 0) {
$keyValue[1] = "";
}
// We keep in the URL when Custom Variable have empty names
// and values, as it means they can be deleted server side
$key = self::truncateCustomVariable($keyValue[0]);
$value = self::truncateCustomVariable($keyValue[1]);
$customVariables['custom_var_k' . $id] = $key;
$customVariables['custom_var_v' . $id] = $value;
}
return $customVariables;
}