本文整理汇总了PHP中XMLsave函数的典型用法代码示例。如果您正苦于以下问题:PHP XMLsave函数的具体用法?PHP XMLsave怎么用?PHP XMLsave使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了XMLsave函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: i18n_gallery_save
function i18n_gallery_save($gallery, $oldname)
{
if ($oldname) {
if (!copy(GSDATAPATH . I18N_GALLERY_DIR . $oldname . '.xml', GSBACKUPSPATH . I18N_GALLERY_DIR . $oldname . '.xml')) {
return false;
}
}
$data = @new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><gallery></gallery>');
foreach ($gallery as $key => $value) {
if ($key != 'items' && $key != 'item') {
$data->addChild($key)->addCData(stripslashes($value));
}
}
foreach ($gallery['items'] as $item) {
$node = $data->addChild('item');
foreach ($item as $key => $value) {
$node->addChild($key)->addCData(stripslashes($value));
}
list($width, $height) = @getimagesize(GSDATAUPLOADPATH . $item['filename']);
$node->addChild('width', $width);
$node->addChild('height', $height);
$ss = @stat(GSDATAUPLOADPATH . $item['filename']);
$node->addChild('size', $ss['size']);
}
if (!XMLsave($data, GSDATAPATH . I18N_GALLERY_DIR . $gallery['name'] . '.xml')) {
return false;
}
if ($oldname && $oldname != $gallery['name']) {
unlink(GSDATAPATH . I18N_GALLERY_DIR . $oldname . '.xml');
}
return true;
}
示例2: items_customfields_save_them
function items_customfields_save_them()
{
if (!copy(GSDATAOTHERPATH . IM_CUSTOMFIELDS_FILE, GSBACKUPSPATH . 'other/' . IM_CUSTOMFIELDS_FILE)) {
return false;
}
$data = @new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel></channel>');
for ($i = 0; isset($_POST['cf_' . $i . '_key']); $i++) {
if ($_POST['cf_' . $i . '_key']) {
$item = $data->addChild('item');
$item->addChild('desc')->addCData(htmlspecialchars(stripslashes($_POST['cf_' . $i . '_key']), ENT_QUOTES));
$item->addChild('label')->addCData(htmlspecialchars(stripslashes($_POST['cf_' . $i . '_label']), ENT_QUOTES));
$item->addChild('type')->addCData(htmlspecialchars(stripslashes($_POST['cf_' . $i . '_type']), ENT_QUOTES));
if ($_POST['cf_' . $i . '_value']) {
$item->addChild('value')->addCData(htmlspecialchars(stripslashes($_POST['cf_' . $i . '_value']), ENT_QUOTES));
}
if ($_POST['cf_' . $i . '_options']) {
$options = preg_split("/\r?\n/", rtrim(stripslashes($_POST['cf_' . $i . '_options'])));
foreach ($options as $option) {
$item->addChild('option')->addCData(htmlspecialchars($option, ENT_QUOTES));
}
}
}
}
XMLsave($data, GSDATAOTHERPATH . IM_CUSTOMFIELDS_FILE);
return true;
}
示例3: saveSettings
private static function saveSettings()
{
$data = @new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><settings></settings>');
foreach (self::$settings as $key => $value) {
if ($value != null) {
$data->addChild($key)->addCData((string) $value);
}
}
XMLsave($data, GSDATAOTHERPATH . I18N_SETTINGS_FILE);
}
示例4: generateSitemapWithoutPing
public static function generateSitemapWithoutPing()
{
global $SITEURL;
$filenames = getFiles(GSDATAPAGESPATH);
if (count($filenames)) {
foreach ($filenames as $file) {
if (isFile($file, GSDATAPAGESPATH, 'xml')) {
$data = getXML(GSDATAPAGESPATH . $file);
if ($data->url != '404' && $data->private != 'Y') {
$pagesArray[] = array('url' => (string) $data->url, 'parent' => (string) $data->parent, 'date' => (string) $data->pubDate, 'menuStatus' => (string) $data->menuStatus);
}
}
}
}
$pagesSorted = subval_sort($pagesArray, 'menuStatus');
$languages = return_i18n_available_languages();
$deflang = return_i18n_default_language();
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
$xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
$xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
if (count($pagesSorted)) {
foreach ($pagesSorted as $page) {
// set <loc>
if (count($languages) > 1) {
$pos = strrpos($page['url'], '_');
if ($pos !== false) {
$pageLoc = find_i18n_url(substr($page['url'], 0, $pos), $page['parent'], substr($page['url'], $pos + 1));
} else {
$pageLoc = find_i18n_url($page['url'], $page['parent'], $deflang);
}
} else {
$pageLoc = find_i18n_url($page['url'], $page['parent']);
}
// set <lastmod>
$pageLastMod = makeIso8601TimeStamp(date("Y-m-d H:i:s", strtotime($page['date'])));
// set <changefreq>
$pageChangeFreq = 'weekly';
// set <priority>
$pagePriority = $page['menuStatus'] == 'Y' ? '1.0' : '0.5';
//add to sitemap
$url_item = $xml->addChild('url');
$url_item->addChild('loc', htmlspecialchars($pageLoc));
$url_item->addChild('lastmod', $pageLastMod);
$url_item->addChild('changefreq', $pageChangeFreq);
$url_item->addChild('priority', $pagePriority);
}
}
//create xml file
$file = GSROOTPATH . 'sitemap.xml';
XMLsave($xml, $file);
}
示例5: i18n_gallery_settings_save
function i18n_gallery_settings_save($settings)
{
if (file_exists(GSDATAOTHERPATH . 'i18n_gallery_settings.xml')) {
if (!copy(GSDATAOTHERPATH . 'i18n_gallery_settings.xml', GSBACKUPSPATH . 'i18n_gallery_settings.xml')) {
return false;
}
}
$data = @new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><settings></settings>');
foreach ($settings as $key => $value) {
$data->addChild($key)->addCData(stripslashes($value));
}
if (!XMLsave($data, GSDATAOTHERPATH . 'i18n_gallery_settings.xml')) {
return false;
}
return true;
}
示例6: bm_cache_to_xml
function bm_cache_to_xml($books)
{
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel></channel>');
foreach ($books as $book) {
$item = $xml->addChild('item');
$elem = $item->addChild('slug');
$elem->addCData($book['slug']);
$elem = $item->addChild('title');
$elem->addCData($book['title']);
$elem = $item->addChild('date');
$elem->addCData($book['date']);
$elem = $item->addChild('tags');
$elem->addCData($book['tags']);
$elem = $item->addChild('private');
$elem->addCData($book['private']);
}
return @XMLsave($xml, BMBOOKCACHE);
}
示例7: nm_cache_to_xml
function nm_cache_to_xml($posts)
{
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel></channel>');
foreach ($posts as $post) {
$item = $xml->addChild('item');
$elem = $item->addChild('slug');
$elem->addCData($post['slug']);
$elem = $item->addChild('title');
$elem->addCData($post['title']);
$elem = $item->addChild('date');
$elem->addCData($post['date']);
$elem = $item->addChild('tags');
$elem->addCData($post['tags']);
$elem = $item->addChild('private');
$elem->addCData($post['private']);
$elem = $item->addChild('image');
$elem->addCData($post['image']);
if (!empty($post['author'])) {
$elem = $item->addChild('author');
$elem->addCData($post['author']);
}
}
return @XMLsave($xml, NMPOSTCACHE);
}
示例8: GSWEBSITEFILE
}
# backup old GSWEBSITEFILE (website.xml) file
$bakpath = GSBACKUPSPATH . getRelPath(GSDATAOTHERPATH, GSDATAPATH);
// backups/other/
createBak($file, $path, $bakpath);
# udpate GSWEBSITEFILE (website.xml) file with new theme
$xml = new SimpleXMLExtended('<item></item>');
$note = $xml->addChild('SITENAME');
$note->addCData($SITENAME);
$note = $xml->addChild('SITEURL');
$note->addCData($SITEURL);
$note = $xml->addChild('TEMPLATE');
$note->addCData($newTemplate);
$xml->addChild('PRETTYURLS', $PRETTYURLS);
$xml->addChild('PERMALINK', $PERMALINK);
XMLsave($xml, $path . $file);
$success = i18n_r('THEME_CHANGED');
$TEMPLATE = $newTemplate;
// set new global
}
# get available themes (only look for folders)
$themes_handle = opendir(GSTHEMESPATH) or die("Unable to open " . GSTHEMESPATH);
while ($file = readdir($themes_handle)) {
$curpath = GSTHEMESPATH . $file;
if (is_dir($curpath) && $file != "." && $file != "..") {
$sel = "";
if (file_exists($curpath . '/' . GSTEMPLATEFILE)) {
if ($TEMPLATE == $file) {
$sel = "selected";
}
$theme_options .= '<option ' . $sel . ' value="' . $file . '" >' . $file . '</option>';
示例9: while
$newfile = GSDATAPAGESPATH . $_GET['id'] . "-" . $count . ".xml";
if (file_exists($newfile)) {
while (file_exists($newfile)) {
$count++;
$newfile = GSDATAPAGESPATH . $_GET['id'] . "-" . $count . ".xml";
}
}
$newurl = $_GET['id'] . '-' . $count;
# do the copy
$status = copy($path . $_GET['id'] . '.xml', $path . $newurl . '.xml');
if ($status) {
$newxml = getXML($path . $newurl . '.xml');
$newxml->url = $newurl;
$newxml->title = $newxml->title . ' [' . i18n_r('COPY') . ']';
$newxml->pubDate = date('r');
$status = XMLsave($newxml, $path . $newurl . '.xml');
if ($status) {
create_pagesxml('true');
header('Location: pages.php?upd=clone-success&id=' . $newurl);
} else {
$error = sprintf(i18n_r('CLONE_ERROR'), $_GET['id']);
header('Location: pages.php?error=' . $error);
}
} else {
$error = sprintf(i18n_r('CLONE_ERROR'), $_GET['id']);
header('Location: pages.php?error=' . $error);
}
}
getPagesXmlValues();
$count = 0;
foreach ($pagesArray as $page) {
示例10: exec_action
$pagePriority = '1.0';
} else {
$pagePriority = '0.5';
}
//add to sitemap
$url_item = $xml->addChild('url');
$url_item->addChild('loc', $pageLoc);
$url_item->addChild('lastmod', $pageLastMod);
$url_item->addChild('changefreq', $pageChangeFreq);
$url_item->addChild('priority', $pagePriority);
exec_action('sitemap-additem');
}
//create xml file
$file = $relative . 'sitemap.xml';
exec_action('save-sitemap');
XMLsave($xml, $file);
}
}
// Variables for website
$spath = $relative . 'data/other/';
$sfile = "website.xml";
$data = getXML($spath . $sfile);
$SITEURL = $data->SITEURL;
if (!defined('GSDONOTPING')) {
if (file_exists($relative . 'sitemap.xml')) {
if (200 === ($status = pingGoogleSitemaps($SITEURL . 'sitemap.xml'))) {
$response = $i18n['SITEMAP_CREATED'];
header('location: theme.php?success=' . $response);
exit;
} else {
$response = $i18n['SITEMAP_ERRORPING'];
示例11: i18n_navigation_structure_save
function i18n_navigation_structure_save(&$pages)
{
$stack = array();
for ($i = 0; isset($_POST['page_' . $i . '_url']); $i++) {
$url = $_POST['page_' . $i . '_url'];
if (isset($pages[$url])) {
$level = (int) $_POST['page_' . $i . '_level'];
if ($level > count($stack)) {
$level = count($stack);
}
$parent = $level <= 0 ? '' : $stack[$level - 1];
$menuOrder = count($stack) <= $level ? 0 : $pages[$stack[$level]]['menuOrder'] + 1;
$menu = htmlentities($_POST['page_' . $i . '_menu'], ENT_QUOTES, 'UTF-8');
$menuStatus = $_POST['page_' . $i . '_menuStatus'];
$private = $_POST['page_' . $i . '_private'];
if ($menu == $pages[$url]['title']) {
$menu = '';
}
if ($parent != $pages[$url]['parent'] || $menuOrder != $pages[$url]['menuOrder'] || $menu != $pages[$url]['menu'] || $menuStatus != $pages[$url]['menuStatus'] || $private != $pages[$url]['private']) {
// update pages array
$pages[$url]['parent'] = $parent;
$pages[$url]['menuOrder'] = $menuOrder;
$pages[$url]['menu'] = $menu;
$pages[$url]['menuStatus'] = $menuStatus;
$pages[$url]['private'] = $private;
// backup page file
if (!copy(GSDATAPAGESPATH . $url . '.xml', GSBACKUPSPATH . 'i18n_navigation/' . $url . '.xml')) {
return false;
}
// update page file
$data = getXML(GSDATAPAGESPATH . $url . '.xml');
$xml = @new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><item></item>');
$xml->addChild('pubDate', (string) $data->pubDate);
if (@$data->creDate) {
$xml->addChild('creDate', (string) $data->creDate);
}
foreach ($data->children() as $child) {
$name = $child->getName();
if ($name != 'parent' && $name != 'menuOrder' && $name != 'menu' && $name != 'menuStatus' && $name != 'private' && $name != 'pubDate' && $name != 'creDate') {
$xml->addChild($name)->addCData((string) $child);
}
}
$xml->addChild('parent')->addCData((string) $parent);
$xml->addChild('menuOrder')->addCData((string) $menuOrder);
$xml->addChild('menu')->addCData((string) $menu);
$xml->addChild('menuStatus')->addCData((string) $menuStatus);
$xml->addChild('private')->addCData((string) $private);
XMLsave($xml, GSDATAPAGESPATH . $url . '.xml');
}
// variants
if (count($pages[$url]['variants']) > 0) {
foreach ($pages[$url]['variants'] as $lang => &$variant) {
if (isset($_POST['page_' . $i . '_menu' . $lang])) {
$menu = htmlentities($_POST['page_' . $i . '_menu' . $lang], ENT_QUOTES, 'UTF-8');
if ($menu == $variant['title']) {
$menu = '';
}
if ($menu != $variant['menu'] || $private != $variant['private']) {
$variant['menu'] = $menu;
// backup variant file
if (!copy(GSDATAPAGESPATH . $variant['url'] . '.xml', GSBACKUPSPATH . 'i18n_navigation/' . $variant['url'] . '.xml')) {
return false;
}
// update variant file
$data = getXML(GSDATAPAGESPATH . $variant['url'] . '.xml');
$xml = @new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><item></item>');
$xml->addChild('pubDate', (string) $data->pubDate);
if (@$data->creDate) {
$xml->addChild('creDate', (string) $data->creDate);
}
foreach ($data->children() as $child) {
$name = $child->getName();
if ($name != 'menu' && $name != 'menuStatus' && $name != 'private' && $name != 'pubDate' && $name != 'creDate') {
$xml->addChild($name)->addCData((string) $child);
}
}
$xml->addChild('menu')->addCData((string) $menu);
$xml->addChild('menuStatus')->addCData((string) $menuStatus);
$xml->addChild('private')->addCData((string) $private);
XMLsave($xml, GSDATAPAGESPATH . $variant['url'] . '.xml');
}
}
}
}
while (count($stack) > $level) {
array_pop($stack);
}
array_push($stack, $url);
}
}
exec_action('menu-aftersave');
return true;
}
示例12: nm_save_post
function nm_save_post()
{
# create a backup if necessary
if (isset($_POST['current-slug'])) {
$file = $_POST['current-slug'] . '.xml';
if (dirname(realpath(NMPOSTPATH . $file)) != realpath(NMPOSTPATH)) {
die('');
}
// path traversal
@nm_rename_file(NMPOSTPATH . $file, NMBACKUPPATH . $file);
}
# empty titles are not allowed
if (empty($_POST['post-title']) || trim($_POST['post-title']) == '') {
$_POST['post-title'] = '[No Title]';
}
# set initial slug and filename
if (!empty($_POST['post-slug'])) {
$slug = nm_create_slug($_POST['post-slug']);
} else {
$slug = nm_create_slug($_POST['post-title']);
if ($slug == '') {
$slug = 'post';
}
}
$file = NMPOSTPATH . $slug . '.xml';
# do not overwrite other posts
if (file_exists($file)) {
$count = 1;
$file = NMPOSTPATH . $slug . '-' . $count . '.xml';
while (file_exists($file)) {
$file = NMPOSTPATH . $slug . '-' . ++$count . '.xml';
}
$slug = basename($file, '.xml');
}
# create undo target if there's a backup available
if (isset($_POST['current-slug'])) {
$backup = $slug . ':' . $_POST['current-slug'];
}
# collect $_POST data
$title = safe_slash_html($_POST['post-title']);
$timestamp = strtotime($_POST['post-date'] . ' ' . $_POST['post-time']);
$date = $timestamp ? date('r', $timestamp) : date('r');
$tags = nm_lowercase_tags(trim(preg_replace(array('/\\s+/', '/\\s*,\\s*/', '/,+/'), array(' ', ',', ','), safe_slash_html(trim($_POST['post-tags']))), ','));
$private = isset($_POST['post-private']) ? 'Y' : '';
$image = safe_slash_html($_POST['post-image']);
$content = safe_slash_html($_POST['post-content']);
if (defined('NMSAVEAUTHOR') && NMSAVEAUTHOR) {
if (isset($_POST['author'])) {
$author = safe_slash_html($_POST['author']);
} else {
global $USR;
$author = $USR ? $USR : '';
}
}
# create xml object
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><item></item>');
$obj = $xml->addChild('title');
$obj->addCData($title);
$obj = $xml->addChild('date');
$obj->addCData($date);
$obj = $xml->addChild('tags');
$obj->addCData($tags);
$obj = $xml->addChild('private');
$obj->addCData($private);
$obj = $xml->addChild('image');
$obj->addCData($image);
$obj = $xml->addChild('content');
$obj->addCData($content);
if (isset($author)) {
$obj = $xml->addChild('author');
$obj->addCData($author);
}
# write data to file
if (@XMLsave($xml, $file) && nm_update_cache()) {
nm_generate_sitemap();
nm_display_message(i18n_r('news_manager/SUCCESS_SAVE'), false, @$backup);
} else {
nm_display_message(i18n_r('news_manager/ERROR_SAVE'), true);
}
}
示例13: generate_sitemap
/**
* Creates Sitemap
*
* Creates sitemap.xml in the site's root.
* Pending: read the content path (xml's)
*/
function generate_sitemap()
{
// Variable settings
global $SITEURL;
$path = GSDATAPAGESPATH;
$count = "0";
$filenames = getFiles($path);
if (count($filenames) != 0) {
foreach ($filenames as $file) {
if (isFile($file, $path, 'xml')) {
$data = getXML($path . $file);
if ($data->url != '404') {
$status = $data->menuStatus;
$pagesArray[$count]['url'] = $data->url;
$pagesArray[$count]['parent'] = $data->parent;
$pagesArray[$count]['date'] = $data->pubDate;
$pagesArray[$count]['private'] = $data->private;
$pagesArray[$count]['menuStatus'] = $data->menuStatus;
$count++;
}
}
}
}
$pagesSorted = subval_sort($pagesArray, 'menuStatus');
if (count($pagesSorted) != 0) {
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
$xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
$xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
foreach ($pagesSorted as $page) {
if ($page['private'] != 'Y') {
// set <loc>
$pageLoc = find_url($page['url'], $page['parent']);
// set <lastmod>
$tmpDate = date("Y-m-d H:i:s", strtotime($page['date']));
$pageLastMod = makeIso8601TimeStamp($tmpDate);
// set <changefreq>
$pageChangeFreq = 'weekly';
// set <priority>
if ($page['menuStatus'] == 'Y') {
$pagePriority = '1.0';
} else {
$pagePriority = '0.5';
}
//add to sitemap
$url_item = $xml->addChild('url');
$url_item->addChild('loc', $pageLoc);
$url_item->addChild('lastmod', $pageLastMod);
$url_item->addChild('changefreq', $pageChangeFreq);
$url_item->addChild('priority', $pagePriority);
exec_action('sitemap-additem');
}
}
//create xml file
$file = GSROOTPATH . 'sitemap.xml';
exec_action('save-sitemap');
XMLsave($xml, $file);
}
if (!defined('GSDONOTPING')) {
if (file_exists(GSROOTPATH . 'sitemap.xml')) {
if (200 === ($status = pingGoogleSitemaps($SITEURL . 'sitemap.xml'))) {
#sitemap successfully created & pinged
return true;
} else {
error_log(i18n_r('SITEMAP_ERRORPING'));
return i18n_r('SITEMAP_ERRORPING');
}
} else {
error_log(i18n_r('SITEMAP_ERROR'));
return i18n_r('SITEMAP_ERROR');
}
} else {
#sitemap successfully created - did not ping
return true;
}
}
示例14: exec_action
$note->addCData($menuStatus);
$note = $xml->addChild('template');
$note->addCData($template);
$note = $xml->addChild('parent');
$note->addCData($parent);
$note = $xml->addChild('content');
$note->addCData($content);
$note = $xml->addChild('private');
$note->addCData($private);
$note = $xml->addChild('author');
$note->addCData($author);
exec_action('changedata-save');
if (isset($_POST['autosave']) && $_POST['autosave'] == 'true' && $autoSaveDraft == true) {
$status = XMLsave($xml, GSAUTOSAVEPATH . $url);
} else {
$status = XMLsave($xml, $file);
}
//ending actions
exec_action('changedata-aftersave');
generate_sitemap();
// redirect user back to edit page
if (isset($_POST['autosave']) && $_POST['autosave'] == 'true') {
echo $status ? 'OK' : 'ERROR';
} else {
if (!$status) {
redirect("edit.php?id=" . $url . "&upd=edit-error&type=edit");
}
if ($_POST['redirectto'] != '') {
$redirect_url = $_POST['redirectto'];
} else {
$redirect_url = 'edit.php';
示例15: create_pluginsxml
/**
* create_pluginsxml
*
* If the plugins.xml file does not exists, read in each plugin
* and add it to the file.
* read_pluginsxml() is called again to repopulate $live_plugins
*
* @since 2.04
* @uses $live_plugins
*
*/
function create_pluginsxml()
{
global $live_plugins;
if (file_exists(GSPLUGINPATH)) {
$pluginfiles = getFiles(GSPLUGINPATH);
}
$xml = @new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel></channel>');
foreach ($pluginfiles as $fi) {
$pathExt = pathinfo($fi, PATHINFO_EXTENSION);
$pathName = pathinfo_filename($fi);
$count = 0;
if ($pathExt == "php") {
$components = $xml->addChild('item');
$c_note = $components->addChild('plugin');
$c_note->addCData($fi);
$c_note = $components->addChild('enabled');
if (isset($live_plugins[(string) $fi])) {
$c_note->addCData($live_plugins[(string) $fi]);
} else {
$c_note->addCData('true');
}
}
}
XMLsave($xml, GSDATAOTHERPATH . "plugins.xml");
read_pluginsxml();
}