public function Index($rows)
 {
     $xml = new SimpleXMLExtended('<?xml version="1.0" encoding="GBK"?><DOCUMENT/>');
     foreach ($rows as $keys => $values) {
         foreach ($values as $key => $value) {
             $i = -8;
             $num_item = $xml->addchild($key);
             $num_key = $num_item->addchild('key');
             $num_display = $num_item->addchild('display');
             $n = 1;
             foreach ($value as $k => $val) {
                 $n++;
                 if ($n < 3) {
                     $num_key->addCData($val);
                 } else {
                     $i++;
                     if ($i < 14) {
                         $num_display->{$k} = NULL;
                         $num_display->{$k}->addCData($val);
                         continue;
                     } elseif ($i == 14) {
                         $num_moremore = $num_display->addchild('moremore');
                         $num_moremore->{$k} = NULL;
                         $num_moremore->{$k}->addCData($val);
                     }
                     $num_moremore->{$k} = NULL;
                     $num_moremore->{$k}->addCData($val);
                 }
             }
         }
     }
     echo $xml->asXml();
 }
function items_customfields_header()
{
    if (!file_exists(GSDATAOTHERPATH . 'plugincustomfields.xml')) {
        $xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel></channel>');
        $xml->asXML(GSDATAOTHERPATH . 'plugincustomfields.xml');
        return true;
    }
    ?>
  <style type="text/css">
    form #metadata_window table.formtable td .cke_editor td:first-child { padding: 0; }
    form #metadata_window table.formtable .cke_editor td.cke_top { border-bottom: 1px solid #AAAAAA; }
    form #metadata_window table.formtable .cke_editor td.cke_contents { border: 1px solid #AAAAAA; }
    #customfieldsForm .hidden { display:none; }
    .shorts {
      width:250px !important;
    }
    .checkp {
      margin-top:17px;
    }
     .user_sub_tr {
      border:0px;border-bottom:0px !important; border-bottom-width:0px !important;border-top:0px;border-top-width:0px !important;
   }
    .user_sub_tr td{
      border:0px;border-bottom:0px !important;border-bottom-width:0px !important;padding-top:6px !important; border-top: 0px !important;
   }
      .resize_img {
    max-height:150px;
  }
    

  </style>
<?php 
}
 /**
  * build the xml structure where the content can be inserted
  *
  * @return void
  */
 private function _xmlbody()
 {
     $dom = new DOMDocument('1.0', 'UTF-8');
     $root = $dom->createElement("tns:phpsysinfo");
     $root->setAttribute('xmlns:tns', 'http://phpsysinfo.sourceforge.net/');
     $root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $root->setAttribute('xsi:schemaLocation', 'http://phpsysinfo.sourceforge.net/phpsysinfo3.xsd');
     $dom->appendChild($root);
     $this->_xml = new SimpleXMLExtended(simplexml_import_dom($dom), $this->_sysinfo->getEncoding());
     $generation = $this->_xml->addChild('Generation');
     $generation->addAttribute('version', CommonFunctions::PSI_VERSION);
     $generation->addAttribute('timestamp', time());
     $options = $this->_xml->addChild('Options');
     $options->addAttribute('tempFormat', defined('PSI_TEMP_FORMAT') ? PSI_TEMP_FORMAT : 'c');
     $options->addAttribute('byteFormat', defined('PSI_BYTE_FORMAT') ? PSI_BYTE_FORMAT : 'auto_binary');
     $options->addAttribute('refresh', defined('PSI_REFRESH') ? PSI_REFRESH : 0);
     $options->addAttribute('showPickListTemplate', defined('PSI_SHOW_PICKLIST_TEMPLATE') ? PSI_SHOW_PICKLIST_TEMPLATE ? 'true' : 'false' : 'false');
     $options->addAttribute('showPickListLang', defined('PSI_SHOW_PICKLIST_LANG') ? PSI_SHOW_PICKLIST_LANG ? 'true' : 'false' : 'false');
     $plug = $this->_xml->addChild('UsedPlugins');
     if ($this->_complete_request && count($this->_plugins) > 0) {
         foreach ($this->_plugins as $plugin) {
             $plug->addChild('Plugin')->addAttribute('name', $plugin);
         }
     } elseif ($this->_plugin_request && count($this->_plugins) > 0) {
         $plug->addChild('Plugin')->addAttribute('name', $this->_plugin);
     }
 }
Exemple #4
0
 /**
 * 增加节点值
 * @param array $data
 * @param SimpleXMLElement $xml
 * 
 * @return void
 */
 public static function node($data, SimpleXMLExtended &$xml)
 {
     foreach ($data as $k => $v) {
         if (is_array($v)) {
             is_numeric($k) && ($k = substr($xml->getName(), 0, -1));
             $subroot = $xml->addChild($k);
             self::node($v, $subroot);
         } else {
             if (is_numeric($v)) {
                 $xml->addChild($k, $v);
             } else {
                 $xml->addChild($k)->addCData($v);
             }
         }
     }
 }
Exemple #5
0
 public function export_category()
 {
     $id = $this->session->userdata('admin_id');
     $cates = $this->catenews_model->list_all_byuser($id);
     $xml = new SimpleXMLExtended("<root></root>");
     foreach ($cates as $cate) {
         $xml_post = $xml->addChild('category');
         $xml_post->addChild('cat_id', $cate->id);
         $content = $xml_post->addChild('cat_name');
         $content->addCData($cate->catenewsname);
     }
     $dom = new DOMDocument("1.0");
     $dom->preserveWhiteSpace = false;
     $dom->formatOutput = true;
     $dom->loadXML($xml->asXML());
     $xml->asXML('export/' . $id . '/category.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);
}
Exemple #7
0
 /**
  * build the xml structure where the content can be inserted
  *
  * @return void
  */
 private function _xmlbody()
 {
     $dom = new DOMDocument('1.0', 'UTF-8');
     $root = $dom->createElement("tns:phpsysinfo");
     $root->setAttribute('xmlns:tns', 'http://phpsysinfo.sourceforge.net/');
     $root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $root->setAttribute('xsi:schemaLocation', 'http://phpsysinfo.sourceforge.net/ phpsysinfo3.xsd');
     $dom->appendChild($root);
     $this->_xml = new SimpleXMLExtended(simplexml_import_dom($dom), $this->_sysinfo->getEncoding());
     $generation = $this->_xml->addChild('Generation');
     $generation->addAttribute('version', PSI_VERSION_STRING);
     $generation->addAttribute('timestamp', time());
     $options = $this->_xml->addChild('Options');
     $options->addAttribute('tempFormat', defined('PSI_TEMP_FORMAT') ? strtolower(PSI_TEMP_FORMAT) : 'c');
     $options->addAttribute('byteFormat', defined('PSI_BYTE_FORMAT') ? strtolower(PSI_BYTE_FORMAT) : 'auto_binary');
     if (defined('PSI_REFRESH')) {
         if (PSI_REFRESH === false) {
             $options->addAttribute('refresh', 0);
         } elseif (PSI_REFRESH === true) {
             $options->addAttribute('refresh', 1);
         } else {
             $options->addAttribute('refresh', PSI_REFRESH);
         }
     } else {
         $options->addAttribute('refresh', 60000);
     }
     if (defined('PSI_FS_USAGE_THRESHOLD')) {
         if (PSI_FS_USAGE_THRESHOLD === true) {
             $options->addAttribute('threshold', 1);
         } elseif (PSI_FS_USAGE_THRESHOLD !== false && PSI_FS_USAGE_THRESHOLD >= 1 && PSI_FS_USAGE_THRESHOLD <= 99) {
             $options->addAttribute('threshold', PSI_FS_USAGE_THRESHOLD);
         }
     } else {
         $options->addAttribute('threshold', 90);
     }
     $options->addAttribute('showPickListTemplate', defined('PSI_SHOW_PICKLIST_TEMPLATE') ? PSI_SHOW_PICKLIST_TEMPLATE ? 'true' : 'false' : 'false');
     $options->addAttribute('showPickListLang', defined('PSI_SHOW_PICKLIST_LANG') ? PSI_SHOW_PICKLIST_LANG ? 'true' : 'false' : 'false');
     $options->addAttribute('showCPUListExpanded', defined('PSI_SHOW_CPULIST_EXPANDED') ? PSI_SHOW_CPULIST_EXPANDED ? 'true' : 'false' : 'true');
     $options->addAttribute('showCPUInfoExpanded', defined('PSI_SHOW_CPUINFO_EXPANDED') ? PSI_SHOW_CPUINFO_EXPANDED ? 'true' : 'false' : 'false');
     if (count($this->_plugins) > 0) {
         if ($this->_plugin_request) {
             $plug = $this->_xml->addChild('UsedPlugins');
             $plug->addChild('Plugin')->addAttribute('name', $this->_plugin);
         } elseif ($this->_complete_request) {
             $plug = $this->_xml->addChild('UsedPlugins');
             foreach ($this->_plugins as $plugin) {
                 $plug->addChild('Plugin')->addAttribute('name', $plugin);
             }
         } else {
             $plug = $this->_xml->addChild('UnusedPlugins');
             foreach ($this->_plugins as $plugin) {
                 $plug->addChild('Plugin')->addAttribute('name', $plugin);
             }
         }
     }
 }
 function saveTemplate($data)
 {
     My_Logger::log("in Ajax_TemplateEditorProcessor saveTemplate()");
     $expected = array('filename', 'type', 'time', 'concepts', 'instructions', 'problem');
     $filename = $this->get($data['filename']);
     if (empty($filename)) {
         throw new Exception('Missing Filename');
     }
     My_Logger::log("filename is " . $filename);
     foreach ($expected as $field) {
         $toCheck = $this->get($data[$field]);
         if (empty($toCheck)) {
             //if (empty($this->get($data[$field]))){
             throw new Exception('Missing field: ' . $field);
         }
     }
     //build xml
     $xml = new SimpleXMLExtended('<question/>');
     $xml->addAttribute('type', $this->get($data['type']));
     $xml->addChild('estimated_time', $this->get($data['time']));
     $concepts = $xml->addChild('concepts');
     $concepts->addChild('concept', $this->get($data['concepts']));
     $xml->addChild('difficulty', $this->get($data['difficulty']));
     $xml->addChild('instructions', $this->get($data['instructions']));
     //$xml->problem = null;
     //$xml->problem->addCData($this->get($data['problem']));
     $xml->addCData('problem', $this->get($data['problem']));
     $sc = $xml->addChild('substitutions');
     $subs = $this->get($data['s']);
     if ($subs) {
         foreach ($subs as $sd) {
             if (empty($sd['name']) || empty($sd['value'])) {
                 continue;
             }
             $s = $sc->addCData('substitution', $sd['value']);
             $s->addAttribute('val', $sd['name']);
         }
     }
     $config = new Zend_Config_Ini(APPLICATION_PATH . "/configs/application.ini", APPLICATION_ENV);
     $path = $config->xml->import_path;
     $full_filename = $path . DIRECTORY_SEPARATOR . $filename;
     My_Logger::log("Saving to {$full_filename}");
     $xml->saveXML($full_filename);
     chmod($full_filename, 0666);
     return array('result' => 'success', 'msg' => "File '{$filename}' saved correctly");
 }
Exemple #9
0
 /**
  * Function for converting to an XML document.
  * Pass in a multi dimensional array or object and this recrusively loops through and builds up an XML document.
  *
  * @param array $data
  * @param string $rootNodeName - what you want the root node to be - defaultsto data.
  * @param SimpleXMLElement $xml - should only be used recursively
  * @return string XML
  */
 public static function toXml($data, $rootNodeName = 'root', $xml = null, $encoding = 'utf-8', $cdata = false)
 {
     // turn off compatibility mode as simple xml throws a wobbly if you don't.
     if (ini_get('zend.ze1_compatibility_mode') == 1) {
         ini_set('zend.ze1_compatibility_mode', 0);
     }
     if ($xml == null) {
         $xml = new SimpleXMLExtended("<?xml version='1.0' encoding='" . $encoding . "'?><{$rootNodeName} />");
     }
     // loop through the data passed in.
     foreach ($data as $key => $value) {
         // no numeric keys in our xml please!
         if (is_numeric($key)) {
             // make string key...
             //return;
             $key = "row";
         }
         // if there is another array or object found recrusively call this function
         if (is_array($value) || is_object($value)) {
             $node = $xml->addChild($key);
             // recrusive call.
             self::toXml($value, $rootNodeName, $node, $encoding, $cdata);
         } else {
             // add single node.
             $value = is_bool($value) ? $value ? 'true' : 'false' : $value;
             $value = htmlspecialchars($value);
             if ($cdata === true) {
                 $node = $xml->addChild($key);
                 $node->addCData($value);
             } else {
                 $xml->addChild($key, $value);
             }
         }
     }
     // pass back as string. or simple xml object if you want!
     return $xml->asXML();
 }
Exemple #10
0
function bm_save_book()
{
    # create a backup if necessary
    if (isset($_POST['current-slug'])) {
        $file = $_POST['current-slug'] . '.xml';
        @rename(BMBOOKPATH . $file, BMBACKUPPATH . $file);
    }
    # empty titles are not allowed
    if (empty($_POST['book-title'])) {
        $_POST['book-title'] = '[No Title]';
    }
    # set initial slug and filename
    if (!empty($_POST['book-slug'])) {
        $slug = bm_create_slug($_POST['book-slug']);
    } else {
        $slug = bm_create_slug($_POST['book-title']);
    }
    $file = BMBOOKPATH . "{$slug}.xml";
    # do not overwrite other books
    if (file_exists($file)) {
        $count = 1;
        $file = BMBOOKPATH . "{$slug}-{$count}.xml";
        while (file_exists($file)) {
            $file = BMBOOKPATH . "{$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['book-title']);
    $timestamp = strtotime($_POST['book-date'] . ' ' . $_POST['book-time']);
    $date = $timestamp ? date('r', $timestamp) : date('r');
    $tags = str_replace(array(' ', ',,'), array('', ','), safe_slash_html($_POST['book-tags']));
    $private = isset($_POST['book-private']) ? 'Y' : '';
    $content = safe_slash_html($_POST['book-content']);
    # 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('content');
    $obj->addCData($content);
    # write data to file
    if (@XMLsave($xml, $file) && bm_update_cache()) {
        bm_display_message(i18n_r('books_manager/SUCCESS_SAVE'), false, @$backup);
    } else {
        bm_display_message(i18n_r('books_manager/SUCCESS_SAVE'), false, @$backup);
    }
}
Exemple #11
0
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);
}
 /**
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 150213
  */
 public function printXML()
 {
     if (headers_sent()) {
         return;
     }
     if (!$this->simpleXML instanceof SimpleXMLExtended) {
         $fileLocation = $this->getFileLocation();
         if (!$this->existsAndReadable($fileLocation)) {
             die('EW:X:P');
         }
         $this->simpleXML = simplexml_load_file($fileLocation);
     }
     header("Content-Type:text/xml");
     echo $this->simpleXML->asXML();
     exit(0);
 }
Exemple #13
0
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);
    }
}
Exemple #14
0
        $sel = '';
        $count++;
    }
    $langs .= '</select><br />';
} else {
    $langs = '<b>' . i18n_r('LANGUAGE') . '</b>: &nbsp;<code style="color:red;">' . i18n_r('NONE') . '</code> &nbsp;&nbsp;';
}
# salt value generation
$api_file = GSDATAOTHERPATH . GSAUTHFILE;
if (!file_exists($api_file)) {
    if (getDef('GSUSECUSTOMSALT')) {
        $saltval = sha1(GSUSECUSTOMSALT);
    } else {
        $saltval = generate_salt();
    }
    $xml = new SimpleXMLExtended('<item></item>');
    $note = $xml->addChild('apikey');
    $note->addCData($saltval);
    if (!XMLsave($xml, $api_file)) {
        $kill = i18n_r('CHMOD_ERROR');
    }
}
# get salt value
$data = getXML($api_file);
$APIKEY = $data->apikey;
if (empty($APIKEY)) {
    $kill = i18n_r('CHMOD_ERROR');
}
$pagetitle = $site_full_name . ' &middot; ' . i18n_r('INSTALLATION');
get_template('header');
?>
function delete_in_category($file)
{
    $data = getXML($file);
    $section = $data->parent;
    $id = $data->url;
    $files = CATEGORIESPATH . '' . $section . '.xml';
    if (file_exists($files)) {
        $p = 0;
        $data = getXML($files);
        $array = array();
        foreach ($data->children() as $child) {
            if (sprintf("%s", $child) != $id) {
                $array[$p] = sprintf("%s", $child);
                $p++;
            }
        }
        //$array=array_reverse($array);
        $xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><item></item>');
        $xml->addChild('pubDate', date('r'));
        for ($i = 1; $i < $p; $i++) {
            $note = $xml->addChild('f' . $i);
            $note->addCData($array[$i]);
        }
        XMLsave($xml, $files);
    }
}
        return urlencode($text);
    }
}
// -----------------------------------------------------
// start XML generation
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
    xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:wp="http://wordpress.org/export/1.2/"
></rss>
XML;
$rss = new SimpleXMLExtended($xml);
$namespaces = $rss->getDocNamespaces(true);
// load the Newblur exported JSON file
$file = file_get_contents("starred_stories.json");
$json = json_decode($file, true);
// Wordpress will choke if our post names aren't unique, so we track
// them separately
$post_names = array();
$channel = $rss->addChild("channel");
$channel->addChild("generator", basename(__FILE__));
$channel->addChild("wxr_version", "1.2", $namespaces["wp"]);
// base_site_url is MUST. WordPress Importer warns if this does not exist
$channel->addChild("base_site_url", "http://asiajin.com/blog", $namespaces["wp"]);
foreach ($json["stories"] as $item) {
    $rssItem = $channel->addChild("item");
    $content = null;
Exemple #17
0
 /**
  * recursive function to allow appending child processes to a parent process
  *
  * @param Array             $child      part of the array which should be appended to the XML
  * @param SimpleXMLExtended $xml        XML-Object to which the array content is appended
  * @param Array             &$positions array with parent positions in xml structure
  *
  * @return SimpleXMLExtended Object with the appended array content
  */
 private function _addchild($child, SimpleXMLExtended $xml, &$positions)
 {
     foreach ($child as $key => $value) {
         $xmlnode = $xml->addChild("Process");
         if (isset($value[0])) {
             array_push($positions, $value[0]);
             $xmlnode->addAttribute('PID', $value[0]);
             $parentid = array_search($value[1], $positions);
             $xmlnode->addAttribute('ParentID', $parentid);
             $xmlnode->addAttribute('PPID', $value[1]);
             $xmlnode->addAttribute('MemoryUsage', $value[2]);
             $xmlnode->addAttribute('Name', $value[3]);
             if (PSI_OS !== 'WINNT') {
                 if ($parentid === 1) {
                     $xmlnode->addAttribute('Expanded', 0);
                 }
                 if (defined('PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED') && PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED === false && $value[3] === "[kthreadd]") {
                     $xmlnode->addAttribute('Expanded', 0);
                 }
             }
         }
         if (isset($value['childs'])) {
             $this->_addChild($value['childs'], $xml, $positions);
         }
     }
     return $xml;
 }
Exemple #18
0
 private function saveMenu($post)
 {
     // initialization
     $return = $nodes = $saved = array();
     foreach ($post as $key => $val) {
         if (is_array($val)) {
             $nodes[] = $key;
         }
     }
     // sets up array
     foreach ($post['level'] as $key => $level) {
         foreach ($nodes as $node) {
             $return[$key][$node] = $post[$node][$key];
         }
         // fill empty fields
         if (empty($return[$key]['slug'])) {
             $return[$key]['slug'] = $this->strtoslug($return[$key]['title']);
         }
         // final formatting
         $return[$key]['slug'] = $this->strtoslug($return[$key]['slug']);
         $return[$key]['url'] = $this->transliterate($return[$key]['url']);
         // checks to see slug doesn't already exist
         if (in_array($return[$key]['slug'], $saved)) {
             $return[$key]['slug'] = $return[$key]['slug'] . '-' . rand(0, 100);
         }
         // add to saved array
         $saved[] = $return[$key]['slug'];
     }
     // build xml file
     $xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel/>');
     $cdata = array('title', 'url');
     // menu items
     $menu = $xml->addChild('menu');
     foreach ($return as $key => $item) {
         $itemxml = $menu->addChild('item');
         foreach ($item as $field => $val) {
             if (in_array($field, $cdata)) {
                 $itemxml->{$field} = null;
                 $itemxml->{$field}->addCData($val);
             } else {
                 $itemxml->addChild($field, $val);
             }
         }
     }
     // settings
     $settings = $xml->addChild('settings');
     // format the xml file (beautify)
     $dom = new DOMDocument();
     $dom->preserveWhiteSpace = false;
     $dom->loadXML($xml->saveXML());
     $dom->formatOutput = true;
     // save to file
     $post['name'] = $this->strtoslug($post['name']);
     $newfile = GSDATAOTHERPATH . self::FILE . '/' . $post['name'] . '.xml';
     if (isset($post['oldname'])) {
         $oldfile = GSDATAOTHERPATH . self::FILE . '/' . $post['oldname'] . '.xml';
         if (file_exists($oldfile) && !file_exists($newfile)) {
             unlink($oldfile);
         }
     }
     return $dom->save($newfile);
 }
Exemple #19
0
echo "job id = {$jobId}<br/>";
echo "packagename = {$packageName}<br/>";
echo "output dir = {$outputDir}<br/>";
$names = array();
// generate one testsuite for each run
$result = mysql_queryf("SELECT name,id FROM runs WHERE job_id = {$jobId};");
while ($run = mysql_fetch_array($result)) {
    $names[$packageName . '.' . $run['name']]['runId'] = $run['id'];
}
foreach ($names as $name => $value) {
    $runId = $value['runId'];
    $xmlstr = "<?xml version='1.0' ?>\n<testsuite></testsuite>";
    // get one testsuite for each useragent (mozilla 3.5, opera 10, ...)
    $result = mysql_queryf("SELECT run_id,useragent_id,name,os FROM run_useragent LEFT OUTER JOIN useragents ON run_useragent.useragent_id = useragents.id WHERE run_id={$runId} AND status=2");
    while ($runAtAgend = mysql_fetch_array($result)) {
        $xml = new SimpleXMLExtended($xmlstr);
        $testsuiteName = $name . '.' . str_replace('.', '-', $runAtAgend['name'] . " on " . $runAtAgend['os']);
        $xml->addAttribute('name', $testsuiteName);
        $value['useragents'][$runAtAgend['useragent_id']]['xml'] = $xml;
        $value['useragents'][$runAtAgend['useragent_id']]['name'] = $testsuiteName;
    }
    // create on test foreach clientrun of user agent
    foreach ($value['useragents'] as $userAgentId => $useragent) {
        $xml = $useragent['xml'];
        $errors = 0;
        $tests = 0;
        $failures = 0;
        $sysout = '';
        $result = mysql_queryf("SELECT fail,error,total,results,ip,useragent FROM run_client INNER JOIN clients ON run_client.client_id = clients.id WHERE useragent_id={$userAgentId} AND run_id={$runId}");
        while ($runAtClient = mysql_fetch_array($result)) {
            preg_match('/\\(.*\\)/', $runAtClient['useragent'], $matches);
Exemple #20
0
 /**
  * returns the XML string
  *
  * @return string
  * @throws \Zend_Config_Exception
  */
 public function render()
 {
     $xml = new SimpleXMLExtended('<' . $this->getRootElementName() . ' />');
     if ($this->_config) {
         $extends = $this->_config->getExtends();
         $sectionName = $this->_config->getSectionName();
         if (is_string($sectionName)) {
             $child = $xml->addChild($sectionName);
             $this->_addBranch($this->_config, $child, $xml);
         } else {
             foreach ($this->_config as $sectionName => $data) {
                 if (!$data instanceof \Zend_Config) {
                     $this->addChildConsiderCdata($xml, $sectionName, $data);
                 } else {
                     $child = $xml->addChild($sectionName);
                     if (isset($extends[$sectionName])) {
                         $child->addAttribute('zf:extends', $extends[$sectionName], \Zend_Config_Xml::XML_NAMESPACE);
                     }
                     $this->_addBranch($data, $child, $xml);
                 }
             }
         }
     }
     $dom = dom_import_simplexml($xml)->ownerDocument;
     if ($encoding = $this->getEncoding()) {
         $dom->encoding = $encoding;
     }
     $dom->formatOutput = $this->getFormatOutput();
     $xmlString = $dom->saveXML();
     return $xmlString;
 }
Exemple #21
0
 /**
  * recursive function to allow appending child processes to a parent process
  *
  * @param Array             $child      part of the array which should be appended to the XML
  * @param SimpleXMLExtended $xml        XML-Object to which the array content is appended
  * @param Array             &$positions array with parent positions in xml structure
  *
  * @return SimpleXMLExtended Object with the appended array content
  */
 private function _addchild($child, $xml, &$positions)
 {
     foreach ($child as $key => $value) {
         $xmlnode = $xml->addChild("Process");
         foreach ($value as $key2 => $value2) {
             if (!is_array($value2)) {
                 switch ($key2) {
                     case 0:
                         array_push($positions, $value2);
                         $xmlnode->addAttribute('PID', $value2);
                         break;
                     case 1:
                         $xmlnode->addAttribute('ParentID', array_search($value2, $positions));
                         $xmlnode->addAttribute('PPID', $value2);
                         break;
                     case 2:
                         $xmlnode->addAttribute('MemoryUsage', $value2);
                         break;
                     case 3:
                         $xmlnode->addAttribute('Name', $value2);
                         break;
                 }
             } else {
                 $this->_addChild($value2, $xml, $positions);
             }
         }
     }
     return $xml;
 }
Exemple #22
0
/**
 * create a page xml obj
 *
 * @since 3.4
 * @param  str      $title     title of page
 * @param  str      $url       optional, url slug of page, if null title is used
 * @param  array   	$data      optional, array of data fields for page
 * @param  boolean 	$overwrite optional, overwrite exisitng slugs, if false auto increments slug id
 * @return obj                 xml object of page
 */
function createPageXml($title, $url = null, $data = array(), $overwrite = false)
{
    global $reservedSlugs;
    $fields = array('title', 'titlelong', 'summary', 'url', 'author', 'template', 'parent', 'menu', 'menuStatus', 'menuOrder', 'private', 'meta', 'metad', 'metarNoIndex', 'metarNoFollow', 'metarNoArchive', 'content');
    // setup url, falls back to title if not set
    if (!isset($url)) {
        $url = $title;
    }
    $url = prepareSlug($url);
    // prepare slug, clean it, translit, truncate
    $title = truncate($title, GSTITLEMAX);
    // truncate long titles
    // If overwrite is false do not use existing slugs, get next incremental slug, eg. "slug-count"
    if (!$overwrite && (file_exists(GSDATAPAGESPATH . $url . ".xml") || in_array($url, $reservedSlugs))) {
        list($newfilename, $count) = getNextFileName(GSDATAPAGESPATH, $url . '.xml');
        $url = $url . '-' . $count;
        // die($url.' '.$newfilename.' '.$count);
    }
    // store url and title in data, if passed in param they are ignored
    $data['url'] = $url;
    $data['title'] = $title;
    // create new xml
    $xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><item></item>');
    $xml->addChild('pubDate', date('r'));
    foreach ($fields as $field) {
        $node = $xml->addChild($field);
        if (isset($data[$field])) {
            $node->addCData($data[$field]);
        }
        // saving all cdata for some reason
    }
    // debugLog(__FUNCTION__ . ': page created with slug of ' . $xml->url);
    return $xml;
}
Exemple #23
0
 $xml = new SimpleXMLElement('<item></item>');
 $xml->addChild('USR', $USR);
 $xml->addChild('PWD', $PASSWD);
 $xml->addChild('EMAIL', $EMAIL);
 $xml->addChild('HTMLEDITOR', '1');
 $xml->addChild('TIMEZONE', $TIMEZONE);
 $xml->addChild('LANG', $LANG);
 if (!XMLsave($xml, GSUSERSPATH . $file)) {
     $kill = i18n_r('CHMOD_ERROR');
 }
 # create password change trigger file
 $flagfile = GSUSERSPATH . getPWDresetName(_id($USR), 'xml');
 copy_file(GSUSERSPATH . $file, $flagfile);
 # create new GSWEBSITEFILE (website.xml) file
 $file = GSWEBSITEFILE;
 $xmls = new SimpleXMLExtended('<item></item>');
 $note = $xmls->addChild('SITENAME');
 $note->addCData($SITENAME);
 $note = $xmls->addChild('SITEURL');
 $note->addCData($SITEURL);
 $xmls->addChild('TEMPLATE', GSINSTALLTEMPLATE);
 $xmls->addChild('PRETTYURLS', '');
 $xmls->addChild('PERMALINK', '');
 $xmls->addChild('SITEUSR', $USR);
 $xmls->addChild('SITEABOUT', '');
 if (!XMLsave($xmls, GSDATAOTHERPATH . $file)) {
     $kill = i18n_r('CHMOD_ERROR');
 }
 # create default index.xml page
 $init = GSDATAPAGESPATH . 'index.xml';
 $temp = GSADMININCPATH . 'tmp/tmp-index.xml';
Exemple #24
0
 }
 $xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><item></item>');
 $xml->addChild('USR', $USR);
 $xml->addChild('NAME', var_out($NAME));
 $xml->addChild('PWD', $PASSWD);
 $xml->addChild('EMAIL', var_out($EMAIL, 'email'));
 $xml->addChild('HTMLEDITOR', $HTMLEDITOR);
 $xml->addChild('TIMEZONE', $TIMEZONE);
 $xml->addChild('LANG', $LANG);
 exec_action('settings-user');
 if (!XMLsave($xml, GSUSERSPATH . $file)) {
     $error = i18n_r('CHMOD_ERROR');
 }
 # create website xml file
 createBak($wfile, GSDATAOTHERPATH, GSBACKUPSPATH . 'other/');
 $xmls = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><item></item>');
 $note = $xmls->addChild('SITENAME');
 $note->addCData($SITENAME);
 $note = $xmls->addChild('SITEURL');
 $note->addCData($SITEURL);
 $note = $xmls->addChild('TEMPLATE');
 $note->addCData($TEMPLATE);
 $xmls->addChild('PRETTYURLS', $PRETTYURLS);
 $xmls->addChild('PERMALINK', var_out($PERMALINK));
 exec_action('settings-website');
 if (!XMLsave($xmls, GSDATAOTHERPATH . $wfile)) {
     $error = i18n_r('CHMOD_ERROR');
 }
 # see new language file immediately
 include GSLANGPATH . $LANG . '.php';
 if (!$error) {
 //check to make sure we dont overwrite any good files upon create
 if (file_exists($file) && $url != $_POST['existing-url']) {
     $count = "1";
     $file = GSDATAPAGESPATH . $url . "-" . $count . ".xml";
     while (file_exists($file)) {
         $count++;
         $file = GSDATAPAGESPATH . $url . "-" . $count . ".xml";
     }
     $url = $url . '-' . $count;
 }
 // if we are editing an existing page, create a backup
 if (file_exists($file)) {
     $bakfile = GSBACKUPSPATH . "pages/" . $url . ".bak.xml";
     copy($file, $bakfile);
 }
 $xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><item></item>');
 $xml->addChild('pubDate', date('r'));
 $note = $xml->addChild('title');
 $note->addCData($title);
 $note = $xml->addChild('url');
 $note->addCData($url);
 $note = $xml->addChild('meta');
 $note->addCData($metak);
 $note = $xml->addChild('metad');
 $note->addCData($metad);
 $note = $xml->addChild('menu');
 $note->addCData($menu);
 $note = $xml->addChild('menuOrder');
 $note->addCData($menuOrder);
 $note = $xml->addChild('menuStatus');
 $note->addCData($menuStatus);
Exemple #26
0
 /** 
  * Creates Blog Posts Cache File
  * 
  * @return bool
  */
 public function createPostsCache()
 {
     $posts = $this->listPosts(true, true);
     if ($posts === false) {
         $posts = array();
     }
     $count = 0;
     $xml = new SimpleXMLExtended('<?xml version="1.0"?><item></item>');
     if (!count($posts) < 1) {
         foreach ($posts as $post) {
             $data = getXML($post['filename']);
             $new_post = $xml->addChild("post");
             foreach ($data as $key => $value) {
                 $post_parent = $new_post->addChild($key);
                 $post_parent->addCData($value);
             }
         }
         $save_cache = XMLsave($xml, BLOGCACHEFILE);
     }
 }
Exemple #27
0
$file = GSWEBSITEFILE;
$theme_options = '';
# was the form submitted?
if (isset($_POST['submitted']) && isset($_POST['template'])) {
    check_for_csrf("activate");
    # get passed value from form
    $newTemplate = var_in($_POST['template']);
    if (!path_is_safe(GSTHEMESPATH . $newTemplate, GSTHEMESPATH)) {
        die;
    }
    # 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);
Exemple #28
0
<?php

// http://coffeerings.posterous.com/php-simplexml-and-cdata
class SimpleXMLExtended extends SimpleXMLElement
{
    public function addCData($cdata_text)
    {
        $node = dom_import_simplexml($this);
        $no = $node->ownerDocument;
        $node->appendChild($no->createCDATASection($cdata_text));
    }
}
$xmlFile = 'config.xml';
// instead of $xml = new SimpleXMLElement('<site/>');
$xml = new SimpleXMLExtended('<site/>');
$xml->title = NULL;
// VERY IMPORTANT! We need a node where to append
$xml->title->addCData('Site Title');
$xml->title->addAttribute('lang', 'en');
$xml->saveXML($xmlFile);
 $xml = new SimpleXMLElement('<item></item>');
 $xml->addChild('USR', $USR);
 $xml->addChild('PWD', $PASSWD);
 $xml->addChild('EMAIL', $EMAIL);
 $xml->addChild('HTMLEDITOR', '1');
 $xml->addChild('TIMEZONE', $TIMEZONE);
 $xml->addChild('LANG', $LANG);
 if (!XMLsave($xml, GSUSERSPATH . $file)) {
     $kill = i18n_r('CHMOD_ERROR');
 }
 # create password change trigger file
 $flagfile = GSUSERSPATH . _id($USR) . ".xml.reset";
 copy(GSUSERSPATH . $file, $flagfile);
 # create new website.xml file
 $file = 'website.xml';
 $xmls = new SimpleXMLExtended('<item></item>');
 $note = $xmls->addChild('SITENAME');
 $note->addCData($SITENAME);
 $note = $xmls->addChild('SITEURL');
 $note->addCData($SITEURL);
 $xmls->addChild('TEMPLATE', 'Innovation');
 $xmls->addChild('PRETTYURLS', '');
 $xmls->addChild('PERMALINK', '');
 if (!XMLsave($xmls, GSDATAOTHERPATH . $file)) {
     $kill = i18n_r('CHMOD_ERROR');
 }
 # create default index.xml page
 $init = GSDATAPAGESPATH . 'index.xml';
 $temp = GSADMININCPATH . 'tmp/tmp-index.xml';
 if (!file_exists($init)) {
     copy($temp, $init);
 /**
  * add the errors to an existing xml document
  *
  * @param String $encoding encoding
  *
  * @return SimpleXmlElement
  */
 public function errorsAddToXML($encoding)
 {
     $dom = new DOMDocument('1.0', 'UTF-8');
     $root = $dom->createElement("Errors");
     $dom->appendChild($root);
     $xml = simplexml_import_dom($dom);
     $xmlerr = new SimpleXMLExtended($xml, $encoding);
     foreach ($this->_arrErrorList as $arrLine) {
         $error = $xmlerr->addCData('Error', $arrLine['message']);
         $error->addAttribute('Function', $arrLine['command']);
     }
     return $xmlerr->getSimpleXmlElement();
 }