';
}else{
$sanrenhuku_table .= '
'.$num[0].'
'.$racer_name.'
';
}
for($j = ($num[0] + 1); $j <= $kumi_num; $j++){
$re_j = $j - 1;
$area = (string) $var['競輪場コード'].(string) $var['競走番号'];
$date = (string) $var['開催日'];
$racer_name = racer_name($date,$area,$j);
if($racer_name != ""){
$sanrenhuku_table .= '
'.$j.'
'.$racer_name.'
';
}else{
$sanrenhuku_table .= '';
}
for($k = ($j + 1); $k <= $kumi_num; $k++){
$re_kumi = ($num[0] * 100) + ($j * 10) + $k;
$re_k = $k - 1;
if($arr[$re_kumi]['yuukou'] != 0){
$sanrenhuku_table .= '
'.$k.'
'.$arr[$re_kumi]['odds'].'
';
}else{
$sanrenhuku_table .= '';
}
}
$sanrenhuku_table .='
';
}
$sanrenhuku_table .='
';
return $sanrenhuku_table;
}
add_shortcode('sanrenhuku_table', 'sanrenhuku_table');
// 三連複---------------------------------------------------------------
// ランキング---------------------------------------------------------------
//会場
function rank_area($tan){
$var = Libs::parseAPI($tan[0]);
//会場変換
$area = (string) $var['競輪場コード'];
$area = conv_racecourse($area);
return $area;
}
add_shortcode('rank_area', 'rank_area');
//何レース
function rank_race($tan){
$var = Libs::parseAPI($tan[0]);
//何レース目
$race = (string) $var['競走番号'];
$race = intval($race);
return $race;
}
add_shortcode('rank_race', 'rank_race');
//ランキング
function ranks($tan){
$var = Libs::parseAPI($tan[1]);
if($tan[0] == 'ranking2'){
for($i=0; $i < count($var['オッズ情報']['二車単情報']['二車単詳細']); $i++){
$kumi = (string) $var['オッズ情報']['二車単情報']['二車単詳細'][$i]['@attributes']['二車単組番'];
$arr[$i]['kumi'] = $kumi;
$rank = (string) $var['オッズ情報']['二車単情報']['二車単詳細'][$i]['二車単人気順'];
$arr[$i]['rank'] = $rank;
$odds = (string) $var['オッズ情報']['二車単情報']['二車単詳細'][$i]['二車単オッズ'];
$arr[$i]['odds'] = $odds;
}
}elseif($tan[0] == 'ranking3'){
for($i=0; $i < count($var['オッズ情報']['三連単情報']['三連単詳細']); $i++){
$kumi = (string) $var['オッズ情報']['三連単情報']['三連単詳細'][$i]['@attributes']['三連単組番'];
$arr[$i]['kumi'] = $kumi;
$rank = (string) $var['オッズ情報']['三連単情報']['三連単詳細'][$i]['三連単人気順'];
$arr[$i]['rank'] = $rank;
$odds = (string) $var['オッズ情報']['三連単情報']['三連単詳細'][$i]['三連単オッズ'];
$arr[$i]['odds'] = $odds;
}
}
array_multisort(array_column($arr, 'rank'), $arr);
for($j = 0; $j < 20 ; $j++){
$wordwrapStr = wordwrap($arr[$j]['kumi'], 1, "-", true);
$row_num .= '
'.$arr[$j]['rank'].'
'.$wordwrapStr.'
'.$arr[$j]['odds'].'
';
}
return $row_num;
}
add_shortcode('rank', 'ranks');
// ランキング---------------------------------------------------------------
// 二枠単---------------------------------------------------------------
//会場
function niwakutan_area($col){
$var = Libs::parseAPI($col[0]);
//会場変換
$area = (string) $var['競輪場コード'];
$area = conv_racecourse($area);
return $area;
}
add_shortcode('niwakutan_area', 'niwakutan_area');
//何レース
function niwakutan_race($col){
$var = Libs::parseAPI($col[0]);
//何レース目
$race = (string) $var['競走番号'];
$race = intval($race);
return $race;
}
add_shortcode('niwakutan_race', 'niwakutan_race');
//行番号
function niwakutan_row_num($col){
$var = Libs::parseAPI($col[0]);
$number = [
'one',
'two',
'three',
'four',
'five',
'six'
];
for($i=0; $i < count($var['オッズ情報']['二枠単情報']['二枠単詳細']); $i++){
$kumi = (string) $var['オッズ情報']['二枠単情報']['二枠単詳細'][$i]['@attributes']['二枠単組番'];
$arr[$kumi]['kumi'] = $kumi;
if($arr[$kumi]['kumi'] <= 16){
$kumi_num = intval($arr[$kumi]['kumi']) - 10;
}
}
for($j = 0; $j < $kumi_num; $j++){
$num = $j + 1;
$row_num .= '
'.$num.'
';
}
return $row_num;
}
add_shortcode('niwakutan_row_num', 'niwakutan_row_num');
//列セット
function niwakutan_col_num($col){
$var = Libs::parseAPI($col[1]);
$number = [
'two',
'three',
'four',
'five',
'six',
'seven',
'eight',
'nine'
];
$col_class = [
'oneCol',
'twoCol',
'threeCol',
'fourCol',
'fiveCol',
'sixCol',
'sevenCol',
'eightCol',
'nineCol'
];
$col_num = "";
for($i=0; $i < count($var['オッズ情報']['二枠単情報']['二枠単詳細']); $i++){
$kumi = (string) $var['オッズ情報']['二枠単情報']['二枠単詳細'][$i]['@attributes']['二枠単組番'];
$arr[$kumi]['kumi'] = $kumi;
$odds = (string) $var['オッズ情報']['二枠単情報']['二枠単詳細'][$i]['二枠単オッズ'];
$arr[$kumi]['odds'] = $odds;
$yuukou = (string) $var['オッズ情報']['二枠単情報']['二枠単詳細'][$i]['二枠単有効フラグ'];
$arr[$kumi]['yuukou'] = $yuukou;
if($arr[$kumi]['kumi'] <= 16){
$kumi_num = intval($arr[$kumi]['kumi']) - 10;
}
}
for($j = 0; $j < $kumi_num; $j++){
$kumiban = (intval($col[0]) * 10) + ($j + 1);
if($arr[$kumiban]['yuukou'] != 0){
if ($arr[$kumiban]['odds']) {
$col_odds .= '
'.$arr[$kumiban]['odds'].'
';
}else{
$col_odds .= '
';
}
}else{
if ($arr[$kumiban]['odds']) {
$col_odds .= '
';
}else{
$col_odds .= '
';
}
}
}
if(($kumi_num + 1) >= intval($col[0])){
if($col[0] >= 4){
$num_st = $col[0] + ($col[0] - 4);
$next_num = $col[0] + ($col[0] - 3);
$area = (string) $var['競輪場コード'].(string) $var['競走番号'];
$date = (string) $var['開催日'];
$racer_name = $num_st.'.'.racer_name($date,$area,$col[0])."
";
if(racer_name($date,$area,$next_num) != 0);
$racer_name .= $next_num.'.'.racer_name($date,$area,$next_num);
$racer_name = str_replace(array(" ", " "), "", $racer_name);//全角スペース取り除き
}else{
$area = (string) $var['競輪場コード'].(string) $var['競走番号'];
$date = (string) $var['開催日'];
$racer_name = $col[0].'.'.racer_name($date,$area,$col[0]);
$racer_name = str_replace(array(" ", " "), "", $racer_name);//全角スペース取り除き
}
$col_num =
'
'.intval($col[0]).'
'.$racer_name.'
'.$col_odds.'
';
}
return $col_num;
}
add_shortcode('niwakutan_col_num', 'niwakutan_col_num');
// 二枠単---------------------------------------------------------------
// 二枠複---------------------------------------------------------------
//会場
function niwakuhuku_area($tan){
$var = Libs::parseAPI($tan[0]);
//会場変換
$area = (string) $var['競輪場コード'];
$area = conv_racecourse($area);
return $area;
}
add_shortcode('niwakuhuku_area', 'niwakuhuku_area');
//何レース
function niwakuhuku_race($tan){
$var = Libs::parseAPI($tan[0]);
//何レース目
$race = (string) $var['競走番号'];
$race = intval($race);
return $race;
}
add_shortcode('niwakuhuku_race', 'niwakuhuku_race');
//行番号
function niwakuhuku_row_num($tan){
$var = Libs::parseAPI($tan[0]);
$number = [
'one',
'two',
'three',
'four',
'five',
'six'
];
for($i=0; $i < count($var['オッズ情報']['二枠複情報']['二枠複詳細']); $i++){
$kumi = (string) $var['オッズ情報']['二枠複情報']['二枠複詳細'][$i]['@attributes']['二枠複組番'];
$arr[$kumi]['kumi'] = $kumi;
if($arr[$kumi]['kumi'] <= 16){
$kumi_num = intval($arr[$kumi]['kumi']) - 10;
}
}
for($j = 0; $j < $kumi_num; $j++){
$num = $j + 1;
$row_num .= '
'.$num.'
';
}
return $row_num;
}
add_shortcode('niwakuhuku_row_num', 'niwakuhuku_row_num');
//列セット
function niwakuhuku_col_num($col){
$var = Libs::parseAPI($col[1]);
$number = [
'two',
'three',
'four',
'five',
'six',
'seven',
'eight',
'nine'
];
$col_class = [
'oneCol',
'twoCol',
'threeCol',
'fourCol',
'fiveCol',
'sixCol',
'sevenCol',
'eightCol',
'nineCol'
];
$col_num = "";
for($i=0; $i < count($var['オッズ情報']['二枠複情報']['二枠複詳細']); $i++){
$kumi = (string) $var['オッズ情報']['二枠複情報']['二枠複詳細'][$i]['@attributes']['二枠複組番'];
$arr[$kumi]['kumi'] = $kumi;
$odds = (string) $var['オッズ情報']['二枠複情報']['二枠複詳細'][$i]['二枠複オッズ'];
$arr[$kumi]['odds'] = $odds;
$yuukou = (string) $var['オッズ情報']['二枠複情報']['二枠複詳細'][$i]['二枠複有効フラグ'];
$arr[$kumi]['yuukou'] = $yuukou;
if($arr[$kumi]['kumi'] <= 16){
$kumi_num = intval($arr[$kumi]['kumi']) - 10;
}
}
for($j = 0; $j < $kumi_num; $j++){
$kumiban = (intval($col[0]) * 10) + ($j + 1);
if($arr[$kumiban]['yuukou'] != 0){
if ($arr[$kumiban]['odds']) {
$col_odds .= '
'.$arr[$kumiban]['odds'].'
';
}else{
$col_odds .= '
';
}
}else{
if ($arr[$kumiban]['odds']) {
$col_odds .= '
';
}else{
$col_odds .= '
';
}
}
}
if(($kumi_num + 1) >= intval($col[0])){
if($col[0] >= 4){
$num_st = $col[0] + ($col[0] - 4);
$next_num = $col[0] + ($col[0] - 3);
$area = (string) $var['競輪場コード'].(string) $var['競走番号'];
$date = (string) $var['開催日'];
$racer_name = $num_st.'.'.racer_name($date,$area,$col[0])."
";
if(racer_name($date,$area,$next_num) != 0);
$racer_name .= $next_num.'.'.racer_name($date,$area,$next_num);
$racer_name = str_replace(array(" ", " "), "", $racer_name);//全角スペース取り除き
}else{
$area = (string) $var['競輪場コード'].(string) $var['競走番号'];
$date = (string) $var['開催日'];
$racer_name = $col[0].'.'.racer_name($date,$area,$col[0]);
$racer_name = str_replace(array(" ", " "), "", $racer_name);//全角スペース取り除き
}
$col_num =
'
'.intval($col[0]).'
'.$racer_name.'
'.$col_odds.'
';
}
return $col_num;
}
add_shortcode('niwakuhuku_col_num', 'niwakuhuku_col_num');
// 二枠複---------------------------------------------------------------
//プルダウン作成
function selection_Func(){
$sr = $_GET["sr"];
// $race = substr($sr, -2, 2);
// $race = ltrim($race, '0');
// $area = substr($sr, -4, 2);
// $area = ltrim($area, '0');
// $parameter = '/?area='.$area.'&race='.$race;
$retHtml .= '
';
return $retHtml;
}
add_shortcode('selection', 'selection_Func');
//現在の時間
function oddstimeFunc()
{
$oddsTime = date_i18n('Y/m/d H:i');
return '
'.$oddsTime. ' 現在のデータ
';
}
add_shortcode('oddstime', 'oddstimeFunc');
//テッパン自動出力
define("TEPPAN_CSVDATA_BASE_DIR","../data/teppan");
function auto_teppanFunc(){
// define("TEPPAN_CSVDATA_BASE_DIR","../data/teppan");
$now_date_time = date('Y年n月j日');
// $now_date_time = date_i18n('Y年n月j日');
$now_date_time2 = date("Y/m/d H:i:s");
$now_date_time3 = date_i18n('Y年n月j日 H:i:s');
$filepaths = file_search(TEPPAN_CSVDATA_BASE_DIR);
for($jj = 0; $jj < count($filepaths); $jj++){
if(strpos($filepaths[$jj],'delete_log') === false && strpos($filepaths[$jj], $now_date_time) !== false){
$pos = strpos($filepaths[$jj], 'ST') + 2;
$jyo = substr($filepaths[$jj], $pos+8, 2);
$code = substr($filepaths[$jj], -6, 2);
$codejyo = $code.$jyo;
$sort_filepath[(string)$codejyo] = $filepaths[$jj];
}
}
ksort($sort_filepath);
$filepaths = array();
foreach ($sort_filepath as $key => $value) {
array_push($filepaths, $value);
}
for($j = 0; $j < count($filepaths); $j++){
if(strpos($filepaths[$j],'delete_log') === false){
//'abcd'のなかに'bc'が含まれていない場合
$file = new SplFileObject($filepaths[$j]);
$file->setFlags(SplFileObject::READ_CSV);
foreach($file as $line){
//終端の空行を除く処理 空行の場合に取れる値は後述
if(!is_null($line[0])){
$records[] = $line;
}
}
}
}
// csv中身チェック用
// echo('
');
// var_dump($filepaths);
// echo('
');
for($i=0; $i < count($records); $i++){
$race_no = preg_replace('/[^0-9]/', '', $records[$i][5]);
$race_no = str_pad($race_no, 2, 0, STR_PAD_LEFT);
$race_time = $records[$i][7];
if( $records[$i][2] == "平" ) $racejoNameConv='いわき平';
else $racejoNameConv=$records[$i][2];
$SR_link = "SR".$records[$i][1].conv_racecourse($racejoNameConv).$race_no;
$shussou = get_posts( array(
's' => $SR_link,
'post_type' => 'keirin_race',
'posts_per_page' => -1,
'post_status' => 'publish',
'category' => null,
'orderby' => 'title',
'order' => 'ASC',
) );
$SR_f = "";
if(empty($shussou)) $SR_f = "sr_no";
//検索コード
$placeNo_code = substr($SR_link, 10,2);
$place_name = conv_racecourse( $placeNo_code );
$scode = date('n/j', strtotime(substr($SR_link, 2,8))).'__'.$place_name;
//引数
$kaisai = get_posts( array(
's' => $scode,
'numberposts' => -1,
'posts_per_page' => 1,
'post_type' => 'keirin_schedule',
'category' => null,
));
foreach ( $kaisai as $post ) :
setup_postdata( $post );
//schedule_FI
$schedule_FI = get_post_meta($post->ID , 'schedule_FI' ,true);
//schedule_FII
$schedule_FII = get_post_meta($post->ID , 'schedule_FII' ,true);
//schedule_GI
$schedule_GI = get_post_meta($post->ID , 'schedule_GI' ,true);
//schedule_GII
$schedule_GII = get_post_meta($post->ID , 'schedule_GII' ,true);
//schedule_GIII
$schedule_GIII = get_post_meta($post->ID , 'schedule_GIII' ,true);
//schedule_GP
$schedule_GP = get_post_meta($post->ID , 'schedule_GP' ,true);
//schedule_ガールズ
$schedule_girls = get_post_meta($post->ID , 'schedule_ガールズ' ,true);
//schedule_ナイター
$schedule_nighter = get_post_meta($post->ID , 'schedule_ナイター' ,true);
//schedule_ミッドナイト
$schedule_midnight = get_post_meta($post->ID , 'schedule_ミッドナイト' ,true);
//schedule_モーニング
$schedule_morning = get_post_meta($post->ID , 'schedule_モーニング' ,true);
//schedule_日付
$schedule_date = get_post_meta($post->ID , 'schedule_日付' ,true);
//場所
$schedule_place = get_post_meta($post->ID , 'schedule_会場' ,true);
//日目
$schedule_date_count = get_post_meta($post->ID , 'schedule_日目' ,true);
$template_directory = get_stylesheet_directory_uri();
endforeach;
// if ( $schedule_GP == '1' ) {$F = 'GP';$gradeBg="444";}
// if ( $schedule_GI == '1' ) {$F = 'GI';$gradeBg="444";}
// if ( $schedule_GII == '1' ) {$F = 'GII';$gradeBg="444";}
// if ( $schedule_GIII == '1' ) {$F = 'GIII';$gradeBg="444";}
// if ( $schedule_FI == '1' ) {$F = 'FI';$gradeBg="444";}
// if ( $schedule_FII == '1' ) {$F = 'FII';$gradeBg="444";}
if ( $schedule_morning == '1' ) {$timeBg = "noonBgColor";}
elseif ( $schedule_nighter == '1' ) {$timeBg = "nightBgColor";}
elseif ( $schedule_midnight == '1' ) {$timeBg = "midnightBgColor";}
else {$timeBg = "noonBgColor";}
//時間の整形
// $timestamp = $records[$i][7].':00';
//時間から背景色をあてがう
// if ( strtotime($timestamp) <= strtotime('16:00:00')) {$timeBg = "noonBgColor";}
// elseif (strtotime($timestamp)<= strtotime('20:59:00')) {$timeBg = "nightBgColor";}
// else{$timeBg="midnightBgColor";}
//レースグレード 背景色
if ($records[$i][3] == "GP"){ $gradeBg = "gpGradeBg";}
if ($records[$i][3] == "GI"){ $gradeBg = "giGradeBg";}
if ($records[$i][3] == "GII"){ $gradeBg = "giiGradeBg";}
if ($records[$i][3] == "GIII"){ $gradeBg = "giiiGradeBg";}
if ($records[$i][3] == "FI"){ $gradeBg = "fiGradeBg";}
if ($records[$i][3] == "FII"){ $gradeBg = "fiiGradeBg";}
//開催日文字色
if ($records[$i][4] == "最終日"){$kaisaibiFontColor = "lastDayFontColor";}
else {$kaisaibiFontColor = "otherDayFontColor";}
$win = "";
if(!empty($records[$i][11])) $win = '
'.$records[$i][10].' 今年の勝率'.$records[$i][11].'%
';
$auto_teppan .= '
'.$records[$i][6].'番車 '.$records[$i][8].'
';
}
return $auto_teppan;
}
add_shortcode('auto_teppan', 'auto_teppanFunc');
// 自動実行用関数
// 12時にてっぱんcsv消す
function my_auto_function2() {
$filepaths = file_search(TEPPAN_CSVDATA_BASE_DIR);
date_default_timezone_set('Asia/Tokyo');
//ファイル名
$sFileName = date('Y_m_d__H_i_s').'.txt';
//ファイルパス
$sPath = TEPPAN_CSVDATA_BASE_DIR.'/delete_log/'.$sFileName;
//ディレクトリ確認
if(file_exists(TEPPAN_CSVDATA_BASE_DIR.'/delete_log')){
//echo '・指定ファイルが既に存在しております。';
//exit;
}else{
//echo '・ファイルの存在確認完了。
';
mkdir(TEPPAN_CSVDATA_BASE_DIR.'/delete_log', 0775);
//各二実に変更
chmod(TEPPAN_CSVDATA_BASE_DIR.'/delete_log', 0775);
}
//ファイルの存在確認
if(file_exists($sPath)){
//echo '・指定ファイルが既に存在しております。';
exit;
}else{
//echo '・ファイルの存在確認完了。
';
}
//ファイルを作成
if(touch($sPath)){
//echo '・ファイル作成完了。
';
}else{
//echo '・ファイル作成失敗。
';
exit;
}
//ファイルのパーティションの変更
if(chmod($sPath,0755)){
//echo '・ファイルパーミッション変更完了。
';
}else{
//echo '・ファイルパーミッション変更失敗。
';
exit;
}
//ファイルをオープン
if($filepoint = fopen($sPath,"w")){
//echo '・ファイルオープン完了。
';
}else{
//echo '・ファイルオープン失敗。
';
exit;
}
//ファイルのロック
if(flock($filepoint, LOCK_EX)){
//echo '・ファイルロック完了。
';
}else{
//echo '・ファイルロック失敗。
';
exit;
}
//ファイルへ書き込み
$now_time = date_i18n('Y年n月j日');
//$now_time = date_i18n('Y年n月j日' , strtotime("-15 hours"));
for($i = 0; $i < count($filepaths); $i++){
$iti = mb_strpos($filepaths[$i], '/ST2', 0) + 31;
$file_date = mb_substr($filepaths[$i], $iti);
if(strpos($filepaths[$i],'.txt') !== false){
}else{
if($now_time > $file_date){
if ( unlink( $filepaths[$i] )) {
//echo "ファイル削除成功!!";
$sWriteContents = $filepaths[$i]."削除\n";
fwrite($filepoint,$sWriteContents);
} else {
//echo "ファイル削除失敗!!";
$sWriteContents = $filepaths[$i]."削除失敗\n";
fwrite($filepoint,$sWriteContents);
}
}
// if(strpos($filepaths[$i], $now_time) !== false){
// if ( unlink( $filepaths[$i] )) {
// //echo "ファイル削除成功!!";
// $sWriteContents = $filepaths[$i]."削除\n";
// fwrite($filepoint,$sWriteContents);
// } else {
// //echo "ファイル削除失敗!!";
// $sWriteContents = $filepaths[$i]."削除失敗\n";
// fwrite($filepoint,$sWriteContents);
// }
// }
}
}
//ファイルのアンロック
if(flock($filepoint, LOCK_UN)){
//echo '・ファイルアンロック完了。
';
}else{
//echo '・ファイルアンロック失敗。
';
exit;
}
//ファイルを閉じる
if(fclose($filepoint)){
//echo '・ファイルクローズ完了。
';
}else{
//echo '・ファイルクローズ失敗。
';
exit;
}
}
add_action ( 'my_auto_function_cron2', 'my_auto_function2' );
// cron登録処理
if ( !wp_next_scheduled( 'my_auto_function_cron2' ) ) { // 何度も同じcronが登録されないように
date_default_timezone_set('Asia/Tokyo');
wp_schedule_event( strtotime('2018-1-18 0:00:00'), 'daily', 'my_auto_function_cron2' );
}
//てっぱんCSV上書き処理
add_filter( 'cron_schedules', 'cron_add_60second' );
function cron_add_60second( $schedules ) {
$schedules['60sec'] = array(
'interval' => 60,
'display' => __( 'Once every 60 second' )
);
return $schedules;
}
function teppan_update_Func(){
$filepaths = file_search(TEPPAN_CSVDATA_BASE_DIR);
for($i = 0; $i < count($filepaths); $i++){
$pos = strpos($filepaths[$i], 'ST') + 2;
$filetitle = substr($filepaths[$i], $pos, 12);
for($ii = 0; $ii < count($filepaths); $ii++){
if(strpos($filepaths[$ii], $filetitle) !== false){
//'abcd'のなかに'bc'が含まれている場合
$date1 = substr($filepaths[$i], $pos+12, 16);
$date1 = str_replace('_', '', $date1);
$date2 = substr($filepaths[$ii], $pos+12, 16);
$date2 = str_replace('_', '', $date2);
if((int)$date1 > (int)$date2){
//けす
unlink($filepaths[$ii]);
}elseif((int)$date1 < (int)$date2){
unlink($filepaths[$i]);
}
}
}
}
}
add_action ( 'my_auto_function_cron3', 'teppan_update_Func' );
//cron登録処理
if ( !wp_next_scheduled( 'my_auto_function_cron3' ) ) { // 何度も同じcronが登録されないように
date_default_timezone_set('Asia/Tokyo');
wp_schedule_event( time(), '200sec', 'my_auto_function_cron3' );
}
// **********************************************************
//スポニチさん確認用
//nextday_teppan
function suponiti_auto_teppanFunc(){
// define("TEPPAN_CSVDATA_BASE_DIR","../data/teppan");
$now_date_time = date_i18n('Y年n月j日' , strtotime("+10 hours 30 minute"));
$sort_filepath = array();
$filepaths = file_search(TEPPAN_CSVDATA_BASE_DIR);
for($jj = 0; $jj < count($filepaths); $jj++){
if(strpos($filepaths[$jj],'delete_log') === false && strpos($filepaths[$jj], $now_date_time) !== false){
$pos = strpos($filepaths[$jj], 'ST') + 2;
$jyo = substr($filepaths[$jj], $pos+8, 2);
$code = substr($filepaths[$jj], -6, 2);
$codejyo = $code.$jyo;
$sort_filepath[(string)$codejyo] = $filepaths[$jj];
}
}
ksort($sort_filepath);
$filepaths = array();
foreach ($sort_filepath as $key => $value) {
array_push($filepaths, $value);
}
for($j = 0; $j < count($filepaths); $j++){
if(strpos($filepaths[$j],'delete_log') === false){
//'abcd'のなかに'bc'が含まれていない場合
$file = new SplFileObject($filepaths[$j]);
$file->setFlags(SplFileObject::READ_CSV);
foreach($file as $line){
//終端の空行を除く処理 空行の場合に取れる値は後述
if(!is_null($line[0])){
$records[] = $line;
}
}
}
}
//csv中身チェック用
// echo('
');
// var_dump($filepaths);
// echo('
');
for($i=0; $i < count($records); $i++){
$race_no = preg_replace('/[^0-9]/', '', $records[$i][5]);
$race_no = str_pad($race_no, 2, 0, STR_PAD_LEFT);
if( $records[$i][2] == "平" ) $racejoNameConv='いわき平';
else $racejoNameConv=$records[$i][2];
$SR_link = "SR".$records[$i][1].conv_racecourse($racejoNameConv).$race_no;
$shussou = get_posts( array(
's' => $SR_link,
'post_type' => 'keirin_race',
'posts_per_page' => -1,
'post_status' => 'publish',
'category' => null,
'orderby' => 'title',
'order' => 'ASC',
) );
$SR_f = "";
if(empty($shussou)) $SR_f = "sr_no";
//検索コード
$placeNo_code = substr($SR_link, 10,2);
$place_name = conv_racecourse( $placeNo_code );
$scode = date('n/j', strtotime(substr($SR_link, 2,8))).'__'.$place_name;
//引数
$kaisai = get_posts( array(
's' => $scode,
'numberposts' => -1,
'posts_per_page' => 1,
'post_type' => 'keirin_schedule',
'category' => null,
));
foreach ( $kaisai as $post ) :
setup_postdata( $post );
//schedule_FI
$schedule_FI = get_post_meta($post->ID , 'schedule_FI' ,true);
//schedule_FII
$schedule_FII = get_post_meta($post->ID , 'schedule_FII' ,true);
//schedule_GI
$schedule_GI = get_post_meta($post->ID , 'schedule_GI' ,true);
//schedule_GII
$schedule_GII = get_post_meta($post->ID , 'schedule_GII' ,true);
//schedule_GIII
$schedule_GIII = get_post_meta($post->ID , 'schedule_GIII' ,true);
//schedule_GP
$schedule_GP = get_post_meta($post->ID , 'schedule_GP' ,true);
//schedule_ガールズ
$schedule_girls = get_post_meta($post->ID , 'schedule_ガールズ' ,true);
//schedule_ナイター
$schedule_nighter = get_post_meta($post->ID , 'schedule_ナイター' ,true);
//schedule_ミッドナイト
$schedule_midnight = get_post_meta($post->ID , 'schedule_ミッドナイト' ,true);
//schedule_モーニング
$schedule_morning = get_post_meta($post->ID , 'schedule_モーニング' ,true);
//schedule_日付
$schedule_date = get_post_meta($post->ID , 'schedule_日付' ,true);
//場所
$schedule_place = get_post_meta($post->ID , 'schedule_会場' ,true);
//日目
$schedule_date_count = get_post_meta($post->ID , 'schedule_日目' ,true);
$template_directory = get_stylesheet_directory_uri();
endforeach;
// if ( $schedule_GP == '1' ) {$F = 'GP';$gradeBg="444";}
// if ( $schedule_GI == '1' ) {$F = 'GI';$gradeBg="444";}
// if ( $schedule_GII == '1' ) {$F = 'GII';$gradeBg="444";}
// if ( $schedule_GIII == '1' ) {$F = 'GIII';$gradeBg="444";}
// if ( $schedule_FI == '1' ) {$F = 'FI';$gradeBg="444";}
// if ( $schedule_FII == '1' ) {$F = 'FII';$gradeBg="444";}
if ( $schedule_morning == '1' ) {$timeBg = "noonBgColor";}
elseif ( $schedule_nighter == '1' ) {$timeBg = "nightBgColor";}
elseif ( $schedule_midnight == '1' ) {$timeBg = "midnightBgColor";}
else {$timeBg = "noonBgColor";}
//時間の整形
// $timestamp = $records[$i][7].':00';
//時間から背景色をあてがう
// if ( strtotime($timestamp) <= strtotime('16:00:00')) {$timeBg = "noonBgColor";}
// elseif (strtotime($timestamp)<= strtotime('20:59:00')) {$timeBg = "nightBgColor";}
// else{$timeBg="midnightBgColor";}
//レースグレード 背景色
if ($records[$i][3] == "GP"){ $gradeBg = "gpGradeBg";}
if ($records[$i][3] == "GI"){ $gradeBg = "giGradeBg";}
if ($records[$i][3] == "GII"){ $gradeBg = "giiGradeBg";}
if ($records[$i][3] == "GIII"){ $gradeBg = "giiiGradeBg";}
if ($records[$i][3] == "FI"){ $gradeBg = "fiGradeBg";}
if ($records[$i][3] == "FII"){ $gradeBg = "fiiGradeBg";}
//開催日文字色
if ($records[$i][4] == "最終日"){$kaisaibiFontColor = "lastDayFontColor";}
else {$kaisaibiFontColor = "otherDayFontColor";}
$win = "";
if(!empty($records[$i][11])) $win = '
'.$records[$i][10].' 今年の勝率'.$records[$i][11].'%
';
$auto_teppan .= '
'.$records[$i][6].'番車 '.$records[$i][8].'
';
}
return $auto_teppan;
}
add_shortcode('suponiti_auto_teppan', 'suponiti_auto_teppanFunc');
////////JSON//////////////////////////////////////////////////////////
require_once locate_template('function_honban_only.php');
//////////////////////////////////////////////////////////////////
////////メールアドレス設定/////////////////////////////////////////////////
function set_mail_from( $email ) {
return 'info@keirinsponichi.jp';
}
function set_mail_from_name( $email_from ) {
return '競輪スポニチ';
}
add_filter( 'wp_mail_from', 'set_mail_from' );
add_filter( 'wp_mail_from_name', 'set_mail_from_name' );
//////////////////////////////////////////////////////////////////
// ===================================================================
// ショートコード 2020/03/08
// ===================================================================
/**
* 昨日の開催一覧ショートコード
*/
add_shortcode( 'keirin_schedule_yesterday_list', function( $attrs ){
$joName = array('久留米' , '伊東', '大宮' , '玉野');
//検索コード(SR+年月日)
$timestamp = time() +3600*9 - 3600*24;//追加 1日前
$scode = date(("Y/n/j") , $timestamp ).'__'.$post->post_content;
// $scode = date_i18n(("Y/n/j") , strtotime("-1 day")).'__'.$post->post_content;
//引数
$attrs = shortcode_atts( array(
's' => $scode,
'numberposts' => -1,
'posts_per_page' => -1,
'post_type' => 'keirin_schedule',
'category' => null,
'orderby' => 'title',
'order' => 'ASC',
), $attrs );
//投稿の取得
$posts = get_posts( $attrs );
//出力
ob_start();
if ( $posts ) {
// global $post;
$schedule_placecode_temp = '';
$schedule_area_count = 1;
$roop_count = 0;
foreach ( $posts as $post ) {
setup_postdata( $post );
//schedule_FI
$schedule_FI = get_post_meta($post->ID , 'schedule_FI' ,true);
//schedule_FII
$schedule_FII = get_post_meta($post->ID , 'schedule_FII' ,true);
//schedule_GI
$schedule_GI = get_post_meta($post->ID , 'schedule_GI' ,true);
//schedule_GII
$schedule_GII = get_post_meta($post->ID , 'schedule_GII' ,true);
//schedule_GIII
$schedule_GIII = get_post_meta($post->ID , 'schedule_GIII' ,true);
//schedule_GP
$schedule_GP = get_post_meta($post->ID , 'schedule_GP' ,true);
//schedule_ガールズ
$schedule_girls = get_post_meta($post->ID , 'schedule_ガールズ' ,true);
//schedule_ナイター
$schedule_nighter = get_post_meta($post->ID , 'schedule_ナイター' ,true);
//schedule_ミッドナイト
$schedule_midnight = get_post_meta($post->ID , 'schedule_ミッドナイト' ,true);
//schedule_モーニング
$schedule_morning = get_post_meta($post->ID , 'schedule_モーニング' ,true);
//schedule_日付
$schedule_date = get_post_meta($post->ID , 'schedule_日付' ,true);
//場所
$schedule_place = get_post_meta($post->ID , 'schedule_会場' ,true);
//日目
$schedule_date_count = get_post_meta($post->ID , 'schedule_日目' ,true);
//stylesheet URL
$template_directory = get_stylesheet_directory_uri();
if ( $roop_count == 0 ) {
?>
' . do_shortcode( '[keirin_schedule_yesterday_list]' ) .'
' . do_shortcode( '[keirin_schedule_list]' ) .'
車券購入
';
return $result;
}
add_shortcode('race_tab_for_top', 'race_tab_for_top_func');
/**
* 管理画面に追加のスタイルを追加する例です。
* 例は管理画面のカテゴリーの段組を解除する追加スタイルです。
*/
function custom_admin_style() {
?> '',
), $attr));
$result = '';
if(empty($getslug))return $result;
// if($getslug==="kaime"){
// date_default_timezone_set('Asia/Tokyo');
// $day = date('Ymd');
// $getslug = "kaime_";
// }
//今見てるページ
$get_page = get_page_by_path($getslug);
$result = do_shortcode($get_page -> post_content);
return $result;
}
add_shortcode('inc_page_get', 'inc_page_getFunc');
require_once locate_template('lib/cvsimport/csvimport_func.php'); //買い目データ関連
// 買い目
function kaime_dailyFunc($attr){
global $uploaddir;
date_default_timezone_set('Asia/Tokyo');
$day = date('Ymd');
//井上
$percent ="";
$person = "inoue";
$filename= $uploaddir.''.$person .'/'.$person .'_d_'.$day. '.txt';
$filename_utfed= $uploaddir.''.$person .'/'.$person .'_d_'.$day. '_utfed.txt';
if (file_exists($filename)) {
$fp = fopen($filename, 'r');
$fileContent = file_get_contents($filename);
//UTF8へ変換
$fileContent = mb_convert_encoding($fileContent, 'UTF-8', 'sjis-win');
//ファイルの読み書き
$fpw = fopen($filename_utfed, 'w');
// fwriteで文字列を書き込む
fwrite($fpw, $fileContent);
// ファイルを閉じる(書き出し)
fclose($fpw);
// whileで行末までループ処理
while (!feof($fp)) {
// fgetsでファイルを読み込み、変数に格納
$txt = fgets($fp);
if(strpos($txt,'_percent') === false){
$str = mb_convert_encoding($txt, "UTF-8", "ASCII,JIS,UTF-8,EUC-JP,SJIS");
}
else{
$percent = str_replace('_percent', '', $txt);
}
// ファイルを読み込んだ変数を出力
}
//出力
echo'
';
}
//小橋
$percent ="";
$person = "kobashi";
$filename= $uploaddir.''.$person .'/'.$person .'_d_'.$day. '.txt';
$filename_utfed= $uploaddir.''.$person .'/'.$person .'_d_'.$day. '_utfed.txt';
if (file_exists($filename)) {
$fp = fopen($filename, 'r');
$fileContent = file_get_contents($filename);
//UTF8へ変換
$fileContent = mb_convert_encoding($fileContent, 'UTF-8', 'sjis-win');
//ファイルの読み書き
$fpw = fopen($filename_utfed, 'w');
// fwriteで文字列を書き込む
fwrite($fpw, $fileContent);
// ファイルを閉じる(書き出し)
fclose($fpw);
// whileで行末までループ処理
while (!feof($fp)) {
// fgetsでファイルを読み込み、変数に格納
$txt = fgets($fp);
if(strpos($txt,'_percent') === false){
$str = mb_convert_encoding($txt, "UTF-8", "ASCII,JIS,UTF-8,EUC-JP,SJIS");
}
else{
$percent = str_replace('_percent', '', $txt);
}
// ファイルを読み込んだ変数を出力
}
//出力
echo'
';
}
//カケル
$percent ="";
$person = "mrx";
$filename= $uploaddir.''.$person .'/'.$person .'_d_'.$day. '.txt';
$filename_utfed= $uploaddir.''.$person .'/'.$person .'_d_'.$day. '_utfed.txt';
if (file_exists($filename)) {
$fp = fopen($filename, 'r');
$fileContent = file_get_contents($filename);
//UTF8へ変換
$fileContent = mb_convert_encoding($fileContent, 'UTF-8', 'sjis-win');
//ファイルの読み書き
$fpw = fopen($filename_utfed, 'w');
// fwriteで文字列を書き込む
fwrite($fpw, $fileContent);
// ファイルを閉じる(書き出し)
fclose($fpw);
// whileで行末までループ処理
while (!feof($fp)) {
// fgetsでファイルを読み込み、変数に格納
$txt = fgets($fp);
if(strpos($txt,'_percent') === false){
$str = mb_convert_encoding($txt, "UTF-8", "ASCII,JIS,UTF-8,EUC-JP,SJIS");
}
else{
$percent = str_replace('_percent', '', $txt);
}
// ファイルを読み込んだ変数を出力
}
//出力
echo'
';
}
}
add_shortcode('kaime_daily', 'kaime_dailyFunc');
// 2020/06/27
function my_admin_style() {
echo ''.PHP_EOL;
}
add_action('admin_print_styles', 'my_admin_style');
add_action( 'init', 'custum_post_type' );
function custum_post_type() {
register_post_type( 'girls_keirin',
array('labels' =>
array(
'name' => __( 'ガールズケイリン' ),
'singular_name' => __( 'ガールズケイリン' )
),
'public' => true,
'menu_position' => 40, //管理画面の左メニュー何番目に表示させるか
'hierarchicla' => true,
'supports' => array('title','editor','thumbnail',
)
)
);
register_post_type( 'midnight_keirin',
array('labels' =>
array(
'name' => __( 'ミッドナイトケイリン' ),
'singular_name' => __( 'ミッドナイトケイリン' )
),
'public' => true,
'menu_position' => 40, //管理画面の左メニュー何番目に表示させるか
'hierarchicla' => true,
'supports' => array('title','editor','thumbnail',
)
)
);
}
//ガールズケイリン
function girls_keirinFunc($attr) {
extract(shortcode_atts(array(
"num" => '',
), $attr));
$args = array(
'posts_per_page' => $num, // 表示する投稿数
'post_type' => 'girls_keirin', // 取得する投稿タイプのスラッグ
'orderby' => 'date', //日付で並び替え
'order' => 'DESC' // 降順 or 昇順
);
$my_posts = get_posts($args);
foreach ($my_posts as $post)
{
// アイキャッチ画像を取得
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumb_url = wp_get_attachment_image_src($thumbnail_id, 'small');
$output = preg_match_all( '/image="(\w+)"/' , $post->post_content, $matches );
$image_url = wp_get_attachment_url( $matches[1][0] );
$output2 = preg_match_all( '/
' . $records[$i][9] . '