<?php
/*
=====================
Модуль скачан с сайта:
Понедельников НЕТ! - Сайт альтернативной поддержки Slaed CMS! (http://www.ponedelnikov.net)
=====================
SHAKA1, 2009
e-mail: seregam007@mail.ru
=====================
*/
if (!defined('ADMIN_FILE') || !is_admin_modul($aid, "Ideas")) die("Illegal File Access");
$idea['conf_file']='config/config_ideas.php';
require_once($idea['conf_file']);
require_once("ideas/functions.php");

function aidea_navi() {
global $admin_file, $db, $prefix, $count, $count_com;
	  $result = $db->sql_query("SELECT COUNT(*) FROM ".$prefix."_ideas WHERE status='5'");
    list($count) = $db->sql_fetchrow($result);
    
    $result2 = $db->sql_query("SELECT COUNT(*) FROM ".$prefix."_icomments");
    list($count_com) = $db->sql_fetchrow($result2);
	GraphicAdmin();
	OpenTable();
	echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"javascripts/SortTable.js\"></script>";
	echo "<link href=\"ideas/css-idea.css\" rel=\"stylesheet\" type=\"text/css\" />";
  echo "<center><font class=\"title\">"._IA_HEAD."</font><br><br>"
	."[ <a href=\"".$admin_file.".php?op=aidea_main\">"._IA_IDEAS."</a>"
	." | <a href=\"".$admin_file.".php?op=aidea_comm\">"._IA_COMM." ($count_com)</a>"
	." | <a href=\"".$admin_file.".php?op=aidea_new\">"._IA_NEW." ($count)</a>"
	." | <a href=\"".$admin_file.".php?op=aidea_conf\">"._IA_CONF."</a> ]</center>";
	CloseTable();
}

function aidea_conf() {
global $prefix, $db, $admin_file, $idea;
	head();
	aidea_navi();
	$permtest = end_chmod($idea['conf_file'], 666);
	if ($permtest) warning($permtest, "", "", 1);
	OpenTable();
  echo "<form action='".$admin_file.".php' method='post'>"
	."<table border='0' align='center' cellpadding='3' cellspacing='0'>"
."<tr><td><center><font class='option'><b>"._IA_CONF_1."</b></font></center></td></tr>"
	."<tr><td>"._AIC_1.":</td><td><select name=\"addform\"><option value=\"0\" ".aidea_select($idea['addform'], 0).">"._AIC_8_0."</option><option value=\"1\" ".aidea_select($idea['addform'], 1).">"._AIC_8_1."</option></select></td></tr>"
	."<tr><td>"._AIC_2.":</td><td><select name=\"naviform\"><option value=\"0\" ".aidea_select($idea['naviform'], 0).">"._AIC_8_0."</option><option value=\"1\" ".aidea_select($idea['naviform'], 1).">"._AIC_8_1."</option></select></td></tr>"
	."<tr><td>"._AIC_3."</td><td><input type='text' name='official' value='".$idea['official']."' size='45' style='width:300px'></td></tr>"
	."<tr><td>"._AIC_4.":</td><td><select name=\"delotvet\"><option value=\"0\" ".aidea_select($idea['delotvet'], 0).">"._AIC_4_0."</option><option value=\"1\" ".aidea_select($idea['delotvet'], 1).">"._AIC_4_1."</option><option value=\"2\" ".aidea_select($idea['delotvet'], 2).">"._AIC_4_2."</option></select></td></tr>"
	."<tr><td>"._AIC_17."</td><td><input type='text' name='cut' value='".$idea['cut']."' size='45' style='width:50px'></td></tr>"
."<tr><td><center><font class='option'><b>"._IA_CONF_2."</b></font></center></td></tr>"
	."<tr><td>"._AIC_5.":</td><td><select name=\"add_comm\"><option value=\"1\" ".aidea_select($idea['add_comm'], 1).">"._AIC_5_1."</option><option value=\"2\" ".aidea_select($idea['add_comm'], 2).">"._AIC_5_2."</option><option value=\"3\" ".aidea_select($idea['add_comm'], 3).">"._AIC_5_3."</option><option value=\"4\" ".aidea_select($idea['add_comm'], 4).">"._AIC_5_4."</option></select></td></tr>"
	."<tr><td>"._AIC_6.":</td><td><select name=\"code_comm\"><option value=\"1\" ".aidea_select($idea['code_comm'], 1).">"._AIC_6_1."</option><option value=\"2\" ".aidea_select($idea['code_comm'], 2).">"._AIC_6_2."</option><option value=\"3\" ".aidea_select($idea['code_comm'], 3).">"._AIC_6_3."</option></select></td></tr>"
	."<tr><td>"._AIC_7.":</td><td><select name=\"sort_comm\"><option value=\"DESC\" ".aidea_select($idea['sort_comm'], 'DESC').">"._AIC_7_1."</option><option value=\"ASC\" ".aidea_select($idea['sort_comm'], 'ASC').">"._AIC_7_2."</option></select></td></tr>"
	."<tr><td>"._AIC_8.":</td><td><select name=\"bb_comm\"><option value=\"0\" ".aidea_select($idea['bb_comm'], 0).">"._AIC_8_0."</option><option value=\"1\" ".aidea_select($idea['bb_comm'], 1).">"._AIC_8_1."</option></select></td></tr>"
	."<tr><td>"._AIC_9."</td><td><select name=\"bb_decode\"><option value=\"0\" ".aidea_select($idea['bb_decode'], 0).">"._AIC_8_0."</option><option value=\"1\" ".aidea_select($idea['bb_decode'], 1).">"._AIC_8_1."</option></select></td></tr>"
	."<tr><td>"._AIC_10.":</td><td><select name=\"com_nap\"><option value=\"1\" ".aidea_select($idea['com_nap'], 1).">"._AIC_10_1."</option><option value=\"2\" ".aidea_select($idea['com_nap'], 2).">"._AIC_10_2."</option></select></td></tr>"
	."<tr><td>"._AIC_11.":</td><td><input type='text' name='com_page' value='".$idea['com_page']."' maxlength='2' size='45' style='width:50px'></td></tr>"
	."<tr><td>"._AIC_12."</td><td><input type='text' name='moders' value='".$idea['moders']."' size='45' style='width:300px'></td></tr>"
."<tr><td><center><font class='option'><b>"._IA_CONF_3."</b></font></center></td></tr>"
	."<tr><td>"._AIC_13.":</td><td><input type='text' name='ionpage' value='".$idea['ionpage']."' maxlength='2' size='45' style='width:50px'></td></tr>"
	."<tr><td>"._AIC_14.":</td><td><select name=\"num_page\"><option value=\"1\" ".aidea_select($idea['num_page'], 1).">"._AIC_10_1."</option><option value=\"2\" ".aidea_select($idea['num_page'], 2).">"._AIC_10_2."</option></select></td></tr>"
	."<tr><td>"._AIC_15.":</td><td><select name=\"dsas\"><option value=\"DESC\" ".aidea_select($idea['dsas'], 'DESC').">"._AIC_15_1."</option><option value=\"ASC\" ".aidea_select($idea['dsas'], 'ASC').">"._AIC_15_2."</option></select></td></tr>"
  ."<tr><td>"._AIC_16.":</td><td><select name=\"mainby\"><option value=\"id\" ".aidea_select($idea['mainby'], 'id').">"._AIC_16_1."</option><option value=\"date\" ".aidea_select($idea['mainby'], 'date').">"._AIC_16_2."</option><option value=\"karma\" ".aidea_select($idea['mainby'], 'karma').">"._AIC_16_3."</option><option value=\"comments\" ".aidea_select($idea['mainby'], 'comments').">"._AIC_16_4."</option><option value=\"totalvote\" ".aidea_select($idea['mainby'], 'totalvote').">"._AIC_16_5."</option><option value=\"rand()\" ".aidea_select($idea['mainby'], 'rand()').">"._AIC_16_6."</option></select></td></tr>"
."<tr><td><center><font class='option'><b>"._IA_CONF_4."</b></font></center></td></tr>"
	."<tr><td>"._AIC_18."</td><td><input type='text' name='poplimit' value='".$idea['poplimit']."' size='65' style='width:300px'></td></tr>"
	."<tr><td>"._AIC_19.":</td><td><select name=\"popsort\"><option value=\"DESC\" ".aidea_select($idea['popsort'], 'DESC').">"._AIC_15_1."</option><option value=\"ASC\" ".aidea_select($idea['popsort'], 'ASC').">"._AIC_15_2."</option></select></td></tr>"
  ."<tr><td>"._AIC_20.":</td><td><select name=\"poporder\"><option value=\"id\" ".aidea_select($idea['poporder'], 'id').">"._AIC_16_1."</option><option value=\"date\" ".aidea_select($idea['poporder'], 'date').">"._AIC_16_2."</option><option value=\"karma\" ".aidea_select($idea['poporder'], 'karma').">"._AIC_16_3."</option><option value=\"comments\" ".aidea_select($idea['poporder'], 'comments').">"._AIC_16_4."</option><option value=\"totalvote\" ".aidea_select($idea['poporder'], 'totalvote').">"._AIC_16_5."</option><option value=\"rand()\" ".aidea_select($idea['poporder'], 'rand()').">"._AIC_16_6."</option></select></td></tr>"
	."<tr><td>"._AIC_21."</td><td><input type='text' name='popconst' value='".$idea['popconst']."' size='65' style='width:300px'></td></tr>"
."<tr><td><center><font class='option'><b>"._IA_CONF_5."</b></font></center></td></tr>"
	."<tr><td>"._AIC_22.":</td><td><select name=\"moder\"><option value=\"1\" ".aidea_select($idea['moder'], '1').">"._AIC_22_1."</option><option value=\"2\" ".aidea_select($idea['moder'], '2').">"._AIC_22_2."</option></select></td></tr>"
	."<tr><td>"._AIC_23.":</td><td><select name=\"addidea\"><option value=\"0\" ".aidea_select($idea['addidea'], '0').">"._AIC_23_0."</option><option value=\"1\" ".aidea_select($idea['addidea'], '1').">"._AIC_23_1."</option><option value=\"2\" ".aidea_select($idea['addidea'], '2').">"._AIC_23_2."</option></select></td></tr>"
	."<tr><td>"._AIC_24.":</td><td><select name=\"seccode\"><option value=\"0\" ".aidea_select($idea['seccode'], '0').">"._AIC_24_0."</option><option value=\"1\" ".aidea_select($idea['seccode'], '1').">"._AIC_24_1."</option><option value=\"2\" ".aidea_select($idea['seccode'], '2').">"._AIC_24_2."</option></select></td></tr>"
."<tr><td><center><font class='option'><b>"._IA_CONF_6."</b></font></center></td></tr>"
	."<tr><td>"._AIC_25."</td><td><input type='text' name='rating' value='".$idea['rating']."' size='65' style='width:300px'></td></tr>"
	."<tr><td>"._AIC_26.":</td><td><select name=\"whovote\"><option value=\"1\" ".aidea_select($idea['whovote'], '1').">"._AIC_26_1."</option><option value=\"2\" ".aidea_select($idea['whovote'], '2').">"._AIC_26_2."</option><option value=\"3\" ".aidea_select($idea['whovote'], '3').">"._AIC_26_3."</option></select></td></tr>"
	."<tr><td>"._AIC_27.":</td><td><select name=\"rating_minus\"><option value=\"0\" ".aidea_select($idea['rating_minus'], 0).">"._AIC_8_0."</option><option value=\"1\" ".aidea_select($idea['rating_minus'], 1).">"._AIC_8_1."</option></select></td></tr>"
	."<tr><td>"._AIC_28."</td><td><select name=\"javavoit\"><option value=\"0\" ".aidea_select($idea['javavoit'], 0).">"._AIC_8_0."</option><option value=\"1\" ".aidea_select($idea['javavoit'], 1).">"._AIC_8_1."</option></select></td></tr>";
	echo "</table>";
	echo "<center><br><input type='hidden' name='op' value='aidea_csave'><input type='submit' value='"._AIC_CONFS."'></center></form>";
	CloseTable();
	foot();
}

function aidea_csave() {
global $admin_file, $idea;
	$addform = (isset($_POST['addform'])) ? intval($_POST['addform']) : 0;
	$naviform = (isset($_POST['naviform'])) ? intval($_POST['naviform']) : 1;
	$delotvet = (isset($_POST['delotvet'])) ? intval($_POST['delotvet']) : 0;
	$cut = (isset($_POST['cut'])) ? intval($_POST['cut']) : 40;
	$official = (isset($_POST['official'])) ? text_filter($_POST['official']) : '';
	$add_comm = (isset($_POST['add_comm'])) ? intval($_POST['add_comm']) : 1;
	$code_comm = (isset($_POST['code_comm'])) ? intval($_POST['code_comm']) : 1;
	$sort_comm = (isset($_POST['sort_comm'])) ? text_filter($_POST['sort_comm']) : 'DESC';
	$bb_comm = (isset($_POST['bb_comm'])) ? intval($_POST['bb_comm']) : 0;
	$bb_decode = (isset($_POST['bb_decode'])) ? intval($_POST['bb_decode']) : 1;
  $com_nap = (isset($_POST['com_nap'])) ? intval($_POST['com_nap']) : 1;
  $com_page = (isset($_POST['com_page'])) ? intval($_POST['com_page']) : 15;
  $moders = (isset($_POST['moders'])) ? text_filter($_POST['moders']) : '';
  $ionpage = (isset($_POST['ionpage'])) ? intval($_POST['ionpage']) : 10;
  $num_page = (isset($_POST['num_page'])) ? intval($_POST['num_page']) : 1;
  $dsas = (isset($_POST['dsas'])) ? text_filter($_POST['dsas']) : 'DESC';
  $mainby = (isset($_POST['mainby'])) ? text_filter($_POST['mainby']) : 'id';
  $poplimit = (isset($_POST['poplimit'])) ? intval($_POST['poplimit']) : 5;
	$popsort = (isset($_POST['popsort'])) ? text_filter($_POST['popsort']) : 'DESC';
	$poporder = (isset($_POST['poporder'])) ? text_filter($_POST['poporder']) : 'id';
	$popconst = (isset($_POST['popconst'])) ? text_filter($_POST['popconst']) : '';
	$moder = (isset($_POST['moder'])) ? intval($_POST['moder']) : 2;
	$addidea = (isset($_POST['addidea'])) ? intval($_POST['addidea']) : 3;
  $seccode = (isset($_POST['seccode'])) ? intval($_POST['seccode']) : 2;
  $rating = (isset($_POST['rating'])) ? intval($_POST['rating']) : 72;
  $whovote = (isset($_POST['whovote'])) ? intval($_POST['whovote']) : 3;
  $rating_minus = (isset($_POST['rating_minus'])) ? intval($_POST['rating_minus']) : 1;
	$javavoit = (isset($_POST['javavoit'])) ? intval($_POST['javavoit']) : 0;
	$content = "//======Main_Settings\n";
	$content .= "\$idea['addform'] = \"$addform\";\n";
	$content .= "\$idea['naviform'] = \"$naviform\";\n";
	$content .= "\$idea['official'] = \"$official\";\n";
	$content .= "\$idea['delotvet'] = \"$delotvet\";\n";
	$content .= "\$idea['cut'] = \"$cut\";\n";
	$content .= "\n//======Comment_Settings\n";
	$content .= "\$idea['add_comm'] = \"$add_comm\";\n";
	$content .= "\$idea['code_comm'] = \"$code_comm\";\n";
	$content .= "\$idea['sort_comm'] = \"$sort_comm\";\n";
	$content .= "\$idea['bb_comm'] = \"$bb_comm\";\n";
	$content .= "\$idea['bb_decode'] = \"$bb_decode\";\n";
	$content .= "\$idea['com_nap'] = \"$com_nap\";\n";
  $content .= "\$idea['com_page'] = \"$com_page\";\n";
  $content .= "\$idea['moders'] = \"$moders\";\n";
  $content .= "\n//======Main_Page_Settings\n";
  $content .= "\$idea['ionpage'] = \"$ionpage\";\n";
  $content .= "\$idea['num_page'] = \"$num_page\";\n";
  $content .= "\$idea['dsas'] = \"$dsas\";\n";
  $content .= "\$idea['mainby'] = \"$mainby\";\n";
  $content .= "\n//======Pop-up_Settings\n";
  $content .= "\$idea['poplimit'] = \"$poplimit\";\n";  
  $content .= "\$idea['popsort'] = \"$popsort\";\n"; 
  $content .= "\$idea['poporder'] = \"$poporder\";\n"; 
  $content .= "\$idea['popconst'] = \"$popconst\";\n"; 
  $content .= "\n//======Add_Idea_Settings\n";
  $content .= "\$idea['moder'] = \"$moder\";\n";
  $content .= "\$idea['addidea'] = \"$addidea\";\n";
  $content .= "\$idea['seccode'] = \"$seccode\";\n";
  $content .= "\n//======Rating_Settings\n";
  $content .= "\$idea['rating'] = \"$rating\";\n";  
  $content .= "\$idea['whovote'] = \"$whovote\";\n"; 
  $content .= "\$idea['rating_minus'] = \"$rating_minus\";\n"; 
  $content .= "\$idea['javavoit'] = \"$javavoit\";\n"; 
	save_conf($idea['conf_file'], $content);
	Header("Location: ".$admin_file.".php?op=aidea_conf");
}

function aidea_new() {
global $db, $prefix, $admin_file, $count;
    $selck = (isset($_GET['selck'])) ? intval($_GET['selck']) : 0;
    if ($selck==1) $chkdall='checked';
    else $chkdall='';
    $ionpage=20;
    head();
    aidea_navi();
    if ($count>0) {
    $total_pages = ceil($count / $ionpage);
    $pagenum = (isset($_GET['pagenum'])) ? intval($_GET['pagenum']) : 1;
    $min = $ionpage * ($pagenum - 1);
    OpenTable();
  echo "<center><font class=\"title\"><b>"._IA_NEW."</b></font></center>";
    CloseTable();
    OpenTable();
  echo '<script type="text/javascript" src="ideas/java-idea.js"></script><form name="post" action="'.$admin_file.'.php?op=aidea_fmoder" method="post"><div style="float:right;padding:0px 0px 5px 0px;"><noscript><a href="'.$admin_file.'.php?op=aidea_new&amp;selck=1"></noscript>'._AIA_SEL.'<noscript></a></noscript> / <noscript><a href="'.$admin_file.'.php?op=aidea_new&amp;selck=0"></noscript>'._AIA_UNSEL.'<noscript></a></noscript>  <input style="border: 4px double green;" onclick="CheckAll(this,\'id[]\')" type="checkbox"></div><br />';
  echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" class=\"sort\" id=\"sort_id\" width=\"100%\">"
  ."<tr><th>"._AIN_ID."</th><th>"._AIN_TITLE."</th><th>"._AIN_AUTHOR."</th><th>"._AIN_DATE."</th><th>"._AIN_SE."</th></tr>";
    $result = $db->sql_query("SELECT id, title, author, date, uid FROM ".$prefix."_ideas WHERE status='5' LIMIT $min, ".$ionpage."");
    while (list($id, $title, $author, $date, $uid) = $db->sql_fetchrow($result)) {
    if ($uid!=0) $author='<a href="index.php?name=Account&amp;op=info&amp;uname='.$author.'">'.$author.'</a>';
  echo "<tr><td align=\"center\" class=\"bgcolor1\">$id</td><td class=\"bgcolor1\">$title</td><td align=\"center\" class=\"bgcolor1\">$author</td><td align=\"center\" class=\"bgcolor1\">".ideadate($date ,1)."</td><td align=\"center\" class=\"bgcolor1\"><input onclick=\"return CheckCB(this);\" type='checkbox' name=\"id[]\" value=\"$id\" $chkdall>  <a href=\"".$admin_file.".php?op=aidea_edit&id=$id\" title=\""._AIN_EDIT."\"><img src=\"ideas/images/edit.gif\" border=\"0\" alt=\""._AIN_EDIT."\"></a></td></tr>";
  }
  echo "</table><div style=\"float:right;padding:5px 0px 0px 0px;\">"._AIN_WITHS." <select name=\"modval\"><option value=\"1\">"._AIN_DEL."</option><option value=\"2\">"._AIN_DISMISS."</option><option value=\"3\">"._AIN_DOING."</option><option value=\"4\">"._AIN_PLAN."</option><option value=\"5\">"._AIN_EXECUTE."</option></select>   <input type='submit' value='"._AIN_OK."'></div>";
  echo "</form>";
  echo ideas_page('', $count, $total_pages, $ionpage, "op=aidea_new&amp;", 1);
  CloseTable();
  } else {OpenTable(); echo "<center><font class=\"title\"><b>"._IA_NONEW."</b></font></center>"; CloseTable();}
	foot();
}

function aidea_comm() {
global $db, $prefix, $admin_file, $count_com;
    $selck = (isset($_GET['selck'])) ? intval($_GET['selck']) : 0;
  if ($selck==1) $chkdall='checked';
    $ionpage=20;
    $cutat=20;
      head();
      aidea_navi();
  if ($count_com>0) {
    $total_pages = ceil($count_com / $ionpage);
    $pagenum = (isset($_GET['pagenum'])) ? intval($_GET['pagenum']) : 1;
    $min = $ionpage * ($pagenum - 1);
      OpenTable();
      echo "<center><font class=\"title\"><b>"._IA_COMM."</b></font></center>";
      CloseTable();
      OpenTable();
      echo '<script type="text/javascript" src="ideas/java-idea.js"></script><form name="post" action="'.$admin_file.'.php?op=aidea_fmoder3" method="post"><div style="float:right;padding:0px 0px 5px 0px;"><noscript><a href="'.$admin_file.'.php?op=aidea_comm&amp;selck=1"></noscript>'._AIA_SEL.'<noscript></a></noscript> / <noscript><a href="'.$admin_file.'.php?op=aidea_comm&amp;selck=0"></noscript>'._AIA_UNSEL.'<noscript></a></noscript>  <input style="border: 4px double green;" onclick="CheckAll(this,\'id[]\')" type="checkbox"></div>';
      echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" class=\"sort\" id=\"sort_id\">"
      ."<tr><th>"._AIN_ID."</th><th>"._AIN_TITLE."</th><th>"._AIN_AUTHOR."</th><th>"._AIK_ADD."</th><th>"._AIK_COM."</th><th>"._AIN_SE."</th></tr>";
    $result = $db->sql_query("SELECT a.id, a.iid, a.uid, a.author, a.cdate, a.text, b.title FROM ".$prefix."_icomments AS a LEFT JOIN ".$prefix."_ideas AS b ON (a.iid=b.id) ORDER BY a.id LIMIT $min, ".$ionpage."");
  while (list($id, $iid, $uid, $author, $cdate, $text, $title) = $db->sql_fetchrow($result)) {
  if (strlen($title)>$cutat) $title = "".trim(substr($title, 0, $cutat))."...";
  if ($uid!=0) $author='<a href="index.php?name=Account&amp;op=info&amp;uname='.$author.'">'.$author.'</a>';
      echo "<tr><td align=\"center\" class=\"bgcolor1\">$id</td><td align=\"left\" class=\"bgcolor1\">$title</td><td align=\"center\" class=\"bgcolor1\">$author</td><td align=\"center\" class=\"bgcolor1\">".ideadate($cdate ,1)."</td><td align=\"left\" class=\"bgcolor1\">".bb_decode(nl2br($text))."</td><td align=\"center\" class=\"bgcolor1\"><input onclick=\"return CheckCB(this);\" type='checkbox' name=\"id[]\" value=\"$id\" $chkdall>  <a href=\"".$admin_file.".php?op=aidea_comedit&id=$id\" title=\""._AIN_EDIT."\"><img src=\"ideas/images/edit.gif\" border=\"0\" alt=\""._AIN_EDIT."\"></a><a href=\"index.php?name=Ideas&amp;op=full_idea&amp;id=$iid\" title=\""._AIM_VIEW."\" target=\"_blank\"><img src=\"ideas/images/preview.gif\" border=\"0\" alt=\""._AIM_VIEW."\"></a></td></tr>";
  }
      echo "</table><div style=\"float:right;padding:5px 0px 0px 0px;\">"._AIN_WITHS." <select name=\"modval\"><option value=\"1\">"._AIN_DEL."</option></select>   <input type='submit' value='"._AIN_OK."'></div>";
      echo "</form>";
      echo ideas_page('', $count_com, $total_pages, $ionpage, "op=aidea_comm&amp;", 1);
      CloseTable();
  } else {OpenTable(); echo "<center><font class=\"title\"><b>"._IA_NOCOM."</b></font></center>"; CloseTable();}
	    foot();

}

function aidea_comedit($id=0, $stop='') {
global $db, $prefix, $admin_file, $idea;
if ($id==0) $id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
if ($id==0) {Header("Location: ".$admin_file.".php?op=aidea_comm");die();}
$result = $db->sql_query("SELECT a.uid, a.author, a.cdate, a.text, a.ip, b.title FROM ".$prefix."_icomments AS a LEFT JOIN ".$prefix."_ideas AS b ON (a.iid=b.id) WHERE a.id='$id'");
  list($uid, $author, $cdate, $text, $ip, $title) = $db->sql_fetchrow($result);
    head();
    aidea_navi();
    if ($stop==1) $stop="<br /><b><font color='red'>"._AIK_NOINP."</font></b><br />";
    if ($idea['bb_decode']==0) $bbwarn="<br /><font color='red'><b><small>"._AIK_BBW."</small></b></font>";
    else $bbwarn='';
    if ($uid!=0) {$author='<a href="index.php?name=Account&amp;op=info&amp;uname='.$author.'">'.$author.'</a>'; $ainauthor=_AIKA_USER;}
    else {$ainauthor=_AIKA_GUEST;}
    OpenTable();
    echo "<center><font class=\"title\"><b>"._AIK_EDIT." $id</b></font></center>";
    echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\"><form name=\"post\" action=\"".$admin_file.".php\" method=\"post\">"
	  ."<tr><td>"._AIN_TITLE.":</td><td>$title</td></tr>"
	  ."<tr><td>$ainauthor:</td><td>$author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ <a href='http://www.dnsstuff.com/tools/whois.ch?ip=$ip'>"._AIE_IPI."</a> ] [ <a href='/$admin_file.php?op=SecurityBlocker&amp;new_ip=$ip'>"._AIE_IPB." IP</a> ]</td></tr>"
	  ."<tr><td>"._AIK_ADD.":</td><td>".ideadate($cdate ,1)."</td></tr>"
	  ."<tr><td>"._AIKE_RDATE."</td><td><input type='checkbox' name=\"refdate\" value=\"1\"></td></tr>"
	  ."<tr><td>$stop"._AIK_COM.":$bbwarn</td><td><textarea id=\"area\" name=\"comment\" cols=\"65\" rows=\"15\" style=\"width:400px\" OnKeyPress=\"TransliteFeld(this, event)\" OnSelect=\"FieldName(this, this.name)\" OnClick=\"FieldName(this, this.name)\" OnKeyUp=\"FieldName(this, this.name)\">".$text."</textarea>".get_code("area")."</td></tr>";
	  echo "</table><center><br /><input type=\"hidden\" name=\"id\" value=\"$id\"><input type='hidden' name='op' value='aidea_comsave'><input type='submit' value='"._AIC_CONFS."'></center></form>";
    CloseTable();
	  foot();  
}

function aidea_comsave() {
global $db, $prefix, $admin_file;
$stop=0;$id=0;
if (isset($_POST['id'])) $id=intval($_POST['id']);
if (isset($_POST['refdate'])) $refdate=intval($_POST['refdate']);
if (isset($_POST['comment']) && $_POST['comment']!='') $comment=text_filter($_POST['comment']);
else {aidea_comedit($id, 1);$stop=1;}
if ($stop==0 && $refdate==1 && $id!=0) {$db->sql_query("UPDATE ".$prefix."_icomments SET text='$comment', cdate='".time()."' WHERE id='$id'");Header("Location: ".$admin_file.".php?op=aidea_comm");}
elseif ($stop==0 && $id!=0) {$db->sql_query("UPDATE ".$prefix."_icomments SET text='$comment' WHERE id='$id'");Header("Location: ".$admin_file.".php?op=aidea_comm");}
elseif ($id==0) Header("Location: ".$admin_file.".php?op=aidea_comm");

}

function aidea_main() {
global $db, $prefix, $admin_file;
    $cutat=20;
    $selck = (isset($_GET['selck'])) ? intval($_GET['selck']) : 0;
    if ($selck==1) $chkdall='checked';
    else $chkdall='';
    $result = $db->sql_query("SELECT COUNT(*) FROM ".$prefix."_ideas WHERE status!='5'");
    list($count) = $db->sql_fetchrow($result);
    $ionpage=20;
    head();
    aidea_navi();
    if ($count>0) {
    $total_pages = ceil($count / $ionpage);
    $pagenum = (isset($_GET['pagenum'])) ? intval($_GET['pagenum']) : 1;
    $min = $ionpage * ($pagenum - 1);
    OpenTable();
  echo "<center><font class=\"title\"><b>"._IA_IDEAS."</b></font></center>";
    CloseTable();
    OpenTable();
  echo '<script type="text/javascript" src="ideas/java-idea.js"></script><form name="post" action="'.$admin_file.'.php?op=aidea_fmoder2" method="post"><div style="float:right;padding:0px 0px 5px 0px;"><noscript><a href="'.$admin_file.'.php?op=aidea_main&amp;selck=1"></noscript>'._AIA_SEL.'<noscript></a></noscript> / <noscript><a href="'.$admin_file.'.php?op=aidea_main&amp;selck=0"></noscript>'._AIA_UNSEL.'<noscript></a></noscript>  <input style="border: 4px double green;" onclick="CheckAll(this,\'id[]\')" type="checkbox"></div><br />';
  echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" class=\"sort\" id=\"sort_id\">"
  ."<tr><th>"._AIN_ID."</th><th>"._AIN_TITLE."</th><th>"._AIN_AUTHOR."</th><th>"._AIN_DATE."</th><th>"._AIE_STS."</th><th>"._AIM_TCOM."</th><th>"._IA_OFFOTVET."</th><th>"._AIN_SE."</th></tr>";
    $result = $db->sql_query("SELECT id, title, author, date, uid, status, close, answer, comments FROM ".$prefix."_ideas WHERE status!='5' ORDER BY id LIMIT $min, ".$ionpage."");
   while (list($id, $title, $author, $date, $uid, $status, $close, $answer, $comments) = $db->sql_fetchrow($result)) {
    if ($status==1) $sd="<font color='red'>"._AIE_STS_1."</font>";
    elseif ($status==2) $sd="<font color='orange'>"._AIE_STS_2."</font>";
    elseif ($status==3) $sd="<font color='blue'>"._AIE_STS_3."</font>";
    elseif ($status==4) $sd="<font color='green'>"._AIE_STS_4."</font>";
    if ($close==1) $cd="<font color='green'>"._AIM_CAL."</font> [$comments]";
    elseif ($close==2) $cd="<font color='orange'>"._AIM_CUSER."</font> [$comments]";
    elseif ($close==3) $cd="<font color='red'>"._AIM_CNOT."</font> [$comments]";
    if ($answer!='') $ad="<font color='green'>"._AIC_8_1."</font>";
    else $ad="<font color='red'>"._AIC_8_0."</font>";
    if (strlen($title)>$cutat) $title = "".trim(substr($title, 0, $cutat))."...";
    if ($uid!=0) $author='<a href="index.php?name=Account&amp;op=info&amp;uname='.$author.'">'.$author.'</a>';
  echo "<tr><td align=\"center\" class=\"bgcolor1\">$id</td><td class=\"bgcolor1\">$title</td><td align=\"center\" class=\"bgcolor1\">$author</td><td align=\"center\" class=\"bgcolor1\">".ideadate($date ,1)."</td><td align=\"center\" class=\"bgcolor1\">$sd</td><td align=\"center\" class=\"bgcolor1\">$cd</td><td align=\"center\" class=\"bgcolor1\">$ad</td><td align=\"center\" class=\"bgcolor1\"><input onclick=\"return CheckCB(this);\" type='checkbox' name=\"id[]\" value=\"$id\" $chkdall>  <a href=\"".$admin_file.".php?op=aidea_edit&id=$id\" title=\""._AIN_EDIT."\"><img src=\"ideas/images/edit.gif\" border=\"0\" alt=\""._AIN_EDIT."\"></a><a href=\"index.php?name=Ideas&amp;op=full_idea&amp;id=$id\" title=\""._AIM_VIEW."\" target=\"_blank\"><img src=\"ideas/images/preview.gif\" border=\"0\" alt=\""._AIM_VIEW."\"></a></td></tr>";
  }
  echo "</table><div style=\"float:right;padding:5px 0px 0px 0px;\">"._AIN_WITHS." <select name=\"modval\"><option value=\"1\">"._AIN_DEL."</option><option value=\"2\">"._AIN_DISMISS."</option><option value=\"3\">"._AIN_DOING."</option><option value=\"4\">"._AIN_PLAN."</option><option value=\"5\">"._AIN_EXECUTE."</option><option value=\"6\">"._AIM_CLOSE1."</option><option value=\"7\">"._AIM_CLOSE2."</option><option value=\"8\">"._AIM_CLOSE3."</option></select>   <input type='submit' value='"._AIN_OK."'></div>";
  echo "</form>";
  echo ideas_page('', $count, $total_pages, $ionpage, "op=aidea_main&amp;", 1);
  CloseTable();
  } else {OpenTable(); echo "<center><font class=\"title\"><b>"._IA_NOID."</b></font></center>"; CloseTable();}
	foot();
}

function aidea_fmoder3() {
global $db, $prefix, $admin_file, $admin;
   $modval = (isset($_POST['modval'])) ? intval($_POST['modval']) : 0;
   $id = isset($_POST['id']);
   $list = array();
   foreach($_POST['id'] as $id) $list[] = intval($id);
   $list = implode(',' , $list);
   if ($modval==1) {
   $result = $db->sql_query("SELECT iid FROM ".$prefix."_icomments WHERE id IN ($list)");
   $db->sql_query("DELETE FROM ".$prefix."_icomments WHERE id IN ($list)");
   while (list($iid) = $db->sql_fetchrow($result)) {
   $db->sql_query("UPDATE ".$prefix."_ideas SET comments=comments-1 WHERE id='$iid'");
   }
   Header("Location: ".$admin_file.".php?op=aidea_comm");
}
}

function aidea_fmoder2() {
global $db, $prefix, $admin_file, $admin;
   $modval = (isset($_POST['modval'])) ? intval($_POST['modval']) : 0;
   $id = isset($_POST['id']);
   $list = array();
   foreach($_POST['id'] as $id) $list[] = intval($id);
   $list = implode(',' , $list);
   if ($modval==1) {$db->sql_query("DELETE FROM ".$prefix."_ideas WHERE id IN ($list)");$db->sql_query("DELETE FROM ".$prefix."_icomments WHERE iid IN ($list)");}
   elseif ($modval==2) $db->sql_query("UPDATE ".$prefix."_ideas SET status = '1' WHERE id IN ($list)");
   elseif ($modval==3) $db->sql_query("UPDATE ".$prefix."_ideas SET status = '2' WHERE id IN ($list)");
   elseif ($modval==4) $db->sql_query("UPDATE ".$prefix."_ideas SET status = '3' WHERE id IN ($list)");
   elseif ($modval==5) $db->sql_query("UPDATE ".$prefix."_ideas SET status = '4' WHERE id IN ($list)");
   elseif ($modval==6) $db->sql_query("UPDATE ".$prefix."_ideas SET close = '1', whoclose='', reason='' WHERE id IN ($list)");
   elseif ($modval==7) $db->sql_query("UPDATE ".$prefix."_ideas SET close = '2', whoclose='".$admin[1]."', reason='' WHERE id IN ($list)");
   elseif ($modval==8) $db->sql_query("UPDATE ".$prefix."_ideas SET close = '3', whoclose='".$admin[1]."', reason='' WHERE id IN ($list)");
   Header("Location: ".$admin_file.".php?op=aidea_main");
}

function aidea_fmoder() {
global $db, $prefix, $admin_file;
   $modval = (isset($_POST['modval'])) ? intval($_POST['modval']) : 0;
   $id = isset($_POST['id']);
   $list = array();
   foreach($_POST['id'] as $id) $list[] = intval($id);
   $list = implode(',' , $list);
   if ($modval==1) {$db->sql_query("DELETE FROM ".$prefix."_ideas WHERE id IN ($list)");$db->sql_query("DELETE FROM ".$prefix."_icomments WHERE iid IN ($list)");}
   elseif ($modval==2) $db->sql_query("UPDATE ".$prefix."_ideas SET status = '1' WHERE id IN ($list)");
   elseif ($modval==3) $db->sql_query("UPDATE ".$prefix."_ideas SET status = '2' WHERE id IN ($list)");
   elseif ($modval==4) $db->sql_query("UPDATE ".$prefix."_ideas SET status = '3' WHERE id IN ($list)");
   elseif ($modval==5) $db->sql_query("UPDATE ".$prefix."_ideas SET status = '4' WHERE id IN ($list)");
   Header("Location: ".$admin_file.".php?op=aidea_new");
}

function aidea_edit() {
global $db, $prefix, $admin_file;
 $id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
 if ($id!='') {
    head();
    aidea_navi();
 $result = $db->sql_query("SELECT title, `desc`, author, mail, ip, uid, `date`, karma, comments, status, close, reason, totalvote, answer, responder, timeanswer, whoclose FROM ".$prefix."_ideas WHERE id='$id'");
 list($title, $desc, $author, $mail, $ip, $uid, $date, $karma, $comments, $status, $close, $reason, $totalvote, $answer, $responder, $timeanswer, $whoclose) = $db->sql_fetchrow($result);
 if ($uid!=0) {$auser='[ <a href="index.php?name=Account&amp;op=info&amp;uname='.$author.'">'._AIE_SEE.'</a> ]'; $ainauthor=_AIE_USER;}
 else {$auser=''; $ainauthor=_AIE_GUEST;}
 if ($status==5) $remb=_AIE_STS_N;
 else $remb="";
    OpenTable();
    echo "<center><font class=\"title\"><b>"._IA_EDIT."</b></font></center>";
    echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\"><form name=\"post\" action=\"".$admin_file.".php\" method=\"post\">"
	  ."<tr><td>"._AIN_TITLE.":</td><td><input type=\"text\" name=\"title\" value=\"$title\" size=\"65\" style=\"width:400px\"></td></tr>"
	  ."<tr><td>"._AIE_DESC.":</td><td><textarea id=\"area\" name=\"desc\" cols=\"65\" rows=\"15\" style=\"width:400px\" OnKeyPress=\"TransliteFeld(this, event)\" OnSelect=\"FieldName(this, this.name)\" OnClick=\"FieldName(this, this.name)\" OnKeyUp=\"FieldName(this, this.name)\">".$desc."</textarea>".get_code("area")."</td></tr>"
	  ."<tr><td>$ainauthor:</td><td><input type=\"text\" name=\"author\" value=\"$author\" size=\"65\" style=\"width:400px\">  $auser</td></tr>"
	  ."<tr><td>"._AIE_MAIL.":</td><td><input type=\"text\" name=\"mail\" value=\"$mail\" size=\"65\" style=\"width:400px\">  [ <a href=\"mailto:$mail\" title=\"$mail\">"._AIE_SMAIL."</a> ]</td></tr>"
	  ."<tr><td>"._AIE_IP.":</td><td><input type=\"text\" name=\"ip\" value=\"$ip\" size=\"65\" style=\"width:400px\"> [ <a href='$admin_file.php?op=SecurityBlocker&new_ip=$ip'>"._AIE_IPB."</a> ]  [ <a href='http://www.dnsstuff.com/tools/whois.ch?ip=$ip'>"._AIE_IPI."</a> ]</td></tr>"
	  ."<tr><td>"._AIE_STS.":</td><td><select name=\"status\"><option style=\"color: red;\" value=\"1\" ".aidea_select($status, 1).">"._AIE_STS_1."</option><option style=\"color: orange;\" value=\"2\" ".aidea_select($status, 2).">"._AIE_STS_2."</option><option style=\"color: blue;\" value=\"3\" ".aidea_select($status, 3).">"._AIE_STS_3."</option><option style=\"color: green;\" value=\"4\" ".aidea_select($status, 4).">"._AIE_STS_4."</option></select>  $remb</td></tr>"
    ."<tr><td>"._AIE_RDATE."</td><td><input type='checkbox' name=\"date\" value=\"1\"></td></tr>"
  ."<tr><td><center><font class='option'><b>"._IA_CONF_2."</b></font></center></td></tr>"	  
	  ."<tr><td>"._AIE_CS_IND.":</td><td><select name=\"close\"><option style=\"color: green;\" value=\"1\" ".aidea_select($close, 1).">"._AIE_CS_IND_1."</option><option style=\"color: blue;\" value=\"2\" ".aidea_select($close, 2).">"._AIE_CS_IND_2."</option><option style=\"color: red;\" value=\"3\" ".aidea_select($close, 3).">"._AIE_CS_IND_3."</option></select></td></tr>"
	  ."<tr><td>"._AIE_CR.":</td><td><textarea name=\"reason\" cols=\"65\" rows=\"8\" style=\"width:400px\">".$reason."</textarea></td></tr>"
	  ."<tr><td>"._AIE_WHO.":</td><td><input type=\"text\" name=\"whoclose\" value=\"$whoclose\" size=\"65\" style=\"width:400px\"></td></tr>"
  ."<tr><td><center><font class='option'><b>"._IA_OFFANSWER."</b></font></center></td></tr>";	  
	  echo "<tr><td>"._IA_OFFOTVET.":</td><td><textarea id=\"area2\" name=\"answer\" cols=\"65\" rows=\"15\" style=\"width:400px\" OnKeyPress=\"TransliteFeld(this, event)\" OnSelect=\"FieldName(this, this.name)\" OnClick=\"FieldName(this, this.name)\" OnKeyUp=\"FieldName(this, this.name)\">".$answer."</textarea>".get_code("area2")."</td></tr>"
	  ."<tr><td>"._IA_OFFWHO.":</td><td><input type=\"text\" name=\"responder\" value=\"$responder\" size=\"65\" style=\"width:400px\"></td></tr>";
 if ($timeanswer!=0) echo "<tr><td>"._IA_OFFDATE."</td><td><input type='checkbox' name=\"timeanswer\" value=\"1\"></td></tr>";
    echo "</table><center><br /><input type=\"hidden\" name=\"id\" value=\"$id\"><input type='hidden' name='op' value='aidea_save'><input type='submit' value='"._AIC_CONFS."'></center></form>";
    CloseTable();
	  foot();
	}
}

function aidea_delete() {
global $db, $prefix, $admin_file;
   $ok = (isset($_GET['ok'])) ? intval($_GET['ok']) : 0;
   $id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
   if ($id!=0 && $ok==0) {
   $result = $db->sql_query("SELECT title FROM ".$prefix."_ideas WHERE id='$id'");
   list($title) = $db->sql_fetchrow($result);
   head();
   aidea_navi();
   OpenTable();
   echo "<center><font class=\"title\"><b>"._IA_DELETE."</b></font></center>";
   echo "<tr><td><center><font class='option'><b>"._IA_DWARN."</b></font>:<br />\"$title\"<br />[ <a href=\"".$admin_file.".php?op=aidea_delete&amp;id=$id&amp;ok=1\">"._AIC_8_1."</a> | <a href=\"".$admin_file.".php?op=aidea_main\">"._AIC_8_0."</a> ]</center></td></tr>";
   CloseTable();
	 foot();
   } elseif ($id!=0 && $ok==1) {
   $db->sql_query("DELETE FROM ".$prefix."_ideas WHERE id='$id'");
   $db->sql_query("DELETE FROM ".$prefix."_icomments WHERE iid='$id'");
   Header("Location: ".$admin_file.".php?op=aidea_main");
   } else Header("Location: ".$admin_file.".php?op=aidea_main");
}

function aidea_comdel() {
global $db, $prefix, $admin_file;
   $ok = (isset($_GET['ok'])) ? intval($_GET['ok']) : 0;
   $id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
   if ($id!=0) {$result = $db->sql_query("SELECT iid, text FROM ".$prefix."_icomments WHERE id='$id'");list($iid, $title) = $db->sql_fetchrow($result);}
   if ($id!=0 && $ok==0) {
   head();
   aidea_navi();
   OpenTable();
   echo "<center><font class=\"title\"><b>"._AIK_DELK."</b></font></center>";
   echo "<tr><td><center><font class='option'><b>"._AIK_DELW."</b></font>:<br />\"".bb_decode(nl2br($title))."\"<br />[ <a href=\"".$admin_file.".php?op=aidea_comdel&amp;id=$id&amp;ok=1\">"._AIC_8_1."</a> | <a href=\"".$admin_file.".php?op=aidea_comm\">"._AIC_8_0."</a> ]</center></td></tr>";
   CloseTable();
	 foot();
   } elseif ($id!=0 && $ok==1) {
   $db->sql_query("UPDATE ".$prefix."_ideas SET comments=comments-1 WHERE id='$iid'");
   $db->sql_query("DELETE FROM ".$prefix."_icomments WHERE id='$id'");
   Header("Location: ".$admin_file.".php?op=aidea_comm");
   } else Header("Location: ".$admin_file.".php?op=aidea_comm");
}

function aidea_save() {
global $db, $prefix, $admin_file;
  $id = (isset($_POST['id'])) ? intval($_POST['id']) : 0;
  if ($id!=0) {
  $result = $db->sql_query("SELECT `date`, timeanswer, uid, status FROM ".$prefix."_ideas WHERE id='$id'");
  list($time, $timea, $uid, $status) = $db->sql_fetchrow($result);
  $tchk='';$tachk='';
  $skip = (isset($_POST['skip'])) ? intval($_POST['skip']) : 0;
  $stop='';$red1='';$red2='';$red3='';$red4='';$red5='';$red6='';$red7='';
    head();
    aidea_navi();
  $mnav="  [ <a href=\"mailto:$mail\" title=\"$mail\">"._AIE_SMAIL."</a> ]";
	$title = (isset($_POST['title'])) ? text_filter($_POST['title']) : '';
	$mail = (isset($_POST['mail'])) ? text_filter($_POST['mail']) : '';
	$author = (isset($_POST['author'])) ? text_filter($_POST['author']) : '';
	$desc = (isset($_POST['desc'])) ? text_filter($_POST['desc']) : '';
	$ip = (isset($_POST['ip'])) ? text_filter($_POST['ip']) : '';
	$status = (isset($_POST['status'])) ? intval($_POST['status']) : 1;
  $date = (isset($_POST['date'])) ? intval($_POST['date']) : 0;
  if ($date==1) {$time=time();$tchk='checked';}
  $close = (isset($_POST['close'])) ? intval($_POST['close']) : 1;
  $reason = (isset($_POST['reason'])) ? text_filter($_POST['reason']) : '';
  $whoclose = (isset($_POST['whoclose'])) ? text_filter($_POST['whoclose']) : '';
  $answer = (isset($_POST['answer'])) ? text_filter($_POST['answer']) : '';
  $responder = (isset($_POST['responder'])) ? text_filter($_POST['responder']) : '';
  $timeanswer = (isset($_POST['timeanswer'])) ? intval($_POST['timeanswer']) : 0;
  if ($timeanswer==1) {$timea=time();$tachk='checked';}
  if ($title=='') {$stop .="<br />"._AIS_ER1."";$red1="background-color: #FCD4D2;border: 1px solid black;";}
  if ($mail=='') {$stop .="<br />"._AIS_ER2."";$red2="background-color: #FCD4D2;border: 1px solid black;";$mnav='';}
  if ($author=='') {$stop .="<br />"._AIS_ER3."";$red3="background-color: #FCD4D2;border: 1px solid black;";$auser=''; $ainauthor=_AIE_NONAME;}
  if ($desc=='') {$stop .="<br />"._AIS_ER4."";$red4="background-color: #FCD4D2;border: 1px solid black;";}
  if ($close!=1 && $reason=='') {$stop .="<br />"._AIS_ER5."";$red5="background-color: #FCD4D2;border: 1px solid black;";}
  if ($close!=1 && $whoclose=='') {$stop .="<br />"._AIS_ER6."";$red6="background-color: #FCD4D2;border: 1px solid black;";}
  if ($answer!='' && $responder=='') {$stop .="<br />"._AIS_ER7."";$red7="background-color: #FCD4D2;border: 1px solid black;";}
  if ($stop!='' && $skip==0) {
  if ($uid!=0 && $author!='') {$auser='[ <a href="index.php?name=Account&amp;op=info&amp;uname='.$author.'">'._AIE_SEE.'</a> ]'; $ainauthor=_AIE_USER;}
  elseif ($author!='') {$auser=''; $ainauthor=_AIE_GUEST;}
  if ($status==5) $remb=_AIE_STS_N;
  else $remb="";
    OpenTable();
    echo "<center><font class=\"title\"><b>"._AIS_ER8."</b></font><font color='green'><b>$stop</b></font></center>";
    echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\"><form name=\"post\" action=\"".$admin_file.".php?op=aidea_save\" method=\"post\">"
	  ."<tr><td>"._AIN_TITLE.":</td><td><input type=\"text\" name=\"title\" value=\"$title\" size=\"65\" style=\"width:400px;$red1\"></td></tr>"
	  ."<tr><td>"._AIE_DESC.":</td><td><textarea id=\"area\" name=\"desc\" cols=\"65\" rows=\"15\" style=\"width:400px;$red4\" OnKeyPress=\"TransliteFeld(this, event)\" OnSelect=\"FieldName(this, this.name)\" OnClick=\"FieldName(this, this.name)\" OnKeyUp=\"FieldName(this, this.name)\">".$desc."</textarea>".get_code("area")."</td></tr>"
	  ."<tr><td>$ainauthor:</td><td><input type=\"text\" name=\"author\" value=\"$author\" size=\"65\" style=\"width:400px;$red3\">  $auser</td></tr>"
	  ."<tr><td>"._AIE_MAIL.":</td><td><input type=\"text\" name=\"mail\" value=\"$mail\" size=\"65\" style=\"width:400px;$red2\">$mnav</td></tr>"
	  ."<tr><td>"._AIE_IP.":</td><td><input type=\"text\" name=\"ip\" value=\"$ip\" size=\"65\" style=\"width:400px\"> [ <a href='$admin_file.php?op=SecurityBlocker&new_ip=$ip'>"._AIE_IPB."</a> ]  [ <a href='http://www.dnsstuff.com/tools/whois.ch?ip=$ip'>"._AIE_IPI."</a> ]</td></tr>"
	  ."<tr><td>"._AIE_STS.":</td><td><select name=\"status\"><option style=\"color: red;\" value=\"1\" ".aidea_select($status, 1).">"._AIE_STS_1."</option><option style=\"color: orange;\" value=\"2\" ".aidea_select($status, 2).">"._AIE_STS_2."</option><option style=\"color: blue;\" value=\"3\" ".aidea_select($status, 3).">"._AIE_STS_3."</option><option style=\"color: green;\" value=\"4\" ".aidea_select($status, 4).">"._AIE_STS_4."</option></select>  $remb</td></tr>"
    ."<tr><td>"._AIE_RDATE."</td><td><input type='checkbox' name=\"date\" value=\"1\" $tchk></td></tr>"
 ."<tr><td><center><font class='option'><b>"._IA_CONF_2."</b></font></center></td></tr>"	  
	  ."<tr><td>"._AIE_CS_IND.":</td><td><select name=\"close\"><option style=\"color: green;\" value=\"1\" ".aidea_select($close, 1).">"._AIE_CS_IND_1."</option><option style=\"color: blue;\" value=\"2\" ".aidea_select($close, 2).">"._AIE_CS_IND_2."</option><option style=\"color: red;\" value=\"3\" ".aidea_select($close, 3).">"._AIE_CS_IND_3."</option></select></td></tr>"
	  ."<tr><td>"._AIE_CR.":</td><td><textarea name=\"reason\" cols=\"65\" rows=\"8\" style=\"width:400px;$red5\">".$reason."</textarea></td></tr>"
	  ."<tr><td>"._AIE_WHO.":</td><td><input type=\"text\" name=\"whoclose\" value=\"$whoclose\" size=\"65\" style=\"width:400px;$red6\"></td></tr>"
 ."<tr><td><center><font class='option'><b>"._IA_OFFANSWER."</b></font></center></td></tr>";	  
	  echo "<tr><td>"._IA_OFFOTVET.":</td><td><textarea id=\"area2\" name=\"answer\" cols=\"65\" rows=\"15\" style=\"width:400px\" OnKeyPress=\"TransliteFeld(this, event)\" OnSelect=\"FieldName(this, this.name)\" OnClick=\"FieldName(this, this.name)\" OnKeyUp=\"FieldName(this, this.name)\">".$answer."</textarea>".get_code("area2")."</td></tr>"
	  ."<tr><td>"._IA_OFFWHO.":</td><td><input type=\"text\" name=\"responder\" value=\"$responder\" size=\"65\" style=\"width:400px;$red7\"></td></tr>";
	if ($timeanswer!=0) echo "<tr><td>"._IA_OFFDATE."</td><td><input type='checkbox' name=\"timeanswer\" value=\"1\" $tachk></td></tr>";
    echo "</table><center><font color='red'><b>"._AIS_ER9."</b></font> <input style=\"border: 4px double red;\" type='checkbox' name=\"skip\" value=\"1\"><br /><input type=\"hidden\" name=\"id\" value=\"$id\"><input type='submit' value='"._AIC_CONFS."'></center></form>";
    CloseTable();
	  foot(); 
  } else {
  $db->sql_query("UPDATE ".$prefix."_ideas SET title='$title', mail='$mail', author='$author', `desc`='$desc', ip='$ip', status='$status', `date`='$time', close='$close', reason='$reason', whoclose='$whoclose', answer='$answer', responder='$responder', timeanswer='$timea' WHERE id='$id'");
  Header("Location: ".$admin_file.".php?op=aidea_main");
  }
} else Header("Location: ".$admin_file.".php?op=aidea_main");
}

switch ($op) {
	  case "aidea_conf":aidea_conf();break;
    case "aidea_save":aidea_save();break;
    case "aidea_csave":aidea_csave();break;
    case "aidea_new":aidea_new();break;
    case "aidea_fmoder":aidea_fmoder();break;
    case "aidea_fmoder2":aidea_fmoder2();break;
    case "aidea_fmoder3":aidea_fmoder3();break;
    case "aidea_edit":aidea_edit();break;
    case "aidea_delete":aidea_delete();break;
    case "aidea_main":aidea_main();break;
    case "aidea_comm":aidea_comm();break;
    case "aidea_comedit":aidea_comedit();break;
    case "aidea_comsave":aidea_comsave();break;
    case "aidea_comdel":aidea_comdel();break;
}
?>