コード例 #1
0
<?php

/**
	To login into google API and refresh tokens
**/
set_include_path(get_include_path() . PATH_SEPARATOR . '../../google-api-php-client/src/Google');
include 'config.php';
require_once 'log_data_service.php';
require_once 'pov_data_service.php';
$error = '';
$logService = new LogDataService();
$ds = new PovDataService($conf['dsn'], $conf['dbname'], $conf['dbpassword'], array(PDO::ATTR_PERSISTENT => false));
$ret = $ds->getCurrentSitemap();
if (!$ret) {
    return;
}
try {
    $name = $ret['name'];
    $urls = $ret['urls'];
    $xml_header = '<?xml version="1.0" encoding="UTF-8"?>
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> ';
    $file = fopen('..\\sitemaps\\' . $name, "w") or die("Unable to open file!");
    fwrite($file, $xml_header);
    foreach ((array) $urls as $u) {
        $url = $u['url'];
        $xml = '
      <url>
        <loc>' . $url . '</loc>
      </url>';
        fwrite($file, $xml);
    }