<?

  include 'inc_hyipguyz/config.inc.php';

  $dbconn = db_open ();
  if (!$dbconn)
  {
    print 'Cannot connect mysql';
    exit ();
  }

  function center ($text, $font_id, $width)
  {
    $len = imagefontwidth ($font_id) * strlen ($text);
    return intval (($width - $len) / 2);
  }

  function imagecolorallocatehex ($im, $color)
  {
    $red = 0;
    $green = 0;
    $blue = 0;
    if (eregi ('[#]?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})', $color, $ret))
    {
      $red = hexdec ($ret[1]);
      $green = hexdec ($ret[2]);
      $blue = hexdec ($ret[3]);
    }
    return imagecolorallocate ($im, $red, $green, $blue);
  }


  $frm['lid'] = intval($frm['lid']);


    global $frm;



    global $settings;



    $q = 'select 

				date_format(date_added, \'%b %D, %Y\') as added,

                hl_listings.*

        from

                hl_listings

        where

                (hl_listings.expiration = 0 || date_added + interval hl_listings.expiration day >= current_date)

                and hl_listings.status = 1 and

                id = ' . intval($frm['lid']);

				

    $sth = mysql_query ($q);

    $row = mysql_fetch_array ($sth);

    if (!$row)

    {	

      header ('Location: ' . $settings['site_logo_url']);

      exit ();

    }



	$group=$row['group_id'];

	$name=$row['name'];

	$status=$row['hyip_status'];



	$Date_1=date("Y-m-d h:i:s"); 

	$Date_2=$row['date_added']; 

	$Date_List_1=explode("-",$Date_1); 

	$Date_List_2=explode("-",$Date_2); 

	$d1=mktime(0,0,0,$Date_List_1[1],$Date_List_1[2],$Date_List_1[0]); 

	$d2=mktime(0,0,0,$Date_List_2[1],$Date_List_2[2],$Date_List_2[0]); 

	

	//added 

	$added="Added : ".$row['added'];

	//monited xx days

	$Days=round(($d1-$d2)/3600/24); 	

	$monited="Monitored : ".$Days." days";

	



	$img=imagecreatefrompng('images/monitorbutton.png');

	

	$colors = array ();

    $colors['pay'] = imagecolorallocatehex ($img, '#498302');

    $colors['wait'] = imagecolorallocatehex ($img, '#0000FF');

    $colors['problem'] = imagecolorallocatehex ($img, '#fd8d01');

    $colors['notpay'] = imagecolorallocatehex ($img, '#FF0000');

	$colors['black'] = imagecolorallocatehex ($img, '#000000');

	



	$colors['name']= imagecolorallocatehex ($img, '#484646');
	$colors['name1']= imagecolorallocatehex ($img, '#000000');

	



	$name=((strlen($name)>26) ? substr($name, 0, 13). '...' : $name);



	$x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($name)) / 3));



	//ImageTTFText($img, 10, 0, $x+1,93+1, $colors['black'], "images/tahoma.ttf", $name);



	ImageTTFText($img, 10, 0, $x,110, $colors['name1'], "images/tahoma.ttf", $name);



	



	



	



	if ($status == 1)

    {

	 $statuscolor = $colors['pay'];

     $text = 'PAYING';

	 $size=18;

	 $x = floor((ImageSX($img) / 3) - ((ImageFontWidth(9) * strlen($text)) / 15));

	 $x=$x;

    }



    if ($status == 2)

    {

	$statuscolor = $colors['wait'];

	  $text = 'WAITING';

	  $size=18;

	  $x = floor((ImageSX($img) / 3) - ((ImageFontWidth(9) * strlen($text)) / 6));

	  $x=$x;

    }





    if ($status == 3)

    {

	$statuscolor = $colors['problem'];

      $text = 'PROBLEM';

	  $size=18;

	  $x = floor((ImageSX($img) / 3) - ((ImageFontWidth(9) * strlen($text)) / 6));



	  $x=$x-5;

    }



    if ($status == 4)

    {

		$statuscolor = $colors['notpay'];

      $text = 'NOT PAYING';

	  $size=17;

	  $x = floor((ImageSX($img) / 3) - ((ImageFontWidth(9) * strlen($text)) / 4));

	  $x=$x;

    }



	if ($group == 7)

	{

	$statuscolor = $colors['notpay'];

      $text = 'CLOSED';

	  $size=18;

	 $x = floor((ImageSX($img) / 3) - ((ImageFontWidth(9) * strlen($text)) / 15));



	  $x=$x-5;

	}



	//ImageTTFText($img, $size, 0, $x+1,92+1, $colors['black'], "images/impact.ttf", $text);



	ImageTTFText($img, $size, 0, $x,145, $statuscolor, "images/impact.ttf", $text);



        if ($group == 1)

	{

      $text = 'Class : Diamond';

	 $x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($text)) / 3));

	}



    if ($group == 2)

    {

      $text = 'Class : Premium';

	  $x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($text)) / 3));

    }



    if ($group == 3)

    {

      $text = 'Class : Golden';

	  $x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($text)) / 3));

    }



    if ($group == 4)

    {

      $text = 'Class : Silver';

	  $x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($text)) / 3));

    }


    if ($group == 5)

    {

      $text = 'Class : Trial';

	  $x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($text)) / 3));

    }



    if ($group == 6)

    {

      $text = 'Class : SCAM';

	  $x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($text)) / 3));

    }



    if ($group == 7)

    {

      $text = 'Class : Closed';

	  $x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($text)) / 3));

    }



	//ImageTTFText($img, 10, 0, $x+1, 135+1, $colors['black'], "images/tahoma.ttf", $text);



	ImageTTFText($img, 8, 0, $x+3, 165, $colors['name'], "images/tahoma.ttf", $text);

	


	$x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($added)) / 3));

	//ImageTTFText($img, 10, 0, $x+1, 135+1, $colors['black'], "images/tahoma.ttff", $monited);

	ImageTTFText($img, 8, 0, $x+5, 177, $colors['name'], "images/tahoma.ttf", $added);

	

	$x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($monited)) / 3));

	//ImageTTFText($img, 10, 0, $x+1, 135+1, $colors['black'], "images/tahoma.ttf", $monited);

	ImageTTFText($img, 8, 0, $x+7, 189, $colors['name'], "images/tahoma.ttf", $monited);

	



	//get listing details	

  $listing = get_listing_details ($row);

  //$listing   

 

 

 //votes

 	$text="Total Votes : ".$listing['cvotes'].' votes';

	$x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($text)) / 3));

	//ImageTTFText($img, 10, 0, $x+10+1, 165+1, $colors['black'], "images/tahoma.ttf", $text);

	ImageTTFText($img, 8, 0, $x+9, 201, $colors['name'], "images/tahoma.ttf", $text);	



 

	//user' rating

	

	$text="User Rating : ".$listing['avg_vote']." pts";

	$x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($text)) / 3));

	//ImageTTFText($img, 10, 0, $x+10+1, 165+1, $colors['black'], "images/tahoma.ttf", $text);

	ImageTTFText($img, 8, 0, $x+8, 213, $colors['name'], "images/tahoma.ttf", $text);	

	

	$text='Our Invest : $'.$listing['spend'].'';

  	$x = floor((ImageSX($img) / 2) - ((ImageFontWidth(5) * strlen($text)) / 4));

	//ImageTTFText($img, 10, 0, $x+1, 150+1, $colors['black'], "images/tahoma.ttf", $text);

	ImageTTFText($img, 8, 0, $x+2, 225, $colors['name'], "images/tahoma.ttf", $text);



	

  	$text='Payout Ratio : '.($listing['ratio']*100).'%';

  	$x = floor((ImageSX($img) / 2) - ((ImageFontWidth(5) * strlen($text)) / 4));

	//ImageTTFText($img, 10, 0, $x+1, 150+1, $colors['black'], "images/tahoma.ttf", $text);

	ImageTTFText($img, 8, 0, $x, 237, $colors['name'], "images/tahoma.ttf", $text);



	//lastpayout

$q = "select 

			date_format(hl_statistics.date, '%b %d') as date 

	from 

			`hl_statistics` 

	where 

			type = 1 and listing_id = " . $frm['lid'] ."

	order by

			hl_statistics.date DESC LIMIT 1";

			

	if (!($sth = mysql_query ($q)))

    {

      exit (mysql_error ());

    }

			

    $row = mysql_fetch_array ($sth);

    if (!$row)

    {	

      $lastpayout = 'Last payout : No';      

    }

	else

	{

		$lastpayout = 'Last payout : '.$row['date'];

	}

	 



 //lastpayout end		



	$x = floor((ImageSX($img) / 2) - ((ImageFontWidth(5) * strlen($lastpayout)) / 4));

	//ImageTTFText($img, 10, 0, $x+1, 190+1, $colors['black'], "images/tahoma.ttf", $lastpayout);

	ImageTTFText($img, 8, 0, $x, 249, $colors['name'], "images/tahoma.ttf", $lastpayout);

	 

	$text='Today is : '.date("M j,Y");;

  	$x = floor((ImageSX($img) / 2) - ((ImageFontWidth(4) * strlen($text)) / 3));

	//ImageTTFText($img, 10, 0, $x+1, 160+1, $colors['black'], "images/tahoma.ttf", $text);

	ImageTTFText($img, 8, 0, $x+8, 263, $colors['name1'], "images/tahoma.ttf", $text);



	header("Content-type: image/png");



	imagepng($img);











  

  


?>
