вопрос
Добрый день!
Вот решил для себя адаптировать модуль от kaliostro
Все сделал, модуль завелся, но админка нет(
Она сначала вообще не отображалась, потом я переделал и она показалась, но сохранение настроек не проходит!
Вот и прошу о помощи!
Вот код:
Помогите, пожалуйста!
Вот решил для себя адаптировать модуль от kaliostro
Все сделал, модуль завелся, но админка нет(
Она сначала вообще не отображалась, потом я переделал и она показалась, но сохранение настроек не проходит!
Вот и прошу о помощи!
Вот код:
<?php
if(!defined('DATALIFEENGINE'))
{
die("Hacking attempt!");
}
if($member_db[1] == 1 and $action == "dologin"){ header("Location: $config_http_script_dir/index.php?mod=options&action=personal"); exit; }
@include(ENGINE_DIR.'/data/block_forum_conf.php');
require_once(ROOT_DIR.'/language/'.$config['langs'].'/block_forum.lng');
function showRow($title="", $description="", $field="")
{
echo"<tr>
<td style=\"padding:4px\" class=\"option\">
<b>$title</b><br /><span class=small>$description</span>
<td width=394 align=middle >
$field
</tr><tr><td background=\"engine/skins/images/mline.gif\" height=1 colspan=2></td></tr>";
$bg = ""; $i++;
}
function makeDropDown($options, $name, $selected)
{
$output = "<select onclick=\"freeze(0)\" name=\"$name\">\r\n";
foreach($options as $value=>$description)
{
$output .= "<option value=\"$value\"";
if($selected == $value){ $output .= " selected "; }
$output .= ">$description</option>\n";
}
$output .= "</select>";
return $output;
}
function echomenu ($image, $header_text, $p = 0)
{
global $lang_block_forum;
echoheader ($image, $header_text, $p);
echo <<<HTML
<script language='javascript' type="text/javascript">
function showmenu(obj)
{
document.getElementById('settings').style.display = "none";
document.getElementById('block_new').style.display = "none";
document.getElementById('block_birth').style.display = "none";
document.getElementById('stats').style.display = "none";
document.getElementById(obj).style.display='';
}
</script>
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%" style="text-align:center">
<tr>
<td width="4"><img src="engine/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
<td background="engine/skins/images/tl_oo.gif"><img src="engine/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
<td width="6"><img src="engine/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
</tr>
<tr>
<td background="engine/skins/images/tl_lb.gif"><img src="engine/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td style="text-align:center"><a href="javascript:showmenu('block_new');" title='{$lang_block_forum['block_new']}'><img src="engine/skins/images/block_new.jpg" border="0" /></a></td>
<td style="text-align:center"><a href="javascript:showmenu('block_birth');" title='{$lang_block_forum['block_birth']}'><img src="engine/skins/images/block_birth.jpg" border="0" /></a></td>
<td style="text-align:center"><a class=main href="javascript:showmenu('settings');" title='{$lang_block_forum['settings']}' ><img src="engine/skins/images/settings.jpg" border="0" /></a></td>
</tr>
</table>
</td>
<td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
</tr>
<tr>
<td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
<td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
<td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
</tr>
</table>
</div>
HTML;
}
function footer_dle_ipb () {
global $block_forum_conf;
echo <<<HTML
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px; text-align:center"><div class="navigation">Copyright © 2007 created by <a target="_blank" href="http://www.kaliostro.net" style="text-decoration:underline;color:green">kaliostro</a>.</div></td>
</tr>
</table>
HTML;
echofooter();
}
function dle_ipb_msg($type, $title, $text, $back=FALSE){
global $lang, $lang_block_forum;
if($back){
$back = "<br /><br> <a class=main href=\"$back\">$lang[func_msg]</a>";
}
echoheader($type, $title);
echo <<<HTML
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td width="4"><img src="engine/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
<td background="engine/skins/images/tl_oo.gif"><img src="engine/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
<td width="6"><img src="engine/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
</tr>
<tr>
<td background="engine/skins/images/tl_lb.gif"><img src="engine/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">{$title}</div></td>
</tr>
</table>
<div class="unterline"></div>
<table width="100%">
<tr>
<td height="100" align="center">{$text} {$back}</td>
</tr>
</table>
</td>
<td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
</tr>
<tr>
<td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
<td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
<td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
</tr>
</table>
</div>
HTML;
footer_dle_ipb();
exit();
}
if ($action == "save") {
$save_con['version_id'] = "1.0.0";
if($member_db[1] != 1){ msg("error", $lang['opt_denied'], $lang['opt_denied']); }
$handler = fopen(ENGINE_DIR.'/data/block_forum_conf.php', "w");
fwrite($handler, "<?PHP \n\n//Forum Block Configurations\n\n\$block_forum_conf = array (\n\n");
function save_conf($save_con, $array=false) {
global $handler, $find, $replace;
foreach($save_con as $name => $value)
{
if (is_array($value)) { fwrite($handler, "'{$name}' => array (\n\n"); save_conf($value, true);} else {
$value = strtr($value, '"', "'");
fwrite($handler, "'{$name}' => \"".stripslashes($value)."\",\n\n"); }
}
if ($array) fwrite($handler, "),\n\n");
}
save_conf($save_con);
fwrite($handler, ");\n\n?>");
fclose($handler);
clear_cache ();
dle_ipb_msg("info", $lang['opt_sysok'], "$lang[opt_sysok_1]<br /><br /><a href=$PHP_SELF?mod=block_forum>$lang[db_prev]</a>");
}
if (!$action) {
echomenu("options", $lang_block_forum['settings'], '');
echo <<<HTML
<form action="" method="post" name="form">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
<tr>
<td width="4"><img src="engine/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
<td background="engine/skins/images/tl_oo.gif"><img src="engine/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
<td width="6"><img src="engine/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
</tr>
<tr>
<td background="engine/skins/images/tl_lb.gif"><img src="engine/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
<td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
HTML;
if ($work_date)
{
$exp_module = <<<HTML
<tr>
<td style="padding:2px;">{$lang_block_forum['work_date']}</td>
<td><font style="color:red" >$work_date</font></td>
</tr>
HTML;
}
echo <<<HTML
<tr id="stats" style=''><td>
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">{$lang_block_forum['stat_all']}</div></td>
</tr>
</table>
<div class="unterline"></div><table width="100%">
<tr>
<td width="265" style="padding:2px;">{$lang_block_forum['version']}</td>
<td>{$block_forum_conf['version_id']}</td>
</tr>
<tr>
<td style="padding:2px;">{$lang_block_forum['module_reg']}</td>
<td><b>{$licence}</b></td>
</tr>
$exp_module
</table></td></tr>
HTML;
echo <<<HTML
<tr id="block_new" style='display:none'><td>
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">{$lang_block_forum['block_new']}</div></td>
</tr>
</table>
<div class="unterline"></div><table width="100%">
HTML;
showRow($lang_block_forum['allow_forum_block'], $lang_block_forum['allow_forum_block_desc'], makeDropDown(array("1"=>$lang_block_forum['yes'],"0"=>$lang_block_forum['no']), "save_con[allow_forum_block]", "{$block_forum_conf['allow_forum_block']}"));
showRow($lang_block_forum['count_post'], $lang_block_forum['count_post_desc'], "<input class=edit type=text style=\"text-align: center;\" name='save_con[count_post]' value='{$block_forum_conf['count_post']}' size=10 onclick=\"freeze(0)\">");
showRow($lang_block_forum['leght_name'], $lang_block_forum['leght_name_desc'], "<input class=edit type=text style=\"text-align: center;\" name='save_con[leght_name]' value='{$block_forum_conf['leght_name']}' size=10 onclick=\"freeze(0)\">");
showRow($lang_block_forum['bad_forum_for_block'], $lang_block_forum['bad_forum_for_block_desc'], "<input class=edit type=text style=\"text-align: center;\" name='save_con[bad_forum_for_block]' value='{$block_forum_conf['bad_forum_for_block']}' size=10 onclick=\"freeze(1)\" id=\"bad\">");
showRow($lang_block_forum['good_forum_for_block'], $lang_block_forum['good_forum_for_block_desc'], "<input class=edit type=text style=\"text-align: center;\" name='save_con[good_forum_for_block]' value='{$block_forum_conf['good_forum_for_block']}' size=10 onclick=\"freeze(2)\" id=\"good\">");
echo "</table></td></tr>";
echo <<<HTML
<tr id="block_birth" style='display:none'><td>
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">{$lang_block_forum['block_birth']}</div></td>
</tr>
</table>
<div class="unterline"></div><table width="100%">
HTML;
showRow($lang_block_forum['allow_birthday_block'], $lang_block_forum['allow_birthday_block_desc'], makeDropDown(array("1"=>$lang_block_forum['yes'],"0"=>$lang_block_forum['no']), "save_con[allow_birthday_block]", "{$block_forum_conf['allow_birthday_block']}"));
showRow($lang_block_forum['count_birthday'], $lang_block_forum['count_birthday_desc'], "<input class=edit type=text style=\"text-align: center;\" name='save_con[count_birthday]' value='{$block_forum_conf['count_birthday']}' size=10 onclick=\"freeze(0)\">");
showRow($lang_block_forum['no_user_birthday'], $lang_block_forum['no_user_birthday_desc'], "<input class=edit type=text style=\"text-align: center;\" name='save_con[no_user_birthday]' value='".stripslashes($block_forum_conf['no_user_birthday'])."' size=30 onclick=\"freeze(0)\">");
showRow($lang_block_forum['spacer'], $lang_block_forum['spacer_desc'], "<input class=edit type=text style=\"text-align: center;\" name='save_con[spacer]' value='{$block_forum_conf['spacer']}' size=10 onclick=\"freeze(0)\">");
showRow($lang_block_forum['birthday_block'], $lang_block_forum['birthday_block_desc'], "<textarea onclick=\"freeze(0)\" cols=\"50\" rows=\"6\" name='save_con[birthday_block]'>".stripslashes($block_forum_conf['birthday_block'])."</textarea>");
echo "</table></td></tr>";
echo <<<HTML
<tr id="settings" style='display:none'><td>
<table width="100%">
<tr>
<td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">{$lang_block_forum['settings']}</div></td>
</tr>
</table>
<div class="unterline"></div><table width="100%">
<script language="javascript">
<!--
function freeze(value)
{
if (value == 1)
{
document.getElementById('bad').disabled = false
document.getElementById('good').value = ""
document.getElementById('good').disabled = true
}
if (value == 2)
{
document.getElementById('good').disabled = false
document.getElementById('bad').value = ""
document.getElementById('bad').disabled = true
}
if (value == 0)
{
document.getElementById('good').disabled = false
document.getElementById('bad').disabled = false
}
}
//-->
</script>
HTML;
$names_array = array("0"=>$lang_block_forum['no_other_names'],
"cp1251" => 'cp1251',
"cp1250" => 'cp1250',
"latin1" => 'latin1',
"latin2" => 'latin2',
"koi8r" => 'koi8r',
"ascii" => 'ascii',
"koi8u" => 'koi8u',
"utf8" => 'utf8',
"cp866" => 'cp866');
$charset_array = array("0"=>$lang_block_forum['no_other_charset'],
"cp1251" => 'cp1251',
"cp1250" => 'cp1250',
"latin1" => 'latin1',
"latin2" => 'latin2',
"koi8r" => 'koi8r',
"ascii" => 'ascii',
"koi8u" => 'koi8u',
"utf8" => 'utf8',
"cp866" => 'cp866');
showRow($lang_block_forum['other_names_ipb'], $lang_block_forum['other_names_ipb_desc'], makeDropDown($names_array, "save_con[other_names_ipb]", "{$block_forum_conf['other_names_ipb']}"));
showRow($lang_block_forum['other_charset_ipb'], $lang_block_forum['other_charset_ipb_desc'], makeDropDown($charset_array, "save_con[other_charset_ipb]", "{$block_forum_conf['other_charset_ipb']}"));
showRow($lang_block_forum['other_names_dle'], $lang_block_forum['other_names_dle_desc'], makeDropDown($names_array, "save_con[other_names_dle]", "{$block_forum_conf['other_names_dle']}"));
showRow($lang_block_forum['other_charset_dle'], $lang_block_forum['other_charset_dle_desc'], makeDropDown($charset_array, "save_con[other_charset_dle]", "{$block_forum_conf['other_charset_dle']}"));
echo "</table></td></tr>";
echo <<<HTML
<tr>
<td style="padding-top:10px; padding-bottom:10px;padding-right:10px;">
<input type=hidden name=action value=save><input type="submit" class="buttons" value="{$lang['user_save']}"></td>
</tr>
</table>
</td>
<td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
</tr>
<tr>
<td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
<td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
<td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
</tr>
</table>
</div></form>
HTML;
footer_dle_ipb ();
}
?>
Помогите, пожалуйста!
Ответил: D0Gmatist
if ( $_POST['action'] == "save" ) {
function save_conf ( $save_con, $array = FALSE )
{
global $find, $replace;
if ( $array == FALSE ) {
$handler = fopen( ENGINE_DIR . '/data/block_forum_conf.php', "w" );
fwrite( $handler, "<?PHP \n\n//Forum Block Configurations\n\n\$block_forum_conf = array (\n\n" );
}
foreach ( $save_con as $name => $value ) {
if ( is_array( $value ) ) {
fwrite( $handler, "'{$name}' => array (\n\n" );
save_conf ( $value, TRUE );
} else {
$value = strtr( $value, '"', "'" );
fwrite( $handler, "'{$name}' => \"" . stripslashes($value) . "\",\n\n" );
}
}
if ($array) {
fwrite( $handler, "),\n\n" );
}
if ( $array == FALSE ) {
fwrite( $handler, ");\n\n?>" );
fclose( $handler );
}
}
$save_con = $_POST['save_con'];
$save_con['version_id'] = "1.0.0";
$save_con = $save_con + $block_forum_conf;
save_conf ( $save_con );
clear_cache();
dle_ipb_msg("info", $lang['opt_sysok'], "$lang[opt_sysok_1]<br /><br /><a href=$PHP_SELF?mod=block_forum>$lang[db_prev]</a>");
}