0

出于某种原因,这在我开箱即用的 WAMP 上完美运行,但是当上传到 Web 服务器时,它会丢弃以下错误:

严重性:警告

消息:DOMDocument::load(): I/O warning : failed to load external entity "/mounted-storage/home155/sub004/sc81961-YHHB/* * * * * *.com/dev/ 2012-10-04 03 :15:03 4 2012-10-04 03:25:16 2012-09-17 19:25:11 3 0 1 1 2012-10-04 04:08:18 “

文件名:models/fuel_model.php

行号:74

它指向应用程序根文件夹。

代码:

   function get_pos($id)
    {
        $get = $this->db->query(
                "SELECT * FROM holding WHERE id=1"
            );
        $stream = $get->row_array();

        $addr = 'http://api.eveonline.com/corp/StarbaseDetail.xml.aspx?keyID='.$stream['apiid'].
                '&vCode='.$stream['apikey'] . '&itemID=' . $id;
        $link = new DOMDocument();

      $get_cache = $this->db->query(
          "SELECT * FROM cache_poses WHERE posid=".$id
        );
      $cache = $get_cache->row_array();

      $posted = strtotime(date("Y-m-d H:i:s"));
      if(!empty($cache))
      {
        $posted = strtotime($cache['cachedon']);
      }

      $current = strtotime(date("Y-m-d H:i:s"));

      $mins = $posted - $current;
      $expiry = $mins % 60;

      if(empty($cache))
      {
        $link->load($addr);
        $this->db->query("INSERT INTO cache_poses (data, posid) VALUES (" . $this->db->escape($link->saveXML()) . "," . $id .")");

      } elseif(!empty($cache) && ($expiry >= 360)) {
        $this->db->query("DELETE FROM cache_poses WHERE posid=".$id);
        $link->load($addr);
        $this->db->query("INSERT INTO cache_poses (data, posid) VALUES (" . $this->db->escape($link->saveXML()) . "," . $id . ")");

      } elseif(!empty($cache) && ($expiry < 360)) {

        $link->load($cache['data']);

      }

        $supply = $link->getElementsByTagName('row');
        $supplies = array();

        foreach ($supply as $fuel) {
            $block = $fuel->attributes;

            $put = $this->db->query('SELECT name FROM items WHERE typeid='.$block->item(0)->nodeValue);
            $lck = $put->row_array();

            $supplies[$lck['name']] = $block->item(1)->nodeValue;
        }

        $info = $this->implode_with_keys($supplies);
        return $info;
    }
4

1 回答 1

0

你能发布XML吗?它引用的 DTD 必须可以在您的本地开发机器上访问,但不能在您的实时服务器上访问。如果 DTD 和它定义的实体对您的 XML 不重要,您可以通过在调用 DOMDocument::load() 之前禁用内部实体的加载来抑制警告,并且可能会因不加载额外资源而提高性能。

$link->resolveExternals = FALSE;
$link->load($cache['data']);

http://www.php.net/manual/en/class.domdocument.php#domdocument.props.resolveexternals

顺便说一句, DOMDocument::load() 接受文件路径。如果你$cache['data']真的是数据库中的一串XML,你需要使用DOMDocument::loadXML()。

于 2012-10-04T04:54:00.810 回答