/**
  * ModuleOpenImmo::_loadXML
  *
  * Returns an array containing the xml data
  * @param fileName
  * @returns array
  **/
 public function _loadXML($fileName = NULL)
 {
     // load xml file
     $sXML = NULL;
     $sXML = @file_get_contents(TL_ROOT . DIRECTORY_SEPARATOR . $fileName);
     if (!empty($sXML)) {
         // check for known namespaces
         $knownNameSpace = false;
         foreach ($this->aAllowedNamespaces as $nameSpace) {
             if (strpos($sXML, '<' . $nameSpace . ':') !== FALSE) {
                 $knownNameSpace = true;
                 // strip namespace from xml
                 $sXML = str_replace(array('<' . $nameSpace . ':', '</' . $nameSpace . ':'), array('<', '</'), $sXML);
             }
         }
         // no of the known namespaces given? NOT VALID!
         if (!$knownNameSpace) {
             return false;
         }
         // parse our xml into an array
         $oXML = NULL;
         $oXML = new XMLParser();
         $aXML = array();
         $aXML = $oXML->xmlToArray($sXML);
         // strip our root node and return xml
         if (!empty($aXML)) {
             $rootNodeName = array_keys($aXML);
             $rootNodeName = $rootNodeName[0];
             $aXML = $aXML[$rootNodeName][0];
             return $aXML;
         }
     }
     return false;
 }
	function thor_build_display_values()
	{
		$form = new entity($this->form_id);
		$form->get_values();
		if ($form->get_value('type') != id_of('form'))
		{
			trigger_error('the thor viewer was passed an invalid id ('.$form_id.') - it must be passed the ID of a reason form entity');
		}
		else
		{
			$form_xml_obj = new XMLParser($form->get_value('thor_content'));
			$form_xml_obj->Parse();
			$display_values = array();
			foreach ($form_xml_obj->document->tagChildren as $k=>$v)
			{
				$tagname = is_object($v) ? $v->tagName : '';
				if (method_exists($this, '_build_display_'.$tagname))
				{
					$build_function = '_build_display_'.$tagname;
					$display_values = array_merge($display_values, $this->$build_function($v));
				}
			}
		}
		foreach ($this->extra_fields as $field_name)
		{
			$display_values[$field_name]['label'] = prettify_string($field_name);
			$display_values[$field_name]['type'] = 'text';
		}
		$this->_display_values = (isset($display_values)) ? $display_values : array();
	}
 /**
  * Parse into structures the XML contents of an email data file.
  * @param $contents string
  * @return array
  */
 function parseEmails($contents)
 {
     $parser = new XMLParser();
     $result = $parser->parseTextStruct($contents, array('email_text', 'subject', 'body'));
     $parser->destroy();
     return $result;
 }
/**
 *	Query EVE Central's XML feed.
 */
function ask_eve_central($item_id)
{
    file_put_contents(KB_CACHEDIR . '/evecentral/activity.log', "Handling from live.\n", FILE_APPEND);
    $query = DBFactory::getDBQuery();
    if (function_exists('curl_init')) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "http://api.eve-central.com/api/marketstat?regionlimit=10000002&typeid=" . $item_id . "");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $content = curl_exec($ch);
        curl_close($ch);
    } else {
        $file = fopen("http://api.eve-central.com/api/marketstat?regionlimit=10000002&typeid=" . $item_id . "", "r");
        if (!$file) {
            return -99;
        }
        $content = stream_get_contents($file);
        fclose($file);
    }
    if (strpos($content, '</evec_api>') == false) {
        return -99;
    } else {
        $parse = new XMLParser();
        $parse->preparseXML();
        $parse->parseXML($content);
        $values = $parse->get_data();
        if (0 == $values['WEIGHTED']) {
            return -99;
        }
        $weighted_average = $values['WEIGHTED'];
    }
    file_put_contents(KB_CACHEDIR . '/evecentral/activity.log', "{$content}\n", FILE_APPEND);
    $query->execute("REPLACE INTO kb3_eve_central (item_id, item_price) VALUES ({$item_id}, '{$weighted_average}')");
    return $weighted_average;
}
Exemple #5
0
 public static function getFAQ()
 {
     if (!($data = @file_get_contents(self::getFilename()))) {
         throw new ErrorException(self::ERROR_READING_FILE);
     }
     /**
      * Let's replace some of the docbook tags and wrap some HTML-entities
      * inside CDATA containers.
      */
     $pattern = array('/<ulink\\s+url="(.+)">(.+)<\\/ulink>/isU', '/<itemizedlist>(.+)<\\/itemizedlist>/isU', '/<listitem><simpara>(.+)<\\/simpara><\\/listitem>/isU', '/<simpara>(.+)<\\/simpara>/isU', '/<emphasis>(.+)<\\/emphasis>/isU', '/<envar>(.+)<\\/envar>/isU', '/<command(?:\\s+[^>]+)?>(.+)<\\/command>/isU', '/<blockquote>(.+)<\\/blockquote>/isU', '/<programlisting(?:\\s+[^>]+)?>(.+)<\\/programlisting>/isU', '/<quote>(.+)<\\/quote>/isU', '/<xref linkend="(.+)"\\s+endterm=".+"\\/>/isU', '/(&(?:lt|gt|quot);)/is');
     $replace = array('<h:a href="\\1">\\2</h:a>', '<h:ul>\\1</h:ul>', '<h:li>\\1</h:li>', '<h:p>\\1</h:p>', '<h:span class="italic">\\1</h:span>', '<h:span class="envar">\\1</h:span>', '<h:span class="bold">\\1</h:span>', '<h:blockquote>\\1</h:blockquote>', '<h:pre>\\1</h:pre>', '&#8220;<h:span class="quote">\\1</h:span>&#8221;', '<h:a xref="\\1"/>', '<![CDATA[\\1]]>');
     $data = preg_replace($pattern, $replace, $data);
     /* Remove this weird character as it displays as À in Firefox. */
     $data = str_replace(chr(194), '', $data);
     /* Now parse the data. */
     $parser = new XMLParser();
     $a = $parser->parseByData($data);
     $sections = array();
     /**
      * Build a map of the defined hrefs so we can give the xrefs the correct
      * text.
      */
     $xref = array();
     $count = 1;
     foreach ($a['faq']['section'] as $data) {
         $sections[] = new QASection($data, $count++, $xref);
     }
     return $sections;
 }
 public function sendHttp($url, $connectTimeout = "", $timeout)
 {
     // verify that the URL uses a supported protocol.
     if (strpos($url, "http://") === 0 || strpos($url, "https://") === 0) {
         //Construct the payload to POST to the url.
         $data = $this->getRequestXml();
         // create a new cURL resource
         $ch = curl_init($url);
         // set URL and other appropriate options
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
         curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
         // Execute the request.
         $result = curl_exec($ch);
         $succeeded = curl_errno($ch) == 0 ? true : false;
         // close cURL resource, and free up system resources
         curl_close($ch);
         // If Communication was not successful set error result, otherwise
         if (!$succeeded) {
             $result = $this->setErrorResponse(CENTINEL_ERROR_CODE_8030, CENTINEL_ERROR_CODE_8030_DESC);
         }
         // Assert that we received an expected Centinel Message in reponse.
         if (strpos($result, "<CardinalMPI>") === false) {
             $result = $this->setErrorResponse(CENTINEL_ERROR_CODE_8010, CENTINEL_ERROR_CODE_8010_DESC);
         }
     } else {
         $result = $this->setErrorResponse(CENTINEL_ERROR_CODE_8000, CENTINEL_ERROR_CODE_8000_DESC);
     }
     $parser = new XMLParser();
     $parser->deserializeXml($result);
     $this->response = $parser->deserializedResponse;
 }
Exemple #7
0
 /**
  * Parse an XML file and return data in an array.
  * @see xml.XMLParser::parseStruct()
  */
 function &parseStruct($file, $tagsToMatch = array())
 {
     $parser = new XMLParser();
     $data =& $parser->parseStruct($file, $tagsToMatch);
     $parser->destroy();
     return $data;
 }
 /**
  * Update currency cache
  */
 private function __update_cache($force = False)
 {
     if (!is_null($this->_cache) && !$force) {
         return;
     }
     $filename = $this->path . 'data/iso_currencies.xml';
     if (file_exists($filename)) {
         // get XML file
         $data = file_get_contents($filename);
         $xml = new XMLParser($data, $filename);
         $xml->Parse();
         $currencies = array();
         // create list with unique data
         foreach ($xml->document->tagChildren as $iso_currency) {
             // extract data
             $entity = $iso_currency->tagChildren[0]->tagData;
             $currency = $iso_currency->tagChildren[1]->tagData;
             $alphabetic_code = $iso_currency->tagChildren[2]->tagData;
             $numeric_code = $iso_currency->tagChildren[3]->tagData;
             $minor_unit = $iso_currency->tagChildren[4]->tagData;
             if ($numeric_code == '' || $alphabetic_code == 'XXX') {
                 continue;
             }
             $currencies[] = array('entity' => $entity, 'currency' => $currency, 'alphabetic_code' => $alphabetic_code, 'numeric_code' => $numeric_code, 'minor_unit' => $minor_unit);
             // update cache
             $this->_cache = $currencies;
         }
     }
 }
Exemple #9
0
 /**
  * Install conference settings from an XML file.
  * @param $id int ID of scheduled conference/conference for settings to apply to
  * @param $filename string Name of XML file to parse and install
  * @param $paramArray array Optional parameters for variable replacement in settings
  */
 function installSettings($id, $filename, $paramArray = array())
 {
     $xmlParser = new XMLParser();
     $tree = $xmlParser->parse($filename);
     if (!$tree) {
         $xmlParser->destroy();
         return false;
     }
     foreach ($tree->getChildren() as $setting) {
         $nameNode =& $setting->getChildByName('name');
         $valueNode =& $setting->getChildByName('value');
         if (isset($nameNode) && isset($valueNode)) {
             $type = $setting->getAttribute('type');
             $isLocaleField = $setting->getAttribute('locale');
             $name =& $nameNode->getValue();
             if ($type == 'date') {
                 $value = strtotime($valueNode->getValue());
             } elseif ($type == 'object') {
                 $arrayNode =& $valueNode->getChildByName('array');
                 $value = $this->_buildObject($arrayNode, $paramArray);
             } else {
                 $value = $this->_performReplacement($valueNode->getValue(), $paramArray);
             }
             // Replace translate calls with translated content
             $this->updateSetting($id, $name, $isLocaleField ? array(Locale::getLocale() => $value) : $value, $type, $isLocaleField);
         }
     }
     $xmlParser->destroy();
 }
 /**
  * 测试XML解析类
  */
 function testXml()
 {
     $xml = file_get_contents('temp.xml');
     $this->load->library('XMLParserLib');
     $parser = new XMLParser($xml);
     $parser->Parse();
     print_r($parser->document->globalinfo);
     //echo $parser->GenerateXML();
 }
Exemple #11
0
 /**
  * Parse a record's contents into an object
  * @param $contents string
  * @return object
  */
 function &parseContents(&$contents)
 {
     $xmlParser = new XMLParser();
     $result =& $xmlParser->parseText($contents);
     $returner = array();
     $returner =& $this->handleRootNode($result);
     $result->destroy();
     $xmlParser->destroy();
     return $returner;
 }
 public static function getAllArticles()
 {
     $fname = DIR_DATA . '/press_articles.xml';
     $parser = new XMLParser();
     $a = $parser->parseByFilename($fname);
     $entries = array();
     foreach ($a['articles']['article'] as $key => $value) {
         $entries[] = new Article(array('name' => $value['name'], 'url' => $value['url'], 'language' => $value['language'], 'posted' => $value['posted']));
     }
     return $entries;
 }
Exemple #13
0
 function testEmails($locale, $referenceLocale)
 {
     import('install.Installer');
     // Bring in data dir
     $errors = array();
     $xmlParser = new XMLParser();
     $referenceEmails =& $xmlParser->parse(INSTALLER_DATA_DIR . "/data/locale/{$referenceLocale}/email_templates_data.xml");
     $emails =& $xmlParser->parse(INSTALLER_DATA_DIR . "/data/locale/{$locale}/email_templates_data.xml");
     $emailsTable =& $emails->getChildByName('table');
     $referenceEmailsTable =& $referenceEmails->getChildByName('table');
     $matchedReferenceEmails = array();
     // Pass 1: For all translated emails, check that they match
     // against reference translations.
     for ($emailIndex = 0; ($email =& $emailsTable->getChildByName('row', $emailIndex)) !== null; $emailIndex++) {
         // Extract the fields from the email to be tested.
         $fields = $this->extractFields($email);
         // Locate the reference email and extract its fields.
         for ($referenceEmailIndex = 0; ($referenceEmail =& $referenceEmailsTable->getChildByName('row', $referenceEmailIndex)) !== null; $referenceEmailIndex++) {
             $referenceFields = $this->extractFields($referenceEmail);
             if ($referenceFields['email_key'] == $fields['email_key']) {
                 break;
             }
         }
         // Check if a matching reference email was found.
         if (!isset($referenceEmail) || $referenceEmail === null) {
             $errors[EMAIL_ERROR_EXTRA_EMAIL][] = array('key' => $fields['email_key']);
             continue;
         }
         // We've successfully found a matching reference email.
         // Compare it against the translation.
         $bodyParams = $this->getParameterNames($fields['body']);
         $referenceBodyParams = $this->getParameterNames($referenceFields['body']);
         if ($bodyParams !== $referenceBodyParams) {
             $errors[EMAIL_ERROR_DIFFERING_PARAMS][] = array('key' => $fields['email_key'], 'mismatch' => array_diff($bodyParams, $referenceBodyParams));
         }
         $subjectParams = $this->getParameterNames($fields['subject']);
         $referenceSubjectParams = $this->getParameterNames($referenceFields['subject']);
         if ($subjectParams !== $referenceSubjectParams) {
             $errors[EMAIL_ERROR_DIFFERING_PARAMS][] = array('key' => $fields['email_key'], 'mismatch' => array_diff($subjectParams, $referenceSubjectParams));
         }
         $matchedReferenceEmails[] = $fields['email_key'];
         unset($email);
         unset($referenceEmail);
     }
     // Pass 2: Make sure that there are no missing translations.
     for ($referenceEmailIndex = 0; ($referenceEmail =& $referenceEmailsTable->getChildByName('row', $referenceEmailIndex)) !== null; $referenceEmailIndex++) {
         // Extract the fields from the email to be tested.
         $referenceFields = $this->extractFields($referenceEmail);
         if (!in_array($referenceFields['email_key'], $matchedReferenceEmails)) {
             $errors[EMAIL_ERROR_MISSING_EMAIL][] = array('key' => $referenceFields['email_key']);
         }
     }
     $this->displayEmailErrors($locale, $errors);
 }
Exemple #14
0
 public static function getAllMenus()
 {
     $fname = DIR_DATA . '/menus.xml';
     $parser = new XMLParser();
     $a = $parser->parseByFilename($fname);
     $entries = array();
     foreach ($a['menus']['group'] as $key => $value) {
         $entries[] = new MenuItem(array('name' => $value['name'], 'class' => $value['class'], 'link' => $value['link']));
     }
     return $entries;
 }
 public static function getAllCredits()
 {
     $fname = DIR_DATA . '/credits.xml';
     $parser = new XMLParser();
     $a = $parser->parseByFilename($fname);
     $sections = array();
     foreach ($a['credits']['section'] as $key => $value) {
         $sections[] = new CSection($value);
     }
     return $sections;
 }
 public static function getAllDocuments()
 {
     $fname = DIR_DATA . '/documentation.xml';
     $parser = new XMLParser();
     $a = $parser->parseByFilename($fname);
     $entries = array();
     foreach ($a['documentation']['document'] as $key => $value) {
         $entries[] = new Document($value);
     }
     return $entries;
 }
 /**
  * Parse an RT version XML file.
  * @param $file string path to the XML file
  * @return RTVersion
  */
 function &parse($file)
 {
     $parser = new XMLParser();
     $tree = $parser->parse($file);
     $parser->destroy();
     $version = false;
     if ($tree !== false) {
         $version =& $this->parseVersion($tree);
     }
     $tree->destroy();
     return $version;
 }
 public static function getAllDownloads()
 {
     $fname = DIR_DATA . '/downloads.xml';
     /* Now parse the data. */
     $parser = new XMLParser();
     $a = $parser->parseByFilename($fname);
     $sections = array();
     foreach ($a['downloads']['section'] as $key => $value) {
         $sections[] = new DSection($value);
     }
     return $sections;
 }
/**
 * MyBB 1.8
 * Copyright 2014 MyBB Group, All Rights Reserved
 *
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
function task_versioncheck($task)
{
    global $cache, $lang, $mybb;
    $current_version = rawurlencode($mybb->version_code);
    $updated_cache = array('last_check' => TIME_NOW);
    // Check for the latest version
    require_once MYBB_ROOT . 'inc/class_xml.php';
    $contents = fetch_remote_file("http://www.mybb.com/version_check.php");
    if (!$contents) {
        add_task_log($task, $lang->task_versioncheck_ran_errors);
        return false;
    }
    $pos = strpos($contents, "<");
    if ($pos > 1) {
        $contents = substr($contents, $pos);
    }
    $pos = strpos(strrev($contents), ">");
    if ($pos > 1) {
        $contents = substr($contents, 0, -1 * ($pos - 1));
    }
    $parser = new XMLParser($contents);
    $tree = $parser->get_tree();
    $latest_code = (int) $tree['mybb']['version_code']['value'];
    $latest_version = "<strong>" . htmlspecialchars_uni($tree['mybb']['latest_version']['value']) . "</strong> (" . $latest_code . ")";
    if ($latest_code > $mybb->version_code) {
        $latest_version = "<span style=\"color: #C00;\">" . $latest_version . "</span>";
        $version_warn = 1;
        $updated_cache['latest_version'] = $latest_version;
        $updated_cache['latest_version_code'] = $latest_code;
    } else {
        $latest_version = "<span style=\"color: green;\">" . $latest_version . "</span>";
    }
    // Check for the latest news
    require_once MYBB_ROOT . "inc/class_feedparser.php";
    $feed_parser = new FeedParser();
    $feed_parser->parse_feed("http://feeds.feedburner.com/MyBBDevelopmentBlog");
    $updated_cache['news'] = array();
    require_once MYBB_ROOT . '/inc/class_parser.php';
    $post_parser = new postParser();
    if ($feed_parser->error == '') {
        foreach ($feed_parser->items as $item) {
            if (isset($updated_cache['news'][2])) {
                break;
            }
            $description = $item['description'];
            $description = $post_parser->parse_message($description, array('allow_html' => true));
            $description = preg_replace('#<img(.*)/>#', '', $description);
            $updated_cache['news'][] = array('title' => htmlspecialchars_uni($item['title']), 'description' => $description, 'link' => htmlspecialchars_uni($item['link']), 'author' => htmlspecialchars_uni($item['author']), 'dateline' => $item['date_timestamp']);
        }
    }
    $cache->update("update_check", $updated_cache);
    add_task_log($task, $lang->task_versioncheck_ran);
}
 /**
  * Parse and return DHL tracking details.
  *
  * @inheritdoc
  */
 public function fetchData($trackingNumber)
 {
     $link = 'http://track.dhl-usa.com/TrackByNbr.asp?ShipmentNumber=' . $trackingNumber;
     $html = $this->fetchUrl($link);
     if (!preg_match_all('#<input type="hidden" name="hdnXML([^"]+)" value="([^"]+)"/>#', $html, $matches, PREG_SET_ORDER)) {
         // XML tracking details not found
         return false;
     }
     $stats = array();
     $locations = array();
     $xml = '';
     foreach ($matches as $match) {
         $xml .= $match[2];
     }
     $xml = html_entity_decode($xml);
     $parser = new XMLParser();
     $obj = $parser->parse($xml);
     if (!isset($obj->track->trackshipments->shipment->result->code->data) && $obj->track->trackshipments->shipment->result->code->data != 1) {
         // XML document could not be parsed
         return false;
     }
     $stats['service'] = isset($obj->track->trackshipments->shipment->service->desc->data) ? $obj->track->trackshipments->shipment->service->desc->data : '';
     $stats['departure'] = isset($obj->track->trackshipments->shipment->pickup->date->data) ? $obj->track->trackshipments->shipment->pickup->date->data : '';
     $stats['destination'] = isset($obj->track->trackshipments->shipment->destinationdescr->location->data) ? $obj->track->trackshipments->shipment->destinationdescr->location->data : '';
     $stats['arrival'] = isset($obj->track->trackshipments->shipment->delivery->date->data) ? $obj->track->trackshipments->shipment->delivery->date->data : '';
     if (isset($obj->track->trackshipments->shipment->trackinghistory->status)) {
         if (!is_array($obj->track->trackshipments->shipment->trackinghistory->status)) {
             $obj->track->trackshipments->shipment->trackinghistory->status = array($obj->track->trackshipments->shipment->trackinghistory->status);
         }
         foreach ($obj->track->trackshipments->shipment->trackinghistory->status as $history) {
             $row = array();
             $row['location'] = $history->location->city->data . ', ';
             if (isset($history->location->state->data) && !empty($history->location->state->data)) {
                 $row['location'] .= $history->location->state->data . ', ';
             }
             if (isset($history->location->country->data) && !empty($history->location->country->data)) {
                 $row['location'] .= $history->location->country->data;
             }
             $row['location'] = rtrim($row['location'], ', ');
             $row['time'] = $history->date->data . ' ' . $history->time->data;
             $row['status'] = $history->statusdesc->data;
             $locations[] = $row;
             if (!isset($stats['status'])) {
                 $stats['status'] = $history->statusdesc->data;
             }
             if (!isset($stats['last_location'])) {
                 $stats['last_location'] = $row['location'];
             }
         }
     }
     return array('details' => $stats, 'locations' => $locations);
 }
 function _parse_ticket($ticket_xml)
 {
     // This XML parser gives us almost what we need, just tidy it up a bit
     $p = new XMLParser($ticket_xml);
     $result = $p->getOutput();
     if (@$result['ticket'] == '') {
         return $result;
     }
     $result = $result['ticket'];
     $result['id'] = $result['token'];
     //### FIXME: Remove when token renamed in service
     return $result;
 }
    /**
     * Scan the plugin registry for custom roles, tasks and commands,
     * and register them as existing.
     */
    function scan()
    {
        static $scanned = false;
        if ($scanned) {
            return;
        }

        $scanned = true;
        $parser = new XMLParser;
        $schemapath = Main::getDataPath();
        if (!file_exists(Main::getDataPath() . '/channel-1.0.xsd')) {
            $schemapath = realpath(__DIR__ . '/../../data');
        }

        $roleschema    = $schemapath . '/customrole-2.0.xsd';
        $taskschema    = $schemapath . '/customtask-2.0.xsd';
        $commandschema = $schemapath . '/customcommand-2.0.xsd';

        try {
            foreach (Config::current()->channelregistry as $channel) {
                foreach ($this->listPackages($channel->name) as $package) {
                    $chan = $channel->name;
                    $files = $this->info($package, $chan, 'installedfiles');
                    // each package may only have 1 role, task or command
                    foreach ($files as $path => $info) {
                        switch ($info['role']) {
                            case 'customrole' :
                                $roleinfo = $parser->parse($path, $roleschema);
                                $roleinfo = $roleinfo['role'];
                                static::makeAutoloader($roleinfo, 'role');
                                Installer\Role::registerCustomRole($roleinfo);
                                continue 2;
                            case 'customtask' :
                                $taskinfo = $parser->parse($path, $taskschema);
                                $taskinfo = $taskinfo['task'];
                                static::makeAutoloader($taskinfo, 'task');
                                Task\Common::registerCustomTask($taskinfo);
                                continue 2;
                            case 'customcommand' :
                                $commands = $parser->parse($path, $commandschema);
                                $this->addCommand($commands['commands']['command']);
                                continue 2;
                        }
                    }
                }
            }
        } catch (\Exception $e) {
            Logger::log(0, 'Unable to add all custom roles/tasks/commands: ' . $e);
        }
    }
Exemple #23
0
 /**
  * Load all modules in specified path
  *
  * @param boolean $include_only
  */
 function loadModules($include_only = false)
 {
     global $db_use, $data_path;
     $preload_list = array();
     $normal_list = array();
     if ($db_use) {
         // database available, form module list from database entries
         $manager = ModuleManager::getInstance();
         // get priority module list
         $preload_raw = $manager->getItems($manager->getFieldNames(), array('active' => 1, 'preload' => 1), array('order'));
         // get normal module list
         $normal_raw = $manager->getItems($manager->getFieldNames(), array('active' => 1, 'preload' => 0), array('order'));
         foreach ($preload_raw as $preload_item) {
             $preload_list[] = $preload_item->name;
         }
         foreach ($normal_raw as $normal_item) {
             $normal_list[] = $normal_item->name;
         }
     } else {
         // no database available use system initialization file
         $file = $data_path . 'system_init.xml';
         if (file_exists($file)) {
             $xml = new XMLParser(@file_get_contents($file), $file);
             $xml->Parse();
             foreach ($xml->document->tagChildren as $xml_tag) {
                 if ($xml_tag->tagName == 'module') {
                     $normal_list[] = $xml_tag->tagAttrs['name'];
                 }
             }
         }
     }
     // load modules
     if (count($preload_list) > 0) {
         foreach ($preload_list as $module_name) {
             $this->_loadModule($module_name);
         }
     }
     if (count($normal_list) > 0) {
         if ($include_only) {
             foreach ($normal_list as $module_name) {
                 $this->_includeModule($module_name);
             }
         } else {
             foreach ($normal_list as $module_name) {
                 $this->_loadModule($module_name);
             }
         }
     }
 }
function get_links_from_rss_string($rss)
{
    require_once INCLUDE_PATH . 'xml/xmlparser.php';
    $xml_parse = new XMLParser($rss);
    $xml_parse->Parse();
    $links = array();
    if (isset($xml_parse->document->channel[0]->item)) {
        foreach ($xml_parse->document->channel[0]->item as $k => $item) {
            if (isset($item->link[0]->tagData)) {
                $links[] = trim(str_replace('&amp;', '&', $item->link[0]->tagData));
            }
        }
    }
    return $links;
}
Exemple #25
0
 function doupdate()
 {
     include_once HDWIKI_ROOT . '/lib/xmlparser.class.php';
     $sendversion = base64_encode(serialize(array('v' => HDWIKI_VERSION, 'r' => HDWIKI_RELEASE, 'c' => WIKI_CHARSET, 'u' => WIKI_URL)));
     $xmlfile = "http://kaiyuan.hudong.com/update.php?v={$sendversion}";
     $xmlparser = new XMLParser();
     $xmlnav = $xmlparser->parse($xmlfile);
     $isupdate = $xmlnav[0]['child'][0]['content'];
     $version = $xmlnav[0]['child'][1]['content'];
     $release = $xmlnav[0]['child'][2]['content'];
     $url = $xmlnav[0]['child'][3]['content'];
     $description = $xmlnav[0]['child'][4]['content'];
     $json = '{"isupdate":"' . $isupdate . '","version":"' . $version . '","release":"' . $release . '","url":"' . $url . '","description":"' . $description . '"}';
     echo $json;
 }
 public static function getAllGroupsAndDemos()
 {
     $fname = DIR_DATA . '/game_demos.xml';
     $parser = new XMLParser();
     $a = $parser->parseByFilename($fname);
     $entries = array();
     foreach ($a['game_demos']['group'] as $key => $value) {
         $demos = array();
         foreach ($value['demos']['demo'] as $data) {
             $demos[] = new GameDemo($data);
         }
         $entries[] = array('name' => $value['name'], 'href' => $value['href'], 'demos' => $demos);
     }
     return $entries;
 }
 /**
  * Cast a given value
  *
  * Error codes returned are:
  * <ul>
  *   <li>invalid_chars - if input contains characters not allowed for XML</li>
  *   <li>not_well_formed - if input cannot be parsed to XML</li>
  * </ul>
  *
  * @param   array value
  * @return  string error or array on success
  */
 public function check($value)
 {
     foreach ($value as $v) {
         if (strlen($v) > strcspn($v, Node::XML_ILLEGAL_CHARS)) {
             return 'invalid_chars';
         }
         try {
             $p = new XMLParser();
             $p->parse('<doc>' . $v . '</doc>');
         } catch (XMLFormatException $e) {
             return 'not_well_formed';
         }
     }
     return NULL;
 }
Exemple #28
0
 /**
  * Parse a record's contents into an object
  * @param $contents string
  * @return object
  */
 function &parseContents(&$contents)
 {
     $xmlParser = new XMLParser();
     $result =& $xmlParser->parseText($contents);
     $returner = array();
     $modsNode =& $result->getChildByName(array('oai_mods:mods', 'mods:mods', 'mods'));
     if (!isset($modsNode)) {
         $returner = null;
         return $returner;
     }
     $returner =& $this->handleRootNode($modsNode);
     $result->destroy();
     $xmlParser->destroy();
     return $returner;
 }
 /**
  *
  * @param Mage_Payment_Model_Abstract $payment
  * @param unknown_type $litleResponse
  */
 public function saveCustomerInsight($payment, $litleResponse)
 {
     preg_match('/.*(\\d\\d\\d\\d)/', $payment->getCcNumber(), $matches);
     $last4 = $matches[1];
     $data = array('customer_id' => $payment->getOrder()->getCustomerId(), 'order_number' => XMLParser::getNode($litleResponse, 'orderId'), 'order_id' => $payment->getOrder()->getId(), 'affluence' => self::formatAffluence(XMLParser::getNode($litleResponse, 'affluence')), 'last' => $last4, 'order_amount' => self::formatAvailableBalance($payment->getAmountAuthorized()), 'affluence' => self::formatAffluence(XMLParser::getNode($litleResponse, 'affluence')), 'issuing_country' => XMLParser::getNode($litleResponse, 'issuerCountry'), 'prepaid_card_type' => self::formatPrepaidCardType(XMLParser::getNode($litleResponse, 'prepaidCardType')), 'funding_source' => self::formatFundingSource(XMLParser::getNode($litleResponse, 'type')), 'available_balance' => self::formatAvailableBalance(XMLParser::getNode($litleResponse, 'availableBalance')), 'reloadable' => self::formatReloadable(XMLParser::getNode($litleResponse, 'reloadable')));
     Mage::getModel('palorus/insight')->setData($data)->save();
 }
Exemple #30
0
/**
 * Perform database initialization.
 *
 * @param boolean $create_database
 * @return boolean
 */
function database_initialize($create_database)
{
    global $db, $db_config, $data_path;
    $result = false;
    $database_exists = false;
    $sql_file = 'units/database/init.sql';
    $xml_file = $data_path . 'system_init.xml';
    if (!file_exists($sql_file) || !file_exists($xml_file)) {
        trigger_error('Can not initialize database, missing configuration!', E_USER_ERROR);
        return $result;
    }
    // make a log entry
    trigger_error('Initializing database: ' . $db_config['name'], E_USER_NOTICE);
    // get initialization SQL
    $sql = file_get_contents($sql_file);
    // create database if needed
    if ($create_database) {
        try {
            $db->create($db_config['name']);
            $db->select($db_config['name']);
            $database_exists = true;
        } catch (Exception $error) {
            $database_exists = false;
        }
    } else {
        $database_exists = true;
    }
    // create database
    if ($database_exists && $db->multi_query($sql)) {
        $module_manager = ModuleManager::getInstance();
        $module_handler = ModuleHandler::getInstance();
        $admin_manager = UserManager::getInstance();
        // populate tables
        $raw_data = file_get_contents($xml_file);
        $data = new XMLParser($raw_data, $xml_file);
        $data->parse();
        // go over XML file and insert data
        foreach ($data->document->tagChildren as $item) {
            switch ($item->tagName) {
                case 'module':
                    // insert data
                    $module_manager->insertData(array('name' => $item->tagAttrs['name'], 'order' => $item->tagAttrs['order'], 'preload' => $item->tagAttrs['preload'] == 'yes' ? 1 : 0, 'active' => 1));
                    // initialize module
                    $module = $module_handler->_loadModule($item->tagAttrs['name']);
                    if (!is_null($module)) {
                        $module->onInit();
                    }
                    break;
                case 'user':
                    $salt = hash('sha256', UserManager::SALT . strval(time()));
                    $password = hash_hmac('sha256', $item->tagAttrs['password'], $salt);
                    $admin_manager->insertData(array('username' => $item->tagAttrs['username'], 'password' => $password, 'fullname' => $item->tagAttrs['fullname'], 'level' => $item->tagAttrs['level'], 'verified' => 1, 'salt' => $salt));
                    break;
            }
        }
        // set result
        $result = true;
    }
    return $result;
}