1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| <?php
$path = './public'; $domain = 'https://www.xiang007.com'; $result = scanFile($path); $urls = []; foreach ($result as $key => $value) { $all_url = $domain.str_replace($path,'',$value); echo $all_url."\n"; $urls[] = $all_url; }
$api = 'http://data.zz.baidu.com/urls?site=https://www.xiang007.com&token=nwmiI8Qsd5B4WRjJ'; $ch = curl_init(); $options = array( CURLOPT_URL => $api, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => implode("\n", $urls), CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), ); curl_setopt_array($ch, $options); $result = curl_exec($ch); echo $result;
function scanFile($path) { global $result; $files = scandir($path); foreach ($files as $file) { if ($file != '.' && $file != '..' && !in_array($file, ['css','images','img','js','lib','link','page','tags','archives','categories'])) { if (is_dir($path . '/' . $file)) { scanFile($path . '/' . $file); $link_add = $path . '/' . $file; $count = substr_count($link_add, '/'); if ($count >= 5) { $result[] = $link_add; } } } } return $result; }
|