// global $cls_val;
//define('DB_NAME', 'hakka0401_wpold');
/** MySQL データベースのユーザー名 */
//define('DB_USER', 'hakka0401_wpold');
/** MySQL データベースのパスワード */
//define('DB_PASSWORD', 'gBTgW3KL');
/** MySQL のホスト名 */
//define('DB_HOST', 'mysql101.sixcore.ne.jp');
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die(mysql_error());
mysql_select_db(DB_NAME, $conn) or die(mysql_error());
$sSQL = "select p.* from wp_posts as p inner join wp_postmeta as m ";
$sSQL .= "on ";
$sSQL .= "p.id = m.post_id ";
$sSQL .= "where ";
$sSQL .= "p.post_status = 'publish' ";
$sSQL .= "and ";
$sSQL .= "m.meta_key = 'X軸' ";
$sSQL .= "or ";
$sSQL .= "m.meta_key = 'Y軸' ";
// $sSQL .= "and ";
// $sSQL .= "m.post_id = '158' ";
$sSQL .= "";
// $sSQL = "SELECT * FROM wp_posts ";
// $sSQL .= "WHERE ";
// $sSQL .= "post_status = 'publish' ";
$sSQL = "SELECT * FROM wp_yarpp_related_cache where post_id = 158";
// $sSQL = "show tables";
$res = mysql_query($sSQL, $conn) or die(mysql_error());
$i = 0;
while ($row = mysql_fetch_array($res)) {
$row2[$i] = $row;
$i++;
}
echo "
";
print_r($row2);
echo "
";
ini_set( 'display_errors', 1 );
require_once("cat_id.php");
// $conn = $cls_val->db_conn();
// $row = $cls_val->get_table_data($conn, "kodawari_map");
//print_r($row);
?>
$last_get_date = file(get_template_directory() . "/get_data_date.txt");
?>
//********************************************************************************************************************
$i = 1;
$cnt = 0;
echo "gourmet=" . $gourmet . "
";
foreach ($gourmet as $val) {
?>
$get_posts = query_posts("posts_per_page=-1&cat=" . $val) ?>
if (post_custom("座標X") != "") {
if (strtotime($post->post_modified) >= strtotime($last_get_date[0])) {
$arr_gourmet[$cnt]["title"] = str_replace("'", "’", get_the_title());
$arr_gourmet[$cnt]["x"] = post_custom("座標X");
$arr_gourmet[$cnt]["y"] = post_custom("座標Y");
$arr_gourmet[$cnt]["post_id"] = $post->ID;
$arr_gourmet[$cnt]["thumbnail"] = get_the_post_thumbnail();
$arr_gourmet[$cnt]["content"] = str_replace("'", "’", str_replace("\r\n", "", mb_strimwidth(strip_tags(get_the_content()), 0, TOP_LABO_TXT, "…")));
$arr_gourmet[$cnt]["icon"] = get_the_author_login();
$arr_gourmet[$cnt]["tab_no"] = $i;
$arr_gourmet[$cnt]["tab"] = 1;
$cnt++;
/*
echo get_the_title() . "
";
echo "座標X=" . post_custom("座標X") . "
";
echo "座標Y=" . post_custom("座標Y") . "
";
echo "ID=" . $post->ID . "
";
echo "thumbnail=" . get_the_post_thumbnail() . "
";
echo "content=" . str_replace("\r\n", "", mb_strimwidth(strip_tags(get_the_content()), 0, TOP_LABO_TXT, "…")) . "
";
echo "date=" . $post->post_modified . "
";
echo "icon=" . get_the_author_login() . "
";
echo "tab_no=" . $i . "
";
echo "
";
*/
}
}
?>
$i++;
} // foreach
//********************************************************************************************************************
?>
//********************************************************************************************************************
$i = 1;
$cnt = 0;
foreach ($life as $val) {
?>
$get_posts = query_posts("posts_per_page=-1&cat=" . $val) ?>
if (post_custom("座標X") != "") {
if (strtotime($post->post_modified) >= strtotime($last_get_date[0])) {
$arr_life[$cnt]["title"] = str_replace("'", "’", get_the_title());
$arr_life[$cnt]["x"] = post_custom("座標X");
$arr_life[$cnt]["y"] = post_custom("座標Y");
$arr_life[$cnt]["post_id"] = $post->ID;
$arr_life[$cnt]["thumbnail"] = get_the_post_thumbnail();
$arr_life[$cnt]["content"] = str_replace("'", "’", str_replace("\r\n", "", mb_strimwidth(strip_tags(get_the_content()), 0, TOP_LABO_TXT, "…")));
$arr_life[$cnt]["icon"] = get_the_author_login();
$arr_life[$cnt]["tab_no"] = $i;
$arr_life[$cnt]["tab"] = 2;
$cnt++;
}
}
?>
$i++;
} // foreach
//********************************************************************************************************************
?>
//********************************************************************************************************************
$i = 1;
$cnt = 0;
foreach ($shop as $val) {
?>
$get_posts = query_posts("posts_per_page=-1&cat=" . $val) ?>
if (post_custom("座標X") != "") {
if (strtotime($post->post_modified) >= strtotime($last_get_date[0])) {
$arr_shop[$cnt]["title"] = str_replace("'", "’", get_the_title());
$arr_shop[$cnt]["x"] = post_custom("座標X");
$arr_shop[$cnt]["y"] = post_custom("座標Y");
$arr_shop[$cnt]["post_id"] = $post->ID;
$arr_shop[$cnt]["thumbnail"] = get_the_post_thumbnail();
$arr_shop[$cnt]["content"] = str_replace("'", "’", str_replace("\r\n", "", mb_strimwidth(strip_tags(get_the_content()), 0, TOP_LABO_TXT, "…")));
$arr_shop[$cnt]["icon"] = get_the_author_login();
$arr_shop[$cnt]["tab_no"] = $i;
$arr_shop[$cnt]["tab"] = 3;
$cnt++;
}
}
?>
$i++;
} // foreach
//********************************************************************************************************************
?>
//********************************************************************************************************************
$i = 1;
$cnt = 0;
foreach ($event as $val) {
?>
$get_posts = query_posts("posts_per_page=-1&cat=" . $val) ?>
if (post_custom("座標X") != "") {
if (strtotime($post->post_modified) >= strtotime($last_get_date[0])) {
$arr_event[$cnt]["title"] = str_replace("'", "’", get_the_title());
$arr_event[$cnt]["x"] = post_custom("座標X");
$arr_event[$cnt]["y"] = post_custom("座標Y");
$arr_event[$cnt]["post_id"] = $post->ID;
$arr_event[$cnt]["thumbnail"] = get_the_post_thumbnail();
$arr_event[$cnt]["content"] = str_replace("'", "’", str_replace("\r\n", "", mb_strimwidth(strip_tags(get_the_content()), 0, TOP_LABO_TXT, "…")));
$arr_event[$cnt]["icon"] = get_the_author_login();
$arr_event[$cnt]["tab_no"] = $i;
$arr_event[$cnt]["tab"] = 4;
$cnt++;
}
}
?>
$i++;
} // foreach
//********************************************************************************************************************
?>
$conn = db_conn();
echo "hogehoge=" . $sSQL . "
";
$arr_col = array("post_id", "tab", "tab_no", "title", "thumbnail", "icon", "x", "y", "content");
// データ挿入
for ($i = 0; $i < count($arr_gourmet); $i++) {
$sSQL = "DELETE FROM kodawari_map ";
$sSQL .= "WHERE ";
$sSQL .= "post_id = " . $arr_gourmet[$i]["post_id"];
$sSQL .= " AND ";
$sSQL .= "tab = 1";
$sSQL .= " AND ";
$sSQL .= "tab_no = " . $arr_gourmet[$i]["tab_no"];
mysql_query($sSQL, $conn);
echo "hogehoge=" . $sSQL . "
";
$sSQL = "INSERT INTO kodawari_map (";
foreach ($arr_col as $val) {
$sSQL .= $val . ",";
}
$sSQL = substr($sSQL, 0, strlen($sSQL) - 1);
$sSQL .= ") VALUES (";
foreach ($arr_col as $val) {
$sSQL .= "'" . $arr_gourmet[$i][$val] . "',";
}
$sSQL = substr($sSQL, 0, strlen($sSQL) - 1);
$sSQL .= ")";
mysql_query($sSQL, $conn);
echo "hogehoge=" . $sSQL . "
";
}
for ($i = 0; $i < count($arr_life); $i++) {
$sSQL = "DELETE FROM kodawari_map ";
$sSQL .= "WHERE ";
$sSQL .= "post_id = " . $arr_life[$i]["post_id"];
$sSQL .= " AND ";
$sSQL .= "tab = 2";
$sSQL .= " AND ";
$sSQL .= "tab_no = " . $arr_life[$i]["tab_no"];
mysql_query($sSQL, $conn);
echo "hogehoge=" . $sSQL . "
";
$sSQL = "INSERT INTO kodawari_map (";
foreach ($arr_col as $val) {
$sSQL .= $val . ",";
}
$sSQL = substr($sSQL, 0, strlen($sSQL) - 1);
$sSQL .= ") VALUES (";
foreach ($arr_col as $val) {
$sSQL .= "'" . $arr_life[$i][$val] . "',";
}
$sSQL = substr($sSQL, 0, strlen($sSQL) - 1);
$sSQL .= ")";
mysql_query($sSQL, $conn);
echo "hogehoge=" . $sSQL . "
";
}
for ($i = 0; $i < count($arr_shop); $i++) {
$sSQL = "DELETE FROM kodawari_map ";
$sSQL .= "WHERE ";
$sSQL .= "post_id = " . $arr_shop[$i]["post_id"];
$sSQL .= " AND ";
$sSQL .= "tab = 3";
$sSQL .= " AND ";
$sSQL .= "tab_no = " . $arr_shop[$i]["tab_no"];
mysql_query($sSQL, $conn);
echo "hogehoge=" . $sSQL . "
";
$sSQL = "INSERT INTO kodawari_map (";
foreach ($arr_col as $val) {
$sSQL .= $val . ",";
}
$sSQL = substr($sSQL, 0, strlen($sSQL) - 1);
$sSQL .= ") VALUES (";
foreach ($arr_col as $val) {
$sSQL .= "'" . $arr_shop[$i][$val] . "',";
}
$sSQL = substr($sSQL, 0, strlen($sSQL) - 1);
$sSQL .= ")";
mysql_query($sSQL, $conn);
echo "hogehoge=" . $sSQL . "
";
}
for ($i = 0; $i < count($arr_event); $i++) {
$sSQL = "DELETE FROM kodawari_map ";
$sSQL .= "WHERE ";
$sSQL .= "post_id = " . $arr_event[$i]["post_id"];
$sSQL .= " AND ";
$sSQL .= "tab = 4";
$sSQL .= " AND ";
$sSQL .= "tab_no = " . $arr_event[$i]["tab_no"];
mysql_query($sSQL, $conn);
echo "hogehoge=" . $sSQL . "
";
$sSQL = "INSERT INTO kodawari_map (";
foreach ($arr_col as $val) {
$sSQL .= $val . ",";
}
$sSQL = substr($sSQL, 0, strlen($sSQL) - 1);
$sSQL .= ") VALUES (";
foreach ($arr_col as $val) {
$sSQL .= "'" . $arr_event[$i][$val] . "',";
}
$sSQL = substr($sSQL, 0, strlen($sSQL) - 1);
$sSQL .= ")";
mysql_query($sSQL, $conn);
echo "hogehoge=" . $sSQL . "
";
}
?>
echo "owari
";
//$fp = fopen(get_template_directory() . "/get_data_date.txt", "w");
//fwrite($fp, date("Y-m-d H:i:s"));
//fclose($fp);
$sSQL = "SELECT DISTINCT tab, tab_no FROM kodawari_map ";
$res = mysql_query($sSQL, $conn) or die(mysql_error());
$i = 0;
while ($row = mysql_fetch_array($res)) {
$row2[$i] = $row;
$i++;
}
$write_data = '
//
' . str_replace("\r", "", str_replace("\r\n", "", $row[$i]["title"])) . '
' . str_replace("\"", "", $row[$i]["thumbnail"]) . ' |
| ' . str_replace("\r", "", str_replace("\r\n", "", $row[$i]["content"])) . ' |
|
";
';
} else {
$write_data .= '
g_Fukidashi[\'' . $row[$i]["tab"] . '_' . $row[$i]["tab_no"] . '_' . $i . '\'] = "
' . str_replace("\r", "", str_replace("\r\n", "", $row[$i]["title"])) . '
' . str_replace("\"", "", $row[$i]["thumbnail"]) . ' |
| ' . str_replace("\r", "", str_replace("\r\n", "", $row[$i]["content"])) . ' |
|
";
';
}
}
$write_data .= '
function mapmap() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl()); // コントロールボタン
var point = new GLatLng(35.66708961816394, 139.7090283036232);
map.setCenter(point, 16); // 拡大縮小
g_map = map;
';
for ($i = 0; $i < count($row); $i++) {
if ($row[$i]["tab"] == 1) {
$view = "";
} else {
$view = "// ";
}
$write_data .= '
' . $view . 'map.addOverlay(marker["' . $row[$i]["tab"] . '_' . $row[$i]["tab_no"] . '_' . $i . '"]);
GEvent.addListener(marker["' . $row[$i]["tab"] . '_' . $row[$i]["tab_no"] . '_' . $i . '"], \'click\', function() {
map.openInfoWindowHtml(g_point["' . $row[$i]["tab"] . '_' . $row[$i]["tab_no"] . '_' . $i . '"], g_Fukidashi["' . $row[$i]["tab"] . '_' . $row[$i]["tab_no"] . '_' . $i . '"]); // ふきだし
show_search("' . $row[$i]["tab"] . '_' . $row[$i]["tab_no"] . '_");
});
';
}
$write_data .= '
}
}
function openOverlay(pointNo) {
g_map.openInfoWindowHtml(g_point[pointNo], g_Fukidashi[pointNo]); // ふきだし
}
//]]>
';
//$fp = fopen(get_template_directory() . "/map.js", "w");
//fwrite($fp, $write_data);
//fclose($fp);
?>