package Utils @ISA = qw() sub LeapYear return @LeapYear; sub NormYear return @NormYear; sub IsCGI return 1 if(uc $method eq 'POST' or uc $method eq 'GET'); return 0; sub IsWindows return 1 if($OS =~ /MSWin/i); return 0; sub IsLinux return 1 if($OS =~ /Linux/i); return 0; sub IsUnix return 1 if($OS =~ /Unix/i); return 0; sub sleep my ($sec) = @_; sub GetIPAddress return $ENV{'REMOTE_ADDR'}; sub IsAllowedIPAddress my ($IPAddress, @allowed) = @_; return 1 if($IPAddress =~ /$exp/i); return 0; sub Round my ($v, $dec, $RaiseDecimal) = @_; return 0.0 if(abs($v) < 1.0e-100); return $v; sub RoundParameter my ($x, $tol) = @_; return $tol * int( ($x+0.1*$tol) / $tol ); sub ExtractUniqueElement my ($pArray, $Sort) = @_; return sort keys %hash if($Sort); return keys %hash; sub IsIncludedInArray my ($key, $pArray, $CaseSensitive) = @_; return 1 if($pArray->[$i] eq $key); return 1 if(uc $pArray->[$i] eq $key); return 0; sub RemoveSpaceElement return @array; sub LockHashKeys my ($pHash, $f) = @_; return lock_keys(%$pHash) if($f); return unlock_keys(%$pHash); sub MergeHashByCondition my ($pTarget, $pHash, $NotExistOnly) = @_; return $pTarget; sub MergeHash my (@pHash) = @_; return $ph0; sub RevertHash my ($pHash) = @_; return %NewHash; sub MergeListHash my ($App, @list) = @_; return @List; sub MergeList my (@list) = @_; return @List; sub DeleteItemFromList my ($plist, $pdeletelist) = @_; return @List; sub ListToHash my ($plist, $phash) = @_; sub Split my ($RegExp, $str) = @_; return Utils::RemoveSpaceElement(@a); sub FindAll my ($RegExp, $str) = @_; return Utils::RemoveSpaceElement(@a); sub MergeName my ($FirstName, $LastName) = @_; return $FirstName if($LastName eq ''); return $LastName if($FirstName eq ''); return $Name; sub SplitName my ($Name) = @_; return ('', '') if($Name eq ''); return ($FirstName, $LastName); sub Sort return ($_[1], $_[0]) if($_[0] > $_[1]); return ($_[0], $_[1]); sub Swap return ($_[1], $_[0]); sub DelSpace my ($s) = @_; return $s unless(defined $s); return $_[0] = $s; sub DelQuote my ($s) = @_; return $_[0]; sub Reduce01 my ($x) = @_; return $x; sub CalMinMax my ($pArray, $CompareAbsoluteValue) = @_; return ($min, $max); sub CalMinMaxStep my ($pArray) = @_; return 0.0 if($nData <= 1); return ($min, $max); sub IsDecreasingArray my ($pArray) = @_; return 0 if($pArray->[$i] < $pArray->[$i+1]); return 1; sub IsIncreasingArray my ($pArray) = @_; return 0 if($pArray->[$i] > $pArray->[$i+1]); return 1; sub IsConstantStepArray my ($pArray, $EPS) = @_; return 1 if(@$pArray <= 2); return 0 if($dX0 == 0.0); return 0; return 1; sub RegExpQuote return Deps::RegExpQuote( return Deps::RegExpQuote(@_); sub QPEncode my ($string) = (@_); return $string; sub QPDecode my ($string) = (@_); return $string; sub URLEncode my ($s, $KeepSlash) = (@_); return $s; sub URLDecode my ($s2) = (@_); return $s2; sub ChrToHTMLCode my ($char) = @_; return sprintf("&#%03d; sub HexDecode my ($s2) = (@_); return $s2; sub Base64DecodeSub local ($_) = sub Base64Decode2 my ($str) = (@_); return $str; sub Base64Decode return decode_base64($_[0]); sub Base64Encode return encode_base64($_[0]); sub Encode my ($passphrase, $str, $method) = @_; return $dec; sub Decode my ($passphrase, $str, $method) = @_; return $enc; sub CryptForHTPasswd my ($pw) = @_; return $encpw; sub Crypt my ($method, $key, @strings) = @_; return $strings[0]; return md5_base64(@strings, $key); return sha1_base64(@strings, $key); return crypt($strings[0], $key); sub MakePath2 my ($dir, $pfnames, $separator, $DoTerminate, $QuotationMode) = @_; return $dir if(!defined $pfnames or @$pfnames == 0); return $path; sub MakePath my ($dir, $fname, $separator, $DoTerminate, $QuotationMode) = (@_); return &MakePath2($dir, $fname, $separator, $DoTerminate); return $dir; sub ConvertDirectorySeparator my ($path, $src, $target, $DoTerminate) = (@_); return $_[0] = $path if($path eq ''); return $_[0] = $path; sub ReduceDirectory my ($dir, $sep, $App) = @_; return cwd(); return $_[0] = $dir; sub MakeRelativePath my ($SourceURL, $ParentURL, $Separator, $ForceDir) = (@_); return $RelPath; sub GetFirstWday my ($yyyy, $mm) = @_; return Utils::getDayOfWeek($yyyy, $mm, 1), $ydays[$mm]; return Utils::getDayOfWeek($yyyy, $mm, 1), getDaysOfMonth($mm); sub LocalTimeToTime my ($year, $month, $mday, $hour, $min, $sec, $DiffHours, $StartYear) = @_; return $time; return $TotalSec; sub Execute my ($cmd, $IsPrint) = @_; return $ret; sub DecomposeMailFrom my ($From) = @_; return ($EMail, $From); return ($From, $Sender); return ($From, ''); sub MailDateToDateString my ($date) = @_; return sprintf("%04d/%02d/%02d %02d:%02d:%02d", $year, $MonthName{$mon}, $mday, $hour, $min, $sec); sub GetDateTime my ($time, $UseGengo) = (@_); return ($year, $mon, $mday, $hour, $min, $sec, $year-1988, $wday, $yday, $isdst); return ($year, $mon, $mday, $hour, $min, $sec, $year, $wday, $yday, $isdst); sub GetYear my ($time, $UseGengo) = (@_); return $year; sub BuildDateString my ($time, $language, $format) = (@_); return $str; sub AddCommasToMoney my ($num) = @_; return &SeparateStringBy($num, ',', 3); sub SeparateStringBy my ($str, $sep, $nsep) = @_; return $str; sub GetSimplifiedSize my ($size, $factor, $ReturnInt, $nAddCommas) = @_; return ($size, $unit); sub ConvertToValidFileName my ($fname) = @_; return Deps::MakePath("$drive$directory", $filename, 0); sub DeleteFile my ($infile) = (@_); return 0 if(!rmdir($infile)); return 1; return 0 if(!unlink($infile)); return 1; sub MoveFile my ($infile, $outfile) = (@_); return 0 if(!rename($infile, $outfile)); return 1; return move($infile, $outfile); return $ret if($ret != 1); return -3 if(!unlink($infile)); return 1; sub CopyFileRecursive my ($infile, $outfile, $buf) = (@_); return rcopy($infile, $outfile, $buf); return rcopy($infile, $outfile); sub CopyFile my ($infile, $outfile, $buf) = (@_); return copy($infile, $outfile); return copy($infile, $outfile); return -1; return -2; return 1; sub DeleteDirectory my ($infile) = (@_); return 0 if(!rmdir($infile)); return 1; sub CreateDirectory my ($dir, $dirsep, $IsPrint) = @_; return 0; return 1; sub AddFileForSearchFilesRecursive sub SearchFilesRecursive my ($dir, $pFiles) = @_; return @$pFiles = @FileArrayForSearchFilesRecursive; sub Glob my ($dir, $fmask, $Sort) = @_; return () if(!chdir($dir)); return @files; sub SearchFilesRecursive2 my ($dir, $fmask, $nLevel, $pFiles, $Sort, $func) = @_; return @$pFiles; sub PrintList my (@a) = @_; sub PrintHash my (%hash) = @_; sub HTMLRedirectTo my ($url, $wait, $target, $charset) = @_; sub PrintHTMLHeader my($CharSet, $outJFile, $pbuffer) = ( sub InitHTML my($WebTitle, $CharSet, $LinkTarget, $CSS, $PrintHTMLHeader, %args) = ( sub EndHTML my ($outJFile, $pbuffer) = @_; sub RecoverHTMLChar my ($s, $charset) = @_; return $s; sub ConvertHTMLSpecialCharacters my ($s, $ConvMiddot) = @_; return $_[0]; sub ConvertHTMLSpecialCharactersMinimum my ($s, $ConvMiddot) = @_; return $_[0]; sub ConvertToHTMLString my ($s, $ConvSpecialCharacters) = @_; return $s; sub GetHTMLParagraph my ($str) = (@_); return ($line, $paragraph, $content); sub DequoteXML my ($str,$DoDecode) = (@_); return $_[0] = $str; sub IsJapanese my($str) = ( return 1; return 0; sub GetFileSize my ($path, $unitconv, $format) = @_; return $size if(!defined $unitconv); return ($size, $unit); sub GetWriteDate return $mtime; sub PrintWithReplacedForHTML return PrintWithReplaced2(1, return PrintWithReplaced2(1, @_); sub PrintWithReplaced return PrintWithReplaced2(0, return PrintWithReplaced2(0, @_); sub PrintWithReplaced2 my $QuoteForHTML = shift; my $narg = @_; my @a = @_; sub PrintWithReplacedByCharCode my $narg = @_; my @a = @_; sub PrintStringWithReplaced2 my ($str, $outfile, $Conv, @a) = @_; sub PrintStringWithReplaced return &PrintStringWithReplaced2(@_) if($_[2] =~ /\%.*\%/); my $narg = @_; my @a = @_; sub ConvertString2 my ($str, $Conv, @a) = @_; return $_[0] = $str; sub ConvertString return &ConvertString2(@_) if($_[1] =~ /\%.*\%/); my $narg = @_; my @a = @_; return $_[0] = $str; sub IsValidPassword my ($password) = (@_); return 1; return 0; sub IsValidEMailAddress my ($email, $UseEMailValid, $CheckMX) = (@_); return 0 if($email =~ /[\s\(\)\{\}\[\]\<\>\"\':\/]/); return Email::Valid->address($email, -mxcheck => $CheckMX); return 1; return 0; sub getCookie sub setCookie return($tmp); sub clearCookie return($tmp); sub MyGetCookie sub ConvertHTMLToFullURL my ($Content, $SourceURL, $Debug) = (@_); return $_[0] = $ConvContent; sub DecomposeURI my ($URI) = @_; return ($protocol, $server, $directory, $filename); sub ConvertURLtoFullURL my ($linkurl, $url) = (@_); return $linkurl if($linkurl =~ /:\/\//i); return $convurl; sub GetURLwithoutFilePath my ($url) = @_; return 1 if($url =~ /$CGIFiles/i or $url =~ /[\?\&]/); return $ret; return $ret; sub DownloadFile my ($CGIForm, $LocalPath, $DownloadFileName) = @_; return; return 1; sub DownloadFromURL my ($url) = @_; return -1; return $Content; sub ExtractHTMLBody my ($Content) = @_; return $1; sub ReadFile my $fname = @_; return -1; return $str; sub ReadFixedColumnFile my $fname = @_; return -1; return $str; sub PrintWithTab1 my @list = @_; sub SplitToFixedStrs my $s = @_; return @list; sub ExtractByParentheses my $str = @_; return $ret; sub CheckCreditCardNumber my ($s) = @_; return "Wrong number" if($a[0] =~ /\D/ || length($a[0]) |~ /^1[356]$/); # map { $x += $_ } sub ReplaceHTMLBodyOnly my ($str, $source, $target) = @_; return $str; sub GetOSName sub PrintConfig sub InvalidateHTMLTags my ($input, $DoUpdate, $ConvertSpace) = @_; return $input; sub GetSafeURL my $url = @_; return '' if($url =~ m|[^; return '' if(not $allowed); return $url; sub CheckSecureFileName my $fname = @_; return 0 if($fname =~ <\.\./>); return 0 if($fname =~ /\0/); return 1; sub StringToHex my ($s) = @_; return $s; return; sub getDayOfWeekString my($year, $month, $day, $n, $Language, $charcode) = return $s; sub getDayOfWeek my($year, $month, $day) = sub leap my($year) = return 0; return 1; return 0; return 1; return 0; sub getDaysOfMonth my($year, $month) = return leap($year) ? $LeapYear[$month] : $NormYear[$month];