view reclib.php @ 147:fadae5e39857

fix: スターチャンネル追加
author epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
date Mon, 22 Mar 2010 22:43:11 +0900
parents f268d7d10590
children b172a0b1ea48
line wrap: on
line source

<?php

// ゃ

function toTimestamp( $string ) {
	sscanf( $string, "%4d-%2d-%2d %2d:%2d:%2d", $y, $mon, $day, $h, $min, $s );
	return mktime( $h, $min, $s, $mon, $day, $y );
}

function toDatetime( $timestamp ) {
	return date("Y-m-d H:i:s", $timestamp);
}


function jdialog( $message, $url = "index.php" ) {
    header( "Content-Type: text/html;charset=utf-8" );
    exit( "<script type=\"text/javascript\">\n" .
          "<!--\n".
         "alert(\"". $message . "\");\n".
         "window.open(\"".$url."\",\"_self\");".
         "// -->\n</script>" );
}

// ゃstr_replace

function mb_str_replace($search, $replace, $target, $encoding = "UTF-8" ) {
	$notArray = !is_array($target) ? TRUE : FALSE;
	$target = $notArray ? array($target) : $target;
	$search_len = mb_strlen($search, $encoding);
	$replace_len = mb_strlen($replace, $encoding);
	
	foreach ($target as $i => $tar) {
		$offset = mb_strpos($tar, $search);
		while ($offset !== FALSE){
			$tar = mb_substr($tar, 0, $offset).$replace.mb_substr($tar, $offset + $search_len);
			$offset = mb_strpos($tar, $search, $offset + $replace_len);
		}
		$target[$i] = $tar;
	}
	return $notArray ? $target[0] : $target;
}

?>