<?php
	require_once "pageBase.php";
	require_once "bin/web/tables/article.php";
	require_once "bin/web/tables/news.php";
	require_once "bin/web/tables/faq.php";
	require_once "bin/web/tables/product.php";
	require_once "bin/web/tables/book.php";
	require_once "bin/web/tables/contact.php";
	require_once "dal/htaccessDAL.php";
	require_once "dal/pictureDAL.php";

	ob_start();
	header('Content-Type: text/xml');

	class _rss extends pageBase {
		public function load() {
			$dalH = new htaccessDAL();
			$host = $_SERVER['REQUEST_SCHEME'] . "://" . $_SERVER['HTTP_HOST'];
			$aryI = [];

			$domS = new DomDocument("1.0", "UTF-8");
			$domS->formatOutput = true;
			$urlset = $domS->createElement("urlset");
			$domS->appendChild($urlset);

			$xmlns1 = $domS->createAttribute("xmlns");
			$xmlns1->value = "http://www.sitemaps.org/schemas/sitemap/0.9";
			$urlset->appendChild($xmlns1);
		
			$xmlns2 = $domS->createAttribute("xmlns:xsi");
			$xmlns2->value = "http://www.w3.org/2001/XMLSchema-instance";
			$urlset->appendChild($xmlns2);

			$xsi = $domS->createAttribute("xsi:schemaLocation");
			$xsi->value = "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd";
			$urlset->appendChild($xsi);
		
			$link = $host . "/";
			$url = $this->additem($domS, $link);
			$urlset->appendChild($url);

			$dalPT = new pictureDAL();
			$dataPT = $dalPT->executeRecordset([], "a.`PictureType`>0 AND a.`Image`!='' AND a.`ShowType`!=2", "a.`PictureType`,a.`TypeOrderNO`");
			foreach ($dataPT as $rows) {
				if (!empty($rows["Image"]) && parent::image_exists($rows["Image"])) {
					$img = $this->getImgLink($rows["Image"]);
					if (!in_array($img, $aryI)) $aryI[] = $img;
				}
			}

			$dalH->ID = "1";
			$dalH->loadRecord();
			if ($dalH->Visible == "1") {
				$dalAC = new article_categoryDAL();
				$dalA = new articleDAL();
				$article = new article();
				$link = $host . $article->linkArticleList();
				$url = $this->additem($domS, $link);
				$urlset->appendChild($url);
				
				$dataAC = $dalAC->executeRecordset([], "a.`Visible`=1 AND a.`Disable`=0");
				foreach ($dataAC as $rows) {
					$link = $host . $article->linkArticleList($rows["CategoryID"]);
					$url = $this->additem($domS, $link);
					$urlset->appendChild($url);
					if (!empty($rows["BannerImage"]) && parent::image_exists($rows["BannerImage"])) {
						$img = $this->getImgLink($rows["BannerImage"]);
						if (!in_array($img, $aryI)) $aryI[] = $img;
					}
					if (!empty($rows["OGImage"]) && parent::image_exists($rows["OGImage"])) {
						$img = $this->getImgLink($rows["OGImage"]);
						if (!in_array($img, $aryI)) $aryI[] = $img;
					}
					
					$intoAry = [parent::addArray(":categoryID", $rows["CategoryID"], "int")];
					$dataA = $dalA->executeRecordset($intoAry, "a.`CategoryID`=:categoryID AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`, a.`ArticleID`");
					foreach ($dataA as $rows2) {
						$link = $host . $article->linkArticleDetail($rows2["ArticleID"]);
						$url = $this->additem($domS, $link);
						$urlset->appendChild($url);
						if (!empty($rows2["Image"]) && parent::image_exists($rows2["Image"])) {
							$img = $this->getImgLink($rows2["Image"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						if (!empty($rows2["BannerImage"]) && parent::image_exists($rows2["BannerImage"])) {
							$img = $this->getImgLink($rows2["BannerImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						if (!empty($rows2["OGImage"]) && parent::image_exists($rows2["OGImage"])) {
							$img = $this->getImgLink($rows2["OGImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
					}
				}
			}

			$dalH->ID = "2";
			$dalH->loadRecord();
			if ($dalH->Visible == "1") {
				$dalNC = new news_categoryDAL();
				$dalN = new newsDAL();
				$news = new news();
				$link = $host . $news->linkNewsList();
				$url = $this->additem($domS, $link);
				$urlset->appendChild($url);

				$dataNC = $dalNC->executeRecordset([], "a.`Visible`=1 AND a.`Disable`=0");
				foreach ($dataNC as $rows) {
					$link = $host . $news->linkNewsList($rows["CategoryID"]);
					$url = $this->additem($domS, $link);
					$urlset->appendChild($url);
					if (!empty($rows["BannerImage"]) && parent::image_exists($rows["BannerImage"])) {
						$img = $this->getImgLink($rows["BannerImage"]);
						if (!in_array($img, $aryI)) $aryI[] = $img;
					}
					if (!empty($rows["OGImage"]) && parent::image_exists($rows["OGImage"])) {
						$img = $this->getImgLink($rows["OGImage"]);
						if (!in_array($img, $aryI)) $aryI[] = $img;
					}

					$intoAry = [parent::addArray(":categoryID", $rows["CategoryID"], "int")];
					$dataN = $dalN->executeRecordset($intoAry, "a.`CategoryID`=:categoryID AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`, a.`NewsID`");
					foreach ($dataN as $rows2) {
						$link = $host . $news->linkNewsDetail($rows2["NewsID"]);
						$url = $this->additem($domS, $link);
						$urlset->appendChild($url);
						if (!empty($rows2["Image"]) && parent::image_exists($rows2["Image"])) {
							$img = $this->getImgLink($rows2["Image"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						if (!empty($rows2["BannerImage"]) && parent::image_exists($rows2["BannerImage"])) {
							$img = $this->getImgLink($rows2["BannerImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						if (!empty($rows2["OGImage"]) && parent::image_exists($rows2["OGImage"])) {
							$img = $this->getImgLink($rows2["OGImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
					}
				}
			}

			$dalH->ID = "3";
			$dalH->loadRecord();
			if ($dalH->Visible == "1") {
				$dalFC = new faq_categoryDAL();
				$dalF = new faqDAL();
				$faq = new faq();
				$link = $host . $faq->linkFaqList();
				$url = $this->additem($domS, $link);
				$urlset->appendChild($url);

				$dataFC = $dalFC->executeRecordset([], "a.`Visible`=1 AND a.`Disable`=0");
				foreach ($dataFC as $rows) {
					$link = $host . $faq->linkFaqList($rows["CategoryID"]);
					$url = $this->additem($domS, $link);
					$urlset->appendChild($url);
					if (!empty($rows["BannerImage"]) && parent::image_exists($rows["BannerImage"])) {
						$img = $this->getImgLink($rows["BannerImage"]);
						if (!in_array($img, $aryI)) $aryI[] = $img;
					}
					if (!empty($rows["OGImage"]) && parent::image_exists($rows["OGImage"])) {
						$img = $this->getImgLink($rows["OGImage"]);
						if (!in_array($img, $aryI)) $aryI[] = $img;
					}
				}
			}

			$dalH->ID = "4";
			$dalH->loadRecord();
			if ($dalH->Visible == "1") {
				$dalC = new categoryDAL();
				$dalP = new productDAL();
				$product = new product();
				$link = $host . $product->linkProductList();
				$url = $this->additem($domS, $link);
				$urlset->appendChild($url);

				$dataC = $dalC->executeRecordset([], "a.`ParentID`=0 AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`, a.`CategoryID`");
				foreach ($dataC as $rowsC) {
					$link = $host . $product->linkProductList($rowsC["CategoryID"]);
					$url = $this->additem($domS, $link);
					$urlset->appendChild($url);
					if (!empty($rowsC["Image"]) && parent::image_exists($rowsC["Image"])) {
						$img = $this->getImgLink($rowsC["Image"]);
						if (!in_array($img, $aryI)) $aryI[] = $img;
					}
					if (!empty($rowsC["BannerImage"]) && parent::image_exists($rowsC["BannerImage"])) {
						$img = $this->getImgLink($rowsC["BannerImage"]);
						if (!in_array($img, $aryI)) $aryI[] = $img;
					}
					if (!empty($rowsC["OGImage"]) && parent::image_exists($rowsC["OGImage"])) {
						$img = $this->getImgLink($rowsC["OGImage"]);
						if (!in_array($img, $aryI)) $aryI[] = $img;
					}

					$intoAry = [parent::addArray(":categoryID", $rowsC["CategoryID"], "int")];
					$dataP = $dalP->executeRecordset($intoAry, "a.`CategoryID`=:categoryID AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`,a.`ModifiedTime` DESC");
					foreach ($dataP as $rows) {
						$link = $host . $product->linkProductDetail($rows["ProductID"]);
						$url = $this->additem($domS, $link);
						$urlset->appendChild($url);
						if (!empty($rows["IconImage"]) && parent::image_exists($rows["IconImage"])) {
							$img = $this->getImgLink($rows["IconImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						if (!empty($rows["BannerImage"]) && parent::image_exists($rows["BannerImage"])) {
							$img = $this->getImgLink($rows["BannerImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						if (!empty($rows["OGImage"]) && parent::image_exists($rows["OGImage"])) {
							$img = $this->getImgLink($rows["OGImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						$dalP->ProductID = $rows["ProductID"];
						$dalP->loadRecord();
						if (isset($dalP->ProductImageArray) && count($dalP->ProductImageArray) > 0) {
							foreach ($dalP->ProductImageArray as $rowsPI) {
								if(!empty($rowsPI["Image"]) && parent::image_exists($rowsPI["Image"])) {
									$img = $this->getImgLink($rowsPI["Image"]);
									if (!in_array($img, $aryI)) $aryI[] = $img;
								}
							}
						}
					}

					$dataC2 = $dalC->executeRecordset($intoAry, "a.`ParentID`=:categoryID AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`, a.`CategoryID`");
					foreach ($dataC2 as $rowsC2) {
						$link = $host . $product->linkProductList($rowsC2["CategoryID"]);
						$url = $this->additem($domS, $link);
						$urlset->appendChild($url);
						if (!empty($rowsC2["Image"]) && parent::image_exists($rowsC2["Image"])) {
							$img = $this->getImgLink($rowsC2["Image"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						if (!empty($rowsC2["BannerImage"]) && parent::image_exists($rowsC2["BannerImage"])) {
							$img = $this->getImgLink($rowsC2["BannerImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						if (!empty($rowsC2["OGImage"]) && parent::image_exists($rowsC2["OGImage"])) {
							$img = $this->getImgLink($rowsC2["OGImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}

						$intoAry = [parent::addArray(":categoryID", $rowsC2["CategoryID"], "int")];
						$dataP = $dalP->executeRecordset($intoAry, "a.`CategoryID`=:categoryID AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`,a.`ModifiedTime` DESC");
						foreach ($dataP as $rows) {
							$link = $host . $product->linkProductDetail($rows["ProductID"]);
							$url = $this->additem($domS, $link);
							$urlset->appendChild($url);
							if (!empty($rows["IconImage"]) && parent::image_exists($rows["IconImage"])) {
								$img = $this->getImgLink($rows["IconImage"]);
								if (!in_array($img, $aryI)) $aryI[] = $img;
							}
							if (!empty($rows["BannerImage"]) && parent::image_exists($rows["BannerImage"])) {
								$img = $this->getImgLink($rows["BannerImage"]);
								if (!in_array($img, $aryI)) $aryI[] = $img;
							}
							if (!empty($rows["OGImage"]) && parent::image_exists($rows["OGImage"])) {
								$img = $this->getImgLink($rows["OGImage"]);
								if (!in_array($img, $aryI)) $aryI[] = $img;
							}
							$dalP->ProductID = $rows["ProductID"];
							$dalP->loadRecord();
							if (isset($dalP->ProductImageArray) && count($dalP->ProductImageArray) > 0) {
								foreach ($dalP->ProductImageArray as $rowsPI) {
									if (!empty($rowsPI["Image"]) && parent::image_exists($rowsPI["Image"])) {
										$img = $this->getImgLink($rowsPI["Image"]);
										if (!in_array($img, $aryI)) $aryI[] = $img;
									}
								}
							}
						}

						$dataC3 = $dalC->executeRecordset($intoAry, "a.`ParentID`=:categoryID AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`, a.`CategoryID`");
						foreach ($dataC3 as $rowsC3) {
							$link = $host . $product->linkProductList($rowsC3["CategoryID"]);
							$url = $this->additem($domS, $link);
							$urlset->appendChild($url);
							if (!empty($rowsC3["Image"]) && parent::image_exists($rowsC3["Image"])) {
								$img = $this->getImgLink($rowsC3["Image"]);
								if (!in_array($img, $aryI)) $aryI[] = $img;
							}
							if (!empty($rowsC3["BannerImage"]) && parent::image_exists($rowsC3["BannerImage"])) {
								$img = $this->getImgLink($rowsC3["BannerImage"]);
								if (!in_array($img, $aryI)) $aryI[] = $img;
							}
							if (!empty($rowsC3["OGImage"]) && parent::image_exists($rowsC3["OGImage"])) {
								$img = $this->getImgLink($rowsC3["OGImage"]);
								if (!in_array($img, $aryI)) $aryI[] = $img;
							}

							$intoAry = [parent::addArray(":categoryID", $rowsC3["CategoryID"], "int")];
							$dataP = $dalP->executeRecordset($intoAry, "a.`CategoryID`=:categoryID AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`,a.`ModifiedTime` DESC");
							foreach ($dataP as $rows) {
								$link = $host . $product->linkProductDetail($rows["ProductID"]);
								$url = $this->additem($domS, $link);
								$urlset->appendChild($url);
								if (!empty($rows["IconImage"]) && parent::image_exists($rows["IconImage"])) {
									$img = $this->getImgLink($rows["IconImage"]);
									if (!in_array($img, $aryI)) $aryI[] = $img;
								}
								if (!empty($rows["BannerImage"]) && parent::image_exists($rows["BannerImage"])) {
									$img = $this->getImgLink($rows["BannerImage"]);
									if (!in_array($img, $aryI)) $aryI[] = $img;
								}
								if (!empty($rows["OGImage"]) && parent::image_exists($rows["OGImage"])) {
									$img = $this->getImgLink($rows["OGImage"]);
									if (!in_array($img, $aryI)) $aryI[] = $img;
								}
								$dalP->ProductID = $rows["ProductID"];
								$dalP->loadRecord();
								if (isset($dalP->ProductImageArray) && count($dalP->ProductImageArray) > 0) {
									foreach ($dalP->ProductImageArray as $rowsPI) {
										if (!empty($rowsPI["Image"]) && parent::image_exists($rowsPI["Image"])) {
											$img = $this->getImgLink($rowsPI["Image"]);
											if (!in_array($img, $aryI)) $aryI[] = $img;
										}
									}
								}
							}
						}
					}
				}
			}

			$dalH->ID = "5";
			$dalH->loadRecord();
			if ($dalH->Visible == "1") {
				$dalBC = new book_categoryDAL();
				$dalB = new bookDAL();
				$book = new book();
				$link = $host . $book->linkBookList();
				$url = $this->additem($domS, $link);
				$urlset->appendChild($url);

				$dataBC = $dalBC->executeRecordset([], "a.`ParentID`=0 AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`, a.`CategoryID`");
				foreach ($dataBC as $rowsC) {
					$link = $host . $book->linkBookList($rowsC["CategoryID"]);
					$url = $this->additem($domS, $link);
					$urlset->appendChild($url);
					if (!empty($rowsC["BannerImage"]) && parent::image_exists($rowsC["BannerImage"])) {
						$img = $this->getImgLink($rowsC["BannerImage"]);
						if (!in_array($img, $aryI)) $aryI[] = $img;
					}
					if (!empty($rowsC["OGImage"]) && parent::image_exists($rowsC["OGImage"])) {
						$img = $this->getImgLink($rowsC["OGImage"]);
						if (!in_array($img, $aryI)) $aryI[] = $img;
					}

					$intoAry = [parent::addArray(":categoryID", $rowsC["CategoryID"], "int")];
					$dataB = $dalB->executeRecordset($intoAry, "a.`CategoryID`=:categoryID AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`,a.`ModifiedTime` DESC");
					foreach ($dataB as $rows) {
						$link = $host . $book->linkBookDetail($rows["BookID"]);
						$url = $this->additem($domS, $link);
						$urlset->appendChild($url);
						if (!empty($rows["BookImage"]) && parent::image_exists($rows["BookImage"])) {
							$img = $this->getImgLink($rows["BookImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						if (!empty($rows["BannerImage"]) && parent::image_exists($rows["BannerImage"])) {
							$img = $this->getImgLink($rows["BannerImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						if (!empty($rows["OGImage"]) && parent::image_exists($rows["OGImage"])) {
							$img = $this->getImgLink($rows["OGImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						$dalB->BookID = $rows["BookID"];
						$dalB->loadRecord();
						if (isset($dalB->PhotoArray) && count($dalB->PhotoArray) > 0) {
							foreach ($dalB->PhotoArray as $rowsBP) {
								if ($rowsBP["PhotoType"] == "1" && $rowsBP["Visible"] == "1" && $rowsBP["Disable"] == "0" && !empty($rowsBP["Image"]) && parent::image_exists($rowsBP["Image"])) {
									$img = $this->getImgLink($rowsBP["Image"]);
									if (!in_array($img, $aryI)) $aryI[] = $img;
								}
							}
						}
					}

					$dataBC2 = $dalBC->executeRecordset($intoAry, "a.`ParentID`=:categoryID AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`, a.`CategoryID`");
					foreach ($dataBC2 as $rowsC2) {
						$link = $host . $book->linkBookList($rowsC2["CategoryID"]);
						$url = $this->additem($domS, $link);
						$urlset->appendChild($url);
						if (!empty($rowsC2["BannerImage"]) && parent::image_exists($rowsC2["BannerImage"])) {
							$img = $this->getImgLink($rowsC2["BannerImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}
						if (!empty($rowsC2["OGImage"]) && parent::image_exists($rowsC2["OGImage"])) {
							$img = $this->getImgLink($rowsC2["OGImage"]);
							if (!in_array($img, $aryI)) $aryI[] = $img;
						}

						$intoAry = [parent::addArray(":categoryID", $rowsC2["CategoryID"], "int")];
						$dataB = $dalB->executeRecordset($intoAry, "a.`CategoryID`=:categoryID AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`,a.`ModifiedTime` DESC");
						foreach ($dataB as $rows) {
							$link = $host . $book->linkBookDetail($rows["BookID"]);
							$url = $this->additem($domS, $link);
							$urlset->appendChild($url);
							if (!empty($rows["BookImage"]) && parent::image_exists($rows["BookImage"])) {
								$img = $this->getImgLink($rows["BookImage"]);
								if (!in_array($img, $aryI)) $aryI[] = $img;
							}
							if (!empty($rows["BannerImage"]) && parent::image_exists($rows["BannerImage"])) {
								$img = $this->getImgLink($rows["BannerImage"]);
								if (!in_array($img, $aryI)) $aryI[] = $img;
							}
							if (!empty($rows["OGImage"]) && parent::image_exists($rows["OGImage"])) {
								$img = $this->getImgLink($rows["OGImage"]);
								if (!in_array($img, $aryI)) $aryI[] = $img;
							}
							$dalB->BookID = $rows["BookID"];
							$dalB->loadRecord();
							if (isset($dalB->PhotoArray) && count($dalB->PhotoArray) > 0) {
								foreach ($dalB->PhotoArray as $rowsBP) {
									if ($rowsBP["PhotoType"] == "1" && $rowsBP["Visible"] == "1" && $rowsBP["Disable"] == "0" && !empty($rowsBP["Image"]) && parent::image_exists($rowsBP["Image"])) {
										$img = $this->getImgLink($rowsBP["Image"]);
										if (!in_array($img, $aryI)) $aryI[] = $img;
									}
								}
							}
						}

						$dataC3 = $dalC->executeRecordset($intoAry, "a.`ParentID`=:categoryID AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`, a.`CategoryID`");
						foreach ($dataC3 as $rowsC3) {
							$link = $host . $book->linkBookList($rowsC3["CategoryID"]);
							$url = $this->additem($domS, $link);
							$urlset->appendChild($url);
							if (!empty($rowsC3["BannerImage"]) && parent::image_exists($rowsC3["BannerImage"])) {
								$img = $this->getImgLink($rowsC3["BannerImage"]);
								if (!in_array($img, $aryI)) $aryI[] = $img;
							}
							if (!empty($rowsC3["OGImage"]) && parent::image_exists($rowsC3["OGImage"])) {
								$img = $this->getImgLink($rowsC3["OGImage"]);
								if (!in_array($img, $aryI)) $aryI[] = $img;
							}

							$intoAry = [parent::addArray(":categoryID", $rowsC3["CategoryID"], "int")];
							$dataB = $dalB->executeRecordset($intoAry, "a.`CategoryID`=:categoryID AND a.`Visible`=1 AND a.`Disable`=0", "a.`OrderNO`,a.`ModifiedTime` DESC");
							foreach ($dataB as $rows) {
								$link = $host . $book->linkBookDetail($rows["BookID"]);
								$url = $this->additem($domS, $link);
								$urlset->appendChild($url);
								if (!empty($rows["BookImage"]) && parent::image_exists($rows["BookImage"])) {
									$img = $this->getImgLink($rows["BookImage"]);
									if (!in_array($img, $aryI)) $aryI[] = $img;
								}
								if (!empty($rows["BannerImage"]) && parent::image_exists($rows["BannerImage"])) {
									$img = $this->getImgLink($rows["BannerImage"]);
									if (!in_array($img, $aryI)) $aryI[] = $img;
								}
								if (!empty($rows["OGImage"]) && parent::image_exists($rows["OGImage"])) {
									$img = $this->getImgLink($rows["OGImage"]);
									if (!in_array($img, $aryI)) $aryI[] = $img;
								}
								$dalB->BookID = $rows["BookID"];
								$dalB->loadRecord();
								if (isset($dalB->PhotoArray) && count($dalB->PhotoArray) > 0) {
									foreach ($dalB->PhotoArray as $rowsBP) {
										if($rowsBP["PhotoType"] == "1" && $rowsBP["Visible"] == "1" && $rowsBP["Disable"] == "0" && !empty($rowsBP["Image"]) && parent::image_exists($rowsBP["Image"])) {
											$img = $this->getImgLink($rowsBP["Image"]);
											if (!in_array($img, $aryI)) $aryI[] = $img;
										}
									}
								}
							}
						}
					}
				}
			}

			$dalH->ID = "6";
			$dalH->loadRecord();
			if ($dalH->Visible == "1") {
				$contact = new contact();
				$link = $host . $contact->linkContact();
				$url = $this->additem($domS, $link);
				$urlset->appendChild($url);
			}

			foreach ($aryI as $v) {
				$url = $this->additem($domS, $v);
				$urlset->appendChild($url);
			}

			$xmlCode = $domS->saveXML();
			echo $xmlCode;
		}

		private function additem($dom, $link) {
			$url = $dom->createElement("url");
			$loc = $dom->createElement("loc", $link);
			$url->appendChild($loc);
			return $url;
		}

		private function getImgLink($url) {
			$scheme = $_SERVER['REQUEST_SCHEME'];
			$host = $_SERVER['HTTP_HOST'];
			if (preg_match("/^\/\//", $url)) {
				$link = $scheme . ":" . $url;
			} else if (preg_match("/^http/", $url)) {
				$link = $url;
			} else if (preg_match("/^\//", $url)) {
				$link = $scheme . "://" . $host . $url;
			} else {
				$link = $scheme . "://" . $host . "/" . $url;
			}
			return $link;
		}
	}
	$page = new _rss();
	$page->load();
?>