teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

14

修正

2018/07/02 02:27

投稿

emporiol
emporiol

スコア9

title CHANGED
File without changes
body CHANGED
@@ -127,8 +127,9 @@
127
127
  $retXML = str_replace( "<url><loc><priority><changefreq>" , "\n<url><loc><priority><changefreq>" , $retXML );
128
128
  ここに<priority><changefreq>は入れましたがその前段階の設定がわかりません。
129
129
 
130
- ``` 試したこと①
130
+ ```
131
131
  <?
132
+ //試したこと①
132
133
  $siteURL = "http://example.com";
133
134
  $changefreqs =[0=>"always",
134
135
  1=>"hourly",

13

誤字

2018/07/02 02:27

投稿

emporiol
emporiol

スコア9

title CHANGED
File without changes
body CHANGED
@@ -127,7 +127,7 @@
127
127
  $retXML = str_replace( "<url><loc><priority><changefreq>" , "\n<url><loc><priority><changefreq>" , $retXML );
128
128
  ここに<priority><changefreq>は入れましたがその前段階の設定がわかりません。
129
129
 
130
- ### 試したこと①
130
+ ``` 試したこと①
131
131
  <?
132
132
  $siteURL = "http://example.com";
133
133
  $changefreqs =[0=>"always",
@@ -163,7 +163,7 @@
163
163
  ?>
164
164
  を秀丸エディタを用いて記述し実行しました。
165
165
 
166
-
166
+ ```
167
167
  ### 補足情報(FW/ツールのバージョンなど)
168
168
 
169
169
  何か情報が足りないとかあるでしょうか?

12

修正

2018/07/02 02:26

投稿

emporiol
emporiol

スコア9

title CHANGED
File without changes
body CHANGED
@@ -127,6 +127,43 @@
127
127
  $retXML = str_replace( "<url><loc><priority><changefreq>" , "\n<url><loc><priority><changefreq>" , $retXML );
128
128
  ここに<priority><changefreq>は入れましたがその前段階の設定がわかりません。
129
129
 
130
+ ### 試したこと①
131
+ <?
132
+ $siteURL = "http://example.com";
133
+ $changefreqs =[0=>"always",
134
+ 1=>"hourly",
135
+ 2=>"daily",
136
+ 3=>"weekly",
137
+ 4=>"monthly",
138
+ 5=>"yearly",
139
+ 6=>"never"];
140
+
141
+ $publicSiteMap[] = ["loc"=>$siteURL . "/search/sample1.html","priority"=>"1.0","changefreq"=>0];
142
+ $publicSiteMap[] = ["loc"=>$siteURL . "/search/sample2.html","priority"=>"0.8","changefreq"=>2];
143
+
144
+ $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" ?>' . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>');
145
+
146
+ // xmlノード追加(記事・マンスリー)
147
+ if (count($publicSiteMap) > 0) {
148
+ foreach ($publicSiteMap as $map) {
149
+ $xmla = $xml->addChild('url');
150
+ foreach($map as $mapkey=>$mapvalue){
151
+ if($mapkey === "changefreq"){
152
+ $xmla->addChild($mapkey, $changefreqs[$mapvalue]);
153
+ }else{
154
+ $xmla->addChild($mapkey, $mapvalue);
155
+ }
156
+ }
157
+ }
158
+
159
+ $retXML = $xml->asXML();
160
+
161
+ echo $retXML;
162
+ }
163
+ ?>
164
+ を秀丸エディタを用いて記述し実行しました。
165
+
166
+
130
167
  ### 補足情報(FW/ツールのバージョンなど)
131
168
 
132
169
  何か情報が足りないとかあるでしょうか?

11

文章修正

2018/07/02 02:17

投稿

emporiol
emporiol

スコア9

title CHANGED
File without changes
body CHANGED
@@ -33,6 +33,69 @@
33
33
  $retXML = $xml->asXML();
34
34
  $retXML = str_replace( "<url><loc><priority><changefreq>" , "\n<url><loc><priority><changefreq>" , $retXML );
35
35
  $retXML = str_replace( "</urlset>" , "\n</urlset>" , $retXML );
36
+
37
+ /****** xmlファイルの書き出し*****/
38
+ $createFile = 'sitemap.xml';
39
+ $putFileName = $docRoot."/".$createFile;
40
+
41
+ file_put_contents ($putFileName, $retXML);
42
+
43
+ mysql_close($con);
44
+
45
+ $mess = "抽出バッチ終了時刻2:".date('Y,m/d H:i:s');
46
+ echo $mess;
47
+ //バッチ起動履歴ログ
48
+ $log -> writeLog2($mess);
49
+
50
+
51
+
52
+
53
+ function getDirFiles($tar,$match)
54
+ {
55
+
56
+ if ($handle = opendir($tar))
57
+ {
58
+ while (false !== ($file = readdir($handle)))
59
+ {
60
+ //echo $file."<br>";
61
+
62
+ if ('.' == $file || '..' == $file)// 自分自身と上位ディレクトリを除外
63
+ {
64
+ continue;
65
+ }// if
66
+
67
+ //echo preg_match($match, $file)."<br>";
68
+
69
+
70
+ //ファイル名パターンにマッチしない場合除外
71
+ if (!preg_match($match, $file)) {
72
+ continue;
73
+ }
74
+
75
+ /***** 制御文字、日本語文字処理 *****/
76
+
77
+ // 制御文字置換
78
+ $file00 = htmlspecialchars($file);
79
+ // 日本語対策 UTF-8へコード変換
80
+ $file01 = mb_convert_encoding($file00, 'UTF-8','HTML-ENTITIES,ASCII,JIS, EUC-JP, SJIS');
81
+
82
+ //ファイル名取得
83
+ $filename[] = $file01;
84
+
85
+ //サイトマップ公開記事(仕事詳細)
86
+ //$publicSiteMap[] = $siteURL."/contents/montly/".$filename;
87
+
88
+ } //while
89
+
90
+ closedir($handle); // ディレクトリハンドルを閉じる
91
+
92
+ return $filename;
93
+
94
+ } //if
95
+ }//function
96
+
97
+
98
+
36
99
  ```
37
100
 
38
101
  ```

10

誤字

2018/07/01 21:31

投稿

emporiol
emporiol

スコア9

title CHANGED
File without changes
body CHANGED
@@ -17,6 +17,9 @@
17
17
  ### 該当のソースコード
18
18
 
19
19
  ```php
20
+
21
+ ////現在のコード
22
+
20
23
  $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" ?>'.'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>');
21
24
 
22
25
  // xmlノード追加(記事・マンスリー)
@@ -30,17 +33,19 @@
30
33
  $retXML = $xml->asXML();
31
34
  $retXML = str_replace( "<url><loc><priority><changefreq>" , "\n<url><loc><priority><changefreq>" , $retXML );
32
35
  $retXML = str_replace( "</urlset>" , "\n</urlset>" , $retXML );
36
+ ```
33
37
 
34
- _____________________________________________________
38
+ ```
35
- 現在の出力状況
39
+ //現在の出力状況
36
40
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
37
41
  <url><loc>http://sample1.com/</loc></url>
38
42
  <url><loc>http://sample2.com/jbinf/00001/01.html</loc></url>
39
43
  <url><loc>http://sample3.com/jbinf/00002/01.html</loc></url>
40
44
 
45
+ ```
46
+ ```
47
+ //出力変更例
41
48
 
42
- 出力変更例
43
-
44
49
  <url>
45
50
  <loc>http://sample1.com/</loc>
46
51
  <priority>1.0</priority>

9

誤字

2018/07/01 21:25

投稿

emporiol
emporiol

スコア9

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  ### 前提・実現したいこと
2
- 【至急!】
2
+
3
3
  sitemap.xmlの仕様変更で<priority>,<changefreq>項目の追加のしかた。
4
4
 
5
5
 

8

誤字

2018/07/01 21:16

投稿

emporiol
emporiol

スコア9

title CHANGED
File without changes
body CHANGED
@@ -31,7 +31,7 @@
31
31
  $retXML = str_replace( "<url><loc><priority><changefreq>" , "\n<url><loc><priority><changefreq>" , $retXML );
32
32
  $retXML = str_replace( "</urlset>" , "\n</urlset>" , $retXML );
33
33
 
34
-
34
+ _____________________________________________________
35
35
  現在の出力状況
36
36
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
37
37
  <url><loc>http://sample1.com/</loc></url>

7

誤字

2018/07/01 21:13

投稿

emporiol
emporiol

スコア9

title CHANGED
File without changes
body CHANGED
@@ -26,7 +26,7 @@
26
26
  $xmla->addChild('loc',$val);
27
27
 
28
28
  }
29
-
29
+ }
30
30
  $retXML = $xml->asXML();
31
31
  $retXML = str_replace( "<url><loc><priority><changefreq>" , "\n<url><loc><priority><changefreq>" , $retXML );
32
32
  $retXML = str_replace( "</urlset>" , "\n</urlset>" , $retXML );

6

誤字

2018/07/01 21:01

投稿

emporiol
emporiol

スコア9

title CHANGED
@@ -1,1 +1,1 @@
1
- 【至急!】sitemap.xmlの書きだし方変更
1
+ sitemap.xmlの書きだし方変更
body CHANGED
@@ -1,5 +1,5 @@
1
1
  ### 前提・実現したいこと
2
-
2
+ 【至急!】
3
3
  sitemap.xmlの仕様変更で<priority>,<changefreq>項目の追加のしかた。
4
4
 
5
5
 

5

文法

2018/07/01 20:45

投稿

emporiol
emporiol

スコア9

title CHANGED
@@ -1,1 +1,1 @@
1
- sitemap.xmlの書きだし方変更
1
+ 【至急!】sitemap.xmlの書きだし方変更
body CHANGED
File without changes

4

文法

2018/07/01 20:13

投稿

emporiol
emporiol

スコア9

title CHANGED
File without changes
body CHANGED
@@ -8,9 +8,10 @@
8
8
  ```
9
9
  sitemap.xmlの<priority>を1.0、0.9、0.8で場合分けで出力
10
10
  さらにchangefreqを出力できるコードの組み方がわかりません。
11
+ 担当者がいきなり初心者の私になりphpがほぼわからない状態となっております。
11
- もしよろしければ足りないコードの組み方を教えてください!!
12
+ このようなことを言うのはずるいかもしれませんが、もしよろしければ足りないコードの組み方を教えてください!!
12
13
  どうかお願いいたします!!
13
- 正直答えを頂かないと全くわからない状況です”!
14
+ 正直答えそのものを頂かないと全くわからない状況です”!
14
15
  ```
15
16
 
16
17
  ### 該当のソースコード
@@ -55,7 +56,6 @@
55
56
 
56
57
  ### 試したこと
57
58
 
58
- 担当者がいきなり初心者の私になりphpがほぼわからない状態となっております。
59
59
  $retXML = str_replace( "<url><loc><priority><changefreq>" , "\n<url><loc><priority><changefreq>" , $retXML );
60
60
  ここに<priority><changefreq>は入れましたがその前段階の設定がわかりません。
61
61
 

3

文法

2018/07/01 20:06

投稿

emporiol
emporiol

スコア9

title CHANGED
File without changes
body CHANGED
@@ -61,4 +61,4 @@
61
61
 
62
62
  ### 補足情報(FW/ツールのバージョンなど)
63
63
 
64
- ここにより詳細な情報を記載してくださ
64
+ 何か情報が足りなとかあるでしょうか?

2

文章追加

2018/07/01 19:54

投稿

emporiol
emporiol

スコア9

title CHANGED
File without changes
body CHANGED
@@ -31,15 +31,22 @@
31
31
  $retXML = str_replace( "</urlset>" , "\n</urlset>" , $retXML );
32
32
 
33
33
 
34
- 出力
34
+ 現在の出力状況
35
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
36
+ <url><loc>http://sample1.com/</loc></url>
37
+ <url><loc>http://sample2.com/jbinf/00001/01.html</loc></url>
38
+ <url><loc>http://sample3.com/jbinf/00002/01.html</loc></url>
35
39
 
40
+
41
+ 出力変更例
42
+
36
43
  <url>
37
- <loc>http://sample.com/</loc>
44
+ <loc>http://sample1.com/</loc>
38
45
  <priority>1.0</priority>
39
46
  <changefreq>weekly</changefreq>
40
47
  </url>
41
48
  <url>
42
- <loc>http://sample.com/info/</loc>
49
+ <loc>http://sample2.com/info/</loc>
43
50
  <priority>0.8</priority>
44
51
  <changefreq>weekly</changefreq>
45
52
  </url>

1

誤字

2018/07/01 18:18

投稿

emporiol
emporiol

スコア9

title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,5 @@
1
1
  ### 前提・実現したいこと
2
2
 
3
- ここに質問の内容を詳しく書いてください。
4
3
  sitemap.xmlの仕様変更で<priority>,<changefreq>項目の追加のしかた。
5
4
 
6
5