<?php session_start();  //Developed by ITechScripts
$username=$_SESSION['adminuser'];
	require 'include/configurations.php'; // ITECHBIDS Configuration File
    require 'include/header.php';
$type = $_GET['type'];

$rdlangs=$_POST['rdlangs'];
if($type == "change"){
$sql="update language set filename='$rdlangs' where auto=1";
$sqll=mysql_query($sql);
}

	$canChange=$_POST['canChange'];
	$lang_query="select * from language where auto=1";
	$lang_result=mysql_query($lang_query);
	$lang_row=mysql_fetch_array($lang_result);
	$defaultlang =$lang_row['filename'];
?>
<?

$filename = $_GET['id'];

if($type == "edit"){
if($_POST['Submit']){
$open = fopen("../language/$filename","w+");
$text = $_POST['update'];
$text = stripslashes($text);
fwrite($open, $text);
fclose($open);
$file = file("../language/$filename");
foreach($file as $text) {
}}
$file = file("../language/$filename");
?>

<table border="0" align="center" width="80%" cellpadding="5" cellspacing="2" class="ft">

<form name="frmLevel" action="<? $_SERVER['PHP_SELF']?>" method="post">

<tr class="ct" height="25"><td colspan="2"><? if($type=="edit") echo 'Edit';else echo 'Add New';?> Language</td></tr>

<tr ><td align="center">

<textarea Name="update" cols="50" rows="10">
<?
foreach($file as $text) {
echo $text;
}
?>
</textarea><BR><BR>
<input name="Submit" type="submit" class="button" value="Update" />

</td></tr>

</form>

</table>

<?		
}
?>

<table border="0" align="center" width="80%" cellpadding="5" cellspacing="2" class="ft">

<tr class="ct" height="25"><td colspan="3"> Site Language Manager</td></tr>

<tr>

  <td colspan="3">

  Here you can Set your Default Language.

  </td>

</tr>

<form name="frmLevel1" action="langs.php?type=change" method="post" onSubmit="this.canChange.value=1;">
<?
      $Folder = "../language/";
      $DirHandle = @opendir($Folder) or die($Folder." could not be opened.");
      while ($Filename1 = readdir($DirHandle))
      {
if(($Filename1!='.')&&($Filename1!='..')&&($Filename1!='emails')){
?>
<tr ><td align="left"><input type="radio" name="rdlangs" value="<?=$Filename1?>" <? if($Filename1==$defaultlang) echo 'checked';?>><?=$Filename1?></td>
<td align="left"><a href="langs.php?type=edit&id=<?=$Filename1?>">Edit</a></td></tr>
<?
}
$Filename1 = "";
}
closedir($DirHandle);
?>
<tr height="25">
<td align="center" colspan="3"><input type="hidden" name="canChange" size="20" value="0"><input name="Submit" type="submit" class="button" value="Update" /></td>

</tr></form>
</table>
<?
require 'include/footer.php';
?>