示例#1
1
/**
 * Search for a tag within an XML DOMDocument
 *
 * @param  stdClass $tagname The name of the tag to search for
 * @param  XPath    $xpath   The XML to find the tag in
 * @param  XPath    $attribute The attribute to search for (if we should search for a child node with the given
 * value for the name attribute
 * @since Moodle 3.1
 */
function get_tag($tagname, $xpath, $attribute = null)
{
    if ($attribute) {
        $result = $xpath->query('//*[local-name() = \'' . $tagname . '\'][@name="' . $attribute . '"]');
    } else {
        $result = $xpath->query('//*[local-name() = \'' . $tagname . '\']');
    }
    if ($result->length > 0) {
        return $result->item(0)->nodeValue;
    }
    return null;
}
 /**
  * Unmarshall a XML diagram file into an object structure (DiaDiagram)
  *
  * @param   string filename The diagram filename (.dia)
  * @return  org.dia.DiaDiagram
  */
 public static function unmarshal($diagram)
 {
     // suck in XML document
     if (!($dom = domxml_open_file($diagram, DOMXML_LOAD_PARSING, $error))) {
         throw new XMLFormatException(xp::stringOf($error));
     }
     // initialize XPath
     $XPath = new XPath($dom);
     // TODO: if the URI is wrong, unmarshalling won't work!
     $XPath->registerNamespace('dia', 'http://www.lysator.liu.se/~alla/dia/');
     // new (unused): $XPath->registerNamespace('dia', 'http://www.gnome.org/projects/dia/');
     // go
     $Dia = DiaUnmarshaller::recurse($XPath, $dom->document_element(), 'org.dia.DiaDiagram');
     Console::writeLine('DiaUnmarshaller used up ' . round(memory_get_usage() / 1024, 2) . ' Kb of memory.');
     return $Dia;
 }
 function Auth_Textcube_xmlparser()
 {
     $this->ns = array();
     $xmlOptions = array(XML_OPTION_CASE_FOLDING => false, XML_OPTION_SKIP_WHITE => TRUE);
     parent::XPath(FALSE, $xmlOptions);
     $this->bDebugXmlParse = false;
 }
示例#4
0
function GetFrameSrc($bookid, $chapterid)
{
    global $http;
    $uri = sprintf('http://www.ysts8.com/down_%d_%d_%d_%d.html', $bookid, (int) ($chapterid / 100000), (int) ($chapterid / 10000) % 10, (int) ($chapterid % 10000));
    //$html = http_proxy_get($uri, "Ysjs/bot.js", 10);
    $html = $http->get($uri);
    $html = str_replace("text/html; charset=gb2312", "text/html; charset=gb18030", $html);
    if (strlen($html) < 1) {
        return "";
    }
    $xpath = new XPath($html);
    $src = $xpath->get_attribute("//iframe[1]", "src");
    // "/play/flv.asp?url=http%3A%2F%2F180e%2Eysx8%2Enet%3A8000%2F%D0%FE%BB%C3%D0%A1%CB%B5%2F2009%2F%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB%2F%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB003%2Emp3&jiidx=/play%5F1836%5F49%5F1%5F4%2Ehtml&jiids=/play%5F1836%5F49%5F1%5F2%2Ehtml&id=1836&said=49"
    // "/play/flv_down.asp?wtid=http%3A%2F%2F180e%2Dd%2Eysts8%2Ecom%3A8000%2F%D0%FE%BB%C3%D0%A1%CB%B5%2F2009%2F%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB%2F%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB001%2Emp3&ctid=http%3A%2F%2F163e%2Dd%2Eysts8%2Ecom%3A8000%2F%D0%FE%BB%C3%D0%A1%CB%B5%2F2009%2F%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB%2F%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB001%2Emp3&title=%B7%B2%C8%CB%D0%DE%CF%C9%B4%AB&ji=1&id=1836&said=49"
    return "http://www.ysts8.com" . $src;
}
示例#5
0
function scrapeImdb($url)
{
    $baseurl = "http://www.imdb.com";
    $array = array();
    $xpath = new XPath($url);
    $imgsrcQuery = $xpath->query("//td[@class='image']//img/@src");
    $imgtitleQuery = $xpath->query("//td[@class='image']//img/@title");
    $linktitleQuery = $xpath->query("//td[@class='title']/a/text()");
    $linkhrefQuery = $xpath->query("//td[@class='title']/a/@href");
    $fh = fopen("imdb.txt", "a++");
    for ($x = 0; $x < $linkhrefQuery->length; $x++) {
        $string = $array[$x]['imageTitle'] = $imgtitleQuery->item($x)->nodeValue . "*";
        $string .= $array[$x]['imageSource'] = $imgsrcQuery->item($x)->nodeValue . "*";
        $string .= $array[$x]['linkTitle'] = $linktitleQuery->item($x)->nodeValue . "*";
        $string .= $array[$x]['linkHref'] = $baseurl . $linkhrefQuery->item($x)->nodeValue . "*";
        $string .= fwrite($fh, $string . "\n\n\n\n");
        /*$array[$x]['imageTitle'] = $imgtitleQuery->item($x)->nodeValue;
        $array[$x]['imageSource'] = $imgsrcQuery->item($x)->nodeValue;
        $array[$x]['linkTitle'] = $linktitleQuery->item($x)->nodeValue;
        $array[$x]['linkHref'] = $baseurl . $linkhrefQuery->item($x)->nodeValue;
        */
    }
    fclose($fh);
    // check for the "Next" link
    $nextPageQuery = $xpath->query("(//span[@class='pagination']/a[contains(., 'Next')])[1]/@href");
    if ($nextPageQuery->length) {
        $nextUrl = $baseurl . $nextPageQuery->item(0)->nodeValue;
        //	$array = array_merge($array, scrapeImdb($nextUrl)); // merging the array and recursively calling the function
        scrapeImdb($nextUrl);
    }
    return $array;
}
 /**
  * Funktion zum generieren von einem RSS 2.0 feed
  */
 function generateRSS($ype = "html")
 {
     //Einf�gen des Basiswertes
     include_once "lib/XPath/XPath.class.php";
     include_once "ext/blog/blog.class.php";
     $xml = new XPath();
     $xml->importFromString($this->prepareXML());
     //Konfiguration einf�gen
     foreach ($this->config['rss'] as $key => $value) {
         if (!empty($value)) {
             $data = "\n<{$key}>{$value}</{$key}>\n";
             $xml->appendChild("/rss[1]/channel[1]", $data);
         }
     }
     //So nun die letzten 10 Eintr�ge aus dem Blog einf�gen
     $blog = new weblog($this->blog);
     $entryArray = $blog->getLastXEntries(10);
     foreach ($entryArray as $entry) {
         $item = "\n<item>\n                        <title>" . $entry['attributes']['title'] . "</title>\n                        <link>http://www.grundprinzip.de/blog/single/" . $entry['number'] . ".html</link>\n                        <author>" . $entry['attributes']['mail'] . "</author>\n                        <category>" . $entry['attributes']['category'] . "</category>\n                        <description>" . $entry['teaser'] . "</description>\n                        </item>\n";
         $xml->appendChild("/rss[1]/channel[1]", $item);
     }
     return $xml->exportAsXml();
 }
示例#7
0
/**
 * generates the category menu from the menu data
 * of directory.xml
 */
function menuFromXml($xmlData, $catdir)
{
    $html = "";
    $subdir = substr($catdir, strlen("content/"));
    $xmlParser = new XPath();
    $xmlParser->importFromString($xmlData);
    $i = 1;
    while ($xmlParser->match("/menu[1]/item[{$i}]")) {
        $html .= "<span class=\"menu\">\n";
        if ($xmlParser->match("/menu[1]/item[{$i}]/file[1]")) {
            $filename = $xmlParser->getData("/menu[1]/item[{$i}]/file[1]");
            $title = getTitle($catdir . "/" . $filename);
            $link = $subdir . "/" . $filename;
            $html .= "<a href=\"index.php?p={$link}\">{$title}</a>\n";
        } elseif ($xmlParser->match("/menu[1]/item[{$i}]/raw_data[1]")) {
            $data = $xmlParser->exportAsXml("/menu[1]/item[{$i}]/raw_data[1]");
            $data = stripTag("raw_data", $data);
            $html .= $data;
        }
        $html .= "</span>\n";
        $i++;
    }
    return $html;
}
示例#8
0
function __ParseChapter($html)
{
    $chapters = array();
    $html = str_replace("text/html; charset=gb2312", "text/html; charset=gb18030", $html);
    if (strlen($html) < 1) {
        return $chapters;
    }
    $xpath = new XPath($html);
    $elements = $xpath->query("//li[@class='a1']/a");
    foreach ($elements as $element) {
        $href = $element->getattribute('href');
        $chapter = $element->nodeValue;
        if (strlen($href) > 0 && strlen($chapter) > 0) {
            list($play, $chapterid) = explode("_", basename($href, ".html"));
            $chapters[] = array("name" => $chapter, "uri" => $chapterid);
        }
    }
    return $chapters;
}
示例#9
0
         return "";
     } else {
         global $webpath;
         $textdir = direction();
         $t = new Template(APP_ROOT . '/templates/' . TEMPLATE_SET);
         $t->set_file(array('box' => 'box.tpl'));
         $t->set_var('title', $title);
         $t->set_var('content', $content);
         $t->set_var('webpath', $webpath);
         $t->set_var('text_dir', $textdir['direction']);
         return $t->parse('out', 'box');
     }
 }
 // Fire off the XPath class
 require_once APP_ROOT . '/includes/XPath.class.php';
 $XPath = new XPath();
 $XPath->importFromString($xml);
 // let the page begin.
 require_once APP_ROOT . '/includes/system_header.php';
 $tpl->set_var('title', $text['title'] . ': ' . $XPath->getData('/phpsysinfo/Vitals/Hostname') . ' (' . $XPath->getData('/phpsysinfo/Vitals/IPAddr') . ')');
 $tpl->set_var('vitals', makebox($text['vitals'], html_vitals()));
 $tpl->set_var('network', makebox($text['netusage'], html_network()));
 $tpl->set_var('hardware', makebox($text['hardware'], html_hardware()));
 $tpl->set_var('memory', makebox($text['memusage'], html_memory()));
 $tpl->set_var('filesystems', makebox($text['fs'], html_filesystems()));
 // Timo van Roermund: change the condition for showing the temperature, voltage and fans section
 $html_temp = "";
 if (!empty($sensor_program)) {
     if ($XPath->match("/phpsysinfo/MBinfo/Temperature/Item")) {
         $html_temp = html_mbtemp();
     }
function sysinfo_generarinfo()
{
    // phpSysInfo - A PHP System Information Script
    // http://phpsysinfo.sourceforge.net/
    // This program is free software; you can redistribute it and/or
    // modify it under the terms of the GNU General Public License
    // as published by the Free Software Foundation; either version 2
    // of the License, or (at your option) any later version.
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    // You should have received a copy of the GNU General Public License
    // along with this program; if not, write to the Free Software
    // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    // $Id: index.php 2 2004-08-20 14:21:01Z root $
    // our version number
    global $sysinfo;
    global $XPath;
    global $text;
    $VERSION = "2.3-cvs";
    define('APP_ROOT', dirname(__FILE__));
    set_magic_quotes_runtime(0);
    if (!file_exists(APP_ROOT . '/config.php')) {
        echo '<center><b>Error: config.php does not exist.</b></center>';
        exit;
    }
    require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/config.php';
    // get the config file
    if (!extension_loaded('xml')) {
        echo '<center><b>Error: phpsysinfo requires xml module.</b></center>';
        exit;
    }
    // reassign HTTP variables (incase register_globals is off)
    if (!empty($HTTP_GET_VARS)) {
        while (list($name, $value) = each($HTTP_GET_VARS)) {
            ${$name} = $value;
        }
    }
    if (!empty($HTTP_POST_VARS)) {
        while (list($name, $value) = each($HTTP_POST_VARS)) {
            ${$name} = $value;
        }
    }
    // Check to see if where running inside of phpGroupWare
    if (isset($sessionid) && $sessionid && $kp3 && $domain) {
        define('PHPGROUPWARE', 1);
        $phpgw_info['flags'] = array('currentapp' => 'phpsysinfo-dev');
        include '../header.inc.php';
    } else {
        define('PHPGROUPWARE', 0);
    }
    if (!isset($template)) {
        $template = $_COOKIE['template'];
    }
    if (!isset($template)) {
        $template = 'classic';
    }
    // check to see if we have a random template first
    if ($template == 'random') {
        $dir = opendir('templates/');
        while (($file = readdir($dir)) != false) {
            if ($file != 'CVS' && $file != '.' && $file != '..') {
                $buf[] = $file;
            }
        }
        $template = $buf[array_rand($buf, 1)];
        $random = true;
    }
    if ($template != 'xml') {
        $template = basename(APP_ROOT . '/templates/' . $template);
        // figure out if we got a template passed in the url
        if (!file_exists(APP_ROOT . "/templates/{$template}")) {
            // default template we should use if we don't get a argument.
            $template = 'classic';
        }
    }
    define('TEMPLATE_SET', $template);
    // get our current language
    // default to english, but this is negotiable.
    if (!isset($lng)) {
        $lng = $_COOKIE['lng'];
    }
    if (!isset($lng)) {
        $lng = 'es';
    }
    $lng = basename(APP_ROOT . '/includes/lang/' . $lng . '.php', '.php');
    if (!file_exists(APP_ROOT . '/includes/lang/' . $lng . '.php')) {
        // see if the browser knows the right languange.
        if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
            $plng = split(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
            if (count($plng) > 0) {
                while (list($k, $v) = each($plng)) {
                    $k = split(';', $v, 1);
                    $k = split('-', $k[0]);
                    if (file_exists(APP_ROOT . '/includes/lang/' . $k[0] . '.php')) {
                        $lng = $k[0];
                        break;
                    }
                }
            }
        }
    }
    require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/lang/' . $lng . '.php';
    // get our language include
    // Figure out which OS where running on, and detect support
    if (file_exists(APP_ROOT . '/includes/os/class.' . PHP_OS . '.inc.php')) {
        require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/os/class.' . PHP_OS . '.inc.php';
        $sysinfo = new sysinfo();
    } else {
        echo '<center><b>Error: ' . PHP_OS . ' is not currently supported</b></center>';
        exit;
    }
    if (!empty($sensor_program)) {
        if (file_exists(APP_ROOT . '/includes/mb/class.' . $sensor_program . '.inc.php')) {
            require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/mb/class.' . $sensor_program . '.inc.php';
            $mbinfo = new mbinfo();
        } else {
            echo '<center><b>Error: ' . $sensor_program . ' is not currently supported</b></center>';
            exit;
        }
    }
    require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/common_functions.php';
    // Set of common functions used through out the app
    require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/xml/vitals.php';
    require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/xml/network.php';
    require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/xml/hardware.php';
    require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/xml/memory.php';
    require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/xml/filesystems.php';
    require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/xml/mbinfo.php';
    $xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
    $xml .= "<!DOCTYPE phpsysinfo SYSTEM \"" . _CFG_INTERFACE_DIRMODULES . "mod_sysinfo/phpsysinfo.dtd\">\n\n";
    $xml .= created_by();
    $xml .= "<phpsysinfo>\n";
    $xml .= "  <Generation version=\"{$VERSION}\" timestamp=\"" . time() . "\"/>\n";
    $xml .= xml_vitals();
    $xml .= xml_network();
    $xml .= xml_hardware();
    $xml .= xml_memory();
    $xml .= xml_filesystems();
    if (!empty($sensor_program)) {
        $xml .= xml_mbtemp();
        $xml .= xml_mbfans();
        $xml .= xml_mbvoltage();
    }
    $xml .= "</phpsysinfo>";
    if ($template == 'xml') {
        // just printout the XML and exit
        Header("Content-Type: text/xml\n\n");
        print $xml;
    } else {
        // If they have GD complied into PHP, find out the height of the image to make this cleaner
        if (function_exists('getimagesize') && $template != 'xml') {
            $image_prop = getimagesize(APP_ROOT . '/templates/' . TEMPLATE_SET . '/images/bar_middle.gif');
            define('BAR_HEIGHT', $image_prop[1]);
            unset($image_prop);
        } else {
            // Until they complie GD into PHP, this could look ugly
            define('BAR_HEIGHT', 16);
        }
        // Store the current template name in a cookie, set expire date to one month later
        // Store 'random' if we want a random template
        if ($random) {
            setcookie("template", 'random', time() + 60 * 60 * 24 * 30);
        } else {
            setcookie("template", $template, time() + 60 * 60 * 24 * 30);
        }
        // Store the current language selection in a cookie
        setcookie("lng", $lng, time() + 60 * 60 * 24 * 30);
        if (PHPGROUPWARE != 1) {
            require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/class.Template.inc.php';
            // template library
        }
        // fire up the template engine
        $tpl = new Template(dirname(__FILE__) . '/templates/' . TEMPLATE_SET);
        $tpl->set_file(array('form' => 'form.tpl'));
        // print out a box of information
        function makebox($title, $content, $percent)
        {
            $t = new Template(dirname(__FILE__) . '/templates/' . TEMPLATE_SET);
            $t->set_file(array('box' => 'box.tpl'));
            $t->set_var('title', $title);
            $t->set_var('content', $content);
            if (empty($content)) {
                return '';
            } else {
                return $t->parse('out', 'box');
            }
        }
        // Fire off the XPath class
        require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/XPath.class.php';
        $XPath = new XPath();
        $XPath->importFromString($xml);
        // let the page begin.
        require _CFG_INTERFACE_DIRMODULES . 'mod_sysinfo/includes/system_header.php';
        $tpl->set_var('title', $text['title'] . ': ' . $XPath->getData('/phpsysinfo/Vitals/Hostname') . ' (' . $XPath->getData('/phpsysinfo/Vitals/IPAddr') . ')');
        $tpl->set_var('vitals', makebox($text['vitals'], html_vitals(), '100%'));
        $tpl->set_var('network', makebox($text['netusage'], html_network(), '100%'));
        $tpl->set_var('hardware', makebox($text['hardware'], html_hardware(), '100%'));
        $tpl->set_var('memory', makebox($text['memusage'], html_memory(), '100%'));
        $tpl->set_var('filesystems', makebox($text['fs'], html_filesystems(), '100%'));
        if (!empty($sensor_program)) {
            $tpl->set_var('mbtemp', makebox($text['temperature'], html_mbtemp(), '100%'));
            $tpl->set_var('mbfans', makebox($text['fans'], html_mbfans(), '100%'));
            $tpl->set_var('mbvoltage', makebox($text['voltage'], html_mbvoltage(), '100%'));
        } else {
            $tpl->set_var('mbtemp', '');
            $tpl->set_var('mbfans', '');
            $tpl->set_var('mbvoltage', '');
        }
        // parse our the template
        return $tpl->pparse('out', 'form');
        // finally our print our footer
        /*  if (PHPGROUPWARE == 1) {
            $phpgw->common->phpgw_footer();
          } else {
            require(_CFG_INTERFACE_DIRMODULES.'mod_sysinfo/includes/system_footer.php');
          }
        */
    }
}
示例#11
0
$self = isset($_SERVER) ? $_SERVER['PHP_SELF'] : $PHP_SELF;
if (basename($self) == 'XPath.class.php') {
    // The sampe source:
    $q = '?';
    $xmlSource = <<<EOD
  <{$q}Process_Instruction test="&copy;&nbsp;All right reserved" {$q}>
    <AAA foo="bar"> ,,1,,
      ..1.. <![CDATA[ bla  bla
      newLine blo blo ]]>
      <BBB foo="bar">
        ..2..
      </BBB>..3..<CC/>   ..4..</AAA>
EOD;
    // The sample code:
    $xmlOptions = array(XML_OPTION_CASE_FOLDING => TRUE, XML_OPTION_SKIP_WHITE => TRUE);
    $xPath = new XPath(FALSE, $xmlOptions);
    //$xPath->bDebugXmlParse = TRUE;
    if (!$xPath->importFromString($xmlSource)) {
        echo $xPath->getLastError();
        exit;
    }
    _title("Following was imported:");
    echo $xPath->exportAsHtml();
    _title("Get some content");
    echo "Last text part in &lt;AAA&gt;: '" . $xPath->wholeText('/AAA[1]', -1) . "'<br>\n";
    echo "All the text in  &lt;AAA&gt;: '" . $xPath->wholeText('/AAA[1]') . "'<br>\n";
    echo "The attibute value  in  &lt;BBB&gt; using getAttributes('/AAA[1]/BBB[1]', 'FOO'): '" . $xPath->getAttributes('/AAA[1]', 'FOO') . "'<br>\n";
    echo "The attibute value  in  &lt;BBB&gt; using getData('/AAA[1]/@FOO'): '" . $xPath->getData('/AAA[1]/@FOO') . "'<br>\n";
    _title("Append some additional XML below /AAA/BBB:");
    $xPath->appendChild('/AAA[1]/BBB[1]', '<CCC> Step 1. Append new node </CCC>', $afterText = FALSE);
    $xPath->appendChild('/AAA[1]/BBB[1]', '<CCC> Step 2. Append new node </CCC>', $afterText = TRUE);
示例#12
0
 public function queryTreeWithDefaultEncoding()
 {
     $value = new String('value öäü', 'utf-8');
     $xpath = new XPath($s = sprintf('<document><node>%s</node></document>', $value->getBytes('utf-8')));
     $this->assertEquals($value, new String($xpath->query('string(/document/node)'), 'utf-8'));
 }
示例#13
0
 function GetCatalogUrls($uri)
 {
     $html = $this->http->get($uri, "Ysjs/bot.js");
     $html = str_replace("text/html; charset=gb2312", "text/html; charset=gb18030", $html);
     $xpath = new XPath($html);
     $options = $xpath->query("//select[@name='select']/option");
     $urls = array();
     foreach ($options as $option) {
         $href = $option->getattribute('value');
         if (strlen($href) < 1) {
             continue;
         }
         $urls[] = dirname($uri) . '/' . $href;
     }
     return $urls;
 }
示例#14
0
         return "";
     } else {
         global $webpath;
         $textdir = direction();
         $t = new Template(APP_ROOT . '/templates/' . TEMPLATE_SET);
         $t->set_file(array('box' => 'box.tpl'));
         $t->set_var('title', $title);
         $t->set_var('content', $content);
         $t->set_var('webpath', $webpath);
         $t->set_var('text_dir', $textdir['direction']);
         return $t->parse('out', 'box');
     }
 }
 // Fire off the XPath class
 require_once APP_ROOT . '/includes/XPath.class.php';
 $XPath = new XPath();
 $XPath->importFromString($xml);
 // let the page begin.
 require_once APP_ROOT . '/includes/system_header.php';
 $tpl->set_var('vitals', makebox($text['vitals'], html_vitals()));
 $tpl->set_var('network', makebox($text['netusage'], html_network()));
 $tpl->set_var('hardware', makebox($text['hardware'], html_hardware()));
 $tpl->set_var('memory', makebox($text['memusage'], html_memory()));
 $tpl->set_var('filesystems', makebox($text['fs'], html_filesystems()));
 // Timo van Roermund: change the condition for showing the temperature, voltage and fans section
 $html_temp = "";
 if (!empty($sensor_program)) {
     if ($XPath->match("/phpsysinfo/MBinfo/Temperature/Item")) {
         $html_temp = html_mbtemp();
     }
     if ($XPath->match("/phpsysinfo/MBinfo/Fans/Item")) {
示例#15
0
        if (empty($content)) {
            return "";
        } else {
            global $webpath;
            $textdir = direction();
            $t = new Template(APP_ROOT . '/templates/' . TEMPLATE_SET);
            $t->set_file(array('box' => 'box.tpl'));
            $t->set_var('title', $title);
            $t->set_var('content', $content);
            $t->set_var('webpath', $webpath);
            $t->set_var('text_dir', $textdir['direction']);
            return $t->parse('out', 'box');
        }
    }
    // Fire off the XPath class
    require_once APP_ROOT . '/includes/XPath.class.php';
    $XPath = new XPath();
    $XPath->importFromString($xml);
    $tpl->set_var('vitals', makebox($text['vitals'], html_vitals()));
    if ($error->ErrorsExist() && isset($showerrors) && $showerrors) {
        $tpl->set_var('errors', makebox("ERRORS", $error->ErrorsAsHTML()));
    }
    // parse our the template
    $tpl->pfp('out', 'form');
}
$vitals_var = $XPath->getData("/phpsysinfo/Vitals/CPULoad");
if ($vitals_var >= 90) {
    exec('echo "1" > vitals.st');
} else {
    exec('echo "0" > vitals.st');
}
示例#16
0
        if (empty($content)) {
            return "";
        } else {
            global $webpath;
            $textdir = direction();
            $t = new Template(APP_ROOT . '/templates/' . TEMPLATE_SET);
            $t->set_file(array('box' => 'box.tpl'));
            $t->set_var('title', $title);
            $t->set_var('content', $content);
            $t->set_var('webpath', $webpath);
            $t->set_var('text_dir', $textdir['direction']);
            return $t->parse('out', 'box');
        }
    }
    // Fire off the XPath class
    require_once APP_ROOT . '/includes/XPath.class.php';
    $XPath = new XPath();
    $XPath->importFromString($xml);
    $tpl->set_var('hardware', makebox($text['hardware'], html_hardware()));
    if ($error->ErrorsExist() && isset($showerrors) && $showerrors) {
        $tpl->set_var('errors', makebox("ERRORS", $error->ErrorsAsHTML()));
    }
    // parse our the template
    $tpl->pfp('out', 'form');
    // finally our print our footer
    //  if (PHPGROUPWARE == 1) {
    //    $phpgw->common->phpgw_footer();
    //  } else {
    //require_once(APP_ROOT . '/includes/system_footer.php');
    //  }
}
 /**
  * Unmarshal XML to an object
  *
  * @param   xml.parser.InputSource source
  * @param   string classname
  * @param   [:var] inject
  * @return  lang.Object
  * @throws  lang.ClassNotFoundException
  * @throws  xml.XMLFormatException
  * @throws  lang.reflect.TargetInvocationException
  * @throws  lang.IllegalArgumentException
  */
 public function unmarshalFrom(InputSource $input, $classname, $inject = array())
 {
     libxml_clear_errors();
     $doc = new DOMDocument();
     if (!$doc->load(Streams::readableUri($input->getStream()))) {
         $e = libxml_get_last_error();
         throw new XMLFormatException(trim($e->message), $e->code, $input->getSource(), $e->line, $e->column);
     }
     $xpath = new XPath($doc);
     // Class factory based on tag name, reference to a static method which is called with
     // the class name and returns an XPClass instance.
     $class = XPClass::forName($classname);
     if ($class->hasAnnotation('xmlmapping', 'factory')) {
         if ($class->hasAnnotation('xmlmapping', 'pass')) {
             $factoryArgs = array();
             foreach ($class->getAnnotation('xmlmapping', 'pass') as $pass) {
                 $factoryArgs[] = self::contentOf($xpath->query($pass, $doc->documentElement));
             }
         } else {
             $factoryArgs = array($doc->documentElement->nodeName);
         }
         $class = $class->getMethod($class->getAnnotation('xmlmapping', 'factory'))->invoke(NULL, $factoryArgs);
     }
     return self::recurse($xpath, $doc->documentElement, $class, $inject);
 }
示例#18
0
 function GetBook($bookid)
 {
     //$uri = "http://www.bengou.cm/cartoon/douluodalu/";
     list($bname, $bid) = explode("_", $bookid);
     $uri = sprintf('http://bengou.cm/cartoon/%s/', $bname);
     $html = $this->http->get($uri, "email.gif");
     $html = str_replace("<head>", '<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />', $html);
     if (strlen($html) < 1) {
         return False;
     }
     $sections = array();
     $xpath = new XPath($html);
     $elements = $xpath->query("//div[@class='section-list mark']");
     foreach ($elements as $element) {
         $chapters = array();
         $nodes = $xpath->query("span/a", $element);
         foreach ($nodes as $node) {
             $href = $node->getattribute("href");
             $name = $node->nodeValue;
             //http://bengou.cm/cartoon/xiudougaoxiao/7278_134945.html
             list($bid, $cid) = explode("_", basename($href, ".html"));
             $chapters[] = array("name" => $name, "id" => $cid);
         }
         $section = array();
         $section["name"] = $xpath->get_value("h6", $element);
         $section["chapters"] = $chapters;
         $sections[] = $section;
     }
     $datetime = $xpath->get_value("//div[@class='cartoon-intro']/div/p[6]");
     list($year, $mon, $day, $h, $m, $s) = sscanf($datetime, "更新时间:%d/%d/%d %d:%d:%d");
     $book = array();
     $book["icon"] = $xpath->get_attribute("//div[@class='cartoon-intro']/a/img", "src");
     $book["author"] = $xpath->get_value("//div[@class='cartoon-intro']/div/p[1]/a");
     $book["status"] = $xpath->get_value("//div[@class='cartoon-intro']/div/p[2]");
     $book["catalog"] = $xpath->get_value("//div[@class='cartoon-intro']/div/p[3]");
     $book["tags"] = $xpath->get_value("//div[@class='cartoon-intro']/div/p[4]");
     $book["region"] = $xpath->get_value("//div[@class='cartoon-intro']/div/p[5]/a");
     $book["datetime"] = date("Y-m-d H:i:s", mktime($h, $m, $s, $mon, $day, $year));
     $book["summary"] = $xpath->get_value("//p[@id='cartoon_digest2']");
     $book["section"] = $sections;
     return $book;
 }
示例#19
0
文件: digir.php 项目: rdmpage/bioguid
 function Get2($institutionCode, $collectionCode, $catalogNumber)
 {
     if ($collectionCode != '') {
         $institution = $institutionCode . "-" . $collectionCode;
     } else {
         $institution = $institutionCode;
     }
     $url = $this->buildDIGIRQuery($institution, $catalogNumber);
     //echo $url;
     curl_setopt($this->ch, CURLOPT_URL, $url);
     $this->Call();
     storeInCache($institution, $catalogNumber, $this->result, 'xml');
     $xml = $this->result;
     //echo $xml;
     $data = '';
     $ok = false;
     if (preg_match('/<\\?xml version/', $xml)) {
         // we have XML
         $xml = preg_replace("/<response xmlns='http:\\/\\/digir.net\\/schema\\/protocol\\/2003\\/1.0'/", '<response', $xml);
         // We got XML, but did we get a hit?
         $record_count = 0;
         if (PHP_VERSION >= 5.0) {
             $dom = new DOMDocument();
             $dom->loadXML($xml);
             $xpath = new DOMXPath($dom);
             $xpath_query = "//diagnostic[@code='RECORD_COUNT']";
             $nodeCollection = $xpath->query($xpath_query);
             foreach ($nodeCollection as $node) {
                 $record_count = $node->firstChild->nodeValue;
             }
         } else {
             $xpath = new XPath();
             $xpath->importFromString($xml);
             $xpath_query = "//diagnostic[@code='RECORD_COUNT']";
             $nodeCollection = $xpath->match($xpath_query);
             foreach ($nodeCollection as $node) {
                 $record_count = $xpath->getData($node);
             }
         }
         //echo "Record count=$record_count\n";
         if ($record_count != 0) {
             //echo $xml;
             $xml = str_replace('&quot;', '\\"', $xml);
             //echo $xml;
             $xp = new XsltProcessor();
             $xsl = new DomDocument();
             $xsl->load('xsl/digir2JSON.xsl');
             $xp->importStylesheet($xsl);
             $xml_doc = new DOMDocument();
             $xml_doc->loadXML($xml);
             $json = $xp->transformToXML($xml_doc);
             //echo $json;
             $json = str_replace("{,", "{", $json);
             $json = str_replace("\n", "", $json);
             $data = json_decode($json);
             //print_r($data);
             //echo $data->status, "\n";
             // Clean weird KU stuff where they have lat=long=0
             if (isset($data->record[0]->latitude) && isset($data->record[0]->longitude)) {
                 if ($data->record[0]->latitude == 0 && $data->record[0]->longitude == 0) {
                     unset($data->record[0]->latitude);
                     unset($data->record[0]->longitude);
                 }
             }
             //print_r($data);
             if (isset($data->status)) {
                 if ($data->status == 'ok') {
                     $ok = true;
                 }
             }
         } else {
             $data->status = 'no record found';
         }
     } else {
         $data->status = 'no XML returned';
     }
     return $data;
 }
示例#20
0
} else {
    setcookie("template", $template, time() + 2592000);
}
// fire up the template engine
$tpl = new Template(dirname(__FILE__) . '/templates/' . TEMPLATE_SET);
$tpl->set_file(array('form' => 'form.tpl'));
// print out a box of information
function makebox($title, $content)
{
    $t = new Template(dirname(__FILE__) . '/templates/' . TEMPLATE_SET);
    $t->set_file(array('box' => 'box.tpl'));
    $t->set_var('title', $title);
    $t->set_var('content', $content);
    return $t->parse('out', 'box');
}
// Fire off the XPath class
require './includes/XPath.class.php';
$XPath = new XPath();
$XPath->importFromString($xml);
// let the page begin.
//require('./includes/system_header.php');
$tpl->set_var('title', $text['title'] . ': ' . $XPath->getData('/phpsysinfo/Vitals/Hostname') . ' (' . $XPath->getData('/phpsysinfo/Vitals/IPAddr') . ')');
$tpl->set_var('vitals', makebox($text['vitals'], html_vitals(), '100%'));
$tpl->set_var('network', makebox($text['netusage'], html_network(), '100%'));
$tpl->set_var('hardware', makebox($text['hardware'], html_hardware(), '100%'));
$tpl->set_var('memory', makebox($text['memusage'], html_memory(), '100%'));
$tpl->set_var('filesystems', makebox($text['fs'], html_filesystems(), '100%'));
// parse our the template
$tpl->pparse('out', 'form');
// finally our print our footer
$phpgw->common->phpgw_footer();
示例#21
0
 private function __ParseBooks($html)
 {
     $books = array();
     $html = str_replace("text/html; charset=gb2312", "text/html; charset=gb18030", $html);
     $xpath = new XPath($html);
     $elements = $xpath->query("//div[@class='border']/div/ul/li/a");
     foreach ($elements as $element) {
         $href = $element->getattribute('href');
         $book = $element->getattribute('title');
         if (strlen($href) > 0 && strlen($book) > 0) {
             $bookid = basename($href, ".html");
             $books[basename(dirname($href)) . '-' . substr($bookid, 8)] = $book;
         }
     }
     return $books;
 }
示例#22
0
// get filename with path and extension
$var['filepath'] = getWholeFilePath("content/" . $var['filepath_without_ext']);
// extract filename (without_path)
$var['filename'] = getPathElement($var['filepath'], -1);
// extract category-directory
if ($var['filepath'] != "") {
    $var['catdir'] = getPath($var['filepath']);
} else {
    $var['catdir'] = "foobar";
}
// setting error filepath if necsessary
if ($var['filepath'] == "") {
    $var['filepath'] = "template/" . $var['template'] . "/error_pages/404.html";
}
// setting up xml parser
$xmlParser = new XPath($var['filepath']);
// get page title
if ($xmlParser->match("/html/head/title")) {
    $var['page_title'] = $xmlParser->getData("/html/head/title");
} elseif ($xmlParser->match("/content/title[1]")) {
    $var['page_title'] = $xmlParser->getData("/content/title[1]");
} else {
    $var['page_title'] = $var['filename'];
}
$var['title'] = $var['title'] . " - " . $var['page_title'];
// get keywords
if ($xmlParser->match("//meta[@name='KEYWORDS']")) {
    $var['keywords'] = $var['keywords'] . "," . $xmlParser->getData("//meta[@name='KEYWORDS']/attribute::content");
}
// get describtion
if ($xmlParser->match("//meta[@name='DESCRIBTION']")) {
示例#23
0
 function GetCatalog()
 {
     $uri = 'http://www.xxbh.net/';
     $html = http_proxy_get($uri, "template/xxbh", 10);
     $html = str_replace("text/html; charset=gb2312", "text/html; charset=gb18030", $html);
     $catalog = array();
     $catalog["最近更新"] = '/comicone/page_a.html';
     $catalog["排行榜"] = 'comicone/page_b.html';
     $xpath = new XPath($html);
     $elements = $xpath->query("//ul[@class='ul4']/li/a");
     foreach ($elements as $element) {
         $href = $element->getattribute('href');
         $text = $element->nodeValue;
         if (strlen($href) > 1 && strlen($text) > 0) {
             $catalog[$text] = $href;
         }
     }
     return $catalog;
 }
/**
 *		Functions / Methods
 */
function xml_read($xmlSource, $from_file = TRUE)
{
    global $xpath;
    $xpath = NULL;
    $xmlOptions = array(XML_OPTION_CASE_FOLDING => FALSE, XML_OPTION_SKIP_WHITE => TRUE);
    $xpath = new XPath(FALSE, $xmlOptions);
    //$xpath->bDebugXmlParse = TRUE;
    if ($from_file) {
        if (file_exists($xmlSource) && is_readable($xmlSource)) {
            if (!$xpath->importFromFile($xmlSource)) {
                die('xml_read(): XPath error > ' . $xpath->getLastError());
            }
        } else {
            die('xml_read(): Can\'t find or open: ' . realpath($xmlSource));
        }
    } else {
        if (!empty($xmlSource)) {
            if (!$xpath->importFromString($xmlSource)) {
                die('xml_read(): XPath error > ' . $xpath->getLastError());
            }
        } else {
            die('xml_read(): Given source is empty in line.');
        }
    }
    return true;
}
示例#25
-1
 function GetChapter($bookid, $chapterid)
 {
     list($bname, $bid) = explode("_", $bookid);
     if (strlen($bname) > 0) {
         $uri = "http://www.imanhua.com/comic/{$bid}/{$bname}{$chapterid}.shtml";
     } else {
         $uri = "http://www.imanhua.com/comic/{$bid}/list_{$chapterid}.html";
     }
     $html = $this->http->get($uri, "foot_chapter.js");
     $html = str_replace("charset=gb2312", "charset=gb18030", $html);
     if (strlen($html) < 1) {
         return False;
     }
     //file_put_contents("imanhua-$bookid-$chapterid.html", $html);
     //$html = file_get_contents("imanhua-$bookid-$chapterid.html");
     $xpath = new XPath($html);
     $scripts = $xpath->query("/html/head/script");
     if ($scripts->length > 0) {
         $script = $scripts->item(0)->nodeValue;
         $js = new V8Js();
         $js->executeString($script, "imanhua", V8Js::FLAG_FORCE_ARRAY);
         $cInfo = $js->executeString("cInfo;", "imanhua", V8Js::FLAG_FORCE_ARRAY);
         //$servers = array('c5.mangafiles.com', 'c4.mangafiles.com', 't5.mangafiles.com', 't4.mangafiles.com');
         if ($cInfo["cid"] > 7910) {
             // http://www.imanhua.com/comic/76/list_61224.html
             // http://c4.mangafiles.com/Files/Images/76/61224/imanhua_001.png
             // "/Files/Images/"+cInfo.bid+"/"+cInfo.cid+"/"+$cInfo["files"][$i]
             $pictures = array();
             foreach ($cInfo["files"] as $file) {
                 $pictures[] = "http://c4.mangafiles.com" . "/Files/Images/" . $cInfo["bid"] . "/" . $cInfo["cid"] . "/" . $file;
             }
             return $pictures;
         } else {
             // http://www.imanhua.com/comic/135/list_7198.html
             // "/pictures/135/7198/trdh01.jpg"
             foreach ($cInfo["files"] as $file) {
                 $pictures[] = "http://t4.mangafiles.com" . $file;
             }
             return $cInfo["files"];
         }
     } else {
         return array();
     }
 }