function main($id, $mode) { global $config, $user, $template, $request; global $phpbb_root_path, $phpEx, $phpbb_container; $user->add_lang('install'); $this->tpl_name = 'acp_update'; $this->page_title = 'ACP_VERSION_CHECK'; /* @var $version_helper \phpbb\version_helper */ $version_helper = $phpbb_container->get('version_helper'); try { $recheck = $request->variable('versioncheck_force', false); $updates_available = $version_helper->get_suggested_updates($recheck); } catch (\RuntimeException $e) { $template->assign_var('S_VERSIONCHECK_FAIL', true); $updates_available = array(); } foreach ($updates_available as $branch => $version_data) { $template->assign_block_vars('updates_available', $version_data); } $update_link = $phpbb_root_path . 'install/app.' . $phpEx; $template->assign_vars(array('S_UP_TO_DATE' => empty($updates_available), 'U_ACTION' => $this->u_action, 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'), 'CURRENT_VERSION' => $config['version'], 'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $update_link))); // Incomplete update? if (phpbb_version_compare($config['version'], PHPBB_VERSION, '<')) { $database_update_link = $phpbb_root_path . 'install/app.php/update'; $template->assign_vars(array('S_UPDATE_INCOMPLETE' => true, 'FILES_VERSION' => PHPBB_VERSION, 'INCOMPLETE_INSTRUCTIONS' => $user->lang('UPDATE_INCOMPLETE_EXPLAIN', $database_update_link))); } }
/** * Checks for correct MySQL version and stores min/max word length in the config */ function init() { global $db, $user; if ($db->sql_layer != 'mysql4' && $db->sql_layer != 'mysqli') { return $user->lang['FULLTEXT_MYSQL_INCOMPATIBLE_VERSION']; } $result = $db->sql_query('SHOW TABLE STATUS LIKE \'' . POSTS_TABLE . '\''); $info = $db->sql_fetchrow($result); $db->sql_freeresult($result); $engine = ''; if (isset($info['Engine'])) { $engine = $info['Engine']; } else { if (isset($info['Type'])) { $engine = $info['Type']; } } $fulltext_supported = $engine === 'MyISAM' || $engine === 'InnoDB' && phpbb_version_compare($db->sql_server_info(true), '5.6.4', '>='); if (!$fulltext_supported) { return $user->lang['FULLTEXT_MYSQL_NOT_SUPPORTED']; } $sql = 'SHOW VARIABLES LIKE \'ft\\_%\''; $result = $db->sql_query($sql); $mysql_info = array(); while ($row = $db->sql_fetchrow($result)) { $mysql_info[$row['Variable_name']] = $row['Value']; } $db->sql_freeresult($result); set_config('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']); set_config('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']); return false; }
function main($id, $mode) { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('install'); $this->tpl_name = 'acp_update'; $this->page_title = 'ACP_VERSION_CHECK'; // Get current and latest version $info = htmlspecialchars(obtain_latest_version_info(request_var('versioncheck_force', false))); if (empty($info)) { trigger_error('VERSIONCHECK_FAIL', E_USER_WARNING); } $info = explode("\n", $info); $latest_version = trim($info[0]); $announcement_url = trim($info[1]); $announcement_url = strpos($announcement_url, '&') === false ? str_replace('&', '&', $announcement_url) : $announcement_url; $update_link = append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update'); // next feature release $next_feature_version = $next_feature_announcement_url = false; if (isset($info[2]) && trim($info[2]) !== '') { $next_feature_version = trim($info[2]); $next_feature_announcement_url = trim($info[3]); } // Determine automatic update... $sql = 'SELECT config_value FROM ' . CONFIG_TABLE . "\n\t\t\tWHERE config_name = 'version_update_from'"; $result = $db->sql_query($sql); $version_update_from = (string) $db->sql_fetchfield('config_value'); $db->sql_freeresult($result); $current_version = !empty($version_update_from) ? $version_update_from : $config['version']; $template->assign_vars(array('S_UP_TO_DATE' => phpbb_version_compare($latest_version, $config['version'], '<='), 'S_UP_TO_DATE_AUTO' => phpbb_version_compare($latest_version, $current_version, '<='), 'S_VERSION_CHECK' => true, 'U_ACTION' => $this->u_action, 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'), 'LATEST_VERSION' => $latest_version, 'CURRENT_VERSION' => $config['version'], 'AUTO_VERSION' => $version_update_from, 'NEXT_FEATURE_VERSION' => $next_feature_version, 'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $announcement_url, $update_link), 'UPGRADE_INSTRUCTIONS' => $next_feature_version ? $user->lang('UPGRADE_INSTRUCTIONS', $next_feature_version, $next_feature_announcement_url) : false)); }
function main($id, $mode) { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('install'); $this->tpl_name = 'acp_update'; $this->page_title = 'ACP_VERSION_CHECK'; // Get current and latest version $errstr = ''; $errno = 0; $info = obtain_latest_version_info(request_var('versioncheck_force', false)); if ($info === false) { trigger_error('VERSIONCHECK_FAIL', E_USER_WARNING); } $info = explode("\n", $info); $latest_version = trim($info[0]); $announcement_url = trim($info[1]); $announcement_url = strpos($announcement_url, '&') === false ? str_replace('&', '&', $announcement_url) : $announcement_url; $update_link = append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update'); // www.phpBB-SEO.com SEO TOOLKIT BEGIN // moved a little bellow // next feature release /*$next_feature_version = $next_feature_announcement_url = false; if (isset($info[2]) && trim($info[2]) !== '') { $next_feature_version = trim($info[2]); $next_feature_announcement_url = trim($info[3]); }*/ // www.phpBB-SEO.com SEO TOOLKIT BEGIN // Determine automatic update... $sql = 'SELECT config_value FROM ' . CONFIG_TABLE . "\n\t\t\tWHERE config_name = 'version_update_from'"; $result = $db->sql_query($sql); $version_update_from = (string) $db->sql_fetchfield('config_value'); $db->sql_freeresult($result); $current_version = !empty($version_update_from) ? $version_update_from : $config['version']; // www.phpBB-SEO.com SEO TOOLKIT BEGIN $phpbb_seo_update = ''; if ($up_to_date) { $phpbb_seo_update = trim(str_replace($current_version, '', $latest_version)); } $update_instruction = sprintf($user->lang['UPDATE_INSTRUCTIONS'], $announcement_url, $update_link); if (!empty($phpbb_seo_update)) { $auto_package = trim($info[2]); $auto_update = $auto_package === 'auto_update:yes' ? true : false; $up_to_date = $latest_version === @$config['seo_premod_version'] ? true : false; if (!$auto_update) { $update_instruction = '<br/><br/><hr/>' . sprintf($user->lang['ACP_PREMOD_UPDATE'], $latest_version, $announcement_url) . '<br/><hr/>'; } } // next feature release $next_feature_version = $next_feature_announcement_url = false; if (isset($info[3]) && trim($info[3]) !== '') { $next_feature_version = trim($info[3]); $next_feature_announcement_url = trim($info[4]); } // www.phpBB-SEO.com SEO TOOLKIT END $template->assign_vars(array('S_UP_TO_DATE' => phpbb_version_compare($latest_version, $config['version'], '<='), 'S_UP_TO_DATE_AUTO' => phpbb_version_compare($latest_version, $current_version, '<='), 'S_VERSION_CHECK' => true, 'U_ACTION' => $this->u_action, 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'), 'LATEST_VERSION' => $latest_version, 'CURRENT_VERSION' => $config['version'], 'AUTO_VERSION' => $version_update_from, 'NEXT_FEATURE_VERSION' => $next_feature_version, 'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $announcement_url, $update_link), 'UPGRADE_INSTRUCTIONS' => $next_feature_version ? $user->lang('UPGRADE_INSTRUCTIONS', $next_feature_version, $next_feature_announcement_url) : false)); }
/** * Enable extension if phpBB version requirement is met * * @var string Require 3.2.0-a1 due to updated 3.2 syntax * * @return bool * @access public */ public function is_enableable() { $config = $this->container->get('config'); if (!phpbb_version_compare($config['version'], '3.2.0-a1', '>=')) { $this->container->get('language')->add_lang('ext_pmstats', 'david63/pmstats'); trigger_error($this->container->get('language')->lang('VERSION_32') . adm_back_link(append_sid('index.' . $this->container->getParameter('core.php_ext'), 'i=acp_extensions&mode=main')), E_USER_WARNING); } else { return true; } }
public function page_header($event) { $nru_group_id = $this->applicationform->getnruid(); if (!$this->config['appform_nru'] && $nru_group_id === (int) $this->user->data['group_id'] || $this->user->data['is_bot'] || $this->user->data['user_id'] == ANONYMOUS) { $this->template->assign_var('U_APP_FORM', false); return false; } $version = phpbb_version_compare($this->config['version'], '3.2.0-b2', '>='); $this->user->add_lang_ext('rmcgirr83/applicationform', 'common'); $this->template->assign_vars(array('U_APP_FORM' => $this->helper->route('rmcgirr83_applicationform_displayform'), 'S_FORUM_VERSION' => $version)); }
/** * A self-written function that checks the php version in the requirement section of this extension. * * @return bool TRUE, if the version is matching, otherwise FALSE. */ function check_php_version() { $this->manager = $this->container->get('ext.manager'); $this->metadata_manager = $this->manager->create_extension_metadata_manager($this->extension_name, $this->container->get('template')); $meta_data = $this->metadata_manager->get_metadata(); $require_fields = $meta_data['require']; // If the PHP field exists, we check the version if ($require_fields && isset($require_fields['php'])) { $php_require_field = $this->split_version_and_operator(html_entity_decode($require_fields['php'])); return $php_require_field && phpbb_version_compare(PHP_VERSION, $php_require_field['version'], $php_require_field['operator']); } return true; }
/** * Event: core.acp_manage_forums_display_form * * @param Event $event */ public function acp_manage_forums_display_form($event) { $this->user->add_lang_ext('kasimi/movetopicswhenlocked', 'acp_forum_settings'); $is_edit = $event['action'] == 'edit'; $forum_data = $event['forum_data']; $template_vars = array('MOVE_TOPICS_WHEN_LOCKED_VERSION' => $this->config['kasimi.movetopicswhenlocked.version'], 'S_MOVE_TOPICS' => $is_edit ? $forum_data['move_topics_when_locked'] : false, 'S_MOVE_TOPICS_TO_OPTIONS' => make_forum_select($is_edit ? $forum_data['move_topics_when_locked_to'] : false, false, false, true)); $topic_solved_extension = $this->user->lang('MOVE_TOPICS_SOLVED_EXTENSION'); if ($this->extension_manager->is_enabled(self::EXT_TOPIC_SOLVED_NAME)) { $metadata = $this->extension_manager->create_extension_metadata_manager(self::EXT_TOPIC_SOLVED_NAME, $this->template)->get_metadata(); $is_valid_version = phpbb_version_compare($metadata['version'], self::EXT_TOPIC_SOLVED_MIN_VERSION, '>='); $template_vars = array_merge($template_vars, array('S_MOVE_TOPICS_SOLVED' => $is_edit ? $forum_data['move_topics_when_locked_solved'] : false, 'MOVE_TOPICS_SOLVED_ENABLED' => $is_valid_version ? $this->user->lang('MOVE_TOPICS_SOLVED_ENABLED', $topic_solved_extension) : false, 'MOVE_TOPICS_SOLVED_VERSION' => $is_valid_version ? false : $this->user->lang('MOVE_TOPICS_SOLVED_VERSION', self::EXT_TOPIC_SOLVED_MIN_VERSION, $topic_solved_extension))); } else { $template_vars['MOVE_TOPICS_SOLVED_DISABLED'] = $this->user->lang('EXTENSION_DISABLED', $topic_solved_extension); } $this->template->assign_vars($template_vars); }
public function effectively_installed() { return isset($this->config['post_models_version']) && phpbb_version_compare($this->config['post_models_version'], '1.0.3', '>='); }
/** * Checks if all requirements in the "require" section of the composer.json file are fulfilled. * * @param array $require_fields The array of requirements specified, containing KeyValuePairs with extension name and version string. * @return bool TRUE, if the requirements are fulfilled, FALSE if they aren't. */ public function check_requirements($require_fields) { if (!isset($require_fields) || empty($require_fields)) { return true; } if (!is_array($require_fields)) { return false; } foreach ($require_fields as $ext_name => $require) { $require = $this->split_version_and_operator($require); // If version string is formatted wrong we consider the requirement is not fullfilled. Sorry. if ($require === false) { return false; } // If the field is PHP, we need to check the php version. Just to make sure (: if (strtolower($ext_name) == "php") { return phpbb_version_compare(PHP_VERSION, $require['version'], $require['operator']); } // If the extension is disabled, return false. If the extension is currently enabling, it counts as enabled. if (!$this->manager->is_enabled($ext_name) && !(isset($this->currently_enabling_extension) && $this->currently_enabling_extension == $ext_name)) { return false; } // gets the actual version number of this extension $ext_meta = $this->manager->create_extension_metadata_manager($ext_name, $this->template); $version = $ext_meta->get_metadata()['version']; if (!phpbb_version_compare($version, $require['version'], $require['operator'])) { return false; } } return true; }
/** * Enable extension if phpBB version requirement is met * * @return bool * @access public */ public function is_enableable() { $config = $this->container->get('config'); return phpbb_version_compare($config['version'], '3.2.0', '<='); }
/** * Get similar topics by matching topic titles * * NOTE: Currently requires MySQL due to the use of FULLTEXT indexes * and MATCH and AGAINST and UNIX_TIMESTAMP. MySQL FULLTEXT has built-in * English ignore words. We use phpBB's ignore words for non-English * languages. We also remove any admin-defined special ignore words. * * @access public * @param array $topic_data Array with topic data */ public function display_similar_topics($topic_data) { // If the forum should not display similar topics, no need to continue if ($topic_data['similar_topics_hide']) { return; } $topic_title = $this->clean_topic_title($topic_data['topic_title']); // If the cleaned up topic_title is empty, no need to continue if (empty($topic_title)) { return; } // Similar Topics query $sql_array = array('SELECT' => "f.forum_id, f.forum_name, t.*,\n\t\t\t\tMATCH (t.topic_title) AGAINST ('" . $this->db->sql_escape($topic_title) . "') AS score", 'FROM' => array(TOPICS_TABLE => 't'), 'LEFT_JOIN' => array(array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = t.forum_id')), 'WHERE' => "MATCH (t.topic_title) AGAINST ('" . $this->db->sql_escape($topic_title) . "') >= 0.5\n\t\t\t\tAND t.topic_status <> " . ITEM_MOVED . ' AND t.topic_visibility = ' . ITEM_APPROVED . ' AND t.topic_time > (UNIX_TIMESTAMP() - ' . $this->config['similar_topics_time'] . ') AND t.topic_id <> ' . (int) $topic_data['topic_id']); // Add topic tracking data to the query (only if query caching is off) if ($this->user->data['is_registered'] && $this->config['load_db_lastread'] && !$this->config['similar_topics_cache']) { $sql_array['LEFT_JOIN'][] = array('FROM' => array(TOPICS_TRACK_TABLE => 'tt'), 'ON' => 'tt.topic_id = t.topic_id AND tt.user_id = ' . $this->user->data['user_id']); $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.forum_id = f.forum_id AND ft.user_id = ' . $this->user->data['user_id']); $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as f_mark_time'; } else { if ($this->config['load_anon_lastread'] || $this->user->data['is_registered']) { // Cookie based tracking copied from search.php $tracking_topics = $this->request->variable($this->config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE); $tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array(); } } // We need to exclude passworded forums so we do not leak the topic title $passworded_forums = $this->user->get_passworded_forums(); // See if the admin set this forum to only search a specific group of other forums, and include them if (!empty($topic_data['similar_topic_forums'])) { // Remove any passworded forums from this group of forums we will be searching $included_forums = array_diff(json_decode($topic_data['similar_topic_forums'], true), $passworded_forums); // if there's nothing left to display (user has no access to the forums we want to search) if (empty($included_forums)) { return; } $sql_array['WHERE'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $included_forums); } else { // Remove any passworded forums if (count($passworded_forums)) { $sql_array['WHERE'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $passworded_forums, true); } $sql_array['WHERE'] .= ' AND f.similar_topics_ignore = 0'; } /** * Event to modify the sql_array for similar topics * * @event vse.similartopics.get_topic_data * @var array sql_array SQL array to get similar topics data * @since 1.3.0 */ $vars = array('sql_array'); extract($this->dispatcher->trigger_event('vse.similartopics.get_topic_data', compact($vars))); $sql = $this->db->sql_build_query('SELECT', $sql_array); $result = $this->db->sql_query_limit($sql, $this->config['similar_topics_limit'], 0, $this->config['similar_topics_cache']); // Grab icons $icons = $this->cache->obtain_icons(); $rowset = array(); while ($row = $this->db->sql_fetchrow($result)) { $similar_forum_id = (int) $row['forum_id']; $similar_topic_id = (int) $row['topic_id']; $rowset[$similar_topic_id] = $row; if ($this->auth->acl_get('f_read', $similar_forum_id)) { // Get topic tracking info if ($this->user->data['is_registered'] && $this->config['load_db_lastread'] && !$this->config['similar_topics_cache']) { $topic_tracking_info = get_topic_tracking($similar_forum_id, $similar_topic_id, $rowset, array($similar_forum_id => $row['f_mark_time'])); } else { if ($this->config['load_anon_lastread'] || $this->user->data['is_registered']) { $topic_tracking_info = get_complete_topic_tracking($similar_forum_id, $similar_topic_id); if (!$this->user->data['is_registered']) { $this->user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) base_convert($tracking_topics['l'], 36, 10) + (int) $this->config['board_startdate'] : 0; } } } // Replies $replies = $this->content_visibility->get_count('topic_posts', $row, $similar_forum_id) - 1; // Get folder img, topic status/type related information $folder_img = $folder_alt = $topic_type = ''; $unread_topic = isset($topic_tracking_info[$similar_topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$similar_topic_id]; topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); $topic_unapproved = $row['topic_visibility'] == ITEM_UNAPPROVED && $this->auth->acl_get('m_approve', $similar_forum_id); $posts_unapproved = $row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $this->auth->acl_get('m_approve', $similar_forum_id); //$topic_deleted = $row['topic_visibility'] == ITEM_DELETED; $u_mcp_queue = $topic_unapproved || $posts_unapproved ? append_sid("{$this->root_path}mcp.{$this->php_ext}", 'i=queue&mode=' . ($topic_unapproved ? 'approve_details' : 'unapproved_posts') . "&t={$similar_topic_id}", true, $this->user->session_id) : ''; //$u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$this->root_path}mcp.{$this->php_ext}", "i=queue&mode=deleted_topics&t=$similar_topic_id", true, $this->user->session_id) : $u_mcp_queue; $base_url = append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&t=' . $similar_topic_id); $topic_row = array('TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'FIRST_POST_TIME' => $this->user->format_date($row['topic_time']), 'LAST_POST_TIME' => $this->user->format_date($row['topic_last_post_time']), 'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'TOPIC_REPLIES' => $replies, 'TOPIC_VIEWS' => $row['topic_views'], 'TOPIC_TITLE' => censor_text($row['topic_title']), 'FORUM_TITLE' => $row['forum_name'], 'TOPIC_IMG_STYLE' => $folder_img, 'TOPIC_FOLDER_IMG' => $this->user->img($folder_img, $folder_alt), 'TOPIC_FOLDER_IMG_ALT' => $this->user->lang($folder_alt), 'TOPIC_ICON_IMG' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => !empty($icons[$row['icon_id']]) ? $icons[$row['icon_id']]['height'] : '', 'ATTACH_ICON_IMG' => $this->auth->acl_get('u_download') && $this->auth->acl_get('f_download', $similar_forum_id) && $row['topic_attachment'] ? $this->user->img('icon_topic_attach', $this->user->lang('TOTAL_ATTACHMENTS')) : '', 'UNAPPROVED_IMG' => $topic_unapproved || $posts_unapproved ? $this->user->img('icon_topic_unapproved', $topic_unapproved ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'S_UNREAD_TOPIC' => $unread_topic, 'S_TOPIC_REPORTED' => !empty($row['topic_reported']) && $this->auth->acl_get('m_report', $similar_forum_id), 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, 'S_HAS_POLL' => (bool) $row['poll_start'], 'U_NEWEST_POST' => append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&t=' . $similar_topic_id . '&view=unread') . '#unread', 'U_LAST_POST' => append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&t=' . $similar_topic_id . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], 'U_VIEW_TOPIC' => append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'f=' . $similar_forum_id . '&t=' . $similar_topic_id), 'U_VIEW_FORUM' => append_sid("{$this->root_path}viewforum.{$this->php_ext}", 'f=' . $similar_forum_id), 'U_MCP_REPORT' => append_sid("{$this->root_path}mcp.{$this->php_ext}", 'i=reports&mode=reports&f=' . $similar_forum_id . '&t=' . $similar_topic_id, true, $this->user->session_id), 'U_MCP_QUEUE' => $u_mcp_queue); /** * Event to modify the similar topics template block * * @event vse.similartopics.modify_topicrow * @var array row Array with similar topic data * @var array topic_row Template block array * @since 1.3.0 */ $vars = array('row', 'topic_row'); extract($this->dispatcher->trigger_event('vse.similartopics.modify_topicrow', compact($vars))); $this->template->assign_block_vars('similar', $topic_row); $this->pagination->generate_template_pagination($base_url, 'similar.pagination', 'start', $replies + 1, $this->config['posts_per_page'], 1, true, true); } } $this->db->sql_freeresult($result); $this->user->add_lang_ext('vse/similartopics', 'similar_topics'); $this->template->assign_vars(array('L_SIMILAR_TOPICS' => $this->user->lang('SIMILAR_TOPICS'), 'NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'LAST_POST_IMG' => $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'REPORTED_IMG' => $this->user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'POLL_IMG' => $this->user->img('icon_topic_poll', 'TOPIC_POLL'), 'S_PST_BRANCH' => phpbb_version_compare(max($this->config['phpbb_version'], PHPBB_VERSION), '3.2.0-dev', '<') ? '31x' : '32x')); }
function main($id, $mode) { global $config, $db, $user, $auth, $template; global $phpbb_root_path, $phpbb_admin_path, $phpEx; // Show restore permissions notice if ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) { $this->tpl_name = 'acp_main'; $this->page_title = 'ACP_MAIN'; $sql = 'SELECT user_id, username, user_colour FROM ' . USERS_TABLE . ' WHERE user_id = ' . $user->data['user_perm_from']; $result = $db->sql_query($sql); $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); $perm_from = '<strong' . ($user_row['user_colour'] ? ' style="color: #' . $user_row['user_colour'] . '">' : '>'); $perm_from .= $user_row['user_id'] != ANONYMOUS ? '<a href="' . append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&u=' . $user_row['user_id']) . '">' : ''; $perm_from .= $user_row['username']; $perm_from .= $user_row['user_id'] != ANONYMOUS ? '</a>' : ''; $perm_from .= '</strong>'; $template->assign_vars(array('S_RESTORE_PERMISSIONS' => true, 'U_RESTORE_PERMISSIONS' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm'), 'PERM_FROM' => $perm_from, 'L_PERMISSIONS_TRANSFERRED_EXPLAIN' => sprintf($user->lang['PERMISSIONS_TRANSFERRED_EXPLAIN'], $perm_from, append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=restore_perm')))); return; } $action = request_var('action', ''); if ($action) { if ($action === 'admlogout') { $user->unset_admin(); $redirect_url = append_sid("{$phpbb_root_path}index.{$phpEx}"); meta_refresh(3, $redirect_url); trigger_error($user->lang['ADM_LOGGED_OUT'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect_url . '">', '</a>')); } if (!confirm_box(true)) { switch ($action) { case 'online': $confirm = true; $confirm_lang = 'RESET_ONLINE_CONFIRM'; break; case 'stats': $confirm = true; $confirm_lang = 'RESYNC_STATS_CONFIRM'; break; case 'user': $confirm = true; $confirm_lang = 'RESYNC_POSTCOUNTS_CONFIRM'; break; case 'date': $confirm = true; $confirm_lang = 'RESET_DATE_CONFIRM'; break; case 'db_track': $confirm = true; $confirm_lang = 'RESYNC_POST_MARKING_CONFIRM'; break; case 'purge_cache': $confirm = true; $confirm_lang = 'PURGE_CACHE_CONFIRM'; break; case 'purge_sessions': $confirm = true; $confirm_lang = 'PURGE_SESSIONS_CONFIRM'; break; default: $confirm = true; $confirm_lang = 'CONFIRM_OPERATION'; } if ($confirm) { confirm_box(false, $user->lang[$confirm_lang], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'action' => $action))); } } else { switch ($action) { case 'online': if (!$auth->acl_get('a_board')) { trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } set_config('record_online_users', 1, true); set_config('record_online_date', time(), true); add_log('admin', 'LOG_RESET_ONLINE'); break; case 'stats': if (!$auth->acl_get('a_board')) { trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } $sql = 'SELECT COUNT(post_id) AS stat FROM ' . POSTS_TABLE . ' WHERE post_approved = 1'; $result = $db->sql_query($sql); set_config('num_posts', (int) $db->sql_fetchfield('stat'), true); $db->sql_freeresult($result); $sql = 'SELECT COUNT(topic_id) AS stat FROM ' . TOPICS_TABLE . ' WHERE topic_approved = 1'; $result = $db->sql_query($sql); set_config('num_topics', (int) $db->sql_fetchfield('stat'), true); $db->sql_freeresult($result); $sql = 'SELECT COUNT(user_id) AS stat FROM ' . USERS_TABLE . ' WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')'; $result = $db->sql_query($sql); set_config('num_users', (int) $db->sql_fetchfield('stat'), true); $db->sql_freeresult($result); $sql = 'SELECT COUNT(attach_id) as stat FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 0'; $result = $db->sql_query($sql); set_config('num_files', (int) $db->sql_fetchfield('stat'), true); $db->sql_freeresult($result); $sql = 'SELECT SUM(filesize) as stat FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 0'; $result = $db->sql_query($sql); set_config('upload_dir_size', (double) $db->sql_fetchfield('stat'), true); $db->sql_freeresult($result); if (!function_exists('update_last_username')) { include $phpbb_root_path . "includes/functions_user.{$phpEx}"; } update_last_username(); add_log('admin', 'LOG_RESYNC_STATS'); break; case 'user': if (!$auth->acl_get('a_board')) { trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } // Resync post counts $start = $max_post_id = 0; // Find the maximum post ID, we can only stop the cycle when we've reached it $sql = 'SELECT MAX(forum_last_post_id) as max_post_id FROM ' . FORUMS_TABLE; $result = $db->sql_query($sql); $max_post_id = (int) $db->sql_fetchfield('max_post_id'); $db->sql_freeresult($result); // No maximum post id? :o if (!$max_post_id) { $sql = 'SELECT MAX(post_id) as max_post_id FROM ' . POSTS_TABLE; $result = $db->sql_query($sql); $max_post_id = (int) $db->sql_fetchfield('max_post_id'); $db->sql_freeresult($result); } // Still no maximum post id? Then we are finished if (!$max_post_id) { add_log('admin', 'LOG_RESYNC_POSTCOUNTS'); break; } $step = $config['num_posts'] ? max((int) ($config['num_posts'] / 5), 20000) : 20000; $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0'); while ($start < $max_post_id) { $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id FROM ' . POSTS_TABLE . ' WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' AND post_postcount = 1 AND post_approved = 1 GROUP BY poster_id'; $result = $db->sql_query($sql); if ($row = $db->sql_fetchrow($result)) { do { $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; $db->sql_query($sql); } while ($row = $db->sql_fetchrow($result)); } $db->sql_freeresult($result); $start += $step; } add_log('admin', 'LOG_RESYNC_POSTCOUNTS'); break; case 'date': if (!$auth->acl_get('a_board')) { trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } set_config('board_startdate', time() - 1); add_log('admin', 'LOG_RESET_DATE'); break; case 'db_track': switch ($db->sql_layer) { case 'sqlite': case 'firebird': $db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE); break; default: $db->sql_query('TRUNCATE TABLE ' . TOPICS_POSTED_TABLE); break; } // This can get really nasty... therefore we only do the last six months $get_from_time = time() - 6 * 4 * 7 * 24 * 60 * 60; // Select forum ids, do not include categories $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type <> ' . FORUM_CAT; $result = $db->sql_query($sql); $forum_ids = array(); while ($row = $db->sql_fetchrow($result)) { $forum_ids[] = $row['forum_id']; } $db->sql_freeresult($result); // Any global announcements? ;) $forum_ids[] = 0; // Now go through the forums and get us some topics... foreach ($forum_ids as $forum_id) { $sql = 'SELECT p.poster_id, p.topic_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' AND t.topic_moved_id = 0 AND t.topic_last_post_time > ' . $get_from_time . ' AND t.topic_id = p.topic_id AND p.poster_id <> ' . ANONYMOUS . ' GROUP BY p.poster_id, p.topic_id'; $result = $db->sql_query($sql); $posted = array(); while ($row = $db->sql_fetchrow($result)) { $posted[$row['poster_id']][] = $row['topic_id']; } $db->sql_freeresult($result); $sql_ary = array(); foreach ($posted as $user_id => $topic_row) { foreach ($topic_row as $topic_id) { $sql_ary[] = array('user_id' => (int) $user_id, 'topic_id' => (int) $topic_id, 'topic_posted' => 1); } } unset($posted); if (sizeof($sql_ary)) { $db->sql_multi_insert(TOPICS_POSTED_TABLE, $sql_ary); } } add_log('admin', 'LOG_RESYNC_POST_MARKING'); break; case 'purge_cache': if ((int) $user->data['user_type'] !== USER_FOUNDER) { trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } global $cache; $cache->purge(); // Clear permissions $auth->acl_clear_prefetch(); cache_moderators(); add_log('admin', 'LOG_PURGE_CACHE'); break; case 'purge_sessions': if ((int) $user->data['user_type'] !== USER_FOUNDER) { trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); } $tables = array(CONFIRM_TABLE, SESSIONS_TABLE); foreach ($tables as $table) { switch ($db->sql_layer) { case 'sqlite': case 'firebird': $db->sql_query("DELETE FROM {$table}"); break; default: $db->sql_query("TRUNCATE TABLE {$table}"); break; } } // let's restore the admin session $reinsert_ary = array('session_id' => (string) $user->session_id, 'session_page' => (string) substr($user->page['page'], 0, 199), 'session_forum_id' => $user->page['forum'], 'session_user_id' => (int) $user->data['user_id'], 'session_start' => (int) $user->data['session_start'], 'session_last_visit' => (int) $user->data['session_last_visit'], 'session_time' => (int) $user->time_now, 'session_browser' => (string) trim(substr($user->browser, 0, 149)), 'session_forwarded_for' => (string) $user->forwarded_for, 'session_ip' => (string) $user->ip, 'session_autologin' => (int) $user->data['session_autologin'], 'session_admin' => 1, 'session_viewonline' => (int) $user->data['session_viewonline']); $sql = 'INSERT INTO ' . SESSIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $reinsert_ary); $db->sql_query($sql); add_log('admin', 'LOG_PURGE_SESSIONS'); break; } } } // Version check $user->add_lang('install'); if ($auth->acl_get('a_server') && version_compare(PHP_VERSION, '5.3.3', '<')) { $template->assign_vars(array('S_PHP_VERSION_OLD' => true, 'L_PHP_VERSION_OLD' => sprintf($user->lang['PHP_VERSION_OLD'], '<a href="https://www.phpbb.com/community/viewtopic.php?f=14&t=2152375">', '</a>'))); } $latest_version_info = false; if (($latest_version_info = obtain_latest_version_info(request_var('versioncheck_force', false))) === false) { $template->assign_var('S_VERSIONCHECK_FAIL', true); } else { $latest_version_info = explode("\n", $latest_version_info); $template->assign_vars(array('S_VERSION_UP_TO_DATE' => phpbb_version_compare(trim($latest_version_info[0]), $config['version'], '<='))); } // Get forum statistics $total_posts = $config['num_posts']; $total_topics = $config['num_topics']; $total_users = $config['num_users']; $total_files = $config['num_files']; $start_date = $user->format_date($config['board_startdate']); $boarddays = (time() - $config['board_startdate']) / 86400; $posts_per_day = sprintf('%.2f', $total_posts / $boarddays); $topics_per_day = sprintf('%.2f', $total_topics / $boarddays); $users_per_day = sprintf('%.2f', $total_users / $boarddays); $files_per_day = sprintf('%.2f', $total_files / $boarddays); $upload_dir_size = get_formatted_filesize($config['upload_dir_size']); $avatar_dir_size = 0; if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path'])) { while (($file = readdir($avatar_dir)) !== false) { if ($file[0] != '.' && $file != 'CVS' && strpos($file, 'index.') === false) { $avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file); } } closedir($avatar_dir); $avatar_dir_size = get_formatted_filesize($avatar_dir_size); } else { // Couldn't open Avatar dir. $avatar_dir_size = $user->lang['NOT_AVAILABLE']; } if ($posts_per_day > $total_posts) { $posts_per_day = $total_posts; } if ($topics_per_day > $total_topics) { $topics_per_day = $total_topics; } if ($users_per_day > $total_users) { $users_per_day = $total_users; } if ($files_per_day > $total_files) { $files_per_day = $total_files; } if ($config['allow_attachments'] || $config['allow_pm_attach']) { $sql = 'SELECT COUNT(attach_id) AS total_orphan FROM ' . ATTACHMENTS_TABLE . ' WHERE is_orphan = 1 AND filetime < ' . (time() - 3 * 60 * 60); $result = $db->sql_query($sql); $total_orphan = (int) $db->sql_fetchfield('total_orphan'); $db->sql_freeresult($result); } else { $total_orphan = false; } $dbsize = get_database_size(); $template->assign_vars(array('TOTAL_POSTS' => $total_posts, 'POSTS_PER_DAY' => $posts_per_day, 'TOTAL_TOPICS' => $total_topics, 'TOPICS_PER_DAY' => $topics_per_day, 'TOTAL_USERS' => $total_users, 'USERS_PER_DAY' => $users_per_day, 'TOTAL_FILES' => $total_files, 'FILES_PER_DAY' => $files_per_day, 'START_DATE' => $start_date, 'AVATAR_DIR_SIZE' => $avatar_dir_size, 'DBSIZE' => $dbsize, 'UPLOAD_DIR_SIZE' => $upload_dir_size, 'TOTAL_ORPHAN' => $total_orphan, 'S_TOTAL_ORPHAN' => $total_orphan === false ? false : true, 'GZIP_COMPRESSION' => $config['gzip_compress'] && @extension_loaded('zlib') ? $user->lang['ON'] : $user->lang['OFF'], 'DATABASE_INFO' => $db->sql_server_info(), 'BOARD_VERSION' => $config['version'], 'U_ACTION' => $this->u_action, 'U_ADMIN_LOG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=logs&mode=admin'), 'U_INACTIVE_USERS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=inactive&mode=list'), 'U_VERSIONCHECK' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=update&mode=version_check'), 'U_VERSIONCHECK_FORCE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'versioncheck_force=1'), 'S_ACTION_OPTIONS' => $auth->acl_get('a_board') ? true : false, 'S_FOUNDER' => $user->data['user_type'] == USER_FOUNDER ? true : false)); $log_data = array(); $log_count = false; if ($auth->acl_get('a_viewlogs')) { view_log('admin', $log_data, $log_count, 5); foreach ($log_data as $row) { $template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => $row['action'])); } } if ($auth->acl_get('a_user')) { $user->add_lang('memberlist'); $inactive = array(); $inactive_count = 0; view_inactive_users($inactive, $inactive_count, 10); foreach ($inactive as $row) { $template->assign_block_vars('inactive', array('INACTIVE_DATE' => $user->format_date($row['user_inactive_time']), 'REMINDED_DATE' => $user->format_date($row['user_reminded_time']), 'JOINED' => $user->format_date($row['user_regdate']), 'LAST_VISIT' => !$row['user_lastvisit'] ? ' - ' : $user->format_date($row['user_lastvisit']), 'REASON' => $row['inactive_reason'], 'USER_ID' => $row['user_id'], 'POSTS' => $row['user_posts'] ? $row['user_posts'] : 0, 'REMINDED' => $row['user_reminded'], 'REMINDED_EXPLAIN' => $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=users&mode=overview')), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USER_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'U_USER_ADMIN' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=users&mode=overview&u={$row['user_id']}"), 'U_SEARCH_USER' => $auth->acl_get('u_search') ? append_sid("{$phpbb_root_path}search.{$phpEx}", "author_id={$row['user_id']}&sr=posts") : '')); } $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE'); if ($config['email_enable']) { $option_ary += array('remind' => 'REMIND'); } $template->assign_vars(array('S_INACTIVE_USERS' => true, 'S_INACTIVE_OPTIONS' => build_select($option_ary))); } // Warn if install is still present if (file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) { $template->assign_var('S_REMOVE_INSTALL', true); } if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx)) { // World-Writable? (000x) $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x2)); } if (extension_loaded('mbstring')) { $template->assign_vars(array('S_MBSTRING_LOADED' => true, 'S_MBSTRING_FUNC_OVERLOAD_FAIL' => intval(@ini_get('mbstring.func_overload')) & (MB_OVERLOAD_MAIL | MB_OVERLOAD_STRING), 'S_MBSTRING_ENCODING_TRANSLATION_FAIL' => @ini_get('mbstring.encoding_translation') != 0, 'S_MBSTRING_HTTP_INPUT_FAIL' => @ini_get('mbstring.http_input') != 'pass', 'S_MBSTRING_HTTP_OUTPUT_FAIL' => @ini_get('mbstring.http_output') != 'pass')); } // Fill dbms version if not yet filled if (empty($config['dbms_version'])) { set_config('dbms_version', $db->sql_server_info(true)); } $this->tpl_name = 'acp_main'; $this->page_title = 'ACP_MAIN'; }
/** * Assign variables to the template */ public function assign_details() { if (!sizeof($this->styles)) { return false; } // Get siblings $prev = $this->sibling($this->default_style, 'prev'); $next = $this->sibling($this->default_style, 'next'); $this->template->assign_vars(array('U_PREV' => $prev['url'], 'PREV_ID' => $prev['id'], 'U_NEXT' => $next['url'], 'NEXT_ID' => $next['id'])); $category = ''; $style = new \titania_contribution(); $style->set_type(TITANIA_TYPE_STYLE); $style->options = array('demo' => true); foreach ($this->styles as $id => $data) { $style->__set_array(array('contrib_id' => $id, 'contrib_name_clean' => $data['contrib_name_clean'], 'contrib_demo' => $data['contrib_demo'])); $preview_img = false; if (isset($data['thumb_id'])) { $parameters = array('id' => $data['thumb_id']); if ($data['thumbnail']) { $parameters += array('mode' => 'view', 'thumb' => 1); } $preview_img = $this->controller_helper->route('phpbb.titania.download', $parameters); } $authors = $this->get_author_profile(array('username_clean' => $data['username_clean'], 'username' => $data['username'], 'user_id' => $data['contrib_user_id'], 'user_colour' => $data['user_colour'])); $authors .= $data['coauthors']; $data['category_name'] = $this->user->lang($data['category_name']); $phpbb_version = $data['phpbb_versions']['branch'][0] . '.' . $data['phpbb_versions']['branch'][1] . '.' . $data['phpbb_versions']['revision']; $current_phpbb_version = $data['phpbb_versions']['branch'][0] . '.' . $data['phpbb_versions']['branch'][1] . '.' . $this->ext_config->phpbb_versions[$data['phpbb_versions']['branch']]['latest_revision']; $vars = array('AUTHORS' => $authors, 'CATEGORY' => $category != $data['category_name'] ? $data['category_name'] : false, 'ID' => $id, 'IFRAME' => $style->get_demo_url($this->phpbb_branch), 'LICENSE' => $data['revision_license'] ? $data['revision_license'] : $this->user->lang['UNKNOWN'], 'NAME' => $data['contrib_name'], 'PHPBB_VERSION' => $phpbb_version, 'PREVIEW' => $preview_img, 'S_OUTDATED' => phpbb_version_compare($phpbb_version, $current_phpbb_version, '<'), 'U_DEMO' => $style->get_demo_url($this->phpbb_branch, true), 'U_DOWNLOAD' => $this->controller_helper->route('phpbb.titania.download', array('id' => $data['attachment_id'])), 'U_VIEW' => $style->get_url()); if ($this->default_style == $id) { $this->template->assign_vars($vars); } $category = $data['category_name']; $this->template->assign_block_vars('stylerow', $vars); unset($this->styles[$id], $vars, $this->coauthors[$id]); } }
function main($id, $mode) { global $db, $user, $auth, $template, $cache, $phpEx; global $config, $phpbb_root_path, $phpbb_admin_path; include $phpbb_root_path . 'includes/functions_user.' . $phpEx; include $phpbb_root_path . 'includes/functions_invite.' . $phpEx; $user->add_lang(array('ucp', 'mods/info_acp_invite', 'acp/board', 'acp/email')); $invite = new invite(); $action = request_var('action', ''); $submit = isset($_POST['submit']) ? true : false; $error = array(); foreach ($invite->config as $k => $v) { $new_config[$k] = utf8_normalize_nfc(request_var($k, $v, true)); } $form_key = 'acp_invite'; add_form_key($form_key); if (request_var('version_check', false)) { $mode = 'version'; } if (!$invite->config['enable']) { $error[] = $user->lang['ACP_IAF_DISABLED']; } if ($invite->config['enable'] && !$config['email_enable']) { $error[] = sprintf($user->lang['ERROR_EMAIL_DISABLED'], append_sid("{$phpbb_admin_path}index.{$phpEx}?i=board&mode=email")); } switch ($mode) { case 'overview': $this->page_title = 'ACP_INVITE_OVERVIEW'; $this->tpl_name = 'acp_invite_overview'; // Calculate stats $days_installed = (time() - $invite->config['tracking_time']) / 86400; $invitations_per_day = sprintf('%.2f', $invite->config['num_invitations'] / $days_installed); $registrations_per_day = sprintf('%.2f', $invite->config['num_registrations'] / $days_installed); $referrals_per_day = sprintf('%.2f', $invite->config['num_referrals'] / $days_installed); $install_date = $user->format_date($invite->config['tracking_time']); // Version check $latest_version_info = $update_to_date = false; if (($latest_version_info = $this->latest_version_info(request_var('versioncheck_force', false))) === false) { $template->assign_var('S_VERSIONCHECK_FAIL', true); } else { $latest_version_info = explode("\n", $latest_version_info); $up_to_date = phpbb_version_compare($invite->config['version'], trim($latest_version_info[0]), '<') ? false : true; } if ($action) { if (!confirm_box(true)) { switch ($action) { case 'sync_referral_data': $confirm = true; $confirm_lang = 'ACP_INVITE_CONFIRM_SYNC_REFERRAL_DATA'; break; default: $confirm = false; break; } if ($confirm) { confirm_box(false, $user->lang[$confirm_lang], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'action' => $action))); } } else { switch ($action) { case 'sync_referral_data': // Get an idea of which users need to be updated $sql = 'SELECT invite_user_id, register_user_id, invite_time FROM ' . INVITE_LOG_TABLE . ' WHERE register_key_used = 1'; $result = $db->sql_query($sql); $uid_array = $db->sql_fetchrowset($result); $db->sql_freeresult($result); for ($i = 0; $i < sizeof($uid_array); $i++) { if ($invite->config['referral_invitation_bridge']) { $sql = 'SELECT COUNT(referrer_id) AS is_existent FROM ' . INVITE_REFERRALS_TABLE . ' WHERE referrer_id = ' . (int) $uid_array[$i]['invite_user_id'] . ' AND referral_id = ' . (int) $uid_array[$i]['register_user_id']; $result = $db->sql_query($sql); $exists = $db->sql_fetchfield('is_existent'); $db->sql_freeresult($result); if (!$exists) { $sql_ary = array('user_referrer_id' => $uid_array[$i]['invite_user_id'], 'user_referrer_name' => $invite->user_return_data($uid_array[$i]['invite_user_id'], 'user_id', 'username_clean')); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . (int) $uid_array[$i]['register_user_id']; $result = $db->sql_query($sql); $db->sql_freeresult($result); $sql_ary = array('referrer_id' => $uid_array[$i]['invite_user_id'], 'referral_id' => $uid_array[$i]['register_user_id'], 'time' => $uid_array[$i]['invite_time']); $sql = 'INSERT INTO ' . INVITE_REFERRALS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $db->sql_query($sql); } } else { $sql_ary = array('user_referrer_id' => 0, 'user_referrer_name' => ''); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . (int) $uid_array[$i]['register_user_id']; $result = $db->sql_query($sql); $db->sql_freeresult($result); $sql = 'DELETE FROM ' . INVITE_REFERRALS_TABLE . ' WHERE referrer_id = ' . (int) $uid_array[$i]['invite_user_id'] . ' AND referral_id = ' . (int) $uid_array[$i]['register_user_id']; $db->sql_query($sql); $sql = 'SELECT COUNT(referrer_id) AS total_referrals FROM ' . INVITE_REFERRALS_TABLE; $result = $db->sql_query($sql); $total_referrals = $db->sql_fetchfield('total_referrals'); $db->sql_freeresult($result); $sql = 'UPDATE ' . INVITE_CONFIG_TABLE . ' SET config_value = ' . (int) $total_referrals . ' WHERE config_name = "num_referrals"'; $result = $db->sql_query($sql); $db->sql_freeresult($result); $sql = 'SELECT COUNT(referrer_id) AS user_referrals FROM ' . INVITE_REFERRALS_TABLE . ' WHERE referrer_id = ' . (int) $uid_array[$i]['invite_user_id']; $result = $db->sql_query($sql); $user_referrals = $db->sql_fetchfield('user_referrals'); $db->sql_freeresult($result); $sql = 'UPDATE ' . USERS_TABLE . ' SET user_referrals = ' . $user_referrals . ' WHERE user_id = ' . (int) $uid_array[$i]['invite_user_id']; $result = $db->sql_query($sql); $db->sql_freeresult($result); } // Synch stats $sql = 'SELECT COUNT(referrer_id) AS total_referrals FROM ' . INVITE_REFERRALS_TABLE; $result = $db->sql_query($sql); $total_referrals = $db->sql_fetchfield('total_referrals'); $db->sql_freeresult($result); $sql = 'UPDATE ' . INVITE_CONFIG_TABLE . ' SET config_value = ' . (int) $total_referrals . ' WHERE config_name = "num_referrals"'; $result = $db->sql_query($sql); $sql = 'SELECT COUNT(referrer_id) AS user_referrals FROM ' . INVITE_REFERRALS_TABLE . ' WHERE referrer_id = ' . (int) $uid_array[$i]['invite_user_id']; $result = $db->sql_query($sql); $user_referrals = $db->sql_fetchfield('user_referrals'); $db->sql_freeresult($result); $sql = 'UPDATE ' . USERS_TABLE . ' SET user_referrals = ' . $user_referrals . ' WHERE user_id = ' . (int) $uid_array[$i]['invite_user_id']; $result = $db->sql_query($sql); } break; default: trigger_error('NO_MODE', E_USER_ERROR); break; } add_log('admin', 'LOG_INVITE_' . strtoupper($action)); trigger_error($user->lang['ACP_INVITE_' . strtoupper($action) . '_SUCCESS'] . adm_back_link($this->u_action)); } } if ($submit) { if (!check_form_key($form_key)) { $error[] = $user->lang['FORM_INVALID']; } foreach ($new_config as $k => $v) { $invite->set_config($k, $v); } add_log('admin', 'LOG_INVITE_SETTINGS_UPDATED'); trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } foreach ($new_config as $k => $v) { $template->assign_vars(array('S_' . strtoupper($k) => $v)); } $template->assign_vars(array('ERROR' => sizeof($error) ? array_pop($error) : '', 'TOTAL_INVITATIONS' => $invite->config['num_invitations'], 'INVITATIONS_PER_DAY' => $invitations_per_day, 'TOTAL_SUCCESSFUL_INVITATIONS' => $invite->config['num_registrations'], 'SUCCESSFUL_INVITATIONS_PER_DAY' => $registrations_per_day, 'TOTAL_REFERRALS' => $invite->config['num_referrals'], 'REFERRALS_PER_DAY' => $referrals_per_day, 'INSTALL_DATE' => $install_date, 'INVITE_VERSION' => $invite->config['version'], 'U_ACTION' => $this->u_action, 'U_VERSIONCHECK' => $this->u_action . '&version_check=1', 'U_VERSIONCHECK_FORCE' => $this->u_action . '&versioncheck_force=1', 'S_VERSION_UP_TO_DATE' => $up_to_date, 'S_SETTINGS_AUTH' => $auth->acl_get('acl_a_invite_settings') ? true : false, 'S_FOUNDER' => $user->data['user_type'] == USER_FOUNDER ? true : false)); break; case 'version': $this->page_title = 'ACP_INVITE_OVERVIEW'; $this->tpl_name = 'acp_invite_overview'; $user->add_lang('install'); $errstr = ''; $errno = 0; $info = $this->latest_version_info(request_var('versioncheck_force', false), true); if ($info === false) { trigger_error('VERSIONCHECK_FAIL', E_USER_WARNING); } $info = explode("\n", $info); $latest_version = trim($info[0]); $announcement_url = trim($info[1]); $announcement_url = strpos($announcement_url, '&') === false ? str_replace('&', '&', $announcement_url) : $announcement_url; $update_link = append_sid($phpbb_root_path . 'install/index.' . $phpEx); $next_feature_version = $next_feature_announcement_url = false; if (isset($info[2]) && trim($info[2]) !== '') { $next_feature_version = trim($info[2]); $next_feature_announcement_url = trim($info[3]); } $up_to_date = phpbb_version_compare($invite->config['version'], $latest_version, '<') ? false : true; $template->assign_vars(array('S_VERSION_CHECK' => true, 'S_UP_TO_DATE' => $up_to_date, 'U_VERSIONCHECK_FORCE' => $this->u_action . '&version_check=1&versioncheck_force=1', 'LATEST_VERSION' => '<strong style="color:#228822">' . $latest_version . '</strong>', 'CURRENT_VERSION' => '<strong style="color:#' . ($up_to_date ? '228822' : 'BC2A4D') . '">' . $invite->config['version'] . '</strong>', 'NEXT_FEATURE_VERSION' => $next_feature_version, 'UPDATE_INSTRUCTIONS' => sprintf($user->lang['ACP_INVITE_UPDATE_INSTRUCTIONS'], $announcement_url, $update_link), 'UPGRADE_INSTRUCTIONS' => $next_feature_version ? $user->lang('INVITE_UPGRADE_INSTRUCTIONS', $next_feature_version, $next_feature_announcement_url) : false)); break; case 'settings': case 'referral_settings': $this->page_title = $mode == 'referral_settings' ? 'ACP_REFERRAL_SETTINGS' : 'ACP_INVITE_SETTINGS'; $this->tpl_name = $mode == 'referral_settings' ? 'acp_invite_referral' : 'acp_invite'; $queue_time_m = request_var('queue_time_m', floor($invite->config['queue_time'] / 60)); $queue_time_s = request_var('queue_time_s', $invite->config['queue_time'] % 60); if (!$invite->config['enable_invitation'] && $mode == 'settings') { $error[] = $user->lang['ACP_INVITATION_DISABLED']; } if (!$invite->config['enable_referral'] && $mode == 'referral_settings') { $error[] = $user->lang['ACP_REFERRAL_DISABLED']; } if ($submit) { $new_config['queue_time'] = $queue_time_s + $queue_time_m * 60; $check_ary = array('queue_time' => array('num', true, 1, 9999999999), 'message_min_chars' => array('num', true, 1, 9999), 'message_max_chars' => array('num', false, 1, 9999), 'subject_min_chars' => array('num', false, 1, 999), 'subject_max_chars' => array('num', false, 1, 999)); $error = validate_data($new_config, $check_ary); if (!check_form_key($form_key)) { $error[] = $user->lang['FORM_INVALID']; } // No errors.. continue! if (!sizeof($error)) { foreach ($new_config as $k => $v) { $invite->set_config($k, $v); } add_log('admin', 'LOG_INVITE_SETTINGS_UPDATED'); trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); } // Replace "error" strings with their real, localised form $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); } foreach ($new_config as $k => $v) { $template->assign_vars(array('S_' . strtoupper($k) => $v)); } $template->assign_vars(array('ERROR' => sizeof($error) ? array_pop($error) : '', 'S_VALUE_EMAIL' => EMAIL, 'S_VALUE_PM' => PM, 'S_VALUE_OPTIONAL' => OPTIONAL, 'S_GROUP_SELECT' => group_select_options($new_config['key_group'], false, 0), 'S_EMAIL_ENABLE' => $config['email_enable'] ? true : false, 'S_SELECT_LANGUAGE' => $this->build_select('language', '', $new_config['invite_language_select']), 'S_SELECT_PROFILE_LOCATION' => $this->build_select('profile_location'), 'S_SELECT_PROFILE_TYPE' => $this->build_select('profile_type'), 'S_SELECT_REFERRAL_PROFILE_LOCATION' => $this->build_select('referral_profile_location'), 'S_SELECT_REFERRAL_PROFILE_TYPE' => $this->build_select('referral_profile_type'), 'S_PRIORITY_OPTIONS' => $this->build_select('priority', '', $new_config['invite_priority_flag']), 'S_QUEUE_TIME_M' => $queue_time_m, 'S_QUEUE_TIME_S' => $queue_time_s, 'U_ACTION' => $this->u_action)); if ($invite->ultimate_points_installed()) { $template->assign_vars(array('S_ULTIMATE_POINTS_INSTALLED' => true)); } if ($invite->cash_installed()) { global $cash; $template->assign_vars(array('S_CASH_INSTALLED' => true, 'S_CASH_CURRENCY_INVITE' => $cash->get_currencies($invite->config['cash_id_invite'], true), 'S_CASH_CURRENCY_REGISTER' => $cash->get_currencies($invite->config['cash_id_register'], true))); } break; case 'templates': $this->page_title = 'ACP_INVITE_TEMPLATES'; $this->tpl_name = 'acp_invite_templates'; $select = isset($_POST['select']) ? true : false; $tpl_type = request_var('template_type', '', true); $tpl_lang = request_var('template_language', $user->data['user_lang'], true); $tpl_subject = $select ? $invite->get_template("{$tpl_type}_subject.txt", $tpl_lang) : ''; $tpl_message = $select ? $invite->get_template("{$tpl_type}_message.txt", $tpl_lang) : ''; if ($submit) { $tpl_subject = request_var('template_subject', $invite->get_template("{$tpl_type}_subject.txt", $tpl_lang), true); $tpl_message = request_var('template_message', $invite->get_template("{$tpl_type}_message.txt", $tpl_lang), true); if (!check_form_key($form_key)) { $error[] = $user->lang['FORM_INVALID']; } // No errors.. continue! if (!sizeof($error)) { $invite->set_template($tpl_subject, "{$tpl_type}_subject.txt", $tpl_lang); $invite->set_template($tpl_message, "{$tpl_type}_message.txt", $tpl_lang); add_log('admin', 'LOG_INVITE_TEMPLATES_UPDATED'); trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); } } // Output wildcard tables $wildcards['general'] = $this->print_wildcard_array($invite, 'general'); $wildcards['user'] = $this->print_wildcard_array($invite, 'user'); foreach ($wildcards as $type => $data) { foreach ($data as $wildcard => $example_value) { $template->assign_block_vars($type . '_wildcards', array('WILDCARD' => $wildcard, 'EXAMPLE_VALUE' => $example_value)); } } $template->assign_vars(array('ERROR' => sizeof($error) ? array_pop($error) : '', 'TEMPLATE_SUBJECT' => $tpl_subject, 'TEMPLATE_MESSAGE' => $tpl_message, 'S_EDIT_TEMPLATE' => $select ? true : false, 'S_TEMPLATE_TYPE_SELECT' => $this->build_select('message', $invite->INVITE_MESSAGE_TYPE, $tpl_type), 'S_TEMPLATE_LANGUAGE_SELECT' => language_select($tpl_lang))); break; case 'log': $this->page_title = 'ACP_INVITE_LOG'; $this->tpl_name = 'acp_invite_log'; $this->log_type = LOG_INVITE; $start = request_var('start', 0); $show_info = request_var('info', 0); $marked = request_var('mark', array(0)); $filter = request_var('filter', 'all'); $deletemark = isset($_POST['delmarked']) ? true : false; $deleteall = isset($_POST['delall']) ? true : false; $entries_per_page = 25; // Sort keys $sort_days = request_var('st', 0); $sort_key = request_var('sk', 't'); $sort_dir = request_var('sd', 'd'); $sort_user = request_var('ui', '', true); // Delete entries if requested and able if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) { if (confirm_box(true)) { $where_sql = ''; if ($deletemark && sizeof($marked)) { $sql_in = array(); foreach ($marked as $mark) { $sql_in[] = $mark; } $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in); unset($sql_in); } if ($where_sql || $deleteall) { $sql = 'DELETE FROM ' . LOG_TABLE . "\n\t\t\t\t\t\t\t\tWHERE log_type = {$this->log_type}\n\t\t\t\t\t\t\t\t{$where_sql}"; $db->sql_query($sql); } add_log('admin', 'LOG_INVITE_LOG_CLEARED'); } else { confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array('start' => $start, 'delmarked' => $deletemark, 'delall' => $deleteall, 'mark' => $marked, 'st' => $sort_days, 'sk' => $sort_key, 'sd' => $sort_dir, 'i' => $id, 'mode' => $mode, 'action' => $action))); } } // Sorting $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']); $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation'); $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); // Define where and sort sql for use in displaying logs $sql_where = $sort_days ? time() - $sort_days * 86400 : 0; $sql_sort = $sort_by_sql[$sort_key] . ' ' . ($sort_dir == 'd' ? 'DESC' : 'ASC'); $sql_user = $invite->user_return_data($db->sql_escape(utf8_clean_string($sort_user)), 'username_clean', 'user_id'); // Grab log data $log_data = array(); $log_count = 0; view_log('invite', $log_data, $log_count, $entries_per_page, $start, $sql_user, $filter, $sql_user, $sql_where, $sql_sort); $u_sort_param .= $sql_user ? "&ui={$sort_user}" : ''; $log_count = $sql_user ? $log_count : ($sort_user ? 0 : $log_count); $template->assign_vars(array('U_ACTION' => $this->u_action, 'S_FILTER' => $this->build_select('filter', '', $filter), 'S_ON_PAGE' => on_page($log_count, $entries_per_page, $start), 'PAGINATION' => generate_pagination($this->u_action . "&{$u_sort_param}", $log_count, $entries_per_page, $start, true), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'S_SORT_USER' => $sort_user ? $sort_user : '', 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'), 'S_USER_ENTRY' => empty($sort_user) ? true : $sql_user)); foreach ($log_data as $row) { // Remove info to fix the bug 'Invitation log - Details' $u_sort_param = $show_info ? str_replace("&info={$show_info}", '', $u_sort_param) : $u_sort_param; $data = array(); $template->assign_block_vars('log', array('USERNAME' => $row['username_full'], 'REPORTEE_USERNAME' => $row['reportee_username'] && $row['user_id'] != $row['reportee_id'] ? $row['reportee_username_full'] : '', 'IP' => $row['ip'], 'DATE' => $user->format_date($row['time']), 'ACTION' => $row['action'], 'DATA' => sizeof($data) ? implode(' | ', $data) : '', 'ID' => $row['id'])); } break; } }
* @ignore */ define('IN_PHPBB', true); $phpbb_root_path = defined('PHPBB_ROOT_PATH') ? PHPBB_ROOT_PATH : './'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include $phpbb_root_path . 'common.' . $phpEx; // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup('mods/dkp_common'); global $config, $db; if (!defined("EMED_BBDKP")) { trigger_error($user->lang['BBDKPDISABLED'], E_USER_WARNING); } // Include the base class if (!class_exists('\\bbdkp\\admin\\Admin')) { require "{$phpbb_root_path}includes/bbdkp/admin/admin.{$phpEx}"; } $admin = new \bbdkp\admin\Admin(); $plugins = $admin->get_plugin_info(); foreach ($plugins as $pname => $pdetails) { $a = \phpbb_version_compare(trim($pdetails['latest']), $pdetails['version'], '<='); $template->assign_block_vars('plugins_row', array('PLUGINNAME' => ucwords($pdetails['name']), 'VERSION' => $pdetails['version'])); } $template->assign_vars(array('PBPBBVERSION' => $config['version'], 'BBDKPVERSION' => $config['bbdkp_version'])); $title = $user->lang['ABOUT']; unset($admin); // Output page page_header($title); $template->set_filenames(array('body' => 'dkp/about.html')); page_footer();
public function effectively_installed() { return phpbb_version_compare($this->config['version'], '3.0.4', '>='); }
/** * Get the template engine to use for parsing skeleton templates. * Will get the appropriate engine based on the current phpBB version. * * @return twig Template object */ protected function get_template_engine() { $config = new config(array('load_tplcompile' => true, 'tpl_allow_php' => false, 'assets_version' => null)); if (phpbb_version_compare(PHPBB_VERSION, '3.2.0-dev', '<')) { $template_engine = new twig($this->phpbb_container->get('path_helper'), $config, $this->user, new context()); } else { $template_engine = new twig($this->phpbb_container->get('path_helper'), $config, new context(), new environment($config, $this->phpbb_container->get('filesystem'), $this->phpbb_container->get('path_helper'), $this->phpbb_container->getParameter('core.cache_dir'), $this->phpbb_container->get('ext.manager'), new loader(new \phpbb\filesystem\filesystem())), $this->phpbb_container->getParameter('core.cache_dir'), $this->phpbb_container->get('user')); } return $template_engine; }
/** * Check whether or not the extension can be enabled. * The current phpBB version should meet or exceed * the minimum version required by this extension: * * Requires phpBB 3.2.0-dev * * @return bool * @access public */ public function is_enableable() { return phpbb_version_compare(PHPBB_VERSION, '3.2.0-dev', '>='); }
/** * Check for FULLTEXT index support * * @return bool True if FULLTEXT is supported, false otherwise */ public function is_supported() { // FULLTEXT is supported on InnoDB since MySQL 5.6.4 according to // http://dev.mysql.com/doc/refman/5.6/en/innodb-storage-engine.html return $this->get_engine() === 'myisam' || $this->get_engine() === 'innodb' && phpbb_version_compare($this->db->sql_server_info(true), '5.6.4', '>='); }
public function is_enableable() { global $config; return phpbb_version_compare($config['version'], '3.1.9', '>=') && phpbb_version_compare($config['version'], '3.2.0@dev', '<') ? true : false; }
/** * Check phpBB 3.1 compatibility * * Requires phpBB 3.1.4 or greater * * @return bool */ protected function phpbb_31x_compatible() { return phpbb_version_compare(PHPBB_VERSION, '3.1.4', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.2.0-dev', '<'); }
public function update_data() { return array(array('if', array(phpbb_version_compare($this->config['version'], '3.0.12-RC2', '<'), array('config.update', array('version', '3.0.12-RC2'))))); }
/** * Wrapper for version_compare() that allows using uppercase A and B * for alpha and beta releases. * * See http://www.php.net/manual/en/function.version-compare.php * * @param string $version1 First version number * @param string $version2 Second version number * @param string $operator Comparison operator (optional) * * @return mixed Boolean (true, false) if comparison operator is specified. * Integer (-1, 0, 1) otherwise. */ public function compare($version1, $version2, $operator = null) { return phpbb_version_compare($version1, $version2, $operator); }
/** * @dataProvider alpha_beta_test_data */ public function test_alpha_beta($expected, $version1, $version2) { $this->assertEquals($expected, phpbb_version_compare($version1, $version2), "Result of version comparison ({$version1}, {$version2}) = {$expected} is incorrect."); }
/** * The version to check * * @param string $version * @return bool */ protected function version_is_filtered($version) { return (!$this->min_version || phpbb_version_compare($this->min_version, $version, '<=')) && (!$this->max_version || phpbb_version_compare($this->max_version, $version, '>=')); }
/** * {@inheritdoc} */ public function is_enableable() { $config = $this->container->get('config'); return phpbb_version_compare($config['version'], self::PHPBB_VERSION, '>='); }
/** * @see \phpbb\extension\base::is_enableable() */ function is_enableable() { $config = $this->container->get('config'); $mgr = $this->container->get('ext.manager'); $template = $this->container->get('template'); $meta_mgr = $mgr->create_extension_metadata_manager($this->extension_name, $template); $meta = $meta_mgr->get_metadata(); if (isset($meta['require'])) { $require = $meta['require']; } else { $require = array(); } if (isset($meta['extra']['soft_require'])) { $require = array_merge($require, $meta['extra']['soft_require']); } $require = array_merge($require, $this->extra_dependencies()); foreach ($require as $key => $value) { $info = $this->split_version_info($value); switch (strtolower($key)) { case 'php': if (!phpbb_version_compare(PHP_VERSION, $info['version'], $info['operator'])) { echo "PHP VERSION FAILED"; return false; } break; case 'phpbb': case 'phpbb/phpbb': if (phpbb_version_compare($config['version'], $info['version'], $info['operator'])) { // No suitable phpbb Version echo "PHPBB VERSION FAILED"; return false; } break; case 'gn36/phpbb-oo-posting-api': if (!file_exists(__DIR__ . '/vendor/gn36/phpbb-oo-posting-api/src/Gn36/OoPostingApi/post.php')) { echo "Vendor dependency {$key} is missing."; return false; } break; default: // This should be an extension as a requirement if (!$mgr->is_enabled($key)) { echo "EXTENSION {$key} IS MISSING"; return false; } $ext_meta_mgr = $mgr->create_extension_metadata_manager($key, $template); $ext_meta = $ext_meta_mgr->get_metadata(); $ext_version = $ext_meta['version']; if (!phpbb_version_compare($ext_version, $info['version'], $info['operator'])) { echo "EXTENSION {$key} HAS INCOMPATIBLE VERSION"; return false; } } } // Apparently passed all checks return true; }
/** * main Settings function * * @param int $id * @param String $mode */ function main($id, $mode) { global $db, $user, $template, $cache, $config, $phpbb_admin_path, $phpEx; $link = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=mainpage") . '"><h3>' . $user->lang['RETURN_DKPINDEX'] . '</h3></a>'; switch ($mode) { /** * MAINPAGE */ case 'mainpage': $sql = 'SELECT count(*) as member_count FROM ' . MEMBER_LIST_TABLE . " WHERE member_status='0'"; $result = $db->sql_query($sql); $total_members_inactive = (int) $db->sql_fetchfield('member_count'); $sql = 'SELECT count(*) as member_count FROM ' . MEMBER_LIST_TABLE . " WHERE member_status='1'"; $result = $db->sql_query($sql); $total_members_active = (int) $db->sql_fetchfield('member_count'); $total_members = $total_members_active . ' / ' . $total_members_inactive; $sql = 'SELECT count(*) as dkp_count FROM ' . MEMBER_DKP_TABLE; $result = $db->sql_query($sql); $total_dkpcount = (int) $db->sql_fetchfield('dkp_count'); $sql = 'SELECT count(*) as pool_count FROM ' . DKPSYS_TABLE; $result = $db->sql_query($sql); $total_poolcount = (int) $db->sql_fetchfield('pool_count'); $sql = 'SELECT count(*) as adjustment_count FROM ' . ADJUSTMENTS_TABLE; $result = $db->sql_query($sql); $total_adjustmentcount = (int) $db->sql_fetchfield('adjustment_count'); $sql = 'SELECT count(*) as event_count FROM ' . EVENTS_TABLE; $result = $db->sql_query($sql); $total_eventcount = (int) $db->sql_fetchfield('event_count'); $sql = 'SELECT count(*) as guild_count FROM ' . GUILD_TABLE; $result = $db->sql_query($sql); $total_guildcount = (int) $db->sql_fetchfield('guild_count'); $total_raids = 0; $sql = 'SELECT count(*) as raid_count FROM ' . RAIDS_TABLE; $result = $db->sql_query($sql); $total_raids = (int) $db->sql_fetchfield('raid_count'); $days = (time() - $config['bbdkp_eqdkp_start']) / 86400; $raids_per_day = sprintf("%.2f", $total_raids / $days); $sql = 'SELECT count(*) as item_count FROM ' . RAID_ITEMS_TABLE; if ($raids_per_day > $total_raids) { $raids_per_day = $total_raids; } $total_items = (int) $db->sql_fetchfield('item_count'); $db->sql_freeresult($result); $items_per_day = sprintf("%.2f", $total_items / $days); if ($items_per_day > $total_items) { $items_per_day = $total_items; } if ($config['bbdkp_eqdkp_start'] != 0) { $bbdkp_started = date($config['bbdkp_date_format'], $config['bbdkp_eqdkp_start']); } else { $bbdkp_started = ''; } // read verbose log $logs = \bbdkp\admin\log::Instance(); $listlogs = $logs->read_log('', false, true, '', ''); if (isset($listlogs)) { foreach ($listlogs as $key => $log) { $template->assign_block_vars('actions_row', array('U_VIEW_LOG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=dkp&mode=dkp_logs&' . URI_LOG . '=' . $log['log_id']), 'LOGDATE' => $log['datestamp'], 'ACTION' => $log['log_line'])); } } $latest_version_info = false; if (($latest_version_info = parent::get_productversion('bbdkp', request_var('versioncheck_force', false))) === false) { $template->assign_var('S_VERSIONCHECK_FAIL', true); } else { if (phpbb_version_compare($latest_version_info, $config['bbdkp_version'], '<=')) { $template->assign_vars(array('S_VERSION_UP_TO_DATE' => true)); } else { // you have an old version $template->assign_vars(array('BBDKP_NOT_UP_TO_DATE_TITLE' => sprintf($user->lang['NOT_UP_TO_DATE_TITLE'], 'bbDKP'), 'BBDKP_LATESTVERSION' => $latest_version_info[0], 'BBDKPVERSION' => $user->lang['BBDKP_YOURVERSION'] . $config['bbdkp_version'], 'UPDATEINSTR' => $user->lang['BBDKP_LATESTVERSION'] . $latest_version_info[0] . ', <a href="' . $user->lang['WEBURL'] . '">' . $user->lang['DOWNLOAD'] . '</a>')); } } //LOOP PLUGINS TABLE $plugin_versioninfo = (array) parent::get_plugin_info(request_var('versioncheck_force', false)); foreach ($plugin_versioninfo as $pname => $pdetails) { $a = phpbb_version_compare(trim($pdetails['latest']), $pdetails['version'], '<='); $template->assign_block_vars('plugin_row', array('PLUGINNAME' => ucwords($pdetails['name']), 'VERSION' => $pdetails['version'], 'ISUPTODATE' => phpbb_version_compare(trim($pdetails['latest']), $pdetails['version'], '<='), 'LATESTVERSION' => $pdetails['latest'], 'UPDATEINSTR' => '<a href="' . BBDKP_PLUGINURL . '">' . $user->lang['DOWNLOAD_LATEST_PLUGINS'] . $pdetails['latest'] . '</a>', 'INSTALLDATE' => $pdetails['installdate'])); } $template->assign_vars(array('GLYPH' => "{$phpbb_admin_path}/images/glyphs/view.gif", 'NUMBER_OF_MEMBERS' => $total_members, 'NUMBER_OF_RAIDS' => $total_raids, 'NUMBER_OF_ITEMS' => $total_items, 'NUMBER_OF_MEMBERDKP' => $total_dkpcount, 'NUMBER_OF_DKPSYS' => $total_poolcount, 'NUMBER_OF_GUILDS' => $total_guildcount, 'NUMBER_OF_EVENTS' => $total_eventcount, 'NUMBER_OF_ADJUSTMENTS' => $total_adjustmentcount, 'RAIDS_PER_DAY' => $raids_per_day, 'ITEMS_PER_DAY' => $items_per_day, 'BBDKP_STARTED' => $bbdkp_started, 'BBDKP_VERSION' => $config['bbdkp_version'], 'U_VERSIONCHECK_FORCE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=mainpage&versioncheck_force=1"), 'GAMES_INSTALLED' => count($this->games) > 0 ? implode(", ", $this->games) : $user->lang['NA'])); $this->page_title = 'ACP_DKP_MAINPAGE'; $this->tpl_name = 'dkp/acp_mainpage'; break; /** * * DKP CONFIG */ /** * * DKP CONFIG */ case 'dkp_config': $action = request_var('action', ''); switch ($action) { case 'addconfig': if (!check_form_key('acp_dkp')) { trigger_error($user->lang['FV_FORMVALIDATION'], E_USER_WARNING); } $day = request_var('bbdkp_start_dd', 0); $month = request_var('bbdkp_start_mm', 0); $year = request_var('bbdkp_start_yy', 0); $bbdkp_start = mktime(0, 0, 0, $month, $day, $year); $settings = array('bbdkp_default_realm' => utf8_normalize_nfc(request_var('realm', '', true)), 'bbdkp_default_region' => utf8_normalize_nfc(request_var('region', '', true)), 'bbdkp_dkp_name' => utf8_normalize_nfc(request_var('dkp_name', '', true)), 'bbdkp_eqdkp_start' => $bbdkp_start, 'bbdkp_user_nlimit' => request_var('bbdkp_user_nlimit', 0), 'bbdkp_date_format' => request_var('date_format', ''), 'bbdkp_date_format' => request_var('date_format', ''), 'bbdkp_lang' => request_var('language', 'en'), 'bbdkp_maxchars' => request_var('maxchars', 2), 'bbdkp_minrosterlvl' => request_var('bbdkp_minrosterlvl', 0), 'bbdkp_roster_layout' => request_var('rosterlayout', 0), 'bbdkp_show_achiev' => request_var('showachievement', 0), 'bbdkp_hide_inactive' => isset($_POST['hide_inactive']) ? request_var('hide_inactive', '') : '0', 'bbdkp_inactive_period' => request_var('inactive_period', 0), 'bbdkp_list_p1' => request_var('list_p1', 0), 'bbdkp_list_p2' => request_var('list_p2', 0), 'bbdkp_list_p3' => request_var('list_p3', 0), 'bbdkp_user_llimit' => request_var('bbdkp_user_llimit', 0), 'bbdkp_user_elimit' => request_var('bbdkp_user_elimit', 0), 'bbdkp_event_viewall' => isset($_POST['event_viewall']) ? request_var('event_viewall', '') : '0', 'bbdkp_user_elimit' => request_var('bbdkp_user_elimit', 0), 'bbdkp_user_alimit' => request_var('bbdkp_user_alimit', 0), 'bbdkp_active_point_adj' => request_var('bbdkp_active_point_adj', 0.0), 'bbdkp_inactive_point_adj' => request_var('bbdkp_inactive_point_adj', 0.0), 'bbdkp_starting_dkp' => request_var('starting_dkp', 0.0), 'bbdkp_user_ilimit' => request_var('bbdkp_user_ilimit', 0), 'bbdkp_user_rlimit' => request_var('bbdkp_user_rlimit', 0)); set_config('bbdkp_default_realm', $settings['bbdkp_default_realm'], true); set_config('bbdkp_default_region', $settings['bbdkp_default_region'], true); set_config('bbdkp_dkp_name', $settings['bbdkp_dkp_name'], true); set_config('bbdkp_eqdkp_start', $settings['bbdkp_eqdkp_start'], true); set_config('bbdkp_user_nlimit', $settings['bbdkp_user_nlimit'], true); set_config('bbdkp_date_format', $settings['bbdkp_date_format'], true); set_config('bbdkp_lang', $settings['bbdkp_lang'], true); set_config('bbdkp_maxchars', $settings['bbdkp_maxchars'], true); //roster set_config('bbdkp_minrosterlvl', $settings['bbdkp_minrosterlvl'], true); set_config('bbdkp_roster_layout', $settings['bbdkp_roster_layout'], true); set_config('bbdkp_show_achiev', $settings['bbdkp_show_achiev'], true); //standings set_config('bbdkp_hide_inactive', $settings['bbdkp_hide_inactive'], true); set_config('bbdkp_inactive_period', $settings['bbdkp_inactive_period'], true); set_config('bbdkp_list_p1', $settings['bbdkp_list_p1'], true); set_config('bbdkp_list_p2', $settings['bbdkp_list_p2'], true); set_config('bbdkp_list_p3', $settings['bbdkp_list_p3'], true); set_config('bbdkp_user_llimit', $settings['bbdkp_user_llimit'], true); //events set_config('bbdkp_user_elimit', $settings['bbdkp_user_elimit'], true); set_config('bbdkp_event_viewall', $settings['bbdkp_event_viewall'], true); //adjustments set_config('bbdkp_user_alimit', $settings['bbdkp_user_alimit'], true); set_config('bbdkp_active_point_adj', $settings['bbdkp_active_point_adj'], true); set_config('bbdkp_inactive_point_adj', $settings['bbdkp_inactive_point_adj'], true); set_config('bbdkp_starting_dkp', $settings['bbdkp_starting_dkp'], true); //items set_config('bbdkp_user_ilimit', $settings['bbdkp_user_ilimit'], true); //raids set_config('bbdkp_user_rlimit', $settings['bbdkp_user_rlimit'], true); // reg id set_config('bbdkp_regid', 1, true); $cache->destroy('config'); // // Logging // $log_action = array('header' => 'L_ACTION_SETTINGS_CHANGED', 'L_SETTINGS' => json_encode($settings)); $this->log_insert(array('log_type' => 'L_ACTION_SETTINGS_CHANGED', 'log_action' => $log_action)); trigger_error($user->lang['ACTION_SETTINGS_CHANGED'] . $link, E_USER_NOTICE); break; case 'register': $regdata = array('domainname' => request_var('domainname', ''), 'phpbbversion' => request_var('phpbbversion', ''), 'bbdkpversion' => request_var('bbdkpversion', '')); $this->post_register_request($regdata); } $s_lang_options = ''; foreach ($this->languagecodes as $lang => $langname) { $selected = $config['bbdkp_lang'] == $lang ? ' selected="selected"' : ''; $s_lang_options .= '<option value="' . $lang . '" ' . $selected . '> ' . $langname . '</option>'; } $template->assign_block_vars('hide_row', array('VALUE' => "YES", 'SELECTED' => $config['bbdkp_hide_inactive'] == 1 ? ' selected="selected"' : '', 'OPTION' => "YES")); $template->assign_block_vars('hide_row', array('VALUE' => "NO", 'SELECTED' => $config['bbdkp_hide_inactive'] == 0 ? ' selected="selected"' : '', 'OPTION' => "NO")); // Default Region foreach ($this->regions as $regionid => $regionvalue) { $template->assign_block_vars('region_row', array('VALUE' => $regionid, 'SELECTED' => $regionid == $config['bbdkp_default_region'] ? ' selected="selected"' : '', 'OPTION' => $regionvalue)); } //roster layout $rosterlayoutlist = array(0 => $user->lang['ARM_STAND'], 1 => $user->lang['ARM_CLASS']); foreach ($rosterlayoutlist as $lid => $lname) { $template->assign_block_vars('rosterlayout_row', array('VALUE' => $lid, 'SELECTED' => $lid == $config['bbdkp_roster_layout'] ? ' selected="selected"' : '', 'OPTION' => $lname)); } $template->assign_vars(array('S_LANG_OPTIONS' => $s_lang_options, 'REALM' => $config['bbdkp_default_realm'], 'EQDKP_START_DD' => date('d', $config['bbdkp_eqdkp_start']), 'EQDKP_START_MM' => date('m', $config['bbdkp_eqdkp_start']), 'EQDKP_START_YY' => date('Y', $config['bbdkp_eqdkp_start']), 'DATE_FORMAT' => $config['bbdkp_date_format'], 'DKP_NAME' => $config['bbdkp_dkp_name'], 'DEFAULT_GAME' => count($this->games) > 0 ? implode(", ", $this->games) : $user->lang['NA'], 'HIDE_INACTIVE_YES_CHECKED' => $config['bbdkp_hide_inactive'] == '1' ? ' checked="checked"' : '', 'HIDE_INACTIVE_NO_CHECKED' => $config['bbdkp_hide_inactive'] == '0' ? ' checked="checked"' : '', 'USER_ELIMIT' => $config['bbdkp_user_elimit'], 'EVENT_VIEWALL_YES_CHECKED' => $config['bbdkp_event_viewall'] == '1' ? ' checked="checked"' : '', 'EVENT_VIEWALL_NO_CHECKED' => $config['bbdkp_event_viewall'] == '0' ? ' checked="checked"' : '', 'USER_NLIMIT' => $config['bbdkp_user_nlimit'], 'INACTIVE_PERIOD' => $config['bbdkp_inactive_period'], 'LIST_P1' => $config['bbdkp_list_p1'], 'LIST_P2' => $config['bbdkp_list_p2'], 'LIST_P3' => $config['bbdkp_list_p3'], 'F_SHOWACHIEV' => $config['bbdkp_show_achiev'], 'USER_ALIMIT' => $config['bbdkp_user_alimit'], 'STARTING_DKP' => $config['bbdkp_starting_dkp'], 'INACTIVE_POINT' => $config['bbdkp_inactive_point_adj'], 'ACTIVE_POINT' => $config['bbdkp_active_point_adj'], 'USER_ILIMIT' => $config['bbdkp_user_ilimit'], 'USER_RLIMIT' => $config['bbdkp_user_rlimit'], 'MAXCHARS' => $config['bbdkp_maxchars'], 'USER_LLIMIT' => $config['bbdkp_user_llimit'], 'MINLEVEL' => $config['bbdkp_minrosterlvl'], 'U_REGISTER' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_config&action=register"), 'U_ADDCONFIG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_config&action=addconfig"), 'DOMAINNAME' => $_SERVER['HTTP_HOST'], 'PHPBBVER' => $config['version'], 'BBDKPVER' => $config['bbdkp_version'], 'REGID' => isset($config['bbdkp_regid']) ? $config['bbdkp_regid'] : '', 'S_BBDKPREGISTERED' => isset($config['bbdkp_regid']) ? $config['bbdkp_regid'] : '')); add_form_key('acp_dkp'); $this->page_title = 'ACP_DKP_CONFIG'; $this->tpl_name = 'dkp/acp_' . $mode; break; /** * PORTAL CONFIG */ /** * PORTAL CONFIG */ case 'dkp_indexpageconfig': $submit = isset($_POST['update']) ? true : false; if ($submit) { if (!check_form_key('acp_dkp_portal')) { trigger_error($user->lang['FV_FORMVALIDATION'], E_USER_WARNING); } if (isset($config['bbdkp_gameworld_version'])) { set_config('bbdkp_portal_bossprogress', request_var('show_bosspblock', 0), true); } set_config('bbdkp_news_forumid', request_var('news_id', 0), true); set_config('bbdkp_n_news', request_var('n_news', 0), true); set_config('bbdkp_n_items', request_var('n_items', 0), true); set_config('bbdkp_recruitment', request_var('bbdkp_recruitment', 0), true); set_config('bbdkp_portal_loot', request_var('show_lootblock', 0), true); set_config('bbdkp_portal_recruitment', request_var('show_recrblock', 0), true); set_config('bbdkp_portal_links', request_var('show_linkblock', 0), true); set_config('bbdkp_portal_menu', request_var('show_menublock', 0), true); set_config('bbdkp_portal_welcomemsg', request_var('show_welcomeblock', 0), true); set_config('bbdkp_portal_recent', request_var('show_recenttopics', 0), true); set_config('bbdkp_portal_rtlen', request_var('n_rclength', 0), true); set_config('bbdkp_portal_rtno', request_var('n_rcno', 0), true); set_config('bbdkp_portal_newmembers', request_var('show_newmembers', 0), true); set_config('bbdkp_portal_maxnewmembers', request_var('num_newmembers', 0), true); set_config('bbdkp_portal_whoisonline', request_var('show_onlineblock', 0), true); set_config('bbdkp_portal_onlineblockposition', request_var('onlineblockposition', 0), true); $cache->destroy('config'); $welcometext = utf8_normalize_nfc(request_var('welcome_message', '', true)); $uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage $allow_bbcode = $allow_urls = $allow_smilies = true; generate_text_for_storage($welcometext, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies); $sql = 'UPDATE ' . WELCOME_MSG_TABLE . " SET\n\t\t\t\t\t\t\twelcome_msg = '" . (string) $db->sql_escape($welcometext) . "' ,\n\t\t\t\t\t\t\twelcome_timestamp = " . (int) time() . " ,\n\t\t\t\t\t\t\tbbcode_bitfield = \t'" . (string) $bitfield . "' ,\n\t\t\t\t\t\t\tbbcode_uid = \t\t'" . (string) $uid . "'\n\t\t\t\t\t\t\tWHERE welcome_id = 1"; $db->sql_query($sql); trigger_error($user->lang['ADMIN_PORTAL_SETTINGS_SAVED'] . $link, E_USER_NOTICE); } // get welcome msg $sql = 'SELECT welcome_msg, bbcode_bitfield, bbcode_uid FROM ' . WELCOME_MSG_TABLE; $db->sql_query($sql); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $welcometext = $row['welcome_msg']; $bitfield = $row['bbcode_bitfield']; $uid = $row['bbcode_uid']; } $textarr = generate_text_for_edit($welcometext, $uid, $bitfield, 7); // number of news and items to show on front page $n_news = $config['bbdkp_n_news']; $n_items = $config['bbdkp_n_items']; add_form_key('acp_dkp_portal'); if (isset($config['bbdkp_gameworld_version'])) { $template->assign_vars(array('S_BP_SHOW' => true, 'SHOW_BOSS_YES_CHECKED' => $config['bbdkp_portal_bossprogress'] == '1' ? ' checked="checked"' : '', 'SHOW_BOSS_NO_CHECKED' => $config['bbdkp_portal_bossprogress'] == '0' ? ' checked="checked"' : '')); } else { $template->assign_var('S_BP_SHOW', false); } $template->assign_vars(array('WELCOME_MESSAGE' => $textarr['text'], 'N_NEWS' => $n_news, 'FORUM_NEWS_OPTIONS' => make_forum_select($config['bbdkp_news_forumid'], false, false, true), 'SHOW_WELCOME_YES_CHECKED' => $config['bbdkp_portal_welcomemsg'] == '1' ? 'checked="checked"' : '', 'SHOW_WELCOME_NO_CHECKED' => $config['bbdkp_portal_welcomemsg'] == '0' ? 'checked="checked"' : '', 'SHOW_ONLINE_YES_CHECKED' => $config['bbdkp_portal_whoisonline'] == '1' ? 'checked="checked"' : '', 'SHOW_ONLINE_NO_CHECKED' => $config['bbdkp_portal_whoisonline'] == '0' ? 'checked="checked"' : '', 'SHOW_ONLINE_BOTTOM_CHECKED' => $config['bbdkp_portal_onlineblockposition'] == '1' ? 'checked="checked"' : '', 'SHOW_ONLINE_SIDE_CHECKED' => $config['bbdkp_portal_onlineblockposition'] == '0' ? 'checked="checked"' : '', 'SHOW_REC_YES_CHECKED' => $config['bbdkp_portal_recruitment'] == '1' ? ' checked="checked"' : '', 'SHOW_REC_NO_CHECKED' => $config['bbdkp_portal_recruitment'] == '0' ? ' checked="checked"' : '', 'SHOW_LOOT_YES_CHECKED' => $config['bbdkp_portal_loot'] == '1' ? ' checked="checked"' : '', 'SHOW_LOOT_NO_CHECKED' => $config['bbdkp_portal_loot'] == '0' ? ' checked="checked"' : '', 'N_ITEMS' => $n_items, 'N_RTNO' => $config['bbdkp_portal_rtno'], 'N_RTLENGTH' => $config['bbdkp_portal_rtlen'], 'SHOW_RT_YES_CHECKED' => $config['bbdkp_portal_recent'] == '1' ? ' checked="checked"' : '', 'SHOW_RT_NO_CHECKED' => $config['bbdkp_portal_recent'] == '0' ? ' checked="checked"' : '', 'SHOW_LINK_YES_CHECKED' => $config['bbdkp_portal_links'] == '1' ? ' checked="checked"' : '', 'SHOW_LINK_NO_CHECKED' => $config['bbdkp_portal_links'] == '0' ? ' checked="checked"' : '', 'SHOW_MENU_YES_CHECKED' => $config['bbdkp_portal_menu'] == '1' ? ' checked="checked"' : '', 'SHOW_MENU_NO_CHECKED' => $config['bbdkp_portal_menu'] == '0' ? ' checked="checked"' : '', 'SHOW_NEWM_YES_CHECKED' => $config['bbdkp_portal_newmembers'] == '1' ? ' checked="checked"' : '', 'SHOW_NEWM_NO_CHECKED' => $config['bbdkp_portal_newmembers'] == '0' ? ' checked="checked"' : '', 'N_NUMNEWM' => $config['bbdkp_portal_maxnewmembers'])); $this->page_title = $user->lang['ACP_INDEXPAGE']; $this->tpl_name = 'dkp/acp_' . $mode; break; /** * DKP LOGS * **/ /** * DKP LOGS * **/ case 'dkp_logs': $this->page_title = 'ACP_DKP_LOGS'; $this->tpl_name = 'dkp/acp_' . $mode; $logs = \bbdkp\admin\log::Instance(); $log_id = isset($_GET[URI_LOG]) ? request_var(URI_LOG, 0) : false; $search = isset($_GET['search']) ? true : false; if ($log_id) { $action = 'view'; } else { $action = 'list'; } switch ($action) { case 'list': $deletemark = isset($_POST['delmarked']) ? true : false; $marked = request_var('mark', array(0)); $search_term = request_var('search', ''); $start = request_var('start', 0); if ($deletemark) { global $db, $user, $phpEx; //if marked array isnt empty if (sizeof($marked) && is_array($marked)) { if (confirm_box(true)) { $marked = request_var('mark', array(0)); $logs = \bbdkp\admin\log::Instance(); $log_action = array('header' => 'L_ACTION_LOG_DELETED', 'L_ADDED_BY' => $user->data['username'], 'L_LOG_ID' => implode(",", $logs->delete_log($marked))); $this->log_insert(array('log_type' => $log_action['header'], 'log_action' => $log_action)); //redirect to listing $meta_info = append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs"); meta_refresh(3, $meta_info); $message = '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs") . '">' . $user->lang['RETURN_LOG'] . '</a><br />' . sprintf($user->lang['ADMIN_LOG_DELETE_SUCCESS'], implode($marked)); trigger_error($message, E_USER_WARNING); } else { // display confirmation confirm_box(false, $user->lang['CONFIRM_DELETE_BBDKPLOG'], build_hidden_fields(array('delmarked' => true, 'mark' => $marked))); } // they hit no $message = '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs") . '">' . $user->lang['RETURN_LOG'] . '</a><br />' . sprintf($user->lang['ADMIN_LOG_DELETE_FAIL'], implode($marked)); trigger_error($message, E_USER_WARNING); } } $sort_order = array(0 => array('log_id desc', 'log_id'), 1 => array('log_date desc', 'log_date'), 2 => array('log_type', 'log_type desc'), 3 => array('username', 'username dsec'), 4 => array('log_ipaddress', 'log_ipaddress desc'), 5 => array('log_result', 'log_result desc')); $current_order = $this->switch_order($sort_order); $verbose = true; $listlogs = $logs->read_log($current_order['sql'], $search, $verbose, $search_term, $start); foreach ($listlogs as $key => $log) { $template->assign_block_vars('logs_row', array('ID' => $log['log_id'], 'DATE' => $log['datestamp'], 'TYPE' => $log['log_type'], 'U_VIEW_LOG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs&" . URI_LOG . '=' . $log['log_id'] . '&search=' . $search_term . '&start=' . $start . '&'), 'VERBOSE' => $verbose, 'USER' => $log['username'], 'ACTION' => $log['log_line'], 'IP' => $log['log_ipaddress'], 'RESULT' => $log['log_result'], 'C_RESULT' => $log['cssresult'], 'ENCODED_TYPE' => urlencode($log['log_type']), 'ENCODED_USER' => urlencode($log['username']), 'ENCODED_IP' => urlencode($log['log_ipaddress']))); } $logcount = $logs->getTotalLogs(); $template->assign_vars(array('S_LIST' => true, 'L_TITLE' => $user->lang['ACP_DKP_LOGS'], 'L_EXPLAIN' => $user->lang['ACP_DKP_LOGS_EXPLAIN'], 'O_DATE' => $current_order['uri'][0], 'O_TYPE' => $current_order['uri'][1], 'O_USER' => $current_order['uri'][2], 'O_IP' => $current_order['uri'][3], 'O_RESULT' => $current_order['uri'][4], 'U_LOGS' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs&") . '&search=' . $search_term . '&start=' . $start . '&', 'U_LOGS_SEARCH' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs"), 'CURRENT_ORDER' => $current_order['uri']['current'], 'START' => $start, 'VIEWLOGS_FOOTCOUNT' => sprintf($user->lang['VIEWLOGS_FOOTCOUNT'], $logcount, USER_LLIMIT), 'VIEWLOGS_PAGINATION' => generate_pagination(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs&") . '&search=' . $search_term . '&o=' . $current_order['uri']['current'], $logcount, USER_LLIMIT, $start))); break; case 'view': $viewlog = $logs->get_logentry($log_id); $log_actionxml = $viewlog['log_action']; $search_term = request_var('search', ''); $start = request_var('start', 0); $log_action = (array) simplexml_load_string($log_actionxml); // loop the action elements and fill template foreach ($log_action as $key => $value) { switch (strtolower($key)) { case 'usercolour': case 'id': break; case 'header': if (in_array($log_action['header'], $logs::$valid_action_types)) { $log_actionstr = $logs->getLogMessage($log_action['header'], false); } break; default: $template->assign_block_vars('logaction_row', array('KEY' => isset($user->lang[$key]) ? $user->lang[$key] . ': ' : $key, 'VALUE' => $value)); } } // fill constant template elements $template->assign_vars(array('S_LIST' => false, 'L_TITLE' => $user->lang['ACP_DKP_LOGS'], 'L_EXPLAIN' => $user->lang['ACP_DKP_LOGS_EXPLAIN'], 'LOG_DATE' => !empty($viewlog['log_date']) ? $user->format_date($viewlog['log_date']) : ' ', 'LOG_USERNAME' => $viewlog['colouruser'], 'LOG_IP_ADDRESS' => $viewlog['log_ipaddress'], 'LOG_SESSION_ID' => $viewlog['log_sid'], 'LOG_RESULT' => $viewlog['log_result'], 'LOG_ACTION' => $log_actionstr)); break; } $template->assign_vars(array('U_BACK' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp&mode=dkp_logs&") . '&search=' . $search_term . '&start=' . $start . '&')); break; } }
/** * @see \phpbb\extension\base::is_enableable() */ function is_enableable() { $config = $this->container->get('config'); $mgr = $this->container->get('ext.manager'); $template = $this->container->get('template'); $meta_mgr = $mgr->create_extension_metadata_manager($this->extension_name, $template); $meta = $meta_mgr->get_metadata(); if (isset($meta['require'])) { $require = $meta['require']; } else { $require = array(); } if (isset($meta['extra']['soft_require'])) { $require = array_merge($require, $meta['extra']['soft_require']); } $require = array_merge($require, $this->extra_dependencies()); /** @var $user \phpbb\user */ $user = $this->container->get('user'); $user->add_lang_ext($this->extension_name, 'install'); foreach ($require as $key => $value) { $info = $this->split_version_info($value); foreach ($info['version'] as $vkey => $version) { switch (strtolower($key)) { case 'php': if (!phpbb_version_compare(PHP_VERSION, $version, $info['operator'][$vkey])) { trigger_error($user->lang('WRONG_PHP_VERSION') . adm_back_link(append_sid('index.' . $this->container->getParameter('core.php_ext'), 'i=acp_extensions&mode=main')), E_USER_WARNING); return false; } break; case 'phpbb': case 'phpbb/phpbb': if (!phpbb_version_compare($config['version'], $version, $info['operator'][$vkey])) { trigger_error($user->lang('WRONG_PHPBB_VERSION') . adm_back_link(append_sid('index.' . $this->container->getParameter('core.php_ext'), 'i=acp_extensions&mode=main')), E_USER_WARNING); return false; } break; case 'gn36/phpbb-oo-posting-api': if (!file_exists(__DIR__ . '/vendor/gn36/phpbb-oo-posting-api/src/Gn36/OoPostingApi/post.php')) { trigger_error($user->lang('MISSING_DEPENDENCIES') . adm_back_link(append_sid('index.' . $this->container->getParameter('core.php_ext'), 'i=acp_extensions&mode=main')), E_USER_WARNING); return false; } break; default: // This should be an extension as a requirement if (!$mgr->is_enabled($key)) { trigger_error($user->lang('MISSING_EXTENSION', $key) . adm_back_link(append_sid('index.' . $this->container->getParameter('core.php_ext'), 'i=acp_extensions&mode=main')), E_USER_WARNING); return false; } $ext_meta_mgr = $mgr->create_extension_metadata_manager($key, $template); $ext_meta = $ext_meta_mgr->get_metadata(); $ext_version = $ext_meta['version']; if (!phpbb_version_compare($ext_version, $version, $info['operator'][$vkey])) { trigger_error($user->lang('WRONG_EXTENSION_VERSION', $key) . adm_back_link(append_sid('index.' . $this->container->getParameter('core.php_ext'), 'i=acp_extensions&mode=main')), E_USER_WARNING); return false; } } } } // Apparently passed all checks return true; }