- Add Sitemap support,

- Add Sitemap button.
This commit is contained in:
agibert 2013-08-27 16:36:46 +00:00
parent 79bfba676b
commit e883a64bd7

View File

@ -1,13 +1,13 @@
<?
// $RCSfile: lmbrowse.php,v $
// $Revision: 1.7 $
// $Revision: 1.8 $
// $Name: $
// $Date: 2013/08/20 16:32:00 $
// $Date: 2013/08/27 16:36:46 $
// $Author: agibert $
/*
* LMBrowse - Langueur Monotone Browser
* Copyright (C) 2012 Arnaud G. GIBERT
* Copyright (C) 2012-2013 Arnaud G. GIBERT
* mailto:arnaud@rx3.net
* http://www.rx3.org/dvp/lmbrowse
*
@ -847,6 +847,8 @@ function lmb_footer()
<td style=\"width: 8px;\">&nbsp;&nbsp;&nbsp;</td>
<td class=\"button-item\" style=\"width: 32px;\"><a class=\"button-stats\" href=\"https://www.google.com/webmasters/tools/dashboard?hl=fr&amp;siteUrl=http%3A%2F%2Fwww.langueur-monotone.com%2F\" title=\"Google Webmaster Tools\"></a></td>
<td style=\"width: 8px;\">&nbsp;&nbsp;&nbsp;</td>
<td class=\"button-item\" style=\"width: 32px;\"><a rel=\"nofollow\" class=\"button-rss\" href=\"http://www.langueur-monotone.com/?page=sitemap\" title=\"SiteMap\"></a></td>
<td style=\"width: 8px;\">&nbsp;&nbsp;&nbsp;</td>
<td class=\"button-item\" style=\"width: 32px;\">
<form action=\"{$lmb_url}\" method=\"post\">
<div>
@ -990,67 +992,6 @@ function lmb_news_tab_get( )
/*--------------------------------------------------------------------------------------------------------------------*/
/* News Tab */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_news_tab_old( )
{
global $lmb_url;
$news_file = "news.txt";
$line = array();
$cmd = "sed -e 's/\t*\t/\t/g' ${news_file}";
exec( $cmd, $line);
ob_start();
for( $i = 0; $i < count($line); $i++)
{
$tab = explode( "\t", $line[$i]);
$css_row = ( $i + 1) % 2 + 1;
if( count($tab) > 2)
{
$play_name = $tab[2];
$play_type = $tab[3];
$play_id = $tab[4];
$play_priority = $tab[5];
$link_tag = "<a href=\"{$lmb_url}?page=play&amp;type={$play_type}&amp;id={$play_id}&amp;priority={$play_priority}\">";
$img_tag = "<img src=\"/discography/{$play_type}/{$play_priority}-{$play_id}/covers/{$play_id}-cover-1-icon.png\" alt=\"\"/>";
$height = 110;
$play_tag=" <td class=\"news3\">{$link_tag}{$play_name}</a></td>
<td class=\"news4\" style=\"height: {$height}px\">{$link_tag}{$img_tag}</a></td>";
$colspan_tag = "";
}
else
{
$play_tag = "";
$cover_tag = "";
$colspan_tag = "colspan=\"3\"";
}
echo " <tr class=\"news{$css_row}\">
<td class=\"news01\"></td>
<td class=\"news1\">{$tab[0]}</td>
<td class=\"news2\" {$colspan_tag}>".lmb_html_text_format( "{$tab[1]}")."</td>
{$play_tag} <td class=\"news01\"></td>
</tr>
";
}
$data = ob_get_contents();
ob_end_clean();
lmb_make_tab( "news", "news", "r", "/images/lm-logo5-n-220.png", $data);
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* News Tab */
/*--------------------------------------------------------------------------------------------------------------------*/
@ -1141,12 +1082,220 @@ function lmb_main_page()
/*--------------------------------------------------------------------------------------------------------------------*/
/* SiteMap Item */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_sitemap_item( $item_type, $page_url, $img_tab)
{
global $lmb_url;
echo " <url>
";
echo " <loc>http://www.langueur-monotone.com{$lmb_url}${page_url}</loc>
<lastmod>2013-08-20</lastmod>
<changefreq>weekly</changefreq>
<priority>0.5</priority>
";
if( isset( $img_tab))
{
foreach( $img_tab as $img)
{
echo " <image:image>
<image:loc>http://www.langueur-monotone.com/{$img["url"]}</image:loc>
<image:title>{$img["title"]}</image:title>
</image:image>
";
}
}
echo " </url>
";
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* SiteMap Track */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_sitemap_track( $play_type, $play_id, $play_priority, $track_id)
{
$play_path = "discography/{$play_type}/{$play_priority}-{$play_id}";
$url = "?page=track&amp;type={$play_type}&amp;id={$play_id}&amp;priority={$play_priority}&amp;tid={$track_id}";
$img_tab = array();
$size = 1024;
lmb_sitemap_item( "track", "{$url}", $img_tab);
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* SiteMap Play */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_sitemap_play( $play_type, $play_id, $play_priority)
{
$play_path = "discography/{$play_type}/{$play_priority}-{$play_id}";
$cover_path = "{$play_path}/covers";
$extra_path = "{$play_path}/extras";
$play_info = lmb_play_info_get( $play_type, $play_id, $play_priority);
$url = "?page=play&amp;type={$play_type}&amp;id={$play_id}&amp;priority={$play_priority}";
$img_tab = array();
$img_idx = 0;
$play_title = lmb_play_title_get( $play_type, $play_id, $play_priority);
$img_tab[$img_idx ]["url"] = "{$play_path}/logos/{$play_id}-logo-1-128.png";
$img_tab[$img_idx++]["title"] = "Langueur Monotone - {$play_title} - Logo 1";
$img_tab[$img_idx ]["url"] = "{$play_path}/logos/{$play_id}-logo-2-128.png";
$img_tab[$img_idx++]["title"] = "Langueur Monotone - {$play_title} - Logo 2";
/* Cover Dump */
$cmd = "ls {$cover_path}/{$play_id}-cover-*.png | sed -e 's/.*{$play_id}-//' | grep -v icon.png | sort ";
exec( $cmd, $cover_tab);
for( $i = 0, $j = 1; $i < count($cover_tab); $i++, $j++)
{
$cover_info_tab = explode( "-", $cover_tab[$i]);
$nb = $cover_info_tab[1];
$size = str_replace( ".png", "", $cover_info_tab[2]);
$img_tab[$img_idx ]["url"] = "{$cover_path}/{$play_id}-cover-{$cover_tab[$i]}";
$img_tab[$img_idx++]["title"] = "Langueur Monotone - {$play_title} - Cover {$nb} ({$size})";
}
/* Extra Dump */
if( ! file_exists( "{$extra_path}/.hide" ))
{
$cmd = "ls {$extra_path}/{$play_id}-*.png | sed -e 's/.*{$play_id}-//' | grep -v icon.png | sort ";
exec($cmd, $extra_tab);
for( $i = 0, $j = 1; $i < count($extra_tab); $i++, $j++)
{
$extra_info_tab = explode( "-", $extra_tab[$i]);
$type = ucfirst( $extra_info_tab[0]);
$nb = $extra_info_tab[1];
$format = str_replace( "_", "/", $extra_info_tab[2]);
$size = str_replace( ".png", "", $extra_info_tab[3]);
$img_tab[$img_idx ]["url"] = "{$extra_path}/{$play_id}-{$extra_tab[$i]}";
$img_tab[$img_idx++]["title"] = "Langueur Monotone - {$play_title} - Extra - {$type} {$nb} ({$format}-{$size})";
}
}
lmb_sitemap_item( "play", "{$url}", $img_tab);
$track_list_info = lmb_tracklist_info_get( $play_type, $play_id, $play_priority);
foreach( $track_list_info as $track_info)
{
lmb_sitemap_track( $play_type, $play_id, $play_priority, str_pad( "{$track_info["id"]}", 2, '0', STR_PAD_LEFT));
}
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* SiteMap Play Type */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_sitemap_play_type( $play_type)
{
$path = "discography/{$play_type}";
$line = array();
$cmd = "ls -d {$path}/??-* | sed -e 's/.*\///'";
exec($cmd, $line);
for( $i = 0; $i < count($line); $i++)
{
$play_tab = explode( "-", $line[$i]);
$play_priority = $play_tab[0];
$play_id = $play_tab[1];
if( ! file_exists( "{$path}/{$play_priority}-{$play_id}/.hide" ))
{
lmb_sitemap_play( $play_type, $play_id, $play_priority);
}
}
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* SiteMap Page */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_sitemap_page()
{
global $lmb_myname;
global $lmb_myver;
global $time_start;
header( 'Content-Type: application/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\">
";
$img_tab = array();
$size = 220;
$img_tab[0]["url"] = "{$play_path}/images/lm-logo5-n-{$size}.png";
$img_tab[0]["title"] = "Langueur Monotone - Logo 5 ({$size})";
lmb_sitemap_item( "top", "", $img_tab);
// $img_tab = array();
// lmb_sitemap_item( "page", "?page=rss", $img_tab);
$img_tab = array();
$size = 220;
$img_tab[0]["url"] = "{$play_path}/images/lm-logo6-n-{$size}.png";
$img_tab[0]["title"] = "Langueur Monotone - Logo 6 ({$size})";
lmb_sitemap_item( "page", "?page=about", $img_tab);
$img_tab = array();
lmb_sitemap_item( "page", "?page=discography", $img_tab);
lmb_sitemap_play_type( "ep", $img_tab);
lmb_sitemap_play_type( "lp", $img_tab);
lmb_sitemap_play_type( "oldies", $img_tab);
$time_stop = microtime_float();
$time_elaps = intval( ( $time_stop - $time_start) * 1000) / 1000;
echo "</urlset>
<!-- Page generated in $time_elaps seconds by {$lmb_myname} (http://www.rx3.org/dvp/?dvp=".strtolower($lmb_myname).") V {$lmb_myver} -->
";
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* RSS Page */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_rss_page()
{
global $lmb_myname;
global $lmb_myver;
global $time_start;
header( 'Content-Type: application/rss+xml');
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>
@ -1213,6 +1362,12 @@ xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
echo "</channel>
</rss>
";
$time_stop = microtime_float();
$time_elaps = intval( ( $time_stop - $time_start) * 1000) / 1000;
echo "<!-- Page generated in $time_elaps seconds by {$lmb_myname} (http://www.rx3.org/dvp/?dvp=".strtolower($lmb_myname).") V {$lmb_myver} -->
";
}
@ -1661,6 +1816,7 @@ function lmb_track_info_get( $play_type, $play_id, $play_priority, $track_id)
/*--------------------------------------------------------------------------------------------------------------------*/
/* Track File Tag Get */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_track_file_tag_get( $play_type, $play_id, $play_priority, $track_id)
{
global $lmb_url;
@ -2495,25 +2651,23 @@ function lmb_play_type_name_get( $play_type_id)
function lmb_play_name_get( $play_type, $play_id, $play_priority)
{
$file = "discography/{$play_type}/{$play_priotiry}-{}-*";
$play_info = lmb_play_info_get( $play_type, $play_id, $play_priority);
switch( "{$play_type_id}")
{
case "ep":
{
return( "EP");
return( "{$play_info["name"]}");
}
case "lp":
{
return( "LP");
}
case "oldies":
/*--------------------------------------------------------------------------------------------------------------------*/
/* Play Title Get */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_play_title_get( $play_type, $play_id, $play_priority)
{
return( "Oldies");
}
}
$play_name = lmb_play_name_get( $play_type, $play_id, $play_priority);
$play_type_name = lmb_play_type_name_get( $play_type);
return( "{$play_name} - {$play_type_name}");
}
@ -2528,10 +2682,17 @@ function lmb_play_page( $play_type, $play_id, $play_priority)
$play_info = lmb_play_info_get( $play_type, $play_id, $play_priority);
/*
$play_name = lmb_play_type_name_get( $play_type);
$play_title = "{$play_info["name"]} - {$play_name}";
*/
$play_title = lmb_play_title_get( $play_type, $play_id, $play_priority);
$play_image = "{$play_type}";
// lmb_header( 3, "Langueur Monotone - {$play_title} Page", "/images/title-{$play_image}.png", "{$play_name}", "Langueur Monotone play page, giving all the information about {$play_info["name"]} {$play_name}", "{$play_type},{$play_info["name"]}", 0);
lmb_header( 3, "Langueur Monotone - {$play_title} Page", "/images/title-{$play_image}.png", "{$play_title}", "Langueur Monotone play page, giving all the information about {$play_info["name"]} {$play_name}", "{$play_type},{$play_info["name"]}", 0);
lmb_play_body( $play_type, $play_id, $play_priority);
@ -3525,6 +3686,12 @@ function lmb_get_proceed( $get_array)
switch ($page_id)
{
case "sitemap":
{
lmb_sitemap_page( );
break;
}
case "rss":
{
lmb_rss_page( );