步骤 二
在根目录下新建一个名为“setup.php”的文件,再新建一个名为“sitemaps”的文件夹。
以下是“setup.php”文件的内容:
<?php require('common/incfiles/common.inc.php'); require('common/incfiles/config.inc.php'); require('common/incfiles/module_config.inc.php'); $mod = ii_get_safecode($_GET["mod"]); if ($mod !="article" and $mod !="shop" and $mod !="product" and $mod !="download") { // 允许的模块 echo "<form name='form' method='get' action='?'>"; // 按扭设置 echo "<input name='mod' type='radio' value='article'>Article"; echo "<input name='mod' type='radio' value='shop'>Shop"; echo "<input name='mod' type='radio' value='product'>Product"; echo "<input name='mod' type='radio' value='download'>Download"; echo "<input type='submit' value=' 生成 Sitemap '>"; echo "</form>"; } else{ switch ($mod): case article: $content = vv_itransfer('top', 'sitemap', 'topx=10000;genre=article'); // 处理表单 break; case shop: $content = vv_itransfer('top', 'sitemap', 'topx=10000;genre=shop'); break; case afflatus: $content = vv_itransfer('top', 'sitemap', 'topx=10000;genre=product'); break; default: $content = vv_itransfer('top', 'sitemap', 'topx=10000;genre=download'); endswitch; $folder = "sitemaps/google_sitemap_"; // 文件的路径和前缀 $ftype = ".html"; // 文件的扩展名 $path = $folder . $mod . $ftype; if (!file_exists($path)) { fopen($path,"w"); } $handle = fopen($path,"w"); fwrite($handle,$content); fclose($handle); echo "<form name='form' method='get' action='?'>"; // 按扭设置 echo "<input name='mod' type='radio' value='article'>Article"; echo "<input name='mod' type='radio' value='shop'>Shop"; echo "<input name='mod' type='radio' value='product'>Product"; echo "<input name='mod' type='radio' value='download'>Download"; echo "<input type='submit' value=' 生成 Sitemap '>"; echo "</form>"; echo "文件生成成功,点击查看!"; echo "<a href='$path' target=_blank>../$path</a>"; } ?>
OK!直接访问 setup.php 就可以了!
提示:这种只能生成各模块的网站地图,主要栏目的还需要单独建一个sitemap手工添加。
|