function insert_ban($ban_type, $ban_text, $ban_comment = "", $ban_expire = 'UNDEFINED', $ban_id = 0) { global $globals; if (strlen($ban_text) < 2) { echo '<div class="form-error">'; echo '<p>' . _('Texto del ban muy corto') . '</p>'; echo "</div>\n"; return; } /* if (strlen($ban_text) > 8 && preg_match('/^www\..+\.[a-z]+(\/[a-z]+\/*){0,1}$/i', $ban_text) ) { $ban_text = preg_replace('/^www\./', '', $ban_text); } */ $ban = new Ban(); if ($ban_id > 0) { $ban->ban_id = (int) $ban_id; $ban->read(); } $ban->ban_type = $ban_type; $ban->ban_text = $ban_text; if (!empty($ban_comment)) { $ban->ban_comment = $ban_comment; } if (!empty($ban_expire)) { $ban->ban_expire = $ban_expire; } $ban->store(); return $ban; }