function Scan($url) { global $scanned, $pf, $extension, $skip, $freq, $priority; echo "scan url {$url}\n"; array_push($scanned, $url); $html = GetUrl($url); $a1 = explode("<a", $html); foreach ($a1 as $key => $val) { $parts = explode(">", $val); $a = $parts[0]; $aparts = explode("href=", $a); $hrefparts = explode(" ", $aparts[1]); $hrefparts2 = explode("#", $hrefparts[0]); $href = str_replace("\"", "", $hrefparts2[0]); if (substr($href, 0, 7) != "http://" && substr($href, 0, 8) != "https://" && substr($href, 0, 6) != "ftp://") { if ($href[0] == '/') { $href = "{$scanned['0']}{$href}"; } else { $href = Path($url) . $href; } } if (substr($href, 0, strlen($scanned[0])) == $scanned[0]) { $ignore = false; if (isset($skip)) { foreach ($skip as $k => $v) { if (substr($href, 0, strlen($v)) == $v) { $ignore = true; } } } if (!$ignore && !in_array($href, $scanned) && strpos($href, $extension) > 0) { fwrite($pf, "<url>\n <loc>{$href}</loc>\n" . " <changefreq>{$freq}</changefreq>\n" . " <priority>{$priority}</priority>\n</url>\n"); echo $href . "\n"; Scan($href); } } } }
function Scan($way, $level) { $list = scandir($way); //获取当前路径的文件列表,包括目录 for ($i = 0; $i < count($list); $i++) { if ($list[$i] != '.' && $list[$i] != '..' && $list[$i] != "index.php" && $list[$i] != "judge" && $list[$i] != "css" && $list[$i] != "js") { if (is_dir($way . $list[$i] . "/")) { print " <li>{$list[$i]}</li>\n"; print "<ul "; if ($level <= 1) { // 每个文件夹只展开两层 print "show=true"; } print ">\n"; Scan($way . $list[$i] . "/", $level + 1); //递归进入下一层 print "\n</ul>\n"; } else { print "<li><a href=\"{$way}{$list[$i]}\">{$list[$i]}</a></li>\n"; } } } }
$qry = "1"; // search filters // QUERY READY global $save_qry; if ($save_qry) { $qry = $session->data['ssdp_devices_qry']; } else { $session->data['ssdp_devices_qry'] = $qry; } if (!$qry) { $qry = "1"; } //="ID DESC"; //$out['SORTBY']=$sortby_ssdp_devices; // SEARCH RESULTS $res = Scan(); if ($res[0]['ID']) { //paging($res, 100, $out); // search result paging $total = count($res); for ($i = 0; $i < $total; $i++) { // some action for every record if required $tmp = explode(' ', $res[$i]['UPDATED']); $res[$i]['UPDATED'] = fromDBDate($tmp[0]) . " " . $tmp[1]; } $out['RESULT'] = $res; } function Scan() { $upnp = new Upnp(); print 'searching...' . PHP_EOL; $everything = $upnp->discover();
function run_mysql() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid, __FILE__)) { return; } $q = new mysql_squid_builder(); if (!$q->FIELD_EXISTS("import_srclogs", "pid")) { $q->QUERY_SQL("ALTER TABLE `import_srclogs` ADD `pid` smallint(5)"); } if (!$q->FIELD_EXISTS("import_srclogs", "first_time")) { $q->QUERY_SQL("ALTER TABLE `import_srclogs` ADD `first_time` INT UNSIGNED"); } if (!$q->FIELD_EXISTS("import_srclogs", "last_time")) { $q->QUERY_SQL("ALTER TABLE `import_srclogs` ADD `last_time` INT UNSIGNED"); } $php = $unix->LOCATE_PHP5_BIN(); $nohup = $unix->find_program("nohup"); $sql = "SELECT * FROM import_srclogs WHERE status=0 ORDER BY zDate"; $results = $q->QUERY_SQL($sql); while ($ligne = mysql_fetch_assoc($results)) { $md5file = $ligne["md5file"]; $path = $ligne["path"]; mysql_progress($md5file, 0, 1, "Open.."); $t1 = time(); if (Scan($path, $md5file)) { $took = $unix->distanceOfTimeInWords($t1, time(), true); mysql_progress($md5file, 100, 2, "{done} {took} {$took}"); @unlink($path); } shell_exec("{$nohup} {$php} " . __FILE__ . " --run-mysql >/dev/null 2>&1"); die; } }
function Scan($url) { global $scanned, $pf, $extension, $skip, $freq, $priority; echo $url . NL; array_push($scanned, $url); $html = GetUrl($url); $a1 = explode("<a", $html); foreach ($a1 as $val) { $anker_parts = explode(">", $val); $a = $anker_parts[0]; $href_split = explode("href=", $a); $href_string = $href_split[1]; if ($href_string[0] == '"') { $next_url = GetQuotedUrl($href_string); } else { $spaces_split = explode(" ", $href_string); $next_url = str_replace("\"", "", $spaces_split[0]); } $fragment_split = explode("#", $next_url); $next_url = $fragment_split[0]; if (substr($next_url, 0, 7) != "http://" && substr($next_url, 0, 8) != "https://" && substr($next_url, 0, 6) != "ftp://" && substr($next_url, 0, 7) != "mailto:") { if ($next_url[0] == '/') { $next_url = "{$scanned['0']}{$next_url}"; } else { $next_url = Path($url) . $next_url; } } if (substr($next_url, 0, strlen($scanned[0])) == $scanned[0]) { $ignore = false; if (isset($skip)) { foreach ($skip as $v) { if (substr($next_url, 0, strlen($v)) == $v) { $ignore = true; } } } if (!$ignore && !in_array($next_url, $scanned)) { foreach ($extension as $ext) { //if (strpos ($next_url, $ext) < 0) //{ fwrite($pf, " <url>\n" . " <loc>" . htmlentities($next_url) . "</loc>\n" . " <changefreq>{$freq}</changefreq>\n" . " <priority>{$priority}</priority>\n" . " </url>\n"); Scan($next_url); //} } } } } }
} // Configure with formdata $Resolution = RequestParm("ddlResolution", $Resolution); $Format = RequestParm("ddlFormat", $Format); $Size = RequestParm("ddlSize", $Size); $Crop = RequestParm("chkCrop", $Crop) != false; $CropFuzz = RequestParm("txtCropFuzz", $CropFuzz); $Prefix = RequestParm("txtPrefix", $Prefix); $CurrentKey = $Scanner["ScanDevice"] . "_" . $Resolution . "_" . $Format . "_" . $Size; // Preprocess $DestFile = null; if (RequestParm("btnScan", false)) { $timeThen = time() + microtime(); CleanUp(); $baseName = $Prefix . "-" . date("Y-m-d_H_i_s"); $DestFile = Scan($Scanner["ScanDevice"], $Resolution, $Format, $Size, $baseName); if ($Crop) { CropImage($DestFile); } MoveToDest($DestFile); $timeNow = time() + microtime(); $timings->RegisterTiming($CurrentKey, $timeNow - $timeThen); } // Pass the JSON object of timings to client echo "<script>\n"; echo "var timings="; echo json_encode($timings->GetTimingsAverage(), JSON_PRETTY_PRINT); echo ";\n"; echo "</script>\n"; // Render Form $formFields = "";