



19,000,000 5%
feed-builder/
build.php ← اسکریپت اصلی
torob-feed.xml
google-feed.xml
feed-log.txt
last-hash.txt
createElement($tag);
$el->appendChild($dom->createTextNode($value));
$parent->appendChild($el);
}
// =======================================
// ساخت فید ترب
// =======================================
$dom_torob = new DOMDocument("1.0", "UTF-8");
$dom_torob->formatOutput = true;
$root_torob = $dom_torob->createElement("products");
foreach ($products as $p) {
if (($p['status'] ?? "") !== "active") continue;
if (($p['stock'] ?? 0) <= 0) continue;
$item = $dom_torob->createElement("product");
xml_add($dom_torob, $item, "id", $p['id']);
xml_add($dom_torob, $item, "name", $p['title']);
xml_add($dom_torob, $item, "price", $p['price']);
xml_add($dom_torob, $item, "brand", $p['brand']);
xml_add($dom_torob, $item, "category", $p['category']);
xml_add($dom_torob, $item, "url", $p['link']);
xml_add($dom_torob, $item, "image", $p['image']);
xml_add($dom_torob, $item, "availability", "instock");
$root_torob->appendChild($item);
}
$dom_torob->appendChild($root_torob);
$dom_torob->save($torob_feed_file);
log_msg("INFO", "Torob feed generated.");
// =======================================
// ساخت فید گوگل (Google Merchant Center)
// =======================================
$dom_google = new DOMDocument("1.0", "UTF-8");
$dom_google->formatOutput = true;
$rss = $dom_google->createElement("rss");
$rss->setAttribute("version", "2.0");
$rss->setAttribute("xmlns:g", "http://base.google.com/ns/1.0");
$channel = $dom_google->createElement("channel");
xml_add($dom_google, $channel, "title", "LavasemKhangi Feed");
xml_add($dom_google, $channel, "link", "https://lavasemkhangi.ir");
xml_add($dom_google, $channel, "description", "Google Feed for store");
foreach ($products as $p) {
if (($p['status'] ?? "") !== "active") continue;
if (($p['stock'] ?? 0) <= 0) continue;
$item = $dom_google->createElement("item");
xml_add($dom_google, $item, "g:id", $p['id']);
xml_add($dom_google, $item, "g:title", $p['title']);
xml_add($dom_google, $item, "g:description", $p['title']);
xml_add($dom_google, $item, "g:link", $p['link']);
xml_add($dom_google, $item, "g:image_link", $p['image']);
xml_add($dom_google, $item, "g:brand", $p['brand']);
xml_add($dom_google, $item, "g:price", $p['price'] . " IRR");
xml_add($dom_google, $item, "g:availability", "in stock");
$channel->appendChild($item);
}
$rss->appendChild($channel);
$dom_google->appendChild($rss);
$dom_google->save($google_feed_file);
log_msg("INFO", "Google feed generated.");
// =======================================
// ارسال به ترب
// =======================================
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $torob_api,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => [
'feed_file' => new CURLFile($torob_feed_file)
],
CURLOPT_RETURNTRANSFER => true
]);
$res = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
if ($err) {
log_msg("ERROR", "Torob upload failed: $err");
exit("Torob upload error");
}
log_msg("INFO", "Torob feed uploaded. Response: $res");
// =======================================
// پینگ گوگل → اطلاعرسانی بروزرسانی فید
// =======================================
$google_ping = "https://www.google.com/ping?sitemap=" . urlencode("https://lavasemkhangi.ir/google-feed.xml");
file_get_contents($google_ping);
log_msg("INFO", "Google Merchant ping sent.");
echo "Feed updated, uploaded to Torob, and Google notified.";
?>
connect_error){
die("Connection failed: " . $conn->connect_error);
}
$conn->set_charset("utf8");
// ------------------ گرفتن محصولات ------------------
$sql = "SELECT * FROM products WHERE status=1";
$result = $conn->query($sql);
// ------------------ ایجاد فید شبانه ------------------
$file = fopen("torob-feed-power.php","w"); // بازنویسی فایل اصلی
fwrite($file, "';\n");
fwrite($file, "echo '
🎁 کد تخفیف ویژه اولین خرید: naniwa | ارسال سریع به سراسر کشور 🚀.




19,000,000 5%