<?php
 ob_start();
//timer starts

$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;

//timer starts

require_once('php/config.php');

if(isset($_GET['keywords']) && !empty($_GET['keywords'])){
   $printkw = htmlentities($_GET['keywords'],ENT_QUOTES,'UTF-8');
}
else{
  $printkw = $lang['err_notprovided'];
}

if(isset($_GET['profile']) && !empty($_GET['profile'])){
  $df_file = 'data/profiles/' . $_GET['profile'] . '.ini';
  $df_status = true;


  if(!file_exists($df_file)){
    $df_status = false;
  }
  else{
    $seoProfile = new IniParser($df_file);
    
    // General
    $g_name   = htmlentities($seoProfile->getValue("g_name"),ENT_QUOTES,'UTF-8');

    //Crawling

    $c_http    = $seoProfile->getValue('c_http');
    $c_robots  = $seoProfile->getValue('c_robots');
    $c_sitemap = $seoProfile->getValue('c_sitemap');
    $c_label   = $seoProfile->getValue('c_label');
    $c_label_c = $seoProfile->getValue('c_label_c');

    //Head:title

    $h_t_show      = $seoProfile->getValue('h_t_show');
    $h_t_length    = $seoProfile->getValue('h_t_length');
    $h_t_length_d  = array_map('intval',explode(',',$seoProfile->getValue('h_t_length_d')));
    $h_t_length_c  = explode(',',$seoProfile->getValue('h_t_length_c'));
    $h_t_stopwords = $seoProfile->getValue('h_t_stopwords');
    $h_t_kwin      = $seoProfile->getValue('h_t_kwin');
    $h_t_rel       = $seoProfile->getValue('h_t_rel');
    $h_t_rel_d     = array_map('intval',explode(',',$seoProfile->getValue('h_t_rel_d')));
    $h_t_rel_c     = explode(',',$seoProfile->getValue('h_t_rel_c'));
    $h_t_label     = $seoProfile->getValue('h_t_label');
    $h_t_label_c   = $seoProfile->getValue('h_t_label_c');


    //Head:kw

    $h_k_show = $seoProfile->getValue('h_k_show');
    $h_k_count = $seoProfile->getValue('h_k_count');
    $h_k_count_d = array_map('intval',explode(',',$seoProfile->getValue('h_k_count_d')));
    $h_k_count_c = explode(',',$seoProfile->getValue('h_k_count_c'));
    $h_k_rel = $seoProfile->getValue('h_k_rel');
    $h__k_rel_d = array_map('intval',explode(',',$seoProfile->getValue('h__k_rel_d')));
    $h__k_rel_c = explode(',',$seoProfile->getValue('h__k_rel_c'));
    $h_k_label = $seoProfile->getValue('h_k_label');
    $h_k_label_c = $seoProfile->getValue('h_k_label_c');

    //Head:descr

    $h_d_show = $seoProfile->getValue('h_d_show');
    $h_d_length = $seoProfile->getValue('h_d_length');
    $h_d_length_d = array_map('intval',explode(',',$seoProfile->getValue('h_d_length_d')));
    $h_d_length_c = explode(',',$seoProfile->getValue('h_d_length_c'));
    $h_d_kwin = $seoProfile->getValue('h_d_kwin');
    $h_d_rel = $seoProfile->getValue('h_d_rel');
    $h_d_rel_d = array_map('intval',explode(',',$seoProfile->getValue('h_d_rel_d')));
    $h_d_rel_c = explode(',',$seoProfile->getValue('h_d_rel_c'));
    $h_d_label = $seoProfile->getValue('h_d_label');
    $h_d_label_c = $seoProfile->getValue('h_d_label_c');

    //Content

    $ct_lang = $seoProfile->getValue('ct_lang');
    $ct_chars = $seoProfile->getValue('ct_chars');
    $ct_chars_d = array_map('intval',explode(',',$seoProfile->getValue('ct_chars_d')));
    $ct_chars_c = explode(',',$seoProfile->getValue('ct_chars_c'));
    $ct_words = $seoProfile->getValue('ct_words');
    $ct_words_d = array_map('intval',explode(',',$seoProfile->getValue('ct_words_d')));
    $ct_words_c = explode(',',$seoProfile->getValue('ct_words_c'));
    $ct_kwin = $seoProfile->getValue('ct_kwin');
    $ct_rel = $seoProfile->getValue('ct_rel');
    $ct_rel_d = array_map('intval',explode(',',$seoProfile->getValue('ct_rel_d')));
    $ct_rel_c = explode(',',$seoProfile->getValue('ct_rel_c'));
    $ct_kwini = $seoProfile->getValue('ct_kwini');
    $ct_kwinb = $seoProfile->getValue('ct_kwinb');
    $ct_headings = $seoProfile->getValue('ct_headings');
    $ct_iframes = $seoProfile->getValue('ct_iframes');
    $ct_label = $seoProfile->getValue('ct_label');
    $ct_label_c = $seoProfile->getValue('ct_label_c');

    //Url Structure

    $ul_show = $seoProfile->getValue('ul_show');
    $ul_kwin = $seoProfile->getValue('ul_kwin');
    $ul_length = $seoProfile->getValue('ul_length');
    $ul_length_d = array_map('intval',explode(',',$seoProfile->getValue('ul_length_d')));
    $ul_length_c = explode(',',$seoProfile->getValue('ul_length_c'));
    $ul_sub = $seoProfile->getValue('ul_sub');
    $ul_label = $seoProfile->getValue('ul_label');
    $ul_label_c = $seoProfile->getValue('ul_label_c');

    //Links

    $l_ilinks = $seoProfile->getValue('l_ilinks');
    $l_ilinks_d = array_map('intval',explode(',',$seoProfile->getValue('l_ilinks_d')));
    $l_ilinks_c = explode(',',$seoProfile->getValue('l_ilinks_c'));
    $l_elinks = $seoProfile->getValue('l_elinks');
    $l_elinks_d = array_map('intval',explode(',',$seoProfile->getValue('l_elinks_d')));
    $l_elinks_c = explode(',',$seoProfile->getValue('l_elinks_c'));
    $l_label = $seoProfile->getValue('l_label');
    $l_label_c = $seoProfile->getValue('l_label_c');

    //Ux

    $u_speed = $seoProfile->getValue('u_speed');
    $u_speed_d = array_map('intval',explode(',',$seoProfile->getValue('u_speed_d')));
    $u_speed_c = explode(',',$seoProfile->getValue('u_speed_c'));
    $u_gram = $seoProfile->getValue('u_gram');
    $u_gram_d = array_map('intval',explode(',',$seoProfile->getValue('u_gram_d')));
    $u_gram_c = explode(',',$seoProfile->getValue('u_gram_c'));
    $u_res = $seoProfile->getValue('u_res');
    $u_fb = $seoProfile->getValue('u_fb');
    $u_label = $seoProfile->getValue('u_label');
    $u_label_c = $seoProfile->getValue('u_label_c');


    #
    # Generating the tab buttons
    #

    $s_crawling = true;
    if($c_http == 'true' || $c_robots == 'true' || $c_sitemap == 'true'){
      $s_crawling = true;
    }
    else{
      $s_crawling = false;
    }

    //var_dump($s_crawling);

    $s_head = true;

    if($h_t_show == 'true' || $h_t_length == 'true' || $h_t_stopwords == 'true' || $h_t_kwin == 'true' || $h_t_rel == 'true'
      || $h_k_show == 'true' || $h_k_count == 'true' ||  $h_k_rel == 'true' 
      || $h_d_show == 'true' || $h_d_length == 'true' || $h_d_kwin == 'true' || $h_d_rel == 'true'){
      $s_head = true;
    }
    else{
      $s_head = false;
    }


    $s_content = true;
    if($ct_lang == 'true' || $ct_chars == 'true' || $ct_chars_d == 'true' || $ct_chars_c == 'true' || $ct_words == 'true' || $ct_words_d == 'true' || $ct_words_c == 'true' || $ct_kwin == 'true' || $ct_rel == 'true' || $ct_rel_d == 'true' || $ct_rel_c == 'true' || $ct_kwini == 'true' || $ct_kwinb == 'true' || $ct_headings == 'true' || $ct_iframes == 'true'){
      $s_content = true;
    }
    else{
      $s_content = false;
    }


    $s_url = true;
    if($ul_show == 'true' || $ul_kwin == 'true' || $ul_length == 'true' || $ul_length_d == 'true' || $ul_length_c == 'true' || $ul_sub == 'true'){
      $s_url = true;
    }
    else{
      $s_url = false;
    } 


    $s_links = true;
    if($l_ilinks == 'true' || $l_ilinks_d == 'true' || $l_ilinks_c == 'true' || $l_elinks == 'true' || $l_elinks_d == 'true' || $l_elinks_c == 'true'){
      $s_links = true;
    }
    else{
      $s_links = false;
    }


    $s_ux = true;
    if($u_speed == 'true' || $u_speed_d == 'true' || $u_speed_c == 'true' || $u_gram == 'true' || $u_gram_d == 'true' || $u_gram_c == 'true' || $u_res == 'true' || $u_fb == 'true'){
      $s_ux = true;
    }
    else{
      $s_ux = false;
    }


    #
    # End of Generating the tab buttons
    #

    /*

    Debugging puorpuses:

    */

     //general

    //var_dump($g_name);
    //print '<br />';

    //crawling
    //print '<br />';
    //print '<br />';



    //var_dump($c_http);
    //print '<br />';
    //var_dump($c_robots);
    //print '<br />';
    //var_dump($c_sitemap);
    //print '<br />';
    //var_dump($c_label);
    //print '<br />';
    //var_dump($c_label_c);
    //print '<br />';



    //head:title
    //print '<br />';
    //print '<br />';


    //var_dump($h_t_show);
    //print '<br />';
    //var_dump($h_t_length);
    //print '<br />';
    //var_dump($h_t_length_d);
    //print '<br />';
    //var_dump($h_t_length_c);
    //print '<br />';
    //var_dump($h_t_stopwords);
    //print '<br />';
    //var_dump($h_t_kwin);
    //print '<br />';
    //var_dump($h_t_rel);
    //print '<br />';
    //var_dump($h_t_rel_d);
    //print '<br />';
    //var_dump($h_t_rel_c);
    //print '<br />';
    //var_dump($h_t_label);
    //print '<br />';
    //var_dump($h_t_label_c);
    //print '<br />';

    //head:kw
    //print '<br />';
    //print '<br />';


    //var_dump($h_k_show);
    //print '<br />';
    //var_dump($h_k_count);
    //print '<br />';
    //var_dump($h_k_count_d);
    //print '<br />';
    //var_dump($h_k_count_c);
    //print '<br />';
    //var_dump($h_k_rel);
    //print '<br />';
    //var_dump($h__k_rel_d);
    //print '<br />';
    //var_dump($h__k_rel_c);
    //print '<br />';
    //var_dump($h_k_label);
    //print '<br />';
    //var_dump($h_k_label_c);
    //print '<br />';

    //head:desc
    //print '<br />';
    //print '<br />';


    //var_dump($h_d_show);
    //print '<br />';
    //var_dump($h_d_length);
    //print '<br />';
    //var_dump($h_d_length_d);
    //print '<br />';
    //var_dump($h_d_length_c);
    //print '<br />';
    //var_dump($h_d_kwin);
    //print '<br />';
    //var_dump($h_d_rel);
    //print '<br />';
    //var_dump($h_d_rel_d);
    //print '<br />';
    //var_dump($h_d_rel_c);
    //print '<br />';
    //var_dump($h_d_label);
    //print '<br />';
    //var_dump($h_d_label_c);
    //print '<br />';


    //content
    //print '<br />';
    //print '<br />';


    //var_dump($ct_lang);
    //print '<br />';
    //var_dump($ct_chars);
    //print '<br />';
    //var_dump($ct_chars_d);
    //print '<br />';
    //var_dump($ct_chars_c);
    //print '<br />';
    //var_dump($ct_words);
    //print '<br />';
    //var_dump($ct_words_d);
    //print '<br />';
    //var_dump($ct_words_c);
    //print '<br />';
    //var_dump($ct_kwin);
    //print '<br />';
    //var_dump($ct_rel);
    //print '<br />';
    //var_dump($ct_rel_d);
    //print '<br />';
    //var_dump($ct_rel_c);
    //print '<br />';
    //var_dump($ct_kwini);
    //print '<br />';
    //var_dump($ct_kwinb);
    //print '<br />';
    //var_dump($ct_headings);
    //print '<br />';
    //var_dump($ct_iframes);
    //print '<br />';
    //var_dump($ct_label);
    //print '<br />';
    //var_dump($ct_label_c);
    //print '<br />';

    //url structure
    //print '<br />';
    //print '<br />';


    //var_dump($ul_show);
    //var_dump($ul_kwin);
    //var_dump($ul_length);
    //var_dump($ul_length_d);
    //var_dump($ul_length_c);
    //var_dump($ul_sub);
    //var_dump($ul_label);
    //var_dump($ul_label_c);

    //link
    //print '<br />';
    //print '<br />';


    //var_dump($l_ilinks);
    //var_dump($l_ilinks_d);
    //var_dump($l_ilinks_c);
    //var_dump($l_elinks);
    //var_dump($l_elinks_d);
    //var_dump($l_elinks_c);
    //var_dump($l_label);
    //var_dump($l_label_c);

    //user exp
    //print '<br />';
    //print '<br />';

    //var_dump($u_speed);
    //print '<br />';
    //var_dump($u_speed_d);
    //print '<br />';
    //var_dump($u_speed_c);
    //print '<br />';
    //var_dump($u_gram);
    //print '<br />';
    //var_dump($u_gram_d);
    //print '<br />';
    //var_dump($u_gram_c);
    //print '<br />';
    //var_dump($u_res);
    //print '<br />';
    //var_dump($u_fb);
    //print '<br />';
    //var_dump($u_label);
    //print '<br />';
    //var_dump($u_label_c);
    //print '<br />';

  }

}
else{
  $df_status = false;
}

?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <?php require_once('php/header.php'); ?>
    <script src="js/bootstrap-tabs.js"></script>
      <script src="js/functions.js" type="text/javascript"></script>
    <script>


        function viewpdf(){
             // base64_encode($('#alltabs').html()); 
              $('#vpdfdata').val($('#alltabs').html());
              $('#type').val('1');
              $( "#vpdfform" ).submit();
        }
        function dlpdf(){
              $('#vpdfdata').val($('#alltabs').html());
              $('#type').val('2');
              $( "#vpdfform" ).submit();
        }

       $(document).ready(function() {
      

         $('.tabs button').click(function(){
           switch_tabs($(this));
         });
        
         switch_tabs($('.defaulttab'));
        
       });
       function switch_tabs(obj)
       {
         $('.tab-content').hide();
         $('.tabs button').removeClass("selected");
         var id = obj.attr("rel");
        
         $('#'+id).show();
         obj.addClass("selected");
       }
    </script>

  </head>
  <body>
  
    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="brand" href="index.php"><?php print $name ?></a>
          <div class="nav-collapse collapse">
            <ul class="nav pull-right ">
              <li class="classicpointer indicator"><a><i><?php print $slogan ?></i></a></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>

    <div class="container">
    

    <?php

    #Check if the framework is available to non-admin users

     if($is_pb == '0'){
       if(!isset($_SESSION['admin'])){
          $footer = '</div>' . file_get_contents('php/footer.php');
          die('

            <h2>'.$lang['err_notloggedin'].'</h2><br /><br />

            ' . $footer);
        }
      } 

    ?>


    <center><?php  print  !empty($ad) ? $ad  :  ''; ?></center>


    <div class="row">

      <div class="span12">

      <form id="vpdfform" action="pdf.php" method="post">
        <input type="hidden" name="vpdfdata" id="vpdfdata"/>
         <input type="hidden" name="type" id="type"/>
      </form>


     <br />

     <?php

  $url  = trim(urldecode($_GET['site'])); 
  $original_url = $url;
  print '<h3 class="nomargin"> <img src="img/status.png"/> '.$lang['analised_loading'].': <span class="blueboy">'. trim(htmlentities($original_url,ENT_QUOTES,'UTF-8')) . '</span>';
  $site_headers = explode("\r\n",getHeaders($url));
  if(!empty($site_headers[0])){
  $httpcode = httpcodextractor($site_headers[0]);
  if($httpcode == 200 || $httpcode == 500 || $httpcode == 301 || $httpcode == 302 || $httpcode == 403){
  
     print ' <span class="ok"> <img src="img/on.png" /> ['.$lang['analised_host_up'].']</span> </h3>';

     if($df_status == true){

     add_site($url . '[&keywords='.$_GET['keywords'] . '&profile=' .  $_GET['profile'] . ']','data/sites.txt');
    #here the magic starts
    require_once('php/core.php'); 
    #and here it ends
    print '<h3 class="nomargin"> <img src="img/raport.png"/> '.$lang['analised_profile'].': <i>"<span class="blueboy">'. $g_name .'</span>"</i></h3> ';

    print '<h3 class="nomargin"> <img src="img/key.png"/> '.$lang['analised_keywords_used'].': <i>"<span class="blueboy">'. $printkw .'</span>"</i></h3> ';

    if($incl_pdf == '1'){
      print '<h3 class="nomargin"> <img src="img/pdf.png"/> <a class="blueboy" onClick="viewpdf();" href="#">'.$lang['analised_view'].'</a> / <a class="blueboy" href="#" onClick="dlpdf();">'.$lang['analised_dl_download'].'</a> '.$lang['analised_the_pdf'].' </h3> ';
    }

    print '<hr>';

    #and now let`s print the results

    //
    // Domain Informations
    //    


    print '<div class="row">

   <center>
      <h3 class="nomargin"><img src="img/score.png"/>'.$lang['analised_score'].': '. ($final_score) .'/100 <img src="img/timer_b.png"> '.$lang['analised_generated'].' '.($total_time).' s</h3>
  
    </div>

    <div class="progress">';

    $final_score = (int)$final_score;
    if($final_score > 33){
      print '<div class="bar bar-danger" style="width: 33%;">'.$lang['analised_bad'] .'</div>';
        $final_score = $final_score - 33;
    }
    elseif($final_score != 0){
      print '<div class="bar bar-danger" style="width: '. ($final_score) .'%;">'.$lang['analised_bad'] .'</div>';
      $final_score = 0;
    }
    else{
      $final_score = 0;
    }
    if($final_score > 33){
      print '<div class="bar bar-warning" style="width:33%;">'.$lang['analised_bad'] .'</div>';
      $final_score = $final_score - 33;
    }
    elseif($final_score != 0){
      print '<div class="bar bar-warning" style="width:'.($final_score).'%;">'.$lang['analised_decent'] .'</div>';
      $final_score = 0;
    }
    else{
      $final_score = 0;
    }
    if($final_score > 33){
      print '<div class="bar bar-success" style="width:33%;">'.$lang['analised_bad'] .'</div>';
        $final_score = $final_score - 33;
    }
    elseif($final_score != 0){
        print '<div class="bar bar-success" style="width:'.($final_score).'%;">'.$lang['analised_perfect'] .'</div>';
        $final_score = 0;
    }
    else{
      $final_score = 0;
    }
      
      
    print '</div>

    </center>

    <hr>

    <div class="span2">
    </div>

    <div class="span4" >
    <h3 class="blueboy"><i class="icon-hdd nostyle blueboy notsobigicon"></i> <span class="bluerboy">'.$lang['analised_host_info'].'</span></h3>
      '.$lang['analised_host_adress'].': ' . $ip . ' | <a href="http://www.spamhaus.org/query/domain/'.clean_url($original_url).'" target="_blank">'.$lang['analised_host_blacklist_status'].'</a> <br />
      '.$lang['analised_host_country'].': ' . $country . '<br />
      '.$lang['analised_host_region'].': ' . $region . '<br />
      '.$lang['analised_host_provider'].': ' . $isp . '<br />
    </div>

    <div class="span4" >
     <h3 class="blueboy"><i class="icon-bookmark-empty nostyle blueboy notsobigicon"></i> <span class="bluerboy">'.$lang['analised_domain_info'].'</span></h3>
      '.$lang['analised_domain_pagerank'].': ' . $pagerank . '<br/>
      '.$lang['analised_domain_alexarank'].': '. $alexa_rank .'<br/>
      '.$lang['analised_domain_alexapopularity'].': '. $alexa_popularity .'<br/>
      '.$lang['analised_domain_whois'].': <a href="http://whois.net/whois/'.clean_url(htmlentities($original_url,ENT_QUOTES,"UTF-8")).'" target="_blank">'.$lang['analised_domain_view_whois'].'</a>
    </div>

    </div>

    <br />

    
    <div class="row" >
    <center>

      <h3 class="blueboy"><i class="icon-graph nostyle blueboy notsobigicon"></i> <span class="bluerboy">'.$lang['analised_seo_raport'].'</span></h3>
    <div id="buttons">
      <ul class="tabs">';
        
        $cat_nr = 1;

        if($s_crawling == true){
          print '<button href="#" '. ($cat_nr == 1 ? 'class="defaulttab"' : '') .' rel="tabs1">'.$lang['category_crawling'].'</button>';
          $nr_crawling = $cat_nr;
          $cat_nr++;
        }
        else{
          $nr_crawling = false;
        }
        if($s_head == true){
          print '<button href="#" '. ($cat_nr == 1 ? 'class="defaulttab"' : '') .' rel="tabs2">'.$lang['category_head'].'</button>';
          $nr_head = $cat_nr;
          $cat_nr++;
        }
        else{
          $nr_head = false;
        }
        if($s_content == true){
          print '<button href="#" '. ($cat_nr == 1 ? 'class="defaulttab"' : '') .' rel="tabs3">'.$lang['category_content'].'</button>';
          $nr_content = $cat_nr;
          $cat_nr++;
        }
        else{
          $nr_content = false;
        }
        if($s_url == true){
          print '<button href="#" '. ($cat_nr == 1 ? 'class="defaulttab"' : '') .' rel="tabs4">'.$lang['category_url'].'</button>';
          $nr_url = $cat_nr;
          $cat_nr++;
        }
        else{
          $nr_url = false;
        }
        if($s_links == true){
          print '<button href="#" '. ($cat_nr == 1 ? 'class="defaulttab"' : '') .' rel="tabs5">'.$lang['category_links'].'</button>';
          $nr_links = $cat_nr;
          $cat_nr++;
        }
        else{
          $nr_links = false;
        }
        if($s_ux == true){
          print '<button href="#" '. ($cat_nr == 1 ? 'class="defaulttab"' : '') .' rel="tabs6">'.$lang['category_ux'].'</button>';
          $nr_ux = $cat_nr;
          $cat_nr++;
        }
        else{
          $nr_ux = false;
        }
      

      print '</ul></div>
      </center>
    



    ';


    //
    //Crawiling report printing
    //

    print '<div id="alltabs">';

    if($s_crawling == true){

    print '<div class="tab-content" id="tabs1">
    <h3 class="bluerboy">'. $nr_crawling .'. <span class="blueboy"> '.$lang['category_crawling'].'</span></h3>';

    if($c_http == 'true'){

      print '
        <br />
        <strong><i>'.$lang['crawling_http'].'</i></strong>' . $msg_httpcode .
        '<br />
        <br />
        <div class="alert alert-block" style="padding: 8px 35px 8px 14px; background-color: rgb(252, 248, 227); border: 1px solid rgb(251, 238, 213); color: rgb(252, 248, 227);color:black;">
        ';

        foreach($site_headers as $header){
            if(trim($header) != ''){
               print $header . '<br />';
            }
        }

        print '
        </div>';

      }

      if($c_robots == 'true'){

        print ' <strong> <i>'.$lang['crawling_robots'].'</i> </strong>' .  $msg_robots . '
        <br /><br />';

      }

      if($c_sitemap == 'true'){

        print '<strong><i> '.$lang['crawling_sitemap'].' </i></strong>' .  $msg_sitemapcheck . '
        <br /><br />';

      }

      if($c_label == 'true'){

      print '<div class="alert alert-info ablue">
        <strong>'.$lang['label_tips'].':</strong> 
        '.$c_label_c.'
      </div>';

      }

      print '</div>';

      }

      //
      //head elements report printing
      //

      if($s_head == true){

      print '<div class="tab-content" id="tabs2">
      <h3 class="bluerboy">'. $nr_head .'. <span class="blueboy"> '.$lang['category_head'].'</span></h3>
      <br />';

      //title

      $nr_head_sub  = -1;
      $head_sub_chr = array('A','B','C'); 

      if($h_t_show == 'true' || $h_t_length == 'true' || $h_t_stopwords == 'true' || $h_t_kwin == 'true' || $h_t_rel == 'true'){

          $nr_head_sub++;

            
          print '<span class="bluerboy">'.$head_sub_chr[$nr_head_sub].')</span> <strong><i> '.$lang['head_title_check'].'</i></strong><br /><br />';
          print '<table>
                  <tbody>';
                    
                    if($h_t_show == 'true'){

                      //Anti XSS
                      if(is_int(strpos($msg_title,'<span class='))){
                        $msg_title = $msg_title;
                      }
                      else{
                        $msg_title = htmlentities($msg_title,ENT_QUOTES,'UTF-8');
                      }


                      print '<tr>
                        <td>'.$lang['head_title_title'].':&nbsp;&nbsp;</td>
                        <td>' . $msg_title . '</td>
                      </tr>';
                    }

                    if($h_t_length == 'true'){
                      print '<tr>
                        <td>'.$lang['head_title_length'].':&nbsp;&nbsp;</td>
                        <td>' . $msg_titlelenght . '</td>
                      </tr>';
                    }

                    if($h_t_stopwords == 'true'){
                      print '<tr>
                        <td>'.$lang['head_title_stop_words'].':&nbsp;&nbsp;</td>
                        <td>' . $msg_titlestopwords . '</td>
                      </tr>';
                    }

                    if($h_t_kwin == 'true'){
                      print '<tr>
                        <td>'.$lang['head_title_kwintitle'].':&nbsp;&nbsp;</td>
                        <td>' . $msg_kwintitle . '</td>
                      </tr>';
                    }

                    if($h_t_rel == 'true'){
                      print '<tr>
                        <td>'.$lang['head_title_relevance'].':&nbsp;&nbsp;</td>
                        <td>' . $msg_kw2titlerel . '</td>
                      </tr>';
                    }

                  print '</tbody>
                </table>
                <br />
                 ';

            if($h_t_label == 'true'){
            print '<div class="alert alert-info" style="padding: 8px 35px 8px 14px; background-color: rgb(217, 237, 247); border: 1px solid rgb(188, 232, 241); color: rgb(58, 135, 173);">
              <strong>'.$lang['label_tips'].'</strong> 
              '.$h_t_label_c.'
            </div>';
            }

      }

      //keywords


      if($h_k_show == 'true' || $h_k_count == 'true' ||  $h_k_rel == 'true' ){

          $nr_head_sub++;

          print '<span class="bluerboy">'.$head_sub_chr[$nr_head_sub].')</span> <strong><i> '.$lang['head_kw_keywords_check'].'</i></strong><br/><br />';

          print '<table>
                        <tbody>';
                         
                         if($h_k_show == 'true'){

                            //Anti XSS
                            if(is_int(strpos($msg_metakeywords,'<span class='))){
                              $msg_metakeywords = $msg_metakeywords;
                            }
                            else{
                              $msg_metakeywords = htmlentities($msg_metakeywords,ENT_QUOTES,'UTF-8');
                            }

                            print '<tr>
                              <td>'.$lang['head_kw_keywords'].':&nbsp;&nbsp;</td>
                              <td>' . $msg_metakeywords . '</td>
                            </tr>';
                          }

                          if($h_k_count == 'true'){
                            print '<tr>
                              <td>'.$lang['head_kw_count'].':&nbsp;&nbsp;</td>
                              <td>' . $msg_keywordcountstats . '</td>
                            </tr>';
                          }

                          if($h_k_rel == 'true'){
                            print '<tr>
                              <td>'.$lang['head_kw_rel'].':&nbsp;&nbsp;</td>
                              <td>'. $msg_metakeywordsrel . '</td>
                            </tr>';
                          }

                        print '</tbody>
                      </table>
                      <br />
                      ';

          if($h_k_label == 'true'){
          print '<div class="alert alert-info" style="padding: 8px 35px 8px 14px; background-color: rgb(217, 237, 247); border: 1px solid rgb(188, 232, 241); color: rgb(58, 135, 173);">
            <strong>'.$lang['label_tips'].':</strong> 
            '.$h_k_label_c.'
          </div>';
          }

      }


      //description


      if($h_d_show == 'true' || $h_d_length == 'true' || $h_d_kwin == 'true' || $h_d_rel == 'true'){

      $nr_head_sub++;

      print '<span class="bluerboy">'.$head_sub_chr[$nr_head_sub].')</span> <strong><i> '.$lang['head_desc_check'].' </i></strong><br/><br/>';
     
      print '<table>
                    <tbody>';

                    if($h_d_show == 'true'){

                       //Anti XSS
                       if(is_int(strpos($msg_metadesctext,'<span class='))){
                         $msg_metadesctext = $msg_metadesctext;
                       }
                       else{
                         $msg_metadesctext = htmlentities($msg_metadesctext,ENT_QUOTES,'UTF-8');
                       }

                        print '<tr>
                          <td>'.$lang['head_desc_desc'].':&nbsp;&nbsp;</td>
                          <td>' . $msg_metadesctext . '</td>
                        </tr>';
                      }

                      if($h_d_length == 'true'){
                        print '<tr>
                          <td>'.$lang['head_desc_length'].':&nbsp;&nbsp;</td>
                          <td>' . $msg_descleng . '</td>
                        </tr>';
                      }

                      if($h_d_kwin == 'true'){
                        print '<tr>
                          <td>'.$lang['head_desc_kwindesc'].':&nbsp;&nbsp;</td>
                          <td>'. $msg_metakwindesc . '</td>
                        </tr>';
                      }

                      if($h_d_rel == 'true'){
                         print '<tr>
                          <td>'.$lang['head_desc_relevance'].':&nbsp;&nbsp;</td>
                          <td>'. $msg_metadescrel . '</td>
                        </tr>';
                      }

                    print '</tbody>
                  </table>
                  <br /><br />
                  ';

        if($h_d_label == 'true'){
          print '<div class="alert alert-info" style="padding: 8px 35px 8px 14px; background-color: rgb(217, 237, 247); border: 1px solid rgb(188, 232, 241); color: rgb(58, 135, 173);">
            <strong>'.$lang['label_tips'].':</strong> 
            '.$h_d_label_c.'
          </div>';
        }
      }

      print '</div>';

      }

      //
      //content report printing
      //


      if($s_content == true){

      print '<div class="tab-content" id="tabs3">
      <h3 class="bluerboy">'.$nr_content.'. <span class="blueboy"> '.$lang['category_content'].'</span></h3>
      <br />';
      
      print '<table>
             <tbody>';

               if($ct_lang == 'true'){
                   print '<tr>
                     <td>'.$lang['content_language'].':&nbsp;&nbsp;</td>
                     <td>' . $msg_lang . '</td>
                   </tr>';
               }

               if($ct_chars == 'true'){
                   print '<tr>
                     <td>'.$lang['content_charcount'].':&nbsp;&nbsp;</td>
                     <td>' . $contentlenght . '</td>
                   </tr>';
               }

               if($ct_words == 'true'){
                   print '<tr>
                     <td>'.$lang['content_wordcount'].':&nbsp;&nbsp;</td>
                     <td>'. $contentwords . '</td>
                   </tr>';
                }

                if($ct_kwin == 'true'){
                    print '<tr>
                     <td>'.$lang['content_kwin'].':&nbsp;&nbsp;</td>
                     <td>'. $kwincontent . '</td>
                   </tr>';
                }


              if($ct_rel == 'true'){
                  print '<tr>
                     <td>'.$lang['content_rel'].':&nbsp;&nbsp;</td>
                     <td>'. $contentrelevance . '</td>
                   </tr> '; 
              }

              if($ct_kwini == 'true'){
                  print '<tr>
                     <td>'.$lang['content_kwini'].':&nbsp;&nbsp;</td>
                     <td>'. $msg_contentitalics . '</td>
                   </tr> ';
              }

              if($ct_kwinb == 'true'){
                  print '<tr>
                     <td>'.$lang['content_kwinb'].':&nbsp;&nbsp;</td>
                     <td>'. $msg_contentbold . '</td>
                   </tr> ';
              }

              if($ct_headings == 'true'){
                  print '<tr>
                     <td>'.$lang['content_headings'].':&nbsp;&nbsp;</td>
                     <td>'. $msg_contentheadings . '</td>
                   </tr> '; 
              }

              if($ct_iframes == 'true'){
                  print '<tr>
                     <td>'.$lang['content_iframes'].':&nbsp;&nbsp;</td>
                     <td>'. $msg_contentframes . '</td>
                   </tr> '; 
              }

            print ' 
             </tbody>
           </table>
           <br /><br />
           ';

      if($ct_label == 'true'){
        print '<div class="alert alert-info" style="padding: 8px 35px 8px 14px; background-color: rgb(217, 237, 247); border: 1px solid rgb(188, 232, 241); color: rgb(58, 135, 173);">
          <strong>'.$lang['label_tips'].':</strong> 
          '.$ct_label_c.'
        </div>';
      }

      print '</div>';

      }

      //
      //url structure report printing
      //


      if($s_url == true){

      print '<div class="tab-content" id="tabs4">
      <h3 class="bluerboy">'.$nr_url.'. <span class="blueboy"> '.$lang['category_url'].'</span></h3><br />';

      print '<table>
                    <tbody>';

                    if($ul_show == 'true'){
                      print '<tr>
                        <td>'.$lang['url_domain'].':&nbsp;&nbsp;</td>
                        <td>' . $msg_urldomain . '</td>
                      </tr>';
                    }

                    if($ul_kwin == 'true'){
                      print '<tr>
                        <td>'.$lang['url_kwin'].':&nbsp;&nbsp;</td>
                        <td>' . $msg_kwinurl . '</td>
                      </tr>';
                    }

                    if($ul_length == 'true'){
                      print '<tr>
                        <td>'.$lang['url_length'].':&nbsp;&nbsp;</td>
                        <td>'. $msg_urldomainlenght . '</td>
                      </tr>';
                    }

                    if($ul_sub == 'true'){
                       print '<tr>
                        <td>'.$lang['url_subdomains'].':&nbsp;&nbsp;</td>
                        <td>'. $msg_urlsubdomain . '</td>
                      </tr>';
                    }

                  print '</tbody>
                  </table>
                  <br /><br />
                  ';

      if($ul_label == 'true'){
        print '<div class="alert alert-info" style="padding: 8px 35px 8px 14px; background-color: rgb(217, 237, 247); border: 1px solid rgb(188, 232, 241); color: rgb(58, 135, 173);">
          <strong>'.$lang['label_tips'].':</strong> 
        '.$ul_label_c.'
        </div>
        </div>';
      }

      }

      //
      //links report printing
      //



      if($s_links == true){

      print '<div class="tab-content" id="tabs5">
      <h3 class="bluerboy">'.$nr_links.'. <span class="blueboy"> '.$lang['category_links'].'</span></h3><br />';

      print '<table>
                    <tbody>';

                    if($l_ilinks == 'true'){
                      print '<tr>
                        <td>'.$lang['links_i'].':&nbsp;&nbsp;</td>
                        <td>' . $msg_internalinks . '</td>
                      </tr>';
                    }

                    if($l_elinks == 'true'){
                      print '<tr>
                        <td>'.$lang['links_e'].':&nbsp;&nbsp;</td>
                        <td>' . $msg_externalinks . '</td>
                      </tr>';
                    }

                    print '</tbody>
                  </table>
                  <br /><br />
                  ';    

        if($l_label == 'true'){
          print '<div class="alert alert-info" style="padding: 8px 35px 8px 14px; background-color: rgb(217, 237, 247); border: 1px solid rgb(188, 232, 241); color: rgb(58, 135, 173);">
            <strong>'.$lang['label_tips'].':</strong> 
            '.$l_label_c.'
          </div>
          ';
        }
        print ' </div>';
      }

      //
      // User experience check printing
      //

      if($s_ux == true){

      print '<div class="tab-content" id="tabs6">
      <h3 class="bluerboy">'.$nr_ux.'. <span class="blueboy"> '.$lang['category_ux'].'</span></h3><br />';

      print '<table>
                    <tbody>';

                    if($u_speed == 'true'){
                        print '<tr>
                          <td>'.$lang['ux_pagespeed'].':&nbsp;&nbsp;</td>
                          <td>' . $msg_speed . '</td>
                        </tr>';
                    }

                    if($u_gram == 'true'){
                        print '<tr>
                          <td>'.$lang['ux_grammar'].':&nbsp;&nbsp;</td>
                          <td>' . $msg_spelling . ' <i>(Beta)</i></td>
                        </tr>';
                      }


                      if($u_res == 'true'){
                        print '<tr>
                          <td>'.$lang['ux_responsive'].':&nbsp;&nbsp;</td>
                          <td>'. $msg_responsive . '</td>
                        </tr>';
                      }


                      if($u_fb == 'true'){
                       print '<tr>
                        <td>'.$lang['ux_contact'].':&nbsp;&nbsp;</td>
                        <td>'. $msg_feedback . '</td>
                      </tr>';
                      }
                    
                    print '</tbody>
                  </table>
                  <br /><br />
                  ';
      if($u_label == 'true'){

      print '<div class="alert alert-info" style="padding: 8px 35px 8px 14px; background-color: rgb(217, 237, 247); border: 1px solid rgb(188, 232, 241); color: rgb(58, 135, 173);">
          <strong>'.$lang['label_tips'].':</strong> 
          '.$u_label_c.'
        </div>
        ';

      }

      print '</div>';

    }

    print '</div>';

    }
    else{
      print '<h3 class="nomargin"> <img src="img/raport.png"/> '.$lang['analised_profile'].': <i>"<span class="redboy">'.$lang['err_notprovided'].'</span>"</i></h3><hr>
      <h3><i class="icon-info-sign nostyle notsobigicon"></i> '.$lang['analised_profile_err'].'.</h3>
       ';
    }

     
  }
  else{
      print '<span class="nok"> <img src="img/off.png" /> ['.$lang['analised_host_down'].']</h3> <hr/> <h3><i class="icon-info-sign nostyle notsobigicon"></i> '.$lang['analised_host_down_tips'].'</h3>';
  }
  }
  else{
      print '<span class="nok"> <img src="img/off.png" /> ['.$lang['analised_host_down'].']</h3> <hr/> <h3><i class="icon-info-sign nostyle notsobigicon"></i> '.$lang['analised_host_down_tips'].'</h3>';
  }

  ?>



      </div>

    </div>



    </div>
    <br/><br/>
    <?php require_once('php/footer.php'); ?>
    <!-- Le javascript
    ================================================== -->
   <script src="js/bootstrap.js"></script>
  </body>
</html>
