本文整理汇总了PHP中Piwik\Common::sanitizeLineBreaks方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::sanitizeLineBreaks方法的具体用法?PHP Common::sanitizeLineBreaks怎么用?PHP Common::sanitizeLineBreaks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Common
的用法示例。
在下文中一共展示了Common::sanitizeLineBreaks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRequestsArrayFromBulkRequest
public function getRequestsArrayFromBulkRequest($rawData)
{
$rawData = trim($rawData);
$rawData = Common::sanitizeLineBreaks($rawData);
// POST data can be array of string URLs or array of arrays w/ visit info
$jsonData = json_decode($rawData, $assoc = true);
$tokenAuth = Common::getRequestVar('token_auth', false, 'string', $jsonData);
$requests = array();
if (isset($jsonData['requests'])) {
$requests = $jsonData['requests'];
}
return array($requests, $tokenAuth);
}
示例2: authenticateBulkTrackingRequests
private function authenticateBulkTrackingRequests($rawData)
{
$rawData = trim($rawData);
$rawData = Common::sanitizeLineBreaks($rawData);
// POST data can be array of string URLs or array of arrays w/ visit info
$jsonData = json_decode($rawData, $assoc = true);
if (isset($jsonData['requests'])) {
$this->requests = $jsonData['requests'];
}
$tokenAuth = Common::getRequestVar('token_auth', false, 'string', $jsonData);
if (empty($tokenAuth)) {
throw new Exception("token_auth must be specified when using Bulk Tracking Import. See <a href='http://developer.piwik.org/api-reference/tracking-api'>Tracking Doc</a>");
}
if (!empty($this->requests)) {
$idSitesForAuthentication = array();
foreach ($this->requests as &$request) {
// if a string is sent, we assume its a URL and try to parse it
if (is_string($request)) {
$params = array();
$url = @parse_url($request);
if (!empty($url)) {
@parse_str($url['query'], $params);
$request = $params;
}
}
// We need to check access for each single request
if (isset($request['idsite']) && !in_array($request['idsite'], $idSitesForAuthentication)) {
$idSitesForAuthentication[] = $request['idsite'];
}
}
foreach ($idSitesForAuthentication as $idSiteForAuthentication) {
// a Bulk Tracking request that is not authenticated should fail
if (!Request::authenticateSuperUserOrAdmin($tokenAuth, $idSiteForAuthentication)) {
throw new Exception("token_auth specified does not have Admin permission for site " . intval($idSiteForAuthentication));
}
}
}
return $tokenAuth;
}