<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#webliberty::String.pm (2006/02/18)
#Copyright(C) 2002-2006 Knight, All rights reserved.

package webliberty::String;

use strict;

### ã‚³ãƒ³ã‚¹ãƒˆãƒ©ã‚¯ã‚¿
sub new {
	my $class = shift;

	my $self = {
		string =&gt; shift
	};
	bless $self, $class;

	return $self;
}

### ä¸€è¡Œãƒ‡ãƒ¼ã‚¿ä½œæˆ
sub create_line {
	my $self = shift;

	$self-&gt;{string} =~ s/\t//g;
	$self-&gt;{string} =~ s/^\s+//;
	$self-&gt;{string} =~ s/\s+$//;
	$self-&gt;{string} =~ s/\r?\n//g;
	$self-&gt;{string} =~ s/&lt;br \/&gt;//g;

	return $self-&gt;{string};
}

### è¤‡æ•°è¡Œãƒ‡ãƒ¼ã‚¿ä½œæˆ
sub create_text {
	my $self = shift;

	$self-&gt;{string} =~ s/\t//g;
	$self-&gt;{string} =~ s/\r?\n/\r/g;
	$self-&gt;{string} =~ s/^\r+//;
	$self-&gt;{string} =~ s/\r+$//;
	$self-&gt;{string} =~ s/\r/&lt;br \/&gt;/g;

	return $self-&gt;{string};
}

### æ•°å€¤ãƒ‡ãƒ¼ã‚¿ä½œæˆ
sub create_number {
	my $self = shift;

	$self-&gt;{string} = int($self-&gt;{string});

	return $self-&gt;{string};
}

### ãƒ—ãƒ¬ãƒ¼ãƒ³ãƒ‡ãƒ¼ã‚¿ä½œæˆ
sub create_plain {
	my $self = shift;

	$self-&gt;{string} =~ s/\r?\n/\n/g;
	$self-&gt;{string} =~ s/&lt;br \/&gt;/\n/g;

	return $self-&gt;{string};
}

### ãƒªãƒ³ã‚¯ä½œæˆ
sub create_link {
	my $self = shift;

	$self-&gt;{string} = "\n$self-&gt;{string}\n";
	$self-&gt;{string} =~ s/([^\"(&amp;quot;)(&amp;gt;)])(https?:\/\/[\w\.\~\-\/\?\&amp;\#\+\=\:\;\@\%]+)([^\"(&amp;quot;)(&amp;lt;)])/$1&lt;a href="$2"&gt;$2&lt;\/a&gt;$3/gi;
	$self-&gt;{string} =~ s/([^\"(&amp;quot;)(&amp;gt;)])(ftp:\/\/[\w\.\~\-\/\?\&amp;\#\+\=\:\;\@\%]+)([^\"(&amp;quot;)(&amp;lt;)])/$1&lt;a href="$2"&gt;$2&lt;\/a&gt;$3/gi;
	$self-&gt;{string} =~ s/([^\"(&amp;quot;)(&amp;gt;)])([\w\-]+\@[\w\-\.]+)([^\"(&amp;quot;)(&amp;lt;)])/$1&lt;a href="mailto:$2"&gt;$2&lt;\/a&gt;$3/gi;
	$self-&gt;{string} =~ s/^\n//;
	$self-&gt;{string} =~ s/\n$//;

	return $self-&gt;{string};
}

### ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ä½œæˆ
sub create_password {
	my $self = shift;

	my $salt = pack('CC', int(rand(26) + 65), int(rand(10) + 48));
	$self-&gt;{string} = crypt($self-&gt;{string}, $salt);

	return $self-&gt;{string};
}

### HTMLæœ‰åŠ¹åŒ–
sub permit_html {
	my $self = shift;

	$self-&gt;{string} =~ s/&amp;quot;/"/g;
	$self-&gt;{string} =~ s/&amp;lt;/&lt;/g;
	$self-&gt;{string} =~ s/&amp;gt;/&gt;/g;
	$self-&gt;{string} =~ s/&amp;amp;/&amp;/g;

	return $self-&gt;{string};
}

### æ–‡å­—æ•°å–å¾—
sub check_length {
	my $self = shift;

	return length($self-&gt;{string});
}

### è¡Œæ•°å–å¾—
sub check_line {
	my $self = shift;

	return ($self-&gt;{string} =~ s/&lt;br \/&gt;/&lt;br \/&gt;/g) + 1;
}

### ãƒ‘ã‚¹ãƒ¯ãƒ¼ãƒ‰ç…§åˆ
sub check_password {
	my $self     = shift;
	my $password = shift;

	my $flag;

	if (crypt($self-&gt;{string}, $password) eq $password) {
		$flag = 1;
	}

	return $flag;
}

### ãƒ‡ãƒ¼ã‚¿è¨­å®š
sub set_string {
	my $self   = shift;
	my $string = shift;

	$self-&gt;{string} = $string;

	return;
}

### ãƒ‡ãƒ¼ã‚¿ç½®æ›
sub replace_string {
	my $self   = shift;
	my $before = shift;
	my $after  = shift;

	$self-&gt;{string} =~ s/$before/$after/g;

	return $self-&gt;{string};
}

### ãƒ‡ãƒ¼ã‚¿å–å¾—
sub get_string {
	my $self = shift;

	return $self-&gt;{string};
}

1;
</pre></body></html>