<?php
include("postget.php");
include_once("common.php");
checklevel(4,$_REQUEST['clientid']);
if ($config[56][1]==1){
	$disabled=" disabled ";
	$mensaje= " "._CHANGE_NOT_ALLOWED_IN_DEMO_MODE;
}else{
	$disabled=" ";
	$mensaje= "";
}

//////////////////////////////////////////////////////////////// si se envi� el formulario, cargar los errores
if ($_REQUEST[sendclick]==""._SEND."") {
	$estiloerror = "class='formfielderror'";
	$errors = '';
	if ($_POST['Xcroncode']=='') {$errors.= "<br>".ucfirst(_CODE_FOR_CRON).": "._NOT_SPECIFIED.""; $estilocron=$estiloerror;}
	if ($_POST['Xlinesperpage']<1) {$errors.= "<br>".ucfirst(_LINES_PER_PAGE).": "._NOT_SPECIFIED.""; $estiloinesperpage=$estiloerror;}
	if ($_POST['new76']<1) {$errors.= "<br>".ucfirst(_LENGTH_OF_PASSWORDS).": "._NOT_SPECIFIED.""; $estilonew76=$estiloerror;}
	if ($_POST['new77']=='') {$errors.= "<br>".ucfirst(_CHARACTERS_ALLOWED_FOR_PASSWORDS).": "._NOT_SPECIFIED.""; $estilonew77=$estiloerror;}
	if ($_POST['new124']=='') {$errors.= "<br>".ucfirst(_DEFAULT_TIMEZONE).": "._NOT_SPECIFIED.""; $estilonew124=$estiloerror;}
}

//////////////////////////////////////////////////////////////// si no hay errores y se presion� SEND
if($errors=='' AND $_REQUEST[sendclick] ==""._SEND."") {
	if($new74=="on"){$new74=1;}else{$new74=0;}
	if($new78=="on"){$new78=1;}else{$new78=0;}
	if($new79=="on"){$new79=1;}else{$new79=0;}
	if($new120=="on"){$new120=1;}else{$new120=0;}

	mysql_query("UPDATE hd_config SET valor='0' WHERE ref='31'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$Xcroncode' WHERE ref='37'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$Xlinesperpage' WHERE ref='32'",$db_link);
	mysql_query("UPDATE hd_config SET valor='UTF-8' WHERE ref='72'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$new54' WHERE ref='54'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$new74' WHERE ref='74'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$new76' WHERE ref='76'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$new77' WHERE ref='77'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$new78' WHERE ref='78'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$new79' WHERE ref='79'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$new105' WHERE ref='105'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$new106' WHERE ref='106'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$new120' WHERE ref='120'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$new122' WHERE ref='122'",$db_link);
	mysql_query("UPDATE hd_config SET valor='$new124' WHERE ref='124'",$db_link);

	messagetop(_THE_CHANGES_WHERE_MADE_SUCCESSFULLY,'','preferences.php',1);

}else{


	$query="SELECT * FROM hd_config ORDER BY ref";
	$result=mysql_query($query,$db_link);
	$fila=0;
	while($row=mysql_fetch_array($result))
	{
		$Config[$fila][0]=$row["variable"] ;
		//	$Config[$fila][1]="'".$row["valor"]."'";
		$Config[$fila][1]=$row["valor"];
		$fila++ ;

	}

	print errors($errors); $errors = '';


	print("<form method='POST'>");
echo '<table class="table table-striped">';

	echo '<tr>';
	print("<td>".tip(132)."".ucfirst(_DEFAULT_TIMEZONE).": </td><td>");
	print("<input $estilonew124 name=new124 value='".$Config[124][1]."' size=60><a href='http://www.php.net/manual/en/timezones.php' target='_blank'>".ucfirst(_HELP)."</a></td></tr>");

	echo '<tr>';
	print("<td>".tip(58)."".ucfirst(_CODE_FOR_THE_CENTRALIZED_PANEL_OF_TICKETS).": </td><td>");
	if ($config[37][1]>0) {
		print("<input $estilocron name=Xcroncode value=".$Config[37][1]."><br>");
		
		print("".$config[1][1]."/tickets_panel.php?c=".$Config[37][1]."");
//		print("<br><strong>"._OR."</strong><br>");
//		print('10 7 * * * wget -nv -O /dev/null "'.$Config[1][1].'/cron.php?c='.$Config[37][1].'"  >/dev/null 2>&1');
		print("</td></tr>");
	}else{
		print("<input $estilocron name=Xcroncode value=".rand(1, 9999999999)."></td></tr>");
	}

	echo '<tr>';
	print("<td>".tip(59)."".ucfirst(_LINES_PER_PAGE).": </td><td>");
	print("<input $estiloinesperpage name=Xlinesperpage value=".$Config[32][1]." class='input-small'></td></tr>");

	echo '<tr>';
	print("<td>".tip(60).""._CHARSET.": </td><td>");
	print("<input $estilocharset name=Xcharset value='UTF-8' size=20 disabled></td></tr>");

	echo '<tr>';
	print("<td>".tip(65)."".ucfirst(_ALLOW_SIGNUP).": </td><td>");
	print("<input type='checkbox' name=new74");
	if ($Config[74][1]=="1"){print(" checked");};
	print("></td></tr>");

	echo '<tr>';
	print("<td>".tip(66)."".ucfirst(_DEFAULT_COUNTRY).": </td><td>");
	print("<select name='new54'>");
	$query="SELECT * FROM hd_countries ORDER BY country";
	$countries=mysql_query($query,$db_link);
	while($row=mysql_fetch_array($countries)) {
		print ("<option value='".$row[id]."' ".sele($config[54][1],$row[id]).">".$row[country]." (".$row[countrycode].")</option>");
	};
	print("</select>");
	print("</td></tr>");

	echo '<tr>';
	print("<td>".tip(67)."".ucfirst(_LENGTH_OF_PASSWORDS).": </td><td>");
	print("<input $estilonew76 name=new76 value='".$Config[76][1]."' size=3></td></tr>");

	echo '<tr>';
	print("<td>".tip(68)."".ucfirst(_CHARACTERS_ALLOWED_FOR_PASSWORDS).": </td><td>");
	print("<input $estilonew77 name=new77 value='".$Config[77][1]."' size=60></td></tr>");

	echo '<tr>';
	print("<td>".tip(69)."".ucfirst(_USE_CAPTCHA_FOR_REGISTERED_USERS).": </td><td>");
	print("<input type='checkbox' name=new78");
	if ($Config[78][1]=="1"){print(" checked");};
	print("></td></tr>");

	echo '<tr>';
	print("<td>".tip(70)."".ucfirst(_USE_CAPTCHA_FOR_UNREGISTERED_USERS).": </td><td>");
	print("<input type='checkbox' name=new79");
	if ($Config[79][1]=="1"){print(" checked");};
	print("></td></tr>");

	echo '<tr>';
	print("<td>".tip(73)."".ucfirst(_ATTEMPTS_LOGIN).": </td><td>");
	$firstinput = "<input $estilonew105106 name=new105 value='".$Config[105][1]."' class='input-small'>" ;
	$secondinput = "<input $estilonew105106 name=new106 value='".$Config[106][1]."' class='input-small'>" ;
	$text = _EVERY_L_FAILED_LOGIN_ATTEMPTS_MAKE_A_BLOCK_OF_S_SECONDS;
	$text = str_replace('%L%',$firstinput,$text);
	$text = str_replace('%S%',$secondinput,$text);
	print(ucfirst($text));
	print("</td></tr>");
	
	echo '<tr>';
	print("<td>".tip(130)."".ucfirst(_ALLOW_FAST_REGISTRATION).": </td><td>");
	print("<input type='checkbox' name=new120");
	if ($Config[120][1]=="1"){print(" checked");};
	print("></td></tr>");

	echo '<tr>';
	print("<td>".tip(131)."".ucfirst(_GOOGLE_ANALYTICS_ID).": </td><td>");
	print("<input  name=new122 value=".$Config[122][1]."></td></tr>");
	
	print("</table>");
	print("<input type=submit name=sendclick value="._SEND." $disabled>$mensaje<input type=hidden name=sendclick value="._SEND."></form>");
}
?>