Exemplo n.º 1
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'));
 }
Exemplo n.º 2
0
 /**
  * Return if there is a preview image and assign block vars if necessary
  */
 public function preview_image()
 {
     foreach ($this->attachments as $attachment_id => $attachment) {
         if (!sizeof($attachment) || !$attachment['is_preview']) {
             continue;
         }
         $block_array = array();
         // Some basics...
         $attachment['extension'] = strtolower(trim($attachment['extension']));
         $filename = titania::$config->upload_path . $attachment['attachment_directory'] . '/' . utf8_basename($attachment['attachment_directory']) . '/' . utf8_basename($attachment['physical_filename']);
         $thumbnail_filename = titania::$config->upload_path . $attachment['attachment_directory'] . '/' . utf8_basename($attachment['attachment_directory']) . '/thumb_' . utf8_basename($attachment['physical_filename']);
         $filesize = get_formatted_filesize($attachment['filesize'], false);
         $comment = bbcode_nl2br(censor_text($attachment['attachment_comment']));
         $block_array += array('FILESIZE' => $filesize['value'], 'SIZE_LANG' => $filesize['unit'], 'DOWNLOAD_NAME' => utf8_basename($attachment['real_filename']), 'COMMENT' => $comment);
         $l_downloaded_viewed = $download_link = '';
         $display_cat = strpos($attachment['mimetype'], 'image') === 0 ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
         // @todo Probably should add support for more types...
         if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) {
             if ($attachment['thumbnail']) {
                 $display_cat = ATTACHMENT_CATEGORY_THUMB;
             } else {
                 if (phpbb::$config['img_display_inlined']) {
                     if (phpbb::$config['img_link_width'] || phpbb::$config['img_link_height']) {
                         $dimension = @getimagesize($filename);
                         // If the dimensions could not be determined or the image being 0x0 we display it as a link for safety purposes
                         if ($dimension === false || empty($dimension[0]) || empty($dimension[1])) {
                             $display_cat = ATTACHMENT_CATEGORY_NONE;
                         } else {
                             $display_cat = $dimension[0] <= phpbb::$config['img_link_width'] && $dimension[1] <= phpbb::$config['img_link_height'] ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
                         }
                     }
                 } else {
                     $display_cat = ATTACHMENT_CATEGORY_NONE;
                 }
             }
         }
         // Make some descisions based on user options being set.
         if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !phpbb::$user->optionget('viewimg')) {
             $display_cat = ATTACHMENT_CATEGORY_NONE;
         }
         $download_link = titania_url::build_url('download', array('id' => $attachment['attachment_id']));
         switch ($display_cat) {
             // Images
             case ATTACHMENT_CATEGORY_IMAGE:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $download_link = titania_url::append_url($download_link, array('mode' => 'view'));
                 $block_array += array('S_IMAGE' => true, 'U_INLINE_LINK' => titania_url::append_url($download_link, array('mode' => 'view')));
                 break;
                 // Images, but display Thumbnail
             // Images, but display Thumbnail
             case ATTACHMENT_CATEGORY_THUMB:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $download_link = titania_url::append_url($download_link, array('mode' => 'view'));
                 $block_array += array('S_THUMBNAIL' => true, 'THUMB_IMAGE' => titania_url::append_url($download_link, array('mode' => 'view', 'thumb' => 1)));
                 break;
             default:
                 $l_downloaded_viewed = 'DOWNLOAD_COUNT';
                 $block_array += array('S_FILE' => true);
                 break;
         }
         $l_download_count = !isset($attachment['download_count']) || $attachment['download_count'] == 0 ? phpbb::$user->lang[$l_downloaded_viewed . '_NONE'] : ($attachment['download_count'] == 1 ? sprintf(phpbb::$user->lang[$l_downloaded_viewed], $attachment['download_count']) : sprintf(phpbb::$user->lang[$l_downloaded_viewed . 'S'], $attachment['download_count']));
         $block_array += array('U_DOWNLOAD_LINK' => $download_link, 'L_DOWNLOAD_COUNT' => $l_download_count);
     }
     if (!empty($block_array)) {
         phpbb::$template->assign_block_vars('preview', $block_array);
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 3
0
    function main($id, $mode)
    {
        global $phpbb_root_path;
        define('PHPBB_INCLUDED', true);
        define('USE_PHPBB_TEMPLATE', true);
        define('IN_TITANIA', true);
        if (!defined('PHP_EXT')) {
            define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
        }
        require TITANIA_ROOT . 'common.' . PHP_EXT;
        // Need a few hacks to be used from within phpBB
        titania_url::decode_url(titania::$config->phpbb_script_path);
        titania::$hook->register(array('titania_url', 'build_url'), 'titania_outside_build_url', 'standalone');
        titania::$hook->register(array('titania_url', 'append_url'), 'titania_outside_build_url', 'standalone');
        titania::$hook->register(array('titania', 'page_header'), 'titania_outside_page_header', 'standalone');
        titania::$hook->register(array('titania', 'page_footer'), 'titania_outside_page_footer', 'standalone');
        $this->p_master->assign_tpl_vars(phpbb::append_sid('ucp'));
        // Include some files
        titania::_include('functions_display', 'titania_topic_folder_img');
        // Setup the sort tool
        $sort = new titania_sort();
        $sort->default_limit = phpbb::$config['topics_per_page'];
        $sort->request();
        // Start initial var setup
        $url = $this->u_action;
        add_form_key('ucp_front_subscription');
        // User wants to unsubscribe?
        if (isset($_POST['unsubscribe'])) {
            if (check_form_key('ucp_front_subscription')) {
                $sections = request_var('sections', array(0 => array(0 => 0)));
                $items = request_var('items', array(0 => array(0 => 0)));
                $subscriptions = $sections + $items;
                if (sizeof($subscriptions)) {
                    foreach ($subscriptions as $type => $type_id) {
                        $object_ids = array_keys($type_id);
                        foreach ($object_ids as $object_id) {
                            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
								WHERE watch_user_id = ' . phpbb::$user->data['user_id'] . '
								AND watch_object_type = ' . $type . '
								AND watch_object_id = ' . $object_id;
                            phpbb::$db->sql_query($sql);
                        }
                    }
                } else {
                    $msg = phpbb::$user->lang['NO_SUBSCRIPTIONS_SELECTED'];
                }
            } else {
                $msg = phpbb::$user->lang['FORM_INVALID'];
            }
            if (isset($msg)) {
                meta_refresh(3, $url);
                $message = $msg . '<br /><br />' . sprintf(phpbb::$user->lang['RETURN_UCP'], '<a href="' . $url . '">', '</a>');
                trigger_error($message);
            }
        }
        switch ($mode) {
            case 'subscription_items':
                $array_items = array(TITANIA_CONTRIB, TITANIA_TOPIC);
                // We prepare pagination stuff
                $sql = 'SELECT COUNT(*) AS subscription_count
					FROM ' . TITANIA_WATCH_TABLE . '
					WHERE ' . phpbb::$db->sql_in_set('watch_object_type', $array_items) . '
						AND watch_user_id = ' . phpbb::$user->data['user_id'];
                phpbb::$db->sql_query($sql);
                $subscription_count = phpbb::$db->sql_fetchfield('subscription_count');
                phpbb::$db->sql_freeresult();
                $sort->total = $subscription_count;
                $sort->build_pagination($url);
                $sql_ary = array('SELECT' => '*,
						CASE w.watch_object_type
							WHEN ' . TITANIA_CONTRIB . ' THEN c.contrib_last_update
							WHEN ' . TITANIA_TOPIC . ' THEN t.topic_last_post_time
						END AS time', 'FROM' => array(TITANIA_WATCH_TABLE => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => '(w.watch_object_type = ' . TITANIA_CONTRIB . ')
								AND c.contrib_id = w.watch_object_id'), array('FROM' => array(TITANIA_TOPICS_TABLE => 't'), 'ON' => 'w.watch_object_type = ' . TITANIA_TOPIC . '
								AND t.topic_id = w.watch_object_id')), 'WHERE' => 'w.watch_user_id = ' . phpbb::$user->data['user_id'] . '
						AND ' . phpbb::$db->sql_in_set('watch_object_type', $array_items), 'ORDER_BY' => 'time DESC');
                // Additional tracking for support topics
                titania_tracking::get_track_sql($sql_ary, TITANIA_TOPIC, 't.topic_id');
                titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tsa');
                titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 't.parent_id', 'tsc');
                titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt');
                // Tracking for contributions
                titania_tracking::get_track_sql($sql_ary, TITANIA_CONTRIB, 'c.contrib_id', 'tc');
                $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
                // Get the data
                $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
                $user_ids = $rows = array();
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $rows[] = $row;
                    titania_tracking::store_from_db($row);
                    if ($row['watch_object_type'] == TITANIA_TOPIC) {
                        $user_ids[] = $row['topic_first_post_user_id'];
                        $user_ids[] = $row['topic_last_post_user_id'];
                    } else {
                        if ($row['watch_object_type'] == TITANIA_CONTRIB) {
                            $user_ids[] = $row['contrib_user_id'];
                        }
                    }
                }
                phpbb::$db->sql_freeresult($result);
                // Get user data
                users_overlord::load_users($user_ids);
                foreach ($rows as $row) {
                    $folder_img = $folder_alt = '';
                    if ($row['watch_object_type'] == TITANIA_TOPIC) {
                        if (!$row['topic_id']) {
                            // Topic was deleted
                            $sql = 'DELETE FROM ' . TITANIA_WATCH_TABLE . '
								WHERE watch_object_type = ' . (int) $row['watch_object_type'] . '
									AND watch_object_id = ' . (int) $row['watch_object_id'];
                            phpbb::$db->sql_query($sql);
                            continue;
                        }
                        $topic = new titania_topic();
                        $topic->__set_array($row);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true);
                        $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true);
                        $tpl_block = 'items';
                        $subscription_target = '';
                        if ($row['topic_type'] == TITANIA_QUEUE_DISCUSSION) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_QUEUE_VALIDATION'];
                        }
                        if ($row['topic_type'] == TITANIA_QUEUE) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_QUEUE'];
                        }
                        if ($row['topic_type'] == TITANIA_SUPPORT) {
                            $subscription_target = phpbb::$user->lang['SUBSCRIPTION_SUPPORT_TOPIC'];
                        }
                        // Tracking check
                        $last_read_mark = titania_tracking::get_track(TITANIA_TOPIC, $topic->topic_id, true);
                        $last_read_mark = max($last_read_mark, titania_tracking::find_last_read_mark($topic->additional_unread_fields, $topic->topic_type, $topic->parent_id));
                        $topic->unread = $topic->topic_last_post_time > $last_read_mark ? true : false;
                        // Get the folder image
                        $topic->topic_folder_img($folder_img, $folder_alt);
                        $vars = array('LAST_POST_IMG' => phpbb::$user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['topic_first_post_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['topic_id'], 'SUBSCRIPTION_LAST_AUTHOR_FULL' => users_overlord::get_user($row['topic_last_post_user_id'], '_full'), 'SUBSCRIPTION_LAST_TIME' => phpbb::$user->format_date($row['topic_last_post_time']), 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['topic_time']), 'SUBSCRIPTION_TARGET' => $subscription_target, 'SUBSCRIPTION_TITLE' => censor_text($row['topic_subject']), 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $topic->get_url(), 'U_VIEW_LAST_POST' => titania_url::append_url($topic->get_url(), array('p' => $topic->topic_last_post_id, '#p' => $topic->topic_last_post_id)), 'S_ACCESS_TEAMS' => $row['topic_access'] == TITANIA_ACCESS_TEAMS || $row['topic_type'] == TITANIA_QUEUE ? true : false, 'S_ACCESS_AUTHORS' => $row['topic_access'] == TITANIA_ACCESS_AUTHORS ? true : false, 'S_TOPIC' => true);
                    } else {
                        if ($row['watch_object_type'] == TITANIA_CONTRIB) {
                            $tpl_block = 'items';
                            $contrib = new titania_contribution();
                            $contrib->__set_array($row);
                            titania_topic_folder_img($folder_img, $folder_alt, 0, titania_tracking::is_unread(TITANIA_CONTRIB, $contrib->contrib_id, $contrib->contrib_last_update));
                            $vars = array('SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['contrib_user_id'], '_full'), 'SUBSCRIPTION_CONTRIB_TYPE' => titania_types::$types[$contrib->contrib_type]->lang, 'SUBSCRIPTION_DOWNLOADS' => $row['contrib_downloads'], 'SUBSCRIPTION_ID' => $row['contrib_id'], 'SUBSCRIPTION_TARGET' => phpbb::$user->lang['SUBSCRIPTION_CONTRIB'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['contrib_last_update']), 'SUBSCRIPTION_TITLE' => $row['contrib_name'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'SUBSCRIPTION_VIEWS' => $row['contrib_views'], 'U_VIEW_SUBSCRIPTION' => $contrib->get_url(), 'S_CONTRIB' => true);
                        }
                    }
                    phpbb::$template->assign_block_vars($tpl_block, array_merge($vars, array('FOLDER_IMG' => phpbb::$user->img($folder_img, $folder_alt), 'FOLDER_IMG_SRC' => phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'), 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height'))));
                }
                break;
            case 'subscription_sections':
                $array_items = array(TITANIA_SUPPORT, TITANIA_QUEUE, TITANIA_ATTENTION);
                // We prepare pagination stuff
                $sql = 'SELECT COUNT(*) AS subscription_count
					FROM ' . TITANIA_WATCH_TABLE . '
					WHERE ' . phpbb::$db->sql_in_set('watch_object_type', $array_items) . '
					AND watch_user_id = ' . phpbb::$user->data['user_id'];
                phpbb::$db->sql_query($sql);
                $subscription_count = phpbb::$db->sql_fetchfield('subscription_count');
                phpbb::$db->sql_freeresult();
                $sort->total = $subscription_count;
                $sort->build_pagination($url);
                $sql_ary = array('SELECT' => '*,
						CASE w.watch_object_type
							WHEN ' . TITANIA_SUPPORT . ' THEN c.contrib_last_update
						END AS time', 'FROM' => array(TITANIA_WATCH_TABLE => 'w'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => '(w.watch_object_type = ' . TITANIA_SUPPORT . ')
								AND c.contrib_id = w.watch_object_id')), 'WHERE' => 'w.watch_user_id = ' . phpbb::$user->data['user_id'] . '
						AND ' . phpbb::$db->sql_in_set('watch_object_type', $array_items), 'ORDER_BY' => 'time DESC');
                $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
                // Get the data
                $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
                $user_ids = array();
                while ($row = phpbb::$db->sql_fetchrow($result)) {
                    $rows[] = $row;
                    $user_ids[] = $row['contrib_user_id'];
                }
                phpbb::$db->sql_freeresult($result);
                // Get user data
                users_overlord::load_users($user_ids);
                if (isset($rows)) {
                    foreach ($rows as $row) {
                        if ($row['watch_object_type'] == TITANIA_SUPPORT) {
                            $tpl_block = 'sections';
                            $contrib = new titania_contribution();
                            $contrib->__set_array($row);
                            $vars = array('SUBSCRIPTION_AUTHOR_FULL' => users_overlord::get_user($row['contrib_user_id'], '_full'), 'SUBSCRIPTION_ID' => $row['watch_object_id'], 'SUBSCRIPTION_TARGET' => phpbb::$user->lang['SUBSCRIPTION_SUPPORT'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['contrib_last_update']), 'SUBSCRIPTION_TITLE' => $row['contrib_name'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'U_VIEW_SUBSCRIPTION' => $contrib->get_url('support'));
                        } else {
                            if ($row['watch_object_type'] == TITANIA_ATTENTION) {
                                $tpl_block = 'sections';
                                $vars = array('SUBSCRIPTION_ID' => $row['watch_object_id'], 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => phpbb::$user->lang['SUBSCRIPTION_ATTENTION'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_ATTENTION' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => titania_url::build_url('manage/attention'));
                            } else {
                                if ($row['watch_object_type'] == TITANIA_QUEUE) {
                                    $tpl_block = 'sections';
                                    $queue_id = $row['watch_object_id'];
                                    // Setup the base url we will use
                                    $base_url = titania_url::build_url('manage/queue');
                                    $vars = array('SUBSCRIPTION_ID' => $queue_id, 'SUBSCRIPTION_TARGET' => titania_types::$types[$queue_id]->lang, 'SUBSCRIPTION_TIME' => phpbb::$user->format_date($row['watch_mark_time']), 'SUBSCRIPTION_TITLE' => phpbb::$user->lang['SUBSCRIPTION_QUEUE'], 'SUBSCRIPTION_TYPE' => $row['watch_object_type'], 'S_QUEUE' => true, 'S_ACCESS_TEAMS' => true, 'U_VIEW_SUBSCRIPTION' => titania_url::append_url($base_url, array('queue' => titania_types::$types[$queue_id]->url)));
                                }
                            }
                        }
                        phpbb::$template->assign_block_vars($tpl_block, $vars);
                    }
                }
                break;
        }
        phpbb::$template->assign_vars(array('S_ACTION' => $url, 'TITANIA_THEME_PATH' => titania::$absolute_path . 'styles/' . titania::$config->style . '/theme/'));
        titania::page_header(phpbb::$user->lang['SUBSCRIPTION_TITANIA']);
        titania::page_footer(true, 'manage/' . $mode . '.html');
    }
Exemplo n.º 4
0
 /**
  * Get rating string
  *
  * @return string The rating string ready for output
  */
 public function get_rating_string()
 {
     $can_rate = !$this->cannot_rate && phpbb::$user->data['is_registered'] && phpbb::$auth->acl_get('u_titania_rate') && !$this->rating_id ? true : false;
     $rate_url = titania_url::build_url('rate', array('type' => $this->rating_type, 'id' => $this->rating_object_id));
     // If it has not had any ratings yet, give it 1/2 the max for the rating
     if ($this->rating_count == 0) {
         $this->rating = round(titania::$config->max_rating / 2, 1);
     }
     phpbb::$template->set_filenames(array('rate' => 'common/rate.html'));
     phpbb::$template->assign_vars(array('OBJECT_ID' => $this->rating_object_id, 'OBJECT_RATING' => round($this->rating), 'RATE_URL' => $rate_url, 'S_HAS_RATED' => $this->rating_id ? true : false, 'S_CAN_RATE' => $can_rate, 'UA_GREY_STAR_SRC' => titania::$theme_path . '/images/star_grey.gif', 'UA_GREEN_STAR_SRC' => titania::$theme_path . '/images/star_green.gif', 'UA_RED_STAR_SRC' => titania::$theme_path . '/images/star_red.gif', 'UA_ORANGE_STAR_SRC' => titania::$theme_path . '/images/star_orange.gif', 'UA_REMOVE_STAR_SRC' => titania::$theme_path . '/images/star_remove.gif', 'UA_MAX_RATING' => titania::$config->max_rating));
     // reset the stars block
     phpbb::$template->destroy_block_vars('stars');
     for ($i = 1; $i <= titania::$config->max_rating; $i++) {
         $rating = !$can_rate ? $this->rating : ($this->rating_value ? $this->rating_value : $i);
         phpbb::$template->assign_block_vars('stars', array('ALT' => $rating . '/' . titania::$config->max_rating, 'ID' => $i, 'RATE_URL' => titania_url::append_url($rate_url, array('value' => $i))));
     }
     return phpbb::$template->assign_display('rate', '', true);
 }
Exemplo n.º 5
0
 /**
  * Assign details
  *
  * A little different from those in other classes, this one only returns the info ready for output
  */
 public function assign_details($output_text = true)
 {
     $details = array('POST_ID' => $this->post_id, 'TOPIC_ID' => $this->topic_id, 'POST_TYPE' => $this->post_type, 'POST_ACCESS' => $this->post_access, 'POST_LOCKED' => $this->post_locked, 'POST_ATTACHMENT' => $this->post_attachment, 'POST_USER_ID' => $this->post_user_id, 'POST_IP' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->post_ip : false, 'POST_TIME' => phpbb::$user->format_date($this->post_time), 'POST_EDIT_REASON' => censor_text($this->post_edit_reason), 'POST_SUBJECT' => censor_text($this->post_subject), 'POST_TEXT' => $output_text ? $this->generate_text_for_display() : '', 'EDITED_MESSAGE' => $this->post_edited ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], users_overlord::get_user($this->post_edit_user, '_full'), phpbb::$user->format_date($this->post_edited)) : '', 'DELETED_MESSAGE' => $this->post_deleted != 0 ? sprintf(phpbb::$user->lang['DELETED_MESSAGE'], users_overlord::get_user($this->post_delete_user, '_full'), phpbb::$user->format_date($this->post_deleted), $this->get_url('undelete')) : '', 'U_VIEW' => $this->get_url(), 'U_EDIT' => $this->acl_get('edit') ? $this->get_url('edit') : '', 'U_QUICKEDIT' => $this->acl_get('edit') ? $this->get_url('quick_edit') : '', 'U_DELETE' => $this->acl_get('delete') && (!$this->post_deleted || phpbb::$auth->acl_get('u_titania_post_hard_delete')) ? $this->get_url('delete') : '', 'U_REPORT' => phpbb::$user->data['is_registered'] ? $this->get_url('report') : '', 'U_WARN' => false, 'U_INFO' => phpbb::$auth->acl_gets('u_titania_mod_author_mod', 'u_titania_mod_contrib_mod', 'u_titania_mod_faq_mod', 'u_titania_mod_post_mod') || sizeof(titania_types::find_authed('moderate')) ? titania_url::build_url('manage/attention', array('type' => TITANIA_POST, 'id' => $this->post_id)) : '', 'U_QUOTE' => $this->acl_get('post') ? $this->get_url('quote') : '', 'S_UNREAD_POST' => $this->unread ? true : false, 'S_POST_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->post_approved : true, 'S_POST_REPORTED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->post_reported : false, 'S_POST_DELETED' => $this->post_deleted != 0 ? true : false, 'S_ACCESS_TEAMS' => $this->post_access == TITANIA_ACCESS_TEAMS ? true : false, 'S_ACCESS_AUTHORS' => $this->post_access == TITANIA_ACCESS_AUTHORS ? true : false);
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $details, $this);
     return $details;
 }
Exemplo n.º 6
0
$screenshot = new titania_attachment(TITANIA_SCREENSHOT, titania::$contrib->contrib_id);
$screenshot->load_attachments();
$screenshot->upload(175);
$error = array_merge($error, $screenshot->error);
if ($screenshot->uploaded || isset($_POST['preview']) || $submit) {
    titania::$contrib->post_data($message);
    titania::$contrib->__set_array(array('contrib_demo' => titania::$config->can_modify_style_demo_url || titania_types::$types[TITANIA_TYPE_STYLE]->acl_get('moderate') || titania::$contrib->contrib_type != TITANIA_TYPE_STYLE ? $contrib_demo : titania::$contrib->contrib_demo, 'contrib_local_name' => utf8_normalize_nfc(request_var('contrib_local_name', '', true)), 'contrib_iso_code' => request_var('contrib_iso_code', '')));
}
if (isset($_POST['preview'])) {
    $message->preview();
} else {
    if ($submit) {
        // Handle the deletion routine
        if (isset($_POST['delete']) && phpbb::$auth->acl_get('u_titania_admin')) {
            titania::$contrib->delete();
            redirect(titania_url::build_url(''));
        }
        titania::$contrib->post_data($message);
        // Begin Error checking
        $error = array_merge($error, titania::$contrib->validate($contrib_categories));
        if (($validate_form_key = $message->validate_form_key()) !== false) {
            $error[] = $validate_form_key;
        }
        $missing_active = $missing_nonactive = array();
        get_author_ids_from_list($active_coauthors_list, $missing_active);
        get_author_ids_from_list($nonactive_coauthors_list, $missing_nonactive);
        $author_username = users_overlord::get_user(titania::$contrib->contrib_user_id, 'username', true);
        $author_username_clean = users_overlord::get_user(titania::$contrib->contrib_user_id, 'username_clean', true);
        if (sizeof($missing_active) || sizeof($missing_nonactive)) {
            $error[] = sprintf(phpbb::$user->lang['COULD_NOT_FIND_USERS'], implode(', ', array_merge($missing_active, $missing_nonactive)));
        }
Exemplo n.º 7
0
 /**
  * Get profile url
  *
  * @param string $page The page we are on (Ex: faq/support/details)
  *
  * @return string
  */
 public function get_url($page = '')
 {
     if ($page) {
         return titania_url::build_url(users_overlord::get_user($this->user_id, '_unbuilt_titania_profile') . '/' . $page);
     }
     return users_overlord::get_user($this->user_id, '_titania_profile');
 }
Exemplo n.º 8
0
 /**
  * Download URL
  */
 public function get_url()
 {
     return titania_url::build_url('download', array('id' => $this->attachment_id));
 }
Exemplo n.º 9
0
            $error[] = sprintf(phpbb::$user->lang['COULD_NOT_FIND_USERS'], implode(', ', array_merge($missing_active, $missing_nonactive)));
        }
        if (array_intersect($active_coauthors_list, $nonactive_coauthors_list)) {
            $error[] = sprintf(phpbb::$user->lang['DUPLICATE_AUTHORS'], implode(', ', array_keys(array_intersect($active_coauthors_list, $nonactive_coauthors_list))));
        }
        if (isset($active_coauthors_list[phpbb::$user->data['username']]) || isset($nonactive_coauthors_list[phpbb::$user->data['username']])) {
            $error[] = phpbb::$user->lang['CANNOT_ADD_SELF_COAUTHOR'];
        }
        if ($contrib_demo && !preg_match('#^http[s]?://(.*?\\.)*?[a-z0-9\\-]+\\.[a-z]{2,4}#i', $contrib_demo)) {
            $error[] = phpbb::$user->lang['WRONG_DATA_WEBSITE'];
        }
        if (!sizeof($error)) {
            titania::$contrib->submit();
            // Submit screenshots
            $screenshot->object_id = titania::$contrib->contrib_id;
            $screenshot->submit();
            titania::$contrib->set_coauthors($active_coauthors_list, $nonactive_coauthors_list, true);
            // Create relations
            titania::$contrib->put_contrib_in_categories($contrib_categories);
            redirect(titania::$contrib->get_url('revision'));
        }
    }
}
// Generate some stuff
generate_type_select(titania::$contrib->contrib_type);
generate_category_select($contrib_categories);
titania::$contrib->assign_details();
$message->display();
$template->assign_vars(array('S_POST_ACTION' => titania_url::build_url('author/' . htmlspecialchars_decode(phpbb::$user->data['username_clean']) . '/create'), 'S_CREATE' => true, 'S_STYLE' => TITANIA_TYPE_STYLE, 'S_CAN_EDIT_STYLE_DEMO' => titania::$config->can_modify_style_demo_url || titania_types::$types[TITANIA_TYPE_STYLE]->acl_get('moderate') ? true : false, 'SCREENSHOT_UPLOADER' => $screenshot->parse_uploader('posting/attachments/simple.html'), 'CONTRIB_PERMALINK' => utf8_normalize_nfc(request_var('permalink', '', true)), 'ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => $active_coauthors, 'NONACTIVE_COAUTHORS' => $nonactive_coauthors, 'S_TRANSLATION_TYPE_ID' => defined('TITANIA_TYPE_TRANSLATION') ? TITANIA_TYPE_TRANSLATION : 0));
titania::page_header('CREATE_CONTRIBUTION');
titania::page_footer(true, 'contributions/contribution_manage.html');
Exemplo n.º 10
0
            if (users_overlord::get_user($row['user_id'], 'user_id') != $row['user_id']) {
                continue;
            }
            if ($row['active']) {
                $active_coauthors[] = users_overlord::get_user($row['user_id'], 'username');
            } else {
                $nonactive_coauthors[] = users_overlord::get_user($row['user_id'], 'username');
            }
        }
        $active_coauthors = implode("\n", $active_coauthors);
        $nonactive_coauthors = implode("\n", $nonactive_coauthors);
    }
}
// Generate some stuff
generate_category_select($contrib_categories);
titania::$contrib->assign_details();
$message->display();
foreach ($status_list as $status => $row) {
    phpbb::$template->assign_block_vars('status_select', array('S_SELECTED' => $status == titania::$contrib->contrib_status ? true : false, 'VALUE' => $status, 'NAME' => phpbb::$user->lang[$row]));
}
// ColorizeIt
if (strlen(titania::$config->colorizeit) && titania_types::$types[titania::$contrib->contrib_type]->acl_get('colorizeit')) {
    $clr_testsample = '';
    if (titania::$contrib->has_colorizeit(true) || is_array(titania::$contrib->clr_sample)) {
        $clr_testsample = 'http://' . titania::$config->colorizeit_url . '/testsample.html?sub=' . titania::$config->colorizeit . '&amp;sample=' . urlencode(titania_url::build_url('download', array('id' => titania::$contrib->clr_sample['attachment_id'])));
    }
    phpbb::$template->assign_vars(array('MANAGE_COLORIZEIT' => titania::$config->colorizeit, 'CLR_SCREENSHOTS' => $clr_sample->parse_uploader('posting/attachments/simple.html'), 'CLR_COLORS' => htmlspecialchars(titania::$contrib->contrib_clr_colors), 'U_TESTSAMPLE' => $clr_testsample));
}
phpbb::$template->assign_vars(array('S_POST_ACTION' => titania::$contrib->get_url('manage'), 'S_EDIT_SUBJECT' => titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate') ? true : false, 'S_DELETE_CONTRIBUTION' => phpbb::$auth->acl_get('u_titania_admin') ? true : false, 'S_IS_OWNER' => titania::$contrib->is_author ? true : false, 'S_IS_MODERATOR' => titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate') ? true : false, 'S_CAN_EDIT_STYLE_DEMO' => titania::$config->can_modify_style_demo_url || titania_types::$types[TITANIA_TYPE_STYLE]->acl_get('moderate') || titania::$contrib->contrib_type != TITANIA_TYPE_STYLE ? true : false, 'S_CAN_EDIT_CONTRIB' => phpbb::$auth->acl_get('u_titania_contrib_submit') ? true : false, 'CONTRIB_PERMALINK' => $permalink, 'SCREENSHOT_UPLOADER' => phpbb::$auth->acl_get('u_titania_contrib_submit') ? $screenshot->parse_uploader('posting/attachments/simple.html') : false, 'ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => $active_coauthors, 'NONACTIVE_COAUTHORS' => $nonactive_coauthors, 'S_TRANSLATION_TYPE_ID' => defined('TITANIA_TYPE_TRANSLATION') ? TITANIA_TYPE_TRANSLATION : 0));
titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['MANAGE_CONTRIBUTION']);
titania::page_footer(true, 'contributions/contribution_manage.html');
Exemplo n.º 11
0
function trigger_back($message)
{
    $message = isset(phpbb::$user->lang[$message]) ? phpbb::$user->lang[$message] : $message;
    $message .= '<br /><br /><a href="' . titania_url::build_url('manage/categories') . '">' . phpbb::$user->lang['BACK'] . '</a>';
    trigger_error($message);
}
Exemplo n.º 12
0
 /**
  * General attachment parsing
  * From phpBB (includes/functions_content.php)
  *
  * @param string &$message The message
  * @param string $tpl The template file to use
  * @param bool $preview true if previewing from the posting page
  * @param string|bool $template_block If not false we will output the parsed attachments to this template block
  *
  * @return array the parsed attachments
  */
 public function parse_attachments(&$message, $tpl = 'common/attachment.html', $preview = false, $template_block = false)
 {
     if (!sizeof($this->attachments)) {
         return array();
     }
     phpbb::$user->add_lang('viewtopic');
     $compiled_attachments = array();
     if ($tpl !== false && !isset(phpbb::$template->filename['titania_attachment_tpl'])) {
         phpbb::$template->set_filenames(array('titania_attachment_tpl' => $tpl));
     }
     // Sort correctly
     if (phpbb::$config['display_order']) {
         // Ascending sort
         krsort($this->attachments);
     } else {
         // Descending sort
         ksort($this->attachments);
     }
     foreach ($this->attachments as $attachment_id => $attachment) {
         if (!sizeof($attachment)) {
             continue;
         }
         // We need to reset/empty the _file block var, because this function might be called more than once
         phpbb::$template->destroy_block_vars('_file');
         $block_array = array();
         // Some basics...
         $attachment['extension'] = strtolower(trim($attachment['extension']));
         $filename = titania::$config->upload_path . $attachment['attachment_directory'] . '/' . utf8_basename($attachment['attachment_directory']) . '/' . utf8_basename($attachment['physical_filename']);
         $thumbnail_filename = titania::$config->upload_path . $attachment['attachment_directory'] . '/' . utf8_basename($attachment['attachment_directory']) . '/thumb_' . utf8_basename($attachment['physical_filename']);
         $filesize = get_formatted_filesize($attachment['filesize'], false);
         if ($preview) {
             $comment = bbcode_nl2br(censor_text(utf8_normalize_nfc(request_var('attachment_comment_' . $attachment_id, (string) $attachment['attachment_comment'], true))));
         } else {
             $comment = bbcode_nl2br(censor_text($attachment['attachment_comment']));
         }
         $block_array += array('FILESIZE' => $filesize['value'], 'SIZE_LANG' => $filesize['unit'], 'DOWNLOAD_NAME' => utf8_basename($attachment['real_filename']), 'COMMENT' => $comment);
         $l_downloaded_viewed = $download_link = '';
         $display_cat = strpos($attachment['mimetype'], 'image') === 0 ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
         // @todo Probably should add support for more types...
         if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) {
             if ($attachment['thumbnail']) {
                 $display_cat = ATTACHMENT_CATEGORY_THUMB;
             } else {
                 if (phpbb::$config['img_display_inlined']) {
                     if (phpbb::$config['img_link_width'] || phpbb::$config['img_link_height']) {
                         $dimension = @getimagesize($filename);
                         // If the dimensions could not be determined or the image being 0x0 we display it as a link for safety purposes
                         if ($dimension === false || empty($dimension[0]) || empty($dimension[1])) {
                             $display_cat = ATTACHMENT_CATEGORY_NONE;
                         } else {
                             $display_cat = $dimension[0] <= phpbb::$config['img_link_width'] && $dimension[1] <= phpbb::$config['img_link_height'] ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE;
                         }
                     }
                 } else {
                     $display_cat = ATTACHMENT_CATEGORY_NONE;
                 }
             }
         }
         // Make some descisions based on user options being set.
         if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !phpbb::$user->optionget('viewimg')) {
             $display_cat = ATTACHMENT_CATEGORY_NONE;
         }
         if ($display_cat == ATTACHMENT_CATEGORY_FLASH && !phpbb::$user->optionget('viewflash')) {
             $display_cat = ATTACHMENT_CATEGORY_NONE;
         }
         $download_link = titania_url::build_url('download', array('id' => $attachment['attachment_id']));
         switch ($display_cat) {
             // Images
             case ATTACHMENT_CATEGORY_IMAGE:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $download_link = titania_url::append_url($download_link, array('mode' => 'view'));
                 $block_array += array('S_IMAGE' => true, 'U_INLINE_LINK' => titania_url::append_url($download_link, array('mode' => 'view')));
                 break;
                 // Images, but display Thumbnail
             // Images, but display Thumbnail
             case ATTACHMENT_CATEGORY_THUMB:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $download_link = titania_url::append_url($download_link, array('mode' => 'view'));
                 $block_array += array('S_THUMBNAIL' => true, 'THUMB_IMAGE' => titania_url::append_url($download_link, array('mode' => 'view', 'thumb' => 1)));
                 break;
                 // Windows Media Streams
             // Windows Media Streams
             case ATTACHMENT_CATEGORY_WM:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 // Giving the filename directly because within the wm object all variables are in local context making it impossible
                 // to validate against a valid session (all params can differ)
                 // $download_link = $filename;
                 $block_array += array('ATTACH_ID' => $attachment['attachment_id'], 'S_WM_FILE' => true);
                 break;
                 // Real Media Streams
             // Real Media Streams
             case ATTACHMENT_CATEGORY_RM:
             case ATTACHMENT_CATEGORY_QUICKTIME:
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $block_array += array('S_RM_FILE' => $display_cat == ATTACHMENT_CATEGORY_RM ? true : false, 'S_QUICKTIME_FILE' => $display_cat == ATTACHMENT_CATEGORY_QUICKTIME ? true : false, 'ATTACH_ID' => $attachment['attachment_id']);
                 break;
                 // Macromedia Flash Files
             // Macromedia Flash Files
             case ATTACHMENT_CATEGORY_FLASH:
                 list($width, $height) = @getimagesize($filename);
                 $l_downloaded_viewed = 'VIEWED_COUNT';
                 $block_array += array('S_FLASH_FILE' => true, 'WIDTH' => $width, 'HEIGHT' => $height, 'U_VIEW_LINK' => titania_url::append_url($download_link, array('view' => 1)));
                 break;
             default:
                 $l_downloaded_viewed = 'DOWNLOAD_COUNT';
                 $block_array += array('S_FILE' => true);
                 break;
         }
         $l_download_count = !isset($attachment['download_count']) || $attachment['download_count'] == 0 ? phpbb::$user->lang[$l_downloaded_viewed . '_NONE'] : ($attachment['download_count'] == 1 ? sprintf(phpbb::$user->lang[$l_downloaded_viewed], $attachment['download_count']) : sprintf(phpbb::$user->lang[$l_downloaded_viewed . 'S'], $attachment['download_count']));
         $block_array += array('U_DOWNLOAD_LINK' => $download_link, 'L_DOWNLOAD_COUNT' => $l_download_count);
         // If a template block is specified, output to that also
         if ($template_block) {
             phpbb::$template->assign_block_vars($template_block, $block_array);
         }
         if ($tpl !== false) {
             phpbb::$template->assign_block_vars('_file', $block_array);
             $compiled_attachments[] = phpbb::$template->assign_display('titania_attachment_tpl');
         }
     }
     $tpl_size = sizeof($compiled_attachments);
     $unset_tpl = array();
     // For inline attachments
     if ($message) {
         preg_match_all('#<!\\-\\- ia([0-9]+) \\-\\->(.*?)<!\\-\\- ia\\1 \\-\\->#', $message, $matches, PREG_PATTERN_ORDER);
         $replace = array();
         foreach ($matches[0] as $num => $capture) {
             // Flip index if we are displaying the reverse way
             $index = phpbb::$config['display_order'] ? $tpl_size - ($matches[1][$num] + 1) : $matches[1][$num];
             $replace['from'][] = $matches[0][$num];
             $replace['to'][] = isset($compiled_attachments[$index]) ? $compiled_attachments[$index] : sprintf(phpbb::$user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][array_search($index, $matches[1])]);
             $unset_tpl[] = $index;
         }
         if (isset($replace['from'])) {
             $message = str_replace($replace['from'], $replace['to'], $message);
         }
         $unset_tpl = array_unique($unset_tpl);
         // Needed to let not display the inlined attachments at the end of the post again
         foreach ($unset_tpl as $index) {
             unset($compiled_attachments[$index]);
         }
     }
     return $compiled_attachments;
 }
Exemplo n.º 13
0
            // Repack if that's what we want
            if ($repack) {
                $revision->repack($old_revision);
            }
            // Update the revision to be submitted, which unhides the queue topic and updates the contrib_last_update time
            $revision->revision_submitted = true;
            $revision->submit();
            // Update the queue (make visible)
            $revision->update_queue();
            if ($repack && titania::$config->use_queue && titania_types::$types[titania::$contrib->contrib_type]->use_queue) {
                redirect(titania_url::build_url('manage/queue', array('q' => $revision->revision_queue_id)));
            }
            // Subscriptions
            $queue = $revision->get_queue();
            if ($queue) {
                $email_vars = array('NAME' => phpbb::$user->lang['VALIDATION'] . ' - ' . titania::$contrib->contrib_name . ' - ' . $revision->revision_version, 'U_VIEW' => titania_url::build_url('manage/queue', array('q' => $queue->queue_id)));
                titania_subscriptions::send_notifications(TITANIA_QUEUE, titania::$contrib->contrib_type, 'subscribe_notify_forum.txt', $email_vars, phpbb::$user->data['user_id']);
            }
            redirect(titania::$contrib->get_url());
            break;
    }
} while ($try_again);
phpbb::$template->assign_vars(array('ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : '', 'NEXT_STEP' => $next_step, 'REVISION_ID' => $revision_id, 'AGREEMENT_NOTICE' => titania_types::$types[titania::$contrib->contrib_type]->upload_agreement ? isset(phpbb::$user->lang[titania_types::$types[titania::$contrib->contrib_type]->upload_agreement]) ? nl2br(phpbb::$user->lang[titania_types::$types[titania::$contrib->contrib_type]->upload_agreement]) : nl2br(titania_types::$types[titania::$contrib->contrib_type]->upload_agreement) : false, 'QUEUE_ALLOW_REPACK' => true, 'S_POST_ACTION' => $repack ? titania_url::append_url(titania::$contrib->get_url('revision'), array('repack' => $repack)) : titania::$contrib->get_url('revision')));
// Output the available license options
foreach (titania_types::$types[titania::$contrib->contrib_type]->license_options as $option) {
    phpbb::$template->assign_block_vars('license_options', array('NAME' => $option, 'VALUE' => $option));
}
// Display the list of phpBB versions available
/*$allowed_branches = get_allowed_phpbb_branches();
foreach ($phpbb_versions as $version => $name)
{
Exemplo n.º 14
0
 /**
  * Build view URL for a category in the Category Management panel
  */
 public function get_manage_url()
 {
     return titania_url::build_url('manage/categories', array('c' => $this->category_id));
 }
Exemplo n.º 15
0
 /**
  * Generate login box or verify password
  */
 function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = false, $s_display = true)
 {
     self::_include('captcha/captcha_factory', 'phpbb_captcha_factory');
     self::$user->add_lang('ucp');
     $err = '';
     // Make sure user->setup() has been called
     if (empty(self::$user->lang)) {
         self::$user->setup();
     }
     // Print out error if user tries to authenticate as an administrator without having the privileges...
     if ($admin && !self::$auth->acl_get('a_')) {
         // Not authd
         // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions
         if (self::$user->data['is_registered']) {
             add_log('admin', 'LOG_ADMIN_AUTH_FAIL');
         }
         trigger_error('NO_AUTH_ADMIN');
     }
     if (isset($_POST['login'])) {
         // Get credential
         if ($admin) {
             $credential = request_var('credential', '');
             if (strspn($credential, 'abcdef0123456789') !== strlen($credential) || strlen($credential) != 32) {
                 if (self::$user->data['is_registered']) {
                     add_log('admin', 'LOG_ADMIN_AUTH_FAIL');
                 }
                 trigger_error('NO_AUTH_ADMIN');
             }
             $password = request_var('password_' . $credential, '', true);
         } else {
             $password = request_var('password', '', true);
         }
         $username = request_var('username', '', true);
         $autologin = !empty($_POST['autologin']) ? true : false;
         $viewonline = !empty($_POST['viewonline']) ? 0 : 1;
         $admin = $admin ? 1 : 0;
         $viewonline = $admin ? self::$user->data['session_viewonline'] : $viewonline;
         // Check if the supplied username is equal to the one stored within the database if re-authenticating
         if ($admin && utf8_clean_string(self::$username) != utf8_clean_string(self::$user->data['username'])) {
             // We log the attempt to use a different username...
             add_log('admin', 'LOG_ADMIN_AUTH_FAIL');
             trigger_error('NO_AUTH_ADMIN_USER_DIFFER');
         }
         // If authentication is successful we redirect user to previous page
         $result = self::$auth->login($username, $password, $autologin, $viewonline, $admin);
         // If admin authentication and login, we will log if it was a success or not...
         // We also break the operation on the first non-success login - it could be argued that the user already knows
         if ($admin) {
             if ($result['status'] == LOGIN_SUCCESS) {
                 add_log('admin', 'LOG_ADMIN_AUTH_SUCCESS');
             } else {
                 // Only log the failed attempt if a real user tried to.
                 // anonymous/inactive users are never able to go to the ACP even if they have the relevant permissions
                 if (self::$user->data['is_registered']) {
                     add_log('admin', 'LOG_ADMIN_AUTH_FAIL');
                 }
             }
         }
         // The result parameter is always an array, holding the relevant information...
         if ($result['status'] == LOGIN_SUCCESS) {
             $redirect = request_var('redirect', '');
             if ($redirect) {
                 $redirect = titania_url::unbuild_url($redirect);
                 $base = $append = false;
                 titania_url::split_base_params($base, $append, $redirect);
                 redirect(titania_url::build_url($base, $append));
             } else {
                 redirect(titania_url::build_url(titania_url::$current_page, titania_url::$params));
             }
         }
         // Something failed, determine what...
         if ($result['status'] == LOGIN_BREAK) {
             trigger_error($result['error_msg']);
         }
         // Special cases... determine
         switch ($result['status']) {
             case LOGIN_ERROR_ATTEMPTS:
                 $captcha = phpbb_captcha_factory::get_instance(self::$config['captcha_plugin']);
                 $captcha->init(CONFIRM_LOGIN);
                 // $captcha->reset();
                 // Parse the captcha template
                 self::reset_template();
                 self::$template->set_filenames(array('captcha' => $captcha->get_template()));
                 // Correct confirm image link
                 self::$template->assign_var('CONFIRM_IMAGE_LINK', self::append_sid('ucp', 'mode=confirm&amp;confirm_id=' . $captcha->confirm_id . '&amp;type=' . $captcha->type));
                 self::$template->assign_display('captcha', 'CAPTCHA', false);
                 titania::set_custom_template();
                 $err = self::$user->lang[$result['error_msg']];
                 break;
             case LOGIN_ERROR_PASSWORD_CONVERT:
                 $err = sprintf(self::$user->lang[$result['error_msg']], self::$config['email_enable'] ? '<a href="' . self::append_sid('ucp', 'mode=sendpassword') . '">' : '', self::$config['email_enable'] ? '</a>' : '', self::$config['board_contact'] ? '<a href="mailto:' . htmlspecialchars(self::$config['board_contact']) . '">' : '', self::$config['board_contact'] ? '</a>' : '');
                 break;
                 // Username, password, etc...
             // Username, password, etc...
             default:
                 $err = self::$user->lang[$result['error_msg']];
                 // Assign admin contact to some error messages
                 if ($result['error_msg'] == 'LOGIN_ERROR_USERNAME' || $result['error_msg'] == 'LOGIN_ERROR_PASSWORD') {
                     $err = !self::$config['board_contact'] ? sprintf(self::$user->lang[$result['error_msg']], '', '') : sprintf(self::$user->lang[$result['error_msg']], '<a href="mailto:' . htmlspecialchars(self::$config['board_contact']) . '">', '</a>');
                 }
                 break;
         }
     }
     // Assign credential for username/password pair
     $credential = $admin ? md5(unique_id()) : false;
     $s_hidden_fields = array('sid' => self::$user->session_id);
     if ($redirect) {
         $s_hidden_fields['redirect'] = $redirect;
     }
     if ($admin) {
         $s_hidden_fields['credential'] = $credential;
     }
     $s_hidden_fields = build_hidden_fields($s_hidden_fields);
     titania::page_header('LOGIN');
     self::$template->assign_vars(array('LOGIN_ERROR' => $err, 'LOGIN_EXPLAIN' => $l_explain, 'U_SEND_PASSWORD' => self::$config['email_enable'] ? self::append_sid('ucp', 'mode=sendpassword') : '', 'U_RESEND_ACTIVATION' => self::$config['require_activation'] == USER_ACTIVATION_SELF && self::$config['email_enable'] ? self::append_sid('ucp', 'mode=resend_act') : '', 'U_TERMS_USE' => self::append_sid('ucp', 'mode=terms'), 'U_PRIVACY' => self::append_sid('ucp', 'mode=privacy'), 'S_DISPLAY_FULL_LOGIN' => $s_display ? true : false, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ADMIN_AUTH' => $admin, 'USERNAME' => $admin ? self::$user->data['username'] : '', 'USERNAME_CREDENTIAL' => 'username', 'PASSWORD_CREDENTIAL' => $admin ? 'password_' . $credential : 'password'));
     titania::page_footer(true, 'login_body.html');
 }
Exemplo n.º 16
0
 private function common_delete($post_id, $undelete = false)
 {
     titania::add_lang('posting');
     phpbb::$user->add_lang('posting');
     // Load the stuff we need
     $post_object = $this->load_post($post_id);
     // Check permissions
     if (!$undelete && !$post_object->acl_get('delete') || $undelete && !$post_object->acl_get('undelete')) {
         titania::needs_auth();
     }
     if (titania::confirm_box(true)) {
         if (!$undelete) {
             $redirect_post_id = false;
             // Delete the post
             if (isset($_POST['hard_delete']) || $post_object->post_deleted) {
                 if (!phpbb::$auth->acl_get('u_titania_post_hard_delete')) {
                     titania::needs_auth();
                 }
                 $post_object->hard_delete();
                 // Try to redirect to the next or previous post
                 $redirect_post_id = posts_overlord::next_prev_post_id($post_object->topic_id, $post_object->post_id);
                 if ($redirect_post_id) {
                     redirect(titania_url::append_url($post_object->topic->get_url(), array('p' => $redirect_post_id, '#p' => $redirect_post_id)));
                 }
                 redirect(titania_url::build_url($post_object->topic->topic_url));
             } else {
                 $post_object->soft_delete();
                 if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) {
                     // They can see the post, redirect back to it
                     redirect($post_object->get_url());
                 } else {
                     // They cannot see the post, try to redirect to the next or previous post
                     $redirect_post_id = posts_overlord::next_prev_post_id($post_object->topic_id, $post_object->post_id);
                     if ($redirect_post_id) {
                         redirect(titania_url::append_url($post_object->topic->get_url(), array('p' => $redirect_post_id, '#p' => $redirect_post_id)));
                     }
                 }
             }
             redirect($post_object->topic->get_url());
         } else {
             $post_object->undelete();
             redirect($post_object->get_url());
         }
     } else {
         phpbb::$template->assign_var('S_HARD_DELETE', !$undelete && !$post_object->post_deleted && phpbb::$auth->acl_get('u_titania_post_hard_delete') ? true : false);
         titania::confirm_box(false, !$undelete ? 'DELETE_POST' : 'UNDELETE_POST', '', array(), 'posting/delete_confirm.html');
     }
     redirect($post_object->get_url());
 }
Exemplo n.º 17
0
			{
				$url_params = substr($url_base, (strrpos($url_base, '/') + 1));
				$url_base = substr($url_base, 0, (strrpos($url_base, '/') + 1));
			}

			phpbb::$template->assign_block_vars('searchresults', array(
				'TOPIC_TITLE'		=> censor_text($document->title),

				'TOPIC_AUTHOR_FULL'	=> users_overlord::get_user($document->author, '_full'),
				'FIRST_POST_TIME'	=> phpbb::$user->format_date($document->date),

				'U_VIEW_TOPIC'		=> titania_url::build_url($url_base, $url_params),

				'S_TOPIC_REPORTED'		=> ($document->reported) ? true : false,
				//'S_TOPIC_UNAPPROVED'	=> (!$document->approved) ? true : false,
			));
		}
	break;

	default : */
foreach ($results['documents'] as $document) {
    $url_base = $url_params = '';
    titania_url::split_base_params($url_base, $url_params, $document->url);
    phpbb::$template->assign_block_vars('searchresults', array('POST_SUBJECT' => censor_text($document->title), 'MESSAGE' => titania_generate_text_for_display($document->text, $document->text_uid, $document->text_bitfield, $document->text_options), 'POST_AUTHOR_FULL' => $document->author ? users_overlord::get_user($document->author, '_full') : false, 'POST_DATE' => $document->date ? phpbb::$user->format_date($document->date) : false, 'U_VIEW_POST' => titania_url::build_url($url_base, $url_params), 'S_POST_REPORTED' => $document->reported ? true : false));
}
/*	break;
}*/
$sort->build_pagination(titania_url::$current_page, titania_url::$params);
titania::page_header('SEARCH');
phpbb::$template->assign_vars(array('SEARCH_WORDS' => $keywords, 'SEARCH_MATCHES' => $sort->total == 1 ? sprintf(phpbb::$user->lang['FOUND_SEARCH_MATCH'], $sort->total) : sprintf(phpbb::$user->lang['FOUND_SEARCH_MATCHES'], $sort->total), 'U_SEARCH_WORDS' => titania_url::build_url(titania_url::$current_page, titania_url::$params), 'U_SEARCH' => titania_url::build_url($mode == 'find-contribution' ? 'find-contribution' : 'search'), 'S_IN_SEARCH' => true, 'S_SEARCH_ACTION' => titania_url::$current_page_url));
titania::page_footer(true, 'search_results.html');
Exemplo n.º 18
0
    /*$close = (isset($_POST['close'])) ? true : false;
    	$id_list = request_var('id_list', array(0));
    
    	if ($close && sizeof($id_list))
    	{
    		$attention_object = new titania_attention;
    		foreach ($id_list as $attention_id)
    		{
    			$attention_object->attention_id = $attention_id;
    			$attention_object->load();
    		}
    	}*/
    switch ($type) {
        case 'reported':
            $type = TITANIA_ATTENTION_REPORTED;
            break;
        case 'unapproved':
            $type = TITANIA_ATTENTION_UNAPPROVED;
            break;
        default:
            $type = false;
            break;
    }
    $options = array('attention_type' => $type, 'display_closed' => $closed, 'only_closed' => !$open && $closed ? true : false);
    attention_overlord::display_attention_list($options);
    phpbb::$template->assign_vars(array('S_ACTION' => titania_url::build_url('manage/attention'), 'S_OPEN_CHECKED' => $open, 'S_CLOSED_CHECKED' => $closed));
    // Subscriptions
    titania_subscriptions::handle_subscriptions(TITANIA_ATTENTION, 0, titania_url::build_url('manage/attention'));
    titania::page_header('ATTENTION');
    titania::page_footer(true, 'manage/attention.html');
}
Exemplo n.º 19
0
 */
/**
* @ignore
*/
if (!defined('IN_TITANIA')) {
    exit;
}
// Mark all topics read
if (request_var('mark', '') == 'topics') {
    titania_tracking::track(TITANIA_QUEUE_DISCUSSION, 0);
}
$queue_type = request_var('queue', '');
// Force the queue_type if we have a queue_id
$queue_type = titania_types::type_from_url($queue_type);
// Setup the base url we will use
$base_url = titania_url::build_url('manage/queue_discussion');
if ($queue_type === false) {
    // We need to select the queue if they only have one that they can access, else display the list
    $authed = titania_types::find_authed('queue_discussion');
    if (empty($authed)) {
        titania::needs_auth();
    } else {
        if (sizeof($authed) == 1) {
            $queue_type = $authed[0];
        } else {
            foreach ($authed as $type_id) {
                $sql = 'SELECT COUNT(topic_id) AS cnt FROM ' . TITANIA_TOPICS_TABLE . '
				WHERE topic_type = ' . TITANIA_QUEUE_DISCUSSION . '
					AND topic_category = ' . (int) $type_id;
                phpbb::$db->sql_query($sql);
                $cnt = phpbb::$db->sql_fetchfield('cnt');
Exemplo n.º 20
0
 /**
  * Display "forum" like section for support/tracker/etc
  *
  * @param string $type The type (support, review, queue, tracker, author_support, author_tracker) author_ for displaying posts from the areas the given author is involved in (either an author/co-author)
  * @param object|boolean $object The object (for contrib related (support, review, queue, tracker) and author_ modes)
  * @param object|boolean $sort The sort object (includes/tools/sort.php)
  * @param array $options Some special options
  * @param string $contrib_type The type of the support topic list
  */
 public static function display_forums($type, $object = false, $sort = false, $options = array())
 {
     if ($sort === false) {
         // Setup the sort tool
         $sort = self::build_sort();
     }
     $sort->request();
     $topic_ids = array();
     $switch_on_sticky = true;
     // Display the extra block after stickies end?  Not used when not sorting with stickies first
     $sql_ary = array('SELECT' => 't.*, u.username as topic_first_post_username, u.user_colour as topic_first_post_user_colour, ul.username as topic_last_post_username, ul.user_colour as topic_last_post_user_colour', 'FROM' => array(TITANIA_TOPICS_TABLE => 't'), 'WHERE' => self::sql_permissions('t.', false, true), 'ORDER_BY' => 't.topic_sticky DESC, ' . $sort->get_order_by());
     $sql_ary['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'u'), 'ON' => 't.topic_first_post_user_id = u.user_id');
     $sql_ary['LEFT_JOIN'][] = array('FROM' => array(USERS_TABLE => 'ul'), 'ON' => 't.topic_last_post_user_id = ul.user_id');
     titania_tracking::get_track_sql($sql_ary, TITANIA_TOPIC, 't.topic_id');
     // Setup the contribution/topic we will use for parsing the output (before the switch so we are able to do type specific things for it)
     $topic = new titania_topic();
     $contrib = new titania_contribution();
     // type specific things
     switch ($type) {
         case 'tracker':
             $page_url = $object->get_url('tracker');
             $sql_ary['WHERE'] .= ' AND t.parent_id = ' . (int) $object->contrib_id;
             $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_TRACKER;
             if (isset($options['category'])) {
                 $sql_ary['WHERE'] .= ' AND t.topic_category = ' . (int) $options['category'];
             }
             break;
         case 'queue':
             $page_url = titania_url::build_url('manage/queue');
             $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_QUEUE;
             break;
         case 'queue_discussion':
             $page_url = titania_url::build_url('manage/queue_discussion', array('queue' => titania_types::$types[$options['topic_category']]->url));
             $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_QUEUE_DISCUSSION;
             // Only display those in which the users are authed
             $authed = titania_types::find_authed('queue_discussion');
             if (!sizeof($authed)) {
                 return compact('sort');
             }
             if (isset($options['topic_category'])) {
                 if (!in_array((int) $options['topic_category'], $authed)) {
                     return compact('sort');
                 }
                 $sql_ary['WHERE'] .= ' AND t.topic_category = ' . (int) $options['topic_category'];
             } else {
                 $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.topic_category', $authed);
             }
             // Additional tracking for all queue discussion topics
             titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt');
             $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true);
             // Additional tracking for marking items as read in each contribution
             titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 't.parent_id', 'tst');
             $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true);
             break;
         case 'author_support':
             $page_url = $object->get_url('support');
             $contrib_ids = titania::$cache->get_author_contribs($object->user_id, true);
             $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.parent_id', array_map('intval', $contrib_ids));
             // We also display the queue discussion topic between validators and authors in the support area
             $sql_ary['WHERE'] .= ' AND (t.topic_type = ' . TITANIA_SUPPORT . ' OR t.topic_type = ' . TITANIA_QUEUE_DISCUSSION . ')';
             // Additional tracking for marking items as read in each contribution
             titania_tracking::get_tracks(TITANIA_SUPPORT, $contrib_ids);
             $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true);
             // Additional tracking for all support topics
             titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg');
             $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0, 'type_match' => true);
             // Track the queue discussion too if applicable
             if (titania_types::find_authed('queue_discussion')) {
                 titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt');
                 $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true);
             }
             // Try to grab the category/contrib name
             $sql_ary['SELECT'] .= ', contrib.contrib_name, contrib.contrib_name_clean, contrib.contrib_id, contrib.contrib_type';
             $sql_ary['LEFT_JOIN'] = array_merge(isset($sql_ary['LEFT_JOIN']) ? $sql_ary['LEFT_JOIN'] : array(), array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'contrib'), 'ON' => 'contrib.contrib_id = t.parent_id')));
             // Do not order stickies first
             $sql_ary['ORDER_BY'] = $sort->get_order_by();
             $switch_on_sticky = false;
             break;
         case 'author_tracker':
             $page_url = $object->get_url('tracker');
             $contrib_ids = titania::$cache->get_author_contribs($object->user_id);
             $sql_ary['WHERE'] .= ' AND ' . phpbb::$db->sql_in_set('t.parent_id', array_map('intval', $contrib_ids));
             $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_TRACKER;
             break;
         case 'all_support':
             // Try to grab the category/contrib name
             $sql_ary['SELECT'] .= ', contrib.contrib_name, contrib.contrib_name_clean, contrib.contrib_id, contrib.contrib_type';
             $sql_ary['LEFT_JOIN'] = array_merge(isset($sql_ary['LEFT_JOIN']) ? $sql_ary['LEFT_JOIN'] : array(), array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'contrib'), 'ON' => 'contrib.contrib_id = t.parent_id')));
             if (isset(titania_types::$types[$options['contrib_type']])) {
                 $page_url = titania_url::build_url('support/' . titania_types::$types[$options['contrib_type']]->url);
                 $sql_ary['WHERE'] .= ' AND contrib.contrib_type = ' . $options['contrib_type'];
             } else {
                 $page_url = titania_url::build_url('support/all');
             }
             // Additional tracking field (to allow marking all support/discussion as read)
             $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_SUPPORT;
             // Additional tracking for all support topics
             titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg');
             $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0);
             // Do not order stickies first
             $sql_ary['ORDER_BY'] = $sort->get_order_by();
             $switch_on_sticky = false;
             break;
         case 'support':
         default:
             $page_url = $object->get_url('support');
             $sql_ary['WHERE'] .= ' AND t.parent_id = ' . (int) $object->contrib_id;
             // We also display the queue discussion topic between validators and authors in the support area
             if ($object->is_author || $object->is_active_coauthor || titania_types::$types[$object->contrib_type]->acl_get('queue_discussion')) {
                 $sql_ary['WHERE'] .= ' AND (t.topic_type = ' . TITANIA_SUPPORT . ' OR t.topic_type = ' . TITANIA_QUEUE_DISCUSSION . ')';
             } else {
                 $sql_ary['WHERE'] .= ' AND t.topic_type = ' . TITANIA_SUPPORT;
             }
             // Additional tracking for marking items as read in each contribution
             titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, $object->contrib_id, 'tst');
             $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'parent_match' => true);
             // Additional tracking for all support topics
             titania_tracking::get_track_sql($sql_ary, TITANIA_SUPPORT, 0, 'tstg');
             $topic->additional_unread_fields[] = array('type' => TITANIA_SUPPORT, 'id' => 0);
             // Track the queue discussion too if applicable
             if (titania_types::$types[$object->contrib_type]->acl_get('queue_discussion')) {
                 titania_tracking::get_track_sql($sql_ary, TITANIA_QUEUE_DISCUSSION, 0, 'tqt');
                 $topic->additional_unread_fields[] = array('type' => TITANIA_QUEUE_DISCUSSION, 'id' => 0, 'type_match' => true);
             }
             break;
     }
     // Main SQL Query
     $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
     // Handle pagination
     if (!$sort->sql_count($sql_ary, 't.topic_id')) {
         // No results...no need to query more...
         return compact('sort');
     }
     $sort->build_pagination($page_url);
     $last_was_sticky = false;
     // Get the data
     $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
     while ($row = phpbb::$db->sql_fetchrow($result)) {
         // Store the tracking info we grabbed from the DB
         titania_tracking::store_from_db($row);
         self::$topics[$row['topic_id']] = $row;
         $topic->__set_array($row);
         $contrib->__set_array($row);
         phpbb::$template->assign_block_vars('topics', array_merge($topic->assign_details(), array('S_TOPIC_TYPE_SWITCH' => $switch_on_sticky && $last_was_sticky && !$topic->topic_sticky ? true : false, 'CONTRIB_TYPE' => isset($row['contrib_type']) && $row['contrib_type'] ? titania_types::$types[$row['contrib_type']]->lang : '', 'TOPIC_CONTRIB_NAME' => isset($row['contrib_name']) && $row['contrib_name'] ? censor_text($row['contrib_name']) : '', 'U_VIEW_TOPIC_CONTRIB' => isset($row['contrib_type']) && $row['contrib_type'] ? $contrib->get_url() : '', 'U_VIEW_TOPIC_CONTRIB_SUPPORT' => isset($row['contrib_type']) && $row['contrib_type'] ? $contrib->get_url('support') : '')));
         $last_was_sticky = $topic->topic_sticky;
     }
     phpbb::$db->sql_freeresult($result);
     unset($topic);
     return compact('sort');
 }
Exemplo n.º 21
0
if (!$thumbnail) {
    // Update download count
    $sql = 'UPDATE ' . TITANIA_ATTACHMENTS_TABLE . '
		SET download_count = download_count + 1
		WHERE attachment_id = ' . $attachment['attachment_id'];
    phpbb::$db->sql_query($sql);
    // Update download count for the contrib object as well
    if ($attachment['object_type'] == TITANIA_CONTRIB) {
        $sql = 'UPDATE ' . TITANIA_CONTRIBS_TABLE . '
			SET contrib_downloads = contrib_downloads + 1
			WHERE contrib_id = ' . $attachment['object_id'];
        phpbb::$db->sql_query($sql);
    }
}
if (!$thumbnail && $mode === 'view' && strpos($attachment['mimetype'], 'image') === 0 && (strpos(strtolower(phpbb::$user->browser), 'msie') !== false && strpos(strtolower(phpbb::$user->browser), 'msie 8.0') === false)) {
    wrap_img_in_html(titania_url::build_url('download', array('id' => $attachment['attachment_id'])), $attachment['real_filename']);
    file_gc();
} else {
    send_file_to_browser($attachment, titania::$config->upload_path);
    file_gc();
}
/**
* Wraps an url into a simple html page. Used to display attachments in IE.
* this is a workaround for now; might be moved to template system later
* direct any complaints to 1 Microsoft Way, Redmond
*/
function wrap_img_in_html($src, $title)
{
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd">';
    echo '<html>';
    echo '<head>';
Exemplo n.º 22
0
$attention_count = phpbb::$db->sql_fetchfield('cnt');
phpbb::$db->sql_freeresult();
/**
* Menu Array
*
* 'filename' => array(
*	'title'		=> 'nav menu title',
* 	'url'		=> $page_url,
*	'auth'		=> ($can_see_page) ? true : false, // Not required, always true if missing
* ),
*/
$nav_ary = array('attention' => array('title' => 'ATTENTION', 'url' => titania_url::build_url('manage/attention'), 'auth' => !phpbb::$auth->acl_gets('u_titania_mod_author_mod', 'u_titania_mod_contrib_mod', 'u_titania_mod_faq_mod', 'u_titania_mod_post_mod') && !sizeof(titania_types::find_authed('moderate')) ? false : true, 'count' => $attention_count), 'queue' => array('title' => 'VALIDATION_QUEUE', 'url' => titania_url::build_url('manage/queue'), 'auth' => sizeof(titania_types::find_authed('view')) && titania::$config->use_queue ? true : false), 'queue_discussion' => array('title' => 'QUEUE_DISCUSSION', 'url' => titania_url::build_url('manage/queue_discussion'), 'auth' => sizeof(titania_types::find_authed('queue_discussion')) && titania::$config->use_queue ? true : false), 'administration' => array('title' => 'ADMINISTRATION', 'url' => titania_url::build_url('manage/administration'), 'auth' => phpbb::$auth->acl_get('u_titania_admin') ? true : false, 'match' => array('categories')), 'categories' => array('title' => 'MANAGE_CATEGORIES', 'url' => titania_url::build_url('manage/categories'), 'auth' => phpbb::$auth->acl_get('u_titania_admin') ? true : false, 'display' => false));
// Display nav menu
titania::generate_nav($nav_ary, $page, 'attention');
// Generate the main breadcrumbs
titania::generate_breadcrumbs(array(phpbb::$user->lang['MANAGE'] => titania_url::build_url('manage')));
if ($page) {
    titania::generate_breadcrumbs(array($nav_ary[$page]['title'] => $nav_ary[$page]['url']));
}
// And now to load the appropriate page...
switch ($page) {
    case 'queue':
    case 'queue_discussion':
    case 'attention':
    case 'administration':
    case 'categories':
        include TITANIA_ROOT . 'manage/' . $page . '.' . PHP_EXT;
        break;
    default:
        include TITANIA_ROOT . 'manage/queue.' . PHP_EXT;
        exit;
Exemplo n.º 23
0
/**
* Copy new posts for queue discussion, queue to the forum
*/
function phpbb_com_titania_queue_update_first_queue_post($hook, &$post_object, $queue_object)
{
    if ($queue_object->queue_status == TITANIA_QUEUE_HIDE || !$queue_object->queue_topic_id) {
        return;
    }
    // First we copy over the queue discussion topic if required
    $sql = 'SELECT topic_id, phpbb_topic_id, topic_category FROM ' . TITANIA_TOPICS_TABLE . '
		WHERE parent_id = ' . $queue_object->contrib_id . '
			AND topic_type = ' . TITANIA_QUEUE_DISCUSSION;
    $result = phpbb::$db->sql_query($sql);
    $topic_row = phpbb::$db->sql_fetchrow($result);
    phpbb::$db->sql_freeresult($result);
    // Do we need to create the queue discussion topic or not?
    if ($topic_row['topic_id'] && !$topic_row['phpbb_topic_id']) {
        $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, TITANIA_QUEUE_DISCUSSION);
        $temp_post = new titania_post();
        // Go through any posts in the queue discussion topic and copy them
        $topic_id = false;
        $sql = 'SELECT * FROM ' . TITANIA_POSTS_TABLE . ' WHERE topic_id = ' . $topic_row['topic_id'];
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $temp_post->__set_array($row);
            $post_text = $row['post_text'];
            titania_decode_message($post_text, $row['post_text_uid']);
            $post_text .= "\n\n" . titania_url::remove_sid($temp_post->get_url());
            $options = array('poster_id' => $row['post_user_id'], 'forum_id' => $forum_id, 'topic_title' => $row['post_subject'], 'post_text' => $post_text);
            titania::_include('functions_posting', 'phpbb_posting');
            if ($topic_id) {
                $options = array_merge($options, array('topic_id' => $topic_id));
                phpbb_posting('reply', $options);
            } else {
                switch ($topic_row['topic_category']) {
                    case TITANIA_TYPE_MOD:
                        $options['poster_id'] = titania::$config->forum_mod_robot;
                        break;
                    case TITANIA_TYPE_STYLE:
                        $options['poster_id'] = titania::$config->forum_style_robot;
                        break;
                }
                $topic_id = phpbb_posting('post', $options);
            }
        }
        phpbb::$db->sql_freeresult($result);
        if ($topic_id) {
            $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
				SET phpbb_topic_id = ' . $topic_id . '
				WHERE topic_id = ' . $topic_row['topic_id'];
            phpbb::$db->sql_query($sql);
        }
        unset($temp_post);
    }
    // Does a queue topic already exist?  If so, don't repost.
    $sql = 'SELECT phpbb_topic_id FROM ' . TITANIA_TOPICS_TABLE . '
		WHERE topic_id = ' . $queue_object->queue_topic_id;
    phpbb::$db->sql_query($sql);
    $phpbb_topic_id = phpbb::$db->sql_fetchfield('phpbb_topic_id');
    phpbb::$db->sql_freeresult();
    if ($phpbb_topic_id) {
        return;
    }
    $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, $post_object->topic->topic_type);
    if (!$forum_id) {
        return;
    }
    $post_object->submit();
    titania::_include('functions_posting', 'phpbb_posting');
    // Need some stuff
    titania::add_lang('contributions');
    $contrib = new titania_contribution();
    $contrib->load((int) $queue_object->contrib_id);
    $revision = $queue_object->get_revision();
    $contrib->get_download($revision->revision_id);
    switch ($post_object->topic->topic_category) {
        case TITANIA_TYPE_MOD:
            $post_object->topic->topic_first_post_user_id = titania::$config->forum_mod_robot;
            $lang_var = 'MOD_QUEUE_TOPIC';
            break;
        case TITANIA_TYPE_STYLE:
            $post_object->topic->topic_first_post_user_id = titania::$config->forum_style_robot;
            $lang_var = 'STYLE_QUEUE_TOPIC';
            break;
        default:
            return;
            break;
    }
    $description = $contrib->contrib_desc;
    titania_decode_message($description, $contrib->contrib_desc_uid);
    $post_text = sprintf(phpbb::$user->lang[$lang_var], $contrib->contrib_name, $contrib->author->get_url(), users_overlord::get_user($contrib->author->user_id, '_username'), $description, $revision->revision_version, titania_url::build_url('download', array('id' => $revision->attachment_id)), $contrib->download['real_filename'], $contrib->download['filesize']);
    $post_text .= "\n\n" . $post_object->post_text;
    titania_decode_message($post_text, $post_object->post_text_uid);
    $post_text .= "\n\n" . titania_url::remove_sid($post_object->get_url());
    $options = array('poster_id' => $post_object->topic->topic_first_post_user_id, 'forum_id' => $forum_id, 'topic_title' => $post_object->topic->topic_subject, 'post_text' => $post_text);
    $topic_id = phpbb_posting('post', $options);
    $post_object->topic->phpbb_topic_id = $topic_id;
    $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
		SET phpbb_topic_id = ' . (int) $topic_id . '
		WHERE topic_id = ' . $post_object->topic->topic_id;
    phpbb::$db->sql_query($sql);
}
Exemplo n.º 24
0
 /**
  * Build the left "tool" navigation for every page
  * This is based upon the active tool
  */
 function gen_left_nav()
 {
     global $template, $user;
     // Grep the correct category
     $tool_list = $this->plugin_list;
     // Run through the tools and collect all info we need
     $tpl_data = array();
     foreach ($tool_list as $tool) {
         $class = $this->load_tool($tool);
         // Can this tool be used?
         if (method_exists($class, 'tool_active')) {
             if ($class->tool_active() !== true) {
                 continue;
             }
         }
         // Get the info
         if (method_exists($class, 'info')) {
             $info = $class->info();
         } else {
             // For us lazy people
             $info = array('NAME' => isset($user->lang[strtoupper($tool)]) ? $user->lang[strtoupper($tool)] : strtoupper($tool));
         }
         $tpl_data[$tool] = $info['NAME'];
     }
     // Sort the data based on the tool name. This way we'll keep the menu sorted correctly for translations
     asort($tpl_data);
     // Now go ahead and build the template
     foreach ($tpl_data as $tool => $name) {
         $_s_active = $tool == $this->tool_id ? true : false;
         // Assign to the template
         $template->assign_block_vars('tools', array('L_TITLE' => $name, 'TOOL' => $tool, 'S_SELECTED' => $_s_active, 'U_TITLE' => titania_url::build_url('manage/administration', array('t' => $tool))));
     }
 }
Exemplo n.º 25
0
phpbb::$user->add_lang('viewforum');
if ($topic_id) {
    // Subscriptions
    titania_subscriptions::handle_subscriptions(TITANIA_TOPIC, $topic_id, $topic->get_url());
    // Check access level
    if ($topic->topic_access < titania::$access_level || $topic->topic_type == TITANIA_QUEUE_DISCUSSION && !titania::$contrib->is_author && !titania::$contrib->is_active_coauthor && !titania_types::$types[titania::$contrib->contrib_type]->acl_get('queue_discussion')) {
        titania::needs_auth();
    }
    posts_overlord::display_topic_complete($topic);
    titania::page_header(censor_text($topic->topic_subject) . ' - ' . titania::$contrib->contrib_name);
    if (phpbb::$auth->acl_get('u_titania_post')) {
        phpbb::$template->assign_var('U_POST_REPLY', titania_url::append_url($topic->get_url(), array('action' => 'reply')));
    }
    // Canonical URL
    phpbb::$template->assign_var('U_CANONICAL', $topic->get_url());
} else {
    // Subscriptions
    titania_subscriptions::handle_subscriptions(TITANIA_SUPPORT, titania::$contrib->contrib_id, titania::$contrib->get_url('support'));
    // Mark all topics read
    if (request_var('mark', '') == 'topics') {
        titania_tracking::track(TITANIA_SUPPORT, titania::$contrib->contrib_id);
    }
    $data = topics_overlord::display_forums_complete('support', titania::$contrib);
    titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['CONTRIB_SUPPORT']);
    if (phpbb::$auth->acl_get('u_titania_topic') && titania::$config->support_in_titania) {
        phpbb::$template->assign_var('U_POST_TOPIC', titania_url::append_url(titania::$contrib->get_url('support'), array('action' => 'post')));
    }
    $data['sort']->set_url(titania::$contrib->get_url('support'));
    phpbb::$template->assign_vars(array('U_MARK_TOPICS' => titania_url::append_url(titania::$contrib->get_url('support'), array('mark' => 'topics')), 'U_CANONICAL' => $data['sort']->build_canonical(), 'S_DISPLAY_SEARCHBOX' => true, 'S_SEARCHBOX_ACTION' => titania_url::build_url('search', array('type' => TITANIA_SUPPORT, 'contrib' => titania::$contrib->contrib_id))));
}
titania::page_footer(true, 'contributions/contribution_support.html');
Exemplo n.º 26
0
    exit;
}
$queue_id = request_var('q', 0);
$queue_type = request_var('queue', '');
$tag = request_var('tag', 0);
// Force the queue_type if we have a queue_id
if ($queue_id) {
    $sql = 'SELECT queue_type FROM ' . TITANIA_QUEUE_TABLE . '
		WHERE queue_id = ' . $queue_id;
    phpbb::$db->sql_query($sql);
    $queue_type = phpbb::$db->sql_fetchfield('queue_type');
} else {
    $queue_type = titania_types::type_from_url($queue_type);
}
// Setup the base url we will use
$base_url = titania_url::build_url('manage/queue');
if ($queue_type === false) {
    // We need to select the queue if they only have one that they can access, else display the list
    $authed = titania_types::find_authed('view');
    if (empty($authed)) {
        titania::needs_auth();
    } else {
        if (sizeof($authed) == 1) {
            $queue_type = $authed[0];
        } else {
            foreach ($authed as $type_id) {
                $sql = 'SELECT COUNT(queue_id) AS cnt FROM ' . TITANIA_QUEUE_TABLE . '
				WHERE queue_type = ' . (int) $type_id . '
					AND queue_status > 0';
                phpbb::$db->sql_query($sql);
                $cnt = phpbb::$db->sql_fetchfield('cnt');
    /**
     * 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));
        }
    }
Exemplo n.º 28
0
 /**
  * Get the URL for the item needing attention
  *
  * @return string the built url
  */
 public function get_url()
 {
     $base = $append = false;
     titania_url::split_base_params($base, $append, $this->attention_url);
     return titania_url::build_url($base, $append);
 }
Exemplo n.º 29
0
 /**
  * Build pagination and send to template
  * $this->url_location and $this->url_parameters will over-ride the settings given here for $page, $params.
  * The reason is that the place that calls build_pagination is typically in a completely different area, in an area that can't say for certain the correct URL (other than the current page)
  *
  * @param string $page path/page to be used in pagination url
  * @param array $params to be used in pagination url
  */
 public function build_pagination($page, $params = array())
 {
     if ($this->url_location) {
         $page = $this->url_location;
     }
     if ($this->url_parameters) {
         $params = $this->url_parameters;
     }
     // Spring cleaning
     unset($params[$this->start_name], $params[$this->limit_name], $params[$this->sort_key_name], $params[$this->sort_dir_name]);
     // Add the limit to the URL if required
     if ($this->limit != $this->default_limit) {
         $params[$this->limit_name] = $this->limit;
     }
     // Don't include the sort key/dir in the sort action url
     $sort_url = titania_url::build_url($page, $params);
     // Add the sort key to the URL if required
     if ($this->sort_key != $this->default_sort_key) {
         $params[$this->sort_key_name] = $this->sort_key;
     }
     // Add the sort dir to the URL if required
     if ($this->sort_dir != $this->default_sort_dir) {
         $params[$this->sort_dir_name] = $this->sort_dir;
     }
     $pagination_url = titania_url::build_url($page, $params);
     phpbb::$template->assign_vars(array($this->template_vars['PAGINATION'] => $this->generate_pagination($pagination_url, false, false, false, true), $this->template_vars['PAGE_NUMBER'] => on_page($this->total, $this->limit, $this->start), $this->template_vars['S_SORT_ACTION'] => $sort_url, $this->template_vars['S_PAGINATION_ACTION'] => $pagination_url, $this->template_vars['S_NUM_POSTS'] => $this->total, $this->template_vars['S_SELECT_SORT_KEY'] => $this->get_sort_key_list(), $this->template_vars['S_SELECT_SORT_DIR'] => $this->get_sort_dir_list(), $this->template_vars['SORT_KEYS_NAME'] => $this->sort_key_name, $this->template_vars['SORT_DIR_NAME'] => $this->sort_dir_name));
     return true;
 }
Exemplo n.º 30
0
<?php

/**
 *
 * @package titania
 * @version $Id$
 * @copyright (c) 2008 phpBB Customisation Database Team
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 *
 */
/**
* @ignore
*/
if (!defined('IN_TITANIA')) {
    exit;
}
// Mark all topics read
if (request_var('mark', '') == 'topics') {
    foreach (titania::$cache->get_author_contribs(titania::$author->user_id) as $contrib_id) {
        titania_tracking::track(TITANIA_SUPPORT, $contrib_id);
    }
}
topics_overlord::display_forums_complete('author_support', titania::$author);
// Mark all topics read
phpbb::$template->assign_var('U_MARK_TOPICS', titania_url::build_url(titania::$author->get_url('support'), array('mark' => 'topics')));
titania::page_header(titania::$author->get_username_string('username') . ' - ' . phpbb::$user->lang['AUTHOR_SUPPORT']);
titania::page_footer(true, 'contributions/contribution_support.html');