Example #1
0
 /**
  * UCP Register
  *
  * @param array $data Data from ucp_register
  * @param array $error
  */
 public static function ucp_register($data, &$error)
 {
     global $config, $user;
     if (!$config['asacp_enable']) {
         return;
     }
     // Profile fields stuff
     foreach (self::$profile_fields as $field => $ary) {
         if ($ary['field_type'] == 'disabled') {
             continue;
         }
         switch ($config['asacp_profile_' . $field]) {
             case 1:
                 // Required
                 if (isset($_POST[$field]) && !request_var($field, '')) {
                     $error[] = sprintf($user->lang['FIELD_REQUIRED'], $user->lang[$ary['lang']]);
                 }
                 break;
             case 2:
                 // Normal
                 if (!$config['asacp_profile_during_reg'] && isset($_POST[$field]) && request_var($field, '')) {
                     $error[] = sprintf($user->lang['FIELD_TOO_LONG'], $user->lang[$ary['lang']], 0);
                 }
                 break;
             case 3:
                 // Never allowed
             // Never allowed
             case 4:
                 // Post Count
                 if (isset($_POST[$field]) && request_var($field, '')) {
                     $error[] = sprintf($user->lang['FIELD_TOO_LONG'], $user->lang[$ary['lang']], 0);
                 }
                 break;
         }
     }
     // Stop Forum Spam stuff
     if (!sizeof($error) && $config['asacp_sfs_action'] > 1) {
         if (!function_exists('get_remote_file')) {
             global $phpbb_root_path, $phpEx;
             include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
         }
         $stop_forum_spam_urls = array('api?username='******'username']), 'api?email=' . urlencode($data['email']));
         foreach ($stop_forum_spam_urls as $url) {
             $errstr = $errno = '';
             $file = get_remote_file('stopforumspam.com', '', $url, $errstr, $errno);
             if ($file !== false) {
                 $file = str_replace("\r\n", "\n", $file);
                 $file = explode("\n", $file);
                 $appears = $frequency = false;
                 foreach ($file as $line) {
                     if (strpos($line, '<appears>') !== false && strpos($line, '</appears>') !== false) {
                         $start = strpos($line, '<appears>') + 9;
                         $end = strpos($line, '</appears>') - $start;
                         $appears = substr($line, $start, $end) == 'yes' ? true : false;
                     } else {
                         if (strpos($line, '<frequency>') !== false && strpos($line, '</frequency>') !== false) {
                             $start = strpos($line, '<frequency>') + 11;
                             $end = strpos($line, '</frequency>') - $start;
                             $frequency = (int) substr($line, $start, $end);
                         }
                     }
                 }
                 if ($appears && $frequency >= $config['asacp_sfs_min_freq']) {
                     self::$sfs_spam = true;
                     if ($config['asacp_sfs_action']) {
                         self::add_log('LOG_SPAM_USER_DENIED_SFS', array($url));
                     }
                     break;
                 }
             }
         }
         if (self::$sfs_spam) {
             switch ($config['asacp_sfs_action']) {
                 case 3:
                     $config['require_activation'] = USER_ACTIVATION_SELF;
                     break;
                 case 4:
                     $config['require_activation'] = USER_ACTIVATION_ADMIN;
                     break;
                 case 5:
                     $user->add_lang('mods/asacp');
                     $error[] = $user->lang['PROFILE_SPAM_DENIED'];
                     break;
             }
         }
     }
 }