function ModifyHolidays() { global $sourcedir, $scripturl, $txt, $context; // Submitting something... if (isset($_REQUEST['delete']) && !empty($_REQUEST['holiday'])) { checkSession(); foreach ($_REQUEST['holiday'] as $id => $value) { $_REQUEST['holiday'][$id] = (int) $id; } // Now the IDs are "safe" do the delete... require_once $sourcedir . '/Subs-Calendar.php'; removeHolidays($_REQUEST['holiday']); } $listOptions = array('id' => 'holiday_list', 'title' => $txt['current_holidays'], 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=managecalendar;sa=holidays', 'default_sort_col' => 'name', 'get_items' => array('file' => $sourcedir . '/Subs-Calendar.php', 'function' => 'list_getHolidays'), 'get_count' => array('file' => $sourcedir . '/Subs-Calendar.php', 'function' => 'list_getNumHolidays'), 'no_items_label' => $txt['holidays_no_entries'], 'columns' => array('name' => array('header' => array('value' => $txt['holidays_title']), 'data' => array('sprintf' => array('format' => '<a href="' . $scripturl . '?action=admin;area=managecalendar;sa=editholiday;holiday=%1$d">%2$s</a>', 'params' => array('id_holiday' => false, 'title' => false))), 'sort' => array('default' => 'title', 'reverse' => 'title DESC')), 'date' => array('header' => array('value' => $txt['date']), 'data' => array('function' => create_function('$rowData', ' global $txt; // Recurring every year or just a single year? $year = $rowData[\'year\'] == \'0004\' ? sprintf(\'(%1$s)\', $txt[\'every_year\']) : $rowData[\'year\']; // Construct the date. return sprintf(\'%1$d %2$s %3$s\', $rowData[\'day\'], $txt[\'months\'][(int) $rowData[\'month\']], $year); '), 'class' => 'windowbg'), 'sort' => array('default' => 'event_date', 'reverse' => 'event_date DESC')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />'), 'data' => array('sprintf' => array('format' => '<input type="checkbox" name="holiday[%1$d]" class="input_check" />', 'params' => array('id_holiday' => false)), 'style' => 'text-align: center'))), 'form' => array('href' => $scripturl . '?action=admin;area=managecalendar;sa=holidays'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => ' <a href="' . $scripturl . '?action=admin;area=managecalendar;sa=editholiday" style="margin: 0 1em">[' . $txt['holidays_add'] . ']</a> <input type="submit" name="delete" value="' . $txt['quickmod_delete_selected'] . '" class="button_submit" />', 'style' => 'text-align: right;'))); require_once $sourcedir . '/Subs-List.php'; createList($listOptions); //loadTemplate('ManageCalendar'); $context['page_title'] = $txt['manage_holidays']; // Since the list is the only thing to show, use the default list template. $context['default_list'] = 'holiday_list'; $context['sub_template'] = 'show_list'; }
function createOpenInvoiceList() { $currentDate = date('Ymd'); $res = mysqli_query_check("select count(*) as cnt from {prefix}invoice i where i.deleted = 0 AND i.interval_type > 0 AND i.next_interval_date <= {$currentDate} AND i.archived = 0"); $row = mysqli_fetch_assoc($res); if ($row['cnt'] > 0) { createList('open_invoices', 'invoice', 'resultlist_repeating_invoices', $GLOBALS['locLabelInvoicesWithIntervalDue'], "i.interval_type > 0 AND i.next_interval_date <= {$currentDate} AND i.archived = 0", true); } $open = ''; $res = mysqli_query_check('SELECT id FROM {prefix}invoice_state WHERE invoice_open=1'); while ($id = mysqli_fetch_value($res)) { if ($open) { $open .= ', '; } $open .= $id; } $unpaid = ''; $res = mysqli_query_check('SELECT id FROM {prefix}invoice_state WHERE invoice_unpaid=1'); while ($id = mysqli_fetch_value($res)) { if ($unpaid) { $unpaid .= ', '; } $unpaid .= $id; } if ($open) { createList('open_invoices', 'invoice', 'resultlist_open_invoices', $GLOBALS['locLabelOpenInvoices'], "i.state_id IN ({$open}) AND i.archived=0", true); } if ($unpaid) { createList('open_invoices', 'invoice', 'resultlist_unpaid_invoices', $GLOBALS['locLabelUnpaidInvoices'], "i.state_id IN ({$unpaid}) AND i.archived=0", true, true); } }
/** * Show page listing of all permission groups in the system */ public function action_sportal_admin_permission_profiles_list() { global $context, $scripturl, $txt, $modSettings; // Removing some permission profiles? if (!empty($_POST['remove_profiles']) && !empty($_POST['remove']) && is_array($_POST['remove'])) { checkSession(); $remove = array(); foreach ($_POST['remove'] as $index => $profile_id) { $remove[(int) $index] = (int) $profile_id; } sp_delete_profiles($remove); } // Build the listoption array to display the permission profiles $listOptions = array('id' => 'portal_permisssions', 'title' => $txt['sp_admin_permission_profiles_list'], 'items_per_page' => $modSettings['defaultMaxMessages'], 'no_items_label' => $txt['error_sp_no_articles'], 'base_href' => $scripturl . '?action=admin;area=portalprofiles;sa=listpermission;', 'default_sort_col' => 'name', 'get_items' => array('function' => array($this, 'list_spLoadProfiles')), 'get_count' => array('function' => array($this, 'list_spCountProfiles')), 'columns' => array('name' => array('header' => array('value' => $txt['sp_admin_profiles_col_name']), 'data' => array('db' => 'label'), 'sort' => array('default' => 'name', 'reverse' => 'name DESC')), 'articles' => array('header' => array('value' => $txt['sp_admin_profiles_col_articles'], 'class' => 'centertext'), 'data' => array('function' => create_function('$row', ' return empty($row[\'articles\']) ? \'0\' : $row[\'articles\']; '), 'class' => 'centertext')), 'blocks' => array('header' => array('value' => $txt['sp_admin_profiles_col_blocks'], 'class' => 'centertext'), 'data' => array('function' => create_function('$row', ' return empty($row[\'blocks\']) ? \'0\' : $row[\'blocks\']; '), 'class' => 'centertext')), 'categories' => array('header' => array('value' => $txt['sp_admin_profiles_col_categories'], 'class' => 'centertext'), 'data' => array('function' => create_function('$row', ' return empty($row[\'categories\']) ? \'0\' : $row[\'categories\']; '), 'class' => 'centertext')), 'pages' => array('header' => array('value' => $txt['sp_admin_profiles_col_pages'], 'class' => 'centertext'), 'data' => array('function' => create_function('$row', ' return empty($row[\'pages\']) ? \'0\' : $row[\'pages\']; '), 'class' => 'centertext')), 'shoutboxes' => array('header' => array('value' => $txt['sp_admin_profiles_col_shoutboxes'], 'class' => 'centertext'), 'data' => array('function' => create_function('$row', ' return empty($row[\'shoutboxes\']) ? \'0\' : $row[\'shoutboxes\']; '), 'class' => 'centertext')), 'action' => array('header' => array('value' => $txt['sp_admin_articles_col_actions'], 'class' => 'centertext'), 'data' => array('sprintf' => array('format' => '<a href="?action=admin;area=portalprofiles;sa=editpermission;profile_id=%1$s;' . $context['session_var'] . '=' . $context['session_id'] . '" accesskey="e">' . sp_embed_image('modify') . '</a> <a href="?action=admin;area=portalprofiles;sa=deletepermission;profile_id=%1$s;' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(' . JavaScriptEscape($txt['sp_admin_articles_delete_confirm']) . ') && submitThisOnce(this);" accesskey="d">' . sp_embed_image('delete') . '</a>', 'params' => array('id' => true)), 'class' => 'centertext', 'style' => "width: 40px")), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />', 'class' => 'centertext'), 'data' => array('function' => create_function('$row', ' return \'<input type="checkbox" name="remove[]" value="\' . $row[\'id\'] . \'" class="input_check" />\'; '), 'class' => 'centertext'))), 'form' => array('href' => $scripturl . '?action=admin;area=portalprofiles;sa=listpermission', 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array($context['session_var'] => $context['session_id']))); // Set the context values $context['page_title'] = $txt['sp_admin_permission_profiles_list']; $context['sub_template'] = 'show_list'; $context['default_list'] = 'portal_permisssions'; // Create the list. require_once SUBSDIR . '/GenericList.class.php'; createList($listOptions); }
function createList($category, $list) { global $connection; global $DBErrorMsg; if ($category !== 'products') { //query db to get parent $query = "SELECT..."; if ($result = $connection->query($query)) { while ($row = $result->fetch_assoc()) { //create category list $parent = $row['canonical_name']; if ($parent !== 'products') { $list = '<li><a href="index.php?nav=' . htmlentities($row['canonical_name']) . '">' . htmlentities($row['name']) . '</a> <span class="glyphicon glyphicon-menu-right"></span> </li>' . $list; } } } else { echo databaseErrorMsg($DBErrorMsg); } //get list recursively $returnList = createList($parent, $list); } else { //Added on last recursion cycle $returnList = '<ol class="breadcrumb"><li><a href="index.php">Main Menu</a> <span class="glyphicon glyphicon-menu-right"></span> </li>' . $list; } return $returnList; }
function registerUser($username, $password, $email) { $salt = createSalt(); $password = saltPassword($password, $salt); $user_id = createUID('users', 'user_id'); $userCreated = mysql_query("INSERT INTO users (user_id, username, password, email, salt) VALUES ('" . $user_id . "', '" . $username . "', '" . $password . "', '" . $email . "', '" . $salt . "')"); if ($userCreated) { return createList($user_id); } else { $userDeleted = mysql_query("DELETE FROM users WHERE user_id = '" . $user_id . "' AND username = '******'"); return false; } }
/** * Show a listing of articles in the system */ public function action_sportal_admin_article_list() { global $context, $scripturl, $txt, $modSettings; // Build the listoption array to display the categories $listOptions = array('id' => 'portal_articles', 'title' => $txt['sp_admin_articles_list'], 'items_per_page' => $modSettings['defaultMaxMessages'], 'no_items_label' => $txt['error_sp_no_articles'], 'base_href' => $scripturl . '?action=admin;area=portalarticles;sa=list;', 'default_sort_col' => 'title', 'get_items' => array('function' => array($this, 'list_spLoadArticles')), 'get_count' => array('function' => array($this, 'list_spCountArticles')), 'columns' => array('title' => array('header' => array('value' => $txt['sp_admin_articles_col_title']), 'data' => array('db' => 'title'), 'sort' => array('default' => 'title', 'reverse' => 'title DESC')), 'namespace' => array('header' => array('value' => $txt['sp_admin_articles_col_namespace']), 'data' => array('db' => 'article_id'), 'sort' => array('default' => 'article_namespace', 'reverse' => 'article_namespace DESC')), 'category' => array('header' => array('value' => $txt['sp_admin_articles_col_category']), 'data' => array('db' => 'category_name'), 'sort' => array('default' => 'name', 'reverse' => 'name DESC')), 'author' => array('header' => array('value' => $txt['sp_admin_articles_col_author']), 'data' => array('db' => 'author_name'), 'sort' => array('default' => 'author_name', 'reverse' => 'author_name DESC')), 'type' => array('header' => array('value' => $txt['sp_admin_articles_col_type']), 'data' => array('db' => 'type'), 'sort' => array('default' => 'type', 'reverse' => 'type DESC')), 'date' => array('header' => array('value' => $txt['sp_admin_articles_col_date']), 'data' => array('db' => 'date'), 'sort' => array('default' => 'date', 'reverse' => 'date DESC')), 'status' => array('header' => array('value' => $txt['sp_admin_articles_col_status'], 'class' => 'centertext'), 'data' => array('db' => 'status_image', 'class' => 'centertext'), 'sort' => array('default' => 'status', 'reverse' => 'status DESC')), 'action' => array('header' => array('value' => $txt['sp_admin_articles_col_actions'], 'class' => 'centertext'), 'data' => array('sprintf' => array('format' => '<a href="?action=admin;area=portalarticles;sa=edit;article_id=%1$s;' . $context['session_var'] . '=' . $context['session_id'] . '" accesskey="e">' . sp_embed_image('modify') . '</a> <a href="?action=admin;area=portalarticles;sa=delete;article_id=%1$s;' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(' . JavaScriptEscape($txt['sp_admin_articles_delete_confirm']) . ') && submitThisOnce(this);" accesskey="d">' . sp_embed_image('delete') . '</a>', 'params' => array('id' => true)), 'class' => 'centertext nowrap')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />', 'class' => 'centertext'), 'data' => array('function' => create_function('$row', ' return \'<input type="checkbox" name="remove[]" value="\' . $row[\'id\'] . \'" class="input_check" />\'; '), 'class' => 'centertext'))), 'form' => array('href' => $scripturl . '?action=admin;area=portalarticles;sa=remove', 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array($context['session_var'] => $context['session_id'])), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '<input type="submit" name="remove_articles" value="' . $txt['sp_admin_articles_remove'] . '" class="right_submit" />'))); // Set the context values $context['page_title'] = $txt['sp_admin_articles_title']; $context['sub_template'] = 'show_list'; $context['default_list'] = 'portal_articles'; // Create the list. require_once SUBSDIR . '/GenericList.class.php'; createList($listOptions); }
/** * Display the mail queue... */ function BrowseMailQueue() { global $scripturl, $context, $modSettings, $txt, $smcFunc; global $sourcedir; // First, are we deleting something from the queue? if (isset($_REQUEST['delete'])) { checkSession('post'); $smcFunc['db_query']('', ' DELETE FROM {db_prefix}mail_queue WHERE id_mail IN ({array_int:mail_ids})', array('mail_ids' => $_REQUEST['delete'])); } // How many items do we have? $request = $smcFunc['db_query']('', ' SELECT COUNT(*) AS queue_size, MIN(time_sent) AS oldest FROM {db_prefix}mail_queue', array()); list($mailQueueSize, $mailOldest) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); $context['oldest_mail'] = empty($mailOldest) ? $txt['mailqueue_oldest_not_available'] : time_since(time() - $mailOldest); $context['mail_queue_size'] = comma_format($mailQueueSize); $listOptions = array('id' => 'mail_queue', 'title' => $txt['mailqueue_browse'], 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=mailqueue', 'default_sort_col' => 'age', 'no_items_label' => $txt['mailqueue_no_items'], 'get_items' => array('function' => 'list_getMailQueue'), 'get_count' => array('function' => 'list_getMailQueueSize'), 'columns' => array('subject' => array('header' => array('value' => $txt['mailqueue_subject']), 'data' => array('function' => create_function('$rowData', ' global $smcFunc; return $smcFunc[\'strlen\']($rowData[\'subject\']) > 50 ? sprintf(\'%1$s...\', htmlspecialchars($smcFunc[\'substr\']($rowData[\'subject\'], 0, 47))) : htmlspecialchars($rowData[\'subject\']); '), 'class' => 'smalltext'), 'sort' => array('default' => 'subject', 'reverse' => 'subject DESC')), 'recipient' => array('header' => array('value' => $txt['mailqueue_recipient']), 'data' => array('sprintf' => array('format' => '<a href="mailto:%1$s">%1$s</a>', 'params' => array('recipient' => true)), 'class' => 'smalltext'), 'sort' => array('default' => 'recipient', 'reverse' => 'recipient DESC')), 'priority' => array('header' => array('value' => $txt['mailqueue_priority']), 'data' => array('function' => create_function('$rowData', ' global $txt; // We probably have a text label with your priority. $txtKey = sprintf(\'mq_mpriority_%1$s\', $rowData[\'priority\']); // But if not, revert to priority 0. return isset($txt[$txtKey]) ? $txt[$txtKey] : $txt[\'mq_mpriority_1\']; '), 'class' => 'smalltext'), 'sort' => array('default' => 'priority', 'reverse' => 'priority DESC')), 'age' => array('header' => array('value' => $txt['mailqueue_age']), 'data' => array('function' => create_function('$rowData', ' return time_since(time() - $rowData[\'time_sent\']); '), 'class' => 'smalltext'), 'sort' => array('default' => 'time_sent', 'reverse' => 'time_sent DESC')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />'), 'data' => array('function' => create_function('$rowData', ' return \'<input type="checkbox" name="delete[]" value="\' . $rowData[\'id_mail\'] . \'" class="input_check" />\'; '), 'class' => 'smalltext'))), 'form' => array('href' => $scripturl . '?action=admin;area=mailqueue', 'include_start' => true, 'include_sort' => true), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '<input type="submit" name="delete_redirects" value="' . $txt['quickmod_delete_selected'] . '" onclick="return confirm(\'' . $txt['quickmod_confirm'] . '\');" class="button_submit" /><a class="button_link" href="' . $scripturl . '?action=admin;area=mailqueue;sa=clear;' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(\'' . $txt['mailqueue_clear_list_warning'] . '\');">' . $txt['mailqueue_clear_list'] . '</a> '))); require_once $sourcedir . '/Subs-List.php'; createList($listOptions); loadTemplate('ManageMail'); $context['sub_template'] = 'browse'; }
function createList($array, $currentParent, $currLevel = 0, $prevLevel = -1) { foreach ($array as $categoryId => $category) { if ($currentParent == $category['parent_ID']) { if ($currLevel > $prevLevel) { echo " <div> "; } if ($currLevel == $prevLevel) { echo " </li> "; } echo '<a href="topics.php?topic_ID=' . $category['topic_ID'] . '" class="btn btn-primary" >' . $category['topic_title'] . '</a>'; if ($currLevel > $prevLevel) { $prevLevel = $currLevel; } $currLevel++; createList($array, $categoryId, $currLevel, $prevLevel); $currLevel--; } } if ($currLevel == $prevLevel) { echo "</div>"; } }
public function action_list() { global $txt, $context, $scripturl, $modSettings, $settings; loadJavascriptFile('notify.js', array('defer' => true)); loadJavascriptFile('jquery.knob.js', array('defer' => true)); loadCSSFile('notify.css'); addInlineJavascript('dismissnotice_editable();', true); $modSettings['jquery_include_ui'] = true; loadCSSFile('dism/jquery.ui.theme.css'); loadCSSFile('dism/jquery.ui.datepicker.css'); loadCSSFile('dism/jquery.ui.d.theme.css'); loadCSSFile('dism/jquery.ui.core.css'); $possible_locals = array($txt['lang_locale']); $b = explode('_', $txt['lang_locale']); foreach ($b as $a) { $possible_locals[] = $a; } foreach ($possible_locals as $local) { if (file_exists($settings['default_theme_dir'] . '/scripts/datepicker-i18n/datepicker-' . $local . '.js')) { loadJavascriptFile('datepicker-i18n/datepicker-' . $local . '.js', array('defer' => true)); break; $context['datepicker_local'] = $local; } } $list_options = array('id' => 'list_dismissible_notices', 'title' => $txt['dismissnotices_title_list'], 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=dismissnotice;sa=list' . $context['session_var'] . '=' . $context['session_id'], 'default_sort_col' => 'timeadded', 'get_items' => array('function' => array($this, 'getItems')), 'get_count' => array('function' => array($this, 'countItems')), 'data_check' => array('class' => function ($rowData) { return 'editable_' . $rowData['id_notice']; }), 'no_items_label' => $txt['hooks_no_hooks'], 'columns' => array('timeadded' => array('header' => array('value' => $txt['dismissnotices_time_added']), 'data' => array('function' => function ($rowData) { return standardTime($rowData['added']); }), 'sort' => array('default' => 'added', 'reverse' => 'added DESC')), 'body' => array('header' => array('value' => $txt['dismissnotices_body']), 'data' => array('db' => 'body')), 'class' => array('header' => array('value' => $txt['dismissnotices_class']), 'data' => array('db_htmlsafe' => 'class'), 'sort' => array('default' => 'class', 'reverse' => 'class DESC')), 'expire' => array('header' => array('value' => $txt['dismissnotices_expire']), 'data' => array('function' => function ($rowData) { return Dismissible_Notices_Integrate::formatExpireCol($rowData['expire']); }), 'sort' => array('default' => 'expire', 'reverse' => 'expire DESC')), 'edit' => array('header' => array('value' => ''), 'data' => array('function' => function ($rowData) { global $txt; return '<a data-idnotice="' . $rowData['id_notice'] . '" class="dismissnotice_editable" href="#">' . $txt['modify'] . '</a>'; }))), 'additional_rows' => array(array('position' => 'bottom_of_list', 'value' => '<a id="dismissnotice_new" class="floatright linkbutton" href="#">' . $txt['new'] . '</a>'))); require_once SUBSDIR . '/GenericList.class.php'; createList($list_options); }
function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $restore_write_status = false) { global $context, $modSettings, $package_ftp, $boarddir, $txt, $sourcedir, $scripturl; // If we're restoring the status of existing files prepare the data. if ($restore_write_status && isset($_SESSION['pack_ftp']) && !empty($_SESSION['pack_ftp']['original_perms'])) { function list_restoreFiles($dummy1, $dummy2, $dummy3, $do_change) { global $txt; $restore_files = array(); foreach ($_SESSION['pack_ftp']['original_perms'] as $file => $perms) { // Check the file still exists, and the permissions were indeed different than now. $file_permissions = @fileperms($file); if (!file_exists($file) || $file_permissions == $perms) { unset($_SESSION['pack_ftp']['original_perms'][$file]); continue; } // Are we wanting to change the permission? if ($do_change && isset($_POST['restore_files']) && in_array($file, $_POST['restore_files'])) { // Use FTP if we have it. if (!empty($package_ftp)) { $ftp_file = strtr($file, array($_SESSION['pack_ftp']['root'] => '')); $package_ftp->chmod($ftp_file, $perms); } else { @chmod($file, $perms); } $new_permissions = @fileperms($file); $result = $new_permissions == $perms ? 'success' : 'failure'; unset($_SESSION['pack_ftp']['original_perms'][$file]); } elseif ($do_change) { $new_permissions = ''; $result = 'skipped'; unset($_SESSION['pack_ftp']['original_perms'][$file]); } // Record the results! $restore_files[] = array('path' => $file, 'old_perms_raw' => $perms, 'old_perms' => substr(sprintf('%o', $perms), -4), 'cur_perms' => substr(sprintf('%o', $file_permissions), -4), 'new_perms' => isset($new_permissions) ? substr(sprintf('%o', $new_permissions), -4) : '', 'result' => isset($result) ? $result : '', 'writable_message' => '<span style="color: ' . (@is_writable($file) ? 'green' : 'red') . '">' . (@is_writable($file) ? $txt['package_file_perms_writable'] : $txt['package_file_perms_not_writable']) . '</span>'); } return $restore_files; } $listOptions = array('id' => 'restore_file_permissions', 'title' => $txt['package_restore_permissions'], 'get_items' => array('function' => 'list_restoreFiles', 'params' => array(!empty($_POST['restore_perms']))), 'columns' => array('path' => array('header' => array('value' => $txt['package_restore_permissions_filename']), 'data' => array('db' => 'path', 'class' => 'smalltext')), 'old_perms' => array('header' => array('value' => $txt['package_restore_permissions_orig_status']), 'data' => array('db' => 'old_perms', 'class' => 'smalltext')), 'cur_perms' => array('header' => array('value' => $txt['package_restore_permissions_cur_status']), 'data' => array('function' => create_function('$rowData', ' global $txt; $formatTxt = $rowData[\'result\'] == \'\' || $rowData[\'result\'] == \'skipped\' ? $txt[\'package_restore_permissions_pre_change\'] : $txt[\'package_restore_permissions_post_change\']; return sprintf($formatTxt, $rowData[\'cur_perms\'], $rowData[\'new_perms\'], $rowData[\'writable_message\']); '), 'class' => 'smalltext')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />'), 'data' => array('sprintf' => array('format' => '<input type="checkbox" name="restore_files[]" value="%1$s" class="input_check" />', 'params' => array('path' => false)), 'style' => 'text-align: center')), 'result' => array('header' => array('value' => $txt['package_restore_permissions_result']), 'data' => array('function' => create_function('$rowData', ' global $txt; return $txt[\'package_restore_permissions_action_\' . $rowData[\'result\']]; '), 'class' => 'smalltext'))), 'form' => array('href' => !empty($chmodOptions['destination_url']) ? $chmodOptions['destination_url'] : $scripturl . '?action=admin;area=packages;sa=perms;restore;' . $context['session_var'] . '=' . $context['session_id']), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '<input type="submit" name="restore_perms" value="' . $txt['package_restore_permissions_restore'] . '" class="button_submit" />', 'class' => 'titlebg', 'style' => 'text-align: right;'), array('position' => 'after_title', 'value' => '<span class="smalltext">' . $txt['package_restore_permissions_desc'] . '</span>', 'class' => 'windowbg2'))); // Work out what columns and the like to show. if (!empty($_POST['restore_perms'])) { $listOptions['additional_rows'][1]['value'] = sprintf($txt['package_restore_permissions_action_done'], $scripturl . '?action=admin;area=packages;sa=perms;' . $context['session_var'] . '=' . $context['session_id']); unset($listOptions['columns']['check'], $listOptions['form'], $listOptions['additional_rows'][0]); $context['sub_template'] = 'show_list'; $context['default_list'] = 'restore_file_permissions'; } else { unset($listOptions['columns']['result']); } // Create the list for display. require_once $sourcedir . '/lib/Subs-List.php'; createList($listOptions); // If we just restored permissions then whereever we are, we are now done and dusted. if (!empty($_POST['restore_perms'])) { obExit(); } } elseif ($restore_write_status) { return true; } // This is where we report what we got up to. $return_data = array('files' => array('writable' => array(), 'notwritable' => array())); // If we have some FTP information already, then let's assume it was required and try to get ourselves connected. if (!empty($_SESSION['pack_ftp']['connected'])) { // Load the file containing the ftp_connection class. loadClassFile('Class-Package.php'); $package_ftp = new ftp_connection($_SESSION['pack_ftp']['server'], $_SESSION['pack_ftp']['port'], $_SESSION['pack_ftp']['username'], package_crypt($_SESSION['pack_ftp']['password'])); } // Just got a submission did we? if (empty($package_ftp) && isset($_POST['ftp_username'])) { loadClassFile('Class-Package.php'); $ftp = new ftp_connection($_POST['ftp_server'], $_POST['ftp_port'], $_POST['ftp_username'], $_POST['ftp_password']); // We're connected, jolly good! if ($ftp->error === false) { // Common mistake, so let's try to remedy it... if (!$ftp->chdir($_POST['ftp_path'])) { $ftp_error = $ftp->last_message; $ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $_POST['ftp_path'])); } if (!in_array($_POST['ftp_path'], array('', '/'))) { $ftp_root = strtr($boarddir, array($_POST['ftp_path'] => '')); if (substr($ftp_root, -1) == '/' && ($_POST['ftp_path'] == '' || substr($_POST['ftp_path'], 0, 1) == '/')) { $ftp_root = substr($ftp_root, 0, -1); } } else { $ftp_root = $boarddir; } $_SESSION['pack_ftp'] = array('server' => $_POST['ftp_server'], 'port' => $_POST['ftp_port'], 'username' => $_POST['ftp_username'], 'password' => package_crypt($_POST['ftp_password']), 'path' => $_POST['ftp_path'], 'root' => $ftp_root, 'connected' => true); if (!isset($modSettings['package_path']) || $modSettings['package_path'] != $_POST['ftp_path']) { updateSettings(array('package_path' => $_POST['ftp_path'])); } // This is now the primary connection. $package_ftp = $ftp; } } // Now try to simply make the files writable, with whatever we might have. if (!empty($chmodFiles)) { foreach ($chmodFiles as $k => $file) { // Sometimes this can somehow happen maybe? if (empty($file)) { unset($chmodFiles[$k]); } elseif (@is_writable($file)) { $return_data['files']['writable'][] = $file; } else { // Now try to change that. $return_data['files'][package_chmod($file, 'writable', true) ? 'writable' : 'notwritable'][] = $file; } } } // Have we still got nasty files which ain't writable? Dear me we need more FTP good sir. if (empty($package_ftp) && (!empty($return_data['files']['notwritable']) || !empty($chmodOptions['force_find_error']))) { if (!isset($ftp) || $ftp->error !== false) { if (!isset($ftp)) { loadClassFile('Class-Package.php'); $ftp = new ftp_connection(null); } elseif ($ftp->error !== false && !isset($ftp_error)) { $ftp_error = $ftp->last_message === null ? '' : $ftp->last_message; } list($username, $detect_path, $found_path) = $ftp->detect_path($boarddir); if ($found_path) { $_POST['ftp_path'] = $detect_path; } elseif (!isset($_POST['ftp_path'])) { $_POST['ftp_path'] = isset($modSettings['package_path']) ? $modSettings['package_path'] : $detect_path; } if (!isset($_POST['ftp_username'])) { $_POST['ftp_username'] = $username; } } $context['package_ftp'] = array('server' => isset($_POST['ftp_server']) ? $_POST['ftp_server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'), 'port' => isset($_POST['ftp_port']) ? $_POST['ftp_port'] : (isset($modSettings['package_port']) ? $modSettings['package_port'] : '21'), 'username' => isset($_POST['ftp_username']) ? $_POST['ftp_username'] : (isset($modSettings['package_username']) ? $modSettings['package_username'] : ''), 'path' => $_POST['ftp_path'], 'error' => empty($ftp_error) ? null : $ftp_error, 'destination' => !empty($chmodOptions['destination_url']) ? $chmodOptions['destination_url'] : ''); // Which files failed? if (!isset($context['notwritable_files'])) { $context['notwritable_files'] = array(); } $context['notwritable_files'] = array_merge($context['notwritable_files'], $return_data['files']['notwritable']); // Sent here to die? if (!empty($chmodOptions['crash_on_error'])) { $context['page_title'] = $txt['package_ftp_necessary']; $context['sub_template'] = 'ftp_required'; obExit(); } } return $return_data; }
function MembersAwaitingActivation() { global $txt, $context, $scripturl, $modSettings, $smcFunc; global $sourcedir; // Not a lot here! $context['page_title'] = $txt['admin_members']; $context['sub_template'] = 'admin_browse'; $context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve'); if (isset($context['tabs'][$context['browse_type']])) { $context['tabs'][$context['browse_type']]['is_selected'] = true; } // Allowed filters are those we can have, in theory. $context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2); $context['current_filter'] = isset($_REQUEST['filter']) && in_array($_REQUEST['filter'], $context['allowed_filters']) && !empty($context['activation_numbers'][$_REQUEST['filter']]) ? (int) $_REQUEST['filter'] : -1; // Sort out the different sub areas that we can actually filter by. $context['available_filters'] = array(); foreach ($context['activation_numbers'] as $type => $amount) { // We have some of these... if (in_array($type, $context['allowed_filters']) && $amount > 0) { $context['available_filters'][] = array('type' => $type, 'amount' => $amount, 'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?', 'selected' => $type == $context['current_filter']); } } // If the filter was not sent, set it to whatever has people in it! if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) { $context['current_filter'] = $context['available_filters'][0]['type']; } // This little variable is used to determine if we should flag where we are looking. $context['show_filter'] = $context['current_filter'] != 0 && $context['current_filter'] != 3 || count($context['available_filters']) > 1; // The columns that can be sorted. $context['columns'] = array('id_member' => array('label' => $txt['admin_browse_id']), 'member_name' => array('label' => $txt['admin_browse_username']), 'email_address' => array('label' => $txt['admin_browse_email']), 'member_ip' => array('label' => $txt['admin_browse_ip']), 'date_registered' => array('label' => $txt['admin_browse_registered'])); // Are we showing duplicate information? if (isset($_GET['showdupes'])) { $_SESSION['showdupes'] = (int) $_GET['showdupes']; } $context['show_duplicates'] = !empty($_SESSION['showdupes']); // Determine which actions we should allow on this page. if ($context['browse_type'] == 'approve') { // If we are approving deleted accounts we have a slightly different list... actually a mirror ;) if ($context['current_filter'] == 4) { $context['allowed_actions'] = array('reject' => $txt['admin_browse_w_approve_deletion'], 'ok' => $txt['admin_browse_w_reject']); } else { $context['allowed_actions'] = array('ok' => $txt['admin_browse_w_approve'], 'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'], 'require_activation' => $txt['admin_browse_w_approve_require_activate'], 'reject' => $txt['admin_browse_w_reject'], 'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email']); } } elseif ($context['browse_type'] == 'activate') { $context['allowed_actions'] = array('ok' => $txt['admin_browse_w_activate'], 'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'], 'delete' => $txt['admin_browse_w_delete'], 'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'], 'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email']); } // Create an option list for actions allowed to be done with selected members. $allowed_actions = ' <option selected="selected" value="">' . $txt['admin_browse_with_selected'] . ':</option> <option value="" disabled="disabled">-----------------------------</option>'; foreach ($context['allowed_actions'] as $key => $desc) { $allowed_actions .= ' <option value="' . $key . '">' . $desc . '</option>'; } // Setup the Javascript function for selecting an action for the list. $javascript = ' function onSelectChange() { if (document.forms.postForm.todo.value == "") return; var message = "";'; // We have special messages for approving deletion of accounts - it's surprisingly logical - honest. if ($context['current_filter'] == 4) { $javascript .= ' if (document.forms.postForm.todo.value.indexOf("reject") != -1) message = "' . $txt['admin_browse_w_delete'] . '"; else message = "' . $txt['admin_browse_w_reject'] . '";'; } else { $javascript .= ' if (document.forms.postForm.todo.value.indexOf("delete") != -1) message = "' . $txt['admin_browse_w_delete'] . '"; else if (document.forms.postForm.todo.value.indexOf("reject") != -1) message = "' . $txt['admin_browse_w_reject'] . '"; else if (document.forms.postForm.todo.value == "remind") message = "' . $txt['admin_browse_w_remind'] . '"; else message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";'; } $javascript .= ' if (confirm(message + " ' . $txt['admin_browse_warn'] . '")) document.forms.postForm.submit(); }'; $listOptions = array('id' => 'approve_list', 'items_per_page' => $modSettings['defaultMaxMembers'], 'base_href' => $scripturl . '?action=admin;area=viewmembers;sa=browse;type=' . $context['browse_type'] . (!empty($context['show_filter']) ? ';filter=' . $context['current_filter'] : ''), 'default_sort_col' => 'date_registered', 'get_items' => array('file' => $sourcedir . '/Subs-Members.php', 'function' => 'list_getMembers', 'params' => array('is_activated = {int:activated_status}', array('activated_status' => $context['current_filter']), $context['show_duplicates'])), 'get_count' => array('file' => $sourcedir . '/Subs-Members.php', 'function' => 'list_getNumMembers', 'params' => array('is_activated = {int:activated_status}', array('activated_status' => $context['current_filter']))), 'columns' => array('id_member' => array('header' => array('value' => $txt['member_id']), 'data' => array('db' => 'id_member', 'class' => 'windowbg', 'style' => 'text-align: center;'), 'sort' => array('default' => 'id_member', 'reverse' => 'id_member DESC')), 'user_name' => array('header' => array('value' => $txt['username']), 'data' => array('sprintf' => array('format' => '<a href="' . strtr($scripturl, array('%' => '%%')) . '?action=profile;u=%1$d">%2$s</a>', 'params' => array('id_member' => false, 'member_name' => false))), 'sort' => array('default' => 'member_name', 'reverse' => 'member_name DESC')), 'email' => array('header' => array('value' => $txt['email_address']), 'data' => array('sprintf' => array('format' => '<a href="mailto:%1$s">%1$s</a>', 'params' => array('email_address' => true)), 'class' => 'windowbg'), 'sort' => array('default' => 'email_address', 'reverse' => 'email_address DESC')), 'ip' => array('header' => array('value' => $txt['ip_address']), 'data' => array('sprintf' => array('format' => '<a href="' . strtr($scripturl, array('%' => '%%')) . '?action=trackip;searchip=%1$s">%1$s</a>', 'params' => array('member_ip' => false))), 'sort' => array('default' => 'INET_ATON(member_ip)', 'reverse' => 'INET_ATON(member_ip) DESC')), 'hostname' => array('header' => array('value' => $txt['hostname']), 'data' => array('function' => create_function('$rowData', ' global $modSettings; return host_from_ip($rowData[\'member_ip\']); '), 'class' => 'smalltext')), 'date_registered' => array('header' => array('value' => $txt['date_registered']), 'data' => array('function' => create_function('$rowData', ' return timeformat($rowData[\'date_registered\']); ')), 'sort' => array('default' => 'date_registered DESC', 'reverse' => 'date_registered')), 'duplicates' => array('header' => array('value' => $txt['duplicates'], 'style' => 'width: 20%'), 'data' => array('function' => create_function('$rowData', ' global $scripturl, $txt; $member_links = array(); foreach ($rowData[\'duplicate_members\'] as $member) { if ($member[\'id\']) $member_links[] = \'<a href="\' . $scripturl . \'?action=profile;u=\' . $member[\'id\'] . \'" \' . (!empty($member[\'is_banned\']) ? \'style="color: red;"\' : \'\') . \'>\' . $member[\'name\'] . \'</a>\'; else $member_links[] = $member[\'name\'] . \' (\' . $txt[\'guest\'] . \')\'; } return implode (\', \', $member_links); '), 'class' => 'smalltext')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />'), 'data' => array('sprintf' => array('format' => '<input type="checkbox" name="todoAction[]" value="%1$d" class="input_check" />', 'params' => array('id_member' => false)), 'class' => 'windowbg', 'style' => 'text-align: center'))), 'javascript' => $javascript, 'form' => array('href' => $scripturl . '?action=admin;area=viewmembers;sa=approve;type=' . $context['browse_type'], 'name' => 'postForm', 'include_start' => true, 'include_sort' => true, 'hidden_fields' => array('orig_filter' => $context['current_filter'])), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => ' <div class="floatleft"> [<a href="' . $scripturl . '?action=admin;area=viewmembers;sa=browse;showdupes=' . ($context['show_duplicates'] ? 0 : 1) . ';type=' . $context['browse_type'] . (!empty($context['show_filter']) ? ';filter=' . $context['current_filter'] : '') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . ($context['show_duplicates'] ? $txt['dont_check_for_duplicate'] : $txt['check_for_duplicate']) . '</a>] </div> <div class="floatright"> <select name="todo" onchange="onSelectChange();"> ' . $allowed_actions . ' </select> <noscript><input type="submit" value="' . $txt['go'] . '" class="button_submit" /></noscript> </div>'))); // Pick what column to actually include if we're showing duplicates. if ($context['show_duplicates']) { unset($listOptions['columns']['email']); } else { unset($listOptions['columns']['duplicates']); } // Only show hostname on duplicates as it takes a lot of time. if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) { unset($listOptions['columns']['hostname']); } // Is there any need to show filters? if (isset($context['available_filters']) && count($context['available_filters']) > 1) { $filterOptions = ' <strong>' . $txt['admin_browse_filter_by'] . ':</strong> <select name="filter" onchange="this.form.submit();">'; foreach ($context['available_filters'] as $filter) { $filterOptions .= ' <option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected="selected"' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>'; } $filterOptions .= ' </select> <noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button_submit" /></noscript>'; $listOptions['additional_rows'][] = array('position' => 'above_column_headers', 'value' => $filterOptions, 'style' => 'text-align: center;'); } // What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at. if (!empty($context['show_filter']) && !empty($context['available_filters'])) { $listOptions['additional_rows'][] = array('position' => 'above_column_headers', 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'], 'class' => 'smalltext', 'style' => 'text-align: left;'); } // Now that we have all the options, create the list. require_once $sourcedir . '/Subs-List.php'; createList($listOptions); }
/** * Show all the custom profile fields available to the user. * * - Allows for drag/drop sorting of custom profile fields * - Accessed with ?action=admin;area=featuresettings;sa=profile * * @uses sub template show_custom_profile */ public function action_profile() { global $txt, $scripturl, $context; loadTemplate('ManageFeatures'); $context['page_title'] = $txt['custom_profile_title']; $context['sub_template'] = 'show_custom_profile'; // What about standard fields they can tweak? $standard_fields = array('location', 'gender', 'website', 'personal_text', 'posts', 'warning_status'); // What fields can't you put on the registration page? $context['fields_no_registration'] = array('posts', 'warning_status'); // Are we saving any standard field changes? if (isset($_POST['save'])) { checkSession(); validateToken('admin-scp'); $changes = array(); // Do the active ones first. $disable_fields = array_flip($standard_fields); if (!empty($_POST['active'])) { foreach ($_POST['active'] as $value) { if (isset($disable_fields[$value])) { unset($disable_fields[$value]); } } } // What we have left! $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); // Things we want to show on registration? $reg_fields = array(); if (!empty($_POST['reg'])) { foreach ($_POST['reg'] as $value) { if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) { $reg_fields[] = $value; } } } // What we have left! $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); if (!empty($changes)) { updateSettings($changes); } } createToken('admin-scp'); require_once SUBSDIR . '/GenericList.class.php'; require_once SUBSDIR . '/ManageFeatures.subs.php'; // Create a listing for all our standard fields $listOptions = array('id' => 'standard_profile_fields', 'title' => $txt['standard_profile_title'], 'base_href' => $scripturl . '?action=admin;area=featuresettings;sa=profile', 'get_items' => array('function' => 'list_getProfileFields', 'params' => array(true)), 'columns' => array('field' => array('header' => array('value' => $txt['standard_profile_field']), 'data' => array('db' => 'label', 'style' => 'width: 60%;')), 'active' => array('header' => array('value' => $txt['custom_edit_active'], 'class' => 'centertext'), 'data' => array('function' => create_function('$rowData', ' $isChecked = $rowData[\'disabled\'] ? \'\' : \' checked="checked"\'; $onClickHandler = $rowData[\'can_show_register\'] ? sprintf(\'onclick="document.getElementById(\\\'reg_%1$s\\\').disabled = !this.checked;"\', $rowData[\'id\']) : \'\'; return sprintf(\'<input type="checkbox" name="active[]" id="active_%1$s" value="%1$s" class="input_check" %2$s %3$s />\', $rowData[\'id\'], $isChecked, $onClickHandler); '), 'style' => 'width: 20%;', 'class' => 'centertext')), 'show_on_registration' => array('header' => array('value' => $txt['custom_edit_registration'], 'class' => 'centertext'), 'data' => array('function' => create_function('$rowData', ' $isChecked = $rowData[\'on_register\'] && !$rowData[\'disabled\'] ? \' checked="checked"\' : \'\'; $isDisabled = $rowData[\'can_show_register\'] ? \'\' : \' disabled="disabled"\'; return sprintf(\'<input type="checkbox" name="reg[]" id="reg_%1$s" value="%1$s" class="input_check" %2$s %3$s />\', $rowData[\'id\'], $isChecked, $isDisabled); '), 'style' => 'width: 20%;', 'class' => 'centertext'))), 'form' => array('href' => $scripturl . '?action=admin;area=featuresettings;sa=profile', 'name' => 'standardProfileFields', 'token' => 'admin-scp'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '<input type="submit" name="save" value="' . $txt['save'] . '" class="right_submit" />'))); createList($listOptions); // And now we do the same for all of our custom ones $token = createToken('admin-sort'); $listOptions = array('id' => 'custom_profile_fields', 'title' => $txt['custom_profile_title'], 'base_href' => $scripturl . '?action=admin;area=featuresettings;sa=profile', 'default_sort_col' => 'vieworder', 'no_items_label' => $txt['custom_profile_none'], 'items_per_page' => 25, 'sortable' => true, 'get_items' => array('function' => 'list_getProfileFields', 'params' => array(false)), 'get_count' => array('function' => 'list_getProfileFieldSize'), 'columns' => array('vieworder' => array('header' => array('value' => '', 'style' => 'display: none'), 'data' => array('db' => 'vieworder', 'style' => 'display: none'), 'sort' => array('default' => 'vieworder')), 'field_name' => array('header' => array('value' => $txt['custom_profile_fieldname']), 'data' => array('function' => create_function('$rowData', ' global $scripturl; return sprintf(\'<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>\', $scripturl, $rowData[\'id_field\'], $rowData[\'field_name\'], $rowData[\'field_desc\']); '), 'style' => 'width: 65%;'), 'sort' => array('default' => 'field_name', 'reverse' => 'field_name DESC')), 'field_type' => array('header' => array('value' => $txt['custom_profile_fieldtype']), 'data' => array('function' => create_function('$rowData', ' global $txt; $textKey = sprintf(\'custom_profile_type_%1$s\', $rowData[\'field_type\']); return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; '), 'style' => 'width: 10%;'), 'sort' => array('default' => 'field_type', 'reverse' => 'field_type DESC')), 'cust' => array('header' => array('value' => $txt['custom_profile_active'], 'class' => 'centertext'), 'data' => array('function' => create_function('$rowData', ' $isChecked = $rowData[\'active\'] ? \' checked="checked"\' : \'\'; return sprintf(\'<input type="checkbox" name="cust[]" id="cust_%1$s" value="%1$s" class="input_check"%2$s />\', $rowData[\'id_field\'], $isChecked); '), 'style' => 'width: 8%;', 'class' => 'centertext'), 'sort' => array('default' => 'active DESC', 'reverse' => 'active')), 'placement' => array('header' => array('value' => $txt['custom_profile_placement']), 'data' => array('function' => create_function('$rowData', ' global $txt; return $txt[\'custom_profile_placement_\' . (empty($rowData[\'placement\']) ? \'standard\' : ($rowData[\'placement\'] == 1 ? \'withicons\' : \'abovesignature\'))]; '), 'style' => 'width: 5%;'), 'sort' => array('default' => 'placement DESC', 'reverse' => 'placement')), 'show_on_registration' => array('data' => array('sprintf' => array('format' => '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=%1$s">' . $txt['modify'] . '</a>', 'params' => array('id_field' => false)), 'style' => 'width: 5%;'))), 'form' => array('href' => $scripturl . '?action=admin;area=featuresettings;sa=profileedit', 'name' => 'customProfileFields', 'token' => 'admin-scp'), 'additional_rows' => array(array('class' => 'submitbutton', 'position' => 'below_table_data', 'value' => '<input type="submit" name="onoff" value="' . $txt['save'] . '" class="right_submit" /> <input type="submit" name="new" value="' . $txt['custom_profile_make_new'] . '" class="right_submit" />'), array('position' => 'top_of_list', 'value' => '<p class="infobox">' . $txt['custom_profile_sort'] . '</p>')), 'javascript' => ' $().elkSortable({ sa: "profileorder", error: "' . $txt['admin_order_error'] . '", title: "' . $txt['admin_order_title'] . '", placeholder: "ui-state-highlight", href: "?action=admin;area=featuresettings;sa=profile", token: {token_var: "' . $token['admin-sort_token_var'] . '", token_id: "' . $token['admin-sort_token'] . '"} }); '); createList($listOptions); }
function ModifyLanguages() { global $txt, $context, $scripturl; global $user_info, $smcFunc, $sourcedir, $language, $boarddir, $forum_version; // Setting a new default? if (!empty($_POST['set_default']) && !empty($_POST['def_language'])) { checkSession(); if ($_POST['def_language'] != $language) { require_once $sourcedir . '/Subs-Admin.php'; updateSettingsFile(array('language' => '\'' . $_POST['def_language'] . '\'')); $language = $_POST['def_language']; } } $listOptions = array('id' => 'language_list', 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=languages', 'title' => $txt['edit_languages'], 'get_items' => array('function' => 'list_getLanguages'), 'get_count' => array('function' => 'list_getNumLanguages'), 'columns' => array('default' => array('header' => array('value' => $txt['languages_default']), 'data' => array('function' => create_function('$rowData', ' return \'<input type="radio" name="def_language" value="\' . $rowData[\'id\'] . \'" \' . ($rowData[\'default\'] ? \'checked="checked"\' : \'\') . \' onclick="highlightSelected(\\\'list_language_list_\' . $rowData[\'id\'] . \'\\\');" class="input_radio" />\'; '), 'style' => 'text-align: center; width: 8%;')), 'name' => array('header' => array('value' => $txt['languages_lang_name']), 'data' => array('function' => create_function('$rowData', ' global $scripturl, $context; return sprintf(\'<a href="%1$s?action=admin;area=languages;sa=editlang;lid=%2$s">%3$s</a>\', $scripturl, $rowData[\'id\'], $rowData[\'name\']); '))), 'character_set' => array('header' => array('value' => $txt['languages_character_set']), 'data' => array('db_htmlsafe' => 'char_set')), 'count' => array('header' => array('value' => $txt['languages_users']), 'data' => array('db_htmlsafe' => 'count', 'style' => 'text-align: center')), 'locale' => array('header' => array('value' => $txt['languages_locale']), 'data' => array('db_htmlsafe' => 'locale'))), 'form' => array('href' => $scripturl . '?action=admin;area=languages'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" /><input type="submit" name="set_default" value="' . $txt['save'] . '"' . (is_writable($boarddir . '/Settings.php') ? '' : ' disabled="disabled"') . ' class="button_submit" />', 'style' => 'text-align: right;')), 'javascript' => ' var prevClass = ""; var prevDiv = ""; function highlightSelected(box) { if (prevClass != "") prevDiv.className = prevClass; prevDiv = document.getElementById(box); prevClass = prevDiv.className; prevDiv.className = "highlight2"; } highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '"); '); // Display a warning if we cannot edit the default setting. if (!is_writable($boarddir . '/Settings.php')) { $listOptions['additional_rows'][] = array('position' => 'after_title', 'value' => $txt['language_settings_writable'], 'class' => 'smalltext alert'); } require_once $sourcedir . '/Subs-List.php'; createList($listOptions); $context['sub_template'] = 'show_list'; $context['default_list'] = 'language_list'; }
function KB_mreports() { global $scripturl, $sourcedir, $txt, $smcFunc, $context; isAllowedTo('manage_kb'); $list_options = array('id' => 'kb_know_reports', 'title' => $txt['kb_rlist1'], 'items_per_page' => 30, 'base_href' => $scripturl . '?action=kb;area=manage', 'default_sort_col' => 'id', 'start_var_name' => 'startreport', 'request_vars' => array('desc' => 'descreport', 'sort' => 'sortreport'), 'get_items' => array('function' => create_function('$start, $items_per_page, $sort', ' global $context, $smcFunc; $request = $smcFunc[\'db_query\'](\'\', \' SELECT k.id, k.id_article, k.id_member, k.comment, m.id_member, m.real_name, k.date FROM {db_prefix}kb_reports AS k LEFT JOIN {db_prefix}members AS m ON (m.id_member = k.id_member) ORDER BY {raw:sort} LIMIT {int:start}, {int:per_page}\', array( \'sort\' => $sort, \'start\' => $start, \'per_page\' => $items_per_page, ) ); $kbcn = array(); while ($row = $smcFunc[\'db_fetch_assoc\']($request)) $kbcn[] = $row; $smcFunc[\'db_free_result\']($request); return $kbcn; ')), 'get_count' => array('function' => create_function('', ' global $smcFunc; $request = $smcFunc[\'db_query\'](\'\', \' SELECT COUNT(*) FROM {db_prefix}kb_reports\', array()); list ($total_kbn) = $smcFunc[\'db_fetch_row\']($request); $smcFunc[\'db_free_result\']($request); return $total_kbn; ')), 'no_items_label' => $txt['knowledgebasenone'], 'columns' => array('id' => array('header' => array('value' => $txt['kb_rlistcomment']), 'data' => array('function' => create_function('$row', ' global $scripturl; return \'\'.$row[\'comment\'].\'\'; '), 'style' => 'width: 20%; text-align: left;'), 'sort' => array('default' => 'id', 'reverse' => 'id DESC')), 'real_name' => array('header' => array('value' => $txt['kb_rlistnor1']), 'data' => array('function' => create_function('$row', ' global $scripturl; return \'<a href="\'.$scripturl.\'?action=profile;u=\'.$row[\'id_member\'].\'">\'.$row[\'real_name\'].\'</a>\'; '), 'style' => 'width: 4%; text-align: center;'), 'sort' => array('default' => 'real_name', 'reverse' => 'real_name DESC')), 'date' => array('header' => array('value' => $txt['knowledgebasecreated']), 'data' => array('function' => create_function('$row', ' return timeformat($row[\'date\']); '), 'style' => 'width: 5%; text-align: center;'), 'sort' => array('default' => 'date', 'reverse' => 'date DESC')), 'id_article' => array('header' => array('value' => '<input type="checkbox" name="all" class="input_check" onclick="invertAll(this, this.form);" />'), 'data' => array('function' => create_function('$row', ' global $sc, $txt, $scripturl; return \'[<a href="\'.$scripturl.\'?action=kb;area=article;cont=\'.$row[\'id_article\'].\'">\'.$txt[\'kb_rlistnor44\'].\'</a>] <input type="checkbox" class="input_check" name="delete[]" value="\' . $row[\'id\'] . \'" />\'; '), 'style' => 'width: 2%; text-align: center;'), 'sort' => array('default' => 'id_article', 'reverse' => 'id_article DESC'))), 'form' => array('href' => $scripturl . '?action=kb;area=manage', 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array($context['session_var'] => $context['session_id'])), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => ' <input type="submit" name="remove" value="' . $txt['kb_remove_log2'] . '" class="button_submit" onclick="return confirmSubmit();" /> <input type="submit" name="removeall" value="' . $txt['kb_remove_log1'] . '" class="button_submit" onclick="return confirmSubmit();" />'))); require_once $sourcedir . '/Subs-List.php'; createList($list_options); if (isset($_POST['removeall'])) { checkSession(); $query_params = array('table' => 'kb_reports', 'where' => ''); $query_data = array(); KB_DeleteData($query_params, $query_data); $mes = $txt['kb_del_areports']; KB_log_actions('del_report', 0, $mes); KB_cleanCache(); redirectexit('action=kb;area=manage'); } elseif (!empty($_POST['remove']) && isset($_POST['delete'])) { checkSession(); $query_params = array('table' => 'kb_reports', 'where' => 'id IN ({array_string:delete_actions})'); $query_data = array('delete_actions' => array_unique($_POST['delete'])); KB_DeleteData($query_params, $query_data); $mes = $txt['kb_del_reports']; KB_log_actions('del_report', 0, $mes); KB_cleanCache(); redirectexit('action=kb;area=manage'); } }
function EditMessageIcons() { global $user_info, $modSettings, $context, $settings, $txt; global $boarddir, $smcFunc, $scripturl, $sourcedir; // Get a list of icons. $context['icons'] = array(); $request = $smcFunc['db_query']('', ' SELECT m.id_icon, m.title, m.filename, m.icon_order, m.id_board, b.name AS board_name FROM {db_prefix}message_icons AS m LEFT JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board) WHERE ({query_see_board} OR b.id_board IS NULL)', array()); $last_icon = 0; $trueOrder = 0; while ($row = $smcFunc['db_fetch_assoc']($request)) { $context['icons'][$row['id_icon']] = array('id' => $row['id_icon'], 'title' => $row['title'], 'filename' => $row['filename'], 'image_url' => $settings[file_exists($settings['theme_dir'] . '/images/post/' . $row['filename'] . '.gif') ? 'actual_images_url' : 'default_images_url'] . '/post/' . $row['filename'] . '.gif', 'board_id' => $row['id_board'], 'board' => empty($row['board_name']) ? $txt['icons_edit_icons_all_boards'] : $row['board_name'], 'order' => $row['icon_order'], 'true_order' => $trueOrder++, 'after' => $last_icon); $last_icon = $row['id_icon']; } $smcFunc['db_free_result']($request); // Submitting a form? if (isset($_POST[$context['session_var']])) { checkSession(); // Deleting icons? if (isset($_POST['delete']) && !empty($_POST['checked_icons'])) { $deleteIcons = array(); foreach ($_POST['checked_icons'] as $icon) { $deleteIcons[] = (int) $icon; } // Do the actual delete! $smcFunc['db_query']('', ' DELETE FROM {db_prefix}message_icons WHERE id_icon IN ({array_int:icon_list})', array('icon_list' => $deleteIcons)); } elseif ($context['sub_action'] == 'editicon' && isset($_GET['icon'])) { $_GET['icon'] = (int) $_GET['icon']; // Do some preperation with the data... like check the icon exists *somewhere* if (strpos($_POST['icon_filename'], '.gif') !== false) { $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); } if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.gif')) { fatal_lang_error('icon_not_found'); } elseif (strlen($_POST['icon_filename']) > 16) { fatal_lang_error('icon_name_too_long'); } elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) { fatal_lang_error('icon_after_itself'); } // First do the sorting... if this is an edit reduce the order of everything after it by one ;) if ($_GET['icon'] != 0) { $oldOrder = $context['icons'][$_GET['icon']]['true_order']; foreach ($context['icons'] as $id => $data) { if ($data['true_order'] > $oldOrder) { $context['icons'][$id]['true_order']--; } } } // If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql) if (empty($_GET['icon']) && empty($context['icons'])) { $_GET['icon'] = 1; } // Get the new order. $newOrder = $_POST['icon_location'] == 0 ? 0 : $context['icons'][$_POST['icon_location']]['true_order'] + 1; // Do the same, but with the one that used to be after this icon, done to avoid conflict. foreach ($context['icons'] as $id => $data) { if ($data['true_order'] >= $newOrder) { $context['icons'][$id]['true_order']++; } } // Finally set the current icon's position! $context['icons'][$_GET['icon']]['true_order'] = $newOrder; // Simply replace the existing data for the other bits. $context['icons'][$_GET['icon']]['title'] = $_POST['icon_description']; $context['icons'][$_GET['icon']]['filename'] = $_POST['icon_filename']; $context['icons'][$_GET['icon']]['board_id'] = (int) $_POST['icon_board']; // Do a huge replace ;) $iconInsert = array(); $iconInsert_new = array(); foreach ($context['icons'] as $id => $icon) { if ($id != 0) { $iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); } else { $iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); } } $smcFunc['db_insert']('replace', '{db_prefix}message_icons', array('id_icon' => 'int', 'id_board' => 'int', 'title' => 'string-80', 'filename' => 'string-80', 'icon_order' => 'int'), $iconInsert, array('id_icon')); if (!empty($iconInsert_new)) { $smcFunc['db_insert']('replace', '{db_prefix}message_icons', array('id_board' => 'int', 'title' => 'string-80', 'filename' => 'string-80', 'icon_order' => 'int'), $iconInsert_new, array('id_icon')); } } // Sort by order, so it is quicker :) $smcFunc['db_query']('alter_table_icons', ' ALTER TABLE {db_prefix}message_icons ORDER BY icon_order', array('db_error_skip' => true)); // Unless we're adding a new thing, we'll escape if (!isset($_POST['add'])) { redirectexit('action=admin;area=smileys;sa=editicons'); } } $context[$context['admin_menu_name']]['current_subsection'] = 'editicons'; $listOptions = array('id' => 'message_icon_list', 'base_href' => $scripturl . '?action=admin;area=smileys;sa=editicons', 'get_items' => array('function' => 'list_getMessageIcons'), 'no_items_label' => $txt['icons_no_entries'], 'columns' => array('icon' => array('data' => array('function' => create_function('$rowData', ' global $settings; $images_url = $settings[file_exists(sprintf(\'%1$s/images/post/%2$s.gif\', $settings[\'theme_dir\'], $rowData[\'filename\'])) ? \'actual_images_url\' : \'default_images_url\']; return sprintf(\'<img src="%1$s/post/%2$s.gif" alt="%3$s" />\', $images_url, $rowData[\'filename\'], htmlspecialchars($rowData[\'title\'])); ')), 'style' => 'text-align: center;'), 'filename' => array('header' => array('value' => $txt['smileys_filename']), 'data' => array('sprintf' => array('format' => '%1$s.gif', 'params' => array('filename' => true)))), 'tooltip' => array('header' => array('value' => $txt['smileys_description']), 'data' => array('db_htmlsafe' => 'title', 'class' => 'windowbg')), 'board' => array('header' => array('value' => $txt['icons_board']), 'data' => array('function' => create_function('$rowData', ' global $txt; return empty($rowData[\'board_name\']) ? $txt[\'icons_edit_icons_all_boards\'] : $rowData[\'board_name\']; '))), 'modify' => array('header' => array('value' => $txt['smileys_modify']), 'data' => array('sprintf' => array('format' => '<a href="' . $scripturl . '?action=admin;area=smileys;sa=editicon;icon=%1$s">' . $txt['smileys_modify'] . '</a>', 'params' => array('id_icon' => false)), 'style' => 'text-align: center')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />'), 'data' => array('sprintf' => array('format' => '<input type="checkbox" name="checked_icons[]" value="%1$d" class="input_check" />', 'params' => array('id_icon' => false)), 'style' => 'text-align: center'))), 'form' => array('href' => $scripturl . '?action=admin;area=smileys;sa=editicons'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '<input type="submit" name="delete" value="' . $txt['quickmod_delete_selected'] . '" style="float: right" class="button_submit" />[<a href="' . $scripturl . '?action=admin;area=smileys;sa=editicon">' . $txt['icons_add_new'] . '</a>]'))); require_once $sourcedir . '/Subs-List.php'; createList($listOptions); // If we're adding/editing an icon we'll need a list of boards if ($context['sub_action'] == 'editicon' || isset($_POST['add'])) { // Force the sub_template just in case. $context['sub_template'] = 'editicon'; $context['new_icon'] = !isset($_GET['icon']); // Get the properties of the current icon from the icon list. if (!$context['new_icon']) { $context['icon'] = $context['icons'][$_GET['icon']]; } // Get a list of boards needed for assigning this icon to a specific board. $boardListOptions = array('use_permissions' => true, 'selected_board' => isset($context['icon']['board_id']) ? $context['icon']['board_id'] : 0); require_once $sourcedir . '/Subs-MessageIndex.php'; $context['categories'] = getBoardList($boardListOptions); } }
/** * Shows an overview of the current membergroups. * Called by ?action=admin;area=membergroups. * Requires the manage_membergroups permission. * Splits the membergroups in regular ones and post count based groups. * It also counts the number of members part of each membergroup. * * @uses ManageMembergroups template, main. */ function MembergroupIndex() { global $txt, $scripturl, $context, $settings, $smcFunc, $sourcedir; $context['page_title'] = $txt['membergroups_title']; // The first list shows the regular membergroups. $listOptions = array('id' => 'regular_membergroups_list', 'title' => $txt['membergroups_regular'], 'base_href' => $scripturl . '?action=admin;area=membergroups' . (isset($_REQUEST['sort2']) ? ';sort2=' . urlencode($_REQUEST['sort2']) : ''), 'default_sort_col' => 'name', 'get_items' => array('file' => $sourcedir . '/Subs-Membergroups.php', 'function' => 'list_getMembergroups', 'params' => array('regular')), 'columns' => array('name' => array('header' => array('value' => $txt['membergroups_name']), 'data' => array('function' => create_function('$rowData', ' global $scripturl; // Since the moderator group has no explicit members, no link is needed. if ($rowData[\'id_group\'] == 3) $group_name = $rowData[\'group_name\']; else { $color_style = empty($rowData[\'online_color\']) ? \'\' : sprintf(\' style="color: %1$s;"\', $rowData[\'online_color\']); $group_name = sprintf(\'<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>\', $scripturl, $rowData[\'id_group\'], $color_style, $rowData[\'group_name\']); } // Add a help option for moderator and administrator. if ($rowData[\'id_group\'] == 1) $group_name .= sprintf(\' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)\', $scripturl); elseif ($rowData[\'id_group\'] == 3) $group_name .= sprintf(\' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)\', $scripturl); return $group_name; ')), 'sort' => array('default' => 'CASE WHEN id_group < 4 THEN id_group ELSE 4 END, group_name', 'reverse' => 'CASE WHEN id_group < 4 THEN id_group ELSE 4 END, group_name DESC')), 'icons' => array('header' => array('value' => $txt['membergroups_icons']), 'data' => array('function' => create_function('$rowData', ' global $settings; $icons = explode(\'#\', $rowData[\'icons\']); // In case no icons are setup, return with nothing if (empty($icons[0]) || empty($icons[1])) return \'\'; // Otherwise repeat the image a given number of times. else { $image = sprintf(\'<img src="%1$s/%2$s" alt="*" />\', $settings[\'images_url\'], $icons[1]); return str_repeat($image, $icons[0]); } ')), 'sort' => array('default' => 'icons', 'reverse' => 'icons DESC')), 'members' => array('header' => array('value' => $txt['membergroups_members_top']), 'data' => array('function' => create_function('$rowData', ' global $txt; // No explicit members for the moderator group. return $rowData[\'id_group\'] == 3 ? $txt[\'membergroups_guests_na\'] : $rowData[\'num_members\']; '), 'style' => 'text-align: center'), 'sort' => array('default' => 'CASE WHEN id_group < 4 THEN id_group ELSE 4 END, 1', 'reverse' => 'CASE WHEN id_group < 4 THEN id_group ELSE 4 END, 1 DESC')), 'modify' => array('header' => array('value' => $txt['modify']), 'data' => array('sprintf' => array('format' => '<a href="' . $scripturl . '?action=admin;area=membergroups;sa=edit;group=%1$d">' . $txt['membergroups_modify'] . '</a>', 'params' => array('id_group' => false)), 'style' => 'text-align: center'))), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '<a class="button_link" href="' . $scripturl . '?action=admin;area=membergroups;sa=add;generalgroup">' . $txt['membergroups_add_group'] . '</a>'))); require_once $sourcedir . '/Subs-List.php'; createList($listOptions); // The second list shows the post count based groups. $listOptions = array('id' => 'post_count_membergroups_list', 'title' => $txt['membergroups_post'], 'base_href' => $scripturl . '?action=admin;area=membergroups' . (isset($_REQUEST['sort']) ? ';sort=' . urlencode($_REQUEST['sort']) : ''), 'default_sort_col' => 'required_posts', 'request_vars' => array('sort' => 'sort2', 'desc' => 'desc2'), 'get_items' => array('file' => $sourcedir . '/Subs-Membergroups.php', 'function' => 'list_getMembergroups', 'params' => array('post_count')), 'columns' => array('name' => array('header' => array('value' => $txt['membergroups_name']), 'data' => array('function' => create_function('$rowData', ' global $scripturl; $colorStyle = empty($rowData[\'online_color\']) ? \'\' : sprintf(\' style="color: %1$s;"\', $rowData[\'online_color\']); return sprintf(\'<a href="%1$s?action=moderate;area=viewgroups;sa=members;group=%2$d"%3$s>%4$s</a>\', $scripturl, $rowData[\'id_group\'], $colorStyle, $rowData[\'group_name\']); ')), 'sort' => array('default' => 'group_name', 'reverse' => 'group_name DESC')), 'icons' => array('header' => array('value' => $txt['membergroups_icons']), 'data' => array('function' => create_function('$rowData', ' global $settings; $icons = explode(\'#\', $rowData[\'icons\']); if (empty($icons[0]) || empty($icons[1])) return \'\'; else { $icon_image = sprintf(\'<img src="%1$s/%2$s" alt="*" />\', $settings[\'images_url\'], $icons[1]); return str_repeat($icon_image, $icons[0]); } ')), 'sort' => array('default' => 'CASE WHEN id_group < 4 THEN id_group ELSE 4 END, icons', 'reverse' => 'CASE WHEN id_group < 4 THEN id_group ELSE 4 END, icons DESC')), 'members' => array('header' => array('value' => $txt['membergroups_members_top']), 'data' => array('db' => 'num_members', 'style' => 'text-align: center'), 'sort' => array('default' => '1 DESC', 'reverse' => '1')), 'required_posts' => array('header' => array('value' => $txt['membergroups_min_posts']), 'data' => array('db' => 'min_posts', 'style' => 'text-align: center'), 'sort' => array('default' => 'min_posts', 'reverse' => 'min_posts DESC')), 'modify' => array('header' => array('value' => $txt['modify']), 'data' => array('sprintf' => array('format' => '<a href="' . $scripturl . '?action=admin;area=membergroups;sa=edit;group=%1$d">' . $txt['membergroups_modify'] . '</a>', 'params' => array('id_group' => false)), 'style' => 'text-align: center'))), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '<a class="button_link" href="' . $scripturl . '?action=admin;area=membergroups;sa=add;postgroup">' . $txt['membergroups_add_group'] . '</a>'))); createList($listOptions); }
function GroupRequests() { global $txt, $context, $scripturl, $user_info, $sourcedir, $smcFunc, $modSettings, $language; // Set up the template stuff... $context['page_title'] = $txt['mc_group_requests']; $context['sub_template'] = 'show_list'; // Verify we can be here. if ($user_info['mod_cache']['gq'] == '0=1') { isAllowedTo('manage_membergroups'); } // Normally, we act normally... $where = $user_info['mod_cache']['gq'] == '1=1' || $user_info['mod_cache']['gq'] == '0=1' ? $user_info['mod_cache']['gq'] : 'lgr.' . $user_info['mod_cache']['gq']; $where_parameters = array(); // We've submitted? if (isset($_POST[$context['session_var']]) && !empty($_POST['groupr']) && !empty($_POST['req_action'])) { checkSession('post'); // Clean the values. foreach ($_POST['groupr'] as $k => $request) { $_POST['groupr'][$k] = (int) $request; } // If we are giving a reason (And why shouldn't we?), then we don't actually do much. if ($_POST['req_action'] == 'reason') { // Different sub template... $context['sub_template'] = 'group_request_reason'; // And a limitation. We don't care that the page number bit makes no sense, as we don't need it! $where .= ' AND lgr.id_request IN ({array_int:request_ids})'; $where_parameters['request_ids'] = $_POST['groupr']; $context['group_requests'] = list_getGroupRequests(0, $modSettings['defaultMaxMessages'], 'lgr.id_request', $where, $where_parameters); // Let obExit etc sort things out. obExit(); } else { // Get the details of all the members concerned... $request = $smcFunc['db_query']('', ' SELECT lgr.id_request, lgr.id_member, lgr.id_group, mem.email_address, mem.id_group AS primary_group, mem.additional_groups AS additional_groups, mem.lngfile, mem.member_name, mem.notify_types, mg.hidden, mg.group_name FROM {db_prefix}log_group_requests AS lgr INNER JOIN {db_prefix}members AS mem ON (mem.id_member = lgr.id_member) INNER JOIN {db_prefix}membergroups AS mg ON (mg.id_group = lgr.id_group) WHERE ' . $where . ' AND lgr.id_request IN ({array_int:request_list}) ORDER BY mem.lngfile', array('request_list' => $_POST['groupr'])); $email_details = array(); $group_changes = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { $row['lngfile'] = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; // If we are approving work out what their new group is. if ($_POST['req_action'] == 'approve') { // For people with more than one request at once. if (isset($group_changes[$row['id_member']])) { $row['additional_groups'] = $group_changes[$row['id_member']]['add']; $row['primary_group'] = $group_changes[$row['id_member']]['primary']; } else { $row['additional_groups'] = explode(',', $row['additional_groups']); } // Don't have it already? if ($row['primary_group'] == $row['id_group'] || in_array($row['id_group'], $row['additional_groups'])) { continue; } // Should it become their primary? if ($row['primary_group'] == 0 && $row['hidden'] == 0) { $row['primary_group'] = $row['id_group']; } else { $row['additional_groups'][] = $row['id_group']; } // Add them to the group master list. $group_changes[$row['id_member']] = array('primary' => $row['primary_group'], 'add' => $row['additional_groups']); } // Add required information to email them. if ($row['notify_types'] != 4) { $email_details[] = array('rid' => $row['id_request'], 'member_id' => $row['id_member'], 'member_name' => $row['member_name'], 'group_id' => $row['id_group'], 'group_name' => $row['group_name'], 'email' => $row['email_address'], 'language' => $row['lngfile']); } } $smcFunc['db_free_result']($request); // Remove the evidence... $smcFunc['db_query']('', ' DELETE FROM {db_prefix}log_group_requests WHERE id_request IN ({array_int:request_list})', array('request_list' => $_POST['groupr'])); // Ensure everyone who is online gets their changes right away. updateSettings(array('settings_updated' => time())); if (!empty($email_details)) { require_once $sourcedir . '/Subs-Post.php'; // They are being approved? if ($_POST['req_action'] == 'approve') { // Make the group changes. foreach ($group_changes as $id => $groups) { // Sanity check! foreach ($groups['add'] as $key => $value) { if ($value == 0 || trim($value) == '') { unset($groups['add'][$key]); } } $smcFunc['db_query']('', ' UPDATE {db_prefix}members SET id_group = {int:primary_group}, additional_groups = {string:additional_groups} WHERE id_member = {int:selected_member}', array('primary_group' => $groups['primary'], 'selected_member' => $id, 'additional_groups' => implode(',', $groups['add']))); } $lastLng = $user_info['language']; foreach ($email_details as $email) { $replacements = array('USERNAME' => $email['member_name'], 'GROUPNAME' => $email['group_name']); $emaildata = loadEmailTemplate('mc_group_approve', $replacements, $email['language']); sendmail($email['email'], $emaildata['subject'], $emaildata['body'], null, null, false, 2); } } else { // Same as for approving, kind of. $lastLng = $user_info['language']; foreach ($email_details as $email) { $custom_reason = isset($_POST['groupreason']) && isset($_POST['groupreason'][$email['rid']]) ? $_POST['groupreason'][$email['rid']] : ''; $replacements = array('USERNAME' => $email['member_name'], 'GROUPNAME' => $email['group_name']); if (!empty($custom_reason)) { $replacements['REASON'] = $custom_reason; } $emaildata = loadEmailTemplate(empty($custom_reason) ? 'mc_group_reject' : 'mc_group_reject_reason', $replacements, $email['language']); sendmail($email['email'], $emaildata['subject'], $emaildata['body'], null, null, false, 2); } } } // Restore the current language. loadLanguage('ModerationCenter'); } } // We're going to want this for making our list. require_once $sourcedir . '/Subs-List.php'; // This is all the information required for a group listing. $listOptions = array('id' => 'group_request_list', 'title' => $txt['mc_group_requests'], 'width' => '100%', 'items_per_page' => $modSettings['defaultMaxMessages'], 'no_items_label' => $txt['mc_groupr_none_found'], 'base_href' => $scripturl . '?action=groups;sa=requests', 'default_sort_col' => 'member', 'get_items' => array('function' => 'list_getGroupRequests', 'params' => array($where, $where_parameters)), 'get_count' => array('function' => 'list_getGroupRequestCount', 'params' => array($where, $where_parameters)), 'columns' => array('member' => array('header' => array('value' => $txt['mc_groupr_member']), 'data' => array('db' => 'member_link'), 'sort' => array('default' => 'mem.member_name', 'reverse' => 'mem.member_name DESC')), 'group' => array('header' => array('value' => $txt['mc_groupr_group']), 'data' => array('db' => 'group_link'), 'sort' => array('default' => 'mg.group_name', 'reverse' => 'mg.group_name DESC')), 'reason' => array('header' => array('value' => $txt['mc_groupr_reason']), 'data' => array('db' => 'reason')), 'action' => array('header' => array('value' => '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" />', 'style' => 'width: 4%;'), 'data' => array('sprintf' => array('format' => '<input type="checkbox" name="groupr[]" value="%1$d" class="input_check" />', 'params' => array('id' => false)), 'style' => 'text-align: center;'))), 'form' => array('href' => $scripturl . '?action=groups;sa=requests', 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array($context['session_var'] => $context['session_id'])), 'additional_rows' => array(array('position' => 'bottom_of_list', 'value' => ' <select name="req_action" onchange="if (this.value != 0 && (this.value == \'reason\' || confirm(\'' . $txt['mc_groupr_warning'] . '\'))) this.form.submit();"> <option value="0">' . $txt['with_selected'] . ':</option> <option value="0">---------------------</option> <option value="approve">' . $txt['mc_groupr_approve'] . '</option> <option value="reject">' . $txt['mc_groupr_reject'] . '</option> <option value="reason">' . $txt['mc_groupr_reject_w_reason'] . '</option> </select> <input type="submit" name="go" value="' . $txt['go'] . '" onclick="var sel = document.getElementById(\'req_action\'); if (sel.value != 0 && sel.value != \'reason\' && !confirm(\'' . $txt['mc_groupr_warning'] . '\')) return false;" class="button_submit" />', 'align' => 'right'))); // Create the request list. createList($listOptions); $context['default_list'] = 'group_request_list'; }
/** * Show the log of all tasks that have taken place. * * @uses ManageScheduledTasks language file */ public function action_log() { global $scripturl, $context, $txt; require_once SUBSDIR . '/ScheduledTasks.subs.php'; // Lets load the language just in case we are outside the Scheduled area. loadLanguage('ManageScheduledTasks'); // Empty the log? if (!empty($_POST['removeAll'])) { checkSession(); validateToken('admin-tl'); emptyTaskLog(); } // Setup the list. $listOptions = array('id' => 'task_log', 'items_per_page' => 30, 'title' => $txt['scheduled_log'], 'no_items_label' => $txt['scheduled_log_empty'], 'base_href' => $context['admin_area'] == 'scheduledtasks' ? $scripturl . '?action=admin;area=scheduledtasks;sa=tasklog' : $scripturl . '?action=admin;area=logs;sa=tasklog', 'default_sort_col' => 'date', 'get_items' => array('function' => array($this, 'list_getTaskLogEntries')), 'get_count' => array('function' => array($this, 'list_getNumTaskLogEntries')), 'columns' => array('name' => array('header' => array('value' => $txt['scheduled_tasks_name']), 'data' => array('db' => 'name')), 'date' => array('header' => array('value' => $txt['scheduled_log_time_run']), 'data' => array('function' => create_function('$rowData', ' return standardTime($rowData[\'time_run\'], true); ')), 'sort' => array('default' => 'lst.id_log DESC', 'reverse' => 'lst.id_log')), 'time_taken' => array('header' => array('value' => $txt['scheduled_log_time_taken']), 'data' => array('sprintf' => array('format' => $txt['scheduled_log_time_taken_seconds'], 'params' => array('time_taken' => false))), 'sort' => array('default' => 'lst.time_taken', 'reverse' => 'lst.time_taken DESC')), 'task_completed' => array('header' => array('value' => $txt['scheduled_log_completed']), 'data' => array('function' => create_function('$rowData', ' global $settings, $txt; return \'<img src="\' . $settings[\'images_url\'] . \'/admin/complete_\' . ($rowData[\'task_completed\'] ? \'success\' : \'fail\') . \'.png" alt="\' . sprintf($txt[$rowData[\'task_completed\'] ? \'maintain_done\' : \'maintain_fail\'], $rowData[\'name\']) . \'" />\'; ')))), 'form' => array('href' => $context['admin_area'] == 'scheduledtasks' ? $scripturl . '?action=admin;area=scheduledtasks;sa=tasklog' : $scripturl . '?action=admin;area=logs;sa=tasklog', 'token' => 'admin-tl'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => ' <input type="submit" name="removeAll" value="' . $txt['scheduled_log_empty_log'] . '" onclick="return confirm(\'' . $txt['scheduled_log_empty_log_confirm'] . '\');" class="right_submit" />'), array('position' => 'after_title', 'value' => $txt['scheduled_tasks_time_offset'], 'class' => 'windowbg2'))); createToken('admin-tl'); require_once SUBSDIR . '/GenericList.class.php'; createList($listOptions); $context['sub_template'] = 'show_list'; $context['default_list'] = 'task_log'; // Make it all look tify. $context[$context['admin_menu_name']]['current_subsection'] = 'tasklog'; $context['page_title'] = $txt['scheduled_log']; }
$headerLevel = 1; if (!$matches[1]) { $headerLevel += 1; } $section = array('type' => 'section', 'level' => $headerLevel, 'name' => "{$header}", 'items' => array()); $newLines[] = $section; unset($lastSection); $lastSection =& $newLines[count($newLines) - 1]; $listCounter = 1; } } } addListItem($listLines, $currentListEntry); $currentListEntry = false; if ($lastSection !== null) { createList($lastSection['items'], $listLines); } function dumpToText($nodes) { global $cli, $script; $text = ''; foreach ($nodes as $node) { if (is_string($node)) { $text .= $node . "\n"; } else { if (!isset($node['type'])) { var_dump($node); } $type = $node['type']; switch ($type) { case 'title':
/** * View all the custom email bounce templates. * * - Shows all the bounce templates in the system available to this user * - Provides for actions to add or delete them * - Accessed by ?action=admin;area=maillist;sa=emailtemplates; */ public function action_view_bounce_templates() { global $modSettings, $context, $txt, $scripturl; // We'll need this, because bounce templates are stored with warning templates. require_once SUBSDIR . '/Moderation.subs.php'; // Submitting a new one or editing an existing one then pass this request off if (isset($_POST['add']) || isset($_POST['save']) || isset($_REQUEST['tid'])) { return $this->action_modify_bounce_templates(); } elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) { checkSession('post'); validateToken('mod-mlt'); removeWarningTemplate($_POST['deltpl'], 'bnctpl'); } // This is all the information required for showing the email templates. $listOptions = array('id' => 'bounce_template_list', 'title' => $txt['ml_bounce_templates_title'], 'items_per_page' => $modSettings['defaultMaxMessages'], 'no_items_label' => $txt['ml_bounce_templates_none'], 'base_href' => $scripturl . '?action=admin;area=maillist;sa=emailtemplates;' . $context['session_var'] . '=' . $context['session_id'], 'default_sort_col' => 'title', 'get_items' => array('function' => array($this, 'list_getBounceTemplates')), 'get_count' => array('function' => array($this, 'list_getBounceTemplateCount'), 'params' => array('bnctpl')), 'columns' => array('title' => array('header' => array('value' => $txt['ml_bounce_templates_name']), 'data' => array('sprintf' => array('format' => '<a href="' . $scripturl . '?action=admin;area=maillist;sa=emailtemplates;tid=%1$d">%2$s</a>', 'params' => array('id_comment' => false, 'title' => false, 'body' => false))), 'sort' => array('default' => 'template_title', 'reverse' => 'template_title DESC')), 'creator' => array('header' => array('value' => $txt['ml_bounce_templates_creator']), 'data' => array('db' => 'creator'), 'sort' => array('default' => 'creator_name', 'reverse' => 'creator_name DESC')), 'time' => array('header' => array('value' => $txt['ml_bounce_templates_time']), 'data' => array('db' => 'time'), 'sort' => array('default' => 'lc.log_time DESC', 'reverse' => 'lc.log_time')), 'delete' => array('header' => array('value' => '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" />', 'style' => 'width: 4%;', 'class' => 'centertext'), 'data' => array('function' => create_function('$rowData', ' return \'<input type="checkbox" name="deltpl[]" value="\' . $rowData[\'id_comment\'] . \'" class="input_check" />\'; '), 'class' => 'centertext'))), 'form' => array('href' => $scripturl . '?action=admin;area=maillist;sa=emailtemplates', 'token' => 'mod-mlt'), 'additional_rows' => array(array('class' => 'submitbutton', 'position' => 'below_table_data', 'value' => ' <input type="submit" name="delete" value="' . $txt['ml_bounce_template_delete'] . '" onclick="return confirm(\'' . $txt['ml_bounce_template_delete_confirm'] . '\');" class="right_submit" /> <input type="submit" name="add" value="' . $txt['ml_bounce_template_add'] . '" class="right_submit" />'))); // Create the template list. $context['page_title'] = $txt['ml_bounce_templates_title']; createToken('mod-mlt'); require_once SUBSDIR . '/GenericList.class.php'; createList($listOptions); // Show the list $context['sub_template'] = 'show_list'; $context['default_list'] = 'bounce_template_list'; }
function SpiderStats() { global $context, $txt, $sourcedir, $scripturl, $smcFunc; // Force an update of the stats every 60 seconds. if (!isset($_SESSION['spider_stat']) || $_SESSION['spider_stat'] < time() - 60) { consolidateSpiderStats(); $_SESSION['spider_stat'] = time(); } // Get the earliest and latest dates. $request = $smcFunc['db_query']('', ' SELECT MIN(stat_date) AS first_date, MAX(stat_date) AS last_date FROM {db_prefix}log_spider_stats', array()); list($min_date, $max_date) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); $min_year = (int) substr($min_date, 0, 4); $max_year = (int) substr($max_date, 0, 4); $min_month = (int) substr($min_date, 5, 2); $max_month = (int) substr($max_date, 5, 2); // Prepare the dates for the drop down. $date_choices = array(); for ($y = $min_year; $y <= $max_year; $y++) { for ($m = 1; $m <= 12; $m++) { // This doesn't count? if ($y == $min_year && $m < $min_month) { continue; } if ($y == $max_year && $m > $max_month) { break; } $date_choices[$y . $m] = $txt['months_short'][$m] . ' ' . $y; } } // What are we currently viewing? $current_date = isset($_REQUEST['new_date']) && isset($date_choices[$_REQUEST['new_date']]) ? $_REQUEST['new_date'] : $max_date; // Prepare the HTML. $date_select = ' ' . $txt['spider_stats_select_month'] . ': <select name="new_date" onchange="document.spider_stat_list.submit();">'; if (empty($date_choices)) { $date_select .= ' <option></option>'; } else { foreach ($date_choices as $id => $text) { $date_select .= ' <option value="' . $id . '"' . ($current_date == $id ? ' selected="selected"' : '') . '>' . $text . '</option>'; } } $date_select .= ' </select> <noscript> <input type="submit" name="go" value="' . $txt['go'] . '" class="button_submit" /> </noscript>'; // If we manually jumped to a date work out the offset. if (isset($_REQUEST['new_date'])) { $date_query = sprintf('%04d-%02d-01', substr($current_date, 0, 4), substr($current_date, 4)); $request = $smcFunc['db_query']('', ' SELECT COUNT(*) AS offset FROM {db_prefix}log_spider_stats WHERE stat_date < {date:date_being_viewed}', array('date_being_viewed' => $date_query)); list($_REQUEST['start']) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); } $listOptions = array('id' => 'spider_stat_list', 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=sengines;sa=stats', 'default_sort_col' => 'stat_date', 'get_items' => array('function' => 'list_getSpiderStats'), 'get_count' => array('function' => 'list_getNumSpiderStats'), 'no_items_label' => $txt['spider_stats_no_entries'], 'columns' => array('stat_date' => array('header' => array('value' => $txt['date']), 'data' => array('db' => 'stat_date'), 'sort' => array('default' => 'stat_date', 'reverse' => 'stat_date DESC')), 'name' => array('header' => array('value' => $txt['spider_name']), 'data' => array('db' => 'spider_name'), 'sort' => array('default' => 's.spider_name', 'reverse' => 's.spider_name DESC')), 'page_hits' => array('header' => array('value' => $txt['spider_stats_page_hits']), 'data' => array('db' => 'page_hits'), 'sort' => array('default' => 'ss.page_hits', 'reverse' => 'ss.page_hits DESC'))), 'form' => array('href' => $scripturl . '?action=admin;area=sengines;sa=stats', 'name' => 'spider_stat_list'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => $date_select, 'style' => 'text-align: right;'))); require_once $sourcedir . '/Subs-List.php'; createList($listOptions); $context['sub_template'] = 'show_list'; $context['default_list'] = 'spider_stat_list'; }
function KB_show_logs() { global $txt, $sourcedir, $modSettings, $smcFunc, $scripturl, $context; $context['sub_template'] = 'kbdolog'; $context['can_delete'] = allowedTo('admin_forum'); $context['hoursdisable'] = $modSettings['kb_del_wait']; $context['waittime'] = time() - $context['hoursdisable'] * 3600; $logperpage = !empty($modSettings['kb_log_perpage']) ? $modSettings['kb_log_perpage'] : 30; if (isset($_POST['removeall']) && $context['can_delete']) { checkSession(); $smcFunc['db_query']('', ' DELETE FROM {db_prefix}kb_log_actions WHERE time < {int:twenty_four_hours_wait}', array('twenty_four_hours_wait' => $context['waittime'])); KB_cleanCache(); } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) { checkSession(); $smcFunc['db_query']('', ' DELETE FROM {db_prefix}kb_log_actions WHERE id_log IN ({array_string:delete_actions}) AND time < {int:twenty_four_hours_wait}', array('delete_actions' => array_unique($_POST['delete']), 'twenty_four_hours_wait' => $context['waittime'])); KB_cleanCache(); } $list_options = array('id' => 'kb_list', 'title' => $txt['kb_log_admin1'], 'items_per_page' => $logperpage, 'base_href' => $scripturl . '?action=admin;area=kb;sa=showlog', 'default_sort_col' => 'id_log', 'default_sort_dir' => 'desc', 'get_items' => array('function' => create_function('$start, $items_per_page, $sort', ' global $context, $modSettings, $scripturl, $user_info, $smcFunc; $request = $smcFunc[\'db_query\'](\'\', \' SELECT a.id_log, a.user_id, a.reason, a.time, a.user_ip, m.real_name, mg.group_name FROM {db_prefix}kb_log_actions AS a LEFT JOIN {db_prefix}members AS m ON (a.user_id = m.id_member) LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN m.id_group = {int:reg_group_id} THEN m.id_post_group ELSE m.id_group END) ORDER BY {raw:sort} LIMIT {int:start}, {int:per_page}\', array( \'reg_group_id\' => 0, \'sort\' => $sort, \'start\' => $start, \'per_page\' => $items_per_page, ) ); $context[\'knowact\'] = array(); while ($row = $smcFunc[\'db_fetch_assoc\']($request)) $context[\'knowact\'][] = $row; $smcFunc[\'db_free_result\']($request); return $context[\'knowact\']; ')), 'get_count' => array('function' => create_function('', ' global $smcFunc; $request = $smcFunc[\'db_query\'](\'\', \' SELECT COUNT(*) FROM {db_prefix}kb_log_actions\', array()); list ($total_kb) = $smcFunc[\'db_fetch_row\']($request); $smcFunc[\'db_free_result\']($request); return $total_kb; ')), 'no_items_label' => $txt['knowledgebasenone'], 'columns' => array('id_log' => array('header' => array('value' => $txt['knowledgebase_actions']), 'data' => array('function' => create_function('$row', ' return \'<div class="smalltext">\'.$row[\'reason\'].\'</div>\'; '), 'style' => 'width: 10%; text-align: left;'), 'sort' => array('default' => 'id_log', 'reverse' => 'id_log DESC')), 'time' => array('header' => array('value' => $txt['kb_log_admin2']), 'data' => array('function' => create_function('$row', ' return \'\'.timeformat($row[\'time\']).\'\'; '), 'style' => 'width: 5%; text-align: center;'), 'sort' => array('default' => 'time', 'reverse' => 'time DESC')), 'user_id' => array('header' => array('value' => $txt['kb_log_admin3']), 'data' => array('function' => create_function('$row', ' global $txt, $scripturl; if($row[\'user_id\'] != 0){ return \'<a href="\'.$scripturl.\'?action=profile;u=\'.$row[\'user_id\'].\'">\'.$row[\'real_name\'].\'</a>\'; } else{ return $txt[\'guest_title\']; } '), 'style' => 'width: 2%; text-align: center;'), 'sort' => array('default' => 'user_id', 'reverse' => 'user_id DESC')), 'group_name' => array('header' => array('value' => $txt['kb_log_admin4']), 'data' => array('function' => create_function('$row', ' if($row[\'group_name\']){ return \'\'.$row[\'group_name\'].\'\'; } else{ return \'N/A\'; } '), 'style' => 'width: 2%; text-align: center;'), 'sort' => array('default' => 'group_name', 'reverse' => 'group_name DESC')), 'user_ip' => array('header' => array('value' => $txt['kb_log_admin5']), 'data' => array('function' => create_function('$row', ' return \'\'.$row[\'user_ip\'].\'\'; '), 'style' => 'width: 2%; text-align: center;'), 'sort' => array('default' => 'user_ip', 'reverse' => 'user_ip DESC')), 'delete' => array('header' => array('value' => '<input type="checkbox" name="all" class="input_check" onclick="invertAll(this, this.form);" />'), 'data' => array('function' => create_function('$row', ' return \'<input type="checkbox" class="input_check" name="delete[]" value="\' . $row[\'id_log\'] . \'" />\'; '), 'style' => 'width: 2%; text-align: center;'))), 'form' => array('href' => $scripturl . '?action=admin;area=kb;sa=showlog', 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array($context['session_var'] => $context['session_id'])), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => ' ' . ($context['can_delete'] ? ' <input type="submit" name="remove" value="' . $txt['kb_remove_log2'] . '" class="button_submit" /> <input type="submit" name="removeall" value="' . $txt['kb_remove_log1'] . '" class="button_submit" />' : '')))); require_once $sourcedir . '/Subs-List.php'; createList($list_options); }
/** * Let the administrator(s) edit the news items for the forum. * * What it does: * - It writes an entry into the moderation log. * - This function uses the edit_news administration area. * - Called by ?action=admin;area=news. * - Requires the edit_news permission. * - Can be accessed with ?action=admin;sa=editnews. */ public function action_editnews() { global $txt, $modSettings, $context, $scripturl; require_once SUBSDIR . '/Post.subs.php'; // The 'remove selected' button was pressed. if (!empty($_POST['delete_selection']) && !empty($_POST['remove'])) { checkSession(); // Store the news temporarily in this array. $temp_news = explode("\n", $modSettings['news']); // Remove the items that were selected. foreach ($temp_news as $i => $news) { if (in_array($i, $_POST['remove'])) { unset($temp_news[$i]); } } // Update the database. updateSettings(array('news' => implode("\n", $temp_news))); logAction('news'); } elseif (!empty($_POST['save_items'])) { checkSession(); foreach ($_POST['news'] as $i => $news) { if (trim($news) == '') { unset($_POST['news'][$i]); } else { $_POST['news'][$i] = Util::htmlspecialchars($_POST['news'][$i], ENT_QUOTES); preparsecode($_POST['news'][$i]); } } // Send the new news to the database. updateSettings(array('news' => implode("\n", $_POST['news']))); // Log this into the moderation log. logAction('news'); } // We're going to want this for making our list. require_once SUBSDIR . '/GenericList.class.php'; require_once SUBSDIR . '/News.subs.php'; $context['page_title'] = $txt['admin_edit_news']; // Use the standard templates for showing this. $listOptions = array('id' => 'news_lists', 'get_items' => array('function' => 'getNews'), 'columns' => array('news' => array('header' => array('value' => $txt['admin_edit_news']), 'data' => array('function' => create_function('$news', ' return \'<textarea class="" id="data_\' . $news[\'id\'] . \'" rows="3" name="news[]">\' . $news[\'unparsed\'] . \'</textarea> <br /> <div id="preview_\' . $news[\'id\'] . \'"></div>\'; '), 'class' => 'newsarea')), 'preview' => array('header' => array('value' => $txt['preview']), 'data' => array('function' => create_function('$news', ' return \'<div id="box_preview_\' . $news[\'id\'] . \'">\' . $news[\'parsed\'] . \'</div>\'; '), 'class' => 'newspreview')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />', 'class' => 'centertext'), 'data' => array('function' => create_function('$news', ' if (is_numeric($news[\'id\'])) return \'<input type="checkbox" name="remove[]" value="\' . $news[\'id\'] . \'" class="input_check" />\'; else return \'\'; '), 'class' => 'centertext'))), 'form' => array('href' => $scripturl . '?action=admin;area=news;sa=editnews', 'hidden_fields' => array($context['session_var'] => $context['session_id'])), 'additional_rows' => array(array('position' => 'bottom_of_list', 'class' => 'submitbutton', 'value' => ' <input type="submit" name="save_items" value="' . $txt['save'] . '" class="right_submit" /> <input type="submit" name="delete_selection" value="' . $txt['editnews_remove_selected'] . '" onclick="return confirm(\'' . $txt['editnews_remove_confirm'] . '\');" class="right_submit" /> <span id="moreNewsItems_link" style="display: none;"> <a class="linkbutton" href="javascript:void(0);" onclick="addAnotherNews(); return false;">' . $txt['editnews_clickadd'] . '</a> </span>')), 'javascript' => ' document.getElementById(\'list_news_lists_last\').style.display = "none"; document.getElementById("moreNewsItems_link").style.display = ""; var last_preview = 0; var txt_preview = ' . javaScriptEscape($txt['preview']) . '; var txt_news_error_no_news = ' . javaScriptEscape($txt['news_error_no_news']) . '; $(document).ready(function () { $("div[id ^= \'preview_\']").each(function () { var preview_id = $(this).attr(\'id\').split(\'_\')[1]; if (last_preview < preview_id) last_preview = preview_id; make_preview_btn(preview_id); }); }); '); // Create the request list. createList($listOptions); $context['sub_template'] = 'show_list'; $context['default_list'] = 'news_lists'; }
function ViewWarningTemplates() { global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info; // Submitting a new one? if (isset($_POST['add'])) { return ModifyWarningTemplate(); } elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) { checkSession('post'); // Log the actions. $request = $smcFunc['db_query']('', ' SELECT recipient_name FROM {db_prefix}log_comments WHERE id_comment IN ({array_int:delete_ids}) AND comment_type = {string:warntpl} AND (id_recipient = {int:generic} OR id_recipient = {int:current_member})', array('delete_ids' => $_POST['deltpl'], 'warntpl' => 'warntpl', 'generic' => 0, 'current_member' => $user_info['id'])); while ($row = $smcFunc['db_fetch_assoc']($request)) { logAction('delete_warn_template', array('template' => $row['recipient_name'])); } $smcFunc['db_free_result']($request); // Do the deletes. $smcFunc['db_query']('', ' DELETE FROM {db_prefix}log_comments WHERE id_comment IN ({array_int:delete_ids}) AND comment_type = {string:warntpl} AND (id_recipient = {int:generic} OR id_recipient = {int:current_member})', array('delete_ids' => $_POST['deltpl'], 'warntpl' => 'warntpl', 'generic' => 0, 'current_member' => $user_info['id'])); } // Setup context as always. $context['page_title'] = $txt['mc_warning_templates_title']; require_once $sourcedir . '/Subs-List.php'; // This is all the information required for a watched user listing. $listOptions = array('id' => 'warning_template_list', 'title' => $txt['mc_warning_templates_title'], 'items_per_page' => $modSettings['defaultMaxMessages'], 'no_items_label' => $txt['mc_warning_templates_none'], 'base_href' => $scripturl . '?action=moderate;area=warnings;sa=templates;' . $context['session_var'] . '=' . $context['session_id'], 'default_sort_col' => 'title', 'get_items' => array('function' => 'list_getWarningTemplates'), 'get_count' => array('function' => 'list_getWarningTemplateCount'), 'columns' => array('title' => array('header' => array('value' => $txt['mc_warning_templates_name']), 'data' => array('sprintf' => array('format' => '<a href="' . $scripturl . '?action=moderate;area=warnings;sa=templateedit;tid=%1$d">%2$s</a>', 'params' => array('id_comment' => false, 'title' => false, 'body' => false))), 'sort' => array('default' => 'template_title', 'reverse' => 'template_title DESC')), 'creator' => array('header' => array('value' => $txt['mc_warning_templates_creator']), 'data' => array('db' => 'creator'), 'sort' => array('default' => 'creator_name', 'reverse' => 'creator_name DESC')), 'time' => array('header' => array('value' => $txt['mc_warning_templates_time']), 'data' => array('db' => 'time'), 'sort' => array('default' => 'lc.log_time DESC', 'reverse' => 'lc.log_time')), 'delete' => array('header' => array('style' => 'width: 4%;'), 'data' => array('function' => create_function('$rowData', ' global $context, $txt, $scripturl; return \'<input type="checkbox" name="deltpl[]" value="\' . $rowData[\'id_comment\'] . \'" class="input_check" />\'; '), 'style' => 'text-align: center;'))), 'form' => array('href' => $scripturl . '?action=moderate;area=warnings;sa=templates'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => ' <input type="submit" name="add" value="' . $txt['mc_warning_template_add'] . '" class="button_submit" /> <input type="submit" name="delete" value="' . $txt['mc_warning_template_delete'] . '" onclick="return confirm(\'' . $txt['mc_warning_template_delete_confirm'] . '\');" class="button_submit" />', 'style' => 'text-align: right;'))); // Create the watched user list. createList($listOptions); $context['sub_template'] = 'show_list'; $context['default_list'] = 'warning_template_list'; }
function ViewModlog() { global $txt, $modSettings, $context, $scripturl, $sourcedir, $user_info, $smcFunc, $settings; // Are we looking at the moderation log or the administration log. $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; if ($context['log_type'] == 3) { isAllowedTo('admin_forum'); } // These change dependant on whether we are viewing the moderation or admin log. if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; } else { $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; } $context['can_delete'] = allowedTo('admin_forum'); loadLanguage('Modlog'); $context['page_title'] = $context['log_type'] == 3 ? $txt['modlog_admin_log'] : $txt['modlog_view']; // The number of entries to show per page of log file. $context['displaypage'] = 30; // Amount of hours that must pass before allowed to delete file. $context['hoursdisable'] = 24; // Handle deletion... if (isset($_POST['removeall']) && $context['can_delete']) { checkSession(); $smcFunc['db_query']('', ' DELETE FROM {db_prefix}log_actions WHERE id_log = {int:moderate_log} AND log_time < {int:twenty_four_hours_wait}', array('twenty_four_hours_wait' => time() - $context['hoursdisable'] * 3600, 'moderate_log' => $context['log_type'])); } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) { checkSession(); $smcFunc['db_query']('', ' DELETE FROM {db_prefix}log_actions WHERE id_log = {int:moderate_log} AND id_action IN ({array_string:delete_actions}) AND log_time < {int:twenty_four_hours_wait}', array('twenty_four_hours_wait' => time() - $context['hoursdisable'] * 3600, 'delete_actions' => array_unique($_POST['delete']), 'moderate_log' => $context['log_type'])); } // Do the column stuff! $sort_types = array('action' => 'lm.action', 'time' => 'lm.log_time', 'member' => 'mem.real_name', 'group' => 'mg.group_name', 'ip' => 'lm.ip'); // Setup the direction stuff... $context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'time'; // If we're coming from a search, get the variables. if (!empty($_REQUEST['params']) && empty($_REQUEST['is_search'])) { $search_params = base64_decode(strtr($_REQUEST['params'], array(' ' => '+'))); $search_params = @unserialize($search_params); } // This array houses all the valid search types. $searchTypes = array('action' => array('sql' => 'lm.action', 'label' => $txt['modlog_action']), 'member' => array('sql' => 'mem.real_name', 'label' => $txt['modlog_member']), 'group' => array('sql' => 'mg.group_name', 'label' => $txt['modlog_position']), 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip'])); if (!isset($search_params['string']) || !empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search']) { $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; } else { $search_params_string = $search_params['string']; } if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); } else { $search_params_type = $search_params['type']; } $search_params_column = $searchTypes[$search_params_type]['sql']; $search_params = array('string' => $search_params_string, 'type' => $search_params_type); // Setup the search context. $context['search_params'] = empty($search_params['string']) ? '' : base64_encode(serialize($search_params)); $context['search'] = array('string' => $search_params['string'], 'type' => $search_params['type'], 'label' => $searchTypes[$search_params_type]['label']); // If they are searching by action, then we must do some manual intervention to search in their language! if ($search_params['type'] == 'action' && !empty($search_params['string'])) { // For the moment they can only search for ONE action! foreach ($txt as $key => $text) { if (substr($key, 0, 10) == 'modlog_ac_' && strpos($text, $search_params['string']) !== false) { $search_params['string'] = substr($key, 10); break; } } } require_once $sourcedir . '/Subs-List.php'; // This is all the information required for a watched user listing. $listOptions = array('id' => 'moderation_log_list', 'title' => '<a href="' . $scripturl . '?action=helpadmin;help=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . '" onclick="return reqWin(this.href);" class="help"><img src="' . $settings['images_url'] . '/helptopics.gif" alt="' . $txt['help'] . '" align="top" /></a> ' . $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], 'width' => '100%', 'items_per_page' => $context['displaypage'], 'no_items_label' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin_log_' : '') . 'no_entries_found'], 'base_href' => $scripturl . $context['url_start'] . (!empty($context['search_params']) ? ';params=' . $context['search_params'] : ''), 'default_sort_col' => 'time', 'get_items' => array('function' => 'list_getModLogEntries', 'params' => array(!empty($search_params['string']) ? ' INSTR({raw:sql_type}, {string:search_string})' : '', array('sql_type' => $search_params_column, 'search_string' => $search_params['string']), $context['log_type'])), 'get_count' => array('function' => 'list_getModLogEntryCount', 'params' => array(!empty($search_params['string']) ? ' INSTR({raw:sql_type}, {string:search_string})' : '', array('sql_type' => $search_params_column, 'search_string' => $search_params['string']), $context['log_type'])), 'columns' => array('action' => array('header' => array('value' => $txt['modlog_action'], 'class' => 'lefttext first_th'), 'data' => array('db' => 'action_text', 'class' => 'smalltext'), 'sort' => array('default' => 'lm.action', 'reverse' => 'lm.action DESC')), 'time' => array('header' => array('value' => $txt['modlog_date'], 'class' => 'lefttext'), 'data' => array('db' => 'time', 'class' => 'smalltext'), 'sort' => array('default' => 'lm.log_time DESC', 'reverse' => 'lm.log_time')), 'moderator' => array('header' => array('value' => $txt['modlog_member'], 'class' => 'lefttext'), 'data' => array('db' => 'moderator_link', 'class' => 'smalltext'), 'sort' => array('default' => 'mem.real_name', 'reverse' => 'mem.real_name DESC')), 'position' => array('header' => array('value' => $txt['modlog_position'], 'class' => 'lefttext'), 'data' => array('db' => 'position', 'class' => 'smalltext'), 'sort' => array('default' => 'mg.group_name', 'reverse' => 'mg.group_name DESC')), 'ip' => array('header' => array('value' => $txt['modlog_ip'], 'class' => 'lefttext'), 'data' => array('db' => 'ip', 'class' => 'smalltext'), 'sort' => array('default' => 'lm.ip', 'reverse' => 'lm.ip DESC')), 'delete' => array('header' => array('value' => '<input type="checkbox" name="all" class="input_check" onclick="invertAll(this, this.form);" />'), 'data' => array('function' => create_function('$entry', ' return \'<input type="checkbox" class="input_check" name="delete[]" value="\' . $entry[\'id\'] . \'"\' . ($entry[\'editable\'] ? \'\' : \' disabled="disabled"\') . \' />\'; '), 'style' => 'text-align: center;'))), 'form' => array('href' => $scripturl . $context['url_start'], 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array($context['session_var'] => $context['session_id'], 'params' => $context['search_params'])), 'additional_rows' => array(array('position' => 'after_title', 'value' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'], 'class' => 'smalltext', 'style' => 'padding: 2ex;'), array('position' => 'below_table_data', 'value' => ' ' . $txt['modlog_search'] . ' (' . $txt['modlog_by'] . ': ' . $context['search']['label'] . '): <input type="text" name="search" size="18" value="' . $context['search']['string'] . '" class="input_text" /> <input type="submit" name="is_search" value="' . $txt['modlog_go'] . '" class="button_submit" /> ' . ($context['can_delete'] ? ' | <input type="submit" name="remove" value="' . $txt['modlog_remove'] . '" class="button_submit" /> <input type="submit" name="removeall" value="' . $txt['modlog_removeall'] . '" class="button_submit" />' : '')))); // Create the watched user list. createList($listOptions); $context['sub_template'] = 'show_list'; $context['default_list'] = 'moderation_log_list'; }
function KB_know() { global $txt, $sourcedir, $smcFunc, $catname, $modSettings, $user_info, $scripturl, $context; $context['sub_template'] = 'kb_know'; $_GET['cat'] = (int) $_GET['cat']; $params = array('table' => 'kb_category', 'call' => 'name', 'where' => 'kbid = {int:cat}'); $data = array('cat' => (int) $_GET['cat']); $catname = KB_ListData($params, $data); $context['linktree'][] = array('url' => $scripturl . '?action=kb;area=cats;cat=' . $_GET['cat'] . '', 'name' => $catname['name']); $context['page_title'] = $catname['name']; KBisAllowedto($_GET['cat'], 'view'); $params1 = array('table' => 'kb_category', 'call' => 'kbid', 'where' => 'id_parent = {int:cat}'); $data1 = array('cat' => (int) $_GET['cat']); $kbid = KB_ListData($params1, $data1); if ($kbid['kbid']) { KB_subcat(); } $artperpage = !empty($modSettings['kb_app']) ? $modSettings['kb_app'] : 30; $list_options = array('id' => 'kb_know', 'title' => $catname['name'], 'items_per_page' => $artperpage, 'base_href' => $scripturl . '?action=kb;area=cats;cat=' . $_GET['cat'] . '', 'default_sort_col' => 'kbnid', 'get_items' => array('function' => create_function('$start, $items_per_page, $sort', ' global $user_info, $smcFunc; $request = $smcFunc[\'db_query\'](\'\', \' SELECT k.kbnid, k.title, k.views, k.date, k.id_cat, k.approved, k.id_member, m.real_name, k.rate, k.comments FROM {db_prefix}kb_articles AS k LEFT JOIN {db_prefix}members AS m ON (k.id_member = m.id_member) WHERE id_cat = {int:cat} AND approved = 1 ORDER BY {raw:sort} LIMIT {int:start}, {int:per_page}\', array( \'current_member\' => $user_info[\'id\'], \'cat\' => (int) $_GET[\'cat\'], \'sort\' => $sort, \'start\' => $start, \'per_page\' => $items_per_page, ) ); $kbcn = array(); while ($row = $smcFunc[\'db_fetch_assoc\']($request)) $kbcn[] = $row; $smcFunc[\'db_free_result\']($request); return $kbcn; ')), 'get_count' => array('function' => create_function('', ' global $smcFunc; $request = $smcFunc[\'db_query\'](\'\', \' SELECT COUNT(*) FROM {db_prefix}kb_articles WHERE id_cat = {int:cat} AND approved = 1\', array(\'cat\' => (int) $_GET[\'cat\'],)); list ($total_kbn) = $smcFunc[\'db_fetch_row\']($request); $smcFunc[\'db_free_result\']($request); return $total_kbn; ')), 'no_items_label' => $txt['knowledgebasenone'], 'columns' => array('kbnid' => array('header' => array('value' => '-'), 'data' => array('function' => create_function('$row', ' global $settings; if($row[\'views\'] >= 25){ return \'<img src="\'.$settings[\'images_url\'].\'/topic/veryhot_post.gif" alt="" align="middle" />\'; }elseif($row[\'views\'] >= 15){ return \'<img src="\'.$settings[\'images_url\'].\'/topic/hot_post.gif" alt="" align="middle" />\'; }else{ return \'<img src="\'.$settings[\'images_url\'].\'/topic/normal_post.gif" alt="" align="middle" />\'; } '), 'style' => 'width: 1%; text-align: left;'), 'sort' => array('default' => 'kbnid DESC', 'reverse' => 'kbnid')), 'title' => array('header' => array('value' => $txt['knowledgebasetitle']), 'data' => array('function' => create_function('$row', ' global $scripturl; return \'<a href="\'.$scripturl.\'?action=kb;area=article;cont=\'.$row[\'kbnid\'].\'">\'.$row[\'title\'].\'</a>\'; '), 'style' => 'width: 20%; text-align: left;'), 'sort' => array('default' => 'title DESC', 'reverse' => 'title')), 'author' => array('header' => array('value' => $txt['knowledgebaseauthor']), 'data' => array('function' => create_function('$row', ' global $scripturl; return \'\'.KB_profileLink($row[\'real_name\'], $row[\'id_member\']).\'\'; '), 'style' => 'width: 5%; text-align: center;'), 'sort' => array('default' => 'real_name', 'reverse' => 'real_name DESC')), 'date' => array('header' => array('value' => $txt['knowledgebasecreated']), 'data' => array('function' => create_function('$row', ' return \'<div class="smalltext">\'.timeformat($row[\'date\']).\'</div>\'; '), 'style' => 'width: 10%; text-align: center;'), 'sort' => array('default' => 'date', 'reverse' => 'date DESC')), 'rate' => array('header' => array('value' => $txt['kb_pinfi2']), 'data' => array('function' => create_function('$row', ' return KB_Stars_Precent($row[\'rate\']); '), 'style' => 'width: 5%; text-align: center;'), 'sort' => array('default' => 'rate', 'reverse' => 'rate DESC')), 'comments' => array('header' => array('value' => $txt['kb_ecom2']), 'data' => array('function' => create_function('$row', ' return $row[\'comments\']; '), 'style' => 'width: 5%; text-align: center;'), 'sort' => array('default' => 'comments', 'reverse' => 'comments DESC')), 'views' => array('header' => array('value' => $txt['knowledgebaseviews']), 'data' => array('function' => create_function('$row', ' return $row[\'views\']; '), 'style' => 'width: 5%; text-align: center;'), 'sort' => array('default' => 'views', 'reverse' => 'views DESC')))); if (empty($modSettings['kb_show_view'])) { unset($list_options['columns']['views']); } if (empty($modSettings['kb_eratings'])) { unset($list_options['columns']['rate']); } if (empty($modSettings['kb_ecom'])) { unset($list_options['columns']['comments']); } if (empty($modSettings['kb_salegend'])) { unset($list_options['columns']['icon']); } require_once $sourcedir . '/Subs-List.php'; createList($list_options); }
/** * Issue/manage an user's warning status. * @uses ProfileAccount template issueWarning sub template * @uses Profile template */ public function action_issuewarning() { global $txt, $scripturl, $modSettings, $mbname, $context, $cur_profile; $memID = currentMemberID(); // make sure the sub-template is set... loadTemplate('ProfileAccount'); $context['sub_template'] = 'issueWarning'; // We need this because of template_load_warning_variables loadTemplate('Profile'); loadJavascriptFile('profile.js'); // jQuery-UI FTW! $modSettings['jquery_include_ui'] = true; loadCSSFile('jquery.ui.slider.css'); loadCSSFile('jquery.ui.theme.css'); // Get all the actual settings. list($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); // This stores any legitimate errors. $issueErrors = array(); // Doesn't hurt to be overly cautious. if (empty($modSettings['warning_enable']) || $context['user']['is_owner'] && !$cur_profile['warning'] || !allowedTo('issue_warning')) { fatal_lang_error('no_access', false); } // Get the base (errors related) stuff done. loadLanguage('Errors'); $context['custom_error_title'] = $txt['profile_warning_errors_occurred']; // Make sure things which are disabled stay disabled. $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; $modSettings['warning_moderate'] = !empty($modSettings['warning_moderate']) && !empty($modSettings['postmod_active']) ? $modSettings['warning_moderate'] : 110; $modSettings['warning_mute'] = !empty($modSettings['warning_mute']) ? $modSettings['warning_mute'] : 110; $context['warning_limit'] = allowedTo('admin_forum') ? 0 : $modSettings['user_limit']; $context['member']['warning'] = $cur_profile['warning']; $context['member']['name'] = $cur_profile['real_name']; // What are the limits we can apply? $context['min_allowed'] = 0; $context['max_allowed'] = 100; if ($context['warning_limit'] > 0) { require_once SUBSDIR . '/Moderation.subs.php'; $current_applied = warningDailyLimit($memID); $context['min_allowed'] = max(0, $cur_profile['warning'] - $current_applied - $context['warning_limit']); $context['max_allowed'] = min(100, $cur_profile['warning'] - $current_applied + $context['warning_limit']); } // Defaults. $context['warning_data'] = array('reason' => '', 'notify' => '', 'notify_subject' => '', 'notify_body' => ''); // Are we saving? if (isset($_POST['save'])) { // Security is good here. checkSession('post'); // This cannot be empty! $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : ''; if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) { $issueErrors[] = 'warning_no_reason'; } $_POST['warn_reason'] = Util::htmlspecialchars($_POST['warn_reason']); // If the value hasn't changed it's either no JS or a real no change (Which this will pass) if ($_POST['warning_level'] == 'SAME') { $_POST['warning_level'] = $_POST['warning_level_nojs']; } $_POST['warning_level'] = (int) $_POST['warning_level']; $_POST['warning_level'] = max(0, min(100, $_POST['warning_level'])); if ($_POST['warning_level'] < $context['min_allowed']) { $_POST['warning_level'] = $context['min_allowed']; } elseif ($_POST['warning_level'] > $context['max_allowed']) { $_POST['warning_level'] = $context['max_allowed']; } require_once SUBSDIR . '/Moderation.subs.php'; // Do we actually have to issue them with a PM? $id_notice = 0; if (!empty($_POST['warn_notify']) && empty($issueErrors)) { $_POST['warn_sub'] = trim($_POST['warn_sub']); $_POST['warn_body'] = trim($_POST['warn_body']); if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { $issueErrors[] = 'warning_notify_blank'; } else { require_once SUBSDIR . '/PersonalMessage.subs.php'; $from = array('id' => 0, 'name' => $context['forum_name'], 'username' => $context['forum_name']); sendpm(array('to' => array($memID), 'bcc' => array()), $_POST['warn_sub'], $_POST['warn_body'], false, $from); // Log the notice. $id_notice = logWarningNotice($_POST['warn_sub'], $_POST['warn_body']); } } // Just in case - make sure notice is valid! $id_notice = (int) $id_notice; // What have we changed? $level_change = $_POST['warning_level'] - $cur_profile['warning']; // No errors? Proceed! Only log if you're not the owner. if (empty($issueErrors)) { // Log what we've done! if (!$context['user']['is_owner']) { logWarning($memID, $cur_profile['real_name'], $id_notice, $level_change, $_POST['warn_reason']); } // Make the change. updateMemberData($memID, array('warning' => $_POST['warning_level'])); // Leave a lovely message. $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success']; } else { // Try to remember some bits. $context['warning_data'] = array('reason' => $_POST['warn_reason'], 'notify' => !empty($_POST['warn_notify']), 'notify_subject' => isset($_POST['warn_sub']) ? $_POST['warn_sub'] : '', 'notify_body' => isset($_POST['warn_body']) ? $_POST['warn_body'] : ''); } // Show the new improved warning level. $context['member']['warning'] = $_POST['warning_level']; } // Taking a look first, good idea that one. if (isset($_POST['preview'])) { $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : ''; $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim(Util::htmlspecialchars($_POST['warn_sub'])) : ''; if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { $issueErrors[] = 'warning_notify_blank'; } if (!empty($_POST['warn_body'])) { require_once SUBSDIR . '/Post.subs.php'; preparsecode($warning_body); $warning_body = parse_bbc($warning_body, true); } // Try to remember some bits. $context['warning_data'] = array('reason' => $_POST['warn_reason'], 'notify' => !empty($_POST['warn_notify']), 'notify_subject' => isset($_POST['warn_sub']) ? $_POST['warn_sub'] : '', 'notify_body' => isset($_POST['warn_body']) ? $_POST['warn_body'] : '', 'body_preview' => $warning_body); } if (!empty($issueErrors)) { // Fill in the suite of errors. $context['post_errors'] = array(); foreach ($issueErrors as $error) { $context['post_errors'][] = $txt[$error]; } } $context['page_title'] = $txt['profile_issue_warning']; // Let's use a generic list to get all the current warnings require_once SUBSDIR . '/GenericList.class.php'; require_once SUBSDIR . '/Profile.subs.php'; // Work our the various levels. $context['level_effects'] = array(0 => $txt['profile_warning_effect_none'], $modSettings['warning_watch'] => $txt['profile_warning_effect_watch'], $modSettings['warning_moderate'] => $txt['profile_warning_effect_moderation'], $modSettings['warning_mute'] => $txt['profile_warning_effect_mute']); $context['current_level'] = 0; foreach ($context['level_effects'] as $limit => $dummy) { if ($context['member']['warning'] >= $limit) { $context['current_level'] = $limit; } } // Build a list to view the warnings $listOptions = array('id' => 'issued_warnings', 'title' => $txt['profile_viewwarning_previous_warnings'], 'items_per_page' => $modSettings['defaultMaxMessages'], 'no_items_label' => $txt['profile_viewwarning_no_warnings'], 'base_href' => $scripturl . '?action=profile;area=issuewarning;sa=user;u=' . $memID, 'default_sort_col' => 'log_time', 'get_items' => array('function' => 'list_getUserWarnings', 'params' => array($memID)), 'get_count' => array('function' => 'list_getUserWarningCount', 'params' => array($memID)), 'columns' => array('issued_by' => array('header' => array('value' => $txt['profile_warning_previous_issued'], 'style' => 'width: 20%;'), 'data' => array('function' => create_function('$warning', ' return $warning[\'issuer\'][\'link\']; ')), 'sort' => array('default' => 'lc.member_name DESC', 'reverse' => 'lc.member_name')), 'log_time' => array('header' => array('value' => $txt['profile_warning_previous_time'], 'style' => 'width: 30%;'), 'data' => array('db' => 'time'), 'sort' => array('default' => 'lc.log_time DESC', 'reverse' => 'lc.log_time')), 'reason' => array('header' => array('value' => $txt['profile_warning_previous_reason']), 'data' => array('function' => create_function('$warning', ' global $scripturl, $txt, $settings; $ret = \' <div class="floatleft"> \' . $warning[\'reason\'] . \' </div>\'; // If a notice was sent, provide a way to view it if (!empty($warning[\'id_notice\'])) $ret .= \' <div class="floatright"> <a href="\' . $scripturl . \'?action=moderate;area=notice;nid=\' . $warning[\'id_notice\'] . \'" onclick="window.open(this.href, \\\'\\\', \\\'scrollbars=yes,resizable=yes,width=400,height=250\\\');return false;" target="_blank" class="new_win" title="\' . $txt[\'profile_warning_previous_notice\'] . \'"><img src="\' . $settings[\'images_url\'] . \'/filter.png" alt="" /></a> </div>\'; return $ret;'))), 'level' => array('header' => array('value' => $txt['profile_warning_previous_level'], 'style' => 'width: 6%;'), 'data' => array('db' => 'counter'), 'sort' => array('default' => 'lc.counter DESC', 'reverse' => 'lc.counter')))); // Create the list for viewing. createList($listOptions); $warning_for_message = isset($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : false; $warned_message_subject = ''; // Are they warning because of a message? if (isset($_REQUEST['msg']) && 0 < (int) $_REQUEST['msg']) { require_once SUBSDIR . '/Messages.subs.php'; $message = basicMessageInfo((int) $_REQUEST['msg']); if (!empty($message)) { $warned_message_subject = $message['subject']; } } require_once SUBSDIR . '/Maillist.subs.php'; // Any custom templates? $context['notification_templates'] = array(); $notification_templates = maillist_templates('warntpl'); foreach ($notification_templates as $row) { // If we're not warning for a message skip any that are. if (!$warning_for_message && strpos($row['body'], '{MESSAGE}') !== false) { continue; } $context['notification_templates'][] = array('title' => $row['title'], 'body' => $row['body']); } // Setup the "default" templates. foreach (array('spamming', 'offence', 'insulting') as $type) { $context['notification_templates'][] = array('title' => $txt['profile_warning_notify_title_' . $type], 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($warning_for_message) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type])); } // Replace all the common variables in the templates. foreach ($context['notification_templates'] as $k => $name) { $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $warning_for_message . ']' . un_htmlspecialchars($warned_message_subject) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => replaceBasicActionUrl($txt['regards_team']))); } }
/** * Browse a list of installed packages. */ public function action_browse() { global $txt, $scripturl, $context, $forum_version, $settings; require_once SUBSDIR . '/GenericList.class.php'; $context['page_title'] .= ' - ' . $txt['browse_packages']; $context['forum_version'] = $forum_version; $installed = $context['sub_action'] == 'installed' ? true : false; $context['package_types'] = $installed ? array('modification') : array('modification', 'avatar', 'language', 'smiley', 'unknown'); foreach ($context['package_types'] as $type) { // Use the standard templates for showing this. $listOptions = array('id' => 'packages_lists_' . $type, 'title' => $installed ? $txt['view_and_remove'] : $txt[$type . '_package'], 'no_items_label' => $txt['no_packages'], 'get_items' => array('function' => array($this, 'list_packages'), 'params' => array('type' => $type, 'installed' => $installed)), 'base_href' => $scripturl . '?action=admin;area=packages;sa=' . $context['sub_action'] . ';type=' . $type, 'default_sort_col' => 'id' . $type, 'columns' => array('id' . $type => array('header' => array('value' => $txt['package_id'], 'style' => 'width: 40px;'), 'data' => array('function' => create_function('$package_md5', ' global $context; if (isset($context[\'available_' . $type . '\'][$package_md5])) return $context[\'available_' . $type . '\'][$package_md5][\'sort_id\']; ')), 'sort' => array('default' => 'sort_id', 'reverse' => 'sort_id')), 'mod_name' . $type => array('header' => array('value' => $txt['mod_name'], 'style' => 'width: 25%;'), 'data' => array('function' => create_function('$package_md5', ' global $context; if (isset($context[\'available_' . $type . '\'][$package_md5])) return $context[\'available_' . $type . '\'][$package_md5][\'name\']; ')), 'sort' => array('default' => 'name', 'reverse' => 'name')), 'version' . $type => array('header' => array('value' => $txt['mod_version'], 'style' => 'width: 25%;'), 'data' => array('function' => create_function('$package_md5', ' global $context; if (isset($context[\'available_' . $type . '\'][$package_md5])) return $context[\'available_' . $type . '\'][$package_md5][\'version\']; ')), 'sort' => array('default' => 'version', 'reverse' => 'version')), 'operations' . $type => array('header' => array('value' => ''), 'data' => array('function' => create_function('$package_md5', ' global $context, $scripturl, $txt; if (!isset($context[\'available_' . $type . '\'][$package_md5])) return \'\'; // Rewrite shortcut $package = $context[\'available_' . $type . '\'][$package_md5]; $return = \'\'; if ($package[\'can_uninstall\']) $return = \' <a href="\' . $scripturl . \'?action=admin;area=packages;sa=uninstall;package=\' . $package[\'filename\'] . \';pid=\' . $package[\'installed_id\'] . \'">[ \' . $txt[\'uninstall\'] . \' ]</a>\'; elseif ($package[\'can_emulate_uninstall\']) $return = \' <a href="\' . $scripturl . \'?action=admin;area=packages;sa=uninstall;ve=\' . $package[\'can_emulate_uninstall\'] . \';package=\' . $package[\'filename\'] . \';pid=\' . $package[\'installed_id\'] . \'">[ \' . $txt[\'package_emulate_uninstall\'] . \' \' . $package[\'can_emulate_uninstall\'] . \' ]</a>\'; elseif ($package[\'can_upgrade\']) $return = \' <a href="\' . $scripturl . \'?action=admin;area=packages;sa=install;package=\' . $package[\'filename\'] . \'">[ \' . $txt[\'package_upgrade\'] . \' ]</a>\'; elseif ($package[\'can_install\']) $return = \' <a href="\' . $scripturl . \'?action=admin;area=packages;sa=install;package=\' . $package[\'filename\'] . \'">[ \' . $txt[\'install_mod\'] . \' ]</a>\'; elseif ($package[\'can_emulate_install\']) $return = \' <a href="\' . $scripturl . \'?action=admin;area=packages;sa=install;ve=\' . $package[\'can_emulate_install\'] . \';package=\' . $package[\'filename\'] . \'">[ \' . $txt[\'package_emulate_install\'] . \' \' . $package[\'can_emulate_install\'] . \' ]</a>\'; return $return . \' <a href="\' . $scripturl . \'?action=admin;area=packages;sa=list;package=\' . $package[\'filename\'] . \'">[ \' . $txt[\'list_files\'] . \' ]</a> <a href="\' . $scripturl . \'?action=admin;area=packages;sa=remove;package=\' . $package[\'filename\'] . \';\' . $context[\'session_var\'] . \'=\' . $context[\'session_id\'] . \'"\' . ($package[\'is_installed\'] && $package[\'is_current\'] ? \' onclick="return confirm(\\\'\' . $txt[\'package_delete_bad\'] . \'\\\');"\' : \'\') . \'>[ \' . $txt[\'package_delete\'] . \' ]</a>\'; '), 'class' => 'righttext'))), 'additional_rows' => array(array('position' => 'bottom_of_list', 'class' => 'submitbutton', 'value' => $context['sub_action'] == 'browse' ? '<div class="smalltext">' . $txt['package_installed_key'] . '<img src="' . $settings['images_url'] . '/icons/package_installed.png" alt="" class="centericon" /> ' . $txt['package_installed_current'] . '<img src="' . $settings['images_url'] . '/icons/package_old.png" alt="" class="centericon" /> ' . $txt['package_installed_old'] . '</div>' : '<a class="linkbutton" href="' . $scripturl . '?action=admin;area=packages;sa=flush;' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(\'' . $txt['package_delete_list_warning'] . '\');">' . $txt['delete_list'] . '</a>'))); createList($listOptions); } $context['sub_template'] = 'browse'; $context['default_list'] = 'packages_lists'; }
/** * Show the log of all tasks that have taken place. * * @uses ManageScheduledTasks language file */ function TaskLog() { global $scripturl, $context, $txt, $smcFunc, $sourcedir; // Lets load the language just incase we are outside the Scheduled area. loadLanguage('ManageScheduledTasks'); // Empty the log? if (!empty($_POST['removeAll'])) { checkSession(); validateToken('admin-tl'); $smcFunc['db_query']('truncate_table', ' TRUNCATE {db_prefix}log_scheduled_tasks', array()); } // Setup the list. $listOptions = array('id' => 'task_log', 'items_per_page' => 30, 'title' => $txt['scheduled_log'], 'no_items_label' => $txt['scheduled_log_empty'], 'base_href' => $context['admin_area'] == 'scheduledtasks' ? $scripturl . '?action=admin;area=scheduledtasks;sa=tasklog' : $scripturl . '?action=admin;area=logs;sa=tasklog', 'default_sort_col' => 'date', 'get_items' => array('function' => 'list_getTaskLogEntries'), 'get_count' => array('function' => 'list_getNumTaskLogEntries'), 'columns' => array('name' => array('header' => array('value' => $txt['scheduled_tasks_name']), 'data' => array('db' => 'name')), 'date' => array('header' => array('value' => $txt['scheduled_log_time_run']), 'data' => array('function' => create_function('$rowData', ' return timeformat($rowData[\'time_run\'], true); ')), 'sort' => array('default' => 'lst.id_log DESC', 'reverse' => 'lst.id_log')), 'time_taken' => array('header' => array('value' => $txt['scheduled_log_time_taken']), 'data' => array('sprintf' => array('format' => $txt['scheduled_log_time_taken_seconds'], 'params' => array('time_taken' => false))), 'sort' => array('default' => 'lst.time_taken', 'reverse' => 'lst.time_taken DESC'))), 'form' => array('href' => $context['admin_area'] == 'scheduledtasks' ? $scripturl . '?action=admin;area=scheduledtasks;sa=tasklog' : $scripturl . '?action=admin;area=logs;sa=tasklog', 'token' => 'admin-tl'), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => ' <input type="submit" name="removeAll" value="' . $txt['scheduled_log_empty_log'] . '" onclick="return confirm(\'' . $txt['scheduled_log_empty_log_confirm'] . '\');" class="button_submit" />', 'style' => 'text-align: right;'), array('position' => 'after_title', 'value' => $txt['scheduled_tasks_time_offset'], 'class' => 'windowbg2'))); createToken('admin-tl'); require_once $sourcedir . '/Subs-List.php'; createList($listOptions); $context['sub_template'] = 'show_list'; $context['default_list'] = 'task_log'; // Make it all look tify. $context[$context['admin_menu_name']]['current_subsection'] = 'tasklog'; $context['page_title'] = $txt['scheduled_log']; }
function BanLog() { global $scripturl, $context, $smcFunc, $sourcedir, $txt; global $context; // Delete one or more entries. if (!empty($_POST['removeAll']) || !empty($_POST['removeSelected']) && !empty($_POST['remove'])) { checkSession(); // 'Delete all entries' button was pressed. if (!empty($_POST['removeAll'])) { $smcFunc['db_query']('truncate_table', ' TRUNCATE {db_prefix}log_banned', array()); } else { // Make sure every entry is integer. foreach ($_POST['remove'] as $index => $log_id) { $_POST['remove'][$index] = (int) $log_id; } $smcFunc['db_query']('', ' DELETE FROM {db_prefix}log_banned WHERE id_ban_log IN ({array_int:ban_list})', array('ban_list' => $_POST['remove'])); } } $listOptions = array('id' => 'ban_log', 'items_per_page' => 30, 'base_href' => $context['admin_area'] == 'ban' ? $scripturl . '?action=admin;area=ban;sa=log' : $scripturl . '?action=admin;area=logs;sa=banlog', 'default_sort_col' => 'date', 'get_items' => array('function' => 'list_getBanLogEntries'), 'get_count' => array('function' => 'list_getNumBanLogEntries'), 'no_items_label' => $txt['ban_log_no_entries'], 'columns' => array('ip' => array('header' => array('value' => $txt['ban_log_ip']), 'data' => array('sprintf' => array('format' => '<a href="' . $scripturl . '?action=trackip;searchip=%1$s">%1$s</a>', 'params' => array('ip' => false))), 'sort' => array('default' => 'lb.ip', 'reverse' => 'lb.ip DESC')), 'email' => array('header' => array('value' => $txt['ban_log_email']), 'data' => array('db_htmlsafe' => 'email'), 'sort' => array('default' => 'lb.email = \'\', lb.email', 'reverse' => 'lb.email != \'\', lb.email DESC')), 'member' => array('header' => array('value' => $txt['ban_log_member']), 'data' => array('sprintf' => array('format' => '<a href="' . $scripturl . '?action=profile;u=%1$d">%2$s</a>', 'params' => array('id_member' => false, 'real_name' => false))), 'sort' => array('default' => 'IFNULL(mem.real_name, 1=1), mem.real_name', 'reverse' => 'IFNULL(mem.real_name, 1=1) DESC, mem.real_name DESC')), 'date' => array('header' => array('value' => $txt['ban_log_date']), 'data' => array('function' => create_function('$rowData', ' return timeformat($rowData[\'log_time\']); ')), 'sort' => array('default' => 'lb.log_time DESC', 'reverse' => 'lb.log_time')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />'), 'data' => array('sprintf' => array('format' => '<input type="checkbox" name="remove[]" value="%1$d" class="input_check" />', 'params' => array('id_ban_log' => false)), 'style' => 'text-align: center'))), 'form' => array('href' => $context['admin_area'] == 'ban' ? $scripturl . '?action=admin;area=ban;sa=log' : $scripturl . '?action=admin;area=logs;sa=banlog', 'include_start' => true, 'include_sort' => true), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => ' <input type="submit" name="removeSelected" value="' . $txt['ban_log_remove_selected'] . '" onclick="return confirm(\'' . $txt['ban_log_remove_selected_confirm'] . '\');" class="button_submit" /> <input type="submit" name="removeAll" value="' . $txt['ban_log_remove_all'] . '" onclick="return confirm(\'' . $txt['ban_log_remove_all_confirm'] . '\');" class="button_submit" />', 'style' => 'text-align: right;'))); require_once $sourcedir . '/Subs-List.php'; createList($listOptions); $context['page_title'] = $txt['ban_log']; $context['sub_template'] = 'show_list'; $context['default_list'] = 'ban_log'; }