function piwik_admin_settings_form_validate in Piwik Web Analytics 5
Same name and namespace in other branches
- 6.2 piwik.admin.inc \piwik_admin_settings_form_validate()
- 6 piwik.admin.inc \piwik_admin_settings_form_validate()
- 7.2 piwik.admin.inc \piwik_admin_settings_form_validate()
- 7 piwik.admin.inc \piwik_admin_settings_form_validate()
File
- ./
piwik.module, line 396
Code
function piwik_admin_settings_form_validate($form_id, $form_values) {
if (!preg_match('/^\\d{1,}$/', $form_values['piwik_site_id'])) {
form_set_error('piwik_site_id', t('A valid Piwik site ID is an integer only.'));
}
$url = $form_values['piwik_url_http'] . '/piwik.php';
$result = drupal_http_request($url);
if ($result->code != 200) {
form_set_error('piwik_url_http', t('The validation of "@url" failed with error "@error" (HTTP code @code).', array(
'@url' => check_url($url),
'@error' => $result->error,
'@code' => $result->code,
)));
}
if (!empty($form_values['piwik_url_https'])) {
$url = $form_values['piwik_url_https'] . '/piwik.php';
$result = drupal_http_request($url);
if ($result->code != 200) {
form_set_error('piwik_url_https', t('The validation of "@url" failed with error "@error" (HTTP code @code).', array(
'@url' => check_url($url),
'@error' => $result->error,
'@code' => $result->code,
)));
}
}
// This is for the Newbie's who cannot read a text area description.
if (preg_match('/(.*)<\\/?script(.*)>(.*)/i', $form_values['piwik_codesnippet_before'])) {
form_set_error('piwik_codesnippet_before', t('Do not include the <script> tags in the javascript code snippets.'));
}
if (preg_match('/(.*)<\\/?script(.*)>(.*)/i', $form_values['piwik_codesnippet_after'])) {
form_set_error('piwik_codesnippet_after', t('Do not include the <script> tags in the javascript code snippets.'));
}
}