/** ------------------------------------- /** Check and Process XML File /** -------------------------------------*/ function process_xml() { global $DSP, $IN, $LANG; $xml_file = !$IN->GBL('xml_file', 'POST') ? '' : $IN->GBL('xml_file', 'POST'); /** ------------------------------------- /** Check file path /** -------------------------------------*/ if (($exists = $this->check_file($xml_file)) !== TRUE) { return; } /** ------------------------------------- /** Read XML file contents /** -------------------------------------*/ if (function_exists('file_get_contents')) { $contents = file_get_contents($xml_file); } else { $fp = fopen($xml_file, 'r'); $contents = fread($fp, filesize($xml_file)); fclose($fp); } /** ------------------------------------- /** Instantiate EE_XMLparser Class /** -------------------------------------*/ if (!class_exists('EE_XMLparser')) { require PATH_CORE . 'core.xmlparser' . EXT; } $XML = new EE_XMLparser(); // parse XML data $xml = $XML->parse_xml($contents); $this->validate_xml($xml); /** ------------------------------------- /** Show Errors /** -------------------------------------*/ if (count($this->errors) > 0) { $msg = ''; foreach ($this->errors as $error) { foreach ($error as $val) { $msg .= $val . '<br />'; } } return $DSP->error_message($msg); } /** ------------------------------------- /** Ok! Cross Fingers and do it! /** -------------------------------------*/ $imports = $this->do_import(); /** ------------------------------------- /** Begin Output /** -------------------------------------*/ $DSP->title = $LANG->line('xml_imported'); $DSP->crumb = $DSP->anchor($this->crumbbase, $LANG->line('member_import_utility')) . $DSP->crumb_item($LANG->line('xml_imported')); $r = $DSP->qdiv('tableHeading', $LANG->line('import_success')); $r .= $DSP->div('box'); $r .= $DSP->qdiv('itemWrapper', $LANG->line('import_success_blurb')); $r .= $DSP->qdiv('itemWrapper', str_replace('%x', $imports, $LANG->line('total_members_imported'))); $r .= $DSP->div_c(); $DSP->body = $r; }
/** * Takes the control panel home page and adds an update method if needed * * @param string $out The control panel html * @return string The modified control panel html * @since Version 1.0.0 */ function control_panel_home_page($home) { global $EXT, $LOC, $SESS; $updates = ''; $updates_available = FALSE; // -- Check if we're not the only one using this hook if ($EXT->last_call !== FALSE) { $home = $EXT->last_call; } // see if we even need to check for updates if ($this->settings['check_for_updates'] == 'n') { return $home; } if (!class_exists('EE_XMLparser')) { require PATH_CORE . 'core.xmlparser' . EXT; } $XML = new EE_XMLparser(); // valid XML? if (($versions = $XML->parse_xml($this->_get_latest_versions())) === FALSE) { $updates = "<div class='alert'>LG Addon Updater failed. There may be a problem with some of the addon sources.</div>"; } else { foreach ($versions->children as $addon) { $addon_id = $addon->attributes['id']; if (isset($SESS->cache['lg'][LG_AU_addon_id]['addons'][$addon_id]) === TRUE && $addon->attributes['version'] > $SESS->cache['lg'][LG_AU_addon_id]['addons'][$addon_id]) { if ($updates_available === FALSE) { $updates_available = TRUE; $updates = "<div class='alert'>Module / extension / plugin updates available:</div><ul class='alert-list'>"; } $updates .= "<li><a href='" . $addon->attributes['docs_url'] . "'>" . $addon->attributes['id'] . " v" . $addon->attributes['version'] . "</a> <small>Last Updated: " . $LOC->set_human_time($addon->attributes['last_updated']) . "</small></li>"; } } if ($updates_available === TRUE) { $updates .= "</ul><style type='text/css' media='screen'>\n#contentNB > .box:first-child .alert{border-top:1px dotted #CCC9A4; margin-top:3px; padding-top:9px;}\n#contentNB > .box:first-child .alert:first-child{border:none; margin:0; padding:0}\n#contentNB > .box:first-child ul.alert-list{margin-bottom:0}\n</style>"; $home->messages = array_merge($home->messages, array($updates)); } } return $home; }
/** * Fetch data * * Checks cache, gets data, writes cache, returns array of parsed xml * * @access public * @param string * @return mixed */ function _fetch_data($url) { global $TMPL; $cache_expired = FALSE; $url = $this->base_url . $url; // Grab the data if (($rawxml = $this->_check_cache($url)) === FALSE) { $cache_expired = TRUE; $TMPL->log_item("Fetching Github data remotely"); if (function_exists('curl_init')) { $rawxml = $this->_curl_fetch($url); } else { $rawxml = $this->_fsockopen_fetch($url); } } if ($rawxml == '' or substr($rawxml, 0, 5) != "<?xml") { // Attempt to use a stale cache? if ($this->offline_stale_cache) { $rawxml = $this->_check_cache($url, TRUE); } if ($rawxml == '' or substr($rawxml, 0, 5) != "<?xml") { $TMPL->log_item("Github Error: Unable to retrieve data from: " . $url); return FALSE; } // Yucky - stale $TMPL->log_item("Github Stale Cache: " . $url); $cache_expired = FALSE; } // Write the cache file if necessary if ($cache_expired === TRUE) { $this->_write_cache($rawxml, $url); } // Parse the XML if (!class_exists('EE_XMLparser')) { require PATH_CORE . 'core.xmlparser' . EXT; } $XML = new EE_XMLparser(); // valid XML? if (($xml_obj = $XML->parse_xml($rawxml)) === FALSE) { $TMPL->log_item("Github Error: Unable to retrieve data from: " . $url); return FALSE; } // Create array from the xml $github_data = $this->_parse_xml($xml_obj); if (!is_array($github_data) or count($github_data) == 0) { return FALSE; } return $github_data; }