Blank screen of death on simple widget help

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Blank screen of death on simple widget help

Postby scrtmtl » 26. March 2011 15:47

HI,
xampp 1.7.4

I have ran two or three large development application with above environment. Wanted to display the weather forecast in the application. Downloaded the weather script and ran it to receive the blank screen of death. Converse with author to finally get the script that he ran, whereby it works for him but not in my above environment of xampp 1.7.4

Only possible scenario is to ask if anything wrong with xampp or what did I fail to do which in xampp, Appreciate any help for I have nothing to work on since I am seeing a blank screen. Never ran parsexml stuff but author provided exact code that ran on his server to thus do no change or mod.

Here is the content of the weather widget. First code block is index. Second block of code is ParseXml.class Both are file type php. Two php snippet place in a folder called anita. Thus I have xammp running in firefox with http://localhost/anita/
I would have attached the content and next best is to post the content with details and what i did. Again, appreciate the time you took to look at post and to provide any help.

Code: Select all
<?php
 
$geoplugin = unserialize( file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $_SERVER['REMOTE_ADDR']) );
 
if ( is_numeric($geoplugin['geoplugin_latitude']) && is_numeric($geoplugin['geoplugin_longitude']) ) {
 
   $lat = $geoplugin['geoplugin_latitude'];
   $long = $geoplugin['geoplugin_longitude'];
   //set farenheight for US
   if ($geoplugin['geoplugin_countryCode'] == 'US') {
      $tempScale = 'fahrenheit';
      $tempUnit = '&deg;F';
   } else {
      $tempScale = 'celsius';
      $tempUnit = '&deg;C';
   }
   require_once('ParseXml.class.php');
 
   $xml = new ParseXml();
   $xml->LoadRemote("http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query={$lat},{$long}", 3);
   $dataArray = $xml->ToArray();
 
   $html = "<center><h2>Weather forecast for " . $geoplugin['geoplugin_city'];
   $html .= "</h2><table cellpadding=5 cellspacing=10><tr>";
 
   foreach ($dataArray['simpleforecast']['forecastday'] as $arr) {
 
      $html .= "<td align='center'>" . $arr['date']['weekday'] . "<br />";
      $html .= "<img src='http://icons-pe.wxug.com/i/c/a/" . $arr['icon'] . ".gif' border=0 /><br />";
      $html .= "<font color='red'>" . $arr['high'][$tempScale] . $tempUnit . " </font>";
      $html .= "<font color='blue'>" . $arr['low'][$tempScale] . $tempUnit . "</font>";
      $html .= "</td>";
 
 
   }
   $html .= "</tr></table>";
 
   echo $html;
}
 
?>



ParseXml.class of type php is directly below in the code block.

Code: Select all
<?php
/**
*    @File name:    ParseXml.class.php
*    @todo:     parsing XML(string or file or url)
*    @author:    zhys9 @ 2008-03-24 <email>zhys99@gmail.com</email>
*    example:
*    <code>
*            $xml = new ParseXml();
*            $xml->LoadFile("test.xml");
*            //$xml->LoadString($xmlString);
*            //$xml->LoadRemote("http"//www.yourdomain.com/dir/filename.xml", 3);
*            $dataArray = $xml->ToArray();
*            print_r($dataArray);
*    </code>
*/
class ParseXml {
    var $xmlStr;
    var $xmlFile;
    var $obj;
    var $aArray;
    var $timeOut;
    var $charsetOutput;
     
    function ParseXml() {

    }
     
    /**
     * @param String xmlString xml string to parsing
     */
    function LoadString($xmlString) {
        $this->xmlStr = $xmlString;
    }
     
    /**
     * @param String Path and file name which you want to parsing,
     *    Also, if Òfopen wrappersÓ  is activated, you can fetch a remote document, but timeout not be supported.
     */
    function LoadFile ($file) {
        $this->xmlFile = $file;
        $this->xmlStr = @file_get_contents($file);
    }
     
    /**
     * @todo Load remote xml document
     * @param string $url URL of xml document.
     * @param int $timeout timeout  default:5s
     */
    function LoadRemote ($url, $timeout=5) {
        $this->xmlFile = $url;
        $p=parse_url($url);
        if($p['scheme']=='http'){
            $host = $p['host'];
            $pos = $p['path'];
            $pos .= isset($p['query']) ? sprintf("?%s",$p['query']) : '';
            $port = isset($p['port'])?$p['port']:80;
            $this->xmlStr = $this->Async_file_get_contents($host, $pos, $port, $timeout);
        }else{
            return false;
        }
         
    }
     
    /**
     * @todo Set attributes.
     * @param array $set array('attribute_name'=>'value')
     */
    function Set (array $set) {
        foreach($set as $attribute=>$value) {
            if($attribute=='charsetOutput'){
                $value = strtoupper($value);
            }
            $this->$attribute = $value;
        }
    }
     
    /**
     * @todo Convert charset&#65292;if you want to output data with a charset not "UTF-8",
     *    this member function must be useful.
     * @param string $string &#38656;&#36716;&#25442;&#30340;&#23383;&#31526;&#20018;
     */
    function ConvertCharset ($string) {
        if('UTF-8'!=$this->charsetOutput) {
            if(function_exists("iconv")){
                $string = iconv('UTF-8', $this->charsetOutput, $string);
            }elseif(function_exists("mb_convert_encoding")){
                $string = mb_convert_encoding($string, $this->charsetOutput, 'UTF-8');
            }else{
                die('Function "iconv" or "mb_convert_encoding" needed!');
            }
        }
        return $string;
    }
     
    /**
     * &#35299;&#26512;xml
     */
    function Parse () {
        $this->obj = simplexml_load_string($this->xmlStr);
    }
     
    /**
     * @return Array Result of parsing.
     */
    function ToArray(){
        if(empty($this->obj)){
            $this->Parse();
        }
        $this->aArray = $this->Object2array($this->obj);
        return $this->aArray;
    }
     
    /**
     * @param Object object Objects you want convert to array.
     * @return Array
     */
    function Object2array($object) {
        $return = array();
        if(is_array($object)){
            foreach($object as $key => $value){
                $return[$key] = $this->Object2array($value);
            }
        }else{
            $var = @get_object_vars($object);
            if($var){
                foreach($var as $key => $value){
                    $return[$key] = ($key && ($value==null)) ? null : $this->Object2array($value);
                }
            }else{
                return $this->ConvertCharset((string)$object);
            }
        }
        return $return;
    }
     
    /**
     * @todo Fetch a remote document with HTTP protect.
     * @param string $site Server's IP/Domain
     * @param string $pos URI to be requested
     * @param int $port Port default:80
     * @param int $timeout Timeout  default:5s
     * @return string/false Data or FALSE when timeout.
     */
    function Async_file_get_contents($site,$pos,$port=80,$timeout=5) {
        $fp = fsockopen($site, $port, $errno, $errstr, 5);
         
        if (!$fp) {
            return false;         
        }else{
            fwrite($fp, "GET $pos HTTP/1.0\r\n");
            fwrite($fp, "Host: $site\r\n\r\n");
            stream_set_timeout($fp, $timeout);
            $res = stream_get_contents($fp);
            $info = stream_get_meta_data($fp);
            fclose($fp);
             
            if ($info['timed_out']) {
                return false;         
            }else{
                return substr(strstr($res, "\r\n\r\n"),4);
            }
        }
    }
     
    /**
     * @todo Get xmlStr of current object.
     * @return string xmlStr
     */
    function GetXmlStr () {
        return $this->xmlStr;
    }
}
?>
scrtmtl
 
Posts: 5
Joined: 24. January 2011 16:59

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 58 guests