Kod php:
<?php
$title = 'Opcje konta';
require_once("includes/head.php");
/**
* Get the localization for game
*/
require_once("languages/".$player -> lang."/account.php");
/**
* Assign variable to template
*/
$smarty -> assign("Avatar", '');
/**
* Links
*/
if (isset($_GET['view']) && $_GET['view'] == 'links')
{
$objLinks = $db -> Execute("SELECT `id`, `file`, `text` FROM `links` WHERE `owner`=".$player -> id." ORDER BY `id` ASC");
$arrId = array(0);
$arrFile = array();
$arrText = array();
$i = 0;
while (!$objLinks -> EOF)
{
$arrId[$i] = $objLinks -> fields['id'];
$arrFile[$i] = $objLinks -> fields['file'];
$arrText[$i] = $objLinks -> fields['text'];
$i ++;
$objLinks -> MoveNext();
}
$objLinks -> Close();
if (!isset($_GET['lid']))
{
$strFormaction = A_ADD;
$intLinkid = 0;
}
else
{
if (!ereg("^[0-9]*$", $_GET['lid']))
{
error(ERROR);
}
if ($_GET['lid'] == 0)
{
$strFormaction = A_ADD;
}
else
{
$strFormaction = A_EDIT;
}
$intLinkid = $_GET['lid'];
}
$smarty -> assign(array("Linksinfo" => LINKS_INFO,
"Tfile" => T_FILE,
"Tname" => T_NAME,
"Tactions" => T_ACTIONS,
"Adelete" => A_DELETE,
"Aedit" => A_EDIT,
"Aform" => $strFormaction,
"Linksid" => $arrId,
"Linksfile" => $arrFile,
"Linkstext" => $arrText,
"Linkid" => $intLinkid,
"Linkfile" => '',
"Linkname" => ''));
/**
* Add/edit links
*/
if (isset($_GET['step']) && $_GET['step'] == 'edit')
{
if (!isset($_GET['action']) && $_GET['lid'] > 0)
{
$objLink = $db -> Execute("SELECT `id`, `file`, `text` FROM `links` WHERE `id`=".$_GET['lid']." AND `owner`=".$player -> id);
if (!$objLink -> fields['id'])
{
error(NOT_YOUR);
}
$smarty -> assign(array("Linkfile" => $objLink -> fields['file'],
"Linkname" => $objLink -> fields['text']));
$objLink -> Close();
}
if (isset($_GET['action']) && $_GET['action'] == 'change')
{
$strFile = strip_tags($_POST['linkadress']);
$strText = strip_tags($_POST['linkname']);
if (empty($strFile) || empty($strText))
{
error(EMPTY_FIELDS);
}
$arrForbidden = array('config.php', 'session.php', 'reset.php', 'resets.php', 'quest', 'portal');
foreach ($arrForbidden as $strForbidden)
{
$intPos = strpos($strFile, $strForbidden);
if ($intPos !== false)
{
error(ERROR);
}
}
if ($_GET['lid'] > 0)
{
$db -> Execute("UPDATE `links` SET `file`='".$strFile."', `text`='".$strText."' WHERE `id`=".$_GET['lid']." AND `owner`=".$player -> id);
$strMessage = YOU_CHANGE;
}
else
{
$db -> Execute("INSERT INTO `links` (`owner`, `file`, `text`) VALUES(".$player -> id.", '".$strFile."', '".$strText."')");
$strMessage = YOU_ADD;
}
error($strMessage);
}
}
/**
* Delete links
*/
if (isset($_GET['step']) && $_GET['step'] == 'delete')
{
$objLink = $db -> Execute("SELECT `id` FROM `links` WHERE `id`=".$_GET['lid']." AND `owner`=".$player -> id);
if (!$objLink -> fields['id'])
{
error(NOT_YOUR);
}
$objLink -> Close();
$db -> Execute("DELETE FROM `links` WHERE `id`=".$_GET['lid']." AND `owner`=".$player -> id);
error(LINK_DELETED);
}
}
/**
* Bugtrack
*/
if (isset($_GET['view']) && $_GET['view'] == 'bugtrack')
{
$objBugs = $db -> Execute("SELECT `id`, `title`, `type`, `location` FROM `bugreport` WHERE `resolution`=0 ORDER BY `id` ASC");
$arrId = array();
$arrTitle = array();
$arrType = array();
$arrLocation = array();
$i = 0;
while (!$objBugs -> EOF)
{
$arrId[$i] = $objBugs -> fields['id'];
$arrTitle[$i] = $objBugs -> fields['title'];
$arrLocation[$i] = $objBugs -> fields['location'];
if ($objBugs -> fields['type'] == 'text')
{
$arrType[$i] = BUG_TEXT;
}
else
{
$arrType[$i] = BUG_CODE;
}
$i++;
$objBugs -> MoveNext();
}
$objBugs -> Close();
$smarty -> assign(array("Bugtype" => BUG_TYPE,
"Bugloc" => BUG_LOC,
"Bugid" => BUG_ID,
"Bugname" => BUG_NAME,
"Bugtrackinfo" => BUGTRACK_INFO,
"Bugstype" => $arrType,
"Bugsloc" => $arrLocation,
"Bugsid" => $arrId,
"Bugsname" => $arrTitle));
}
/**
* Bug report
*/
if (isset($_GET['view']) && $_GET['view'] == 'bugreport')
{
$smarty -> assign(array("Bugtype" => BUG_TYPE,
"Bugtext" => BUG_TEXT,
"Bugcode" => BUG_CODE,
"Bugloc" => BUG_LOC,
"Bugdesc" => BUG_DESC,
"Areport" => A_REPORT,
"Bugname" => BUG_NAME,
"Buginfo" => BUG_INFO));
/**
* Report bug
*/
if (isset($_GET['step']) && $_GET['step'] == 'report')
{
$arrFields = array($_POST['bugtitle'], $_POST['type'], $_POST['location'], $_POST['desc']);
require_once('includes/bbcode.php');
foreach ($arrFields as $strField)
{
$strField = strip_tags($strField);
$strField = bbcodetohtml($strField);
if (!ereg("[[:graph:]]", $strField))
{
error(EMPTY_FIELDS);
}
}
if (!in_array($arrFields[1], array('text', 'code')))
{
error(ERROR);
}
$intDesc = strlen($arrFields[3]);
if ($intDesc < 100)
{
error(TOO_SHORT);
}
$db -> Execute("INSERT INTO `bugreport` (`sender`, `title`, `type`, `location`, `desc`) VALUES(".$player -> id.", '".$arrFields[0]."', '".$arrFields[1]."', '".$arrFields[2]."', '".$arrFields[3]."')");
error(B_REPORTED);
}
}
/**
* Select game localization
*/
if (isset ($_GET['view']) && $_GET['view'] == "lang")
{
/**
* Check avaible languages
*/
$path = 'languages/';
$dir = opendir($path);
$arrLanguage = array();
$i = 0;
while ($file = readdir($dir))
{
if (!ereg(".htm*$", $file))
{
if (!ereg("\.$", $file))
{
$arrLanguage[$i] = $file;
$i = $i + 1;
}
}
}
closedir($dir);
/**
* Show select menu
*/
$smarty -> assign(array("Langinfo" => LANG_INFO,
"Flang" => F_LANG,
"Slang" => S_LANG,
"Aselect" => A_SELECT,
"Lang" => $arrLanguage));
/**
* Write selected information to database
*/
if (isset ($_GET['step']) && $_GET['step'] == 'lang')
{
if (!isset($_POST['mainlang']) || !isset($_POST['seclang']))
{
error(EMPTY_FIELDS);
}
if (!in_array($_POST['mainlang'], $arrLanguage) || !in_array($_POST['seclang'], $arrLanguage))
{
error(ERROR);
}
$db -> Execute("UPDATE players SET lang='".$_POST['mainlang']."' WHERE id=".$player -> id);
$strMessage = YOU_SELECT.$_POST['mainlang'];
if ($_POST['seclang'] != $_POST['mainlang'] || isset($player -> seclang))
{
$db -> Execute("UPDATE players SET seclang='".$_POST['seclang']."' WHERE id=".$player -> id);
$strMessage = $strMessage.AND_SECOND.$_POST['seclang'];
}
$strMessage = $strMessage." <a href=\"account.php\">".A_REFRESH."</a>";
$smarty -> assign("Message", $strMessage);
}
}
Zakładki