<?php
ob_start();
require_once('php/config.php');

?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <?php require_once('php/header.php'); ?>
    
    <script type="text/javascript">
      $( document ).ready(function() {
        profile = $('#pfile').val();
        $.post("php/xmlreq.php", { q: "gd", i: profile})
        .done(function(data) {
           $('#descrbox').html(data);
         });
        $( "#pfile" ).change(function() {
                profile = $('#pfile').val();
                $.post("php/xmlreq.php", { q: "gd", i: profile})
               .done(function(data) {
                  $('#descrbox').html(data);
                });
        });
      });
    </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">

      <br />

      <div class="row">
          <div class="span12 well">

      <h1><i class="icon-asl nostyle bigicon"></i> <?php print $lang['main_welcome_to']; ?> <span class="blueboy"><?php print $name; ?></span></h1>
    <p><?php print $main_text; ?></p>
      <br />
      <div class="row">
<center>
  <div class="span12">
    <form method="get" action="analyser.php" class="form-inline" >
      <span class="lind"><?php print $lang['main_site'];  ?>:</span> <input name="site" class="span3" type="text" placeholder="<?php print $lang['main_site_placeholder']; ?>">
      <?php
      if($incl_kw == '1'){
        print '<span class="lind">'.$lang['main_keywords'].':</span><input name="keywords" class="span3" type="text" placeholder="'.$lang['main_keywords_placeholder'].'">&nbsp;';
      }
      if($incl_sp == '1'){

           if(!file_exists('data/profiles/'. str_replace('"','',$pfile))){
              $fileE = false;
            }
            else{
              $fileE = true;
            }


           $sel = 'selected';
           $files = scandir('data/profiles');
            unset($files[0],$files[1]);
            $pfiles = '<select name="profile" id="pfile">';
            foreach($files as $file){
               $seoProfiles = new IniParser('data/profiles/' . $file);
                $g_ispb   = $seoProfiles->getValue("g_ispb");
                $iname    = $seoProfiles->getValue("g_name");
                $ifiles[$file] = $iname;
                if((int)$g_ispb == 1){
                  if($fileE == true){
                    $pfiles = $pfiles .  '<option value="'.str_replace('.ini','',$file).'"  '. ($file == $pfile ? $sel :  '') .'>'.$iname.'</option>';
                  }
                  else{
                    $pfiles = $pfiles .  '<option value="'.str_replace('.ini','',$file).'" >'.$iname.'</option>';
                  }
                  
                
                }
            }
            $pfiles .= '</select>';
            
            if(is_int(strpos($pfiles,'<option'))){
              print ' <span class="lind">'.$lang['main_seo_profile'].': </span>' . $pfiles;
            }
            else{
              print '<span class="lind">'.$lang['main_seo_profile'].': </span><span class="lind" style="color:#dd4814"> <i>('.$lang['main_seo_profile_not'].')</i></span>';
            }
      }
      else{
        print '<input type="hidden" name="profile" value="'.str_replace('.ini','',$pfile).'" />';
      }

      ?>
      <button type="submit" class="btn btn-primary" > <i class="icon-search icon-white nostyle"></i></button>
    </form>

    <?php

    if($incl_sp == '1'){
    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['main_about_profile'].':</strong> 
       <span id="descrbox"></span>
      </div> ';
    }
    ?>

  </div>
</center>
</div>

  
      </div>
  </div>

  <div class="row">
        <div class="span12 well">

   <h1><i class="icon-braille nostyle bigicon"></i> <?php print $lang['main_sites_analysed']; ?>:</h1>
   <br />


   <?php
   $file = array_reverse(file('data/sites.txt'));
   for($j=0;$j<3;$j++){
    print '<div class="latest">
    ';
     for($i=0;$i<5;$i++){
    $s_url = clean_url($file[$i]);
    if(strlen($s_url) > 16){
      $s_url = substr($s_url,0,16) . '...';
      }
      $urlparts = explode('[',$file[$i]);
      $domain = clean_url($urlparts[0]);
      $components = str_replace(']', '', $urlparts[1]);
      print '<span class="aqua"><a href="analyser.php?site='.$domain . $components .'" >'. $domain .'</a></span><br />';
     }
     print '
     </div>';
     unset($file[0],$file[1],$file[2],$file[3],$file[4]);
     $file = array_values($file);
   }
   ?>


      </div>
   </div>

   <br />

      <?php
      if($incl_fb == '1'){

        print '   <div class="row">
        <div class="span12 well">
          <h2><i class="icon-facebook nostyle bigicon"></i> '.$lang['main_like_us'].'</h2>
          <center>
          <div class="well ">
         <iframe src="//www.facebook.com/plugins/likebox.php?href='.str_replace('"', '', $fb_link).'&width=950&amp;height=258&amp;colorscheme=light&amp;show_faces=true&amp;header=false&amp;stream=false&amp;show_border=false" scrolling="no" frameborder="0" style="border:1px solid grey; overflow:hidden; width:950px; height:258px;" allowTransparency="true"></iframe>
          </div>
          </center>
        </div>
      </div>';

      }
      ?>




      </div>

    </div>



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