function TPCredits() { tp_hidebars(); $context['TPortal']['not_forum'] = false; if (loadLanguage('TPhelp') == false) { loadLanguage('TPhelp', 'english'); } loadtemplate('TPhelp'); }
function TPortalDLAdmin() { global $txt, $scripturl, $boarddir, $boardurl, $smcFunc, $context, $settings, $sourcedir; // check permissions if (isset($_POST['dl_useredit'])) { checkSession('post'); } else { isAllowedTo('tp_dlmanager'); } // add visual options to this section $dl_visual = explode(',', $context['TPortal']['dl_visual_options']); $dv = array('left', 'right', 'center', 'top', 'bottom', 'lower'); foreach ($dv as $v => $val) { if (in_array($val, $dl_visual)) { $context['TPortal'][$val . 'panel'] = '1'; $context['TPortal']['dl_' . $val] = '1'; } else { $context['TPortal'][$val . 'panel'] = '0'; } } if (in_array('showtop', $dl_visual)) { $context['TPortal']['showtop'] = true; $context['TPortal']['dl_top'] = true; } else { $context['TPortal']['showtop'] = false; } if ($context['TPortal']['hidebars_admin_only'] == '1') { tp_hidebars(); } // fetch membergroups so we can quickly set permissions // dlmanager, dlupload, dlcreatetopic $context['TPortal']['perm_all_groups'] = get_grps(); $context['TPortal']['perm_groups'] = tp_fetchpermissions(array('tp_dlmanager', 'tp_dlupload', 'tp_dlcreatetopic')); $context['TPortal']['boards'] = tp_fetchboards(); $context['TPortal']['all_dlitems'] = array(); $request = $smcFunc['db_query']('', ' SELECT id, name FROM {db_prefix}tp_dlmanager WHERE type = {string:type} ORDER BY name ASC', array('type' => 'dlitem')); if ($smcFunc['db_num_rows']($request) > 0) { while ($row = $smcFunc['db_fetch_assoc']($request)) { $context['TPortal']['all_dlitems'][] = array('id' => $row['id'], 'name' => $row['name']); } $smcFunc['db_free_result']($request); } // Add in BBC editor before we call in template so the headers are there if ($context['TPortal']['dl_wysiwyg'] == 'bbc') { if ($context['TPortal']['dlsub'] == 'adminaddcat') { $context['TPortal']['editor_id'] = 'newdladmin_text'; TP_prebbcbox($context['TPortal']['editor_id']); } else { $context['TPortal']['editor_id'] = 'tp_dl_introtext'; TP_prebbcbox($context['TPortal']['editor_id'], $context['TPortal']['dl_introtext']); } } // any items from the ftp screen? if (!empty($_POST['ftpdlsend'])) { // new category? if (!empty($_POST['assign-ftp-newcat'])) { $newcat = true; $newcatname = $_POST['assign-ftp-newcat']; if (isset($_POST['assign-ftp-cat']) && $_POST['assign-ftp-cat'] > 0) { $newcatparent = $_POST['assign-ftp-cat']; } else { $newcatparent = 0; } if ($newcatname == '') { $newcatname = '-no name-'; } } else { $newcat = false; $newcatname = ''; $newcatnow = $_POST['assign-ftp-cat']; $newcatparent = 0; } // if new category create it first. if ($newcat) { $request = $smcFunc['db_insert']('INSERT', '{db_prefix}tp_dlmanager', array('name' => 'string', 'description' => 'string', 'icon' => 'string', 'category' => 'int', 'type' => 'string', 'downloads' => 'int', 'views' => 'int', 'file' => 'string', 'created' => 'int', 'last_access' => 'int', 'filesize' => 'int', 'parent' => 'int', 'access' => 'string', 'link' => 'string', 'author_id' => 'int', 'screenshot' => 'string', 'rating' => 'string', 'voters' => 'string', 'subitem' => 'int'), array($newcatname, '', '', 0, 'dlcat', 0, 0, '', 0, 0, 0, $newcatparent, '', '', $context['user']['id'], '', '', '', 0), array('id')); $newcatnow = $smcFunc['db_insert_id']($request); } // now go through each file and put it into the table. foreach ($_POST as $what => $value) { if (substr($what, 0, 19) == 'assign-ftp-checkbox') { $name = $value; $now = time(); $fsize = filesize($boarddir . '/tp-downloads/' . $value); $smcFunc['db_insert']('INSERT', '{db_prefix}tp_dlmanager', array('name' => 'string', 'description' => 'string', 'icon' => 'string', 'category' => 'int', 'type' => 'string', 'downloads' => 'int', 'views' => 'int', 'file' => 'string', 'created' => 'int', 'last_access' => 'int', 'filesize' => 'int', 'parent' => 'int', 'access' => 'string', 'link' => 'string', 'author_id' => 'int', 'screenshot' => 'string', 'rating' => 'string', 'voters' => 'string', 'subitem' => 'int'), array($name, '', '', $newcatnow, 'dlitem', 1, 1, $value, $now, $now, $fsize, 0, '', '', $context['user']['id'], '', '', '', 0), array('id')); } } // done, set a value to make member aware of assigned category redirectexit('action=tpmod;dl=adminftp;ftpcat=' . $newcatnow); } // check for new category if (!empty($_POST['newdlsend'])) { // get the items $name = strip_tags($_POST['newdladmin_name']); // no html here if (empty($name)) { $name = $txt['tp-dlnotitle']; } $text = $_POST['newdladmin_text']; $parent = $_POST['newdladmin_parent']; $icon = $boardurl . '/tp-downloads/icons/' . $_POST['newdladmin_icon']; // special case, the access $dlgrp = array(); foreach ($_POST as $what => $value) { if (substr($what, 0, 16) == 'newdladmin_group') { $vv = substr($what, 16); if ($vv != '-2') { $dlgrp[] = $vv; } } } $access = implode(',', $dlgrp); // insert the category $request = $smcFunc['db_insert']('INSERT', '{db_prefix}tp_dlmanager', array('name' => 'string', 'description' => 'string', 'icon' => 'string', 'category' => 'int', 'type' => 'string', 'downloads' => 'int', 'views' => 'int', 'file' => 'string', 'created' => 'int', 'last_access' => 'int', 'filesize' => 'int', 'parent' => 'int', 'access' => 'string', 'link' => 'string', 'author_id' => 'int', 'screenshot' => 'string', 'rating' => 'string', 'voters' => 'string', 'subitem' => 'int'), array($name, $text, $icon, 0, 'dlcat', 0, 0, '', 0, 0, 0, $parent, $access, '', $context['user']['id'], '', '', '', 0), array('id')); $newcat = $smcFunc['db_insert_id']($request); redirectexit('action=tpmod;dl=admineditcat' . $newcat); } $myid = 0; // check if tag links are present if (isset($_POST['dladmin_itemtags'])) { $itemid = $_POST['dladmin_itemtags']; // get title $request = $smcFunc['db_query']('', ' SELECT name FROM {db_prefix}tp_dlmanager WHERE id = {int:item} LIMIT 1', array('item' => $itemid)); $title = $smcFunc['db_fetch_row']($request); // remove old ones first $smcFunc['db_query']('', ' DELETE FROM {db_prefix}tp_variables WHERE value3 = {string:val3} AND subtype2 = {int:sub}', array('val3' => 'dladmin_itemtags', 'sub' => $itemid)); $alltags = array(); foreach ($_POST as $what => $value) { // a tag from edit items if (substr($what, 0, 17) == 'dladmin_itemtags_') { $tag = substr($what, 17); $itemid = $value; // insert new one $href = '?action=tpmod;dl=item' . $itemid; $tg = '<span style="background: url(' . $settings['tp_images_url'] . '/glyph_download.png) no-repeat;" class="taglink">' . $title[0] . '</span>'; if (!empty($tag)) { $smcFunc['db_query']('INSERT', '{db_prefix}tp_variables', array('value1' => 'string', 'value2' => 'string', 'value3' => 'string', 'type' => 'string', 'value4' => 'string', 'value5' => 'int', 'subtype' => 'string', 'value7' => 'string', 'value8' => 'string', 'subtype2' => 'int'), array($href, $tg, 'dladmin_itemtags', '', 0, $tag, '', '', $itemid), array('id')); $alltags[] = $tag; } } } $tg = implode(',', $alltags); $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET global_tag = {string:tag} WHERE id = {int:item}', array('tag' => $tg, 'item' => $itemid)); $myid = $itemid; $go = 2; $newgo = 2; } // check if tag links are present -categories if (isset($_POST['dladmin_cattags'])) { $itemid = $_POST['dladmin_cattags']; // get title $request = $smcFunc['db_query']('', ' SELECT name FROM {db_prefix}tp_dlmanager WHERE id = {int:item} LIMIT 1', array('item' => $itemid)); $title = $smcFunc['db_fetch_row']($request); // remove old ones first $smcFunc['db_query']('', ' DELETE FROM {db_prefix}tp_variables WHERE value3 = {string:val3} AND subtype2 = {int:sub}', array('val3' => 'dladmin_cattags', 'sub' => $itemid)); foreach ($_POST as $what => $value) { // a tag from edit category if (substr($what, 0, 16) == 'dladmin_cattags_') { $tag = substr($what, 16); $itemid = $value; // insert new one $href = '?action=tpmod;dl=cat' . $itemid; $title = $title[0] . ' [' . strtolower($txt['tp-downloads']) . '] '; $smcFunc['db_query']('INSERT', '{db_prefix}tp_variables', array('value1' => 'string', 'value2' => 'string', 'value3' => 'string', 'type' => 'string', 'value4' => 'string', 'value5' => 'int', 'subtype' => 'string', 'value7' => 'string', 'value8' => 'string', 'subtype2' => 'int'), array($href, $title, 'dladmin_cattags', '', 0, $tag, '', '', $itemid), array('id')); } } $myid = $itemid; $go = 3; $newgo = 3; } // check for access value if (!empty($_POST['dlsend'])) { $admgrp = array(); $groupset = false; $dlgrp = array(); $dlset = false; $visual = array(); $visualset = false; $creategrp = array(); $dlmanager_grp = array(); $dlupload_grp = array(); $dlcreatetopic_grp = array(); // Our settings array to send to updateTPSettings(); $changeArray = array(); foreach ($_POST as $what => $value) { if (substr($what, 0, 13) == 'dladmin_group') { $val = substr($what, 13); if ($val != '-2') { $admgrp[] = $val; } $groupset = true; $id = $value; } elseif (substr($what, 0, 8) == 'tp_group') { if ($value != '-2') { $dlgrp[] = $value; } $dlset = true; } elseif (substr($what, 0, 20) == 'tp_dl_visual_options') { if ($value != 'not') { $visual[] = $value; } $visualset = true; } elseif (substr($what, 0, 11) == 'tp_dlboards') { $creategrp[] = $value; } } if ($groupset) { $dlaccess = implode(',', $admgrp); $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET access = {string:access} WHERE id = {int:item}', array('access' => $dlaccess, 'item' => $id)); } if (!empty($_POST['dlsettings'])) { $changeArray['dl_createtopic_boards'] = implode(',', $creategrp); } if ($dlset) { $changeArray['dl_approve_groups'] = implode(',', $dlgrp); } if ($visualset) { $changeArray['dl_visual_options'] = implode(',', $visual); } $go = 0; if (!empty($_FILES['qup_dladmin_text']['tmp_name']) && (file_exists($_FILES['qup_dladmin_text']['tmp_name']) || is_uploaded_file($_FILES['qup_dladmin_text']['tmp_name']))) { $name = TPuploadpicture('qup_dladmin_text', $context['user']['id'] . 'uid'); tp_createthumb('tp-images/' . $name, 50, 50, 'tp-images/thumbs/thumb_' . $name); } if (!empty($_FILES['qup_blockbody']['tmp_name']) && (file_exists($_FILES['qup_dladmin_text']['tmp_name']) || is_uploaded_file($_FILES['qup_dladmin_text']['tmp_name']))) { $name = TPuploadpicture('qup_dladmin_text', $context['user']['id'] . 'uid'); tp_createthumb('tp-images/' . $name, 50, 50, 'tp-images/thumbs/thumb_' . $name); } // a screenshot from edit item screen? if (!empty($_FILES['tp_dluploadpic_edit']['tmp_name']) && (file_exists($_FILES['tp_dluploadpic_edit']['tmp_name']) || is_uploaded_file($_FILES['tp_dluploadpic_edit']['tmp_name']))) { $shot = true; } else { $shot = false; } if ($shot) { $sid = $_POST['tp_dluploadpic_editID']; $sfile = 'tp_dluploadpic_edit'; $uid = $context['user']['id'] . 'uid'; $dim = '1800'; $suf = 'jpg,gif,png'; $dest = 'tp-images/dlmanager'; $sname = TPuploadpicture($sfile, $uid, $dim, $suf, $dest); $screenshot = $sname; tp_createthumb($dest . '/' . $sname, $context['TPortal']['dl_screenshotsize'][0], $context['TPortal']['dl_screenshotsize'][1], $dest . '/thumb/' . $sname); tp_createthumb($dest . '/' . $sname, $context['TPortal']['dl_screenshotsize'][2], $context['TPortal']['dl_screenshotsize'][3], $dest . '/listing/' . $sname); tp_createthumb($dest . '/' . $sname, $context['TPortal']['dl_screenshotsize'][4], $context['TPortal']['dl_screenshotsize'][5], $dest . '/single/' . $sname); $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET screenshot = {string:ss} WHERE id = {int:item}', array('ss' => $screenshot, 'item' => $sid)); $uploaded = true; } else { $screenshot = ''; $uploaded = false; } if (isset($_POST['tp_dluploadpic_link']) && !$uploaded) { $sid = $_POST['tp_dluploadpic_editID']; $screenshot = $_POST['tp_dluploadpic_link']; $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET screenshot = {string:ss} WHERE id = {int:item}', array('ss' => $screenshot, 'item' => $sid)); } else { $screenshot = ''; } // a new file uploaded? if (!empty($_FILES['tp_dluploadfile_edit']['tmp_name']) && is_uploaded_file($_FILES['tp_dluploadfile_edit']['tmp_name'])) { $shot = true; } else { $shot = false; } if ($shot) { $sid = $_POST['tp_dluploadfile_editID']; $shotname = $_FILES['tp_dluploadfile_edit']['name']; $sname = strtr($shotname, 'ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'); $sname = strtr($sname, array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u')); $sname = preg_replace(array('/\\s/', '/[^\\w_\\.\\-]/'), array('_', ''), $sname); $sname = time() . $sname; // check the size $dlfilesize = filesize($_FILES['tp_dluploadfile_edit']['tmp_name']); if ($dlfilesize > 1000 * $context['TPortal']['dl_max_upload_size']) { unlink($_FILES['tp_dluploadfile_edit']['tmp_name']); $error = $txt['tp-dlmaxerror'] . ' ' . $context['TPortal']['dl_max_upload_size'] . ' Kb<br /><br />' . $txt['tp-dlmaxerror2'] . ': ' . ceil($dlfilesize / 1000) . ' Kb'; fatal_error($error); } // check the extension $allowed = explode(',', $context['TPortal']['dl_allowed_types']); $match = false; foreach ($allowed as $extension => $value) { $ext = '.' . $value; $extlen = strlen($ext); if (substr($sname, strlen($sname) - $extlen, $extlen) == $ext) { $match = true; } } if (!$match) { unlink($_FILES['tp_dluploadfile_edit']['tmp_name']); $error = $txt['tp-dlexterror'] . ':<b> <br />' . $context['TPortal']['dl_allowed_types'] . '</b><br /><br />' . $txt['tp-dlexterror2'] . ': <b>' . $sname . '</b>'; fatal_error($error); } $success2 = move_uploaded_file($_FILES['tp_dluploadfile_edit']['tmp_name'], $boarddir . '/tp-downloads/' . $sname); $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET file = {string:file} WHERE id = {int:item}', array('file' => $sname, 'item' => $sid)); $new_upload = true; // update filesize as well $value = filesize($boarddir . '/tp-downloads/' . $sname); if (!is_numeric($value)) { $value = 0; } $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET filesize = {int:size} WHERE id = {int:item}', array('size' => $value, 'item' => $sid)); $myid = $sid; $go = 2; } // get all values from forms foreach ($_POST as $what => $value) { if (substr($what, 0, 12) == 'dladmin_name') { $id = substr($what, 12); // no html here $value = strip_tags($value); if (empty($value)) { $value = '-no title-'; } $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET name = {string:name} WHERE id = {int:item}', array('name' => $value, 'item' => $id)); } elseif (substr($what, 0, 12) == 'dladmin_icon') { $id = substr($what, 12); if ($value != '') { $val = $boardurl . '/tp-downloads/icons/' . $value; $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET icon = {string:icon} WHERE id = {int:item}', array('icon' => $val, 'item' => $id)); } } elseif (substr($what, 0, 12) == 'dladmin_text') { $id = substr($what, 12); if (is_numeric($id)) { // If we came from WYSIWYG then turn it back into BBC regardless. if (!empty($_REQUEST[$what . '_mode']) && isset($_REQUEST[$what])) { require_once $sourcedir . '/Subs-Editor.php'; $_REQUEST[$what] = html_to_bbc($_REQUEST[$what]); // We need to unhtml it now as it gets done shortly. $_REQUEST[$what] = un_htmlspecialchars($_REQUEST[$what]); // We need this for everything else. $value = $_POST[$what] = $_REQUEST[$what]; } if (isset($_POST['dladmin_text' . $id . '_pure']) && isset($_POST['dladmin_text' . $id . '_choice'])) { if ($_POST['dladmin_text' . $id . '_choice'] == 1) { $value = $_POST['dladmin_text' . $id]; } else { $value = $_POST['dladmin_text' . $id . '_pure']; } } $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET description = {string:desc} WHERE id = {int:item}', array('desc' => $value, 'item' => $id)); } } elseif (substr($what, 0, 14) == 'dladmin_delete') { $id = substr($what, 14); $request = $smcFunc['db_query']('', ' SELECT * FROM {db_prefix}tp_dlmanager WHERE id = {int:item}', array('item' => $id)); if ($smcFunc['db_num_rows']($request) > 0) { $row = $smcFunc['db_fetch_assoc']($request); if ($row['type'] == 'dlitem') { $category = $row['category']; if ($category > 0) { $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET downloads = downloads - 1 WHERE id = {int:cat} LIMIT 1', array('cat' => $category)); } // delete both screenshot and file if (!empty($row['file']) && file_exists($boarddir . '/tp-downloads/' . $row['file'])) { $succ = unlink($boarddir . '/tp-downloads/' . $row['file']); if (!$succ) { $err = $txt['tp-dlfilenotdel'] . ' (' . $row['file'] . ')'; } } if (!empty($row['screenshot']) && file_exists($boarddir . '/' . $row['screenshot'])) { $succ2 = unlink($boarddir . '/' . $row['screenshot']); if (!$succ2) { $err .= '<br />' . $txt['tp-dlssnotdel'] . ' (' . $row['screenshot'] . ')'; } } } $smcFunc['db_free_result']($request); } $smcFunc['db_query']('', ' DELETE FROM {db_prefix}tp_dlmanager WHERE id = {int:item}', array('item' => $id)); if (isset($err)) { fatal_error($err); } redirectexit('action=tpmod;dl=admincat' . $category); } elseif (substr($what, 0, 15) == 'dladmin_approve' && $value == 'ON') { $id = abs(substr($what, 15)); $request = $smcFunc['db_query']('', ' SELECT category FROM {db_prefix}tp_dlmanager WHERE id = {int:item}', array('item' => $id)); if ($smcFunc['db_num_rows']($request) > 0) { $row = $smcFunc['db_fetch_row']($request); $newcat = abs($row[0]); $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET category = {int:cat} WHERE id = {int:item}', array('cat' => $newcat, 'item' => $id)); $smcFunc['db_query']('', ' DELETE FROM {db_prefix}tp_variables WHERE type = {string:type} AND value5 = {int:val5}', array('type' => 'dl_not_approved', 'val5' => $id)); $smcFunc['db_free_result']($request); } } elseif (substr($what, 0, 16) == 'dl_admin_approve' && $value == 'ON') { $id = abs(substr($what, 16)); $request = $smcFunc['db_query']('', ' SELECT category FROM {db_prefix}tp_dlmanager WHERE id = {int:item}', array('item' => $id)); if ($smcFunc['db_num_rows']($request) > 0) { $row = $smcFunc['db_fetch_row']($request); $newcat = abs($row[0]); $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET category = {int:cat} WHERE id = {int:item}', array('cat' => $newcat, 'item' => $id)); $smcFunc['db_query']('', ' DELETE FROM {db_prefix}tp_variables WHERE type = {string:type} AND value5 = {int:val5}', array('type' => 'dl_not_approved', 'val5' => $id)); $smcFunc['db_free_result']($request); } } elseif (substr($what, 0, 16) == 'dladmin_category') { $id = substr($what, 16); // update, but not on negative values :) if ($value > 0) { $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET category = {int:cat} WHERE id = {int:item}', array('cat' => $value, 'item' => $id)); } } elseif (substr($what, 0, 14) == 'dladmin_parent') { $id = substr($what, 14); $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET parent = {int:parent} WHERE id = {int:item}', array('parent' => $value, 'item' => $id)); } elseif (substr($what, 0, 15) == 'dladmin_subitem') { $id = substr($what, 15); $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET subitem = {int:sub} WHERE id = {int:item}', array('sub' => $value, 'item' => $id)); } elseif (substr($what, 0, 11) == 'tp_dlcatpos') { $id = substr($what, 11); if (!empty($_POST['admineditcatval'])) { $myid = $_POST['admineditcatval']; $go = 4; } $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET downloads = {int:down} WHERE id = {int:item}', array('down' => $value, 'item' => $id)); } elseif (substr($what, 0, 18) == 'dladmin_screenshot') { $id = substr($what, 18); $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET screenshot = {string:ss} WHERE id = {int:item}', array('ss' => $value, 'item' => $id)); } elseif (substr($what, 0, 12) == 'dladmin_link') { $id = substr($what, 12); $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET link = {string:link} WHERE id = {int:item}', array('link' => $value, 'item' => $id)); } elseif (substr($what, 0, 12) == 'dladmin_file' && !isset($new_upload)) { $id = substr($what, 12); $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET file = {string:file} WHERE id = {int:item}', array('file' => $value, 'item' => $id)); $myid = $id; $go = 2; } elseif (substr($what, 0, 12) == 'dladmin_size' && !isset($new_upload)) { $id = substr($what, 12); // check the actual size $name = $_POST['dladmin_file' . $id]; $value = filesize($boarddir . '/tp-downloads/' . $name); if (!is_numeric($value)) { $value = 0; } $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_dlmanager SET filesize = {int:size} WHERE id = {int:item}', array('size' => $value, 'item' => $id)); } elseif ($what == 'tp_dl_allowed_types') { $changeArray['dl_allowed_types'] = $value; $go = 1; } elseif ($what == 'tp_dl_usescreenshot') { $changeArray['dl_usescreenshot'] = $value; $go = 1; } elseif (substr($what, 0, 20) == 'tp_dl_screenshotsize') { // which one $who = substr($what, 20); $result = $smcFunc['db_query']('', ' SELECT value FROM {db_prefix}tp_settings WHERE name = {string:name} LIMIT 1', array('name' => 'dl_screenshotsizes')); $row = $smcFunc['db_fetch_assoc']($result); $smcFunc['db_free_result']($result); $all = explode(',', $row['value']); $all[$who] = $value; $changeArray['dl_screenshotsizes'] = implode(',', $all); $go = 1; } elseif ($what == 'tp_dl_showfeatured') { $changeArray['dl_showfeatured'] = $value; $go = 1; } elseif ($what == 'tp_dl_wysiwyg') { $changeArray['dl_wysiwyg'] = $value; $go = 1; } elseif ($what == 'tp_dl_showrecent') { $changeArray['dl_showlatest'] = $value; $go = 1; } elseif ($what == 'tp_dl_showstats') { $changeArray['dl_showstats'] = $value; $go = 1; } elseif ($what == 'tp_dl_showcategorytext') { $changeArray['dl_showcategorylist'] = $value; $go = 1; } elseif ($what == 'tp_dl_featured') { $changeArray['dl_featured'] = $value; $go = 1; } elseif ($what == 'tp_dl_introtext') { if ($context['TPortal']['dl_wysiwyg'] == 'bbc') { // If we came from WYSIWYG then turn it back into BBC regardless. if (!empty($_REQUEST['tp_dl_introtext']) && isset($_REQUEST['tp_dl_introtext'])) { require_once $sourcedir . '/Subs-Editor.php'; $_REQUEST['tp_dl_introtext'] = html_to_bbc($_REQUEST['tp_dl_introtext']); // We need to unhtml it now as it gets done shortly. $_REQUEST['tp_dl_introtext'] = un_htmlspecialchars($_REQUEST['tp_dl_introtext']); // We need this for everything else. $value = $_POST['tp_dl_introtext'] = $_REQUEST['tp_dl_introtext']; } } $changeArray['dl_introtext'] = trim($value); $go = 1; } elseif ($what == 'tp_dluploadsize') { $changeArray['dl_max_upload_size'] = $value; $go = 1; } elseif ($what == 'tp_dl_approveonly') { $changeArray['dl_approve'] = $value; $go = 1; } elseif ($what == 'tp_dlallowupload') { $changeArray['dl_allow_upload'] = $value; $go = 1; } elseif ($what == 'tp_dl_fileprefix') { $changeArray['dl_fileprefix'] = $value; $go = 1; } elseif ($what == 'tp_dltheme') { $changeArray['dlmanager_theme'] = $value; $go = 1; } } // Update all the changes settings finally updateTPSettings($changeArray); // if we came from useredit screen.. if (isset($_POST['dl_useredit'])) { redirectexit('action=tpmod;dl=useredit' . $_POST['dl_useredit']); } if (!empty($newgo)) { $go = $newgo; } // guess not, admin screen then if ($go == 1) { redirectexit('action=tpmod;dl=adminsettings'); } elseif ($go == 2) { redirectexit('action=tpmod;dl=adminitem' . $myid); } elseif ($go == 3) { redirectexit('action=tpmod;dl=admineditcat' . $myid); } elseif ($go == 4) { redirectexit('action=tpmod;dl=admincat' . $myid); } } // **************** TP_dlgeticons(); // get all themes $context['TPthemes'] = array(); $request = $smcFunc['db_query']('', ' SELECT value AS name, id_theme as ID_THEME FROM {db_prefix}themes WHERE variable = {string:var} AND id_member = {int:id_mem} ORDER BY value ASC', array('var' => 'name', 'id_mem' => 0)); if ($smcFunc['db_num_rows']($request) > 0) { while ($row = $smcFunc['db_fetch_assoc']($request)) { $context['TPthemes'][] = array('id' => $row['ID_THEME'], 'name' => $row['name']); } $smcFunc['db_free_result']($request); } // fetch all files from tp-downloads $context['TPortal']['tp-downloads'] = array(); $count = 1; if ($handle = opendir($boarddir . '/tp-downloads')) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && $file != '.htaccess' && $file != 'icons') { $size = floor(filesize($boarddir . '/tp-downloads/' . $file) / 102.4) / 10; $context['TPortal']['tp-downloads'][$count] = array('id' => $count, 'file' => $file, 'size' => $size); $count++; } } closedir($handle); } // get all membergroups for permissions $context['TPortal']['dlgroups'] = get_grps(true, true); //fetch all categories $sorted = array(); $context['TPortal']['linkcats'] = array(); $srequest = $smcFunc['db_query']('', ' SELECT id, name, description, icon, access, parent FROM {db_prefix}tp_dlmanager WHERE type = {string:type} ORDER BY downloads ASC', array('type' => 'dlcat')); if ($smcFunc['db_num_rows']($srequest) > 0) { while ($row = $smcFunc['db_fetch_assoc']($srequest)) { // for the linktree $context['TPortal']['linkcats'][$row['id']] = array('id' => $row['id'], 'name' => $row['name'], 'parent' => $row['parent']); $sorted[$row['id']] = array('id' => $row['id'], 'parent' => $row['parent'], 'name' => $row['name'], 'text' => $row['description'], 'icon' => $row['icon']); } $smcFunc['db_free_result']($srequest); } // sort them if (count($sorted) > 1) { $context['TPortal']['admuploadcats'] = chain('id', 'parent', 'name', $sorted); } else { $context['TPortal']['admuploadcats'] = $sorted; } $context['TPortal']['dl_admcats'] = array(); $context['TPortal']['dl_admcats2'] = array(); $context['TPortal']['dl_admitems'] = array(); $context['TPortal']['dl_admcount'] = array(); $context['TPortal']['dl_admsubmitted'] = array(); $context['TPortal']['dl_allitems'] = array(); // count items in each category $request = $smcFunc['db_query']('', ' SELECT file, category FROM {db_prefix}tp_dlmanager WHERE type = {string:type}', array('type' => 'dlitem')); if ($smcFunc['db_num_rows']($request) > 0) { while ($row = $smcFunc['db_fetch_assoc']($request)) { if ($row['category'] < 0) { if (isset($context['TPortal']['dl_admsubmitted'][abs($row['category'])])) { $context['TPortal']['dl_admsubmitted'][abs($row['category'])]++; } else { $context['TPortal']['dl_admsubmitted'][abs($row['category'])] = 1; } } else { if (isset($context['TPortal']['dl_admcount'][$row['category']])) { $context['TPortal']['dl_admcount'][$row['category']]++; } else { $context['TPortal']['dl_admcount'][$row['category']] = 1; } } $context['TPortal']['dl_allitems'][] = $row['file']; } $smcFunc['db_free_result']($request); } // fetch all categories $admsub = substr($context['TPortal']['dlsub'], 5); if ($admsub == '') { $context['TPortal']['dl_title'] = $txt['tp-dladmin']; // fetch all categories with subcats $req = $smcFunc['db_query']('', ' SELECT * FROM {db_prefix}tp_dlmanager WHERE type = {string:type} ORDER BY downloads ASC', array('type' => 'dlcat')); if ($smcFunc['db_num_rows']($req) > 0) { while ($brow = $smcFunc['db_fetch_assoc']($req)) { if (isset($context['TPortal']['dl_admcount'][$brow['id']])) { $items = $context['TPortal']['dl_admcount'][$brow['id']]; } else { $items = 0; } if (isset($context['TPortal']['dl_admsubmitted'][$brow['id']])) { $sitems = $context['TPortal']['dl_admsubmitted'][$brow['id']]; } else { $sitems = 0; } $context['TPortal']['admcats'][] = array('id' => $brow['id'], 'name' => $brow['name'], 'icon' => $brow['icon'], 'access' => $brow['access'], 'parent' => $brow['parent'], 'description' => $brow['description'], 'shortname' => $brow['link'], 'items' => $items, 'submitted' => $sitems, 'total' => $items + $sitems, 'href' => $scripturl . '?action=tpmod;dl=admincat' . $brow['id'], 'href2' => $scripturl . '?action=tpmod;dl=admineditcat' . $brow['id'], 'href3' => $scripturl . '?action=tpmod;dl=admindelcat' . $brow['id'], 'pos' => $brow['downloads']); } $smcFunc['db_free_result']($req); } } elseif (substr($admsub, 0, 3) == 'cat') { $cat = substr($admsub, 3); // get the parent first $request = $smcFunc['db_query']('', ' SELECT parent, name, link FROM {db_prefix}tp_dlmanager WHERE type = {string:type} AND id = {int:item}', array('type' => 'dlcat', 'item' => $cat)); if ($smcFunc['db_num_rows']($request) > 0) { $row = $smcFunc['db_fetch_assoc']($request); $catparent = abs($row['parent']); $catname = $row['name']; $catshortname = $row['link']; $smcFunc['db_free_result']($request); } // fetch items within a category $request = $smcFunc['db_query']('', ' SELECT dl.*, dl.author_id as authorID,m.real_name as realName FROM ({db_prefix}tp_dlmanager AS dl, {db_prefix}members AS m) WHERE abs(dl.category) = {int:cat} AND dl.type = {string:type} AND dl.subitem = {int:sub} AND dl.author_id = m.id_member ORDER BY dl.id DESC', array('cat' => $cat, 'type' => 'dlitem', 'sub' => 0)); if ($smcFunc['db_num_rows']($request) > 0) { while ($row = $smcFunc['db_fetch_assoc']($request)) { $context['TPortal']['dl_admitems'][] = array('id' => $row['id'], 'name' => $row['name'], 'icon' => $row['icon'], 'category' => abs($row['category']), 'file' => $row['file'], 'filesize' => floor($row['filesize'] / 1024), 'views' => $row['views'], 'authorID' => $row['authorID'], 'author' => '<a href="' . $scripturl . '?action=profile;u=' . $row['authorID'] . '">' . $row['realName'] . '</a>', 'created' => timeformat($row['created']), 'last_access' => timeformat($row['last_access']), 'description' => $row['description'], 'downloads' => $row['downloads'], 'sshot' => $row['screenshot'], 'link' => $row['link'], 'href' => $scripturl . '?action=tpmod;dl=adminitem' . $row['id'], 'approved' => $row['category'] < 0 ? '0' : '1', 'approve' => $scripturl . '?action=tpmod;dl=adminapprove' . $row['id']); } $smcFunc['db_free_result']($request); } // fetch all categories with subcats $request = $smcFunc['db_query']('', ' SELECT * FROM {db_prefix}tp_dlmanager WHERE type = {string:type} ORDER BY name ASC', array('type' => 'dlcat')); if ($smcFunc['db_num_rows']($request) > 0) { while ($row = $smcFunc['db_fetch_assoc']($request)) { if (isset($context['TPortal']['dl_admcount'][$row['id']])) { $items = $context['TPortal']['dl_admcount'][$row['id']]; } else { $items = 0; } if (isset($context['TPortal']['dl_admsubmitted'][$row['id']])) { $sitems = $context['TPortal']['dl_admsubmitted'][$row['id']]; } else { $sitems = 0; } $context['TPortal']['admcats'][] = array('id' => $row['id'], 'name' => $row['name'], 'pos' => $row['downloads'], 'icon' => $row['icon'], 'shortname' => $row['link'], 'access' => $row['access'], 'parent' => $row['parent'], 'description' => $row['description'], 'items' => $items, 'submitted' => $sitems, 'total' => $items + $sitems, 'href' => $scripturl . '?action=tpmod;dl=admincat' . $row['id'], 'href2' => $scripturl . '?action=tpmod;dl=admineditcat' . $row['id'], 'href3' => $scripturl . '?action=tpmod;dl=admindelcat' . $row['id']); } $smcFunc['db_free_result']($request); } // check to see if its child $parents = array(); while ($catparent > 0) { $parents[$catparent] = array('id' => $catparent, 'name' => $context['TPortal']['linkcats'][$catparent]['name'], 'parent' => $context['TPortal']['linkcats'][$catparent]['parent']); $catparent = $context['TPortal']['linkcats'][$catparent]['parent']; } // make the linktree TPadd_linktree($scripturl . '?action=tpmod;dl=admin', $txt['tp-dladmin']); if (isset($parents)) { $parts = array_reverse($parents, TRUE); // add to the linktree foreach ($parts as $parent) { TPadd_linktree($scripturl . '?action=tpmod;dl=admincat' . $parent['id'], $parent['name']); } } // add to the linktree TPadd_linktree($scripturl . '?action=tpmod;dl=admincat' . $cat, $catname); } elseif ($context['TPortal']['dlsub'] == 'adminsubmission') { // check any submissions if admin $submitted = array(); isAllowedTo('tp_dlmanager'); $context['TPortal']['dl_admitems'] = array(); $request = $smcFunc['db_query']('', ' SELECT dl.id, dl.name, dl.file, dl.created, dl.filesize, dl.author_id as authorID, m.real_name as realName FROM ({db_prefix}tp_dlmanager AS dl, {db_prefix}members AS m) WHERE dl.type = {string:type} AND dl.category < 0 AND dl.author_id = m.id_member', array('type' => 'dlitem')); if ($smcFunc['db_num_rows']($request) > 0) { $rows = $smcFunc['db_num_rows']($request); while ($row = $smcFunc['db_fetch_assoc']($request)) { $context['TPortal']['dl_admitems'][] = array('id' => $row['id'], 'name' => $row['name'], 'file' => $row['file'], 'filesize' => floor($row['filesize'] / 1024), 'href' => $scripturl . '?action=tpmod;dl=adminitem' . $row['id'], 'author' => '<a href="' . $scripturl . '?action=profile;u=' . $row['authorID'] . '">' . $row['realName'] . '</a>', 'date' => timeformat($row['created'])); $submitted[] = $row['id']; } $smcFunc['db_free_result']($request); } // check that submissions link to downloads $request = $smcFunc['db_query']('', ' SELECT id,value5 FROM {db_prefix}tp_variables WHERE type = {string:type}', array('type' => 'dl_not_approved')); if ($smcFunc['db_num_rows']($request) > 0) { while ($row = $smcFunc['db_fetch_assoc']($request)) { $what = $row['id']; if (!in_array($row['value5'], $submitted)) { $smcFunc['db_query']('', ' DELETE FROM {db_prefix}tp_variables WHERE id = {int:item}', array('item' => $what)); } } $smcFunc['db_free_result']($request); } } elseif (substr($admsub, 0, 7) == 'editcat') { $context['TPortal']['dl_title'] = '<a href="' . $scripturl . '?action=tpmod;dl=admin">' . $txt['tp-dladmin'] . '</a>'; $cat = substr($admsub, 7); // edit category $request = $smcFunc['db_query']('', ' SELECT * FROM {db_prefix}tp_dlmanager WHERE id = {int:item} AND type = {string:type} LIMIT 1', array('item' => $cat, 'type' => 'dlcat')); if ($smcFunc['db_num_rows']($request) > 0) { while ($row = $smcFunc['db_fetch_assoc']($request)) { $context['TPortal']['admcats'][] = array('id' => $row['id'], 'name' => $row['name'], 'access' => $row['access'], 'shortname' => $row['link'], 'description' => $row['description'], 'icon' => $row['icon'], 'parent' => $row['parent']); } $smcFunc['db_free_result']($request); } if ($context['TPortal']['dl_wysiwyg'] == 'bbc') { $context['TPortal']['editor_id'] = 'dladmin_text' . $context['TPortal']['admcats'][0]['id']; TP_prebbcbox($context['TPortal']['editor_id'], $context['TPortal']['admcats'][0]['description']); } } elseif (substr($admsub, 0, 6) == 'delcat') { $context['TPortal']['dl_title'] = '<a href="' . $scripturl . '?action=tpmod;dl=admin">' . $txt['tp-dladmin'] . '</a>'; $cat = substr($admsub, 6); // delete category and all item it's in $request = $smcFunc['db_query']('', ' DELETE FROM {db_prefix}tp_dlmanager WHERE type = {string:type} AND category = {int:cat}', array('type' => 'dlitem', 'cat' => $cat)); $request = $smcFunc['db_query']('', ' DELETE FROM {db_prefix}tp_dlmanager WHERE id = {int:cat} LIMIT 1', array('cat' => $cat)); redirectexit('action=tpmod;dl=admin'); } elseif (substr($admsub, 0, 8) == 'settings') { $context['TPortal']['dl_title'] = $txt['tp-dlsettings']; } elseif (substr($admsub, 0, 4) == 'item') { $item = substr($admsub, 4); $request = $smcFunc['db_query']('', ' SELECT * FROM {db_prefix}tp_dlmanager WHERE id = {int:item} AND type = {string:type} LIMIT 1', array('item' => $item, 'type' => 'dlitem')); if ($smcFunc['db_num_rows']($request) > 0) { $row = $smcFunc['db_fetch_assoc']($request); // is it actually a subitem? if ($row['subitem'] > 0) { redirectexit('action=tpmod;dl=adminitem' . $row['subitem']); } // Add in BBC editor before we call in template so the headers are there if ($context['TPortal']['dl_wysiwyg'] == 'bbc') { $context['TPortal']['editor_id'] = 'dladmin_text' . $item; TP_prebbcbox($context['TPortal']['editor_id'], $row['description']); } // get all items for a list $context['TPortal']['admitems'] = array(); $itemlist = $smcFunc['db_query']('', ' SELECT id, name FROM {db_prefix}tp_dlmanager WHERE id != {int:item} AND type = {string:type} AND subitem = 0 ORDER BY name ASC', array('item' => $item, 'type' => 'dlitem')); if ($smcFunc['db_num_rows']($itemlist) > 0) { while ($ilist = $smcFunc['db_fetch_assoc']($itemlist)) { $context['TPortal']['admitems'][] = array('id' => $ilist['id'], 'name' => $ilist['name']); } } // Any additional files then..? $subitem = $row['id']; $fdata = array(); $fetch = $smcFunc['db_query']('', ' SELECT id, name, file, downloads, filesize, created FROM {db_prefix}tp_dlmanager WHERE type = {string:type} AND subitem = {int:sub}', array('type' => 'dlitem', 'sub' => $subitem)); if ($smcFunc['db_num_rows']($fetch) > 0) { while ($frow = $smcFunc['db_fetch_assoc']($fetch)) { if ($context['TPortal']['dl_fileprefix'] == 'K') { $ffs = ceil($row['filesize'] / 1000) . ' Kb'; } elseif ($context['TPortal']['dl_fileprefix'] == 'M') { $ffs = ceil($row['filesize'] / 1000) / 1000 . ' Mb'; } elseif ($context['TPortal']['dl_fileprefix'] == 'G') { $ffs = ceil($row['filesize'] / 1000000) / 1000 . ' Gb'; } $fdata[] = array('id' => $frow['id'], 'name' => $frow['name'], 'file' => $frow['file'], 'href' => $scripturl . '?action=tpmod;dl=item' . $frow['id'], 'downloads' => $frow['downloads'], 'created' => $frow['created'], 'filesize' => $ffs); } $smcFunc['db_free_result']($fetch); } if (!empty($row['screenshot'])) { if (substr($row['screenshot'], 0, 10) == 'tp-images/') { $sshot = $boardurl . '/' . $row['screenshot']; } else { $sshot = $boardurl . '/tp-images/dlmanager/listing/' . $row['screenshot']; } } $context['TPortal']['dl_admitems'][] = array('id' => $row['id'], 'name' => $row['name'], 'icon' => $row['icon'], 'category' => $row['category'], 'file' => $row['file'], 'views' => $row['views'], 'authorID' => $row['author_id'], 'description' => $row['description'], 'created' => timeformat($row['created']), 'last_access' => timeformat($row['last_access']), 'filesize' => substr($row['file'], 14) != '- empty item -' ? floor(filesize($boarddir . '/tp-downloads/' . $row['file']) / 1024) : '0', 'downloads' => $row['downloads'], 'sshot' => !empty($sshot) ? $sshot : '', 'screenshot' => $row['screenshot'], 'link' => $row['link'], 'href' => $scripturl . '?action=tpmod;dl=adminitem' . $row['id'], 'approved' => $row['category'] < 0 ? '0' : '1', 'approve' => $scripturl . '?action=tpmod;dl=adminitem' . $row['id'], 'subitem' => $fdata); $authorID = $row['author_id']; $catparent = $row['category']; $itemname = $row['name']; $smcFunc['db_free_result']($request); $request = $smcFunc['db_query']('', ' SELECT mem.real_name as realName FROM {db_prefix}members as mem WHERE mem.id_member = {int:id_mem}', array('id_mem' => $authorID)); if ($smcFunc['db_num_rows']($request) > 0) { $row = $smcFunc['db_fetch_assoc']($request); $context['TPortal']['admcurrent']['member'] = $row['realName']; $smcFunc['db_free_result']($request); } else { $context['TPortal']['admcurrent']['member'] = '-' . $txt['guest_title'] . '-'; } } // check to see if its child $parents = array(); while ($catparent > 0) { $parents[$catparent] = array('id' => $catparent, 'name' => $context['TPortal']['linkcats'][$catparent]['name'], 'parent' => $context['TPortal']['linkcats'][$catparent]['parent']); $catparent = $context['TPortal']['linkcats'][$catparent]['parent']; } // make the linktree TPadd_linktree($scripturl . '?action=tpmod;dl=admin', $txt['tp-dldownloads']); if (isset($parents)) { $parts = array_reverse($parents, TRUE); // add to the linktree foreach ($parts as $parent) { TPadd_linktree($scripturl . '?action=tpmod;dl=admincat' . $parent['id'], $parent['name']); } } // add to the linktree TPadd_linktree($scripturl . '?action=tpmod;dl=adminitem' . $item, $itemname); } loadTemplate('TPdladmin'); if (loadLanguage('TPmodules') == false) { loadLanguage('TPmodules', 'english'); } if (loadLanguage('TPortalAdmin') == false) { loadLanguage('TPortalAdmin', 'english'); } // setup admin tabs according to subaction $context['admin_area'] = 'tp_dlmanager'; $context['admin_tabs'] = array('title' => $txt['tp-dlheader1'], 'help' => $txt['tp-dlheader2'], 'description' => $txt['tp-dlheader3'], 'tabs' => array()); if (allowedTo('tp_dlmanager')) { $context['TPortal']['subtabs'] = array('admin' => array('text' => 'tp-dltabs4', 'url' => $scripturl . '?action=tpmod;dl=admin', 'active' => substr($context['TPortal']['dlsub'], 0, 5) == 'admin' && $context['TPortal']['dlsub'] != 'adminsettings' && $context['TPortal']['dlsub'] != 'adminaddcat' && $context['TPortal']['dlsub'] != 'adminftp' && $context['TPortal']['dlsub'] != 'adminsubmission'), 'settings' => array('text' => 'tp-dltabs1', 'url' => $scripturl . '?action=tpmod;dl=adminsettings', 'active' => $context['TPortal']['dlsub'] == 'adminsettings'), 'addcategory' => array('text' => 'tp-dltabs2', 'url' => $scripturl . '?action=tpmod;dl=adminaddcat', 'active' => $context['TPortal']['dlsub'] == 'adminaddcat'), 'upload' => array('text' => 'tp-dltabs3', 'url' => $scripturl . '?action=tpmod;dl=upload', 'active' => $context['TPortal']['dlsub'] == 'upload'), 'submissions' => array('text' => 'tp-dlsubmissions', 'url' => $scripturl . '?action=tpmod;dl=adminsubmission', 'active' => $context['TPortal']['dlsub'] == 'adminsubmission'), 'ftp' => array('text' => 'tp-dlftp', 'url' => $scripturl . '?action=tpmod;dl=adminftp', 'active' => $context['TPortal']['dlsub'] == 'adminftp')); } $context['template_layers'][] = 'tpadm'; $context['template_layers'][] = 'subtab'; TPadminIndex(''); $context['current_action'] = 'admin'; }
function tpshout_admin() { global $context, $scripturl, $txt, $smcFunc, $sourcedir; // check permissions isAllowedTo('tp_can_admin_shout'); if (!isset($context['tp_panels'])) { $context['tp_panels'] = array(); } if (isset($_GET['p']) && is_numeric($_GET['p'])) { $tpstart = $_GET['p']; } else { $tpstart = 0; } require_once $sourcedir . '/Subs-Post.php'; loadtemplate('TPShout'); $context['template_layers'][] = 'tpadm'; $context['template_layers'][] = 'subtab'; loadlanguage('TPortalAdmin'); TPadminIndex('shout', true); $context['current_action'] = 'admin'; if (isset($_REQUEST['send']) || isset($_REQUEST[$txt['tp-send']]) || isset($_REQUEST['tp_preview']) || isset($_REQUEST['TPadmin_blocks'])) { $go = 0; $changeArray = array(); foreach ($_POST as $what => $value) { if (substr($what, 0, 18) == 'tp_shoutbox_remove') { $val = substr($what, 18); $smcFunc['db_query']('', ' DELETE FROM {db_prefix}tp_shoutbox WHERE id = {int:shout}', array('shout' => $val)); $go = 2; } elseif (substr($what, 0, 18) == 'tp_shoutbox_hidden') { $val = substr($what, 18); if (!empty($_POST['tp_shoutbox_sticky' . $val])) { $value = '1'; } else { $value = ''; } if (!empty($_POST['tp_shoutbox_sticky_layout' . $val]) && is_numeric($_POST['tp_shoutbox_sticky_layout' . $val])) { $svalue = $_POST['tp_shoutbox_sticky_layout' . $val]; } else { $svalue = '0'; } $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_shoutbox SET value6 = "' . $value . '",value8 = "' . $svalue . '" WHERE id = {int:shout}', array('shout' => $val)); $go = 2; } elseif ($what == 'tp_shoutsdelall' && $value == 'ON') { $smcFunc['db_query']('', ' DELETE FROM {db_prefix}tp_shoutbox WHERE type = {string:type}', array('type' => 'shoutbox')); $go = 2; } elseif ($what == 'tp_shoutsunstickall' && $value == 'ON') { $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_shoutbox SET value6 = "0", value8 = "0" WHERE 1'); $go = 2; } elseif (substr($what, 0, 16) == 'tp_shoutbox_item') { $val = substr($what, 16); $bshout = $smcFunc['htmlspecialchars'](substr($value, 0, 300)); preparsecode($bshout); $smcFunc['db_query']('', ' UPDATE {db_prefix}tp_shoutbox SET value1 = {string:val1} WHERE id = {int:val}', array('val1' => $bshout, 'val' => $val)); $go = 2; } else { $what = substr($what, 3); if ($what == 'shoutbox_smile') { $changeArray['show_shoutbox_smile'] = $value; } if ($what == 'shoutbox_icons') { $changeArray['show_shoutbox_icons'] = $value; } if ($what == 'shoutbox_height') { $changeArray['shoutbox_height'] = $value; } if ($what == 'shoutbox_usescroll') { $changeArray['shoutbox_usescroll'] = $value; } if ($what == 'shoutbox_scrollduration') { if ($value > 5) { $value = 5; } elseif ($value < 1) { $value = 1; } $changeArray['shoutbox_scrollduration'] = $value; } if ($what == 'shoutbox_limit') { if (!is_numeric($value)) { $value = 10; } $changeArray['shoutbox_limit'] = $value; } if ($what == 'shoutbox_refresh') { if (empty($value)) { $value = '0'; } $changeArray['shoutbox_refresh'] = $value; } if ($what == 'show_profile_shouts') { $changeArray['profile_shouts_hide'] = $value; } if ($what == 'shout_allow_links') { $changeArray['shout_allow_links'] = $value; } if ($what == 'shoutbox_layout') { $changeArray['shoutbox_layout'] = $value; } if ($what == 'shout_submit_returnkey') { $changeArray['shout_submit_returnkey'] = $value; } if ($what == 'shoutbox_stitle') { $changeArray['shoutbox_stitle'] = $value; } } } updateTPSettings($changeArray, true); if (empty($go)) { redirectexit('action=tpmod;shout=admin;settings'); } else { redirectexit('action=tpmod;shout=admin'); } } // get latest shouts for admin section // check that a member has been filtered if (isset($_GET['u'])) { $memID = $_GET['u']; } // check that a IP has been filtered if (isset($_GET['ip'])) { $ip = $_GET['ip']; } if (isset($_GET['s'])) { $single = $_GET['s']; } $context['TPortal']['admin_shoutbox_items'] = array(); if (isset($memID)) { $shouts = $smcFunc['db_query']('', ' SELECT COUNT(*) FROM {db_prefix}tp_shoutbox WHERE type = {string:type} AND value5 = {int:val5} AND value7 = {int:val7}', array('type' => 'shoutbox', 'val5' => $memID, 'val7' => 0)); $weh = $smcFunc['db_fetch_row']($shouts); $smcFunc['db_free_result']($shouts); $allshouts = $weh[0]; $context['TPortal']['admin_shoutbox_items_number'] = $allshouts; $context['TPortal']['shoutbox_pageindex'] = 'Member ' . $memID . ' filtered (<a href="' . $scripturl . '?action=tpmod;shout=admin">' . $txt['remove'] . '</a>) <br />' . TPageIndex($scripturl . '?action=tpmod;shout=admin;u=' . $memID, $tpstart, $allshouts, 10, true); $request = $smcFunc['db_query']('', ' SELECT * FROM {db_prefix}tp_shoutbox WHERE type = {string:type} AND value5 = {int:val5} AND value7 = {int:val7} ORDER BY value2 DESC LIMIT {int:start},10', array('type' => 'shoutbox', 'val5' => $memID, 'val7' => 0, 'start' => $tpstart)); } elseif (isset($ip)) { $shouts = $smcFunc['db_query']('', ' SELECT COUNT(*) FROM {db_prefix}tp_shoutbox WHERE type = {string:type} AND value4 = {string:val4} AND value7 = {int:val7}', array('type' => 'shoutbox', 'val4' => $ip, 'val7' => 0)); $weh = $smcFunc['db_fetch_row']($shouts); $smcFunc['db_free_result']($shouts); $allshouts = $weh[0]; $context['TPortal']['admin_shoutbox_items_number'] = $allshouts; $context['TPortal']['shoutbox_pageindex'] = 'IP ' . $ip . ' filtered (<a href="' . $scripturl . '?action=tpmod;shout=admin">' . $txt['remove'] . '</a>) <br />' . TPageIndex($scripturl . '?action=tpmod;shout=admin;ip=' . urlencode($ip), $tpstart, $allshouts, 10, true); $request = $smcFunc['db_query']('', ' SELECT * FROM {db_prefix}tp_shoutbox WHERE type = {string:type} AND value4 = {string:val4} AND value7 = {int:val7} ORDER BY value2 DESC LIMIT {int:start}, 10', array('type' => 'shoutbox', 'val4' => $ip, 'val7' => 0, 'start' => $tpstart)); } elseif (isset($single)) { // check session checkSession('get'); $context['TPortal']['shoutbox_pageindex'] = ''; $request = $smcFunc['db_query']('', ' SELECT * FROM {db_prefix}tp_shoutbox WHERE type = {string:type} AND value7 = {int:val7} AND id = {int:shout}', array('type' => 'shoutbox', 'val7' => 0, 'shout' => $single)); } else { $shouts = $smcFunc['db_query']('', ' SELECT COUNT(*) FROM {db_prefix}tp_shoutbox WHERE type = {string:type} AND value7 = {int:val7}', array('type' => 'shoutbox', 'val7' => 0)); $weh = $smcFunc['db_fetch_row']($shouts); $smcFunc['db_free_result']($shouts); $allshouts = $weh[0]; $context['TPortal']['admin_shoutbox_items_number'] = $allshouts; $context['TPortal']['shoutbox_pageindex'] = TPageIndex($scripturl . '?action=tpmod;shout=admin', $tpstart, $allshouts, 10, true); $request = $smcFunc['db_query']('', ' SELECT * FROM {db_prefix}tp_shoutbox WHERE type = {string:type} AND value7 = {int:val7} ORDER BY value2 DESC LIMIT {int:start}, 10', array('type' => 'shoutbox', 'val7' => 0, 'start' => $tpstart)); } if ($smcFunc['db_num_rows']($request) > 0) { while ($row = $smcFunc['db_fetch_assoc']($request)) { $context['TPortal']['admin_shoutbox_items'][] = array('id' => $row['id'], 'body' => html_entity_decode($row['value1'], ENT_QUOTES), 'poster' => $row['value3'], 'timestamp' => $row['value2'], 'time' => timeformat($row['value2']), 'ip' => $row['value4'], 'ID_MEMBER' => $row['value5'], 'sort_member' => '<a href="' . $scripturl . '?action=tpmod;shout=admin;u=' . $row['value5'] . '">' . $txt['tp-allshoutsbymember'] . '</a>', 'sticky' => $row['value6'], 'sticky_layout' => $row['value8'], 'sort_ip' => '<a href="' . $scripturl . '?action=tpmod;shout=admin;ip=' . $row['value4'] . '">' . $txt['tp-allshoutsbyip'] . '</a>', 'single' => isset($single) ? '<hr><a href="' . $scripturl . '?action=tpmod;shout=admin"><b>' . $txt['tp-allshouts'] . '</b></a>' : ''); } $smcFunc['db_free_result']($request); } $context['TPortal']['subtabs'] = ''; // setup menu items if (allowedTo('tp_can_admin_shout')) { $context['TPortal']['subtabs'] = array('shoutbox_settings' => array('text' => 'tp-settings', 'url' => $scripturl . '?action=tpmod;shout=admin;settings', 'active' => isset($_GET['action']) && ($_GET['action'] == 'tpmod' || $_GET['action'] == 'tpadmin') && isset($_GET['shout']) && $_GET['shout'] == 'admin' && isset($_GET['settings']) ? true : false), 'shoutbox' => array('text' => 'tp-tabs10', 'url' => $scripturl . '?action=tpmod;shout=admin', 'active' => isset($_GET['action']) && ($_GET['action'] == 'tpmod' || $_GET['action'] == 'tpadmin') && isset($_GET['shout']) && $_GET['shout'] == 'admin' && !isset($_GET['settings']) ? true : false)); $context['admin_header']['tp_shout'] = $txt['tp_shout']; } // on settings screen? if (isset($_GET['settings'])) { $context['sub_template'] = 'tpshout_admin_settings'; } else { $context['sub_template'] = 'tpshout_admin'; } $context['page_title'] = 'Shoutbox admin'; tp_hidebars(); }
function doTPblocks() { global $context, $scripturl, $user_info, $smcFunc, $modSettings; $now = time(); // setup the containers $blocks = array('left' => '', 'right' => '', 'center' => '', 'front' => '', 'bottom' => '', 'top' => '', 'lower' => ''); $blocktype = array('no', 'userbox', 'newsbox', 'statsbox', 'searchbox', 'html', 'onlinebox', 'themebox', 'oldshoutbox', 'catmenu', 'phpbox', 'scriptbox', 'recentbox', 'ssi', 'module', 'rss', 'sitemap', 'oldadmin', 'articlebox', 'categorybox', 'tpmodulebox'); // construct the spot we are in $sqlarray = array(); // any action? if (!empty($_GET['action'])) { $sqlarray[] = 'actio=' . preg_replace('/[^A-Za-z0-9]/', '', $_GET['action']); if (in_array($_GET['action'], array('forum', 'collapse', 'post', 'calendar', 'search', 'login', 'logout', 'register', 'unread', 'unreadreplies', 'recent', 'stats', 'pm', 'profile', 'post2', 'search2', 'login2'))) { $sqlarray[] = 'actio=forumall'; } } if (!empty($_GET['board'])) { if (!isset($_GET['action'])) { $sqlarray[] = 'board=-1'; } $sqlarray[] = 'board=' . $_GET['board']; $sqlarray[] = 'actio=forumall'; } if (!empty($_GET['topic'])) { if (!isset($_GET['action'])) { $sqlarray[] = 'board=-1'; } $sqlarray[] = 'topic=' . $_GET['topic']; $sqlarray[] = 'actio=forumall'; } if (!empty($_GET['dl'])) { if (substr($_GET['dl'], 0, 3) == 'cat') { $down = true; } } // frontpage if (!isset($_GET['action']) && !isset($_GET['board']) && !isset($_GET['topic']) && !isset($_GET['page']) && !isset($_GET['cat'])) { $front = true; } $sqlarray[] = 'actio=allpages'; // set the location access $access2 = 'FIND_IN_SET(\'' . implode('\', access2) OR FIND_IN_SET(\'', $sqlarray) . '\', access2)'; // set the membergroup access $mygroups = $user_info['groups']; $access = '(FIND_IN_SET(' . implode(', access) OR FIND_IN_SET(', $mygroups) . ', access))'; if (allowedTo('tp_blocks') && (!empty($context['TPortal']['admin_showblocks']) || !isset($context['TPortal']['admin_showblocks']))) { $access = '1'; } // get the blocks $request = $smcFunc['db_query']('', ' SELECT * FROM {db_prefix}tp_blocks WHERE off = {int:off} AND bar != {int:bar} AND (' . (!empty($_GET['page']) ? 'FIND_IN_SET({string:page}, access2) OR ' : '') . ' ' . (!empty($_GET['cat']) ? 'FIND_IN_SET({string:cat}, access2) OR ' : '') . ' ' . (!empty($_GET['shout']) ? 'FIND_IN_SET({string:shout}, access2) OR ' : '') . ' ' . (!empty($front) ? 'FIND_IN_SET({string:front}, access2) OR ' : '') . ' ' . (!empty($down) ? 'FIND_IN_SET({string:down}, access2) OR ' : '') . ' ' . (!empty($context['TPortal']['uselangoption']) ? 'FIND_IN_SET({string:lang}, access2) OR ' : '') . ' ' . $access2 . ') AND ' . $access . ' ORDER BY bar, pos, id ASC', array('off' => 0, 'bar' => 4, 'lang' => 'tlang=' . $user_info['language'], 'page' => !empty($_GET['page']) ? !empty($context['shortID']) ? 'tpage=' . $context['shortID'] : 'tpage=' . $_GET['page'] : '', 'cat' => !empty($_GET['cat']) ? !empty($context['catshortID']) ? 'tpcat=' . $context['catshortID'] : 'tpcat=' . $_GET['cat'] : '', 'front' => 'actio=frontpage', 'down' => !empty($down) ? 'dlcat=' . substr($_GET['dl'], 3) : '', 'shout' => 'tpmod=shout')); $context['TPortal']['hide_frontbar_forum'] = 0; $count = array('left' => 0, 'right' => 0, 'center' => 0, 'front' => 0, 'bottom' => 0, 'top' => 0, 'lower' => 0); $fetch_articles = array(); $fetch_article_titles = array(); $panels = array(1 => 'left', 2 => 'right', 3 => 'center', 4 => 'front', 5 => 'bottom', 6 => 'top', 7 => 'lower'); if ($smcFunc['db_num_rows']($request) > 0) { while ($row = $smcFunc['db_fetch_assoc']($request)) { // some tests to minimize sql calls if ($row['type'] == 7) { $test_themebox = true; } elseif ($row['type'] == 18) { $test_articlebox = true; if (is_numeric($row['body'])) { $fetch_articles[] = $row['body']; } } elseif ($row['type'] == 9 || $row['type'] == 16) { $test_menubox = true; } elseif ($row['type'] == 19) { $test_catbox = true; if (is_numeric($row['body'])) { $fetch_article_titles[] = $row['body']; } } elseif ($row['type'] == 20) { if (!empty($context['TPortal']['tpmodules']['blockrender'][$row['var1']]['sourcefile']) && file_exists($context['TPortal']['tpmodules']['blockrender'][$row['var1']]['sourcefile'])) { require_once $context['TPortal']['tpmodules']['blockrender'][$row['var1']]['sourcefile']; } } $can_edit = !empty($row['editgroups']) ? get_perm($row['editgroups'], '') : false; $can_manage = allowedTo('tp_blocks'); if ($can_manage) { $can_edit = false; } $blocks[$panels[$row['bar']]][$count[$panels[$row['bar']]]] = array('frame' => $row['frame'], 'title' => strip_tags($row['title'], '<center>'), 'type' => isset($blocktype[$row['type']]) ? $blocktype[$row['type']] : $row['type'], 'body' => $row['body'], 'visible' => $row['visible'], 'var1' => $row['var1'], 'var2' => $row['var2'], 'var3' => $row['var3'], 'var4' => $row['var4'], 'id' => $row['id'], 'lang' => $row['lang'], 'access2' => $row['access2'], 'can_edit' => $can_edit, 'can_manage' => $can_manage); $count[$panels[$row['bar']]]++; } $smcFunc['db_free_result']($request); } if (sizeof($fetch_articles) > 0) { $fetchart = '(art.id=' . implode(' OR art.id=', $fetch_articles) . ')'; } else { $fetchart = ''; } if (sizeof($fetch_article_titles) > 0) { $fetchtitles = '(art.category=' . implode(' OR art.category=', $fetch_article_titles) . ')'; } else { $fetchtitles = ''; } // if a block displays an article if (isset($test_articlebox) && $fetchart != '') { $context['TPortal']['blockarticles'] = array(); $request = $smcFunc['db_query']('', ' SELECT art.*, var.value1, var.value2, var.value3, var.value4, var.value5, var.value7, var.value8, art.type as rendertype, IFNULL(mem.real_name,art.author) as realName, mem.avatar, mem.posts, mem.date_registered as dateRegistered,mem.last_login as lastLogin, IFNULL(a.id_attach, 0) AS ID_ATTACH, a.filename, a.attachment_type as attachmentType, var.value9 FROM {db_prefix}tp_articles as art LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = art.author_id) LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = art.author_id) LEFT JOIN {db_prefix}tp_variables as var ON (var.id= art.category) WHERE ' . $fetchart . ' AND art.off = 0 AND ((art.pub_start = 0 AND art.pub_end = 0) OR (art.pub_start != 0 AND art.pub_start < ' . $now . ' AND art.pub_end = 0) OR (art.pub_start = 0 AND art.pub_end != 0 AND art.pub_end > ' . $now . ') OR (art.pub_start != 0 AND art.pub_end != 0 AND art.pub_end > ' . $now . ' AND art.pub_start < ' . $now . ')) AND art.approved = 1 AND art.category > 0 AND art.category < 9999'); if ($smcFunc['db_num_rows']($request) > 0) { while ($article = $smcFunc['db_fetch_assoc']($request)) { // allowed and all is well, go on with it. $context['TPortal']['blockarticles'][$article['id']] = $article; // setup the avatar code if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize') { $avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : ''; $avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : ''; } else { $avatar_width = ''; $avatar_height = ''; } $context['TPortal']['blockarticles'][$article['id']]['avatar'] = $article['avatar'] == '' ? $article['ID_ATTACH'] > 0 ? '<img src="' . (empty($article['attachmentType']) ? $scripturl . '?action=tpmod;sa=tpattach;attach=' . $article['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $article['filename']) . '" alt="" class="avatar" border="0" />' : '' : (stristr($article['avatar'], 'http://') ? '<img src="' . $article['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($article['avatar'], ENT_QUOTES) . '" alt="" class="avatar" border="0" />'); // sort out the options $context['TPortal']['blockarticles'][$article['id']]['visual_options'] = array(); // since these are inside blocks, some stuff has to be left out $context['TPortal']['blockarticles'][$article['id']]['frame'] = 'none'; } $smcFunc['db_free_result']($request); } } // any cat listings from blocks? if (isset($test_catbox) && $fetchtitles != '') { $request = $smcFunc['db_query']('', ' SELECT art.id, art.subject, art.date, art.category, art.author_id as authorID, art.shortname, IFNULL(mem.real_name,art.author) as realName FROM {db_prefix}tp_articles AS art LEFT JOIN {db_prefix}members AS mem ON (art.author_id = mem.id_member) WHERE ' . $fetchtitles . ' AND art.off = 0 AND ((art.pub_start = 0 AND art.pub_end = 0) OR (art.pub_start != 0 AND art.pub_start < ' . $now . ' AND art.pub_end = 0) OR (art.pub_start = 0 AND art.pub_end != 0 AND art.pub_end > ' . $now . ') OR (art.pub_start != 0 AND art.pub_end != 0 AND art.pub_end > ' . $now . ' AND art.pub_start < ' . $now . ')) AND art.approved = 1'); if (!isset($context['TPortal']['blockarticle_titles'])) { $context['TPortal']['blockarticle_titles'] = array(); } if ($smcFunc['db_num_rows']($request) > 0) { while ($row = $smcFunc['db_fetch_assoc']($request)) { $context['TPortal']['blockarticle_titles'][$row['category']][$row['date'] . '_' . $row['id']] = array('id' => $row['id'], 'subject' => $row['subject'], 'shortname' => $row['shortname'] != '' ? $row['shortname'] : $row['id'], 'category' => $row['category'], 'poster' => '<a href="' . $scripturl . '?action=profile;u=' . $row['authorID'] . '">' . $row['realName'] . '</a>'); } $smcFunc['db_free_result']($request); } } // get menubox items if (isset($test_menubox)) { $context['TPortal']['menu'] = array(); $request = $smcFunc['db_query']('', ' SELECT * FROM {db_prefix}tp_variables WHERE type = {string:type} ORDER BY subtype + 0 ASC', array('type' => 'menubox')); if ($smcFunc['db_num_rows']($request) > 0) { while ($row = $smcFunc['db_fetch_assoc']($request)) { $icon = ''; if ($row['value5'] < 1) { $mtype = substr($row['value3'], 0, 4); $idtype = substr($row['value3'], 4); if ($mtype != 'cats' && $mtype != 'arti' && $mtype != 'head' && $mtype != 'spac') { $mtype = 'link'; $idtype = $row['value3']; } if ($mtype == 'cats') { if (isset($context['TPortal']['article_categories']['icon'][$idtype])) { $icon = $context['TPortal']['article_categories']['icon'][$idtype]; } } if ($mtype == 'head') { $mtype = 'head'; $idtype = $row['value1']; } $menupos = $row['value5']; $context['TPortal']['menu'][$row['subtype2']][] = array('id' => $row['id'], 'menuID' => $row['subtype2'], 'name' => $row['value1'], 'pos' => $menupos, 'type' => $mtype, 'IDtype' => $idtype, 'off' => '0', 'sub' => $row['value4'], 'icon' => $icon, 'newlink' => $row['value2'], 'sitemap' => in_array($row['id'], $context['TPortal']['sitemap']) ? true : false); } } $smcFunc['db_free_result']($request); } } // for tpadmin $context['TPortal']['adminleftpanel'] = $context['TPortal']['leftpanel']; $context['TPortal']['adminrightpanel'] = $context['TPortal']['rightpanel']; $context['TPortal']['admincenterpanel'] = $context['TPortal']['centerpanel']; $context['TPortal']['adminbottompanel'] = $context['TPortal']['bottompanel']; $context['TPortal']['admintoppanel'] = $context['TPortal']['toppanel']; $context['TPortal']['adminlowerpanel'] = $context['TPortal']['lowerpanel']; // if admin specifies no blocks, no blocks are shown! likewise, if in admin or tpadmin screen, turn off blocks if (in_array($context['TPortal']['action'], array('help', 'moderate', 'theme', 'tpadmin', 'admin', 'ban', 'boardrecount', 'cleanperms', 'detailedversion', 'dumpdb', 'featuresettings', 'featuresettings2', 'findmember', 'maintain', 'manageattachments', 'manageboards', 'managecalendar', 'managesearch', 'membergroups', 'modlog', 'news', 'optimizetables', 'packageget', 'packages', 'permissions', 'pgdownload', 'postsettings', 'regcenter', 'repairboards', 'reports', 'serversettings', 'serversettings2', 'smileys', 'viewErrorLog', 'viewmembers'))) { $in_admin = true; } if ($context['TPortal']['action'] == 'tpmod' && isset($_GET['dl']) && substr($_GET['dl'], 0, 5) == 'admin') { $in_admin = true; $context['current_action'] = 'admin'; } if ($context['user']['is_admin'] && isset($_GET['noblocks']) || $context['TPortal']['hidebars_admin_only'] == '1' && isset($in_admin)) { tp_hidebars(); } // check the panels foreach ($panels as $p => $panel) { // any blocks at all? if ($count[$panel] < 1) { $context['TPortal'][$panel . 'panel'] = 0; } // check the hide setting if (!isset($context['TPortal']['not_forum']) && $context['TPortal']['hide_' . $panel . 'bar_forum'] == 1) { tp_hidebars($panel); } } $context['TPortal']['blocks'] = $blocks; }