Selam arkadaşlar
Birçok program ile sitemap oluşturabiliyoruz. Ancak ben siteme dinamik sitemap eklemek istiyorum. Yani php ile veritabanındaki verileri alıp sitemap oluşturabilen, veritabanına veri girildikçe kendini güncelleyen veya belli aralıklarla kendini güncelleyen bir dinamik sitemap nasıl oluşturulur.
Uzman arkadaşlarımızdan yardım bekliyorum
Teşekkürler
PHP - Dinamik Sitemap Oluşturma - Yardım -
6
●4.423
- 01-05-2009, 11:47:18Buyur yardımcı olur.
Büyük siteler için php ile google sitemap yapımı | kodaman.org - 06-05-2009, 13:24:13index sayfandaki sorgu kodlarını gönderirmisin ? Ordan yola çıkarak bilgiLendirme yapaLım.
mrsilver adlı üyeden alıntı: mesajı görüntüle - 10-05-2009, 00:43:37Üyeliği durduruldubende bu php ile sitemap yapmak istiyorum.arkadaşın verdiği sitedeki kodları ekliyorum ancak karışık biraz bunu bize anlayacağımız şekilde açıklarmısınız lütfen.
<? // Önce mysql bağlantı bilgilerini içeren php dosyamızı include ediyoruz $mysqlhost="localhost"; $mysqluser="makaleler"; $mysqlpass="12345"; $mysqldatabase="makaleler"; if(! $baglanti=@mysql_connect($mysqlhost, $mysqluser, $mysqlpass)) die("veritabani baglantisi yok."); mysql_select_db($mysqldatabase); // İkinci olarak sayfa output'unun hangi formatta olduğunu belirten header komutunu gönderiyoruz. Sayfamız xml formatında olacaktır. header("Content-Type: text/xml"); // Get metoduyla aldığımız sayfa verisini $sayfa isimli değişkene atıyoruz. if(! isset($_GET[sayfa])) $sayfa=1; else $sayfa=$_GET[sayfa]; //Tarihi belirtiyoruz. Burada format önemli. Format dışına çıkılmamalı. Eğer veritabanınızda her makalenin giriş tarihi varsa dinamik olarak onu da ekleyebilirsiniz. Burada sabit bir gün kullandım. $date="2008-10-21"; // Eğer sayfa değişkeni "index" değeri aldıysa output olarak sitemap-index verilecek. if($sayfa=="index"): // İlk olarak bütün makale sayısını alıyoruz. $index_sayi=mysql_num_rows(mysql_query("SELECT `id` FROM `makaleler`")); // İkinci olarak kaç adet index'te kaç adet sitemap listeleneceğini bulmak için, toplam rakamı sitemap başı url sayısına bölüyoruz. Ben genelde veritabanını yormamak ve hızlı yüklenme için 6000 kullanırım. $index_sayi=ceil($index_sayi / 6000); //Google sitemap-index header'larını giriyoruz. Encoding'i dileğinize göre değiştirebilirsiniz. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n"; // Ana etiketleri girdikten sonra sitemap'ları döngü ile listeliyoruz. for($i=0; $i<$index_sayi; $i++){ echo "<sitemap> <loc>http://www.butunmakaleler.com/sitemap.php?sayfa=".($i+1)."</loc> <lastmod>$date</lastmod> </sitemap>\n"; } // Son olarak sitemap-index sonlandırma etiketini girip index'i bitiriyoruz. echo "</sitemapindex>"; // Eğer GET ile aldığımız sayfa değişkeni numerik ise bu kodlar çalışacak. else: // Sayfa numarasına göre 6000'lik veri alınıyor. $sorgu=mysql_query("SELECT `id` FROM `makaleler` ORDER BY `id` ASC LIMIT ".(($sayfa-1)*6000).",6000"); // Sitemap ana xml etiketleri giriliyor. echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> <urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd\">\n"; // Alınan 6000'lik parça döngü ile yazdırılıyor. while($sonuc=mysql_fetch_assoc($sorgu)): echo " <url> <loc>http://www.butunmakaleler.com/makale.php?id=".$sonuc[id]."</loc> <lastmod>$date</lastmod> <changefreq>daily</changefreq> <priority>0.5</priority> </url>\n"; endwhile; // Son olarak sitemap'ı sonlandırma etiketini yazdırıp dosyayı kapatıyoruz. echo '</urlset>'; endif; ?> - 24-05-2009, 23:41:00aynı sorun bende de var. ve benim sistemim dle club. id olarak atamadıgı için sitemap olusturulamıyor :Sexcellency adlı üyeden alıntı: mesajı görüntüle
ve index.php dosyam ise
<?php @session_start(); @ob_start(); @ob_implicit_flush(0); @error_reporting(E_ALL ^ E_NOTICE); @ini_set('display_errors', true); @ini_set('html_errors', false); @ini_set('error_reporting', E_ALL ^ E_NOTICE); define('DATALIFEENGINE', true); $member_id = FALSE; $is_logged = FALSE; define('ROOT_DIR', dirname (__FILE__)); define('ENGINE_DIR', ROOT_DIR.'/engine'); require_once ROOT_DIR.'/engine/init.php'; require_once ROOT_DIR.'/engine/modules/lastnews.php'; // Added by Last Comments v.2.0 - Start require_once ROOT_DIR.'/engine/modules/lastcommentsb.php'; // Added by Last Comments v.2.0 - End $tpl->load_template('main.tpl'); $tpl->set('{lastnews}',$lastnews); $tpl->set('{calendar}', $tpl->result['calendar']); $tpl->set('{archives}', $tpl->result['archive']); $tpl->set('{tags}', $tpl->result['tags_cloud']); $tpl->set('{tags_all_view}', $tpl->result['tags_all_view']); $tpl->set('{vote}', $tpl->result['vote']); // Added by Last Comments v.2.0 - Start $tpl->set('{lastcommb}',$lastcommb); // Added by Last Comments v.2.0 - End $tpl->set('{topnews}',$topnews); $tpl->set('{login}',$login_panel); $tpl->set('{info}', "<span id='dle-info'>".$tpl->result['info']."</span>"); $tpl->set('{speedbar}', $tpl->result['speedbar']); if ($config['allow_skin_change'] == "yes") $tpl->set('{changeskin}', ChangeSkin (ROOT_DIR.'/templates', $config['skin'])); if (count($banners) AND $config['allow_banner']) { foreach ($banners as $name => $value) { $tpl->copy_template = str_replace("{banner_".$name."}",$value, $tpl->copy_template); } } $tpl->set_block("'{banner_(.*?)}'si",""); if (count($informers) AND $config['rss_informer']) { foreach ($informers as $name => $value) { $tpl->copy_template = str_replace("{inform_".$name."}",$value, $tpl->copy_template); }} if ($do=="" AND !$subaction AND $year) $do = "date"; elseif ($do=="" AND $catalog) $do = "catalog"; elseif ($do=="") $do = $subaction; if ($allow_active_news AND $config['allow_change_sort'] AND !$config['ajax']) { $tpl->set('[sort]', "" ); $tpl->set('{sort}', news_sort( $do ) ); $tpl->set('[/sort]', "" ); } else { $tpl->set_block("'\\[sort\\](.*?)\\[/sort\\]'si",""); } if ( strpos( $tpl->copy_template, "[aviable=" ) !== false ) { $tpl->copy_template = preg_replace( "#\\[aviable=(.+?)\\](.*?)\\[/aviable\\]#ies","check_module('\\1', '\\2', '{$do}')", $tpl->copy_template); } if ( strpos( $tpl->copy_template, "[not-aviable=" ) !== false ) { $tpl->copy_template = preg_replace( "#\\[not-aviable=(.+?)\\](.*?)\\[/not-aviable\\]#ies","check_module('\\1', '\\2', '{$do}', false)", $tpl->copy_template); } if ( strpos( $tpl->copy_template, "[not-group=" ) !== false ) { $tpl->copy_template = preg_replace( "#\\[not-group=(.+?)\\](.*?)\\[/not-group\\]#ies","check_group('\\1', '\\2', false)", $tpl->copy_template); } if ( strpos( $tpl->copy_template, "[group=" ) !== false ) { $tpl->copy_template = preg_replace( "#\\[group=(.+?)\\](.*?)\\[/group\\]#ies","check_group('\\1', '\\2')", $tpl->copy_template); } if ( strpos( $tpl->copy_template, "[category=" ) !== false ) { $tpl->copy_template = preg_replace( "#\\[category=(.+?)\\](.*?)\\[/category\\]#ies","check_category('\\1', '\\2', '{$category_id}')", $tpl->copy_template); } if ( strpos( $tpl->copy_template, "[not-category=" ) !== false ) { $tpl->copy_template = preg_replace( "#\\[not-category=(.+?)\\](.*?)\\[/not-category\\]#ies","check_category('\\1', '\\2', '{$category_id}', false)", $tpl->copy_template); } if ( strpos( $tpl->copy_template, "{custom" ) !== false ) { $tpl->copy_template = preg_replace( "#\\{custom category=['\"](.+?)['\"] template=['\"](.+?)['\"] aviable=['\"](.+?)['\"] from=['\"](.+?)['\"] limit=['\"](.+?)['\"] cache=['\"](.+?)['\"]\\}#ies", "custom_print('\\1', '\\2', '\\3', '\\4', '\\5', '\\6', '{$do}')", $tpl->copy_template ); } $config['http_home_url'] = explode("index.php", $_SERVER['PHP_SELF']); $config['http_home_url'] = reset($config['http_home_url']); if (!$user_group[$member_id['user_group']]['allow_admin']) $config['admin_path'] = ""; $ajax .= <<<HTML <script language="javascript" type="text/javascript"> <!-- var dle_root = '{$config['http_home_url']}'; var dle_admin = '{$config['admin_path']}'; var dle_login_hash = '{$dle_login_hash}'; var dle_skin = '{$config['skin']}'; var dle_wysiwyg = '{$config['allow_comments_wysiwyg']}'; var quick_wysiwyg = '{$config['allow_quick_wysiwyg']}'; var menu_short = '{$lang['menu_short']}'; var menu_full = '{$lang['menu_full']}'; var menu_profile = '{$lang['menu_profile']}'; var menu_fnews = '{$lang['menu_fnews']}'; var menu_fcomments = '{$lang['menu_fcomments']}'; var menu_send = '{$lang['menu_send']}'; var menu_uedit = '{$lang['menu_uedit']}'; var dle_req_field = '{$lang['comm_req_f']}'; var dle_del_agree = '{$lang['news_delcom']}'; var dle_del_news = '{$lang['news_delnews']}';\n HTML; if ($user_group[$member_id['user_group']]['allow_all_edit']) { $ajax .= <<<HTML var allow_dle_delete_news = true;\n HTML; } else { $ajax .= <<<HTML var dle_login_hash = ''; var allow_dle_delete_news = false;\n HTML; } $ajax .= <<<HTML //--> </script> <script type="text/javascript" src="{$config['http_home_url']}engine/ajax/menu.js"></script> <script language='javascript' type='text/javascript'> <!-- tags = new Array( 'td', 'tr', 'p', 'b', 'table', 'strong', 'em', 'a', 'h1', 'h2', 'h3', 'pre', 'sub', 'sup', 'i', 'cp', 'ul', 'ol', 'li', 'dt', 'dd', 'input' ); defaultSize = 11; resizeCounter = 0; increment = 1; //--> </script> <script language='javascript' src='{$config['http_home_url']}engine/skins/FWResizeFont.js' type='text/ javascript'></script> <script type="text/javascript" src="{$config['http_home_url']}engine/ajax/dle_ajax.js"></script> <div id="loading-layer" style="display:none;font-family: Verdana;font-size: 11px;width:200px;height:50px;background:#FFF;padding:10px;text-align:center;border:1px solid #000"><div style="font-weight:bold" id="loading-layer-text">{$lang['ajax_info']}</div><br /><img src="{$config['http_home_url']}engine/ajax/loading.gif" border="0" alt="" /></div> <div id="busy_layer" style="visibility: hidden; display: block; position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; background-color: gray; opacity: 0.1; filter: alpha(opacity=10); "></div> <script type="text/javascript" src="{$config['http_home_url']}engine/ajax/js_edit.js"></script> HTML; if ($allow_comments_ajax AND ($config['allow_comments_wysiwyg'] == "yes" OR $config['allow_quick_wysiwyg']) ) $ajax .= <<<HTML <script type="text/javascript" src="{$config['http_home_url']}engine/editor/jscripts/tiny_mce/tiny_mce_gzip.js"></script> <script type="text/javascript"> tinyMCE_GZ.init({ plugins : "safari,emotions,inlinepopups", themes : 'advanced', languages : '{$lang['wysiwyg_language']}', disk_cache : false, debug : false }); </script> HTML; if ( strpos( $tpl->result['content'], "hs.expand" ) !== false OR strpos( $tpl->copy_template, "hs.expand" ) !== false OR $config['ajax'] OR $pm_alert != "") { if ($pm_alert != "") $hs_prefix = "-html"; else $hs_prefix = ""; $ajax .= <<<HTML <script type="text/javascript" src="{$config['http_home_url']}engine/classes/highslide/highslide{$hs_prefix}.js"></script> <script type="text/javascript"> hs.graphicsDir = '{$config['http_home_url']}engine/classes/highslide/graphics/'; hs.outlineType = 'rounded-white'; hs.numberOfImagesToPreload = 0; hs.showCredits = false; hs.loadingText = '{$lang['loading']}'; hs.fullExpandTitle = '{$lang['thumb_expandtitle']}'; hs.restoreTitle = '{$lang['thumb_restore']}'; hs.focusTitle = '{$lang['thumb_focustitle']}'; hs.loadingTitle = '{$lang['thumb_cancel']}'; </script> {$pm_alert} HTML; } $tpl->set('{AJAX}', $ajax); $tpl->set('{headers}', $metatags); $tpl->set('{content}', "<div id='dle-content'>".$tpl->result['content']."</div>"); $tpl->set('{THEME}', $config['http_home_url'].'templates/'.$config['skin']); $tpl->compile('main'); echo $tpl->result['main']; $tpl->global_clear(); $db->close(); echo"\n<!--DataLife Engine Türkçe destek (http://dleclub.com)-DataLife Engine Copyright SoftNews Media Group (http://dle-news.ru) -->\r\n"; /* */ GzipOut(); ?>yardım beklemedeyim
ve siteye atıp yaptıgımda ise
Warning: Cannot modify header information - headers already sent by (output started at /home/seckin/public_html/sitemap.php:1) in /home/seckin/public_html/sitemap.php on line 11
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/seckin/public_html/sitemap.php on line 54
hatasını veriyor.