"; } $ret .= mb_substr($value, $i * $cutLen, $cutLen); } else{ $ret = $value; } $ret = nl2br( $ret ); return $ret; } /*---------------------------------------------------- 文字列を指定された桁数で切る ----------------------------------------------------*/ function MODIFIER_lengthCut ( $value, $param=NULL ){ if ( $value == "" ) { return NULL; } if ( is_array( $param ) ){ if ( mb_strlen ( $value ) > $param[0] ) { $ret = mb_substr( $value, 0, $param[0] ); return $ret . "..."; } } else{ if ( mb_strlen ( $value ) > $param ) { $ret = mb_substr( $value, 0, $param ); return $ret . "..."; } } return $value; } /*---------------------------------------------------- 文字列を指定された行数で切る ----------------------------------------------------*/ function MODIFIER_sentence ( $value, $param=NULL ){ if ( $value == "" ) { return NULL; } unset ( $sent ); $sentence = preg_split ( "#|\n#", $value ); for ( $i = 0; $i < count ( $sentence ); $i++ ) { if ( $sentence[$i] != "" && !preg_match ( "#^\n#", $sentence[$i] ) ) { $sent[] = $sentence[$i]; } } if ( count ( $sent ) > 0 ) { $arr = @array_chunk ( $sent, $param ); $value = @join ( "
", $arr[0] ); } else { $value = ""; } return $value; } /*---------------------------------------------------- 時刻変換(HH:MM:SS=>HH:MM) ----------------------------------------------------*/ function MODIFIER_timeHMM ( $value, $param=NULL ){ global $ini; $times = explode( ":", $value ); $ret = $times[0] . ":" . $times[1]; return $ret; } /*---------------------------------------------------- 時刻(分)の表示形式 ----------------------------------------------------*/ function MODIFIER_dispMin ( $value, $param=NULL ) { $ret = sprintf( "%02d", $value ); return $ret; } /* ------------------------------------- htmlEntityDecode HTML タグを有効にする ------------------------------------- */ function MODIFIER_htmlEntityDecode ( $value, $param=NULL ) { $ret = html_entity_decode( $value, ENT_QUOTES ); return $ret; } /* ------------------------------------- stripTags HTML・PHP タグを除去する ------------------------------------- */ function MODIFIER_stripTags ( $value, $param=NULL ) { $ret = strip_tags( $value ); return $ret; } /* ------------------------------------- numeric 数字化する ------------------------------------- */ function MODIFIER_numeric ( $value, $param=NULL ) { $ret = intval( $value ); return $ret; } /* ------------------------------------- val2str_date 日型を文字列にする ------------------------------------- */ function MODIFIER_val2str_date ( $value, $param=NULL ) { $ret = val2str_date( $value ); return $ret; } /* ------------------------------------- val2slash_date 日型を文字(/)列にする ------------------------------------- */ function MODIFIER_val2slash_date ( $value, $param=NULL ) { $ret = val2slash_date( $value ); return $ret; } /* ------------------------------------- numberSum 足し引きをする ------------------------------------- */ function MODIFIER_numberAU ( $value, $param=NULL ) { preg_match("#^([\+\-\*\/])?(\d+)#",$param[0],$match); if($match[1]==""){ $match[1]="+"; } $eval = "\$ret=$value{$match[1]}{$match[2]};"; eval($eval); return $ret; } ?> VAL ==============================================================================*/ /*---------------------------------------------------- 名前変換 DB -> VAL ----------------------------------------------------*/ function db2val_name( $input ) { list( $ret["familyName"], $ret["givenName"] ) = explode( "@", $input ); return $ret; } /*---------------------------------------------------- email 変換 DB -> VAL ----------------------------------------------------*/ function db2val_email( $input ) { list( $ret["account"], $ret["domain"] ) = explode( "@", $input ); return $ret; } /*---------------------------------------------------- 電話番号 変換 DB -> VAL ----------------------------------------------------*/ function db2val_phone( $input ) { list( $ret["phone1"], $ret["phone2"], $ret["phone3"] ) = explode( "-", $input ); return $ret; } /*---------------------------------------------------- 日付変換 DB -> VAL ----------------------------------------------------*/ function db2val_date( $input ) { if ( $input == "0000-00-00" ){ $input = ""; } if ( $input != "" ) { list( $year, $month, $day ) = explode( "-", $input ); // ゼロサプレス $ret["year"] = sprintf( "%d", $year ); $ret["month"] = sprintf( "%d", $month ); $ret["day"] = sprintf( "%d", $day ); $ret["date"] = sprintf( "%d/%d/%d", $year, $month, $day ); $ret["DB"] = $input; } else { $ret["year"] = ""; $ret["month"] = ""; $ret["day"] = ""; } return $ret; } /*---------------------------------------------------- 時間変換 DB -> VAL ----------------------------------------------------*/ function db2val_datetime( $input ) { if ( $input != "" ) { list( $date, $time ) = explode( " ", $input ); list( $year, $month, $day ) = explode( "-", $date ); list( $hour, $min, $sec ) = explode( ":", $time ); // ゼロサプレス $ret["year"] = sprintf( "%d", $year ); $ret["month"] = sprintf( "%d", $month ); $ret["day"] = sprintf( "%d", $day ); $ret["hour"] = sprintf( "%02d", $hour ); $ret["min"] = sprintf( "%02d", $min ); $ret["sec"] = sprintf( "%02d", $sec ); $ret["date"] = sprintf( "%d/%d/%d", $year, $month, $day ); $ret["time"] = sprintf( "%02d:%02d:%02d", $hour, $min, $sec ); $ret["DB"] = $input; } else { $ret["year"] = ""; $ret["month"] = ""; $ret["day"] = ""; $ret["hour"] = ""; $ret["min"] = ""; $ret["sec"] = ""; } return $ret; } /*---------------------------------------------------- 郵便番号変換 DB -> VAL ----------------------------------------------------*/ function db2val_postalCode( $input ) { list( $ret["postalCode1"], $ret["postalCode2"] ) = explode( "-", $input ); return $ret; } /*---------------------------------------------------- 年月変換 DB -> VAL ----------------------------------------------------*/ function db2val_yearMonth( $input ) { if ( $input != "" ) { list( $month, $day ) = explode( "-", $input ); // ゼロサプレス $ret["month"] = sprintf( "%d", $month ); $ret["day"] = sprintf( "%d", $day ); } else { $ret["month"] = ""; $ret["day"] = ""; } return $ret; } /*---------------------------------------------------- 時刻変換(HH:MM:SS=>HH:MM) ----------------------------------------------------*/ function db2val_timeHMM ( $input ){ $times = explode( ":", $input ); $ret = $times[0] . ":" . $times[1]; return $ret; } /*---------------------------------------------------- 時刻変換(HH:MM:SS=>hour, min) ----------------------------------------------------*/ function db2val_hourMin ( $input ){ $times = explode( ":", $input ); $ret["hour"] = sprintf( "%d" , $times[0] ); $ret["min"] = sprintf( "%02d", $times[1] ); return $ret; } /*---------------------------------------------------- 文章にリンク先URL(Aタグ)をつける ----------------------------------------------------*/ function db2val_contentWithURL ( $content, $url, $linkType ){ if( trim( $url ) == "" ){ return $content; } if( $linkType != "1" && $linkType != "2" ){ return $content; } $tag_from_s = ""; $tag_from_e["2"] = "' target='_blank'>"; $tag_to = ""; $tag_from = $tag_from_s . $url . $tag_from_e["{$linkType}"]; $wkContent = mb_ereg_replace( "\[\[\[", $tag_from, $content ); $ret = nl2br( mb_ereg_replace( "\]\]\]", $tag_to, $wkContent ) ); return $ret; } /*============================================================================= VAL => DB ==============================================================================*/ /*---------------------------------------------------- 年月変換 VAL -> DB ----------------------------------------------------*/ function val2db_yearMonth( $input ) { if ( is_numeric( $input["month"] ) && is_numeric( $input["day"] ) ) { $month = sprintf( "%02d", $input["month"] ); $day = sprintf( "%02d", $input["day"] ); $ret = $month . "-" . $day; } else { $ret["com"] = "NULL"; } return $ret; } /*---------------------------------------------------- 時分変換 VAL -> DB ----------------------------------------------------*/ function val2db_hourMin( $input ) { if ( is_numeric( $input["hour"] ) && is_numeric( $input["min"] ) ) { $hour = sprintf( "%02d", $input["hour"] ); $min = sprintf( "%02d", $input["min"] ); $ret = $hour . ":" . $min; } else { $ret["com"] = "NULL"; } return $ret; } /*---------------------------------------------------- 名前変換 VAL -> DB ----------------------------------------------------*/ function val2db_name( $input ) { $ret = $input["familyName"] . "@" . $input["givenName"]; return $ret; } /*---------------------------------------------------- 年月日変換 VAL -> DB ----------------------------------------------------*/ function val2db_date( $input ) { $ret = val2db_dateNULL($input); if ( !( @checkdate( $input["month"], $input["day"], $input["year"] ) ) ) { $ret["com"] = "NULL"; } return $ret; } /*---------------------------------------------------- 年月日変換 VAL -> DB ----------------------------------------------------*/ function val2db_dateNULL( $input ) { if( !is_array( $input ) ) { preg_match( "/^(\d+)[-\.\/ ](\d+)[-\.\/ ](\d+)$/", $input, $match ); if ( count( $match ) > 0 ) { unset( $input ); $input["year"] = sprintf( "%d", $match[1] ); $input["month"] = sprintf( "%d", $match[2] ); $input["day"] = sprintf( "%d", $match[3] ); } } if ( @checkdate( $input["month"], $input["day"], $input["year"] ) ) { $month = sprintf( "%02d", $input["month"] ); $day = sprintf( "%02d", $input["day"] ); $ret = $input["year"] . "-" . $month . "-" . $day; } return $ret; } /*---------------------------------------------------- 年月日変換 VAL -> STR ----------------------------------------------------*/ function val2str_date( $input ) { if($input["year"]==""&&$input["month"]==""&&$input["day"]==""){ return; } $month = sprintf( "%02d", $input["month"] ); $day = sprintf( "%02d", $input["day"] ); $ret = $input["year"] . $month . $day; return $ret; } /*---------------------------------------------------- 年月日変換 VAL -> STR(/) ----------------------------------------------------*/ function val2slash_date( $input ) { if($input["year"]==""&&$input["month"]==""&&$input["day"]==""){ return; } $month = sprintf( "%d", $input["month"] ); $day = sprintf( "%d", $input["day"] ); $ret = $input["year"].'/'.$month.'/'.$day; return $ret; } /*---------------------------------------------------- 年月日変換 STR -> VAL ----------------------------------------------------*/ function str2val_date( $input ) { preg_match("#(\d{4})-?(\d{2})-?(\d{2})#", $input, $match); array_shift($match); list($year,$month,$day) = $match; $year = (int)$year; $month = (int)$month; $day = (int)$day; if(checkdate($month,$day,$year)){ $ret = compact("year","month","day"); } return $ret; } /*---------------------------------------------------- 日時変換 VAL -> DB ----------------------------------------------------*/ function val2db_datetime( $input ) { if( !is_array( $input ) ) { preg_match( "/^(\d+)[-\.\/ ](\d+)[-\.\/ ](\d+) (\d+):(\d+):(\d+)$/", $input, $match ); if ( count( $match ) > 0 ) { unset( $input ); $input["year"] = sprintf( "%d", $match[1] ); $input["month"] = sprintf( "%d", $match[2] ); $input["day"] = sprintf( "%d", $match[3] ); $input["hour"] = sprintf( "%d", $match[4] ); $input["min"] = sprintf( "%d", $match[5] ); $input["sec"] = sprintf( "%d", $match[6] ); } } if ( @checkdate( $input["month"], $input["day"], $input["year"] ) ) { $month = sprintf( "%02d", $input["month"] ); $day = sprintf( "%02d", $input["day"] ); $hour = sprintf( "%02d", $input["hour"] ); $min = sprintf( "%02d", $input["min"] ); $sec = sprintf( "%02d", $input["sec"] ); $ret = $input["year"] . "-" . $month . "-" . $day . " " . $hour . ":" . $min . ":" . $sec; } else { $ret["com"] = "NULL"; } return $ret; } /*---------------------------------------------------- メールアドレス変換 VAL -> DB ----------------------------------------------------*/ function val2db_email( $input ) { $ret = $input["account"] . "@" . $input["domain"]; return $ret; } /*---------------------------------------------------- 電話番号変換 VAL -> DB ----------------------------------------------------*/ function val2db_phone( $input ) { if ( ( is_numeric( $input["phone1"] ) && strlen( $input["phone1"] ) < 10 ) && ( is_numeric( $input["phone2"] ) && strlen( $input["phone2"] ) < 10 ) && ( is_numeric( $input["phone3"] ) && strlen( $input["phone3"] ) < 10 ) ) { $phone = array( $input["phone1"], $input["phone2"], $input["phone3"] ); $ret = @join( "-", $phone ); } else { $ret = ""; } return $ret; } /*---------------------------------------------------- 郵便番号変換 VAL -> DB ----------------------------------------------------*/ function val2db_postalCode( $input ) { if ( strlen( $input["postalCode1"] ) < 5 && strlen( $input["postalCode2"] ) < 10 ) { $postalCode = array( $input["postalCode1"], $input["postalCode2"] ); $ret = @join( "-", $postalCode ); } else { $ret = ""; } return $ret; } /*---------------------------------------------------- 年齢 date(val) -> age ----------------------------------------------------*/ function val2age_date( $input ) { $bd = sprintf("%4d",$input["year"]); $bd .= sprintf("%02d",$input["month"]); $bd .= sprintf("%02d",$input["day"]); return (int) ((date('Ymd')-$bd)/10000); } ?>set_basePath(); // セッションKey/IDの取得 $this->get_sessionInfo(); // ログアウト if( $ini["flg_logout"] != 1 && ( preg_match ( "#^logout#", $_SERVER["QUERY_STRING"] ) || preg_match ( "#^logout#", $_POST["stb034logout"] ) || preg_match ( "#logout$#", $path["script"]["fileRP"] ) ) ) { $this->logoutFlag = 1; $this->logout(); unset ( $_COOKIE["bason"]["session"][$this->zone] ); unset ( $_COOKIE ); $ini["flg_logout"] = 1; return; } // モード・ゾーンが設定されていない if ( !( $this->is_loginPage() ) && ( $ini["session"]["mode"] == "" || $ini["session"]["mode"] == "none" || $ini["session"]["zone"] == "" ) ) { return; } else { if ( !in_array( $ini["session"]["mode"], array ( "login", "loginAuto", "monitor", "monitorAuto", "loginDenyAuto", "loginStrict", "none" ) ) ) { return; } } // 異常ナシをベースにする $this->st["sessionLive"] = 10; // loginStrict モード if ( $ini["session"]["mode"] == "loginStrict" ) { if ( !$this->check_loginStrict() ) { $this->st["sessionLive"] = 7; } } // ライブIDがDBに存在してない(ログインしていない) elseif ( $this->tbl["sessionLive"]["memberID"] == "" ) { $this->st["sessionLive"] = 2; } // ライブIDがタイムアウトしている elseif ( $this->is_sessionLive_timeout() ) { $this->st["sessionLive"] = 5; } // loginDenyAuto であり、且つ現在Autoでログイン中 elseif ( preg_match ( "#DenyAuto#i", $ini["session"]["mode"] ) && $this->tbl["sessionLive"]["auto"] == "auto" ) { $this->st["sessionLive"] = 9; } // レベルが足りない elseif ( !$this->is_levelANDstatus() ) { $this->st["sessionLive"] = 4; } // ファンドとブログの相関チェック 2011.6.22 K.Takeda elseif ( preg_match( "/oen_article.php/", $_SERVER["REQUEST_URI"] ) ){ if ($this->checkBlogFund() ){ $this->st["sessionLive"] = 4; } } // 非ログイン状態である if ( $this->st["sessionLive"] != 10 ) { // 自動ログインモード if ( $this->autoLogin == 1 && preg_match ( "#auto#i", $ini["session"]["mode"] ) && !( preg_match ( "#DenyAuto#i", $ini["session"]["mode"] ) ) ) { // レベルチェックチェックをクリアした場合 if ( $this->is_levelANDstatus() ) { $this->exec_login( "auto" ); $this->st["sessionLive"] = 10; } else { $this->st["sessionLive"] = 4; } } // 非自動ログインモード else { // モニター系モード if ( preg_match ( "#monitor#i", $ini["session"]["mode"] ) ) { // モニターメンバー情報の取得 $this->get_monitorMemberInfo(); // メンバーIDがない if ( !( $this->memberID > 0 ) ) { // 仮メンバー登録 & マスター登録 $this->add_loginAsTemporaryMember(); return; } } // 非モニター系モード(ログインページ以外) elseif ( $this->flg_loginPage == "" ) { // ■ ログインページにリダイレクション ■ $this->loginFault_redirection(); return; } } } // ログイン状態である else { $this->st["sessionLive"] = 10; // sessionDBアップデート $this->update_sessionDB( "live" ); $this->update_sessionDB( "master" ); // ログイン直後 if ( $this->is_sessionData() ) { // データを読み戻す list( $originalURL, $sessionData ) = $this->get_originalSessionData(); $justInput = array_mix ( $justInput, $sessionData ); // セッションデータを消す $this->delete_dbSessionData(); if($ini["session"]["dupLogin"]=="deny" && $this->memberID>0 && $ini["session"]["zone"]!="" && $this->id["sessionLive"]!=""){ $live_sql="DELETE FROM sessionLive WHERE memberID=$this->memberID AND zone=\"{$ini["session"]["zone"]}\" AND sessionID<>\"{$this->id["sessionLive"]}\""; sql_query ( $live_sql ); if($this->id["sessionMaster"]!=""){ $master_sql="DELETE FROM sessionMaster WHERE memberID=$this->memberID AND zone=\"{$ini["session"]["zone"]}\" AND sessionID<>\"{$this->id["sessionMaster"]}\""; sql_query ( $master_sql ); } } } if($ini["session"]["pwLimit"]==1){ $pcdate = val2str_date(db2val_date($this->tbl["sessionMember"]["passwordChangeDate"])); $expiredate[1] = val2str_date(db2val_date(date("Y-m-d",mktime(0,0,0,date("m")-$ini["session"]["pwExpire"]["first"],date("d"),date("Y"))))); $expiredate[2] = val2str_date(db2val_date(date("Y-m-d",mktime(0,0,0,date("m")-$ini["session"]["pwExpire"]["second"],date("d"),date("Y"))))); if($pcdate<$expiredate[2]){ $this->st["sessionLive"] = 3; // メンバーのステータスを無効にする $this->member_status2invalid(); } elseif($pcdate<$expiredate[1]){ $this->pwExpire_redirection(); } } } if ( $this->st["sessionLive"] != 10 ) { // ■ ログインページにリダイレクション ■ $this->loginFault_redirection(); return; } } function is_levelANDstatus () { global $ini; // 退会者はログイン不可 if ( $this->status == 9 ) { return false; } if ( $this->level > 0 && $this->level >= $ini["session"]["level"] && $this->status > 0 && $this->status >= $ini["session"]["status"] ) { return true; } return false; } function set_basePath () { global $path, $ini; if ( $ini["session"]["loginRootUrl"] == "" ) { return; } list ( $https, $dirName ) = explode ( ",", $ini["session"]["loginRootUrl"] ); $path["loginRoot"]["https"] = trim ( $https ); $path["loginRoot"]["dirName"] = trim ( $dirName ); // ログイン関係 $this->httpsHead = ( $path["loginRoot"]["https"] == "https" ) ? $path["https"]["domain"] : $path["http"]["domain"]; $path["loginRoot"]["url"] = pathGlue ( "{$this->httpsHead}/{$path["loginRoot"]["dirName"]}" ); $path["loginRoot"]["dirRP"] = $path["loginRoot"]["dirName"]; $path["loginRoot"]["logic"]["dirRP"] = $path["loginRoot"]["dirName"]; $path["loginRoot"]["logic"]["dirAP"] = pathGlue ( "{$path["logicRoot"]["dirAP"]}/{$path["loginRoot"]["dirName"]}" ); $path["loginRoot"]["template"]["dirRP"] = $path["loginRoot"]["dirName"]; $path["loginRoot"]["template"]["dirAP"] = pathGlue ( "{$path["templateRoot"]["dirAP"]}/{$path["loginRoot"]["dirName"]}" ); $path["loginRoot"]["template"]["fileRP"] = pathGlue ( "{$path["loginRoot"]["template"]["dirRP"]}/{$path["loginFault"]["fileName"]}" ); $path["loginRoot"]["template"]["fileAP"] = pathGlue ( "{$path["templateRoot"]["dirAP"]}/{$path["loginRoot"]["template"]["fileRP"]}" ); } /*---------------------------------------------------- モニターメンバー情報の取得 ----------------------------------------------------*/ function get_monitorMemberInfo() { if ( $this->id["sessionMaster"] != "" && !( $this->memberID > 0 ) ) { $this->get_session( "master", "session" ); } } /*---------------------------------------------------- 仮メンバー登録 ----------------------------------------------------*/ function add_loginAsTemporaryMember() { // 仮メンバー登録 $this->exec_temporaryMember(); // sessionIDの発行 $this->issue_sessionID( "master", "session" ); // sessionDBに追加 $this->add_sessionDB( "master" ); } /*---------------------------------------------------- 仮メンバー登録の実行 ----------------------------------------------------*/ function exec_temporaryMember() { global $ini; $insert["level"] = $ini["session"]["temporaryMember"]["level"]; $sql = "INSERT INTO sessionMember {insert_value}"; list ( $affectedRow, $memberID ) = sql_query ( $sql, $insert ); if($memberID > 0 && is_numeric($memberID)){ $this->memberID = $memberID; } } /*---------------------------------------------------- セッション情報の取得 ----------------------------------------------------*/ function get_sessionInfo() { global $path, $ini; // ログインゾーンの取得 $this->zone = $ini["session"]["zone"]; $this->get_session( "master", "session" ); if(!$this->get_sessionLive_byMemberID_andIP()){ $this->get_session( "live", "session" ); } if ( $path["ssl"] == "on" ) { $this->get_session( "master", "secure" ); $this->get_session( "live", "secure" ); } if ( $this->memberID > 0 ) { $this->get_basicMemberInfo(); } $this->loginUrlHeader = $path["loginRoot"]["https"]; $this->loginURL = $path["loginRoot"]["url"]; $this->flg_loginPage = ( $this->loginURL == $path["unit"]["url"] ) ? 1 : 0; $this->sessionDataID = $_COOKIE["bason"]["session"][$this->zone]["sessionDataID"]; } /*---------------------------------------------------- セッションライブ情報を取り出す ----------------------------------------------------*/ function get_sessionLive_byMemberID_andIP() { if($this->memberID>0){ $sql = "SELECT * FROM sessionLive WHERE memberID=$this->memberID AND IPAddress=\"{$_SERVER["REMOTE_ADDR"]}\" AND zone=\"{$this->zone}\" ORDER BY timestamp DESC LIMIT 1"; $tbl = sql_query($sql,"single"); if($tbl["sessionLive"]["memberID"]==$this->memberID){ $this->tbl["sessionLive"] = $tbl["sessionLive"]; $this->id["sessionLive"] = $this->tbl["sessionLive"]["sessionID"]; return true; } } return false; } /*---------------------------------------------------- セッション情報を取り出す ----------------------------------------------------*/ function get_session( $masterLive, $sessionSecure ) { global $ini; $ucMasterLive = ucfirst( $masterLive ); $ucSessionSecure = ucfirst( $sessionSecure ); if ( isset( $_COOKIE["bason"]["session"][$this->zone][$ucMasterLive][$ucSessionSecure] ) ) { $this->id["$sessionSecure$ucMasterLive"] = (string)$_COOKIE["bason"]["session"][$this->zone][$ucMasterLive][$ucSessionSecure]; } else { $this->issue_sessionID( $masterLive, $sessionSecure ); } $this->get_sessionDataDB( $masterLive, $sessionSecure ); } /*---------------------------------------------------------------- sessionLive/Masterテーブルの取得 ----------------------------------------------------------------*/ function get_sessionDataDB( $masterLive, $sessionSecure ) { global $path; $ucMasterLive = ucfirst( $masterLive ); $sql = "SELECT * FROM session$ucMasterLive WHERE {$sessionSecure}ID=\"{$this->id["$sessionSecure$ucMasterLive"]}\" AND zone=\"{$this->zone}\""; $this->tbl["session$ucMasterLive"] = sql_query ( $sql, "single" ); if ( $this->tbl["session$ucMasterLive"]["memberID"] > 0 ) { $this->memberID = $this->tbl["session$ucMasterLive"]["memberID"]; } } /*---------------------------------------------------- メンバー基本情報の取得 ----------------------------------------------------*/ function get_basicMemberInfo() { if($this->memberID>0){ $sql = "SELECT * FROM sessionMember WHERE memberID={$this->memberID}"; $this->tbl["sessionMember"] = sql_query ( $sql, "single" ); $this->level = $this->tbl["sessionMember"]["level"]; $this->status = $this->tbl["sessionMember"]["status"]; $this->autoLogin = $this->tbl["sessionMember"]["autoLogin"]; return true; } return false; } /*---------------------------------------------------- ログインページにいるのか? ----------------------------------------------------*/ function is_loginPage() { global $path, $ini; if ( $this->flg_loginPage != "" ) { return $this->flg_loginPage == 1 ? true : false; } return ( $this->loginURL == $path["unit"]["url"] ) ? true : false; } /*---------------------------------------------------- ログインページにリダイレクション ----------------------------------------------------*/ function loginFault_redirection() { global $path, $ini, $class, $justInput; if ( $this->logoutFlag != 1 ) { if ( isset( $_FILES ) ) { // アップロードしたファイルを移す ループ $this->copyUploadedFiles( $_FILES ); } // セッション用の入力値合わせ $justInput = $class["framework"]->get_justInput( "session" ); // セッションデータを消す $this->delete_dbSessionData(); // 入力値(シリアライズ)をDBに入れる $insert["serializedData"] = ngdfw_serialize ( $justInput ); $insert["sessionID"] = $this->id["sessionLive"]; $insert["url"] = $path["url"]["full"]; $sql = "INSERT INTO sessionData {insert_value}"; list ( $affectedRow, $sessionDataID ) = sql_query ( $sql, $insert ); // セッションデータIDをクッキーに入れる setcookie( "bason[session][$this->zone][sessionDataID]", $sessionDataID, 0, "/", $path["host"]["name"] ); // ZONE-IDをクッキーに入れる if ( $ini["session"]["zone"] != "" ) { setcookie( "bason[session][zone]", $ini["session"]["zone"], 0, "/", $path["host"]["name"] ); } } // 転送 $this->pageRedirection( $this->loginURL ); } /*---------------------------------------------------- パスワード有効期限切れリダイレクション ----------------------------------------------------*/ function pwExpire_redirection() { global $path, $ini, $class, $justInput; /* if ( isset( $_FILES ) ) { // アップロードしたファイルを移す ループ $this->copyUploadedFiles( $_FILES ); } // セッション用の入力値合わせ $justInput = $class["framework"]->get_justInput( "session" ); // セッションデータを消す $this->delete_dbSessionData(); // 入力値(シリアライズ)をDBに入れる $insert["serializedData"] = ngdfw_serialize ( $justInput ); $insert["sessionID"] = $this->id["sessionLive"]; $insert["url"] = $path["url"]["full"]; $sql = "INSERT INTO sessionData {insert_value}"; list ( $affectedRow, $sessionDataID ) = sql_query ( $sql, $insert ); // セッションデータIDをクッキーに入れる setcookie( "bason[session][$this->zone][sessionDataID]", $sessionDataID, 0, "/", $path["host"]["name"] ); // ZONE-IDをクッキーに入れる if ( $ini["session"]["zone"] != "" ) { setcookie( "bason[session][zone]", $ini["session"]["zone"], 0, "/", $path["host"]["name"] ); } */ list ( $https, $dirName ) = explode ( ",", $ini["session"]["pwExpire"]["url"] ); $path["pwExpire"]["https"] = trim ( $https ); $path["pwExpire"]["dirName"] = trim ( $dirName ); $pwExpire_httpsHead = ( $path["loginRoot"]["https"] == "https" ) ? $path["https"]["domain"] : $path["http"]["domain"]; $path["pwExpire"]["url"] = pathGlue ( "{$pwExpire_httpsHead}/{$path["pwExpire"]["dirName"]}" ); header("HTTP/1.1 301 Moved Permanently"); header('Pragma: no-cache'); header("Location: {$path["pwExpire"]["url"]}"); } function member_status2invalid(){ $update["status"]=7; $sql = "UPDATE sessionMember SET {update_set} WHERE memberID=$this->memberID"; sql_query ( $sql, $update ); } /*---------------------------------------------------- ログインページにリダイレクション ----------------------------------------------------*/ function pageRedirection( $url ) { global $ini, $output, $path; $output["loginURL"] = $url; $ini["flag_execute"] = "none"; $ini["view"] = "sessionFault"; } /*---------------------------------------------------- アップロードしたファイルを移す ループ ----------------------------------------------------*/ function copyUploadedFiles( $files ) { if ( is_array ( $files ) ) { foreach ( $files as $key => $val ) { if ( $key === "tmp_name" ) { $this->copyUPF_tmpName = 1; $copyUPF_tmpName = 1; } if ( is_array ( $val ) ) { $this->copyUploadedFiles( $val ); } else { if ( $this->copyUPF_tmpName === 1 ) { $this->exec_copyUploadFiles( $val ); } } if ( $copyUPF_tmpName == 1 ) { $this->copyUPF_tmpName = 0; $copyUPF_tmpName = 0; } } } } /*---------------------------------------------------- アップロードしたファイルを移す 実行 ----------------------------------------------------*/ function exec_copyUploadFiles( $tmp_name ) { global $path; $filename = preg_replace ( "#.*/#", "", $tmp_name ); $dest = pathGlue ( "{$path["temporaryUpload"]["dirAP"]}/$filename" ); copy ( $tmp_name, $dest ); } /*---------------------------------------------------- 入力値DBの存否 ----------------------------------------------------*/ function is_sessionData(){ // DBのデータがあるのか? $sql = "SELECT sessionID FROM sessionData WHERE sessionDataID=\"{$this->sessionDataID}\" AND sessionID=\"{$this->id["sessionLive"]}\""; $sessionDataDB = sql_query ( $sql, "single" ); return ( $sessionDataDB["sessionID"] == $this->id["sessionLive"] ) ? true : false; } /*---------------------------------------------------- 入力値を戻す ----------------------------------------------------*/ function get_originalSessionData(){ global $justInput, $path, $ini; if ( $this->sessionDataID != "" ) { // DBからデータを取り出す $sql = "SELECT * FROM sessionData WHERE sessionDataID=\"{$this->sessionDataID}\""; $sessionDataDB = sql_query ( $sql, "single" ); // 取り出した入力値をアンシリアライズ if ( $sessionDataDB["serializedData"] != "" ) { $originalURL = preg_replace ( "#\?logout$#", "", $sessionDataDB["url"] ); $sessionData = ngdfw_unserialize ( $sessionDataDB["serializedData"] ); } // セッションデータIDを消す // $this->delete_cookieSessionData(); } if ( $originalURL == "" ) { list ( $urlHeader, $fileRP ) = explode ( ",", $ini["session"]["defaultLoginUrl"] ); $fileRP = trim( $fileRP ); $this->defaultLoginUrl = $path[$urlHeader]["head"] . pathGlue ( $path["host"]["name"] . "/" . $fileRP ); $originalURL = $this->defaultLoginUrl; $this->no_before_login_url=1; } return array( $originalURL, $sessionData ); } /*---------------------------------------------------- DBのセッションデータを消す ----------------------------------------------------*/ function delete_dbSessionData(){ global $ini,$path; if($ini["session"]["pwLimit"]!=1){ list ( $https, $dirName ) = explode ( ",", $ini["session"]["pwExpire"]["url"] ); $dirName = trim( $dirName ); $path["pwExpire"]["url"] = $path[$https]["head"] . pathGlue ( $path["host"]["name"] . "/" . $dirName ); } if ( $this->id["sessionLive"] != "" && ($ini["session"]["pwLimit"]==1 || !preg_match("#^{$path["pwExpire"]["url"]}#",$path["url"]["full"] ))) { $sql = "DELETE FROM sessionData WHERE sessionID=\"{$this->id["sessionLive"]}\""; sql_query ( $sql ); } } /*---------------------------------------------------- クッキーのセッションデータを消す ----------------------------------------------------*/ function delete_cookieSessionData(){ global $path; setcookie( "bason[session][$this->zone][sessionDataID]", "", time() - 3600, "/", $path["host"]["name"] ); } /*---------------------------------------------------- レベルが足りない ----------------------------------------------------*/ function check_sessionLive_level() { global $ini; $timeout = date( "YmdHis", mktime( date("H"), date("i") - $ini["session"]["timeout"], date("s"), date("m"), date("d"), date("Y") ) ); $livetime = preg_replace ( "#-| |:#", "", $this->tbl["sessionLive"]["timestamp"] ); if ( $livetime < $timeout ) { return true; } return false; } /*---------------------------------------------------- ライブIDがタイムアウトしている ----------------------------------------------------*/ function is_sessionLive_timeout() { global $ini; $timeout = date( "YmdHis", mktime( date("H"), date("i") - $ini["session"]["timeout"], date("s"), date("m"), date("d"), date("Y") ) ); $livetime = preg_replace ( "#-| |:#", "", $this->tbl["sessionLive"]["timestamp"] ); if ( $livetime < $timeout ) { return true; } return false; } /*---------------------------------------------------- check_loginStrict ----------------------------------------------------*/ function check_loginStrict() { global $ini, $path; // ログイン直後である if ( $this->is_sessionData() ) { // ログインストリクトモードがオン $this->loginStrict = 1; return true; } // リファラーがある if ( $_SERVER["HTTP_REFERER"] != "" ) { // リファラーURL $refererURL = pathGlue ( preg_replace ( "#{$path["head"]["domain"]}#", "", $_SERVER["HTTP_REFERER"] ) ); // ログインストリクト領域内にリファラーURLが存在しているか? if ( preg_match ( "#{$ini["session"]["loginStrict"]}#", $refererURL ) ) { return true; } } return false; } /*---------------------------------------------------- logout ----------------------------------------------------*/ function logout() { global $ini, $path; // ログ作成 2010.12.22 K.Takeda $this->write_logoutLog(); $this->drop_sessionInfo(); // ZONE-IDをクッキーに入れる if ( $ini["session"]["zone"] != "" ) { setcookie( "bason[session][zone]", $ini["session"]["zone"], 0, "/", $path["host"]["name"] ); } unset ( $this ); } /*---------------------------------------------------- セッション情報を消す ----------------------------------------------------*/ function drop_sessionInfo() { if ( $this->memberID > 0 && $this->zone != "" ) { if ( $this->id["sessionMaster"] != "" ) { $sql = "DELETE FROM sessionMaster WHERE memberID={$this->memberID} AND zone=\"{$this->zone}\""; sql_query ( $sql ); $sql = "DELETE FROM sessionMaster_securite WHERE memberID={$this->memberID}"; sql_query ( $sql ); } if ( $this->id["sessionLive"] != "" ) { $sql = "DELETE FROM sessionLive WHERE memberID={$this->memberID} AND zone=\"{$this->zone}\""; sql_query ( $sql ); $sql = "DELETE FROM sessionLive_securite WHERE memberID={$this->memberID}"; sql_query ( $sql ); } } } /*---------------------------------------------------- セッションライブにエントリーを更新する ----------------------------------------------------*/ function update_sessionDB( $masterLive, $autoFlag=NULL ) { $ucMasterLive = ucfirst( $masterLive ); if ( $this->memberID > 0 && $this->zone != "" ) { $update["memberID"] = $this->memberID; if ( $this->id["secure$ucMasterLive"] != "" ) { $update["secureID"] = $this->id["secure$ucMasterLive"]; } if ( $autoFlag != NULL ) { $update["auto"] = $autoFlag; } $update["IPAddress"] = $_SERVER["REMOTE_ADDR"]; $update["timestamp"]["com"] = "now()"; $sql = "UPDATE session$ucMasterLive SET {update_set} WHERE sessionID=\"{$this->id["session$ucMasterLive"]}\" AND zone=\"{$this->zone}\""; sql_query ( $sql, $update ); } } /* ============================================================================================= ログイン処理 ============================================================================================= */ /*---------------------------------------------------- ロックアウト判定 ----------------------------------------------------*/ function is_lockout( $loginID=NULL ){ global $ini; if ( $loginID == NULL ) { return false; } // ロックアウト情報の取得 $sql = "SELECT * FROM loginTryCount WHERE loginID=\"$loginID\""; $this->tbl["loginTryCount"] = sql_query( $sql, "single" ); $this->tbl["loginTryCount"]["counter"] = sprintf ( "%d", $this->tbl["loginTryCount"]["counter"] ); // ロックアウトしている if( $this->tbl["loginTryCount"]["counter"] >= $ini["session"]["lockoutLimit"] ){ // ロックアウト期間を経過していないか? $nowPlus = date( "YmdHis", mktime( date("H"), date("i") - $ini["session"]["lockoutTimeIN"], date("s"), date("m"), date("d"), date("Y") ) ); $lockoutTime = preg_replace ( "#-| |:#", "", $this->tbl["loginTryCount"]["lockoutDatetime"] ); // 今ロックアウトした! if ( $lockoutTime == "" ) { $update["counter"] = $this->tbl["loginTryCount"]["counter"] + 1; $update["lockoutDatetime"]["com"] = "now()"; $sql = "UPDATE loginTryCount SET {update_set} WHERE loginID=\"$loginID\""; sql_query( $sql, $update ); } // ロックアウト期間を経過している elseif ( $nowPlus > $lockoutTime ) { $sql = "DELETE FROM loginTryCount WHERE loginID=\"$loginID\""; sql_query( $sql ); return false; } // ロックアウト期間中である else { $update["counter"] = $this->tbl["loginTryCount"]["counter"] + 1; $update["lockoutDatetime"]["com"] = "now()"; $sql = "UPDATE loginTryCount SET {update_set} WHERE loginID=\"$loginID\""; sql_query( $sql, $update ); } return true; } return false; } /*---------------------------------------------------- ログインIDとパスワードの確認 ----------------------------------------------------*/ function is_authorized( $loginID, $password ){ global $ini; if ( $loginID == "" || $password == "" ){ $this->st["sessionLive"] = 2; return false; } // メンバー情報の取得 // $sql = "SELECT * FROM sessionMember WHERE loginID=\"$loginID\" AND password=\"$password\" AND status='1'"; $sql = "SELECT * FROM sessionMember WHERE loginID=\"$loginID\" AND password=\"$password\""; $this->tbl["sessionMember"] = sql_query( $sql, "single" ); // ID・パスワード違い if( $this->tbl["sessionMember"]["memberID"] == "" ){ $this->st["sessionLive"] = 1; return false; } // ステータス(退会)チェック if( $this->tbl["sessionMember"]["status"] == 9 ){ $this->st["sessionLive"] = 4; return false; } // アクセス権限レベルチェック if( $this->tbl["sessionMember"]["level"] < $ini["session"]["level"] ){ $this->st["sessionLive"] = 4; return false; } if ( $this->memberID != $this->tbl["sessionMember"]["memberID"] ) { $this->monitorID = $this->memberID = $this->tbl["sessionMember"]["memberID"]; } elseif($this->memberID>0) { $this->monID = $this->memberID; } if($ini["session"]["pwLimit"]==1){ $pcdate = val2str_date(db2val_date($this->tbl["sessionMember"]["passwordChangeDate"])); $expiredate[1] = val2str_date(db2val_date(date("Y-m-d",mktime(0,0,0,date("m")-$ini["session"]["pwExpire"]["first"],date("d"),date("Y"))))); $expiredate[2] = val2str_date(db2val_date(date("Y-m-d",mktime(0,0,0,date("m")-$ini["session"]["pwExpire"]["second"],date("d"),date("Y"))))); if($pcdate<$expiredate[2]||$this->tbl["sessionMember"]["status"]==7){ $this->st["sessionLive"] = 3; // メンバーのステータスを無効にする $this->member_status2invalid(); return false; } elseif($pcdate<$expiredate[1]){ $this->pwExpire_redirection(); } } return true; } /*---------------------------------------------------- ロックアウトカウントアップ ----------------------------------------------------*/ function countUp_loginTryCount( $loginID ){ if ( $this->tbl["loginTryCount"]["counter"] == 0 ) { $insert["loginID"] = $loginID; $insert["counter"] = 1; $insert["insertDatetime"]["com"] = "now()"; $sql = "INSERT INTO loginTryCount {insert_value}"; sql_query( $sql, $insert ); } else { $update["counter"] = $this->tbl["loginTryCount"]["counter"] + 1; $sql = "UPDATE loginTryCount SET {update_set} WHERE loginID=\"$loginID\""; sql_query( $sql, $update ); } } /*---------------------------------------------------- ログインの実行 ----------------------------------------------------*/ function exec_login( $autoFlag=NULL ) { // セッションIDの発行 $this->issue_sessionID( "live", "session" ); $this->issue_sessionID( "live", "secure" ); $this->issue_sessionID( "master", "session" ); $this->issue_sessionID( "master", "secure" ); // sessionDBに追加 $this->add_sessionDB( "live", $autoFlag ); $this->add_sessionDB( "master" ); // ログイントライカウントをクリア $sql = "DELETE FROM loginTryCount WHERE loginID=\"$this->loginID\""; sql_query( $sql ); // sessionLive/Masterテーブルの取得 $this->get_sessionDataDB( "live", "session" ); $this->get_sessionDataDB( "live", "secure" ); $this->get_sessionDataDB( "master", "session" ); $this->get_sessionDataDB( "master", "secure" ); // メンバー基本情報の取得 $this->get_basicMemberInfo(); } /*---------------------------------------------------- セッションIDの発行 ----------------------------------------------------*/ function issue_sessionID( $masterLive, $sessionSecure ) { global $path; $ucMasterLive = ucfirst( $masterLive ); $sessionID = ""; $ucSessionSecure = ucfirst( $sessionSecure ); if ( $this->id["$sessionSecure$ucMasterLive"] == "" && ( $masterLive == "master" || $masterLive == "live" ) && ( $sessionSecure == "session" || $sessionSecure == "secure" ) ) { while ( $sessionID == "" ) { $tmpSessionID = create_randomString ( 32 ); if ( !( $this->is_sessionIDonDB( $tmpSessionID, $ucMasterLive, $sessionSecure ) ) ) { $sessionID = $tmpSessionID; } } $secureMode = ( $sessionSecure == "secure" ) ? 1 : 0; // $expireTerm = $masterLive == "master" ? time() + 3600 * 24 * 365 : 0; $expireTerm = 0; setcookie ( "bason[session][$this->zone][$ucMasterLive][$ucSessionSecure]", $sessionID, $expireTerm, "/", $path["host"]["name"], $secureMode ); // 古いIDはDBから削除 if ( $sessionID != $this->id["$sessionSecure$ucMasterLive"] ) { $this->drop_sessionIDfromDB ( $this->id["$sessionSecure$ucMasterLive"], $masterLive, $sessionSecure ); } $this->id["$sessionSecure$ucMasterLive"] = $sessionID; } } /*---------------------------------------------------- sessionID の存否確認 ----------------------------------------------------*/ function is_sessionIDonDB( $sessionID, $ucMasterLive, $sessionSecure ) { $table = "session$ucMasterLive"; $sql = "SELECT {$sessionSecure}ID FROM $table WHERE {$sessionSecure}ID=\"$sessionID\""; $tbl = sql_query ( $sql, "single" ); return ( $tbl["{$sessionSecure}ID"] != "" ) ? true : false; } /*---------------------------------------------------- 古いIDはDBから削除 ----------------------------------------------------*/ function drop_sessionIDfromDB( $sessionID, $masterLive, $sessionSecure ) { if ( $sessionID != "" && $this->memberID > 0 ) { $ucMasterLive = ucfirst( $masterLive ); $table = "session$ucMasterLive"; $sql = "DELETE FROM $table WHERE {$sessionSecure}ID=\"$sessionID\" AND memberID=$this->memberID"; sql_query ( $sql ); } } /*---------------------------------------------------- セッションライブにエントリーを入れる ----------------------------------------------------*/ function add_sessionDB( $masterLive, $autoFlag=NULL ) { $ucMasterLive = ucfirst( $masterLive ); $updateFlag = 1; if ( $this->tbl["session$ucMasterLive"]["sessionID"] == "" && $this->tbl["session$ucMasterLive"]["secureID"] == "" && $this->memberID > 0 ) { $sql = "SELECT sessionID FROM session$ucMasterLive WHERE sessionID=\"{$this->id["session$ucMasterLive"]}\" AND zone=\"{$this->zone}\""; $tbl = sql_query ( $sql, "single" ); if ( $tbl["sessionID"] == "" ) { $insert["memberID"] = $this->memberID; $insert["sessionID"] = $this->id["session$ucMasterLive"]; $insert["secureID"] = $this->id["secure$ucMasterLive"]; $insert["IPAddress"] = $_SERVER["REMOTE_ADDR"]; $insert["zone"] = $this->zone; if ( $masterLive == "live" ) { $insert["loginTime"]["com"] = "now()"; } if ( $autoFlag != NULL ) { $insert["auto"] = $autoFlag; } $sql = "INSERT INTO session$ucMasterLive {insert_value}"; sql_query ( $sql, $insert ); $updateFlag = 0; } } // アップデート if ( $updateFlag == 1 ) { $this->update_sessionDB( $masterLive, $autoFlag ); } } /*---------------------------------------------------- モニターメンバーの削除 ----------------------------------------------------*/ function drop_monitorMember() { if ( $this->monitorID > 0 ) { $sql = "DELETE FROM sessionMember WHERE memberID=$this->monitorID"; sql_query ( $sql ); } } /*---------------------------------------------------- 自動ログインフラグを立てる ----------------------------------------------------*/ function set_autoLoginFlag( $autoLogin ) { if ( $this->memberID > 0 ) { $update["autoLogin"] = sprintf( "%d", $autoLogin ); $sql = "UPDATE sessionMember SET {update_set} WHERE memberID=\"$this->memberID\""; sql_query( $sql, $update ); } $this->autoLogin = $autoLogin; } /*---------------------------------------------------- デバッグテキスト出力 ----------------------------------------------------*/ function writeDeb ($log,$file_name="") { if( $file_name=="" ){ $file_name="debugLog.txt"; } // ファイルの保存 $fp = fopen( "$file_name", "a" ); fputs( $fp, $log . "\n" ); fclose( $fp ); chmod( $file_name, 0666 ); } /*---------------------------------------------------- ログ書込み(ログイン) 2010.12.22 K.Takeda ----------------------------------------------------*/ function write_loginLog(){ unset( $insert ); $insert["memberID"] = $this->memberID; $insert["loginID"] = $this->loginID; $insert["HTTPS"] = $_SERVER["HTTPS"]; $insert["sessionID"] = $this->id["sessionMaster"]; $insert["secureID"] = $this->id["sessionLive"]; $insert["IPAddress"] = $_SERVER["REMOTE_ADDR"]; $insert["referer"] = $_SERVER["HTTP_REFERER"]; $insert["loginLogout"] = "LOGIN"; $sql = "INSERT INTO loginLog {insert_value}"; sql_query( $sql, $insert ); } /*---------------------------------------------------- ログ書込み(ログアウト) 2010.12.22 K.Takeda ----------------------------------------------------*/ function write_logoutLog(){ unset( $insert ); $insert["memberID"] = $this->memberID; $insert["loginID"] = $this->loginID; $insert["HTTPS"] = $_SERVER["HTTPS"]; $insert["sessionID"] = $this->id["sessionMaster"]; $insert["secureID"] = $this->id["sessionLive"]; $insert["IPAddress"] = $_SERVER["REMOTE_ADDR"]; $insert["referer"] = $_SERVER["HTTP_REFERER"]; $insert["loginLogout"] = "LOGOUT"; $sql = "INSERT INTO loginLog {insert_value}"; sql_query( $sql, $insert ); } /*---------------------------------------------------- ブログとファンドの相関チェック 2011.6.22 K.Takeda ----------------------------------------------------*/ function checkBlogFund(){ global $class; if( $_GET["ba"] != "" ) { $blogarticleID = $_GET["ba"]; } if( $_POST["ba"] != "" ) { $blogarticleID = $_POST["ba"]; } // 一覧表示の場合 if( $_GET["bl"] > 0 ) { // ブログ情報の取得 $output["blogInfo"] = $this->get_blogInfo( $_GET["bl"] ); $fundID = $output["blogInfo"]["linkage_id"]; } // 一覧表示以外の場合 if( $blogarticleID != "" ) { list( $blogID, $article_id, $artist_blog_id ) = $this->restore_BA( $blogarticleID ); $blogInfo = $this->get_blogInfo( $blogID ); $fundID = $blogInfo["linkage_id"]; } // ブログを購入している? $buyFund = $this->check_buyFund( $fundID ); // ファンドを購入していなければエラー if( count( $buyFund ) == 0 ){ return true; } return false; } /*---------------------------------------------------- 【ba】ブログIDと記事IDに戻す ----------------------------------------------------*/ function restore_BA ( $ba ) { $base_blog_id = 10700; $base_article_id = 30500; // 変換したブログIDのみ抽出 $blog_id_pattern = '/^b[0-9]+/'; preg_match( $blog_id_pattern, $ba, $blog_id_matches ); // 数値だけ取り出す $result_blog_id = preg_replace( '/^b/', '', $blog_id_matches[0] ); // ブログIDに変換 $blog_id = (int)$result_blog_id - (int)$base_blog_id; // 変換した記事IDのみ抽出 $article_id_pattern = '/a[0-9]+/'; preg_match( $article_id_pattern, $ba, $article_id_matches ); // 数値だけ取り出す $result_article_id = preg_replace( '/^a/', '', $article_id_matches[0] ); // 記事IDに変換 $article_id = (int)$result_article_id - (int)$base_article_id; // 変換した記事IDのみ抽出 $artist_blog_id_pattern = '/ab[0-9]+/'; preg_match( $artist_blog_id_pattern, $ba, $artist_blog_id_matches ); // 数値だけ取り出す $result_artist_blog_id = preg_replace( '/^ab/', '', $artist_blog_id_matches[0] ); // 記事IDに変換 if( $result_artist_blog_id != "" ) { $artist_blog_id = (int)$result_artist_blog_id - (int)$base_blog_id; } return array( $blog_id, $article_id, $artist_blog_id ); } /*---------------------------------------------------- 情報取得 ----------------------------------------------------*/ function get_blogInfo ( $blogID ) { if ( $blogID == "" || $blogID == "0" ){ return; } $sql = "SELECT * FROM blog WHERE blog_id='{$blogID}'"; $ret = sql_query( $sql, "single" ); return $ret; } function check_buyFund( $fundID ){ $sql = "SELECT * FROM tbl_buy WHERE member_id={$this->memberID} AND fund_id={$fundID}"; $tbl = sql_query( $sql ); return $tbl; } } ?>