<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.1 www.exoops.info 2006/03
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Mysterix @ Sub-port
// Author Website : http://www.e-xoops.com
// Licence Type   : GPL
// ------------------------------------------------------------------------- //
include_once("./admin_header.php");
//------------------------------------------------------------------------------------------//
function setupindex() {
xoops_cp_header();
OpenTable();
echo "
- <b><a href='./index.php?op=main'>"._MI_XIRC_MAIN."</a></b><br />
- <b><a href='./index.php?op=appearance'>"._MI_XIRC_APPEARANCE."</a></b><br />
- <b><a href='./index.php?op=footer'>"._MI_XIRC_FOOTER."</a></b><br />
<br />xPJIRC 1.0 <a href='http://www.mandaxy.de'>Mandaxy</a>";
CloseTable();
xoops_cp_footer();
}
function xpjirc_navig() {
echo '<a href="./index.php?op=main">'._MI_XIRC_MAIN.'</a> | <a href="./index.php?op=appearance">'._MI_XIRC_APPEARANCE.'</a> | <a href="./index.php?op=footer">'._MI_XIRC_FOOTER.'</a> ';
}
//------------------------------------------------------------------------------------------//
function main() {
global $xoopsModule;
include_once(XOOPS_ROOT_PATH . "/modules/xpjirc/cache/config.php");
xoops_cp_header();
OpenTable();
?>
<form name="main" action="./index.php?op=save_main" method="post">
<table border="0" align="center">
<tr>
<td colspan="2"><hr align="center" noshade="noshade" />
<div align="center"><?php xpjirc_navig(); ?></div>
<hr align="center" noshade="noshade" /></td>
</tr><tr>
<td colspan="2"><hr align="center" noshade="noshade" />
<div align="center"><?php echo _AM_XIRC_SERVER_LIST;?></div>
<hr align="center" noshade="noshade" /></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_SERVERS;?> :</td>
<td><input name="host" type="text" class="text" value="<?php echo $irc_cfg['host'];?>" /></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_PORT;?> :</td>
<td><input name="port" type="text" class="text" value="<?php echo $irc_cfg['port'];?>" size="4" maxlength=4 /></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_ALTSERVERS;?> :</td>
<td><input name="alternateserver" type="text" class="text" value="<?php echo $irc_cfg['alternateserver'];?>" /></td>
</tr>
<tr>
<td colspan="2"><hr align="center" noshade="noshade" />
<div align="center"><?php echo _AM_XIRC_CHANNEL_LIST;?></div>
<hr align="center" noshade="noshade" /></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_CHANNELS;?> :</td>
<td><input name="channel" type="text" class="text" value="<?php echo $irc_cfg['channel'];?>" /> (with leading # )</td>
</tr><tr>
<td colspan="2"><hr align="center" noshade="noshade" />
<div align="center"><?php echo _AM_XIRC_MISC;?></div>
<hr align="center" noshade="noshade" /></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_DEF_LANG;?> :</td>
<td><select name="deflang" class="select">
<?php
$handle = opendir("../sources/java");
while ($file = readdir($handle)) {
if (preg_match("/(.*)?\.(lng)$/i", $file, $matches) || preg_match("/(.*)?\.(txt)$/i", $file, $matches)) {
$lang[] = $matches[1];
}}
closedir($handle);
for ($i=0; $i<count($lang); $i++) {
if ( $irc_cfg['deflang'] == $lang[$i]) { $chk = " selected='selected'"; } else { unset($chk); }
echo "<option value='$lang[$i]'$chk>$lang[$i]</option>";
}
?>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_POPUP;?> :</td>
<td><select name="popup" class="select" >
<?php
if ($irc_cfg['popup'] == "false") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="true"><?php echo _YES;?></option>
<option value="false"<?php echo $chk;?>><?php echo _NO;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_AUTOCONNECTION;?> :</td>
<td><select name="autoconnection" class="select" >
<?php
if ($irc_cfg['autoconnection'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="true" <?php echo $chk;?>><?php echo _YES;?></option>
<option value="false"><?php echo _NO;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_HEIGHT;?> :</td>
<td><input name="height" type="text" class="text" value="<?php echo $irc_cfg['height'];?>" size="3" /></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_WIDTH;?> :</td>
<td><input name="width" type="text" class="text" value="<?php echo $irc_cfg['width'];?>" size="3" /></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_LIST_CHANS;?> :</td>
<td><select name="showchanlist" class="select" >
<?php
if ($irc_cfg['showchanlist'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_CONNECT;?> :</td>
<td><select name="showconnect" class="select">
<?php
if ($irc_cfg['showconnect'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_STATUS;?> :</td>
<td><select name="showstatus" class="select">
<?php
if ($irc_cfg['showstatus'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_CLOSE;?> :</td>
<td><select name="showclose" class="select">
<?php
if ($irc_cfg['showclose'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_ABOUT;?> :</td>
<td><select name="showabout" class="select">
<?php
if ($irc_cfg['showabout'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_HELP;?> :</td>
<td><select name="showhelp" class="select">
<?php
if ($irc_cfg['showhelp'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_STYLESELECTOR;?> :</td>
<td><select name="styleselector" class="select">
<?php
if ($irc_cfg['styleselector'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_USEINFO;?> :</td>
<td><select name="useinfo" class="select">
<?php
if ($irc_cfg['useinfo'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_IDENTSERVER;?> :</td>
<td><select name="useidentserver" class="select">
<?php
if ($irc_cfg['useidentserver'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td colspan="2" align="center"><input type="submit" name="submit" class="button" value="<?php echo _AM_XIRC_SAVE;?>"></td>
</tr></table>
</form>
<?php
CloseTable();
xoops_cp_footer();
}
//------------------------------------------------------------------------------------------//
function save_main() {
global $_POST;
include_once("../cache/config.php");
$irc_cfg['host']           = $_POST['host'];
$irc_cfg['port']            = $_POST['port'];
$irc_cfg['alternateserver']   = $_POST['alternateserver'];
$irc_cfg['autoconnection']          = $_POST['autoconnection'];
$irc_cfg['channel']          = $_POST['channel'];
$irc_cfg['deflang']           = $_POST['deflang'];
$irc_cfg['popup']             = $_POST['popup'];
$irc_cfg['height']            = $_POST['height'];
$irc_cfg['width']             = $_POST['width'];
$irc_cfg['showchanlist']      = $_POST['showchanlist'];
$irc_cfg['useidentserver']    = $_POST['useidentserver'];
$irc_cfg['useinfo']           = $_POST['useinfo'];
$irc_cfg['styleselector']     = $_POST['styleselector'];
$irc_cfg['showhelp']          = $_POST['showhelp'];
$irc_cfg['showabout']         = $_POST['showabout'];
$irc_cfg['showclose']         = $_POST['showclose'];
$irc_cfg['showstatus']        = $_POST['showstatus'];
$irc_cfg['showconnect']       = $_POST['showconnect'];
save($irc_cfg);
}
//------------------------------------------------------------------------------------------//
function appearance() {
global $xoopsModule;
include_once(XOOPS_ROOT_PATH . "/modules/xpjirc/cache/config.php");
xoops_cp_header();
OpenTable();
?>
<form name="appearance" action="./index.php?op=save_appearance" method="post">
<table border="0" align="center">
<tr>
<td colspan="2"><hr align="center" noshade="noshade" />
<div align="center"><?php xpjirc_navig(); ?></div>
<hr align="center" noshade="noshade" /></td>
</tr><tr>
<td colspan="2" align="right"><hr align="center" noshade="noshade" />
<div align="center"><?php echo _AM_XIRC_GENERAL;?>
<hr align="center" noshade="noshade" />
</div></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_SMILEYS;?> :</td>
<td><select name="showsmileys" class="select">
<?php
if ($irc_cfg['showsmileys'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_SETFONTSTYLE;?> :</td>
<td><select name="setfontstyle" class="select">
<?php
if ($irc_cfg['setfontstyle'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_CHANNELFONT;?> :</td>
<td><input name="channelfont" type="text" class="text" value="<?php echo $irc_cfg['channelfont'];?>" size="20"> (like: Verdana 11)</td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_BGIMAGE;?> :</td>
<td><select name="bgimage" class="select">
<?php
if ($irc_cfg['bgimage'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_DEFAULTBACKGROUNDIMAGE;?> :</td>
<td><input name="bgimage1" type="text" class="text" value="<?php echo $irc_cfg['bgimage1'];?>" size="50"> (save in: sources/img)</td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_HIGHLIGHTNICK;?> :</td>
<td><select name="highlightnick" class="select">
<?php
if ($irc_cfg['highlightnick'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_HIGHLIGHT;?> :</td>
<td><select name="highlight" class="select">
<?php
if ($irc_cfg['highlight'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_SOUNDBEEP;?> :</td>
<td><input name="smileys" type="text" class="text" value="<?php echo $irc_cfg['soundbeep'];?>" size="15"> (like: bell2.au )</td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_SOUNDQUERY;?> :</td>
<td><input name="smileys" type="text" class="text" value="<?php echo $irc_cfg['soundquery'];?>" size="15"> (like: bell2.au )</td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_NICKLISTWIDTH;?> :</td>
<td><input name="nicklistwidth" type="text" class="text" value="<?php echo $irc_cfg['nicklistwidth'];?>" size="3" maxlength=3> </td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_NICKFIELD;?> :</td>
<td><select name="nickfield" class="select">
<?php
if ($irc_cfg['nickfield'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></tr><tr>
<td align="right"><?php echo _AM_XIRC_MESSAGEFIELD;?> :</td>
<td><select name="messagefield" class="select">
<?php
if ($irc_cfg['messagefield'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></tr><tr>
<td align="right"><?php echo _AM_XIRC_TIMESTAMP;?> :</td>
<td><select name="timestamp" class="select">
<?php
if ($irc_cfg['timestamp'] == "true") { $chk = " selected='selected'"; } else { unset($chk); }
?>
<option value="false"><?php echo _NO;?></option>
<option value="true"<?php echo $chk;?>><?php echo _YES;?></option>
</select></tr><tr>
<td align="right"><?php echo _AM_XIRC_HELPPAGEPATH;?> :</td>
<td><input name="helppage" type="text" class="text" value="<?php echo $irc_cfg['helppage'];?>" size="50"> ( Path to helppage )</td>
</tr><tr>
<td align="right"><?php echo _AM_XIRC_QUITMESSAGE;?> :</td>
<td><input name="quitmessage" type="text" class="text" value="<?php echo $irc_cfg['quitmessage'];?>" size="50"> </td>
</tr><tr>
<td colspan="2" align="center"><input type="submit" name="submit" class="button" value="<?php echo _AM_XIRC_SAVE;?>"></td>
</tr></table>
</form>
<?php
CloseTable();
xoops_cp_footer();
}
//------------------------------------------------------------------------------------------//
function save_appearance() {
global $_POST;
include_once("../cache/config.php");
$irc_cfg['showsmileys']        = $_POST['showsmileys'];
$irc_cfg['helppage']           = $_POST['helppage'];
$irc_cfg['messagefield']       = $_POST['messagefield'];
$irc_cfg['nickfield']          = $_POST['nickfield'];
$irc_cfg['nicklistwidth']      = $_POST['nicklistwidth'];
$irc_cfg['soundquery']         = $_POST['soundquery'];
$irc_cfg['soundbeep']          = $_POST['soundbeep'];
$irc_cfg['highlight']          = $_POST['highlight'];
$irc_cfg['highlightnick']      = $_POST['highlightnick'];
$irc_cfg['bgimage']            = $_POST['bgimage'];
$irc_cfg['bgimage1']           = $_POST['bgimage1'];
$irc_cfg['channelfont']        = $_POST['channelfont'];
$irc_cfg['setfontstyle']       = $_POST['setfontstyle'];
$irc_cfg['quitmessage']        = $_POST['quitmessage'];
$irc_cfg['timestamp']          = $_POST['timestamp'];
save($irc_cfg);
}
//------------------------------------------------------------------------------------------//
function footer() {
global $myts, $xoopsModule, $content;
include_once(XOOPS_ROOT_PATH . "/include/xoopscodes.php");
xoops_cp_header();
OpenTable();
$content = join('', file("../cache/footer.txt"));
$content = $myts->makeTareaData4PreviewInForm($content);
echo "
<form name='footer' action='./index.php?op=save_footer' method='post'>
<table border='0' align='center'>
 <tr>
  <td>
   
    <div align='center'>". xpjirc_navig() ."</div>
   
  </td>
</tr><tr><td>";
xoopsCodeTarea("content");
xoopsSmilies("content");
echo "
</td></tr><tr>
<td><input type='submit' name='submit' class='button' value='"._AM_XIRC_SAVE."'></td>
</tr></table></form>";
CloseTable();
xoops_cp_footer();
}
//------------------------------------------------------------------------------------------//
function save_footer() {
global $myts, $_POST;
$content = $myts->oopsStripSlashesGPC($_POST['content']);
$fp    = fopen("../cache/footer.txt", wb);
$write = fwrite($fp, trim($content));
fclose($fp);
if ($write > -1) {
redirect_header("index.php", 1, _AM_XIRC_CFGUPDATED);
} else {
redirect_header("index.php", 1, _AM_XIRC_CFGERROR);
}
exit();
}
//------------------------------------------------------------------------------------------//
function save($value) {
$content = "<?php\n";
foreach ($value as $key => $entry) {
$content .= "\$irc_cfg['$key'] = \"$entry\";" . "\n";
}
$content .= "?>";
$fp    = fopen("../cache/config.php", w);
$write = fwrite($fp, trim($content));
fclose($fp);
if ($write > -1) {
redirect_header("index.php", 1, _AM_XIRC_CFGUPDATED);
} else {
redirect_header("index.php", 1, _AM_XIRC_CFGERROR);
}
exit();
}
//------------------------------------------------------------------------------------------//
switch($op) {
	case "main":
		main();
		break;
	case "save_main":
		save_main();
		break;
	case "appearance":
		appearance();
		break;
	case "save_appearance":
		save_appearance();
		break;
	case "footer":
		footer();
		break;
	case "save_footer":
		save_footer();
		break;
	default:
		setupindex();
		break;
}
?>
