質問編集履歴
1
失礼致しました。私なりにインデントを揃えました。見づらかったらすみません。
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,6 +24,8 @@
|
|
24
24
|
|
25
25
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
26
26
|
|
27
|
+
|
28
|
+
|
27
29
|
<?php
|
28
30
|
|
29
31
|
|
@@ -54,55 +56,53 @@
|
|
54
56
|
|
55
57
|
?>
|
56
58
|
|
59
|
+
|
60
|
+
|
57
61
|
<div style="margin:0 0 2% 0;">
|
58
62
|
|
59
|
-
<form name="searchform" id="itemsearchform" method="get" action="">
|
63
|
+
<form name="searchform" id="itemsearchform" method="get" action="">
|
60
|
-
|
64
|
+
|
61
|
-
<input type="text" name="keyword" id="itemkeyword" value="" />
|
65
|
+
<input type="text" name="keyword" id="itemkeyword" value="" />
|
62
|
-
|
66
|
+
|
63
|
-
<input type="submit" id="itemsubmit" value="検索" />
|
67
|
+
<input type="submit" id="itemsubmit" value="検索" />
|
64
|
-
|
68
|
+
|
65
|
-
</form>
|
69
|
+
</form>
|
66
70
|
|
67
71
|
</div>
|
68
72
|
|
73
|
+
|
74
|
+
|
69
75
|
<?php
|
70
76
|
|
71
77
|
|
72
78
|
|
73
|
-
$keyword = htmlspecialchars($_GET['keyword'], ENT_QUOTES);
|
79
|
+
$keyword = htmlspecialchars($_GET['keyword'], ENT_QUOTES);
|
74
|
-
|
80
|
+
|
75
|
-
$e_keyword = urlencode($keyword);
|
81
|
+
$e_keyword = urlencode($keyword);
|
76
82
|
|
77
83
|
$currentpage = (empty($_GET['page'])) ? 1 : $_GET['page'];
|
78
84
|
|
79
|
-
|
80
|
-
|
81
|
-
$first = $currentpage * 10 - 9;
|
85
|
+
$first = $currentpage * 10 - 9;
|
82
|
-
|
86
|
+
|
83
|
-
$last = $currentpage * 10;
|
87
|
+
$last = $currentpage * 10;
|
84
|
-
|
88
|
+
|
85
|
-
$shopcode ="********";//shopコード記載
|
89
|
+
$shopcode = "********";//shopコード記載
|
86
|
-
|
90
|
+
|
87
|
-
$timestamp =strtotime('now');
|
91
|
+
$timestamp = strtotime('now');
|
88
|
-
|
92
|
+
|
89
|
-
$date = date('Y-n-j H:i:s',$timestamp);
|
93
|
+
$date = date('Y-n-j H:i:s',$timestamp);
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
94
|
+
|
97
|
-
$baseurl = 'https://app.rakuten.co.jp/services/api/IchibaItem/Search/20140222?format=json';
|
95
|
+
$baseurl = 'https://app.rakuten.co.jp/services/api/IchibaItem/Search/20140222?format=json';
|
98
|
-
|
96
|
+
|
99
|
-
$rsparam = array();
|
97
|
+
$rsparam = array();
|
100
|
-
|
101
|
-
|
102
|
-
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
-
if ($e_keyword != "")
|
103
|
+
if ($e_keyword != ""){
|
104
|
-
|
104
|
+
|
105
|
-
$rsparam['keyword'] = $e_keyword;
|
105
|
+
$rsparam['keyword'] = $e_keyword;
|
106
106
|
|
107
107
|
}
|
108
108
|
|
@@ -110,25 +110,21 @@
|
|
110
110
|
|
111
111
|
$rsparam['applicationId'] = $appId;
|
112
112
|
|
113
|
-
$rsparam['hits'] = 30;
|
113
|
+
$rsparam['hits'] = 30;
|
114
|
-
|
114
|
+
|
115
|
-
$rsparam['field'] = 0;
|
115
|
+
$rsparam['field'] = 0;
|
116
|
-
|
116
|
+
|
117
|
-
$rsparam['imageFlag'] = 0;
|
117
|
+
$rsparam['imageFlag'] = 0;
|
118
|
-
|
118
|
+
|
119
|
-
$rsparam['page'] = $currentpage;
|
119
|
+
$rsparam['page'] = $currentpage;
|
120
|
-
|
120
|
+
|
121
|
-
$rsparam['orFlag'] = 1;
|
121
|
+
$rsparam['orFlag'] = 1;
|
122
|
-
|
122
|
+
|
123
|
-
$rsparam['first'] = $first;
|
123
|
+
$rsparam['first'] = $first;
|
124
|
-
|
124
|
+
|
125
|
-
$rsparam['last'] = $last;
|
125
|
+
$rsparam['last'] = $last;
|
126
|
-
|
126
|
+
|
127
|
-
$rsparam['shopCode'] = $shopcode;
|
127
|
+
$rsparam['shopCode'] = $shopcode;
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
128
|
|
133
129
|
|
134
130
|
|
@@ -140,23 +136,19 @@
|
|
140
136
|
|
141
137
|
|
142
138
|
|
143
|
-
$rsurl = $baseurl.$palame;
|
139
|
+
$rsurl = $baseurl.$palame;
|
144
|
-
|
145
|
-
|
146
|
-
|
140
|
+
|
147
|
-
$rs_json = @file_get_contents($rsurl, true);
|
141
|
+
$rs_json = @file_get_contents($rsurl, true);
|
148
|
-
|
149
|
-
|
150
|
-
|
142
|
+
|
151
|
-
$item = json_decode($rs_json);
|
143
|
+
$item = json_decode($rs_json);
|
152
|
-
|
144
|
+
|
153
|
-
$Item = array();
|
145
|
+
$Item = array();
|
154
|
-
|
146
|
+
|
155
|
-
$Items = $item->Items;
|
147
|
+
$Items = $item->Items;
|
156
|
-
|
148
|
+
|
157
|
-
$count = $item->count;
|
149
|
+
$count = $item->count;
|
158
|
-
|
150
|
+
|
159
|
-
$hits = $rsparam['hits'];
|
151
|
+
$hits = $rsparam['hits'];
|
160
152
|
|
161
153
|
$max_page = ceil($count/$hits);
|
162
154
|
|
@@ -204,9 +196,11 @@
|
|
204
196
|
|
205
197
|
|
206
198
|
|
207
|
-
|
199
|
+
$nextpage = $currentpage+1;
|
208
|
-
|
200
|
+
|
209
|
-
|
201
|
+
$prevpage = $currentpage-1;
|
202
|
+
|
203
|
+
|
210
204
|
|
211
205
|
|
212
206
|
|
@@ -220,146 +214,122 @@
|
|
220
214
|
|
221
215
|
if ($imageFlag == "1") {
|
222
216
|
|
217
|
+
|
218
|
+
|
223
|
-
$mediumImageUrls = $item->Items[$i]->Item->mediumImageUrls[0]->imageUrl;
|
219
|
+
$mediumImageUrls = $item->Items[$i]->Item->mediumImageUrls[0]->imageUrl;
|
224
|
-
|
225
|
-
|
226
|
-
|
220
|
+
|
227
|
-
$affiliateUrl[$i] = $item->Items[$i]->Item->affiliateUrl;
|
221
|
+
$affiliateUrl[$i] = $item->Items[$i]->Item->affiliateUrl;
|
228
|
-
|
229
|
-
|
230
|
-
|
222
|
+
|
231
|
-
$itemName[$i] = $item->Items[$i]->Item->itemName;
|
223
|
+
$itemName[$i] = $item->Items[$i]->Item->itemName;
|
224
|
+
|
225
|
+
$itemCode[$i] = $item->Items[$i]->Item->itemCode;
|
226
|
+
|
227
|
+
$spCode[$i] = $item->Items[$i]->Item->shopCode;
|
228
|
+
|
229
|
+
$itemUrl[$i] = $item->Items[$i]->Item->itemUrl;
|
230
|
+
|
231
|
+
$postageFlag[$i] = number_format((int)$item->Items[$i]->Item->postageFlag);
|
232
|
+
|
233
|
+
$itemPrice[$i] = number_format((int)$item->Items[$i]->Item->itemPrice);
|
234
|
+
|
235
|
+
$itemCaption[$i] = mb_strimwidth($item->Items[$i]->Item->itemCaption, 0, 380, '...', 'UTF-8');
|
236
|
+
|
237
|
+
|
232
238
|
|
233
239
|
|
234
240
|
|
241
|
+
echo '<div style="padding:10px 10px 0 10px;">';
|
242
|
+
|
243
|
+
echo '<div style="width:130px;height:130px;float:left;"><a href="'.$affiliateUrl[$i].'" target="_blank"><img src="'.$mediumImageUrls.'" alt="" /></a></div>';
|
244
|
+
|
245
|
+
echo '<div style="margin:0 0 0 136px;">'.$itemName[$i].'<br />';
|
246
|
+
|
247
|
+
echo '<span style="color:#ff0000;">価格 '.$itemPrice[$i].' 円</span><br />';
|
248
|
+
|
235
|
-
|
249
|
+
echo $itemUrl[$i].'<br />';
|
250
|
+
|
251
|
+
|
236
252
|
|
237
253
|
|
238
254
|
|
255
|
+
if($postageFlag[$i]==0){
|
256
|
+
|
239
|
-
|
257
|
+
echo "送料込".'<br />';
|
258
|
+
|
240
|
-
|
259
|
+
}else{
|
260
|
+
|
241
|
-
|
261
|
+
echo "送料別".'<br />';
|
262
|
+
|
242
|
-
|
263
|
+
}
|
264
|
+
|
265
|
+
|
266
|
+
|
243
|
-
|
267
|
+
echo $itemCode[$i].'</div>';
|
244
268
|
|
245
269
|
|
246
270
|
|
247
|
-
$
|
271
|
+
$mysql_con = mysql_connect ("*******","*******","*******");
|
272
|
+
|
273
|
+
if ($mysql_con == false) {
|
274
|
+
|
275
|
+
print "DB_Connect Error!";
|
276
|
+
|
277
|
+
exit;
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
//MySQLのデータベースを選択
|
284
|
+
|
285
|
+
$select_db = mysql_select_db ("*******",$mysql_con);
|
286
|
+
|
287
|
+
if ($select_db == false) {
|
288
|
+
|
289
|
+
print "DB_SELECT Error!";
|
290
|
+
|
291
|
+
exit;
|
292
|
+
|
293
|
+
}
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
//insert時の文字化け回避
|
298
|
+
|
299
|
+
mysql_query('set character set utf8');
|
248
300
|
|
249
301
|
|
250
302
|
|
251
|
-
$itemPrice[$i] = number_format((int)$item->Items[$i]->Item->itemPrice);
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
$itemCaption[$i] = mb_strimwidth($item->Items[$i]->Item->itemCaption, 0, 380, '...', 'UTF-8');
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
303
|
+
$sql = "INSERT INTO rakuten_api VALUES
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
304
|
+
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
echo '<div style="margin:0 0 0 136px;">'.$itemName[$i].'<br />';
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
305
|
+
('$spCode[$i]','$itemCode[$i]','$itemName[$i]','$itemPrice[$i]','$itemUrl[$i]','$date')";
|
272
|
-
|
273
|
-
|
274
|
-
|
306
|
+
|
307
|
+
|
308
|
+
|
275
|
-
e
|
309
|
+
$result = mysql_query ($sql,$mysql_con);
|
310
|
+
|
311
|
+
|
312
|
+
|
276
|
-
|
313
|
+
//実行した結果にエラーあったらエラー表示する
|
277
|
-
|
278
|
-
|
314
|
+
|
279
|
-
if($
|
315
|
+
if ($result == false) {
|
280
|
-
|
316
|
+
|
281
|
-
|
317
|
+
print "Data Insert Error!";
|
318
|
+
|
282
|
-
|
319
|
+
exit;
|
320
|
+
|
283
|
-
|
321
|
+
} else {
|
284
|
-
|
322
|
+
|
285
|
-
|
323
|
+
print "Data Insert OK!";
|
286
|
-
|
324
|
+
|
287
|
-
}
|
325
|
+
}
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
echo $itemCode[$i].'</div>';
|
296
326
|
|
297
327
|
|
298
328
|
|
299
|
-
$mysql_con = mysql_connect ("*******","*******","*******");
|
300
|
-
|
301
|
-
if ($mysql_con == false) {
|
302
|
-
|
303
|
-
print "DB_Connect Error!";
|
304
|
-
|
305
|
-
exit;
|
306
|
-
|
307
|
-
}
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
//MySQLのデータベースを選択
|
312
|
-
|
313
|
-
$select_db = mysql_select_db ("*******",$mysql_con);
|
314
|
-
|
315
|
-
if ($select_db == false) {
|
316
|
-
|
317
|
-
print "DB_SELECT Error!";
|
318
|
-
|
319
|
-
exit;
|
320
|
-
|
321
|
-
}
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
// mysql_query('set character set utf8'); //insert時の文字化け回避
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
//$sql = "INSERT INTO rakuten_api VALUES
|
334
|
-
|
335
|
-
//('$spCode[$i]','$itemCode[$i]','$itemName[$i]','$itemPrice[$i]','$itemUrl[$i]','$date')";
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
//$result = mysql_query ($sql,$mysql_con);
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
//実行した結果にエラーあったらエラー表示する
|
346
|
-
|
347
|
-
//if ($result == false) {
|
348
|
-
|
349
|
-
// print "Data Insert Error!";
|
350
|
-
|
351
|
-
// exit;
|
352
|
-
|
353
|
-
//} else {
|
354
|
-
|
355
|
-
// print "Data Insert OK!";
|
356
|
-
|
357
|
-
//}
|
358
|
-
|
359
|
-
|
360
|
-
|
361
329
|
?>
|
362
330
|
|
331
|
+
|
332
|
+
|
363
333
|
<div style="clear:both; visibility:hidden; height:10px;">クリア</div>
|
364
334
|
|
365
335
|
<hr style="width:100%;border-top:1px dotted #bbb;" />
|
@@ -378,19 +348,21 @@
|
|
378
348
|
|
379
349
|
|
380
350
|
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
<
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
<
|
392
|
-
|
393
|
-
<
|
351
|
+
<!-- Rakuten Web Services Attribution Snippet FROM HERE -->
|
352
|
+
|
353
|
+
<div>
|
354
|
+
|
355
|
+
<a href="http://webservice.rakuten.co.jp/" target="_blank">
|
356
|
+
|
357
|
+
<img src="http://webservice.rakuten.co.jp/img/credit/200709/credit_31130.gif" border="0" alt="楽天ウェブサービスセンター" title="楽天ウェブサービスセンター" width="311" height="30"/>
|
358
|
+
|
359
|
+
</a>
|
360
|
+
|
361
|
+
</div>
|
362
|
+
|
363
|
+
<!-- Rakuten Web Services Attribution Snippet TO HERE -->
|
364
|
+
|
365
|
+
<div>全 <?php echo number_format($count); ?> 品数</div><?php }
|
394
366
|
|
395
367
|
|
396
368
|
|
@@ -422,89 +394,85 @@
|
|
422
394
|
|
423
395
|
function Page_Link($max_page,$currentpage,$nextpage,$url_a,$url_b){
|
424
396
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
$plus=0;
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
return $html;
|
397
|
+
|
398
|
+
|
399
|
+
$html = "";
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
if($max_page < 1) return $html;
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
if($currentpage > 1) $html .= $url_a.($currentpage-1).$url_b.' style="background-color: #ffffff; margin: 0; padding: 0.2em 0.5em; border: solid 1px; text-decoration: none;"'.">«</a>";
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
$prevpage = $currentpage - $nextpage;
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
while ($prevpage < $currentpage) {
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
$prevpage++;
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
if($prevpage > 1) $html .= $url_a.($prevpage-1).$url_b.">".($prevpage-1)."</a>";
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
}
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
$html .= '<span style="background-color: #ff0000; color: #ffffff; margin: 0; padding: 0.2em 0.5em; border: solid 1px #ff0000; text-decoration: none;">'.$currentpage.'</span>';
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
if($currentpage < $max_page){
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
$max_page = $max_page - $currentpage;
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
if($max_page > $nextpage) $max_page=$nextpage;
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
$plus=0;
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
while ($plus < $max_page) {
|
452
|
+
|
453
|
+
$nextpage=$currentpage+$plus+1;
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
$html .= $url_a.$nextpage.$url_b.">".$nextpage."</a>";
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
$plus++;
|
462
|
+
|
463
|
+
}
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
$html .= $url_a.($currentpage+1).$url_b.' style="background-color: #ffffff; color: #ff0000; margin: 0; padding: 0.2em 0.4em; border: solid 1px; text-decoration: none;"'.">»</a>";
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
}
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
return $html;
|
508
476
|
|
509
477
|
|
510
478
|
|