Пример #1
0
 /**
  * Run Tool
  *
  * Does the actual stuff we want the tool to do after submission
  */
 function run_tool(&$error)
 {
     if (!check_form_key('organize_lang')) {
         $error[] = 'FORM_INVALID';
         return;
     }
     $file = request_var('file', '');
     if (!$file || !file_exists(TITANIA_ROOT . 'language/' . $file) && !file_exists(TITANIA_ROOT . 'language/' . $file . '.' . PHP_EXT)) {
         $error[] = 'NO_FILE';
         return;
     }
     organize_lang($file);
     trigger_back('ORGANIZE_LANG_SUCCESS');
 }
Пример #2
0
 function run_tool()
 {
     $section = request_var('section', 0);
     $start = request_var('start', 0);
     $limit = titania::$config->search_backend == 'solr' ? 1000 : 100;
     $total = 0;
     $sync = new titania_sync();
     switch ($section) {
         case 0:
             titania_search::truncate();
             $display_message = 'Truncating Search';
             break;
         case 1:
             $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE;
             phpbb::$db->sql_query($sql);
             $total = phpbb::$db->sql_fetchfield('cnt');
             phpbb::$db->sql_freeresult();
             $sync->contribs('index', false, $start, $limit);
             $display_message = 'Indexing Contributions';
             break;
         case 2:
             $sql = 'SELECT COUNT(post_id) AS cnt FROM ' . TITANIA_POSTS_TABLE;
             phpbb::$db->sql_query($sql);
             $total = phpbb::$db->sql_fetchfield('cnt');
             phpbb::$db->sql_freeresult();
             $sync->posts('index', $start, $limit);
             $display_message = 'Indexing Posts';
             break;
         case 3:
             $sql = 'SELECT COUNT(faq_id) AS cnt FROM ' . TITANIA_CONTRIB_FAQ_TABLE;
             phpbb::$db->sql_query($sql);
             $total = phpbb::$db->sql_fetchfield('cnt');
             phpbb::$db->sql_freeresult();
             $sync->faqs('index', $start, $limit);
             $display_message = 'Indexing FAQ';
             break;
         case 4:
             trigger_back('Done!');
             break;
     }
     if ($start + $limit >= $total) {
         // Move to the next step
         meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'reindex', 'section' => $section + 1, 'submit' => 1, 'hash' => generate_link_hash('manage'))));
     } else {
         // Move to the next step
         meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'reindex', 'section' => $section, 'start' => $start + $limit, 'submit' => 1, 'hash' => generate_link_hash('manage'))));
     }
     trigger_error($display_message . ' - section ' . $section . ' of 3 - ' . ($start + $limit < $total ? 'part ' . ($start + $limit) . ' of ' . $total : 'Done'));
 }
 /**
  * Run Tool
  *
  * Does the actual stuff we want the tool to do after submission
  */
 function run_tool()
 {
     global $cache, $db;
     $changes_made = false;
     /**
      * Fix Left/Right ID's for the categories table
      */
     $i = 1;
     $changes_made = $this->fixem($i, 'category_id', TITANIA_CATEGORIES_TABLE) || $changes_made ? true : false;
     // Purge the cache so the next time a page with modules is viewed it is not getting an old version from the cache
     $cache->purge();
     if ($changes_made) {
         trigger_back('LEFT_RIGHT_IDS_FIX_SUCCESS');
     } else {
         trigger_back('LEFT_RIGHT_IDS_NO_CHANGE');
     }
 }
    /**
     * Run the tool
     */
    function run_tool()
    {
        // Define some vars that we'll need
        $start = request_var('start', 0);
        $limit = 100;
        // Create topic if it does not exist?
        $create_topic = true;
        titania::_include('functions_posting', 'phpbb_posting');
        titania::add_lang('contributions');
        $types = array();
        foreach (titania_types::$types as $id => $class) {
            if ($class->forum_robot && $class->forum_database) {
                $types[] = $id;
            }
        }
        if (!sizeof($types)) {
            trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE');
        }
        $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . TITANIA_CONTRIBS_TABLE . '
			WHERE ' . phpbb::$db->sql_in_set('contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . '
				AND ' . phpbb::$db->sql_in_set('contrib_type', $types);
        phpbb::$db->sql_query($sql);
        $total = phpbb::$db->sql_fetchfield('cnt');
        phpbb::$db->sql_freeresult();
        // Grab our batch
        $sql_ary = array('SELECT' => 'c.contrib_id, c.contrib_user_id, c.contrib_type, c.contrib_name, c.contrib_name_clean, c.contrib_desc, c.contrib_desc_uid, c.contrib_release_topic_id,
				t.topic_first_post_id,
				u.user_id, u.username, u.username_clean, u.user_colour', 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c', USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_TABLE => 't'), 'ON' => 't.topic_id = c.contrib_release_topic_id')), 'GROUP_BY' => 'c.contrib_id', 'WHERE' => phpbb::$db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . '
				AND u.user_id = c.contrib_user_id
				AND ' . phpbb::$db->sql_in_set('contrib_type', $types), 'ORDER_BY' => 'c.contrib_id DESC');
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        $result = phpbb::$db->sql_query_limit($sql, $limit, $start);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            // Grab the revisions
            $revisions = array();
            $sql = 'SELECT r.revision_id, r.attachment_id, r.revision_version, a.real_filename, a.filesize
				FROM ' . TITANIA_REVISIONS_TABLE . ' r, ' . TITANIA_ATTACHMENTS_TABLE . ' a
				WHERE r.contrib_id = ' . $row['contrib_id'] . '
					AND r.revision_status = ' . TITANIA_REVISION_APPROVED . '
					AND a.attachment_id = r.attachment_id';
            $rev_result = phpbb::$db->sql_query($sql);
            while ($rev_row = phpbb::$db->sql_fetchrow($rev_result)) {
                $revisions[$rev_row['revision_version']] = $rev_row;
            }
            phpbb::$db->sql_freeresult($rev_result);
            // Sort the revisions by their version, put the newest one in $revision
            uksort($revisions, 'reverse_version_compare');
            if (!sizeof($revisions)) {
                continue;
            }
            $revision = array_shift($revisions);
            users_overlord::$users[$row['user_id']] = $row;
            $contrib = new titania_contribution();
            $contrib->__set_array($row);
            $contrib->download = $row;
            // Update the release topic
            $contrib->update_release_topic();
        }
        phpbb::$db->sql_freeresult($result);
        if ($start + $limit >= $total) {
            trigger_back('UPDATE_RELEASE_TOPICS_COMPLETE');
        } else {
            meta_refresh(0, titania_url::build_url('manage/administration', array('t' => 'update_release_topics', 'start' => $start + $limit, 'submit' => 1, 'hash' => generate_link_hash('manage'))));
            trigger_error(phpbb::$user->lang('UPDATE_RELEASE_TOPICS_PROGRESS', $start + $limit, $total));
        }
    }
    function run_tool()
    {
        $new_phpbb_version = request_var('new_phpbb_version', '');
        $limit_phpbb_versions = request_var('limit_phpbb_version', array(''));
        if (!$new_phpbb_version || strlen($new_phpbb_version) < 5 || $new_phpbb_version[1] != '.' || $new_phpbb_version[3] != '.') {
            trigger_back('NO_VERSION_SELECTED');
        }
        // Does the zip for this exist?
        $version = preg_replace('#[^a-zA-Z0-9\\.\\-]+#', '', $new_phpbb_version);
        if (!file_exists(TITANIA_ROOT . 'includes/phpbb_packages/phpBB-' . $version . '.zip')) {
            trigger_back(sprintf(phpbb::$user->lang['FILE_NOT_EXIST'], 'includes/phpbb_packages/phpBB-' . $version . '.zip'));
        }
        $phpbb_version_branch = (int) $new_phpbb_version[0] . (int) $new_phpbb_version[2];
        $phpbb_version_revision = get_real_revision_version(substr($new_phpbb_version, 4));
        // Is it in our version cache?
        $versions = titania::$cache->get_phpbb_versions();
        if (!isset($versions[$phpbb_version_branch . $phpbb_version_revision])) {
            titania::$cache->destroy('_titania_phpbb_versions');
        }
        $testable_types = array();
        foreach (titania_types::$types as $type_id => $type) {
            if ($type->automod_test) {
                $testable_types[] = $type_id;
            }
        }
        if (!sizeof($testable_types)) {
            trigger_back('NO_REVISIONS_UPDATED');
        }
        $revisions = array();
        $sql = 'SELECT DISTINCT(c.contrib_id), r.revision_id FROM ' . TITANIA_REVISIONS_TABLE . ' r, ' . TITANIA_CONTRIBS_TABLE . ' c
			WHERE c.contrib_id = r.contrib_id
				AND ' . phpbb::$db->sql_in_set('c.contrib_type', $testable_types) . '
			GROUP BY c.contrib_id
			ORDER BY r.revision_time DESC';
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $revisions[$row['revision_id']] = $row['contrib_id'];
        }
        phpbb::$db->sql_freeresult($result);
        if (sizeof($limit_phpbb_versions) > 1 || sizeof($limit_phpbb_versions) && $limit_phpbb_versions[0] != 0) {
            $revisions_selected = array();
            // phpBB versions limiter
            foreach ($limit_phpbb_versions as $limit_phpbb_version) {
                $sql = 'SELECT revision_id
					FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . '
					WHERE phpbb_version_branch = ' . (int) substr($limit_phpbb_version, 0, 2) . '
						AND phpbb_version_revision = \'' . phpbb::$db->sql_escape(substr($limit_phpbb_version, 2)) . '\'';
                $result = phpbb::$db->sql_query($sql);
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    if (isset($revisions[$row['revision_id']])) {
                        $revisions_selected[$row['revision_id']] = $revisions[$row['revision_id']];
                    }
                }
                phpbb::$db->sql_freeresult($result);
            }
            // swap
            $revisions = $revisions_selected;
        }
        if (!sizeof($revisions)) {
            trigger_back('NO_REVISIONS_UPDATED');
        }
        // Don't include those which already are marked for this phpBB version
        $sql = 'SELECT revision_id FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . '
			WHERE ' . phpbb::$db->sql_in_set('revision_id', array_map('intval', array_keys($revisions))) . '
				AND phpbb_version_branch = ' . $phpbb_version_branch . '
				AND phpbb_version_revision = \'' . phpbb::$db->sql_escape($phpbb_version_revision) . '\'';
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            unset($revisions[$row['revision_id']]);
        }
        phpbb::$db->sql_freeresult($result);
        // Don't include those which already are in the automod queue
        $sql = 'SELECT revision_id FROM ' . TITANIA_AUTOMOD_QUEUE_TABLE . '
			WHERE phpbb_version_branch = ' . $phpbb_version_branch . '
				AND phpbb_version_revision = \'' . phpbb::$db->sql_escape($phpbb_version_revision) . '\'';
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            unset($revisions[$row['revision_id']]);
        }
        phpbb::$db->sql_freeresult($result);
        if (!sizeof($revisions)) {
            trigger_back('NO_REVISIONS_UPDATED');
        }
        $sql_ary = array();
        foreach ($revisions as $revision_id => $contrib_id) {
            $sql_ary[] = array('revision_id' => (int) $revision_id, 'phpbb_version_branch' => $phpbb_version_branch, 'phpbb_version_revision' => $phpbb_version_revision);
        }
        phpbb::$db->sql_multi_insert(TITANIA_AUTOMOD_QUEUE_TABLE, $sql_ary);
        trigger_back(sprintf(phpbb::$user->lang['REVISIONS_ADDED_TO_QUEUE'], sizeof($revisions)));
    }
Пример #6
0
    function run_tool()
    {
        $new_phpbb_version = request_var('new_phpbb_version', '');
        $limit_phpbb_versions = request_var('limit_phpbb_version', array(''));
        $categories = request_var('category', array(0));
        if (!$new_phpbb_version || strlen($new_phpbb_version) < 5 || $new_phpbb_version[1] != '.' || $new_phpbb_version[3] != '.') {
            trigger_back('NO_VERSION_SELECTED');
        }
        $phpbb_version_branch = (int) $new_phpbb_version[0] . (int) $new_phpbb_version[2];
        $phpbb_version_revision = get_real_revision_version(substr($new_phpbb_version, 4));
        // Is it in our version cache?
        $versions = titania::$cache->get_phpbb_versions();
        if (!isset($versions[$phpbb_version_branch . $phpbb_version_revision])) {
            titania::$cache->destroy('_titania_phpbb_versions');
        }
        // Categories limiter
        $contribs = $revisions = array();
        if (sizeof($categories) > 1 || sizeof($categories) && $categories[0] != 0) {
            $sql = 'SELECT contrib_id FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . '
				WHERE ' . phpbb::$db->sql_in_set('category_id', array_map('intval', $categories));
            $result = phpbb::$db->sql_query($sql);
            while ($row = phpbb::$db->sql_fetchrow($result)) {
                $contribs[] = $row['contrib_id'];
            }
            phpbb::$db->sql_freeresult($result);
            if (!sizeof($contribs)) {
                trigger_back('NO_REVISIONS_UPDATED');
            }
        }
        if (sizeof($limit_phpbb_versions) > 1 || sizeof($limit_phpbb_versions) && $limit_phpbb_versions[0] != 0) {
            // phpBB versions limiter
            foreach ($limit_phpbb_versions as $limit_phpbb_version) {
                $sql = 'SELECT rp.contrib_id, rp.revision_id, r.revision_status FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . ' rp, ' . TITANIA_REVISIONS_TABLE . ' r
					WHERE rp.phpbb_version_branch = ' . (int) substr($limit_phpbb_version, 0, 2) . '
						AND rp.phpbb_version_revision = \'' . phpbb::$db->sql_escape(substr($limit_phpbb_version, 2)) . '\'' . (sizeof($contribs) ? ' AND ' . phpbb::$db->sql_in_set('rp.contrib_id', array_map('intval', $contribs)) : '') . '
						AND r.revision_id = rp.revision_id';
                $result = phpbb::$db->sql_query($sql);
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $revisions[$row['revision_id']] = $row;
                }
                phpbb::$db->sql_freeresult($result);
            }
        } else {
            if (sizeof($categories) > 1 || sizeof($categories) && $categories[0] != 0) {
                // Only category limited
                $sql = 'SELECT contrib_id, revision_id, revision_status FROM ' . TITANIA_REVISIONS_TABLE . '
				WHERE ' . phpbb::$db->sql_in_set('contrib_id', array_map('intval', $contribs));
                $result = phpbb::$db->sql_query($sql);
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $revisions[$row['revision_id']] = $row;
                }
                phpbb::$db->sql_freeresult($result);
            } else {
                // All
                $sql = 'SELECT contrib_id, revision_id, revision_status FROM ' . TITANIA_REVISIONS_TABLE;
                $result = phpbb::$db->sql_query($sql);
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $revisions[$row['revision_id']] = $row;
                }
                phpbb::$db->sql_freeresult($result);
            }
        }
        if (!sizeof($revisions)) {
            trigger_back('NO_REVISIONS_UPDATED');
        }
        // Don't include those which already are marked for this phpBB version
        $sql = 'SELECT revision_id FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . '
			WHERE ' . phpbb::$db->sql_in_set('revision_id', array_map('intval', array_keys($revisions))) . '
				AND phpbb_version_branch = ' . $phpbb_version_branch . '
				AND phpbb_version_revision = \'' . phpbb::$db->sql_escape($phpbb_version_revision) . '\'';
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            unset($revisions[$row['revision_id']]);
        }
        phpbb::$db->sql_freeresult($result);
        if (!sizeof($revisions)) {
            trigger_back('NO_REVISIONS_UPDATED');
        }
        $sql_ary = array();
        foreach ($revisions as $revision_id => $row) {
            $sql_ary[] = array('contrib_id' => (int) $row['contrib_id'], 'revision_id' => (int) $revision_id, 'phpbb_version_branch' => $phpbb_version_branch, 'phpbb_version_revision' => $phpbb_version_revision, 'revision_validated' => $row['revision_status'] == TITANIA_REVISION_APPROVED ? true : false);
        }
        phpbb::$db->sql_multi_insert(TITANIA_REVISIONS_PHPBB_TABLE, $sql_ary);
        trigger_back(sprintf(phpbb::$user->lang['REVISIONS_UPDATED'], sizeof($revisions)));
    }