First thing - you should escape your template inserts with $db->escape_string()
Secondly, for your language issue:
ZiNga BuRgA Wrote:The file inc/languages/turkish/admin/advportal.lang.php doesn't exist. So what language file does exist?
Here's some fixed code (language thing not fixed):
function advportal_activate()
{
global $db, $lang, $mybb;
advportal();
$advportal_group = array(
"gid" => "NULL",
"name" => "advportal",
"title" => "Advanced Portal Settings",
"description" => "Settings",
"disporder" => "1",
"isdefault" => "no",
);
$db->insert_query(TABLE_PREFIX."settinggroups", $advportal_group);
$gid = $db->insert_id();
// Ayarlar
$advportal_1 = array(
"sid" => "NULL",
"name" => "advportal_item_lenght",
"title" => "Maximum Length For Subject Titles",
"description" => "How many characters do you want to set as maximum? If 0,it is free.",
"optionscode" => "text",
"value" => "0",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $advportal_1);
$advportal_2 = array(
"sid" => "NULL",
"name" => "advportal_max",
"title" => "How Many Threads",
"description" => "How Many Threads do you want to show?",
"optionscode" => "text",
"value" => "15",
"disporder" => "2",
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $advportal_2);
// Sablon Güncellemesi
require MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("footer", '#<!-- End copyright -->#', "<br>MyBB Advanced Portal by <a href=\"http://www.miqrop.net\"><b>eN-S</b></a>\n<!-- End copyright -->");
find_replace_templatesets("portal", '#{\$stats}#', "\n");
find_replace_templatesets("portal", '#{\$latestthreads}#', "\n");
find_replace_templatesets("portal", '#{\$whosonline}#', "\n");
find_replace_templatesets("portal", '#{\$announcements}#', "{\$announcements}\n{\$advportal}\n{\$whosonline}\n{\$stats}");
// Yeni Sablon Yaratimi
$templatearray = array(
"tid" => "NULL",
"title" => "portal_advportal",
"template" => $db->escape_string("
<td valign=\"top\">
<table align=\"center\" valign=\"top\" width=\"900\">
<tr class=\"thead\" width=\"900\">
<td align=\"left\"><b>{\$lang->advportal_lastposts}</b></td>\n
</tr>\n
<tr class=\"tcat\">\n
<td align=\"left\" width=\"50%\"><b>{\$lang->advportal_subject}</b></td>\n
<td align=\"right\" width=\"13%\"><b>{\$lang->advportal_author}</b></td>\n
<td align=\"center\" width=\"19%\"><b>{\$lang->advportal_poster}</b></td>\n
<td align=\"right\" width=\"9%\"><b>{\$lang->advportal_views}</b></td>\n
<td align=\"right\" width=\"9%\"><b>{\$lang->advportal_replies}</b></td>\n
</tr>{\$advportal_ek}</table></td>"),
"sid" => "-1",
);
$db->insert_query(TABLE_PREFIX."templates", $templatearray);
$templatearray = array(
"tid" => "NULL",
"title" => "portal_advportal_ek",
"template" => $db->escape_string("<tr class=\"trow1\" width=\"900\" height=\"40\">
<td align=\"left\" valign=\"top\" width=\"50%\"><a href=\"showthread.php?tid={\$tid}\" title=\"{\$subject}\"><b>{\$subject}</b></a></td>
<td align=\"right\" valign=\"top\" width=\"13%\">\{\$author}</td>
<td align=\"center\" valign=\"top\" width=\"19%\"><a href=\"member.php?action=profile&uid={\$uid}\"><b>{\$username}</b></a></td>
<td align=\"right\" valign=\"top\" width=\"13%\">{\$views}</a></td>
<td align=\"right\" valign=\"top\" width=\"13%\">{\$replies}</td>
</tr>"),
"sid" => "-1",
);
$db->insert_query(TABLE_PREFIX."templates", $templatearray);
// Dil paketi yüklenmesi
$lang->load("advportal");
// settings.php yi yeniden Yapilandir
rebuild_settings();
}
function advportal()
{
global $db, $mybb, $cache, $templates, $theme, $lang, $advportal, $advportal_ek, $unviewwhere;
// Tüm Degiskenler
if(!$mybb->settings['advportal_max'])
{
$mybb->settings['advportal_max'] = 20;
}
if(!$length)
{
$length = 10;
}
$query = $db->query ("SELECT subject,username,uid,pid,tid FROM ".TABLE_PREFIX."posts WHERE visible='1' ".get_unviewable()." ORDER BY dateline DESC LIMIT 0,".$mybb->settings['advportal_max']."");
$query2 = $db->query ("SELECT subject,username,uid,tid,replies FROM ".TABLE_PREFIX."threads WHERE visible='1' ".get_unviewable()." ORDER BY dateline DESC LIMIT 0,".$mybb->settings['advportal_max']."");
$newest_posts = $db->fetch_array($query);
$newest_thread = $db->fetch_array($query2);
$tid = $newest_posts['tid'];
$uid = $newest_posts['uid'];
$username = $newest_posts['username'];
$author = $newest_thread['username'];
$replies = $newest_posts['replies'];
$subject = $newest_posts['subject'];
$views = $newest_posts['views'];
// Sablon Degiskenlerinin Tanimlanmasi
eval("\$advportal = \"".$templates->get("portal_advportal")."\";");
eval("\$advportal_ek = \"".$templates->get("portal_advportal_ek")."\";");
// Uzunluk Degeri
$length = $mybb->settings['advportal_item_lenght'];
$width = $mybb->settings['advportal_width'];
if ($length != 0)
{
if (strlen($subject) > $length)
{
$subject = substr($subject,0,$length) . "...";
}
}
return $subject;
}
function get_unviewable() {
$unviewable = get_unviewable_forums();
if($unviewable)
{
$unviewwhere = " AND fid NOT IN ($unviewable)";
}
}