79a80,94 > $form['ignoring a set of hosts'] = array( > '#type' => 'fieldset', > '#title' => t('Ignore certain hosts'), > '#collapsible' => TRUE, > '#collapsed' => FALSE, > ); > > $form['ignoring a set of hosts']['download_count_excluded_hosts'] = array( > '#type' => 'textfield', > '#title' => t('Excluded hosts'), > '#default_value' => variable_get('download_count_excluded_hosts', 'google yahoo'), > '#maxlength' => 255, > '#description' => t('Here you can set which hosts to ignore downloads from. Typically this would be used to ignore downloads from search engines etc. Separate hosts with a space. If you do not want to exclude any host, leave the field blank. ') > ); > 92a108,121 > > $form['download notify email'] = array( > '#type' => 'fieldset', > '#title' => t('Notify via email'), > '#collapsible' => TRUE, > '#collapsed' => FALSE, > ); > > $form['download notify email']['email_on_download'] = array( > '#type' => 'checkbox', > '#title' => t('Email site owner on download'), > '#default_value' => variable_get('email_on_download', FALSE), > '#description' => t('Check this if you need an email notification when a download occurs.'), > ); 186c215 < --- > global $user; 193a223,238 > if (variable_get('email_on_download', FALSE)) { > $ip = $_SERVER['REMOTE_ADDR']; > $downloaderhost = gethostbyaddr ( $ip ); > > $ignore_hosts = explode(' ', trim(variable_get('download_count_excluded_hosts', ''))); > if (count($ignore_hosts)) { > foreach ($ignore_hosts as $host) { > if (stripos($downloaderhost,$host) === false) { > /* not in the list */ > } else { > /* in the list - ignore */ > return; > } > } > } > } 200a246,252 > > if (variable_get('email_on_download', FALSE)) { > $emailaddress = variable_get('site_mail', ini_get('sendmail_from')); > > $msg = $filename." downloaded from website by ".$user->name." (".$ip." ".$downloaderhost.")."; > drupal_mail('download_file_notify',$emailaddress,'File downloaded',$msg,$emailaddress); > } 281c333 < } \ No newline at end of file --- > }