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')); }
public function faqs($mode) { switch ($mode) { case 'index': titania_search::truncate(TITANIA_FAQ); $data = array(); $sql = 'SELECT f.*, c.contrib_name_clean, c.contrib_type FROM ' . TITANIA_CONTRIB_FAQ_TABLE . ' f, ' . TITANIA_CONTRIBS_TABLE . ' c WHERE c.contrib_id = f.contrib_id'; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $data[] = array('object_type' => TITANIA_FAQ, 'object_id' => $row['faq_id'], 'title' => $row['faq_subject'], 'text' => $row['faq_text'], 'text_uid' => $row['faq_text_uid'], 'text_bitfield' => $row['faq_text_bitfield'], 'text_options' => $row['faq_text_options'], 'author' => 0, 'date' => 0, 'url' => titania_types::$types[$row['contrib_type']]->url . '/' . $row['contrib_name_clean'] . '/faq/f_' . $row['faq_id'], 'access_level' => $row['faq_access']); } phpbb::$db->sql_freeresult($result); titania_search::mass_index($data); break; } }
// We index later... titania_search::initialize(); titania_search::$do_not_index = true; $tags_to_cats = array(9 => 12, 10 => 13, 11 => 15, 12 => 14, 30 => 8, 31 => 3, 32 => 4, 33 => 6, 34 => 6, 35 => 5, 36 => 6, 37 => 7, 106 => 9, 107 => 4, 108 => 10, 155 => 12, 165 => 12, 175 => 12, 195 => 16, 235 => 16); $queue_swap = array(1 => TITANIA_QUEUE_NEW, 2 => TITANIA_QUEUE_NEW, 3 => 19, 4 => 20, -1 => TITANIA_QUEUE_APPROVED, -2 => TITANIA_QUEUE_DENIED); switch ($step) { case 0: trigger_error('Are you ready to begin the conversion? All old data in Titania will be lost!<br /><br /><a href="' . append_sid(TITANIA_ROOT . 'ariel_convert.' . PHP_EXT, 'step=1') . '">Continue with the converter</a>'); break; case 1: $truncate = array(TITANIA_AUTOMOD_QUEUE_TABLE, TITANIA_REVISIONS_PHPBB_TABLE, TITANIA_ATTENTION_TABLE, TITANIA_QUEUE_TABLE, TITANIA_ATTACHMENTS_TABLE, TITANIA_AUTHORS_TABLE, TITANIA_CONTRIBS_TABLE, TITANIA_CONTRIB_COAUTHORS_TABLE, TITANIA_CONTRIB_FAQ_TABLE, TITANIA_CONTRIB_IN_CATEGORIES_TABLE, TITANIA_POSTS_TABLE, TITANIA_RATINGS_TABLE, TITANIA_REVISIONS_TABLE, TITANIA_TOPICS_TABLE, TITANIA_TRACK_TABLE, TITANIA_WATCH_TABLE); foreach ($truncate as $table) { phpbb::$db->sql_query('TRUNCATE TABLE ' . $table); } // Truncate search index titania_search::truncate(); // Clean up the files directory foreach (scandir(titania::$config->upload_path) as $item) { if ($item == '.' || $item == '..' || $item == '.svn' || $item == 'contrib_temp') { continue; } if (is_dir(titania::$config->upload_path . $item)) { titania_rmdir_recursive(titania::$config->upload_path . $item . '/'); } } titania_mkdir_recursive(titania::$config->upload_path . 'titania_screenshots'); $display_message = 'Truncating Tables, Cleaning File Storage'; break; case 2: $sql = 'SELECT COUNT(contrib_id) AS cnt FROM ' . $ariel_prefix . 'contribs'; phpbb::$db->sql_query($sql);
function titania_custom($action, $version) { switch ($action) { case 'install': switch ($version) { case '0.1.40': titania_tags(); titania_categories(); break; } break; case 'update': switch ($version) { case '0.1.34': $sync = new titania_sync(); $sync->topics('post_count'); break; case '0.1.37': $sync = new titania_sync(); $sync->queue('revision_queue_id'); break; case '0.1.47': $sync = new titania_sync(); $sync->topics('queue_discussion_category'); break; case '0.1.49': $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . ' SET topic_sticky = 1 WHERE topic_type = ' . TITANIA_QUEUE_DISCUSSION; phpbb::$db->sql_query($sql); break; case '0.1.53': $sql_ary = array(); $sql = 'SELECT contrib_id, revision_id, phpbb_version FROM ' . TITANIA_REVISIONS_TABLE; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $sql_ary[] = array('revision_id' => $row['revision_id'], 'contrib_id' => $row['contrib_id'], 'phpbb_version_branch' => $row['phpbb_version'][0] . $row['phpbb_version'][2], 'phpbb_version_revision' => get_real_revision_version(substr($row['phpbb_version'], 4))); } phpbb::$db->sql_freeresult($result); phpbb::$db->sql_multi_insert(TITANIA_REVISIONS_PHPBB_TABLE, $sql_ary); break; case '0.1.55': $validated = array(); $sql = 'SELECT revision_id FROM ' . TITANIA_REVISIONS_TABLE . ' WHERE revision_validated = 1'; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $validated[] = $row['revision_id']; } phpbb::$db->sql_freeresult($result); if (sizeof($validated)) { $sql = 'UPDATE ' . TITANIA_REVISIONS_PHPBB_TABLE . ' SET revision_validated = 1 WHERE ' . phpbb::$db->sql_in_set('revision_id', $validated); phpbb::$db->sql_query($sql); } break; case '0.3.2': $update = array(); // Reset the status $sql = 'UPDATE ' . TITANIA_REVISIONS_TABLE . ' SET revision_status = 0'; phpbb::$db->sql_query($sql); $sql = 'SELECT r.revision_id, q.queue_status FROM ' . TITANIA_REVISIONS_TABLE . ' r, ' . TITANIA_QUEUE_TABLE . ' q WHERE q.revision_id = r.revision_id'; $result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { switch ($row['queue_status']) { case TITANIA_QUEUE_DENIED: $update[TITANIA_REVISION_DENIED][] = $row['revision_id']; break; case TITANIA_QUEUE_APPROVED: $update[TITANIA_REVISION_APPROVED][] = $row['revision_id']; break; case TITANIA_QUEUE_NEW: $update[TITANIA_REVISION_NEW][] = $row['revision_id']; break; } } phpbb::$db->sql_freeresult($result); foreach ($update as $status => $revision_ids) { $sql = 'UPDATE ' . TITANIA_REVISIONS_TABLE . ' SET revision_status = ' . (int) $status . ' WHERE ' . phpbb::$db->sql_in_set('revision_id', $revision_ids); phpbb::$db->sql_query($sql); } // Any that are left should be repacked $sql = 'UPDATE ' . TITANIA_REVISIONS_TABLE . ' SET revision_status = ' . TITANIA_REVISION_REPACKED . ' WHERE revision_status = 0'; phpbb::$db->sql_query($sql); break; case '0.3.3': titania_sync::contribs('faq_count'); break; } break; case 'uninstall': // Uninstall the types (prevent errors) foreach (titania_types::$types as $class) { $class->uninstall(); } titania_search::truncate(); break; } }