圖片展示網站及源碼

@zgcwkj  2019年09月06日

分類:

代碼 網站 

代碼有點粗糙,能用就行哈哈!(PHP)

為什麼要寫這個源碼呢,其實是有原因的

關注我的人都知道,之前寫了很多的爬蟲的程序,基本上都是圖片的,我就想能不能把它們活用呢?於是乎,通過網站的形式展示出圖片的網站就是這樣出來了!

源碼鑒賞:

<?php
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);

echo '<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width; initial-scale=1.0; minimum-scale=1.0; maximum-scale=1.0">
    <title>' . (isset($_REQUEST["name"]) ? $_REQUEST["name"] . ' - ' : '') . '圖片庫 - By zgcwkj</title>
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <link href="css/zoomify.css" rel="stylesheet" type="text/css">
</head>
<body>
';
$go_Name = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
$go_FilePath = dirname(__FILE__) . '/img/' . $go_Name; //獲取當前路徑
$go_FilePath = iconv('UTF-8', 'GBK', $go_FilePath); //處理中文亂碼問題
$go_Files = scandir($go_FilePath); //獲取所有的文件
for ($i = 0; $i < count($go_Files); $i++) {
    $go_File = $go_Files[$i];
    if ($go_File == '.' || $go_File == '..' || strpos($go_File, '.php') || strpos($go_File, '.exe')) continue;
    $go_File = iconv('GBK', 'UTF-8',  $go_File);
    $go_File = $go_Name ? $go_Name . "/" . $go_File : $go_File;
    if (strpos($go_File, '.jpg') || strpos($go_File, '.jpeg') || strpos($go_File, '.png') || strpos($go_File, '.bmp')) {
        $html = "<img class='phpImg' height='200' src='img/" . $go_File . "' alt = '" . $go_File . "'>";
    } else {
        $html = "<div class='phpDiv'>";
        $html .= "<a href='index.php?name=" . $go_File . "' target='_blank'>" . $go_File . "</a>";
        $html .= "</div>";
    }
    echo $html;
}
echo '
    <footer>
        <p>本站圖片由 <a href="http://www.mzitu.com/" target="_blank">妹子圖</a> 提供,使用 <a href="http://blog.www.zgcwkj.com/archives/854.html" target="_blank">MzituGrab</a> 程序采集</p>
        <p>Powered by <a href="http://blog.www.zgcwkj.com/" target="_blank">zgcwkj</a></p>
    </footer>
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="js/zoomify.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(".phpImg").zoomify();
    </script>
</body>
</html>
';

源碼下載:

內容已隱藏,需要評論並且審核通過後,才能閱讀隱藏內容

使用說明:

解壓,然後運行 img 文件夾下的 exe 程序即可!


評論已關閉

  1. 還可以上車嗎?

  2. 阿文

    想學習下,謝謝分享

  3. 與亓

    看源碼學一下,感謝分享!

  4. 我要上車。。。

  5. 大佬想要那種圖片站的源碼,可以顯示圖片的信息格式

    1. @繁華落盡

      我這沒有~~

  6. 李白哥哥

    找半天,終於找到了!

  7. 個個人滿

    我要上車~ 別開太快

  8. 車速快的停不下來~

  9. 如果我下載了,那一定是我手抖了。

  10. 你這個老司機

  11. 感謝分享源碼。

Top