';
echo "\r\n";
echo'';
echo "\r\n";
/*
|--------------------------------------------------------------------------
| Custom Function: sitemap.php?page=1&load=1
| Extract and save data to option table
|* @param page = x (to run multiple pages) load = 1 (to write to robots.txt)
|* @return (true, false)
|--------------------------------------------------------------------------
|
*/
include_once("includes/config.php");
$mysqli = new mysqli($hostname, $username, $password, $database);
if (isset($_GET['specialtyID'])) $specialtyID = $_GET["specialtyID"]; else $specialtyID = '';
if (isset($_GET["page"])) $page = $_GET["page"]; else $page = '';
if (isset($_GET["load"])) $load = $_GET["load"]; else $load = '';
$startpost = "47";
$per_page =5000;//define how links per page
$base_url="https://".$_SERVER['SERVER_NAME'].dirname($_SERVER["REQUEST_URI"].'?');
//echo "base url: $base_url
";
?>
https:// echo $_SERVER["SERVER_NAME"]; ?>/
echo date("Y-m-d"); ?>
daily
1.0
//main pages ******************************************************/
if ($page == "") { // || $page == 0) { //if ($specialtyID == "") { //state pages and city pages on page 1 only
$links = array("/law-office/", "/immigration-law/", "/bankruptcy-law/", "/divorce-law/", "/personal-injury/", "/estate-law/",
"/child-support-laws/", "/corporate-law/", "/credit-repair-law/", "/criminal-law/", "/defense/", "/disability-law/", "/divorce-law/",
"/dui-law/", "/law-office/", "/auto-accident/", "/bankruptcy-law/", "/business-law/", "/child-support-laws/", "/civil-rights-law/",
"/construction-law/", "/corporate-law/", "/credit-repair-law/", "/criminal-law/", "/defense/", "/disability-law/", "/divorce-law/",
"/dui-law/", "/employment-law/", "/environmental-law/", "/estate-law/", "/immigration-law/", "/insurance-law/", "/intellectual-property-law/",
"/international-law/", "/litigation-law/", "/medical-malpractrice/", "/patent-law/", "/personal-injury/", "/tax-law/", "/trial-law/",
"/workers-compensation-law/");
foreach ($links as $key => $item) {
?>
https:// echo $_SERVER["SERVER_NAME"].$item; ?>
echo date("Y-m-d"); ?>
daily
0.9
}
//FAQs pages
include_once("_web-content-list.php"); $inputFile = $input;
for ($j=0; $j
https:// echo $_SERVER["SERVER_NAME"]."/".$arrListItems[$i]['docName']; ?>/
echo date("Y-m-d"); ?>
daily
0.8
} //end for i
} //end for j
//state pages
$links = array("law-office","immigration-law","bankruptcy-law","estate-law","divorce-law","child-support-laws","personal-injury","law-office","auto-accident","bankruptcy-law","business-law","child-support-laws","civil-rights-law","construction-law","corporate-law","credit-repair-law","criminal-law","defense","disability-law","divorce-law","dui-law","employment-law","environmental-law","estate-law","immigration-law","insurance-law","intellectual-property-law","international-law","litigation-law","medical-malpractrice","patent-law","personal-injury","tax-law","trial-law","workers-compensation-law");
foreach ($links as $key => $item) {
if ($item == "law-office")
$sql = "SELECT CONCAT('/$item/',URLSTATE,'/') as link FROM states";
else
$sql = "SELECT CONCAT('/$item/location/',URLSTATE,'/') as link FROM states";
//ex: https://www.lawyersattorneysguide.com/law-office/florida/
//ex: https://www.lawyersattorneysguide.com/immigration-law/location/florida/
$oRs = $mysqli->query($sql);
while($string=$oRs->fetch_array()){?>
https:// echo $_SERVER["SERVER_NAME"]; ?>
echo date("Y-m-d"); ?>
daily
0.7
} //end while
} // end for each
// city pages ******************************************************/
} else if ($specialtyID != "" && $page > 0) {
$start = ($page - 1) * $per_page;
include_once("_custom-header.php");
if ($specialtyID == "8111") {
$sql = "SELECT DISTINCT CONCAT('/$specialtyDir/', REPLACE(LOWER(b1.URLSTATE),' ','-'), '/',REPLACE(LOWER(a1.CITY),' ','-'),'/') as link
FROM $tablelist a1
LEFT JOIN states b1 ON b1.STCODE = a1.STATE
WHERE a1.CITY IS NOT NULL AND a1.`SIC CODE` = $specialtyID
LIMIT $start,$per_page ";
} else {
$sql = "SELECT DISTINCT CONCAT('/$specialtyDir/location/', REPLACE(LOWER(b1.URLSTATE),' ','-'), '/',REPLACE(LOWER(a1.CITY),' ','-'),'/') as link
FROM $tablelist a1
LEFT JOIN states b1 ON b1.STCODE = a1.STATE
WHERE a1.CITY IS NOT NULL AND a1.`SIC CODE` = $specialtyID
LIMIT $start,$per_page ";
}
$oRs = $mysqli->query($sql);
//echo $sql;
while($string=$oRs->fetch_array()){?>
https://www.lawyersattorneysguide.com
echo date("Y-m-d"); ?>
daily
0.7
} //end while
} //end if ?>
//loading robots.txt with sitemap links
if ($load > 0) {
$sql = $mysqli->query("select count(*) as total FROM wp_posts WHERE post_title <> '' AND ID > ".$startpost." ");
//$string = $sql->fetch_assoc();
$string = mysqli_fetch_array($sql);
$tot_rows = $string['total'];
$total = ceil($tot_rows/$per_page);
echo "Pages: ".$total."
";
$txtrobots = "# robots.txt\r\n";
$txtrobots .= "User-agent: Googlebot\r\n";
$txtrobots .= "User-agent: Slurp\r\n";
$txtrobots .= "User-agent: msnbot \r\n";
$txtrobots .= "User-agent: Mediapartners-Google*\r\n";
$txtrobots .= "User-agent: Mediapartners-Google\r\n";
$txtrobots .= "User-agent: Googlebot-Image \r\n";
$txtrobots .= "User-agent: Yahoo-MMCrawler\r\n";
$txtrobots .= "User-agent: Adsbot-Google\r\n";
$txtrobots .= "User-agent: *Google*\r\n";
$txtrobots .= "Disallow: \r\n";
$txtrobots .= "\r\n";
$txtrobots .= "User-agent: SemrushBot\r\n";
$txtrobots .= "Disallow: /\r\n";
$txtrobots .= "\r\n";
$txtrobots .= "User-agent: SemrushBot-SA\r\n";
$txtrobots .= "Disallow: /\r\n";
$txtrobots .= "\r\n";
for ($i = 1; $i <= $total; $i++)
{
$txtrobots .= "Sitemap: https://". $_SERVER["SERVER_NAME"]. "/sitemap.php?page=".$i."\r\n";
}
echo $txtrobots;
$fp = fopen("robots.txt", 'w');
fwrite($fp, $txtrobots);
fclose($fp);
echo "Done!";
}
?>