<?php

include("../setting.php");
//$datafile = "data.html";

// connect db

//$db = mysql_connect("localhost", "littlemis_com_ge", "lt37ms");
//mysql_select_db("littlemis_com_ge");

$db = mysql_connect("localhost", "littlege_user2", "pass2");
mysql_select_db("littlege_db1");
//mysql_query('SET NAMES "cp1251"');
//mysql_query("SET CHARACTER SET cp1251");

// end connect db
$msg = "";

//
$pass1 = $_POST["pass1"];
$pass2 = $_POST["pass2"];
$action = $_POST["action"];
$r_name1 = $_POST["r_name1"];
$r_name2 = $_POST["r_name2"];
$field2 = $_POST["field2"];
$newtext = $_POST["newtext"];

//echo($action.".1<br>");
//echo($r_name1.".2<br>");
//echo($r_name2.".3<br>");
//echo($field2.".4<br>");
//echo($newtext.".5<br>");

// time
$today = date("H:i:s");                           
$plus_time = strtotime ("+0 hour"); // +0 hours
$cur_date = date(Y."-".m."-".d, $plus_time);

//if(isset($action) && $REQUEST_METHOD == "POST")
//{
	if($pass1 == $password1 && $pass2 == $password2)
	{
		if($action == "save" && $r_name2 != "")
		{
			mysql_query("UPDATE info_table SET page_text = '$newtext', page_update = '$cur_date' WHERE page_name = '$r_name2'");
			$msg = $msg." New information is saved <br> (".$r_name2.")";
			$currenttext = $newtext;
			$r_name1 = $r_name2;
		}
	}
	else
	{
		$msg = $msg." Incorrect passwords <br> ";
		$currenttext = $newtext;
	}
	
//}

////

if($r_name1 != "" && $action == "nosave")
{
	$result = mysql_query("SELECT * FROM info_table WHERE page_name = '$r_name1'",$db);
	if($myrow = mysql_fetch_array($result))
	{
		$currenttext = $myrow["page_text"];
		$msg = $msg." View <br> (".$r_name1.")";
	}
}

//

if($action == "save" && $r_name2 != "")
{
	$result = mysql_query("SELECT * FROM info_table WHERE page_name = '$r_name2'",$db);
	if($myrow = mysql_fetch_array($result))
	{
		$currenttext = $myrow["page_text"];
	}
}

//////////////////////////////////////////////////////////////
?>
<HTML>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=windows-1251">
<title>
CK Editor //
</title>

<style>
.field 
{
	font-family: Tahoma,Verdana;font-size:10pt;border: 2px double #EEEEEE;
}
.field2 
{
	font-family: Tahoma,Verdana;font-size:10pt;border: 2px outset #000000; font-weight:bold;color:white;background-color:#880000;
}
body
{
	SCROLLBAR-FACE-COLOR: #FFFFFF; 
	SCROLLBAR-HIGHLIGHT-COLOR: #CCCCCC; 
	SCROLLBAR-SHADOW-COLOR: #CCCCCC; 
	SCROLLBAR-3DLIGHT-COLOR: #EFEFEF; 
	SCROLLBAR-ARROW-COLOR: #B9BCA4; 
	SCROLLBAR-TRACK-COLOR: #F5F5F3; 
	SCROLLBAR-DARKSHADOW-COLOR: #F5F5F3;
	BACKGROUND-COLOR: #F5F5F3;
}
</style>


<BODY>


<?php
/*
 // Make sure you're using correct paths here
 include_once '../ckeditor/ckeditor.php';
 include_once '../ckfinder/ckfinder.php';
 
 $ckeditor = new CKEditor();
 $ckeditor->basePath = '../ckeditor/';
 $ckfinder = new CKFinder();
 $ckfinder->BasePath = '../ckfinder/'; // Note: BasePath property in CKFinder class starts with capital letter
 $ckfinder->SetupCKEditorObject($ckeditor);
 $ckeditor->editor('text_geo');
 */
 ?>

<table align="center" width="100%">
<tr>
<td align="center" vAlign="middle">
<br>
<form name="form1" method="POST" action="index.php"  enctype="multipart/form-data">


 <?php 
include_once '../ckeditor/ckeditor.php';
include_once '../ckfinder/ckfinder.php';

$initialValue = $currenttext;
$ckeditor = new CKEditor();
$ckeditor->basePath = '../ckeditor/';
$ckfinder = new CKFinder();
$ckfinder->BasePath = '../ckfinder/'; // Note: BasePath property in CKFinder class starts with capital letter
$ckfinder->SetupCKEditorObject($ckeditor);
$ckeditor->editor('newtext', $initialValue);
?>

<input type="hidden" name="action" value="nosave">

<input type="hidden" name="r_name2" value="<?php echo($r_name1);?>">

<select name="r_name1" class="field2">
<option value="home_eng_1">Home (eng)</option>
<option value="history_eng_1">History (eng)</option>
<option value="rules_eng_1">Rules (eng)</option>
<option value="entry_form_eng_1">Entry_form (eng)</option>
<option value="delegates_eng_2006_1">Delegates 2006 (eng)</option>
<option value="delegates_eng_2007_1">Delegates 2007 (eng)</option>
<option value="delegates_eng_2008_1">Delegates 2008 (eng)</option>
<option value="delegates_eng_2009_1">Delegates 2009 (eng)</option>
<option value="delegates_eng_2010_1">Delegates 2010 (eng)</option>
<option value="partners_eng_1">Partners (eng)</option>
<option value="contact_eng_1">Contact (eng)</option>

<!--
<option value="home_eng_1">home_eng_1</option>
<option value="home_eng_2">home_eng_2</option>
<option value="home_eng_3">home_eng_3</option>
<option value="home_eng_4">home_eng_4</option>
<option value="home_eng_5">home_eng_5</option>

<option value="history_eng_1">history_eng_1</option>
<option value="history_eng_2">history_eng_2</option>
<option value="history_eng_3">history_eng_3</option>
<option value="history_eng_4">history_eng_4</option>
<option value="history_eng_5">history_eng_5</option>

<option value="participants_eng_1">participants_eng_1</option>
<option value="participants_eng_2">participants_eng_2</option>
<option value="participants_eng_3">participants_eng_3</option>
<option value="participants_eng_4">participants_eng_4</option>
<option value="participants_eng_5">participants_eng_5</option>

<option value="partners_eng_1">partners_eng_1</option>
<option value="partners_eng_2">partners_eng_2</option>
<option value="partners_eng_3">partners_eng_3</option>
<option value="partners_eng_4">partners_eng_4</option>
<option value="partners_eng_5">partners_eng_5</option>

<option value="contact_eng_1">contact_eng_1</option>

<option value="home_rus_1">home_rus_1</option>
<option value="home_rus_2">home_rus_2</option>
<option value="home_rus_3">home_rus_3</option>
<option value="home_rus_4">home_rus_4</option>
<option value="home_rus_5">home_rus_5</option>

<option value="history_rus_1">history_rus_1</option>
<option value="history_rus_2">history_rus_2</option>
<option value="history_rus_3">history_rus_3</option>
<option value="history_rus_4">history_rus_4</option>
<option value="history_rus_5">history_rus_5</option>

<option value="participants_rus_1">participants_rus_1</option>
<option value="participants_rus_2">participants_rus_2</option>
<option value="participants_rus_3">participants_rus_3</option>
<option value="participants_rus_4">participants_rus_4</option>
<option value="participants_rus_5">participants_rus_5</option>

<option value="partners_rus_1">partners_rus_1</option>
<option value="partners_rus_2">partners_rus_2</option>
<option value="partners_rus_3">partners_rus_3</option>
<option value="partners_rus_4">partners_rus_4</option>
<option value="partners_rus_5">partners_rus_5</option>

<option value="contact_rus_1">contact_rus_1</option>

-->

</select>&nbsp;

<INPUT type=button value="View Text" onClick="document.form1.submit();" class="field2" style="cursor:hand;" title="View Text">

<INPUT type=password value="<?=@$pass1?>" name="pass1" class="field" size="3"><font face="Tahoma,Verdana,Arial" size="1"><b>- Pass 1</b></font>

<INPUT type=password value="<?=@$pass2?>" name="pass2" class="field" size="3"><font face="Tahoma,Verdana,Arial" size="1"><b>- Pass2</b></font>

<INPUT type=button value="Save" onclick="saveText();" class="field2" style="cursor:hand;" title="Save Information">

<br>

<font style="color: #BB0000; font-size: 8pt; font-weight: bold; font-family: Tahoma;">

<?php

echo($today);
echo("<br>");

if($msg == "")
{

}
else
{
	echo($msg);
}

?>
</font>

</form>
</td>
</tr>
</table>
<br>
<br>
<!--
<SCRIPT language="Jscript" type="text/Jscript" src="WHE/labels.js"></SCRIPT>
<SCRIPT language="Jscript" type="text/Jscript" src="WHE/panel.js"></SCRIPT>
<SCRIPT language="Jscript" type="text/Jscript" src="WHE/HTMLEditor.js"></SCRIPT>
-->
<SCRIPT language="Javascript">

function saveText()
{	
		var error = "";

		//document.form1.newtext.value = htmlText;
		//
		/*
		if(document.form1.newtext.value.length <= 25)
		{
			error = error + "Enter text\n";
		}
		*/
		//
		if(document.form1.pass1.value=="")
		{
			error = error + "Enter password 1\n";
		}
		if(document.form1.pass2.value=="")
		{
			error = error + "Enter password 2\n";
		}

		if(error)
		{
			alert("- Message -\n\n" + error);
		}
		if(!error)
		{
			document.form1.action.value = "save";
			document.form1.submit();
		}

	
}
</SCRIPT>
<?php
//echo('<script>'."\n");
//echo('var HTML = "<body>'.$data_text.'</body>";'."\n");
//echo('</script>'."\n");
?>
<!--
<script language="JavaScript">
  var lang = "EN";
  var HTML = document.form1.newtext.value;
  if(HTML == "")
  {
	  //HTML = "<BODY><LINK href=js_css/center.css rel=stylesheet></BODY>";
	  HTML = "<BODY></BODY>";
  }
  HTMLEditor("editor","ALL",ed1,lang,HTML,"WHE/","images/");
  editor.PutHTML(HTML);
</script>
-->


</BODY>
</HTML>
