SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    echo output starting on line 2 xml doc...

    I have an interesting issue I have never seen before and it has me baffled. I have a script I wrote to produce an xml

    document but its starting on line 2 instead of line 1 when it outputs, as if there is a whitespace and \cr before the string

    is echo. I isolated the problem but it makes no sense to me, maybe you can figure it out.

    here is the output:

    Code:
    line 1 
    line 2 <?xml version="1.0" encoding="UTF-8"?>
    line 3... <feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" 
    
    xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" 
    
    xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:media="http://search.yahoo.com/mrss/">
      <id>tag:webpresscreative.org,2013:/?</id>
      <updated>2013-11-04T17:47:33Z</updated>
      <title type="text"></title>
      <subtitle type="text"></subtitle>
      <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" 
    
    href="http://webpresscreative.org/rssfeed/?"/>
      <link rel="self" type="application/atom+xml" title="" href="http://webpresscreative.org/rssfeed/?"/>
      <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" 
    
    href="http://webpresscreative.org/rssfeed/?"/>
    
          <name>Web Press Creative: http://webpresscreative.org/?</name>
          <uri>http://webpresscreative.org/?</uri>
          <email>webpress.softnet@gmail.com</email>
        </author>
      </entry>
    </feed>....
    I put in the line numbers so you can see the head starts on line 2 instead of line 1 so it is an invalid xml doc.

    now here is what is causing it, and I used this simple script to find the code causing it.

    Code:
    <?
    include_once ($try.php');
    echo "line 1";
    ?>
    here is the script causing it: (as try.php)

    Code:
    <?php
    //*************** MAIN COFIG FILE *****************************************************
    //*************** DO NOT EDIT BELOW ***************************************************
    if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); 
    else ob_start();
    $doc_root=$_SERVER['DOCUMENT_ROOT'];
    //*************** EDIT DATABASE VALUES BELOW ******************************************
    // main database
    $db_user="";
    $db_pass="";
    $db_name="";
    $db_host="";
    //*************** DO NOT EDIT BELOW ***************************************************
    include ($doc_root.'/core/system/config/config_values_inc.php');
    function decrypt_user($encrypted_text,$skey,$iv2,$bit_check){
    $cipher = mcrypt_module_open(MCRYPT_TRIPLEDES,'','ctr','');
    mcrypt_generic_init($cipher, $skey, $iv2);
    $decrypted = mdecrypt_generic($cipher,base64_decode($encrypted_text));
    mcrypt_generic_deinit($cipher);
    $last_char=substr($decrypted,-1);
    for($i=0;$i<$bit_check-1; $i++){
    if(chr($i)==$last_char){
    $decrypted=substr($decrypted,0,strlen($decrypted)-$i);
    break;
    }
    }
    return $decrypted;
    } 
    ?>
    ** and the variables page that is causing the issue, if the include in the above script is commented out the problem goes

    away and the output is at line 1 (config_values_inc.php)

    Code:
    <?php
    // Config values includes
    
    // core values
    unset($a_values);
    $page_name="config_values";
    $con=mysql_connect($db_host,$db_user,$db_pass);
    @mysql_select_db($db_name, $con) or die(mysql_error());
    
    $values=mysql_query("SELECT pagename, content FROM wp_page WHERE pagename = '$page_name'");
    
    $a_values = mysql_fetch_row($values);
    @mysql_free_result($values);
    unset($values);
    
    mysql_close($con);
    
    $array_val=urldecode($a_values[1]);
    unset($config_values);
    $config_values=explode('^',$array_val);
    
    $domain_name=$config_values[1];
    $advertise=$config_values[2];
    $session_time=$config_values[3];
    $tracking_code=$config_values[4];
    $wpc=$config_values[5];
    
    // options values
    unset($a_values);
    $page_name="options_table";
    $con=mysql_connect($db_host,$db_user,$db_pass);
    @mysql_select_db($db_name, $con) or die(mysql_error());
    
    $values=mysql_query("SELECT pagename, content FROM wp_page WHERE pagename = '$page_name'");
    
    $a_values = mysql_fetch_row($values);
    @mysql_free_result($values);
    unset($values);
    
    mysql_close($con);
    
    $array_val=urldecode($a_values[1]);
    unset($options);
    $options=explode(',',$array_val);
    
    $template=$options[1];
    $admin_title=$options[5];
    $copyright=$options[6];
    $page_title=$options[7];
    $header_name=$options[8];
    $page_desc_loc=$options[9];
    
    // encryption keys
    $key = "E4HD9y4DhSDjEmhhRemkS3N6";// 24 bit Key
    $iv = "fYfhUeDm";// 8 bit IV
    $iv2 = "ji50og6b";// 8 bit IV-2
    $bit_check=8;// bit amount for diff algor.
    
    // token key
    $tokenkey=array
    
    (0,1,2,3,4,5,6,7,8,9,q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m,Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M,
    
    1);
    
    //***************** DO NOT REMOVE *******************************
    unset($a_values);
    ?>
    What is causing this issue? There needs to be two pages like this because of editing options for the user... could it simply

    be the include in try.php?

    see the actual script working (use Google Chrome): view-source:http://webpresscreative.org/test.php

    and the real page: view-source:http://webpresscreative.org/rss_feed/

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,069
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Is there an empty line after the ?> in any of the files? That will cause the empty line

    (this is the reason ?> is not allowed in files with PHP only in the PSR-2 standard)
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •