コード例 #1
0
ファイル: search.php プロジェクト: Gfksx/customisation-db
 /**
  * Initialize the Search
  */
 public static function initialize()
 {
     if (self::$index === false) {
         // Initialize the ezc/Zend Search class
         if (titania::$config->search_backend == 'zend') {
             if (!is_writable(TITANIA_ROOT . self::store_path)) {
                 throw new exception(self::store_path . ' must be writable to use the Zend Lucene Search');
             }
             $handler = new ezcSearchZendLuceneHandler(TITANIA_ROOT . self::store_path);
         } else {
             if (titania::$config->search_backend == 'solr') {
                 $handler = new ezcSearchSolrHandler(titania::$config->search_backend_ip, titania::$config->search_backend_port);
                 // In case Solr would happen to go down..
                 if (!$handler->connection) {
                     // Log this as an error
                     titania::log(TITANIA_ERROR, 'Solr Server not responding');
                     self::$do_not_index = true;
                     return false;
                 }
             } else {
                 throw new exception('We need a proper search backend selected');
             }
         }
         $manager = new ezcSearchEmbeddedManager();
         self::$index = new ezcSearchSession($handler, $manager);
         return true;
     }
 }
コード例 #2
0
ファイル: reindex.php プロジェクト: Gfksx/customisation-db
 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'));
 }
コード例 #3
0
ファイル: sync.php プロジェクト: Gfksx/customisation-db
    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;
        }
    }
コード例 #4
0
ファイル: post.php プロジェクト: Gfksx/customisation-db
 /**
  * Index this post
  */
 public function index()
 {
     titania_search::index($this->post_type, $this->post_id, array('parent_id' => $this->topic->parent_id, 'title' => $this->post_subject, 'text' => $this->post_text, 'text_uid' => $this->post_text_uid, 'text_bitfield' => $this->post_text_bitfield, 'text_options' => $this->post_text_options, 'author' => $this->post_user_id, 'date' => $this->post_time, 'url' => $this->post_url, 'access_level' => min($this->post_access, $this->topic->topic_access), 'approved' => $this->post_approved, 'reported' => $this->post_reported));
 }
コード例 #5
0
ファイル: search.php プロジェクト: kairion/customisation-db
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $contribs[] = $row['contrib_id'];
        }
        phpbb::$db->sql_freeresult($result);
        // Search in the set
        titania_search::in_set($query, 'id', $contribs);
    }
    $query->where($query->eq('type', TITANIA_CONTRIB));
} else {
    // Search type
    if ($search_type) {
        $query->where($query->eq('type', $search_type));
    }
}
// Do the search
$results = titania_search::custom_search($query, $sort);
// Grab the users
users_overlord::load_users($results['user_ids']);
/*switch ($display)
{
	case 'topics' :
		foreach ($results['documents'] as $document)
		{
			$url_base = $document->url;
			$url_params = '';
			if (substr($url_base, -1) != '/')
			{
				$url_params = substr($url_base, (strrpos($url_base, '/') + 1));
				$url_base = substr($url_base, 0, (strrpos($url_base, '/') + 1));
			}
コード例 #6
0
// 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);
コード例 #7
0
ファイル: faq.php プロジェクト: Gfksx/customisation-db
    public function delete()
    {
        titania_search::delete(TITANIA_FAQ, $this->faq_id);
        // Update the FAQ count
        $sql = 'SELECT contrib_faq_count FROM ' . TITANIA_CONTRIBS_TABLE . '
			WHERE contrib_id = ' . $this->contrib_id;
        phpbb::$db->sql_query($sql);
        $contrib_faq_count = phpbb::$db->sql_fetchfield('contrib_faq_count');
        phpbb::$db->sql_freeresult();
        $flags = titania_count::update_flags($this->faq_access);
        $sql = 'UPDATE ' . TITANIA_CONTRIBS_TABLE . '
			SET contrib_faq_count = \'' . phpbb::$db->sql_escape(titania_count::decrement($contrib_faq_count, $flags)) . '\'
			WHERE contrib_id = ' . $this->contrib_id;
        phpbb::$db->sql_query($sql);
        parent::delete();
    }
コード例 #8
0
}
require TITANIA_ROOT . 'common.' . PHP_EXT;
// Hack for local
phpbb::$config['site_upload_dir'] = !isset(phpbb::$config['site_upload_dir']) ? '../phpBB3_titania/files/contribdb' : '../../' . phpbb::$config['site_upload_dir'];
$screenshots_dir = phpbb::$config['site_upload_dir'] . '/demo/';
$ariel_prefix = 'community_site_';
$mod_validation_trash_forum = 28;
$style_validation_trash_forum = 83;
$queue_swap = array(1 => TITANIA_QUEUE_NEW, 2 => TITANIA_QUEUE_NEW, 3 => 19, 4 => 20, -1 => TITANIA_QUEUE_APPROVED, -2 => TITANIA_QUEUE_DENIED);
titania::add_lang('manage');
if (phpbb::$user->data['user_type'] != USER_FOUNDER) {
    titania::needs_auth();
}
// We index later...
titania_search::initialize();
titania_search::$do_not_index = true;
// Hopefully this helps
@set_time_limit(0);
// Cleanup
$sql_ary = array('SELECT' => 'c.contrib_id', 'FROM' => array($ariel_prefix . 'contribs' => 'c'), 'WHERE' => 'c.contrib_status = 0');
$sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
$result = phpbb::$db->sql_query($sql);
while ($row = phpbb::$db->sql_fetchrow($result)) {
    $sql = 'SELECT queue_topic_id FROM ' . TITANIA_QUEUE_TABLE . ' WHERE contrib_id = ' . $row['contrib_id'];
    $result1 = phpbb::$db->sql_query($sql);
    while ($row1 = phpbb::$db->sql_fetchrow($result1)) {
        phpbb::$db->sql_query('DELETE FROM ' . TITANIA_TOPICS_TABLE . ' WHERE topic_id = ' . $row1['queue_topic_id']);
    }
    phpbb::$db->sql_freeresult($result1);
    phpbb::$db->sql_query('DELETE FROM ' . TITANIA_QUEUE_TABLE . ' WHERE contrib_id = ' . $row['contrib_id']);
}
コード例 #9
0
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;
    }
}
コード例 #10
0
 /**
  * Index the contribution
  */
 public function index()
 {
     $data = array('title' => $this->contrib_name, 'text' => $this->contrib_desc, 'text_uid' => $this->contrib_desc_uid, 'text_bitfield' => $this->contrib_desc_bitfield, 'text_options' => $this->contrib_desc_options, 'author' => $this->contrib_user_id, 'date' => $this->contrib_last_update, 'url' => titania_url::unbuild_url($this->get_url()), 'approved' => !titania::$config->require_validation || !titania_types::$types[$this->contrib_type]->require_validation || in_array($this->contrib_status, array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) ? true : false);
     titania_search::index(TITANIA_CONTRIB, $this->contrib_id, $data);
 }