[API] Headers already send out

Eronisch

Web Developer
Jan 1, 2011
234
25
I'm getting the following error:


Warning: Cannot modify header information - headers already sent by (output started at /home/diaxa/public_html/thehabbos_api/config.php:1) in /home/diaxa/public_html/thehabbos_api/types/client.php on line 27
 

Eronisch

Web Developer
Jan 1, 2011
234
25
Anyone??

Config file:

<?php
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; }

////////////////////////////////////////////////////////
// # TheHabbos Topsites API Script - Release 1.0.3 //
// # © Copyright TheHabbos 2011. All rights reserved. //
////////////////////////////////////////////////////////

if(!defined('IN_THEHABBOS_API')) {
die('Sorry, but you can not access this file directly. :(');
}
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,132
2,456
Anyone??

Config file:

<?php
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; }

////////////////////////////////////////////////////////
// # TheHabbos Topsites API Script - Release 1.0.3 //
// # © Copyright TheHabbos 2011. All rights reserved. //
////////////////////////////////////////////////////////

if(!defined('IN_THEHABBOS_API')) {
die('Sorry, but you can not access this file directly. :(');
}
I don't see line 27 here.
 

BatDev

Active Member
Apr 20, 2012
110
25
PHP:
/home/diaxa/public_html/thehabbos_api/types/client.php on line 27

look on line 27 in the client.php file.
 

Eronisch

Web Developer
Jan 1, 2011
234
25
Warning: Cannot modify header information - headers already sent by (output started at /home/diaxa/public_html/habblo-world.tk/thehabbos_api/config.php:1) in /home/diaxa/public_html/habblo-world.tk/thehabbos_api/class.validate.php on line 45

Warning: Cannot modify header information - headers already sent by (output started at /home/diaxa/public_html/habblo-world.tk/thehabbos_api/config.php:1) in /home/diaxa/public_html/habblo-world.tk/thehabbos_api/types/client.php on line 21
Files:
Class_validate:
PHP:
<?php
////////////////////////////////////////////////////////
// # TheHabbos Topsites API Script - Release 1.0.3    //
// # © Copyright TheHabbos 2011. All rights reserved. //
////////////////////////////////////////////////////////
 
if(!defined('IN_THEHABBOS_API')) {
  die('Sorry, but you can not access this file directly. :(');
}
 
class Validate {
 
  public function validateVote() {
    global $CONFIG;
    if($this->checkCookie()) {
      return 2;
    }else{
      $data = $this->getData('http://votingapi.com/validate.php?user='.$CONFIG['Username'].'&ip='.$_SERVER['REMOTE_ADDR']);
      if(!$data || !is_numeric($data)) {
        return 6;
      }else{
        if($data == 1 || $data == 2) {
          $this->setCookie();
        }
        return $data;
      }
    }
  }
 
  private function getData($url) {
    global $CONFIG;
    if($CONFIG['Curl_Enabled']) {
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_TIMEOUT, $CONFIG['Timeout']);   
      return curl_exec($ch);
    }else{
      $context = stream_context_create(array('http' => array('timeout' => $CONFIG['Timeout'])));
      return @file_get_contents($url, 0, $context);
    }
  }
 
  public function setCookie() {
    $resetTime = $this->getResetTime();
    setcookie('voting_stamp', $resetTime, $resetTime);
  }
 
  private function checkCookie() {
    $resetTime = $this->getResetTime();
    if(isset($_COOKIE['voting_stamp'])) {
      if($_COOKIE['voting_stamp'] == $resetTime) {
        return true;
      }else{
        setcookie('voting_stamp', '');
        return false;
      }
    }else{
      return false;
    }
  }
 
  private function getResetTime() {
    $defaultTime = date_default_timezone_get();
    date_default_timezone_set('America/Chicago');
    $resetTime = mktime(0, 0, 0, date('n'), date('j') + 1);
    date_default_timezone_set($defaultTime);
    return $resetTime;
  }
   
}

Client:

PHP:
<?php
////////////////////////////////////////////////////////
// # TheHabbos Topsites API Script - Release 1.0.3    //
// # © Copyright TheHabbos 2011. All rights reserved. //
////////////////////////////////////////////////////////
 
if(!defined('IN_THEHABBOS_API')) {
  die('Sorry, but you can not access this file directly. :(');
}
 
switch($lookingFor) {
  case 1:
  {
    //what happens if someone does successfully vote
    header("Location: client.php");
    break;
  }
  case 2:
  {
    //what happens if someone has already voted
    header("Location: client.php");
    break;
  }
  case 3:
  {
    //what happens if someone hasn't voted yet
    echo '<div class="contentTitle">Please Vote</div>
          It appears that you have not voted yet today! Please click the button below.<br />
          <br />
          <form action="http://votingapi.com/vote/'.$CONFIG['Username'].'" method="post">
            <input type="hidden" name="api_url" value="'.$CONFIG['URL'].'" />
            <input class="button" type="submit" name="votingAPI" value="" />
          </form>';
    break;
  }
  case 4:
  case 5:
  {
    //what happens if someone sends an invalid request
    echo $LANG['content'][4].'<br /><br />Click <a href="client.php" style="color: #000000;">here</a> to proceed to the client.';
    break;
  }
  case 6:
  {
    //what happens if thehabbos is down or having connection issues
    header("Location: client.php");
    break;
  }
}

Config:

PHP:
<?php
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; }
 
////////////////////////////////////////////////////////
// # TheHabbos Topsites API Script - Release 1.0.3    //
// # © Copyright TheHabbos 2011. All rights reserved. //
////////////////////////////////////////////////////////
 
if(!defined('IN_THEHABBOS_API')) {
  die('Sorry, but you can not access this file directly. :(');
}
 
 
/* FEEL FREE TO EDIT ANYTHING BELOW */
 
$CONFIG['Username'] = 'diaxahotel26'; //thehabbos topsites username
$CONFIG['URL']      = 'http://habblo-world.tk/api2.php'; //the location to the file api.php on your website (i.e. http://example.com/api.php)
$CONFIG['Type']     = 'client'; //current options: other or client (thehabbos_api/types)
$CONFIG['Style']    = 'Habbo Sleek'; //don't change this unless you have created your own style (thehabbos_api/styles)
$CONFIG['Credits']  = '150'; //you can use this if you are using a specific type above - your users will be rewarded this many credits for voting
 
/* ADVANCED OPTIONS */
 
$CONFIG['Timeout']      = 2; //max amount of seconds before the api stops trying to connect to votingapi.com
$CONFIG['Curl_Enabled'] = 1; //mark this 0 if cURL isn't installed/enabled on your server, although cURL is recommended
 
/* DO NOT EDIT ANYTHING BELOW */
 
$votingValidation = new Validate();
$CONFIG['Status'] = $votingValidation->validateVote();

 

Eronisch

Web Developer
Jan 1, 2011
234
25
I turned it off, but i am still getting this:

23r4sip.png
 

Users who are viewing this thread

Top