You are here

function googleanalytics_admin_settings_form_validate in Google Analytics 5

Same name and namespace in other branches
  1. 6.4 googleanalytics.admin.inc \googleanalytics_admin_settings_form_validate()
  2. 6 googleanalytics.admin.inc \googleanalytics_admin_settings_form_validate()
  3. 6.2 googleanalytics.admin.inc \googleanalytics_admin_settings_form_validate()
  4. 6.3 googleanalytics.admin.inc \googleanalytics_admin_settings_form_validate()
  5. 7.2 googleanalytics.admin.inc \googleanalytics_admin_settings_form_validate()
  6. 7 googleanalytics.admin.inc \googleanalytics_admin_settings_form_validate()

File

./googleanalytics.module, line 497

Code

function googleanalytics_admin_settings_form_validate($form_id, $form_values) {
  if (!preg_match('/^UA-\\d{4,}-\\d+$/', $form_values['googleanalytics_account'])) {
    form_set_error('googleanalytics_account', t('A valid Google Analytics account number is case sensitive and formatted like UA-xxxxxx-x.'));
  }

  // This is for the Newbie's who cannot read a text area description.
  if (stristr($form_values['googleanalytics_codesnippet_before'], 'http://www.google-analytics.com/urchin.js') || stristr($form_values['googleanalytics_codesnippet_before'], 'google-analytics.com/ga.js')) {
    form_set_error('googleanalytics_codesnippet_before', t('Do not add the tracker code provided by Google into the javascript code snippets! This module already builds the tracker code based on your Google Analytics account number and settings.'));
  }
  if (stristr($form_values['googleanalytics_codesnippet_after'], 'http://www.google-analytics.com/urchin.js') || stristr($form_values['googleanalytics_codesnippet_after'], 'google-analytics.com/ga.js')) {
    form_set_error('googleanalytics_codesnippet_after', t('Do not add the tracker code provided by Google into the javascript code snippets! This module already builds the tracker code based on your Google Analytics account number and settings.'));
  }
  if (preg_match('/(.*)<\\/?script(.*)>(.*)/i', $form_values['googleanalytics_codesnippet_before'])) {
    form_set_error('googleanalytics_codesnippet_before', t('Do not include the &lt;script&gt; tags in the javascript code snippets.'));
  }
  if (preg_match('/(.*)<\\/?script(.*)>(.*)/i', $form_values['googleanalytics_codesnippet_after'])) {
    form_set_error('googleanalytics_codesnippet_after', t('Do not include the &lt;script&gt; tags in the javascript code snippets.'));
  }
}