本文整理汇总了PHP中DomDocument::getElementsByTagname方法的典型用法代码示例。如果您正苦于以下问题:PHP DomDocument::getElementsByTagname方法的具体用法?PHP DomDocument::getElementsByTagname怎么用?PHP DomDocument::getElementsByTagname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomDocument
的用法示例。
在下文中一共展示了DomDocument::getElementsByTagname方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse_server_status_XML
function parse_server_status_XML($xml_)
{
if (!$xml_ || strlen($xml_) == 0) {
return false;
}
$dom = new DomDocument('1.0', 'utf-8');
$buf = @$dom->loadXML($xml_);
if (!$buf) {
return false;
}
if (!$dom->hasChildNodes()) {
return false;
}
$node = $dom->getElementsByTagname('server')->item(0);
if (is_null($node)) {
return false;
}
if (!$node->hasAttribute('name')) {
return false;
}
if (!$node->hasAttribute('status')) {
return false;
}
return array('name' => $node->getAttribute('name'), 'status' => $node->getAttribute('status'));
}
示例2: parse_session_status_XML
function parse_session_status_XML($xml_)
{
if (!$xml_ || strlen($xml_) == 0) {
return false;
}
$dom = new DomDocument('1.0', 'utf-8');
$buf = @$dom->loadXML($xml_);
if (!$buf) {
return false;
}
if (!$dom->hasChildNodes()) {
return false;
}
$node = $dom->getElementsByTagname('session')->item(0);
if (is_null($node)) {
return false;
}
if (!$node->hasAttribute('id')) {
return false;
}
if (!$node->hasAttribute('status')) {
return false;
}
$ret = array('id' => $node->getAttribute('id'), 'server' => $_SERVER['REMOTE_ADDR'], 'status' => $node->getAttribute('status'), 'reason' => NULL, 'role' => NULL);
if ($node->hasAttribute('reason')) {
$ret['reason'] = $node->getAttribute('reason');
}
if ($node->hasAttribute('role')) {
$ret['role'] = $node->getAttribute('role');
}
return $ret;
}
示例3: get_login
public function get_login()
{
$buf = $this->prefs->get('AuthMethod', 'Token');
$token_url = $buf['url'];
$user_node_name = $buf['user_node_name'];
$login_attribute_name = $buf['login_attribute_name'];
if (!isset($token_url) or $token_url == '') {
Logger::error('main', 'Token URL is not defined');
return NULL;
}
if (!isset($_REQUEST['token'])) {
Logger::warning('main', 'Missing parameter : token');
return NULL;
}
$token_url = str_replace('%TOKEN%', $_REQUEST['token'], $token_url);
$xml = query_url($token_url);
$dom = new DomDocument('1.0', 'utf-8');
$ret = @$dom->loadXML($xml);
if (!$ret) {
Logger::error('main', 'Token webservice does not send a valid XML');
return NULL;
}
$user_node = $dom->getElementsByTagname($user_node_name)->item(0);
if (!is_object($user_node)) {
Logger::error('main', 'Token webservice does not send a valid XML');
return NULL;
}
if (!$user_node->hasAttribute($login_attribute_name)) {
Logger::error('main', 'Token webservice does not send a valid XML');
return NULL;
}
$this->login = $user_node->getAttribute($login_attribute_name);
return $this->login;
}
示例4: parse_session_dump_XML
function parse_session_dump_XML($xml_)
{
if (!$xml_ || strlen($xml_) == 0) {
return false;
}
$dom = new DomDocument('1.0', 'utf-8');
$buf = @$dom->loadXML($xml_);
if (!$buf) {
return false;
}
if (!$dom->hasChildNodes()) {
return false;
}
$node = $dom->getElementsByTagname('session')->item(0);
if (is_null($node)) {
return false;
}
if (!$node->hasAttribute('id')) {
return false;
}
$ret = array('id' => $node->getAttribute('id'), 'server' => $_SERVER['REMOTE_ADDR'], 'dump' => array());
foreach ($dom->getElementsByTagname('dump') as $node) {
if (!$node->hasAttribute('name')) {
return false;
}
$name = $node->getAttribute('name');
$textNode = null;
foreach ($node->childNodes as $child_node) {
if ($child_node->nodeType != XML_TEXT_NODE) {
continue;
}
$textNode = $child_node;
break;
}
if ($textNode === null) {
return false;
}
$ret['dump'][$name] = trim($textNode->wholeText);
}
return $ret;
}
示例5: getApplications
function getApplications($user)
{
$socket = curl_init('https://' . ULTEO_OVD_SM_HOST . '/ovd/client/applications?user=' . $user);
/*?token=token');*/
curl_setopt($socket, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($socket, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($socket, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($socket, CURLOPT_TIMEOUT, 15 + 5);
curl_setopt($socket, CURLOPT_SSL_VERIFYHOST, 1);
$data = curl_exec($socket);
$code = curl_getinfo($socket, CURLINFO_HTTP_CODE);
$content_type = curl_getinfo($socket, CURLINFO_CONTENT_TYPE);
curl_close($socket);
if ($code != 200) {
$_SESSION['error'] = 'Unable to talk to sm';
return false;
}
if (strpos($content_type, 'text/xml') === FALSE) {
$_SESSION['error'] = 'invalid returned format';
return false;
}
$dom = new DomDocument('1.0', 'utf-8');
$ret = @$dom->loadXML($data);
if (!$ret) {
$_SESSION['error'] = 'invalid returned format';
return false;
}
if ($dom->documentElement->nodeName != 'user') {
$_SESSION['error'] = 'authentication issue';
return false;
}
$apps = array();
foreach ($dom->getElementsByTagname('application') as $app_node) {
$app = array();
$app['id'] = $app_node->getAttribute('id');
$app['name'] = $app_node->getAttribute('name');
$app['mimetypes'] = array();
foreach ($app_node->getElementsByTagname('mime') as $mime_node) {
$app['mimetypes'][] = $mime_node->getAttribute('type');
}
$apps[$app['id']] = $app;
}
return $apps;
}
示例6: parse_premium_sign_XML
function parse_premium_sign_XML($xml_)
{
if (!$xml_ || strlen($xml_) == 0) {
return false;
}
$dom = new DomDocument('1.0', 'utf-8');
$buf = @$dom->loadXML($xml_);
if (!$buf) {
return false;
}
if (!$dom->hasChildNodes()) {
return false;
}
$node = $dom->getElementsByTagname('message')->item(0);
if (is_null($node)) {
return false;
}
return $node->textContent;
}
示例7: init_saml2_auth
function init_saml2_auth()
{
global $sessionmanager_url;
$sm = new SessionManager($sessionmanager_url);
$ret = $sm->query('auth_params');
$dom = new DomDocument('1.0', 'utf-8');
$buf = @$dom->loadXML($ret);
if (!$buf) {
send_error("Unable to retrieve the SAML parameters");
}
if (!$dom->hasChildNodes()) {
send_error("Unable to retrieve the SAML parameters");
}
$saml2 = $dom->getElementsByTagname('SAML2')->item(0);
$url = $saml2->getElementsByTagname('idp_url')->item(0)->textContent;
$fingerprint = $saml2->getElementsByTagname('idp_fingerprint')->item(0)->textContent;
$cert = $saml2->getElementsByTagname('idp_cert')->item(0)->textContent;
$settings = build_saml_settings($url, $fingerprint, $cert);
return new OneLogin_Saml2_Auth($settings);
}
示例8: parse_logout_XML
function parse_logout_XML($xml_, &$mode_)
{
if (!$xml_ || strlen($xml_) == 0) {
return false;
}
$dom = new DomDocument('1.0', 'utf-8');
$buf = @$dom->loadXML($xml_);
if (!$buf) {
return false;
}
if (!$dom->hasChildNodes()) {
return false;
}
$node = $dom->getElementsByTagname('logout')->item(0);
if (is_null($node)) {
return false;
}
if ($node->hasAttribute('mode')) {
$mode_ = $node->getAttribute('mode');
}
return true;
}
示例9: validateAccess
function validateAccess($action_required, $rol_required)
{
// Abrir el archivo XML de permisos
$dom = new DomDocument();
$dom->load(realpath(".") . '/' . PERMISSION_FILE);
// Levantar los tags de permisos y buscar la accion
$permisos = $dom->getElementsByTagname("permiso");
foreach ($permisos as $permiso) {
// Busco el nombre de la accion
$accion = $permiso->getElementsByTagname("accion")->item(0)->firstChild->data;
if ($accion == $action_required) {
// Busco los roles
$roles = $permiso->getElementsByTagname("rol");
// Para recorrer los roles que tienen permiso para la accion
foreach ($roles as $rol) {
if ($rol->firstChild->data == $rol_required) {
return true;
}
}
}
}
// No se encontro el rol para la accion
return false;
}
示例10: loadConfigurationFromXml
/**
* Carga en $this->_actions el archivo de configuraci�n. La configuraci�n se obtiene del archivo indicado en _config_file
*
* @access private
* @return void
*/
function loadConfigurationFromXml()
{
// Abrir el archivo XML y obtener el root
$dom = new DomDocument();
$dom->load(realpath(".") . '/' . $this->_config_file);
// Procesar el default (es un solo elemento)
$defaults = $dom->getElementsByTagname("default");
foreach ($defaults as $default) {
// Nombre de la acci�n
$nombre = $default->getElementsByTagname('nombre')->item(0)->firstChild->data;
// Front de la aplicacion
$front = $default->getElementsByTagname('front')->item(0)->firstChild->data;
}
// Guardar los defaults
$this->_defaults['nombre'] = $nombre;
$this->_defaults['front'] = $front;
// Procesar las acciones
$acciones = $dom->getElementsByTagname("accion");
foreach ($acciones as $accion) {
// Nombre de la acci�n
$nombre = $accion->getElementsByTagname('nombre')->item(0)->firstChild->data;
// Link de la acci�n
$link = $accion->getElementsByTagname('link')->item(0)->firstChild->data;
// Nombre del m�dulo
$modulo = $accion->getElementsByTagname('modulo')->item(0)->firstChild->data;
// Nombre de la clase
$clase = $accion->getElementsByTagname('clase')->item(0)->firstChild->data;
// Indexar las acciones por el link
$this->_actions_link[$link] = array('nombre' => $nombre, 'link' => $link, 'modulo' => $modulo, 'clase' => $clase);
// Indexar las acciones por el nombre
$this->_actions_name[$nombre] = array('nombre' => $nombre, 'link' => $link, 'modulo' => $modulo, 'clase' => $clase);
}
}
示例11: DomDocument
$applications_node->appendChild($application_node);
}
$session_node->appendChild($applications_node);
$dom->appendChild($session_node);
$sessionManagement->appendToSessionCreateXML($dom);
$xml = $dom->saveXML();
$ret_xml = query_url_post_xml($server->getBaseURL() . '/webapps/session/create', $xml);
$ret = $sessionManagement->parseSessionCreate($ret_xml);
if (!$ret) {
Logger::critical('main', '(client/start) Unable to create Session \'' . $session->id . '\' for User \'' . $session->user_login . '\' on Server \'' . $server->fqdn . '\', aborting');
$session->orderDeletion(true, Session::SESSION_END_STATUS_ERROR);
throw_response(INTERNAL_ERROR);
}
$ret_dom = new DomDocument('1.0', 'utf-8');
$ret_buf = @$ret_dom->loadXML($ret_xml);
$node = $ret_dom->getElementsByTagname('session')->item(0);
$webapps_url = $node->getAttribute('webapps-scheme') . '://' . $server->getExternalName() . ':' . $node->getAttribute('webapps-port');
$session->settings['webapps-url'] = $webapps_url;
}
//
$session->setStatus(Session::SESSION_STATUS_READY);
Logger::info('main', '(client/start) Resuming session for ' . $user->getAttribute('login') . ' (' . $old_session_id . ' => ' . $session->server . ')');
} else {
if (!$sessionManagement->generateCredentials()) {
Logger::error('main', '(client/start) Unable to generate access credentials for User "' . $user->getAttribute('login') . '", aborting');
throw_response(SERVICE_NOT_AVAILABLE);
}
if (array_key_exists(Server::SERVER_ROLE_APS, $sessionManagement->credentials)) {
$user_login_aps = $sessionManagement->credentials[Server::SERVER_ROLE_APS]['login'];
$user_password_aps = $sessionManagement->credentials[Server::SERVER_ROLE_APS]['password'];
}
示例12: print_error
function print_error($errno)
{
$dom = new DomDocument('1.0', 'utf-8');
$node = $dom->createElement('ajaxplorer');
$node->setAttribute('status', 'error');
$node->setAttribute('error', $errno);
$dom->appendChild($node);
return $dom->saveXML();
}
$input = file_get_contents('php://input');
$xml = new DomDocument('1.0', 'utf-8');
if (!$xml->loadXML($input)) {
echo print_error(0);
die;
}
$session_node = $xml->getElementsByTagname('session')->item(0);
if (!$session_node) {
echo print_error(1);
die;
}
$aj = new Ajaxplorer($session_node);
$use_explorer = $aj->can_run() && $aj->is_required();
if ($use_explorer === true) {
$_SESSION['ovd-client']['ajxp'] = $aj->build_data();
} else {
echo print_error(2);
die;
}
$dom = new DomDocument('1.0', 'utf-8');
$node = $dom->createElement('ajaxplorer');
$node->setAttribute('status', 'ok');
示例13: getDatasourcesFromXml
/**
* Carga todas las conexiones registradas en el archivo de configurci�n XML
* @access private
* @static
* @return void
*/
static function getDatasourcesFromXml()
{
$_datasources = array();
// Abrir el archivo XML y obtener el root
$dom = new DomDocument();
$dom->load(CONFIG . DATASOURCES_FILE);
// Procesar cada uno de los datasources
$datasources = $dom->getElementsByTagname("datasource");
foreach ($datasources as $datasource) {
// Name
$name = $datasource->getElementsByTagname('name')->item(0)->firstChild->data;
// Base
$base = $datasource->getElementsByTagname('base')->item(0)->firstChild->data;
// Hostname
$hostname = $datasource->getElementsByTagname('hostname')->item(0)->firstChild;
if ($hostname != null) {
$hostname = $hostname->data;
}
// Driver
$driver = $datasource->getElementsByTagname('driver')->item(0)->firstChild->data;
// Username
$username = $datasource->getElementsByTagname('username')->item(0)->firstChild;
if ($username != null) {
$username = $username->data;
}
// Password
$password = $datasource->getElementsByTagname('password')->item(0)->firstChild;
if ($password != null) {
$password = $password->data;
}
// Port
$port = $datasource->getElementsByTagname('port')->item(0)->firstChild;
if ($port != null) {
$port = $port->data;
}
// Indexar los datasources
$_datasources[$name] = array('name' => $name, 'base' => $base, 'hostname' => $hostname, 'driver' => $driver, 'username' => $username, 'password' => $password, 'port' => $port);
}
return $_datasources;
}
示例14: get_users_list
function get_users_list()
{
if (!defined('SESSIONMANAGER_HOST')) {
return false;
}
global $sessionmanager_url;
$sm = new SessionManager($sessionmanager_url);
$ret = $sm->query('userlist');
$dom = new DomDocument('1.0', 'utf-8');
$buf = @$dom->loadXML($ret);
if (!$buf) {
return false;
}
if (!$dom->hasChildNodes()) {
return false;
}
$users_node = $dom->getElementsByTagname('users')->item(0);
if (is_null($users_node)) {
return false;
}
$users = array();
foreach ($users_node->childNodes as $user_node) {
if ($user_node->hasAttribute('login')) {
$users[$user_node->getAttribute('login')] = strlen($user_node->getAttribute('displayname')) > 32 ? substr($user_node->getAttribute('displayname'), 0, 32) . '...' : $user_node->getAttribute('displayname');
}
}
natcasesort($users);
if (count($users) == 0) {
return false;
}
return $users;
}
示例15: refresh
public function refresh()
{
$server = Abstract_Server::load($this->server);
if (!is_object($server)) {
Logger::error('apt-get', 'TASK::refresh for task ' . $this->id . ' returned an error (unknown server ' . $this->server . ')');
return false;
}
$xml = query_url($server->getBaseURL() . '/aps/debian/' . $this->job_id . '/status');
if (!$xml) {
Logger::error('apt-get', 'TASK::refresh for task ' . $this->id . ' on server ' . $this->server . ' returned an error');
$this->status = 'error';
return true;
}
$dom = new DomDocument('1.0', 'utf-8');
$buf = @$dom->loadXML($xml);
if (!$buf) {
return false;
}
if (!$dom->hasChildNodes()) {
return false;
}
$node = $dom->getElementsByTagname('debian_request')->item(0);
if (is_null($node)) {
return false;
}
$this->status = $node->getAttribute('status');
$ret = true;
switch ($this->status) {
case 'created':
Logger::warning('apt-get', 'TASK::refresh for task ' . $this->id . ' on server ' . $this->server . ' is created');
$ret = false;
break;
case 'in progress':
Logger::warning('apt-get', 'TASK::refresh for task ' . $this->id . ' on server ' . $this->server . ' is in progress');
$ret = false;
break;
case 'success':
Logger::info('apt-get', 'TASK::refresh for task ' . $this->id . ' on server ' . $this->server . ' is now finished');
$this->t_end = time();
$server->updateApplications();
$ret = true;
break;
case 'error':
Logger::error('apt-get', 'TASK::refresh for task ' . $this->id . ' on server ' . $this->server . ' returned an error');
$ret = true;
break;
}
return $ret;
}