{"id":1460,"date":"2024-05-15T22:21:37","date_gmt":"2024-05-15T14:21:37","guid":{"rendered":"https:\/\/hkc.nasclub.vip\/?p=1460"},"modified":"2024-05-15T22:24:54","modified_gmt":"2024-05-15T14:24:54","slug":"%e8%87%aa%e5%b7%b1%e5%88%b6%e4%bd%9c%e4%b8%80%e4%b8%aa%e6%9c%ac%e5%9c%b0%e5%9b%be%e7%89%87api%e6%8e%a5%e5%8f%a3","status":"publish","type":"post","link":"https:\/\/hkc.nasclub.vip\/?p=1460","title":{"rendered":"\u81ea\u5df1\u5236\u4f5c\u4e00\u4e2a\u672c\u5730\u56fe\u7247api\u63a5\u53e3"},"content":{"rendered":"<p>\u5982\u4f55\u50bb\u74dc\u5f0f\u7684\u52a8\u624b\u505a\u4e00\u4e2a<strong>API<\/strong> \u56fe\u7247API\/\u52a8\u6f2bAPI\/\u968f\u673a\u56fe\u7247<\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"dk4hb\">\u51c6\u5907\u5de5\u4f5c\uff1a<\/h3>\n<p>\u51c6\u5907\u4e00\u4e2a\u57df\u540d\uff0c\u4e00\u4e2a\u670d\u52a1\u5668\uff08\u865a\u62df\u4e3b\u673a\u4e5f\u53ef\u4ee5\uff0c\u9700\u8981\u652f\u6301PHP\uff09<\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"1h6kj\">\u672c\u5730\u56fe\u7247API\u5236\u4f5c\u65b9\u6cd5\uff1a<\/h3>\n<p>\u65b0\u5efa\u4e00\u4e2aPHP\u6587\u4ef6\uff08\u4f8b\uff1aapi.php\uff09\uff0c\u5728\u521b\u5efa\u4e00\u4e2aimages\u6587\u4ef6\u5939\uff0c\u628a\u56fe\u7247\u653e\u8fdb\u53bb<\/p>\n<p>\u628aapi.php\u6587\u4ef6\u548cimages\u6587\u4ef6\u5939\u4e0a\u4f20\u5230\u670d\u52a1\u5668\uff0c\u7136\u540e\u8bbf\u95ee\u00a0 <strong>\u57df\u540d\/api.php\u00a0 <\/strong>\u6587\u4ef6\u540d\u5c31\u53ef\u4ee5\u5566<\/p>\n<p>\u4f8b\uff1ahttps:\/\/domain.com\/api.php<\/p>\n<p>&nbsp;<\/p>\n<p>php\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"io-enlighter-pre\"><code class=\"code\" data-enlighter-language=\"php\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"\" data-enlighter-highlight=\"\">&lt;?php\r\nheader('Content-Type: image\/png'); \/\/ \u5148\u9ed8\u8ba4\u8bbe\u7f6e\u4e3a png \u7c7b\u578b\r\n\r\n$galleryPath = '.\/images'; \/\/ \u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u56fe\u5e93\u8def\u5f84\r\n\r\nif (isset($_GET['image'])) {\r\n    $imageName = $_GET['image'];\r\n\r\n    $extension = pathinfo($imageName, PATHINFO_EXTENSION);\r\n\r\n    switch ($extension) {\r\n        case 'gif':\r\n            header('Content-Type: image\/gif');\r\n            break;\r\n        case 'jpg':\r\n        case 'jpeg':\r\n            header('Content-Type: image\/jpeg');\r\n            break;\r\n        case 'png':\r\n            header('Content-Type: image\/png');\r\n            break;\r\n        case 'webp':\r\n            header('Content-Type: image\/webp');\r\n            break;\r\n        case 'bmp':\r\n            header('Content-Type: image\/bmp');\r\n            break;\r\n        case 'ico':\r\n            header('Content-Type: image\/x-icon');\r\n            break;\r\n        case'svg':\r\n            header('Content-Type: image\/svg+xml');\r\n            break;\r\n    }\r\n\r\n    $imagePath = $galleryPath. '\/'. $imageName;\r\n} else {\r\n    $images = scandir($galleryPath);\r\n    $randomImage = $images[array_rand($images)];\r\n\r\n    $randomExtension = pathinfo($randomImage, PATHINFO_EXTENSION);\r\n\r\n    switch ($randomExtension) {\r\n        case 'gif':\r\n            header('Content-Type: image\/gif');\r\n            break;\r\n        case 'jpg':\r\n        case 'jpeg':\r\n            header('Content-Type: image\/jpeg');\r\n            break;\r\n        case 'png':\r\n            header('Content-Type: image\/png');\r\n            break;\r\n        case 'webp':\r\n            header('Content-Type: image\/webp');\r\n            break;\r\n        case 'bmp':\r\n            header('Content-Type: image\/bmp');\r\n            break;\r\n        case 'ico':\r\n            header('Content-Type: image\/x-icon');\r\n            break;\r\n        case'svg':\r\n            header('Content-Type: image\/svg+xml');\r\n            break;\r\n    }\r\n\r\n    $imagePath = $galleryPath. '\/'. $randomImage;\r\n}\r\n\r\nif (file_exists($imagePath)) {\r\n    readfile($imagePath);\r\n} else {\r\n    http_response_code(404);\r\n}\r\n?&gt;<\/code><\/pre>\n<p>\u4e00\u4e2a\u672c\u5730\u56fe\u7247API\u63a5\u53e3\u5c31\u53ea\u505a\u597d\u4e86\uff0c\u65e2\u53ef\u4ee5\u663e\u793a\u968f\u673a\u56fe\u7247\uff0c\u4e5f\u53ef\u4ee5\u663e\u793a\u6307\u5b9a\u56fe\u7247<\/p>\n<p>\u6253\u5f00\u6d4f\u89c8\u5668\u8f93\u5165\uff1a<\/p>\n<p>https:\/\/domain.com\/api.php\u00a0 \u00a0 \u00a0 \u00a0\u968f\u673a\u663e\u793aimages\u6587\u4ef6\u5939\u4e0b\u7684\u56fe\u7247<\/p>\n<p>https:\/\/domain.com\/api.php?image=name.png\u00a0 \u00a0 \u00a0\u663e\u793a\u6307\u5b9a\u6587\u4ef6\u540d\u7684\u56fe\u7247<\/p>\n<h3><\/h3>\n<h3><\/h3>\n<h3 id=\"5o4s2\">\u5916\u94fe\u56fe\u7247API<\/h3>\n<p>\u5236\u4f5c\u65b9\u6cd5<\/p>\n<p>\u65b0\u5efa\u4e00\u4e2aPHP\u6587\u4ef6\uff08\u4f8b\uff1aapi.php\uff09\u4e0e\u00a0 \u00a0images.txt\u6587\u6863\u6587\u4ef6\uff0c\u628a\u5916\u94fe\u56fe\u7247\u5730\u5740\u5199\u8fdbimages.txt<\/p>\n<p>\u628aphp\u6587\u4ef6\u548ctxt\u6587\u6863\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u91cc\uff0c\u7136\u540e\u8bbf\u95ee\u00a0 <strong>\u57df\u540d\/api.php\u00a0 <\/strong>\u6587\u4ef6\u540d\u5c31\u53ef\u4ee5\u5566<\/p>\n<p>\u4f8b\uff1ahttps:\/\/domain.com\/api.php<\/p>\n<p>PHP\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"io-enlighter-pre\"><code class=\"code\" data-enlighter-language=\"php\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"\" data-enlighter-highlight=\"\">&lt;?php\r\n$arr=file(\"images.txt\");\r\n$n=count($arr)-1;\r\nfor ($i=1;$i&lt;=1;$i++){\r\n$x=rand(0,$n);\r\nheader(\"Location:\".$arr[$x],\"\\n\");\r\n}\r\n?&gt;<\/code><\/pre>\n<h3>TXT\u6587\u4ef6\u5185\u5bb9\uff1a<\/h3>\n<pre class=\"io-enlighter-pre\"><code class=\"code\" data-enlighter-language=\"generic\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"\" data-enlighter-highlight=\"\">http:\/\/domain.com\/img\/pc\/pc_1.jpg\r\nhttp:\/\/domain.com\/img\/pc\/pc_2.jpg\r\nhttp:\/\/domain.com\/img\/pc\/pc_3.jpg\r\n......<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u50bb\u74dc\u5f0f\u7684\u52a8\u624b\u505a\u4e00\u4e2aAPI \u56fe&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[],"class_list":["post-1460","post","type-post","status-publish","format-standard","hentry","category-hkc","category-synology"],"_links":{"self":[{"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=\/wp\/v2\/posts\/1460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1460"}],"version-history":[{"count":4,"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=\/wp\/v2\/posts\/1460\/revisions"}],"predecessor-version":[{"id":1464,"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=\/wp\/v2\/posts\/1460\/revisions\/1464"}],"wp:attachment":[{"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hkc.nasclub.vip\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}