<?php require_once('setcookie.php');?>
<?php include('../config.php');?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<title>Administration panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="author" content="anish" /> 
<meta name="keywords" content=" "/>
<meta name="description" content="Valuable informations about <?php echo $keyword; ?> at <?php echo $mysitename; ?>">
<meta name="ROBOTS" content="ALL"/>

<link href="andreas09.css" rel="stylesheet" type="text/css" />

<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>

<body>
<div id="container">
<div id="sitename">


<h1><?php echo $mysitename; ?></a></a></h1>
<h2>Admin area</h2><br>
 
</div>
<div id="mainmenu">


<?php include('navbar.php');?>
</div>
<!-- end header -->
<div id="wrap">
	

	<div id="rightside">
	<?php include("rightside.php");?>
	</div>

<div id="contentalt">

<?PHP
// check that permissions on files are correct
  if($_REQUEST['a_d']!="yes"){
    $writable="";
    if (!is_writable('../config.php')){
        $writable['../config.php']=false;
        echo "You need to change the permissions to datas/config.php in order to configure your site";
        }else{
        $writable['../config.php']=true;
        }
  
   
        
   
    } 
  
?>
<?PHP


function page_header(){
    print 'Config.php installer
   
    
';
}


//lets load the stuff that's in the config.php already.
if (file_exists('../config.php')){
    include('../config.php');
    }else{
    //check if access rights are such that config.php can be created.
    }
if ($_REQUEST['a_d']!="yes" && $_REQUEST['create_config']==""){
    page_header();
    //phpinfo();
    ?>
	
	<?php 
	function check_check($checkbox){
if ($checkbox=="1"){
echo "checked='checked'";
}else{
echo "";
}
}
function check_uk($amazcountry){
if ($amazcountry=="uk"){
echo "checked='checked'";
}else{
echo "";
}
}
function check_us($amazcountry){
if ($amazcountry=="us"){
echo "checked='checked'";
}else{
echo "";
}
}
function check_searticle($seart){
if (!$seart=="0"){
echo "checked='checked'";
}else{
echo "";
}
}
?>
<style type="text/css">
<!--
.style1 {color: #990000}
.style2 {color: #FF0000}
.style3 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: smaller;
}
.style4 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
	font-size: smaller;
}
.style5 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style6 {font-size: smaller}
.style8 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: smaller; font-style: italic; }
.style10 {font-size: smaller; color: #990000; }
-->
</style>

    <div >
     <form method="POST" action="<?PHP print $_SERVER['PHP_SELF']?>">
    <table width="95%"  border="1" align="center" cellpadding="2" cellspacing="2" bordercolor="#990000">
      <tr>
        <td colspan="2"><h1 align="center"><span class="style1">Configuration panel :</span></h1>
        <h3 align="center"><span class="style1"> this is the place where you will update the &quot;config.php&quot; file </span></h3></td>
      </tr>
      <tr>
        <td colspan="2"><P class="style3"><span class="style2">WARNING</span> : Make sure your config.php file is writeable by the server (666 or 777)<br />
          Once the script is completed, chmod it back to 644 </P>
          <h3>Please answer the following questions or You can also edit the <i>Config.php file</i> by <a href="./edit_file.php?file=site_config" target=_blank>clicking here</a> to make any changes you want manually</h3>
          <span class="small">Guesses are already in the boxes please check if they are correct</span></strong></P>
        <P class="style3">&nbsp;</P></td>
      </tr>
      <tr bordercolor="#000099">
        <td width="28%"><h2><span class="style4">What "Monetization modules" do you want to include ?</span></h2></td>
        <td width="72%"><span class="style3">
          <input name="show_google" type="checkbox"  <?php check_check($show_google);?>>
          <strong>Adsense</strong> (3 blocks + 1 text links ads above the navigation)<br />
<input type="checkbox" name="show_yahoo" <?php check_check($show_yahoo);?>>
<strong>Yahoo YPN</strong> - Do not check if Adsense is Checked (3 blocks) <br />
<input name="show_sf" type="checkbox" <?php check_check($show_sf);?> >
<strong>SearchFeed</strong> (on the main column, just below the articles) <br />
<input name="show_amazon" type="checkbox"  <?php check_check($show_amazon);?>>
<strong>Amazon feed</strong>s (on the right column, below the Google skycraper)<br />
<input name="show_chitika" type="checkbox" <?php check_check($show_chitika);?> >
<strong>Chitika</strong> ( on the right column, below the Amazon feeds) </span></td>
      </tr>
      <tr>
        <td bordercolor="#000033"><p class="style4">&nbsp;</p>
        <h2 class="style4">What "Personalization modules" do you want to include ?</h2></td>
        <td>
          <p class="style3"><strong>On the left column :</strong> <br>
		    <input name="show_partners" type="checkbox"  <?php check_check($show_partners);?>>
            Display Link to the Partners' area (top of the navigation menu) <br />
			<input name="show_bestseller" type="checkbox" <?php check_check($show_bestseller);?>>
          Display the "Best Seller" module (just below the navigation menu on the left)<br>
		  <input name="show_bestproducts" type="checkbox" <?php check_check($show_bestproducts);?>>
          Display the "Best Products"  module (just below the Best Seller module)</p>
		  <p><strong>On the main column (center) :</strong> <br>
		  <input name="show_persobanner_center" type="checkbox" <?php check_check($show_persobanner_center);?>>
          Display the "Personal Central Banner" module (just below the article - actually used to display random article snippets)</p>
			
			<p><strong>On the right column :</strong> <br>
			<input name="show_subscribe" type="checkbox"  <?php check_check($show_subscribe);?>>
            Display Newsletter Subscription form at the top of the right column<br />
            <input type="checkbox" name="show_addarticles" <?php check_check($show_addarticles);?>>
          Allow visitors to submit their own articles and to add them directly to the site - Displayed below the subscription form
		  (a link to the submit form will be displayed if the box is checked) <br>
		  <input name="show_persobanner_right" type="checkbox" <?php check_check($show_persobanner_right);?>>
          Display another "Personal Banner" space below the Adsense / YPN skycraper
		  </p>
		  <p><strong><i>Reformat Articles? : </i></strong><br>
		  <input name="formatarticle" type="checkbox"  <?php check_check($formatarticle);?>>
            Check the box if you want the system to transform the newline (\n characters) by <quote>BR Tags</quote><br>It can be useful for articles that are not formated with html tags.</p>
		  <p></p></td>
      </tr>
      <tr>
        <td><div align="center" class="style3">
          <p>&nbsp;</p>
          <h3><b>Amazon options</b></h3>
        </div></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><div class="style5 style6" id="Item0" >
          <div align="right">Amazon Associate ID :      </div>
        </div></td>
        <td>        <input name="Aassociates_id" type="text" value="<?PHP print $Aassociates_id?>"></td>
      </tr>
      <tr>
        <td><div align="right">Amazon Country :      </div></td>
        <td>  US : <input name="amazcountry" type="radio" value="us" <?php check_us($amazon_country);?>>
        <br>
		UK : <input name="amazcountry" type="radio" value="uk" <?php check_uk($amazon_country);?>></td>
      </tr>
      <tr>
        <td><div align="right" class="style3">Number of results to display : </div></td>
        <td><input name="num_amazon" type="text" value="<?PHP print $num_amazon?>"></td>
      </tr>
      <tr>
        <td><div align="center" class="style3">
          <p>&nbsp;</p>
          <h3><b>Adsense options</b></h3>
        </div></td>
        <td><span class="style6"></span></td>
      </tr>
      <tr>
        <td><div align="right" class="style3">Adsense ID :</div></td>
        <td><input name="adsense_pub" type="text" value="<?PHP print $adsense_pub?>"></td>
      </tr>
      <tr>
        <td><div align="right" class="style3">Channel </div></td>
        <td><input name="adsense_channel" type="text" value="<?PHP print $adsense_channel?>"></td>
      </tr>
      <tr>
        <td><div align="center" class="style3">
          <p>&nbsp;</p>
          <h3><b>Yahoo options</b></h3>
        </div></td>
        <td><span class="style6"></span></td>
      </tr>
      <tr>
        <td><div align="right" class="style3">Yahoo ID :</div></td>
        <td><input name="yahoo_pub" type="text" value="<?PHP print $yahoo_pub?>"></td>
      </tr>
      <tr>
        <td><div align="right" class="style3">Section :</div></td>
        <td><input name="yahoo_channel" type="text" value="<?PHP print $yahoo_channel?>"></td>
      </tr>
      <tr>
        <td><div align="center" class="style3">
          <p>&nbsp;</p>
          <h3><b>SearchFeed options</b></h3>
        </div></td>
        <td><span class="style6"></span></td>
      </tr>
      <tr>
        <td><div align="right"><span class="style3">account ID :</span></div></td>
        <td><input name="sf_account_id" type="text" value="<?PHP print $sf_account_id?>"></td>
      </tr>
      <tr>
        <td><div align="right"><span class="style3">track ID :</span></div></td>
        <td><input name="sf_track_id" type="text" value="<?PHP print $sf_track_id?>"></td>
      </tr>
	  <tr>
        <td><div align="center" class="style3">
          <p>&nbsp;</p>
          <h3><b>Chitika options</b></h3>
        </div></td>
        <td><span class="style6"></span></td>
      </tr>
      <tr>
        <td><div align="right"><span class="style3">account ID :</span></div></td>
        <td><input name="chitika_pub" type="text" id="chitika_pub" value="<?PHP print $chitika_pub?>"></td>
      </tr>
      <tr>
        <td><div align="right"><span class="style3">Channel :</span></div></td>
        <td><input name="chitika_channel" type="text" id="chitika_channel" value="<?PHP print $chitika_channel?>"></td>
      </tr>
      <tr>
        <td><div align="center">
          <p class="style3">&nbsp;</p>
          <h3 class="style3"><b>RSS options</b></h3>
        </div></td>
        <td><span class="style6"></span></td>
      </tr>
      <tr>
        <td><div align="right"><span class="style3">Number of results to display on each page :</span></div></td>
        <td><input name="_numResults" type="text" value="<?PHP print $_numResults?>"></td>
      </tr>
	  <tr>
        <td><div align="center">
          <p class="style3">&nbsp;</p>
          <h3 class="style3"><b>Clickbank</b></h3>
        </div></td>
        <td><span class="style6"></span></td>
      </tr>
      <tr>
        <td><div align="right"><span class="style3">Clickbank ID  :</span></div></td>
        <td><input name="clickbank_pub" type="text" id="clickbank_pub" value="<?PHP print $clickbank_pub?>"></td>
      </tr>
      <tr>
        <td><h2>Article Search Engine </h2></td>
        <td><p><span class="style1">If you enable this feature</span>
          <li>Relevant articles will be displayed for each keyword link (if you have enough relevant articles in the articles folder) : for each keyword, a &quot;database&quot; of the relevant articles (1 or more depending on how many articles you have in the folder) will be created ; when someone visits this keyword page,  the system will pick one of the relevant article (if you have more than 1 relevant article, selection will be random among the keyword relevant articles ) </li>
		  <li>If no relevant article is found, then a random one will be chosen in the articles folder</li> 
		  <li>You can choose the number of links to related articles that will be displayed below the relevant article</li></p>
     <p><span class="style1">If you disable this feature</span> : <br>
       A random article will be selected among all the available articles (no change with what you may have experienced previously)</p> </tr>
      <tr>
        <td><div align="right">Activate the Article Search Engine</div></td>
        <td>Yes : <input type="radio" name="searticles" value="yes" <?php check_searticle($ARTICLEPERPAGE);?>><br>
		No : <input type="radio" name="searticles" value="no"> </td>
      </tr>
      <tr>
        <td><div align="right">How many related articles to you want to display (if you have checked "Yes" above)</div></td>
        <td><input name="ARTICLEPERPAGE" type="text" id="ARTICLEPERPAGE" value="<?PHP print $ARTICLEPERPAGE?>" /> 
          (if you have checked &quot;No&quot; and enter a number different than 0 then it will activate the feature!) </td>
      </tr>
      <tr>
        <td><div align="center">
          <p class="style4">&nbsp;</p>
          <p class="style4">Site Name</p>
        </div></td>
        <td><input name="mysitename" type="text" value="<?PHP print $mysitename?>"></td>
      </tr>
      <tr>
        <td><h2>Personal details</h2> : they will be used for the TOS and Privacy pages</td>
        <td>First name : 
          <input name="firstname" type="text" value="<?PHP print $firstname?>" /><br>
		  Last name : 
          <input name="lastname" type="text" value="<?PHP print $lastname?>" /><br>
		  E-mail : 
          <input name="email" type="text" value="<?PHP print $email?>" /><br>
Autoresponder direct email : <input name="autoresponder" type="text" value="<?PHP print $autoresponder?>" /><br>Example : adsfiresale2@aweber.com		
<br>Domain Name of the install<input name="domainname" type="text" value="<?php print $domainname?>" />The domain where the site is installed format:domainname.com (do not add the www)
  </td>
      </tr>
      <tr>
        <td><div align="center"><span class="style8">I suggest you don't edit below this line if you don't know what you're doing... </span></div></td>
        <td><span class="style6"></span></td>
      </tr>
      <tr>
        <td><div align="right"><span class="style3">Primary Keyword</span></div></td>
        <td><input name="mainkeyword" type="text" value="<?PHP print $mainkeyword?>"></td>
      </tr>
      <tr>
        <td><div align="right"><span class="style3">Templates folder</span></div></td>
        <td><input name="templatefoldername" type="text" value="<?PHP print substr($_SERVER['PHP_SELF'],1,-25)?>" size="40"></td>
      </tr>
      <tr>
        <td><div align="center"><span class="style4">Site URL </span></div></td>
        <td><span class="style6"><b><?PHP print $rooturl?></b></span></td>
      </tr>
      <tr>
        <td><div align="right">
          <h3><span class="style10">Generate the config.php now! </span></h3>
        </div></td>
        <td><span class="style6">
          <input type="submit" name="create_config" value="create config">
        </span></td>
      </tr>
    </table>
     </form>
</div>
<?PHP
}else{
//phpinfo();
    //Create the config file
    if ($_REQUEST['a_d']=="yes"){
        include ('../config.php');
        //$mysitename = $_REQUEST['mysitename'];

        }
  if ($_REQUEST['create_config']!="" || $_REQUEST['a_d']=="yes"){
    foreach($_REQUEST as $k=>$v){
        $$k = $v;
    }

  }
  
 
  if ($show_google=="on"){
  $show_google=1;
  }else{
  $show_google=0;
  }

  if ($show_yahoo=="on"){
  $show_yahoo=1;
  }else{
  $show_yahoo=0;
  }


  if ($show_sf=="on"){
  $show_sf=1;
  }else{
  $show_sf=0;
  }


  if ($show_amazon=="on"){
  $show_amazon=1;
  }else{
  $show_amazon=0;
  }


  if ($show_partners=="on"){
  $show_partners=1;
  }else{
  $show_partners=0;
  }
  
  if ($show_chitika=="on"){
  $show_chitika=1;
  }else{
  $show_chitika=0;
  }


  if ($show_subscribe=="on"){
  $show_subscribe=1;
  }else{
  $show_subscribe=0;
  }
  
  if ($show_persobanner_center=="on"){
  $show_persobanner_center=1;
  }else{
  $show_persobanner_center=0;
  }
  
 if ($show_persobanner_right=="on"){
  $show_persobanner_right=1;
  }else{
  $show_persobanner_right=0;
  }
  
  if ($show_bestseller=="on"){
  $show_bestseller=1;
  }else{
  $show_bestseller=0;
  }
  if ($show_addarticles=="on"){
  $show_addarticles=1;
  }else{
  $show_addarticles=0;
  }
  if ($formatarticle=="on"){
  $formatarticle=1;
  }else{
  $formatarticle=0;
  }
  
  if ($show_bestproducts=="on"){
  $show_bestproducts=1;
  }else{
  $show_bestproducts=0;
  }
  
  if ($searticle=="no"){
  $ARTICLEPERPAGE=0;
  }
  
  if ($amazcountry=="us"){
  $amazon_country="us";
  }else{
  $amazon_country="uk";
  }

    $config='<?PHP
//Config file generated by install.php - Do not alter now - Use your control panel to make changes
//----------------------------------------------------------------------------------
//Monetization modules
$show_google = "'.$show_google.'"; 
$show_yahoo ="'.$show_yahoo.'"; 
$show_sf ="'.$show_sf.'";   
$show_chitika="'.$show_chitika.'";
$show_subscribe="'.$show_subscribe.'";
$show_amazon ="'.$show_amazon.'"; 
$show_partners="'.$show_partners.'"; 
$show_bestseller="'.$show_bestseller.'"; 
$show_bestproducts="'.$show_bestproducts.'"; 
$show_persobanner_center="'.$show_persobanner_center.'";
$show_persobanner_right="'.$show_persobanner_right.'";
$show_addarticles="'.$show_addarticles.'";
$_numResults ="'.$_numResults.'";
$formatarticle="'.$formatarticle.'";
//-----------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------
// Configuration of your local installation and personnal site definitions
$templatefoldername="'.$templatefoldername.'";  
$mysitename = "'.$mysitename.'"; 
$mainkeyword = "'.$mainkeyword.'";  
//-----------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------
// your personnal affiliate ID in the following programs
$adsense_pub = "'.$adsense_pub.'";  
$adsense_channel = "'.$adsense_channel.'"; 
$yahoo_pub ="'.$yahoo_pub.'"; 
$yahoo_channel="'.$yahoo_channel.'"; 
$chitika_pub ="'.$chitika_pub.'"; 
$chitika_channel="'.$chitika_channel.'"; 
$clickbank_pub ="'.$clickbank_pub.'"; 
$sf_account_id = "'.$sf_account_id.'"; 
$sf_track_id = "'.$sf_track_id.'"; 
$amazon_country="'.$amazon_country.'";
$Aassociates_id="'.$Aassociates_id.'";
$num_amazon = "'.$num_amazon.'"; 
//-------------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------
//Personal details
$firstname="'.$firstname.'";
$lastname="'.$lastname.'";
$email="'.$email.'";
$autoresponder="'.$autoresponder.'";
$domainname="'.$domainname.'";
//-----------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------
// WARNING do not edit below this line
$site = "http://"; 

$site .= $_SERVER["HTTP_HOST"]; 

$sitexml = $site."/";

$full = $_SERVER["REQUEST_URI"]; 

$dir = dirname($full);

$dir = str_replace("/datas", "", $dir);
$rootdir = str_replace("datas", "", $templatefoldername);
$rooturl = $sitexml.$rootdir;

$site .= $dir;

$nr_links = 15;


$template_index = "theindex.php";

$template_pages = "pages.php";

$template_sitemap = "thesitemap.php";

require_once("google_function.php");
require_once("chitika_function.php");
require_once("yahoo_function.php");

$ARTICLEPERPAGE = "'.$ARTICLEPERPAGE.'";
// This array for exclude pages when system is generating keywords page....
$array  = array("index.php","sitemap.php","privacy.php","tos.php","permalink.php","partners.php", "wfb.php", "article_list.php", "wfbtrash", "partners_instr.php", "submitarticle.php", "tellafriend.php");

?>
';

    $fh=fopen('../config.php','w+');
    fwrite ($fh,$config);
    fclose($fh);
	echo "<h3>Configuration has been updated!</h3>You can now view your site <a href='".$rooturl."' target=_blank>HERE</a>";


//now what we do depends on whether it's an auto install or not
if ($_REQUEST['a_d']=="yes"){
    $type="a_d=yes";
    }

}
?>
</div>
<div class="clearingdiv">&nbsp;</div>
</div>
</div>
<div id="footer"><?php include("footer.php");?></div>

</body>
</html>

