Seditio ve Ldu hakkında sınırsız arama yapın
 
 
> 1 <

Etiketler: kral tacı hata

Author Message

B5L5XIS

Members


Online status

54 posts
http://www.hack-ordusu.ch
Pagerank: 0

Location: Turkey
Occupation: www.hack-ordusu.ch
Age:

#39941   2008-09-27 08:23 GMT      

kral tacını site upload yaptım sonra şu kodu functions.php kaydettim

Code:
elseif ($row['gru_groupid']==5)
{
$result = "<img src='/icon-crown-orange.gif'><a href=\"users.php?m=details&amp;id=".$id."\"><font style=\"color:#renk;\">".$result."</font></a>";
}


sonra şu hata verdi resim:

http://b4l4xis.googlepages.com/gdg.jpg/gdg-full.jpg
www.hack-ordusu.ch//www.saldiri.net

Mr.DaRKWoRLD

Bilgili Üye


Online status

176 posts
http://www.adanahack.ch/
Pagerank: 0

Location: Turkey ADana
Occupation: WeB MaSTeR
Age: 115

#39942   2008-09-27 09:01 GMT      
bak ftpne img die bir dosya olustur img/kral.gif olarak at daha sonra

Code:
elseif ($row['gru_groupid']==5)
{
$result = "<img src='siten/img/kral.gif><a href=\"users.php?m=details&amp;id=".$id."\"><font style=\"color:#renk;\">".$result."</font></a>";
}


düzelir ;)
DemonStyle.Ch Tıkla

Mr.DaRKWoRLD

Bilgili Üye


Online status

176 posts
http://www.adanahack.ch/
Pagerank: 0

Location: Turkey ADana
Occupation: WeB MaSTeR
Age: 115

#39943   2008-09-27 09:09 GMT      

bende functions var kendine göre editleye bilirsin

Code:
<?PHP

/* ====================
Seditio - Website engine
Copyright Neocrome
http://www.neocrome.net
[BEGIN_SED]
File=system/functions.php
Version=121
Updated=2007-oct-11
Type=Core
Author=Neocrome
Description=Functions
[END_SED]
==================== */

if (!defined('SED_CODE')) { die('Wrong URL.'); }

$cfg = array();
$out = array();
$plu = array();
$sys = array();
$usr = array();

/* ======== Pre-sets ========= */

$i = explode(' ', microtime());
$sys['starttime'] = $i[1] + $i[0];

unset ($warnings, $moremetas, $morejavascript, $error_string,  $sed_cat, $sed_smilies, $sed_acc, $sed_catacc, $sed_rights, $sed_config, $sql_config, $sed_usersonline, $sed_plugins, $sed_groups, $rsedition, $rseditiop, $rseditios, $tcount, $qcount);

$cfg['authmode'] = 3; // (1:cookies, 2:sessions, 3:cookies+sessions)
$cfg['xmlclient'] = FALSE; // For testing-purposes only, else keep it off
$cfg['enablecustomhf'] = FALSE; // To enable header.$location.tpl and footer.$location.tpl
$cfg['pfs_dir'] = 'datas/users/';
$cfg['av_dir'] = 'datas/avatars/';
$cfg['photos_dir'] = 'datas/photos/';
$cfg['sig_dir'] = 'datas/signatures/';
$cfg['defav_dir'] = 'datas/defaultav/';
$cfg['th_dir'] = 'datas/thumbs/';
$cfg['pfsmaxuploads'] = 8;
$cfg['version'] = '121';
$cfg['sqldb'] = 'mysql';

/* ======== Names of the SQL tables ========= */

$sed_dbnames = array ('auth', 'auth_default', 'banlist', 'cache', 'com', 'core', 'config', 'forum_sections', 'forum_structure', 'forum_topics', 'forum_posts', 'groups', 'groups_users', 'logger', 'online', 'pages', 'pfs', 'pfs_folders', 'plugins', 'pm', 'polls_options', 'polls', 'polls_voters', 'rated', 'ratings', 'referers', 'smilies', 'stats', 'structure', 'trash', 'users');

foreach($sed_dbnames as $k => $i)
{
$j = 'db_'.$i;
$$j = 'sed_'.$i;
}

/* ================== Replacements for PHP5-only functions ================== */

if (!function_exists('str_split'))
{
function str_split($txt, $length=1)
{
if ($length<1)
{ return(FALSE); }
$res = array();
for ($i=0; $i<strlen($txt); $i+=$length)
{ $res[] = substr($txt, $i, $length); }
return($res);
}
}

/* ------------------ */

function sed_alphaonly($text)
{
return(preg_replace('/[^a-zA-Z0-9_]/', '', $text));
}

/* ------------------ */

function sed_auth($area, $option, $mask='RWA')
{
global $sys, $usr;

$mn['R'] = 1;
$mn['W'] = 2;
$mn['1'] = 4;
$mn['2'] = 8;
$mn['3'] = 16;
$mn['4'] = 32;
$mn['5'] = 64;
$mn['A'] = 128;

$masks = str_split($mask);
$res = array();

foreach($masks as $k => $ml)
{
if(empty($mn[$ml]))
{
$sys['auth_log'][] = $area.".".$option.".".$ml."=0";
$res[] = FALSE;
}
elseif ($option=='any')
{
$cnt = 0;

if (is_array($usr['auth'][$area]))
{
foreach($usr['auth'][$area] as $k => $g)
{ $cnt += (($g & $mn[$ml]) == $mn[$ml]); }
}
$cnt = ($cnt==0 && $usr['auth']['admin']['a'] && $ml=='A') ? 1 : $cnt;

$sys['auth_log'][] = ($cnt>0) ? $area.".".$option.".".$ml."=1" : $area.".".$option.".".$ml."=0";
$res[] = ($cnt>0) ? TRUE : FALSE;
}
else
{
$sys['auth_log'][] = (($usr['auth'][$area][$option] & $mn[$ml]) == $mn[$ml]) ? $area.".".$option.".".$ml."=1" : $area.".".$option.".".$ml."=0";
$res[] = (($usr['auth'][$area][$option] & $mn[$ml]) == $mn[$ml]) ? TRUE : FALSE;
}
}
if (count($res)==1)
{ return ($res[0]); }
   else
{ return($res); }
}

/* ------------------ */

function sed_auth_build($userid, $maingrp=0)
{
global $db_auth, $db_groups_users;

$groups = array();
$authgrid = array();
$tmpgrid = array();

if ($userid==0 || $maingrp==0)
{
$groups[] = 1;
}
else
{
$groups[] = $maingrp;
$sql = sed_sql_query("SELECT gru_groupid FROM $db_groups_users WHERE gru_userid='$userid'");

while ($row = sed_sql_fetcharray($sql))
   { $groups[] = $row['gru_groupid']; }
}

    $sql_groups = implode(',', $groups);
$sql = sed_sql_query("SELECT auth_code, auth_option, auth_rights FROM $db_auth WHERE auth_groupid IN (".$sql_groups.") ORDER BY auth_code ASC, auth_option ASC");

while ($row = sed_sql_fetcharray($sql))
    { $authgrid[$row['auth_code']][$row['auth_option']] |= $row['auth_rights']; }

    return($authgrid);
}

/* ------------------ */

function sed_auth_clear($id='all')
{
global $db_users;

if($id=='all')
{ $sql = sed_sql_query("UPDATE $db_users SET user_auth='' WHERE 1"); }
else
{ $sql = sed_sql_query("UPDATE $db_users SET user_auth='' WHERE user_id='$id'"); }
return( sed_sql_affectedrows());
}

/* ------------------ */

function sed_bbcode($text)
{
global $L, $skin, $sys, $cfg, $sed_groups;

$text = sed_bbcode_autourls($text);
$text = " ".$text;

$bbcodes = array(
'$' => '$',
'[b]' => '<strong>',
'[/b]' => '</strong>',
'[p]' => '<p>',
'[/p]' => '</p>',
'[u]' => '<u>',
'[/u]' => '</u>',
'[i]' => '<em>',
'[/i]' => '</em>',
'[hr]' => '<hr />',
'[_]' => '&nbsp;',
'[__]' => '&nbsp; &nbsp;',
'[list]' => '<ul type="square">',
'[/list]' => '</ul>',
'[red]' => '<span style="color:#F93737">',
'[/red]' => '</span>',
'[white]' => '<span style="color:#FFFFFF">',
'[/white]' => '</span>',
'[green]' => '<span style="color:#09DD09">',
'[/green]' => '</span>',
'[blue]' => '<span style="color:#018BFF">',
'[/blue]' => '</span>',
'[orange]' => '<span style="color:#FF9900">',
'[/orange]' => '</span>',
'[yellow]' => '<span style="color:#FFFF00">',
'[/yellow]' => '</span>',
'[purple]' => '<span style="color:#A22ADA">',
'[/purple]' => '</span>',
'[black]' => '<span style="color:#000000">',
'[/black]' => '</span>',
'[grey]' => '<span style="color:#B9B9B9">',
'[/grey]' => '</span>',
'[pink]' => '<span style="color:#FFC0FF">',
'[/pink]' => '</span>',
'[sky]' => '<span style="color:#D1F4F9">',
'[/sky]' => '</span>',
'[sea]' => '<span style="color:#171A97">',
'[/sea]' => '</span>',
'[quote]' => '<blockquote>'.$L['bbcodes_quote'].'<hr />',
'[/quote]' => '<hr /></blockquote>',
'[br]' => '<br />',
'[more]' => ''
);

foreach($bbcodes as $bbcode => $bbcodehtml)
{ $text = str_replace($bbcode,$bbcodehtml,$text); }

$bbcodes = array(
'\\[img\\]([^\\\'\;\?([]*)\.(jpg|jpeg|gif|png)\\[/img\\]' => '<img src="\\1.\\2" alt="" />',
'\\[img=([^\\\'\;\?([]*)\.(jpg|jpeg|gif|png)\\]([^\\[]*)\.(jpg|jpeg|gif|png)\\[/img\\]' => '<a href="\\1.\\2"><img src="\\3.\\4" alt="" /></a>',
'\\[thumb=([^\\\'\;\?([]*)\.(jpg|jpeg|gif|png)\\]([^\\[]*)\.(jpg|jpeg|gif|png)\\[/thumb\\]' => ' <a href="pfs.php?m=view&amp;v=\\3.\\4"><img src="\\1.\\2" alt="" /></a>',
'\\[pfs]([^\\[]*)\\[/pfs\\]' => '<a href="'.$cfg['pfs_dir'].'\\1"><img src="system/img/admin/pfs.gif" alt="" /> \\1</a>',
'\\[t=([^\\\'\;\?([]*)\.(jpg|jpeg|gif|png)\\]([^\\[]*)\.(jpg|jpeg|gif|png)\\[/t\\]' => '<a href="\\3.\\4"><img src="\\1.\\2" alt="" /></a>',
'\\[url=([^\\\'\;([]*)\\]([^\\[]*)\\[/url\\]' => '<a href="\\1">\\2</a>',
'\\[url\\]([^\\([]*)\\[/url\\]' => '<a href="\\1">\\1</a>',
'\\[color=([0-9A-F]{6})\\]([^\\[]*)\\[/color\\]' => '<span style="color:#\\1">\\2</span>',
'\\[style=([1-9]{1})\\]([^\\[]*)\\[/style\\]' => '<span class="bbstyle\\1">\\2</span>',
'\\[email=([._A-z0-9-]+@[A-z0-9-]+\.[.a-z]+)\\]([^\\[]*)\\[/email\\]' => '<a href="mailto:\\1">\\2</a>',
'\\[email\\]([._A-z0-9-]+@[A-z0-9-]+\.[.a-z]+)\\[/email\\]' => '<a href="mailto:\\1">\\1</a>',
'\\[user=([0-9]+)\\]([A-z0-9_\. -]+)\\[/user\\]' => '<a href="users.php?m=details&amp;id=\\1">\\2</a>',
'\\[page=([0-9]+)\\]([^\\[]*)\\[/page\\]' => '<a href="page.php?id=\\1">\\2</a>',
'\\[page\\]([0-9]+)\\[/page\\]' => '<a href="page.php?id=\\1">'.$L['Page'].' #\\1</a>',
'\\[group=([0-9]+)\\]([^\\([]*)\\[/group\\]' => '<a href="users.php?g=\\1">\\2</a>',
'\\[topic\\]([0-9]+)\\[/topic\\]' => '<a href="forums.php?m=posts&amp;q=\\1">'.$L['Topic'].' #\\1</a>',
'\\[post\\]([0-9]+)\\[/post\\]' => '<a href="forums.php?m=posts&amp;p=\\1#\\1">'.$L['Post'].' #\\1</a>',
'\\[pm\\]([0-9]+)\\[/pm\\]' => '<a href="pm.php?m=send&amp;to=\\1"><img src="skins/'.$skin.'/img/system/icon-pm.gif" alt=""></a>',
'\\[f\\]([a-z][a-z])\\[/f\\]' => '<a href="users.php?f=country_\\1"><img src="system/img/flags/f-\\1.gif" alt="" /></a>',
'\\[ac=([^\\[]*)\\]([^\\[]*)\\[/ac\\]' => '<acronym title="\\1">\\2</acronym>',
'\\[del\\]([^\\[]*)\\[/del\\]' => '<del>\\1</del>',
'\\[quote=([^\\[]*)\\]' => '<blockquote>\\1<hr />',
'\\[spoiler\\]' => '<div style="margin:0; margin-top:8px"><div style="margin-bottom:4px"><input type="button" value="'.$L['Show'].'" onClick="if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'\'; this.innerText = \'\'; this.value = \''.$L['Hide'].'\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'none\'; this.innerText = \'\'; this.value = \''.$L['Show'].'\'; }"></div><div class="spoiler"><div style="display: none;">',
'\\[spoiler=([A-z0-9_\. -]+)\\]' => '<div style="margin:0; margin-top:8px"><div style="margin-bottom:4px"><input type="button" value="'.$L['Show'].':\\1" onClick="if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'\'; this.innerText = \'\'; this.value = \''.$L['Hide'].':\\1\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'none\'; this.innerText = \'\'; this.value = \''.$L['Show'].':\\1\'; }"></div><div class="spoiler"><div style="display: none;">',

'\\[/spoiler\\]' => '</div></div></div>');

foreach($bbcodes as $bbcode => $bbcodehtml)
{ $text = eregi_replace($bbcode,$bbcodehtml,$text); }

if ($cfg['parser_vid'])
{
$bbcodes = array(
'\\[youtube=([^\\[]*)\\]' => '<object width="425" height="350">
<param name="movie" value="http://www.youtube.com/v/\\1"></param>
<embed src="http://www.youtube.com/v/\\1" type="application/x-shockwave-flash" width="425" height="350"></embed>
</object>',
'\\[googlevideo=([^\\[]*)\\]' => '<embed style="width:425px; height:326px;" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=\\1&hl=en-GB"> </embed>',
'\\[metacafe=([^\\[]*)\\]' => '<embed style="width:425px; height:345px;" src="http://www.metacafe.com/fplayer/\\1" width="400" height="345" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>');

foreach($bbcodes as $bbcode => $bbcodehtml)
{ $text = eregi_replace($bbcode,$bbcodehtml,$text); }
}

$bbcodes = array(
'\\[colleft\\]([^\\[]*)\\[/colleft\\]' => '<div class="colleft">\\1</div>',
'\\[colright\\]([^\\[]*)\\[/colright\\]' => '<div class="colright">\\1</div>',
'\\[center\\]([^\\[]*)\\[/center\\]' => '<div style="text-align:center;">\\1</div>',
'\\[right\\]([^\\[]*)\\[/right\\]' => '<div style="text-align:right;">\\1</div>',
'\\[left\\]([^\\[]*)\\[/left\\]' => '<div style="text-align:left;">\\1</div>',
'\\[c1\\:([^\\[]*)\\]([^\\[]*)\\[c2\\:([^\\[]*)\\]([^\\[]*)\\[c3\\]' => '<table style="margin:0; vertical-align:top; width:100%;"><tr><td style="padding:8px; vertical-align:top; width:\\1%;">\\2</td><td  style="padding:8px; vertical-align:top; width:\\3%;">\\4</td></tr></table>'
);

foreach($bbcodes as $bbcode => $bbcodehtml)
{ $text = eregi_replace($bbcode,$bbcodehtml,$text); }

return(substr($text,1));
}

/* ------------------ */

function sed_bbcode_autourls($text)
{
$text = ' '.$text;
$text = preg_replace("#([\n ])([a-z0-9]+?)://([^\t \n\r]+)#i", "\\1[url]\\2://\\3[/url]", $text);
$text = preg_replace("#([\n ])([a-z0-9-_.]+?@[A-z0-9-]+\.[^,\t \n\r]+)#i", "\\1[email]\\2[/email]", $text);
return(substr($text,1));
}

/* ------------------ */

function sed_bbcode_urls($text)
{
global $cfg;
$bbcodes = array(
'\\[img\\]([^\\\'\;\?([]*)\.(jpg|jpeg|gif|png)\\[/img\\]' => '\\1.\\2',
'\\[thumb=([^\\\'\;\?([]*)\.(jpg|jpeg|gif|png)\\]([^\\[]*)\.(jpg|jpeg|gif|png)\\[/thumb\\]' => '\\1.\\2',
'\\[pfs]([^\\[]*)\\[/pfs\\]' => $cfg['pfs_dir'].'\\1',
);

foreach($bbcodes as $bbcode => $bbcodehtml)
{ $text = eregi_replace($bbcode,$bbcodehtml,$text); }

return($text);
}

/* ------------------ */

function sed_block($allowed)
{
if (!$allowed)
{
global $sys;
header("Location: message.php?msg=930&".$sys['url_redirect']);
exit;
}
return(FALSE);
}


/* ------------------ */

function sed_blockguests()
{
global $usr, $sys;

if ($usr['id']<1)
{
header("Location: message.php?msg=930&".$sys['url_redirect']);
exit;
}
return(FALSE);
}

/* ------------------ */

function sed_build_addtxt($c1, $c2)
{
$result = "
function addtxt(text)
{
document.".$c1.".".$c2.".value  += text;
document.".$c1.".".$c2.".focus();
}
";
return($result);
}

/* ------------------ */

function sed_build_age($birth)
{
global $sys;

if ($birth==1)
{ return ('?'); }

$day1 = @date('d', $birth);
$month1 = @date('m', $birth);
$year1 = @date('Y', $birth);

$day2 = @date('d', $sys['now_offset']);
$month2 = @date('m', $sys['now_offset']);
$year2 = @date('Y', $sys['now_offset']);

  $age = ($year2-$year1)-1;

if ($month1<$month2 || ($month1==$month2 && $day1<=$day2))
{ $age++; }

if($age < 0)
{ $age += 136; }

return ($age);
}

/* ------------------ */

function sed_build_bbcodes($c1, $c2, $title)
{
$result = "<a href=\"javascript:help('bbcodes','".$c1."','".$c2."')\">".$title."</a>";
return($result);
}

/* ------------------ */

function sed_build_bbcodes_local($limit)
{
global $sed_bbcodes;

reset ($sed_bbcodes);

$result = '<div class="bbcodes">';

while (list($i,$dat)=each($sed_bbcodes))
{
$kk = 'bbcodes_'.$dat[1];
$result .= "<a href=\"javascript:addtxt('".$dat[0]."')\"><img src=\"system/img/bbcodes/".$dat[1].".gif\" alt=\"\" /></a> ";
}

$result .= "</div>";
return($result);
}

/* ------------------ */

function sed_build_catpath($cat, $mask)
{
global $sed_cat, $cfg;

$pathcodes = explode('.', $sed_cat[$cat]['path']);
foreach($pathcodes as $k => $x)
{ $tmp[]= sprintf($mask, $x, $sed_cat[$x]['title']); }
$result = implode(' '.$cfg['separator'].' ', $tmp);
return ($result);
}

/* ------------------ */

function sed_build_comments($code, $url, $display)
{
global $db_com, $db_users, $cfg, $usr, $L, $sys;

list($usr['auth_read_com'], $usr['auth_write_com'], $usr['isadmin_com']) = sed_auth('comments', 'a');

if ($cfg['disable_comments'] || !$usr['auth_read_com'])
{ return(array('', '', ''));  }

if ($display)
{
$ina = sed_import('ina','G','ALP');
$ind = sed_import('ind','G','INT');

if ($ina=='send' && $usr['auth_write_com'])
{
sed_shield_protect();
$rtext = sed_import('rtext','P','HTM');

/* == Hook for the plugins == */
$extp = sed_getextplugins('comments.send.first');
if (is_array($extp))
{ foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */

$error_string .= (strlen($rtext)<2) ? $L['com_commenttooshort']."<br />" : '';
$error_string .= (strlen($rtext)>2000) ? $L['com_commenttoolong']."<br />" : '';

if (empty($error_string))
{
$sql = sed_sql_query("INSERT INTO $db_com (com_code, com_author, com_authorid, com_authorip, com_text, com_date) VALUES ('".sed_sql_prep($code)."', '".sed_sql_prep($usr['name'])."', ".(int)$usr['id'].", '".$usr['ip']."', '".sed_sql_prep($rtext)."', ".(int)$sys['now_offset'].")");

/* == Hook for the plugins == */
$extp = sed_getextplugins('comments.send.new');
if (is_array($extp))
{ foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */

sed_shield_update(20, "New comment");
header("Location: $url&comments=1");
exit;
}
}

if ($ina=='delete' && $usr['isadmin_com'])
{
sed_check_xg();
$sql = sed_sql_query("SELECT * FROM $db_com WHERE com_id='$ind' LIMIT 1");

if ($row = sed_sql_fetchassoc($sql))
{
if ($cfg['trash_comment'])
{ sed_trash_put('comment', $L['Comment']." #".$ind." (".$row['com_author'].")", $ind, $row); }
$sql = sed_sql_query("DELETE FROM $db_com WHERE com_id='$ind'");
sed_log("Deleted comment #".$ind." in '".$code."'",'adm');
}

header("Location: ".$url."&comments=1");
exit;
}

$error_string .= ($ina=='added') ? $L['com_commentadded']."<br />" : '';

$t = new XTemplate(sed_skinfile('comments'));

/* == Hook for the plugins == */
$extp = sed_getextplugins('comments.main');
if (is_array($extp))
{ foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */

$sql = sed_sql_query("SELECT c.*, u.user_avatar FROM $db_com AS c
LEFT JOIN $db_users AS u ON u.user_id=c.com_authorid
WHERE com_code='$code' ORDER BY com_id ASC");

if (!empty($error_string))
{
$t->assign("COMMENTS_ERROR_BODY",$error_string);
$t->parse("COMMENTS.COMMENTS_ERROR");
}

if ($usr['auth_write_com'])
{
$bbcodes = ($cfg['parsebbcodecom']) ? sed_build_bbcodes("newcomment", "rtext", $L['BBcodes']) : '';
$smilies = ($cfg['parsesmiliescom']) ? sed_build_smilies("newcomment", "rtext", $L['Smilies']) : '';
$pfs = ($usr['id']>0) ? sed_build_pfs($usr['id'], "newcomment", "rtext", $L['Mypfs']) : '';
$pfs .= (sed_auth('pfs', 'a', 'A')) ? " &nbsp; ".sed_build_pfs(0, "newcomment", "rtext", $L['SFS']) : '';
$post_main = "<textarea name=\"rtext\" rows=\"4\" cols=\"40\">".$rtext."</textarea><br />".$bbcodes." ".$smilies." ".$pfs;
}

$t->assign(array(
"COMMENTS_CODE" => $code,
"COMMENTS_FORM_SEND" => $url."&amp;comments=1&amp;ina=send",
"COMMENTS_FORM_AUTHOR" => $usr['name'],
"COMMENTS_FORM_AUTHORID" => $usr['id'],
"COMMENTS_FORM_TEXT" => $post_main,
"COMMENTS_FORM_TEXTBOXER" => $post_main,
"COMMENTS_FORM_BBCODES" => $bbcodes,
"COMMENTS_FORM_SMILIES" => $smilies,
"COMMENTS_FORM_MYPFS" => $pfs
));

if ($usr['auth_write_com'])
{

/* == Hook for the plugins == */
$extp = sed_getextplugins('comments.newcomment.tags');
if (is_array($extp))
{ foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */

$t->parse("COMMENTS.COMMENTS_NEWCOMMENT");
}

if (sed_sql_numrows($sql)>0)
{
$i = 0;

/* === Hook - Part1 : Set === */
$extp = sed_getextplugins('comments.loop');
/* ===== */

while ($row = sed_sql_fetcharray($sql))
{
$i++;
$com_author = sed_cc($row['com_author']);
$com_text = sed_cc($row['com_text']);

$com_admin = ($usr['isadmin_com']) ? $L['Ip'].":".sed_build_ipsearch($row['com_authorip'])." &nbsp;".$L['Delete'].":[<a href=\"".$url."&amp;comments=1&amp;ina=delete&amp;ind=".$row['com_id']."&amp;".sed_xg()."\">x</a>]" : '' ;
$com_authorlink = ($row['com_authorid']>0) ? "<a href=\"users.php?m=details&amp;id=".$row['com_authorid']."\">".$com_author."</a>" : $com_author ;

$t-> assign(array(
"COMMENTS_ROW_ID" => $row['com_id'],
"COMMENTS_ROW_ORDER" => $i,
"COMMENTS_ROW_URL" => $url."&amp;comments=1#c".$row['com_id'],
"COMMENTS_ROW_AUTHOR" => $com_authorlink,
"COMMENTS_ROW_AUTHORID" => $row['com_authorid'],
"COMMENTS_ROW_AVATAR" => sed_build_userimage($row['user_avatar']),
"COMMENTS_ROW_TEXT" => sed_parse($com_text, $cfg['parsebbcodecom'], $cfg['parsesmiliescom'], 1),
"COMMENTS_ROW_DATE" => @date($cfg['dateformat'], $row['com_date'] + $usr['timezone'] * 3600),
"COMMENTS_ROW_ADMIN" => $com_admin,
));

/* === Hook - Part2 : Include === */
if (is_array($extp))
{ foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */

$t->parse("COMMENTS.COMMENTS_ROW");
}
}
else
{
$t-> assign(array(
"COMMENTS_EMPTYTEXT" => $L['com_nocommentsyet'],
));
$t->parse("COMMENTS.COMMENTS_EMPTY");
}

/* == Hook for the plugins == */
$extp = sed_getextplugins('comments.tags');
if (is_array($extp))
{ foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */

$t->parse("COMMENTS");
$res_display = $t->text("COMMENTS");
}
else
{
$res_display = '';
}

$res = "<a href=\"".$url."&amp;comments=1\"><img src=\"skins/".$usr['skin']."/img/system/icon-comment.gif\" alt=\"\" />";

if ($cfg['countcomments'])
{
$nbcomment = sed_sql_result(sed_sql_query("SELECT COUNT(*) FROM $db_com where com_code='$code'"), 0, "COUNT(*)");
$res .= " (".$nbcomment.")";
}
$res .= "</a>";

return(array($res, $res_display, $nbcomment));
}

/* ------------------ */

function sed_build_country($flag)
{
global $sed_countries;

$flag = (empty($flag)) ? '00' : $flag;
$result = '<a href="users.php?f=country_'.$flag.'">'.$sed_countries[$flag].'</a>';
return($result);
}

/* ------------------ */

function sed_build_email($email, $hide=0)
{
global $L;
if ($hide)
{ $result = $L['Hidden']; }
elseif (!empty($email) && eregi('@', $email))
{
$email = sed_cc($email);
$result = "<a href=\"mailto:".$email."\">".$email."</a>";
}

return($result);
}

/* ------------------ */

function sed_build_flag($flag)
{
$flag = (empty($flag)) ? '00' : $flag;
$result = '<a href="users.php?f=country_'.$flag.'"><img src="system/img/flags/f-'.$flag.'.gif" alt="" /></a>';
return($result);
}

/* ------------------ */

function sed_build_forums($sectionid, $title, $category, $link=TRUE)
{
global $sed_forums_str, $cfg;

$pathcodes = explode('.', $sed_forums_str[$category]['path']);

if ($link)
{
foreach($pathcodes as $k => $x)
{ $tmp[]= "<a href=\"forums.php?c=$x#$x\">".sed_cc($sed_forums_str[$x]['title'])."</a>"; }
$tmp[]= "<a href=\"forums.php?m=topics&amp;s=$sectionid\">".sed_cc($title)."</a>";
}
else
{
foreach($pathcodes as $k => $x)
{ $tmp[]= sed_cc($sed_forums_str[$x]['title']); }
$tmp[]= sed_cc($title);
}

$result = implode(' '.$cfg['separator'].' ', $tmp);

return($result);
}


/* ------------------ */

function sed_build_gallery($id, $c1, $c2, $title)
{
return("<a href=\"javascript:gallery('".$id."','".$c1."','".$c2."')\">".$title."</a>");
}

/* ------------------ */

function sed_build_group($grpid)
{
global $sed_groups, $L;

if (empty($grpid))
{ $res = ''; }
else
{
if ($sed_groups[$grpid]['hidden'])
{
if (sed_auth('users', 'a', 'A'))
{ $res = "<a href=\"users.php?gm=".$grpid."\">".$sed_groups[$grpid]['title']."</a> (".$L['Hidden'].')'; }
else
{ $res = $L['Hidden']; }
}
else
{ $res = "<a href=\"users.php?gm=".$grpid."\">".$sed_groups[$grpid]['title']."</a>"; }
}
return($res);

}

/* ------------------ */

function sed_build_groupsms($userid, $edit=FALSE, $maingrp=0)
{
global $db_groups_users, $sed_groups, $L;

$sql = sed_sql_query("SELECT gru_groupid FROM $db_groups_users WHERE gru_userid='$userid'");

while ($row = sed_sql_fetcharray($sql))
{ $member[$row['gru_groupid']] = TRUE; }

foreach($sed_groups as $k => $i)
{
$checked = ($member[$k]) ? "checked=\"checked\"" : '';
$checked_maingrp = ($maingrp==$k) ? "checked=\"checked\"" : '';
$readonly = (!$edit || $k==1 || $k==2 || $k==3 || ($k==5 && $userid==1)) ? "disabled=\"disabled\"" : '';
$readonly_maingrp = (!$edit || $k==1 || ($k==2 && $userid==1) || ($k==3 && $userid==1)) ? "disabled=\"disabled\"" : '';

if ($member[$k] || $edit)
{
if (!($sed_groups[$k]['hidden'] && !sed_auth('users', 'a', 'A')))
{
$res .= "<input type=\"radio\" class=\"radio\" name=\"rusermaingrp\" value=\"$k\" ".$checked_maingrp." ".$readonly_maingrp." /> \n";
$res .= "<input type=\"checkbox\" class=\"checkbox\" name=\"rusergroupsms[$k]\" ".$checked." $readonly />\n";
$res .= ($k==1) ? $sed_groups[$k]['title'] : "<a href=\"users.php?g=".$k."\">".$sed_groups[$k]['title']."</a>";
$res .= ($sed_groups[$k]['hidden']) ? ' ('.$L['Hidden'].')' : '';
$res .= "<br />";
}
}
}

return($res);
}

/* ------------------ */

function sed_build_icq($text)
{
global $cfg;

$text = sed_import($text, 'D', 'INT', 32);
if ($text>0)
{ $text = $text." <a href=\"http://www.icq.com/".$text."#pager\"><img src=\"http://web.icq.com/whitepages/online?icq=".$text."&amp;img=5\" alt=\"\" /></a>"; }
return($text);
}

/* ------------------ */

function sed_build_ipsearch($ip)
{
global $xk;

if (!empty($ip))
{
$result = "<a href=\"admin.php?m=tools&amp;p=ipsearch&amp;a=search&amp;id=".$ip."&amp;x=".$xk."\">".$ip."</a>";
}

return($result);
}

/* ------------------ */

function sed_build_msn($msn)
{
if (!empty($msn) && eregi('@', $msn))
{
$msn = sed_cc($msn);
$result = "<a href=\"mailto:".$msn."\">".$msn."</a>";
}

return($result);
}

/* ------------------ */

function sed_build_oddeven($number)
{
if ($number % 2 == 0 )
{ return ('even'); }
else
{ return ('odd'); }
}

/* ------------------ */

function sed_build_pfs($id, $c1, $c2, $title)
{
global $L, $cfg, $usr, $sed_groups;
if ($cfg['disable_pfs'])
{ $res = ''; }
else
{
if ($id==0)
{ $res = "<a href=\"javascript:pfs('0','".$c1."','".$c2."')\">".$title."</a>"; }
elseif ($sed_groups[$usr['maingrp']]['pfs_maxtotal']>0 && $sed_groups[$usr['maingrp']]['pfs_maxfile']>0 && sed_auth('pfs', 'a', 'R'))
{ $res = "<a href=\"javascript:pfs('".$id."','".$c1."','".$c2."')\">".$title."</a>"; }
else
{ $res = ''; }
}
return($res);
}

/* ------------------ */

function sed_build_pm($user)
{
global $usr, $cfg, $L;
$result = "<a href=\"pm.php?m=send&amp;to=".$user."\"><img src=\"skins/".$usr['skin']."/img/system/icon-pm.gif\"  alt=\"\" /></a>";
return($result);
}

/* ------------------ */

function sed_build_ratings($code, $url, $display)
{
global $db_ratings, $db_rated, $db_users, $cfg, $usr, $sys, $L;

list($usr['auth_read_rat'], $usr['auth_write_rat'], $usr['isadmin_rat']) = sed_auth('ratings', 'a');

if ($cfg['disable_ratings'] || !$usr['auth_read_rat'])
{ return (array('','')); }

$sql = sed_sql_query("SELECT * FROM $db_ratings WHERE rating_code='$code' LIMIT 1");

if ($row = sed_sql_fetcharray($sql))
{
$rating_average = $row['rating_average'];
$yetrated = TRUE;
if ($rating_average<1)
{ $rating_average = 1; }
elseif ($rating_average>10)
{ $rating_average = 10; }
$rating_cntround = round($rating_average, 0);
}
else
{
$yetrated = FALSE;
$rating_average = 0;
$rating_cntround = 0;
}

$res = "<a href=\"".$url."&amp;ratings=1\"><img src=\"skins/".$usr['skin']."/img/system/vote".$rating_cntround.".gif\" alt=\"\" /></a>";

if ($display)
{
$ina = sed_import('ina','G','ALP');
$newrate = sed_import('newrate','P','INT');

if ($ina=='send' && $newrate>=1 && $newrate<=10 && $usr['auth_write_rat'])
{
/* == Hook for the plugins == */
$extp = sed_getextplugins('ratings.send.first');
if (is_array($extp))
{ foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */

if (!$yetrated)
{
$sql = sed_sql_query("INSERT INTO $db_ratings (rating_code, rating_state, rating_average, rating_creationdate, rating_text) VALUES ('".sed_sql_prep($code)."', 0, ".(int)$newrate.", ".(int)$sys['now_offset'].", '') ");
}

$sql = sed_sql_query("INSERT INTO $db_rated (rated_code, rated_userid, rated_value) VALUES ('".sed_sql_prep($code)."', ".(int)$usr['id'].", ".(int)$newrate.")");
$sql = sed_sql_query("SELECT COUNT(*) FROM $db_rated WHERE rated_code='$code'");
$rating_voters = sed_sql_result($sql, 0, "COUNT(*)");
$ratingnewaverage = ($rating_average * ($rating_voters - 1) + $newrate) / ( $rating_voters );
$sql = sed_sql_query("UPDATE $db_ratings SET rating_average='$ratingnewaverage' WHERE rating_code='$code'");

/* == Hook for the plugins == */
$extp = sed_getextplugins('ratings.send.done');
if (is_array($extp))
{ foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */

header("Location: $url&ratings=1&ina=added");
exit;
}

$votedcasted = ($ina=='added') ? 1 : 0;

$rate_form = "<input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"1\" /><img src=\"skins/".$usr['skin']."/img/system/vote1.gif\" alt=\"\" /> 1 - ".$L['rat_choice1']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"2\" /><img src=\"skins/".$usr['skin']."/img/system/vote2.gif\" alt=\"\" /> 2 - ".$L['rat_choice2']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"3\" /><img src=\"skins/".$usr['skin']."/img/system/vote3.gif\" alt=\"\" /> 3 - ".$L['rat_choice3']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"4\" /><img src=\"skins/".$usr['skin']."/img/system/vote4.gif\" alt=\"\" /> 4 - ".$L['rat_choice4']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"5\" checked=\"checked\" /><img src=\"skins/".$usr['skin']."/img/system/vote5.gif\" alt=\"\" /> 5 - ".$L['rat_choice5']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"6\" /><img src=\"skins/".$usr['skin']."/img/system/vote6.gif\" alt=\"\" /> 6 - ".$L['rat_choice6']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"7\" /><img src=\"skins/".$usr['skin']."/img/system/vote7.gif\" alt=\"\" /> 7 - ".$L['rat_choice7']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"8\" /><img src=\"skins/".$usr['skin']."/img/system/vote8.gif\" alt=\"\" /> 8 - ".$L['rat_choice8']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"9\" /><img src=\"skins/".$usr['skin']."/img/system/vote9.gif\" alt=\"\" /> 9 - ".$L['rat_choice9']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"10\" /><img src=\"skins/".$usr['skin']."/img/system/vote10.gif\" alt=\"\" /> 10 - ".$L['rat_choice10'];

if ($usr['id']>0)
{
$sql1 = sed_sql_query("SELECT rated_value FROM $db_rated WHERE rated_code='$code' AND rated_userid='".$usr['id']."' LIMIT 1");

if ($row1 = sed_sql_fetcharray($sql1))
{
$alreadyvoted = TRUE;
$rating_uservote = $L['rat_alreadyvoted']." (".$row1['rated_value'].")";
}
}

$t = new XTemplate(sed_skinfile('ratings'));

/* == Hook for the plugins == */
$extp = sed_getextplugins('ratings.main');
if (is_array($extp))
{ foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */

if (!empty($error_string))
{
$t->assign("RATINGS_ERROR_BODY",$error_string);
$t->parse("RATINGS.RATINGS_ERROR");
}

if ($yetrated)
{
$sql = sed_sql_query("SELECT COUNT(*) FROM $db_rated WHERE rated_code='$code' ");
$rating_voters = sed_sql_result($sql, 0, "COUNT(*)");
$rating_average = $row['rating_average'];
$rating_since = $L['rat_since']." ".date($cfg['dateformat'], $row['rating_creationdate'] + $usr['timezone'] * 3600);
if ($rating_average<1)
{ $rating_average = 1; }
elseif ($ratingaverage>10)
{ $rating_average = 10; }

$rating = round($rating_average,0);
$rating_averageimg = "<img src=\"skins/".$usr['skin']."/img/system/vote".$rating.".gif\" alt=\"\" />";
$sql = sed_sql_query("SELECT COUNT(*) FROM $db_rated WHERE rated_code='$code' ");
$rating_voters = sed_sql_result($sql, 0, "COUNT(*)");
}
else
{
$rating_voters = 0;
$rating_since = '';
$rating_average = $L['rat_notyetrated'];
$rating_averageimg = '';
}

$t->assign(array(
"RATINGS_AVERAGE" => $rating_average,
"RATINGS_AVERAGEIMG" => $rating_averageimg,
"RATINGS_VOTERS" => $rating_voters,
"RATINGS_SINCE" => $rating_since
));


if ($usr['id']>0 && $votedcasted)
{
$t->assign(array(
"RATINGS_EXTRATEXT" => $L['rat_votecasted'],
));
$t->parse("RATINGS.RATINGS_EXTRA");
}
elseif ($usr['id']>0 && $alreadyvoted)
{
$t->assign(array(
"RATINGS_EXTRATEXT" => $rating_uservote,
));
$t->parse("RATINGS.RATINGS_EXTRA");
}
elseif ($usr['id']==0)
{
$t->assign(array(
"RATINGS_EXTRATEXT" => $L['rat_registeredonly'],
));
$t->parse("MAIN.RATINGS_EXTRA");
}

elseif ($usr['id']>0 && !$alreadyvoted)
{
$t->assign(array(
"RATINGS_NEWRATE_FORM_SEND" => $url."&amp;ratings=1&amp;ina=send",
"RATINGS_NEWRATE_FORM_VOTER" => $usr['name'],
"RATINGS_NEWRATE_FORM_RATE" => $rate_form
));
$t->parse("RATINGS.RATINGS_NEWRATE");
}

/* == Hook for the plugins == */
$extp = sed_getextplugins('ratings.tags');
if (is_array($extp))
{ foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */

$t->parse("RATINGS");
$res_display = $t->text("RATINGS");
}
else
{
$res_display = '';
}

return(array($res, $res_display));
}

/* ------------------ */

function sed_build_smilies($c1, $c2, $title)
{
$result = "<a href=\"javascript:help('smilies','".$c1."','".$c2."')\">".$title."</a>";
return($result);
}

/* ------------------ */

function sed_build_smilies_local($limit)
{
global $sed_smilies;

$result = '<div class=\"smilies\">';

if (is_array($sed_smilies))
{
reset ($sed_smilies);
while (list($i,$dat) = each($sed_smilies))
{
$result .= "<a href=\"javascript:addtxt('".$dat[1]."')\"><img src=\"".$dat['smilie_image']."\" alt=\"\" /></a> ";
}
}

$result .= "</div>";
return($result);
}

/* ------------------ */

function sed_build_stars($level)
{
global $skin;

if ($level>0 and $level<100)
{ return("<img src=\"skins/$skin/img/system/stars".(floor($level/10)+1).".gif\" alt=\"\" />"); }
else
{ return(''); }
}

/* ------------------ */

function sed_build_timegap($t1,$t2)
{
global $L;

$gap = $t2 - $t1;

if ($gap<=0 || !$t2 || $gap>94608000)
        {
        $result = '';
        }
       elseif ($gap<60)
        {
        $result  = $gap.' '.$L['Seconds'];
        }
      elseif ($gap<3600)
        {
        $gap = floor($gap/60);
      $result = ($gap<2) ? '1 '.$L['Minute'] : $gap.' '.$L['Minutes'];
        }
       elseif ($gap<86400)
        {
        $gap1 = floor($gap/3600);
        $gap2 = floor(($gap-$gap1*3600)/60);
$result = ($gap1<2) ? '1 '.$L['Hour'].' ' : $gap1.' '.$L['Hours'].' ';
if ($gap2>0)
{ $result .= ($gap2<2) ? '1 '.$L['Minute'] : $gap2.' '.$L['Minutes']; }
        }
       else
        {
        $gap = floor($gap/86400);
        $result = ($gap<2) ? '1 '.$L['Day'] : $gap.' '.$L['Days'];
        }

return($result);
   }

/* ------------------ */

function sed_build_timezone($tz)
{
global $L;

$result = 'GMT';

if ($tz==-1 OR $tz==1)
{ $result .= $tz.' '.$L['Hour']; }
elseif ($tz!=0)
{ $result .= $tz.' '.$L['Hours']; }
return($result);
}

/* ------------------ */

function sed_build_url($text, $maxlen=64)
{
global $cfg;

if (!empty($text))
{
if (!eregi('http://', $text))
{ $text='http://'. $text; }
$text = sed_cc($text);
$text = "<a href=\"".$text."\">".sed_cutstring($text, $maxlen)."</a>";
}
return($text);
}

/* ------------------ */

function sed_build_user($id, $user)
{/*
Function hack by Dvdbil
$Web: www.seditio-tr.com
$mail: dvdbil@seditio-tr.com */
global $cfg;

if (($id==0 && !empty($user)))
{ $result = $user; }
elseif ($id==0)
{ $result = ''; }
else
{ $result = (!empty($user)) ? $user : '?'; }

$sql = sed_sql_query("SELECT gru_groupid FROM sed_groups_users WHERE gru_userid='$id' LIMIT 1");
$row = sed_sql_fetcharray($sql);

if ($row['gru_groupid']==5)
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\"><img src=\"img/resim.gif\"><font style=\"color:#003399;font-weight:bold;\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==4)
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\"><font style=\"color:#008000;\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==8)
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\"><img src=\"img/kral1.gif\"><font style=\"color:#00ff33;font-weight:bold;\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==9)
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\"><font style=\"color:#ccff66\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==11)
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\"><font style=\"color:#99ff00\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==12)
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\"><font style=\"color:#3333cc\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==10)
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\"><font style=\"color:#cc0033\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==13)
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\"><font style=\"color:#ff9966\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==7)
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\"><img src=\"img/kral.gif\"><font style=\"color:#cc0000;font-weight:bold;\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==6)
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\"><img src=\"img/kral2.gif\"><font style=\"color:#00ff99;font-weight:bold;\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==3)
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\"><font style=\"color:#FF00FF;text-decoration:line-through;\">".$result."</font></a>";
}
elseif ($row['gru_groupid']==2)
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\"><font style=\"color:#804040;font-style:italic;\">".$result."</font></a>";
}
else
{
$result = "<a href=\"users.php?m=details&amp;id=".$id."\">".$user."</a>";
}
return($result);
}
/* ------------------ */

function sed_build_userimage($image)
{
if (!empty($image))
      { $result = "<img src=\"".$image."\" class=\"reflect\" alt=\"\" class=\"avatar\" />"; }
return($result);
}

/* ------------------ */

function sed_build_usertext($text)
{
global $cfg;

if (!$cfg['usertextimg'])
{
$bbcodes_img = array(
'\\[img\\]([^\\[]*)\\[/img\\]' => 'No [img] !',
'\\[thumb=([^\\[]*)\\[/thumb\\]' => 'No [Thumbs] !',
'\\[t=([^\\[]*)\\[/t\\]' => 'No [t] !',
'\\[list\\]' => '',
'\\[style=([^\\[]*)\\]' => 'No styles !',
'\\[quote' => 'No quotes !',
'\\[code' => 'No code !'
);

foreach($bbcodes_img as $bbcode => $bbcodehtml)
{ $text = eregi_replace($bbcode, $bbcodehtml, $text); }
}

if ($cfg['usertextimg_nocolors'])
{
$bbcodes_img = array(
'\\[red\\]' => '',
'\\[/red\\]' => '',
'\\[white\\]' => '',
'\\[/white\\]' => '',
'\\[green\\]' => '',
'\\[/green\\]' => '',
'\\[blue\\]' => '',
'\\[/blue\\]' => '',
'\\[orange\\]' => '',
'\\[/orange\\]' => '',
'\\[yellow\\]' => '',
'\\[/yellow\\]' => '',
'\\[purple\\]' => '',
'\\[/purple\\]' => '',
'\\[black\\]' => '',
'\\[/black\\]' => '',
'\\[grey\\]' => '',
'\\[/grey\\]' => '',
'\\[pink\\]' => '',
'\\[/pink\\]' => '',
'\\[sky\\]' => '',
'\\[/sky\\]' => '',
'\\[sea\\]' => '',
'\\[/sea\\]' => '',
'\\[color=([^\\[]*)\\]' => 'No colors !'
);

foreach($bbcodes_img as $bbcode => $bbcodehtml)
{ $text = eregi_replace($bbcode, $bbcodehtml, $text); }

}

$text = sed_cc($text);

if ($cfg['parsebbcodeusertext'])
{ $text = sed_bbcode($text); }

$text = nl2br($text);

if ($cfg['parsesmiliesusertext'])
{ $text = sed_smilies($text); }

return($text);
}

/* ------------------ */

function sed_cache_clear($name)
{
global $db_cache;

$sql = sed_sql_query("DELETE FROM $db_cache WHERE c_name='$name'");
return(TRUE);
}

/* ------------------ */

function sed_cache_clearall()
{
global $db_cache;
$sql = sed_sql_query("DELETE FROM $db_cache");
return(TRUE);
}

/* ------------------ */

function sed_cache_get($name)
{
global $cfg, $sys, $db_cache;

if (!$cfg['cache'])
          { return FALSE; }
$sql = sed_sql_query("SELECT c_value FROM $db_cache WHERE c_name='$name' AND c_expire>'".$sys['now']."'");
if ($row = sed_sql_fetcharray($sql))
{ return(unserialize($row['c_value'])); }
else
    { return(FALSE); }
}

/* ------------------ */

function sed_cache_getall($auto="1")
{
global $cfg, $sys, $db_cache;

if (!$cfg['cache'])
          { return FALSE; }
$sql = sed_sql_query("DELETE FROM $db_cache WHERE c_expire<'".$sys['now']."'");
if ($auto)
{ $sql = sed_sql_query("SELECT c_name, c_value FROM $db_cache WHERE c_auto=1"); }
       else
{ $sql = sed_sql_query("SELECT c_name, c_value FROM $db_cache"); }
if (sed_sql_numrows($sql)>0)
{ return($sql); }
else
    { return(FALSE); }
}

/* ------------------ */

function sed_cache_store($name,$value,$expire,$auto="1")
{
global $db_cache, $sys, $cfg;

if (!$cfg['cache'])
      { return(FALSE); }
$sql = sed_sql_query("REPLACE INTO $db_cache (c_name, c_value, c_expire, c_auto) VALUES ('$name', '".sed_sql_prep(serialize($value))."', '".($expire + $sys['now'])."', '$auto')");
return(TRUE);
}

/* ------------------ */

function sed_cc($text)
{
$text = preg_replace('/&#([0-9]{2,4});/is','&#$1;',$text);
$text = str_replace(
array('{', '<', '>' , '$', '\'', '"', '\\', '&amp;', '&nbsp;'),
array('{', '<', '>', '$', ''', '"', '\', '&amp;amp;', '&amp;nbsp;'), $text);
return($text);
}

/* ------------------ */

function sed_check_xg()
{
global $xg, $cfg;

if ($xg!=sed_sourcekey())
{ sed_diefatal('Wrong parameter in the URL.'); }
return (TRUE);
}

/* ------------------ */

function sed_check_xp()
{
global $xp;

$sk = sed_sourcekey();
if ($_SERVER["REQUEST_METHOD"]=='POST' && !defined('SED_AUTH'))
{
if ( empty($xp) || $xp!=$sk)
{ sed_diefatal('Wrong parameter in the URL.'); }
}
return ($sk);
}

/* ------------------ */

function sed_cutstring($res,$l)
{
global $cfg;

$enc = strtolower($cfg['charset']);
if ($enc=='utf-8')
{
if(mb_strlen($res)>$l)
{ $res = mb_substr($res, 0, ($l-3), $enc).'...'; }
}
else
{
if(strlen($res)>$l)
{ $res = substr($res, 0, ($l-3)).'...'; }
}
       return($res);
    }

/* ------------------ */

function sed_createthumb($img_big, $img_small, $small_x, $small_y, $keepratio, $extension, $filen, $fsize, $textcolor, $textsize, $bgcolor, $bordersize, $jpegquality, $dim_priority="Width")
{
if (!function_exists('gd_info'))
{ return; }

global $cfg;

$gd_supported = array('jpg', 'jpeg', 'png', 'gif');

switch($extension)
{
case 'gif':
$source = imagecreatefromgif($img_big);
break;

case 'png':
$source = imagecreatefrompng($img_big);
break;

default:
$source = imagecreatefromjpeg($img_big);
break;
}

$big_x = imagesx($source);
$big_y = imagesy($source);

if (!$keepratio)
{
$thumb_x = $small_x;
$thumb_y = $small_y;
}
elseif ($dim_priority=="Width")
{
$thumb_x = $small_x;
$thumb_y = floor($big_y * ($small_x / $big_x));
}
else
{
$thumb_x = floor($big_x * ($small_y / $big_y));
$thumb_y = $small_y;
}

if ($textsize==0)
{
if ($cfg['th_amode']=='GD1')
{ $new = imagecreate($thumb_x+$bordersize*2, $thumb_y+$bordersize*2); }
else
{ $new = imagecreatetruecolor($thumb_x+$bordersize*2, $thumb_y+$bordersize*2); }

$background_color = imagecolorallocate ($new, $bgcolor[0], $bgcolor[1] ,$bgcolor[2]);
imagefilledrectangle ($new, 0,0, $thumb_x+$bordersize*2, $thumb_y+$bordersize*2, $background_color);

if ($cfg['th_amode']=='GD1')
{ imagecopyresized($new, $source, $bordersize, $bordersize, 0, 0, $thumb_x, $thumb_y, $big_x, $big_y); }
else
{ imagecopyresampled($new, $source, $bordersize, $bordersize, 0, 0, $thumb_x, $thumb_y, $big_x, $big_y); }

}
   else
{
if ($cfg['th_amode']=='GD1')
{ $new = imagecreate($thumb_x+$bordersize*2, $thumb_y+$bordersize*2+$textsize*3.5+6); }
else
{ $new = imagecreatetruecolor($thumb_x+$bordersize*2, $thumb_y+$bordersize*2+$textsize*3.5+6); }

$background_color = imagecolorallocate($new, $bgcolor[0], $bgcolor[1] ,$bgcolor[2]);
imagefilledrectangle ($new, 0,0, $thumb_x+$bordersize*2, $thumb_y+$bordersize*2+$textsize*4+14, $background_color);
$text_color = imagecolorallocate($new, $textcolor[0],$textcolor[1],$textcolor[2]);

if ($cfg['th_amode']=='GD1')
{ imagecopyresized($new, $source, $bordersize, $bordersize, 0, 0, $thumb_x, $thumb_y, $big_x, $big_y); }
else
{ imagecopyresampled($new, $source, $bordersize, $bordersize, 0, 0, $thumb_x, $thumb_y, $big_x, $big_y); }

imagestring ($new, $textsize, $bordersize, $thumb_y+$bordersize+$textsize+1, $big_x."x".$big_y." ".$fsize."kb", $text_color);
}

switch($extension)
{
case 'gif':
imagegif($new, $img_small);
break;

case 'png':
imagepng($new, $img_small);
break;

default:
imagejpeg($new, $img_small, $jpegquality);
break;
}

imagedestroy($new);
imagedestroy($source);
return;
}

/* ------------------ */

function sed_die($cond=TRUE)
{
if ($cond)
{
header("Location: message.php?msg=950");
exit;
}
return(FALSE);
}

/* ------------------ */

function sed_diefatal($text='Reason is unknown.', $title='Fatal error')
{
global $cfg;

$disp = "<strong><a href=\"".$cfg['mainurl']."\">".$cfg['maintitle']."</a></strong><br />";
$disp .= @date('Y-m-d H:i').'<br />'.$title.' : '.$text;
die($disp);
}

/* ------------------ */

function sed_dieifdisabled($disabled)
{
if ($disabled)
{
header("Location: message.php?msg=940");
exit;
}
return;
}

/* ------------------ */

function sed_forum_prunetopics($mode, $section, $param)
{
global $cfg, $sys, $db_forum_topics, $db_forum_posts, $db_forum_sections, $L;

$num = 0;
$num1 = 0;

switch ($mode)
{
case 'updated':
$limit = $sys['now'] - ($param*86400);
$sql1 = sed_sql_query("SELECT * FROM $db_forum_topics WHERE ft_sectionid='$section' AND ft_updated<'$limit' AND ft_sticky='0'");
break;

case 'single':
$sql1 = sed_sql_query("SELECT * FROM $db_forum_topics WHERE ft_sectionid='$section' AND ft_id='$param'");
break;
}

if (sed_sql_numrows($sql1)>0)
{
while ($row1 = sed_sql_fetchassoc($sql1))
{
$q = $row1['ft_id'];

if ($cfg['trash_forum'])
{
$sql = sed_sql_query("SELECT * FROM $db_forum_posts WHERE fp_topicid='$q' ORDER BY fp_id DESC");

while ($row = sed_sql_fetchassoc($sql))
{ sed_trash_put('forumpost', $L['Post']." #".$row['fp_id']." from topic #".$q, "p".$row['fp_id']."-q".$q, $row); }
}

$sql = sed_sql_query("DELETE FROM $db_forum_posts WHERE fp_topicid='$q'");
$num += sed_sql_affectedrows();

if ($cfg['trash_forum'])
{
$sql = sed_sql_query("SELECT * FROM $db_forum_topics WHERE ft_id='$q'");

while ($row = sed_sql_fetchassoc($sql))
{ sed_trash_put('forumtopic', $L['Topic']." #".$q." (no post left)", "q".$q, $row); }
}

$sql = sed_sql_query("DELETE FROM $db_forum_topics WHERE ft_id='$q'");
$num1 += sed_sql_affectedrows();
}

$sql = sed_sql_query("DELETE FROM $db_forum_topics WHERE ft_movedto='$q'");

$sql = sed_sql_query("UPDATE $db_forum_sections SET fs_topiccount=fs_topiccount-'$num1' WHERE fs_id='$section'");
$sql = sed_sql_query("UPDATE $db_forum_sections SET fs_postcount=fs_postcount-'$num' WHERE fs_id='$section'");
$sql = sed_sql_query("UPDATE $db_forum_sections SET fs_topiccount_pruned=fs_topiccount_pruned+'$num1' WHERE fs_id='$section'");
$sql = sed_sql_query("UPDATE $db_forum_sections SET fs_postcount_pruned=fs_postcount_pruned+'$num' WHERE fs_id='$section'");
}
       $num1 = ($num1=='') ? '0' : $num1;
return($num1);
}

/* ------------------ */

function sed_forum_sectionsetlast($id)
{
global $db_forum_topics, $db_forum_sections;

$sql = sed_sql_query("SELECT ft_id, ft_lastposterid, ft_lastpostername, ft_updated, ft_title, ft_poll FROM $db_forum_topics WHERE ft_sectionid='$id' AND ft_movedto='0' and ft_mode='0' ORDER BY ft_updated DESC LIMIT 1");
$row = sed_sql_fetcharray($sql);
$sql = sed_sql_query("UPDATE $db_forum_sections SET fs_lt_id=".(int)$row['ft_id'].", fs_lt_title='".sed_sql_prep($row['ft_title'])."', fs_lt_date=".(int)$row['ft_updated'].", fs_lt_posterid=".(int)$row['ft_lastposterid'].", fs_lt_postername='".sed_sql_prep($row['ft_lastpostername'])."' WHERE fs_id='$id'");
return;
}

/* ------------------ */

function sed_getextplugins($hook, $cond='R')
{
global $sed_plugins, $usr;

if (is_array($sed_plugins))
{
foreach($sed_plugins as $i => $k)
{
if ($k['pl_hook']==$hook && sed_auth('plug', $k['pl_code'], $cond))
{ $extplugins[$i] = $k; }
}
}
return ($extplugins);
}

/* ------------------ */

function sed_htmlmetas()
{
global $cfg;
$contenttype = ($cfg['doctypeid']>2 && $cfg['xmlclient']) ? "application/xhtml+xml" : "text/html";
$result = "<meta http-equiv=\"content-type\" content=\"".$contenttype."; charset=".$cfg['charset']."\" />
<meta name=\"description\" content=\"".$cfg['maintitle']." - ".$cfg['subtitle']."\" />
<meta name=\"keywords\" content=\"".$cfg['metakeywords']."\" />
<meta name=\"generator\" content=\"Seditio by Neocrome http://www.neocrome.net\" />
<meta http-equiv=\"expires\" content=\"Fri, Apr 01 1974 00:00:00 GMT\" />
<meta http-equiv=\"pragma\" content=\"no-cache\" />
<meta http-equiv=\"cache-control\" content=\"no-cache\" />
<meta http-equiv=\"last-modified\" content=\"".gmdate("D, d M Y H:i:s")." GMT\" />
<link rel=\"shortcut icon\" href=\"favicon.ico\" />
";
return ($result);
}


/* ------------------ */

function sed_import($name, $source, $filter, $maxlen=0, $dieonerror=FALSE)
{
switch($source)
{
case 'G':
$v = $_GET[$name];
$log = TRUE;
break;

case 'P':
$v = $_POST[$name];
$log = TRUE;
if ($filter=='ARR') { return($v); }
break;

case 'C':
$v = $_COOKIE[$name];
$log = TRUE;
break;

case 'D':
$v = $name;
$log = FALSE;
break;

default:
sed_diefatal('Unknown source for a variable : <br />Name = '.$name.'<br />Source = '.$source.' ? (must be G, P, C or D)');
break;
}

if (MQGPC && ($source='G' || $source='P' || $source='C') )
{ $v = stripslashes($v); }

if ($v=='')
        { return(''); }

    if ($maxlen>0)
    { $v = substr($v, 0, $maxlen); }

$pass = FALSE;
$defret = NULL;
$filter = ($filter=='STX') ? 'TXT' : $filter;

switch($filter)
{
case 'INT':
if (is_numeric($v)==TRUE && floor($v)==$v)
        { $pass = TRUE; }
break;

case 'NUM':
if (is_numeric($v)==TRUE)
        { $pass = TRUE; }
break;

case 'TXT':
$v = trim($v);
if (strpos($v, '<')===FALSE)
        { $pass = TRUE; }
       else
{ $defret = str_replace('<', '<', $v); }
break;

case 'SLU':
$v = trim($v);
$f = preg_replace('/[^a-zA-Z0-9_=\/]/', '', $v);
if ($v == $f)
        { $pass = TRUE; }
      else
{ $defret = ''; }
break;

case 'ALP':
$v = trim($v);
$f = sed_alphaonly($v);
if ($v == $f)
        { $pass = TRUE; }
       else
{ $defret = $f; }
break;

case 'PSW':
$v = trim($v);
$f = sed_alphaonly($v);
$f = substr($f, 0 ,32);

if ($v == $f)
        { $pass = TRUE; }
else
{ $defret = $f; }
break;

case 'HTM':
$v = trim($v);
$pass = TRUE;
break;

case 'ARR':
if (TRUE) // !!!!!!!!!!!
        { $pass = TRUE; }
break;

case 'BOL':
if ($v=="1" || $v=="on")
        {
        $pass = TRUE;
        $v = "1";
        }
elseif ($v=="0" || $v=="off")
        {
        $pass = TRUE;
        $v = "0";
        }
    else
        {
        $defret = "0";
        }
break;

case 'LVL':
if (is_numeric($v)==TRUE && $v>=0 && $v<=100 && floor($v)==$v)
        { $pass = TRUE; }
else
{ $defret = NULL; }
break;

case 'NOC':
$pass = TRUE;
break;

default:
sed_diefatal('Unknown filter for a variable : <br />Var = '.$cv_v.'<br />Filter = '.$filter.' ?');
break;
}

if ($pass)
{ return($v); }
else
{
if ($log) { sed_log_sed_import($source, $filter, $name, $v); }
if ($dieonerror)
{ sed_diefatal('Wrong input.'); }
else
{ return($defret); }
}
}


/* ------------------ */

function sed_infoget($file, $limiter='SED', $maxsize=32768)
{
$result = array();

if ($fp = @fopen($file, 'r'))
{
$limiter_begin = "[BEGIN_".$limiter."]";
$limiter_end = "[END_".$limiter."]";
$data = fread($fp, $maxsize);
$begin = strpos($data, $limiter_begin);
$end = strpos($data, $limiter_end);

if ($end>$begin && $begin>0)
{
$lines = substr($data, $begin+8+strlen($limiter), $end-$begin-strlen($limiter)-8);
$lines = explode ("\n",$lines);

foreach ($lines as $k => $line)
{
$linex = explode ("=", $line);
$ii=1;
while (!empty($linex[$ii]))
{
$result[$linex[0]] .= trim($linex[$ii]);
$ii++;
}
}
}
else
{ $result['Error'] = 'Warning: No tags found in '.$file; }
}
else
{ $result['Error'] = 'Error: File '.$file.' is missing!'; }
@fclose($fp);
return ($result);
}

/* ------------------ */

function sed_javascript($more='')
{
$result = "<script type=\"text/javascript\">
<!--

function popup(code,w,h)
{ window.open('plug.php?o='+code,'','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width='+w+',height='+h+',left=32,top=16'); }

function pfs(id,c1,c2)
{ window.open('pfs.php?userid='+id+'&c1='+c1+'&c2='+c2,'PFS','status=1, toolbar=0,location=0,directories=0,menuBar=0,resizable=1,scrollbars=yes,width=754,height=512,left=32,top=16'); }

function help(rcode,c1,c2)
{ window.open('plug.php?h='+rcode+'&c1='+c1+'&c2='+c2,'Help','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=480,height=512,left=32,top=16'); }

function comments(rcode)
{ window.open('comments.php?id='+rcode,'Comments','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=480,height=512,left=16,top=16'); }

function ratings(rcode)
{ window.open('ratings.php?id='+rcode,'Ratings','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=480,height=512,left=16,top=16'); }

function polls(rcode)
{ window.open('polls.php?id='+rcode,'Polls','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=608,height=448,left=16,top=16'); }

function pollvote(rcode,rvote)
{ window.open('polls.php?a=send&id='+rcode+'&vote='+rvote,'Polls','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=608,height=448,left=16,top=16'); }

function picture(url,sx,sy)
{ window.open('pfs.php?m=view&v='+url,'Picture','toolbar=0,location=0,directories=0,menuBar=0,resizable=1,scrollbars=yes,width='+sx+',height='+sy+',left=0,top=0'); }

function redirect(url)
{ location.href = url.options[url.selectedIndex].value; }

function toggleblock(id)
{
var bl = document.getElementById(id);
if(bl.style.display == 'none')
{ bl.style.display = ''; }
else
{ bl.style.display = 'none'; }
}

window.name='main';

".$more."

//-->
</script>";
return ($result);
}

/* ------------------ */

function sed_loadbbcodes()
{
global $location;

$result = array();
$result[]=array('[b][/b]','bold');
$result[]=array('[u][/u]','underline');
$result[]=array('[i][/i]','italic');
$result[]=array('[left][/left]','left');
$result[]=array('[center][/center]','center');
$result[]=array('[right][/right]','right');
$result[]=array('[_]','spacer');
$result[]=array('[code]
','code');
$result[]=array('
Quote

','quote');
$result[]=array('\n
    1\n2\n3\
','list');
$result[]=array('[t=thumbnail]fullsize[/t]','thumb');
$result[]=array('[img][/img]','image');
$result[]=array('
','colleft');
$result[]=array('
','colright');
$result[]=array('','url');
$result[]=array('','urlp');
$result[]=array('[email][/email]','email');
$result[]=array('[email=][/email]','emailp');
$result[]=array('[user=][/user]','user');
$result[]=array('[page=][/page]','page');
$result[]=array('[link=][/link]','link');
$result[]=array('

','p');
$result[]=array('','ac');
$result[]=array('[topic=][/topic]','topic');
$result[]=array('[post=][/post]','post');
$result[]=array('','black');
$result[]=array('','grey');
$result[]=array('','sea');
$result[]=array('','blue');
$result[]=array('','sky');
$result[]=array('','green');
$result[]=array('','yellow');
$result[]=array('','orange');
$result[]=array('','red');
$result[]=array('','white');
$result[]=array('','pink');
$result[]=array('','purple');
$result[]=array('
','hr');
$result[]=array('[f][/f]','flag');
$result[]=array('','style1');
$result[]=array('','style2');
$result[]=array('','style3');
$result[]=array('','style4');
$result[]=array('','style5');
$result[]=array('','style6');
$result[]=array('','style7');
$result[]=array('','style8');
$result[]=array('','style9');

if ($location=='Pages')
{ $result[]=array('[newpage]\n[title]...[/title]','multipages'); }
elseif ($location=='Newstopic')
{ $result[]=array('','more'); }

return($result);
}

/* ------------------ */

function sed_load_structure()
{
global $db_structure, $cfg, $L;

$res = array();
$sql = sed_sql_query("SELECT * FROM $db_structure ORDER BY structure_path ASC");

while ($row = sed_sql_fetcharray($sql))
{
if (!empty($row['structure_icon']))
{ $row['structure_icon'] = "<img src=\"".$row['structure_icon']."\" alt=\"\" />"; }

$path2 = strrpos($row['structure_path'], '.');

$row['structure_tpl'] = (empty($row['structure_tpl'])) ? $row['structure_code'] : $row['structure_tpl'];

if ($path2>0)
{
$path1 = substr($row['structure_path'],0,($path2));
$path[$row['structure_path']] = $path[$path1].'.'.$row['structure_code'];
$tpath[$row['structure_path']] = $tpath[$path1].' '.$cfg['separator'].' '.$row['structure_title'];
$row['structure_tpl'] = ($row['structure_tpl']=='same_as_parent') ? $parent_tpl : $row['structure_tpl'];
}
else
{
$path[$row['structure_path']] = $row['structure_code'];
$tpath[$row['structure_path']] = $row['structure_title'];
}

$order = explode('.',$row['structure_order']);
$parent_tpl = $row['structure_tpl'];

$res[$row['structure_code']] = array (
'path' => $path[$row['structure_path']],
'tpath' => $tpath[$row['structure_path']],
'rpath' => $row['structure_path'],
'tpl' => $row['structure_tpl'],
'title' => $row['structure_title'],
'desc' => $row['structure_desc'],
'icon' => $row['structure_icon'],
'group' => $row['structure_group'],
'order' => $order[0],
'way' => $order[1]
);
}

return($res);
}

/* ------------------ */

function sed_load_forum_structure()
{
global $db_forum_structure, $cfg, $L;

$res = array();
$sql = sed_sql_query("SELECT * FROM $db_forum_structure ORDER BY fn_path ASC");

while ($row = sed_sql_fetcharray($sql))
{
if (!empty($row['fn_icon']))
{ $row['fn_icon'] = "<img src=\"".$row['fn_icon']."\" alt=\"\" />"; }

$path2 = strrpos($row['fn_path'], '.');

$row['fn_tpl'] = (empty($row['fn_tpl'])) ? $row['fn_code'] : $row['fn_tpl'];

if ($path2>0)
{
$path1 = substr($row['fn_path'],0,($path2));
$path[$row['fn_path']] = $path[$path1].'.'.$row['fn_code'];
$tpath[$row['fn_path']] = $tpath[$path1].' '.$cfg['separator'].' '.$row['fn_title'];
$row['fn_tpl'] = ($row['fn_tpl']=='same_as_parent') ? $parent_tpl : $row['fn_tpl'];
}
else
{
$path[$row['fn_path']] = $row['fn_code'];
$tpath[$row['fn_path']] = $row['fn_title'];
}

$parent_tpl = $row['fn_tpl'];

$res[$row['fn_code']] = array (
'path' => $path[$row['fn_path']],
'tpath' => $tpath[$row['fn_path']],
'rpath' => $row['fn_path'],
'tpl' => $row['fn_tpl'],
'title' => $row['fn_title'],
'desc' => $row['fn_desc'],
'icon' => $row['fn_icon'],
'defstate' => $row['fn_defstate']
);
}

return($res);
}

/* ------------------ */

function sed_log($text, $group='def')
{
global $db_logger, $sys, $usr, $_SERVER;

$sql = sed_sql_query("INSERT INTO $db_logger (log_date, log_ip, log_name, log_group, log_text) VALUES (".(int)$sys['now_offset'].", '".$usr['ip']."', '".sed_sql_prep($usr['name'])."', '$group', '".sed_sql_prep($text.' - '.$_SERVER['REQUEST_URI'])."')");
return;
}

/* ------------------ */

function sed_log_sed_import($s, $e, $v, $o)
{
$text = "A variable type check failed, expecting ".$s."/".$e." for '".$v."' : ".$o;
sed_log($text, 'sec');
return;
}

/* ------------------ */

function sed_mail($fmail, $subject, $body, $headers='')
{
global $cfg;

if(empty($fmail))
{
return(FALSE);
}
else
{
$headers = (empty($headers)) ? "From: \"".$cfg['maintitle']."\" <".$cfg['adminemail'].">\n"."Reply-To: <".$cfg['adminemail'].">\n"."Content-Type: text/plain; charset=".$cfg['charset']."\n" : $headers;
$body .= "\n\n".$cfg['maintitle']." - ".$cfg['mainurl']."\n".$cfg['subtitle'];
mail($fmail, $subject, $body, $headers);
sed_stat_inc('totalmailsent');
return(TRUE);
}
}

/* ------------------ */

function sed_mktime($hour = false, $minute = false, $second = false, $month = false, $date = false, $year = false)
{
// Code from http://www.php.net/date
// Author rickenmeer at hotmail dot com
// 12-Jan-2004 12:30

if ($hour === false) $hour = Date ('G');
if ($minute === false) $minute = Date ('i');
if ($second === false) $second = Date ('s');
if ($month === false) $month = Date ('n');
if ($date === false) $date = Date ('j');
if ($year === false) $year = Date ('Y');

if ($year >= 1970) return mktime ($hour, $minute, $second, $month, $date, $year);

$m_days = Array (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if ($year % 4 == 0 && (�