コード例 #1
0
function friends_function_generate_menu(&$arg)
{
    global $auth, $cache, $config, $db, $user, $template, $phpbb_root_path;
    global $user_id, $blog_template, $blog_images_path;
    $limit = 4;
    $template->assign_vars(array('ZEBRA_LIST_LIMIT' => $limit, 'IMG_PORTAL_MEMBER' => $blog_images_path . 'icon_friend.gif', 'S_CONTENT_FLOW_BEGIN' => $user->lang['DIRECTION'] == 'ltr' ? 'left' : 'right', 'S_CONTENT_FLOW_END' => $user->lang['DIRECTION'] == 'ltr' ? 'right' : 'left'));
    if ($user_id == ANONYMOUS || $user->data['is_bot']) {
        return;
    }
    // Output listing of friends online
    $menu_friends_online = $menu_friends_offline = $user_friends = 0;
    $update_time = time() - intval($config['load_online_time']) * 60;
    // lets use the cache...as this query is quite intensive
    $cache_data = false;
    //$cache->get("_zebra{$user_id}");
    if ($cache_data === false) {
        $sql = $db->sql_build_query('SELECT_DISTINCT', array('SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline', 'FROM' => array(USERS_TABLE => 'u', ZEBRA_TABLE => 'z'), 'LEFT_JOIN' => array(array('FROM' => array(SESSIONS_TABLE => 's'), 'ON' => 's.session_user_id = z.zebra_id')), 'WHERE' => 'z.user_id = ' . intval($user_id) . '
				AND z.friend = 1
				AND u.user_id = z.zebra_id', 'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username', 'ORDER_BY' => 'u.username_clean ASC'));
        $result = $db->sql_query($sql);
        $rowset = $db->sql_fetchrowset($result);
        $db->sql_freeresult($result);
        //$cache->put("_zebra{$user_id}", $rowset, 60); // cache for 1 minute
        $cache_data = $rowset;
    }
    foreach ($cache_data as $row) {
        $which = $update_time < $row['online_time'] && ($row['viewonline'] || $auth->acl_get('u_viewonline')) ? 'menu_friends_online' : 'menu_friends_offline';
        ${$which}++;
        $template->assign_block_vars("{$which}", array('USER_ID' => $row['user_id'], 'U_PROFILE' => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']), 'U_VIEW_BLOG' => blog_url($row['user_id']), 'USER_COLOUR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']), 'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'HIDE' => true));
    }
    $template->assign_vars(array('S_SHOW_NEXT_ONLINE' => $menu_friends_online > $limit ? true : false, 'S_SHOW_NEXT_OFFLINE' => $menu_friends_offline > $limit ? true : false, 'S_MENU_ZEBRA_ENABLED' => $menu_friends_online || $menu_friends_offline ? true : false));
    $arg['user_menu_extra'] .= blog_plugins::parse_template('blog/plugins/friends/friends_body.html');
}
コード例 #2
0
ファイル: plugins.php プロジェクト: EXreaction/User-Blog-Mod
 /**
  * Constructor
  *
  * Load all installed and enabled plugins
  */
 public function __construct()
 {
     global $cache, $config, $db, $phpbb_root_path, $phpEx, $blog_plugins_path, $table_prefix, $user;
     if (!isset($config['user_blog_enable_plugins']) || !$config['user_blog_enable_plugins']) {
         return false;
     }
     // Just in case it is not set we will use the default.
     if (!$blog_plugins_path) {
         $blog_plugins_path = $phpbb_root_path . 'blog/plugins/';
     }
     if (($cache_data = $cache->get('_blog_plugins')) === false) {
         if (!defined('BLOGS_PLUGINS_TABLE')) {
             include $phpbb_root_path . 'blog/includes/constants.' . $phpEx;
         }
         $sql = 'SELECT * FROM ' . BLOGS_PLUGINS_TABLE . ' ORDER BY plugin_id ASC';
         $result = $db->sql_query($sql);
         while ($row = $db->sql_fetchrow($result)) {
             self::$plugins[$row['plugin_name']] = $row;
         }
         $cache->put('_blog_plugins', self::$plugins);
     } else {
         self::$plugins = $cache_data;
     }
     unset($cache_data);
     foreach (self::$plugins as $row) {
         $name = $row['plugin_name'];
         // this is checked in the plugin file
         if ($row['plugin_enabled'] && file_exists($blog_plugins_path . 'info/info_' . $name . '.' . $phpEx)) {
             include $blog_plugins_path . 'info/info_' . $name . '.' . $phpEx;
         }
     }
     return true;
 }
コード例 #3
0
function archive_function_generate_menu(&$arg)
{
    global $auth, $db, $user, $template, $phpbb_root_path, $blog_images_path;
    if (!$arg['user_id']) {
        return;
    }
    $last_mon = 0;
    $archive_rows = array();
    $sql = 'SELECT blog_id, blog_time, blog_subject FROM ' . BLOGS_TABLE . '
		WHERE user_id = ' . intval($arg['user_id']) . ($auth->acl_get('m_blogapprove') ? '' : ' AND blog_approved = 1') . (!$auth->acl_gets('m_blogdelete', 'a_blogdelete') ? ' AND (blog_deleted = 0 OR blog_deleted = ' . $user->data['user_id'] . ')' : '') . build_permission_sql($user->data['user_id']) . '
			ORDER BY blog_time DESC';
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $date = getdate($row['blog_time']);
        // If we are starting a new month
        if ($date['mon'] != $last_mon) {
            $archive_row = array('MONTH' => $user->lang['datetime'][$date['month']], 'YEAR' => $date['year'], 'monthrow' => array());
            $archive_rows[] = $archive_row;
        }
        $archive_row_month = array('TITLE' => censor_text($row['blog_subject']), 'U_VIEW' => blog_url($arg['user_id'], $row['blog_id'], false, array(), array('blog_subject' => $row['blog_subject'])), 'DATE' => $user->format_date($row['blog_time']));
        $archive_rows[sizeof($archive_rows) - 1]['monthrow'][] = $archive_row_month;
        // set the last month variable as the current month
        $last_mon = $date['mon'];
    }
    $db->sql_freeresult($result);
    foreach ($archive_rows as $row) {
        $template->assign_block_vars('archiverow', $row);
    }
    $template->assign_vars(array('S_ARCHIVES' => sizeof($archive_rows) ? true : false, 'T_THEME_PATH' => "{$phpbb_root_path}styles/" . $user->theme['theme_path'] . '/theme', 'IMG_PLUS' => $blog_images_path . 'plus.gif', 'IMG_MINUS' => $blog_images_path . 'minus.gif'));
    $arg['user_menu_extra'] .= blog_plugins::parse_template('blog/plugins/archive/archive_body.html');
    unset($template->_tpldata['archiverow']);
}
コード例 #4
0
/**
* gets the star rating of the item from the int rating
*
* @param string $start_url The url which will be used to rate each item (the rating part of the url should be *rating*, EX: blog.php?page=rate&b=1&rating=*rating*)
* @param string $delete_url The url which will be used to remove the rating for the item
* @param int $average_rating The current rating of the item
* @param int $num_ratings The number of times the item has been rated
* @param int $user_rating The rating the user gave for the item
* @param bool $force_average If you want to force it to display the average score without the links to submit the rating
*/
function get_star_rating($start_url, $delete_url, $average_rating, $num_ratings, $user_rating, $force_average = false)
{
    global $auth, $config, $phpbb_root_path, $phpEx, $user, $blog_plugins, $blog_images_path;
    if (!$config['user_blog_enable_ratings']) {
        return false;
    }
    $temp = compact('start_url', 'delete_url', 'average_rating', 'num_ratings', 'user_rating', 'force_average');
    blog_plugins::plugin_do_ref('function_get_star_rating', $temp);
    extract($temp);
    $can_rate = $user->data['is_registered'] && !$force_average && $user_rating === false ? true : false;
    // If it has not had any ratings yet, give it 1/2 the max for the rating
    if ($num_ratings == 0) {
        // If they can not rate the item and there are no ratings, do not show it at all.
        if (!$can_rate) {
            return '';
        }
        $average_rating = ceil($config['user_blog_max_rating'] / 2);
    }
    // Some variables we'll need
    $star_green = $blog_images_path . 'star_green.gif';
    $star_grey = $blog_images_path . 'star_grey.gif';
    $star_orange = $blog_images_path . 'star_orange.gif';
    $star_red = $blog_images_path . 'star_red.gif';
    $star_remove = $blog_images_path . 'star_remove.gif';
    $final_code = $force_average ? sprintf($num_ratings == 1 ? $user->lang['AVERAGE_OF_RATING'] : $user->lang['AVERAGE_OF_RATINGS'], $num_ratings) . ':' : '';
    // A unique string that will get added to the rating.  So if the item is shown more than once, hovering over and trying to rate one doesn't mess up the other list.
    $unique_str = md5(microtime());
    $unique_str = "u_{$unique_str}_s_";
    // If the user has rated this already and we are not just getting the average, get the average as well.
    if ($user_rating !== false && !$force_average) {
        $final_code = get_star_rating($start_url, $delete_url, $average_rating, $num_ratings, $user_rating, true) . '';
        $average_rating = $user_rating;
    }
    $final_code .= $user_rating !== false && !$force_average ? $user->lang['MY_RATING'] . ': ' : '';
    $final_code .= '<div>';
    for ($i = $config['user_blog_min_rating']; $i <= $config['user_blog_max_rating']; $i++) {
        $title = $user_rating === false && !$force_average ? sprintf($user->lang['RATE_ME'], $i, $config['user_blog_max_rating']) : sprintf($user->lang['RATE_ME'], $average_rating, $config['user_blog_max_rating']);
        $final_code .= $can_rate ? '<a href="' . str_replace('*rating*', $i, $start_url) . '">' : '';
        $final_code .= '<img id="' . $unique_str . $i . '" ';
        if ($user_rating !== false && $i <= $user_rating && !$force_average) {
            $final_code .= 'src="' . $star_green . '" ';
        } else {
            if ($i <= $average_rating) {
                $final_code .= 'src="' . $star_orange . '" ';
            } else {
                $final_code .= 'src="' . $star_grey . '" ';
            }
        }
        $final_code .= $can_rate ? "onmouseover=\"ratingHover('{$i}', '{$unique_str}')\"  onmouseout=\"ratingUnHover('{$average_rating}', '{$unique_str}')\"  onmousedown=\"ratingDown('{$i}', '{$unique_str}')\"" : '';
        $final_code .= ' alt="' . $title . '" title="' . $title . '" />';
        $final_code .= $can_rate ? '</a>' : '';
    }
    // If required, we will add the remove rating icon at the end
    if ($user_rating !== false && !$force_average) {
        $final_code .= ' <a href="' . $delete_url . '"><img id="' . $unique_str . 'remove" src="' . $star_remove . '"  alt="' . $user->lang['REMOVE_RATING'] . '" title="' . $user->lang['REMOVE_RATING'] . '" /></a>';
    }
    $final_code .= '</div>';
    return $final_code;
}
コード例 #5
0
ファイル: download.php プロジェクト: EXreaction/User-Blog-Mod
    wrap_img_in_html(append_sid('./blog.' . $phpEx, 'page=download&amp;id=' . $attachment['attach_id']), $attachment['real_filename']);
} else {
    // Determine the 'presenting'-method
    if ($download_mode == PHYSICAL_LINK) {
        // This presenting method should no longer be used
        if (!@is_dir($phpbb_root_path . $config['upload_path'])) {
            trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']);
        }
        redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']);
        exit;
    } else {
        send_file_to_browser($attachment, $config['upload_path'] . '/blog_mod', $display_cat);
        exit;
    }
}
blog_plugins::plugin_do('download_end');
/**
* 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>';
    echo '<meta http-equiv="content-type" content="text/html; charset=UTF-8" />';
    echo '<title>' . $title . '</title>';
    echo '</head>';
    echo '<body>';
    echo '<div>';
コード例 #6
0
/**
* Syncronise Blog Data
*
* This should never need to be used unless someone manually deletes blogs or replies from the database
* It is not used by the User Blog mod anywhere, except for updates/upgrades and the resync page.
* To any potential users: Make sure you do not set this in a page where it gets ran often.  Resyncing data is a long process, especially when the number of blogs that you have is large
*
* @param string $mode can be all, reply_count, real_reply_count, delete_orphan_replies, or user_blog_count
*/
function resync_blog($mode)
{
    global $cache, $db;
    $blog_data = array();
    // Start by selecting all blog data that we will use
    $sql = 'SELECT blog_id, blog_reply_count, blog_real_reply_count FROM ' . BLOGS_TABLE . ' ORDER BY blog_id ASC';
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $blog_data[$row['blog_id']] = $row;
    }
    $db->sql_freeresult($result);
    /*
     * Update & Resync the reply counts
     */
    if ($mode == 'reply_count' || $mode == 'all') {
        foreach ($blog_data as $row) {
            // count all the replies (an SQL query seems the easiest way to do it)
            $sql = 'SELECT count(reply_id) AS total
				FROM ' . BLOGS_REPLY_TABLE . '
					WHERE blog_id = ' . $row['blog_id'] . '
						AND reply_deleted = 0
						AND reply_approved = 1';
            $result = $db->sql_query($sql);
            $total = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($total['total'] != $row['blog_reply_count']) {
                // Update the reply count
                $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_reply_count = ' . $total['total'] . ' WHERE blog_id = ' . $row['blog_id'];
                $db->sql_query($sql);
            }
        }
    }
    /*
     * Update & Resync the real reply counts
     */
    if ($mode == 'real_reply_count' || $mode == 'all') {
        foreach ($blog_data as $row) {
            // count all the replies (an SQL query seems the easiest way to do it)
            $sql = 'SELECT count(reply_id) AS total
				FROM ' . BLOGS_REPLY_TABLE . '
					WHERE blog_id = ' . $row['blog_id'];
            $result = $db->sql_query($sql);
            $total = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if ($total['total'] != $row['blog_real_reply_count']) {
                // Update the reply count
                $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_real_reply_count = ' . $total['total'] . ' WHERE blog_id = ' . $row['blog_id'];
                $db->sql_query($sql);
            }
        }
    }
    /*
     * Delete's all oprhaned replies (replies where the blogs they should go under have been deleted).
     */
    if ($mode == 'delete_orphan_replies' || $mode == 'all') {
        // Now get all reply data we will use
        $sql = 'SELECT reply_id, blog_id FROM ' . BLOGS_REPLY_TABLE . ' ORDER BY reply_id ASC';
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            // if the blog_id it attached to is not in $blog_data
            if (!array_key_exists($row['blog_id'], $blog_data)) {
                $sql2 = 'DELETE FROM ' . BLOGS_REPLY_TABLE . ' WHERE reply_id = ' . $row['reply_id'];
                $db->sql_query($sql2);
            }
        }
        $db->sql_freeresult($result);
    }
    /*
     * Updates the blog_count for each user
     */
    if ($mode == 'user_blog_count' || $mode == 'all') {
        // select the users data we will need
        $sql = 'SELECT user_id, blog_count FROM ' . USERS_TABLE;
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            // count all the replies (an SQL query seems the easiest way to do it)
            $sql2 = 'SELECT count(blog_id) AS total
				FROM ' . BLOGS_TABLE . '
					WHERE user_id = \'' . $row['user_id'] . '\'
						AND blog_deleted = 0
						AND blog_approved = 1';
            $result2 = $db->sql_query($sql2);
            $total = $db->sql_fetchrow($result2);
            $db->sql_freeresult($result2);
            if ($total['total'] != $row['blog_count']) {
                // Update the reply count
                $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = ' . $total['total'] . ' WHERE user_id = ' . $row['user_id'];
                $db->sql_query($sql);
            }
        }
        $db->sql_freeresult($result);
    }
    /**
     * Updates the user permissions for each blog
     */
    if ($mode == 'user_permissions' || $mode == 'all') {
        $sql = 'SELECT * FROM ' . BLOGS_USERS_TABLE;
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $sql_ary = array('perm_guest' => $row['perm_guest'], 'perm_registered' => $row['perm_registered'], 'perm_foe' => $row['perm_foe'], 'perm_friend' => $row['perm_friend']);
            $sql = 'UPDATE ' . BLOGS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'];
            $db->sql_query($sql);
        }
        $db->sql_freeresult($result);
    }
    // clear the cache
    $cache->purge();
    if (class_exists('blog_plugins')) {
        blog_plugins::plugin_do_arg('function_resync_blog', $mode);
    }
}
コード例 #7
0
ファイル: delete.php プロジェクト: EXreaction/User-Blog-Mod
    trigger_error('REPLY_EDIT_LOCKED');
}
// Setup the page header and sent the title of the page that will go into the browser header
page_header($user->lang['DELETE_REPLY']);
// Generate the breadcrumbs
generate_blog_breadcrumbs($user->lang['DELETE_REPLY']);
blog_plugins::plugin_do('reply_delete');
$display_vars = array();
if ($auth->acl_get('a_blogdelete') && blog_data::$reply[$reply_id]['reply_deleted'] == 0) {
    $display_vars = array('legend1' => $user->lang['HARD_DELETE'], 'hard_delete' => array('lang' => 'HARD_DELETE', 'validate' => 'bool', 'type' => 'checkbox', 'default' => false, 'explain' => true));
}
blog_plugins::plugin_do_ref('blog_delete', $display_vars);
include "{$phpbb_root_path}blog/includes/functions_confirm.{$phpEx}";
$settings = blog_confirm('DELETE_REPLY', 'DELETE_REPLY_CONFIRM', $display_vars, 'yes/no');
if (is_array($settings)) {
    blog_plugins::plugin_do('reply_delete_confirm');
    // if it has already been soft deleted
    if ((isset($settings['hard_delete']) && $settings['hard_delete'] || blog_data::$reply[$reply_id]['reply_deleted'] != 0) && $auth->acl_get('a_blogreplydelete')) {
        // If it has not been soft deleted we need to do a few more things...
        if (blog_data::$reply[$reply_id]['reply_deleted'] == 0) {
            // Remove the search index
            $blog_search->index_remove($blog_id, $reply_id);
            // update the reply count for the blog
            $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_reply_count = blog_reply_count - 1 WHERE blog_id = ' . intval($blog_id) . ' AND blog_reply_count > 0';
            $db->sql_query($sql);
            set_config('num_blog_replies', --$config['num_blog_replies'], true);
        }
        // Delete the Attachments
        $blog_attachment->get_attachment_data(false, $reply_id);
        if (sizeof(blog_data::$reply[$reply_id]['attachment_data'])) {
            foreach (blog_data::$reply[$reply_id]['attachment_data'] as $null => $data) {
コード例 #8
0
 /**
  * Set the options in the template
  */
 function set_in_template()
 {
     global $template, $user, $phpbb_root_path, $phpEx;
     // Assign some variables to the template parser
     $template->assign_vars(array('S_BBCODE_CHECKED' => $this->enable_bbcode ? '' : ' checked="checked"', 'S_SMILIES_CHECKED' => $this->enable_smilies ? '' : ' checked="checked"', 'S_MAGIC_URL_CHECKED' => $this->enable_magic_url ? '' : ' checked="checked"', 'BBCODE_STATUS' => $this->bbcode_status ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $this->img_status ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $this->flash_status ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $this->smilies_status ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $this->url_status ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 'S_BBCODE_ALLOWED' => $this->bbcode_status, 'S_SMILIES_ALLOWED' => $this->smilies_status, 'S_LINKS_ALLOWED' => $this->url_status, 'S_BBCODE_IMG' => $this->img_status, 'S_BBCODE_URL' => $this->url_status, 'S_BBCODE_FLASH' => $this->flash_status, 'S_BBCODE_QUOTE' => true));
     blog_plugins::plugin_do('post_options_set_in_template');
 }
コード例 #9
0
 /**
  * Handle User Data
  *
  * @param int $user_id The user_id of the user we will setup data for
  */
 public function handle_user_data($user_id)
 {
     global $phpbb_root_path, $phpEx, $user, $auth, $config, $template;
     global $blog_data, $zebra_list;
     if (!isset(self::$user[$user_id])) {
         return array();
     }
     $custom_fields = array();
     if ($config['user_blog_custom_profile_enable']) {
         // output the custom profile fields
         if (isset(self::$user[$user_id]['cp_row']['blockrow'])) {
             foreach (self::$user[$user_id]['cp_row']['blockrow'] as $row) {
                 $custom_fields[] = array('PROFILE_FIELD_NAME' => $row['PROFILE_FIELD_NAME'], 'PROFILE_FIELD_VALUE' => $row['PROFILE_FIELD_VALUE']);
             }
         }
     }
     // add the blog links in the custom fields
     if ($user_id != ANONYMOUS) {
         $custom_fields[] = add_blog_links($user_id, '', self::$user[$user_id], false, true, true);
     }
     $output_data = array('USER_ID' => $user_id, 'AGE' => '', 'AVATAR' => $user->optionget('viewavatars') ? self::$user[$user_id]['avatar'] : '', 'POSTER_FROM' => self::$user[$user_id]['user_from'], 'POSTER_JOINED' => $user->format_date(self::$user[$user_id]['user_regdate']), 'POSTER_POSTS' => self::$user[$user_id]['user_posts'], 'RANK_IMG' => self::$user[$user_id]['rank_img'], 'RANK_IMG_SRC' => self::$user[$user_id]['rank_img_src'], 'RANK_TITLE' => self::$user[$user_id]['rank_title'], 'SIGNATURE' => $config['allow_sig'] && $user->optionget('viewsigs') && self::$user[$user_id]['user_sig'] ? generate_text_for_display(self::$user[$user_id]['user_sig'], self::$user[$user_id]['user_sig_bbcode_uid'], self::$user[$user_id]['user_sig_bbcode_bitfield'], 7) : '', 'STATUS_IMG' => self::$user[$user_id]['status'] ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE'), 'USERNAME' => self::$user[$user_id]['username'], 'USER_COLOUR' => self::$user[$user_id]['user_colour'], 'USER_FULL' => self::$user[$user_id]['username_full'], 'USER_FOE' => isset($zebra_list[$user->data['user_id']]['foe']) && in_array($user_id, $zebra_list[$user->data['user_id']]['foe']) ? true : false, 'L_USER_FOE' => sprintf($user->lang['POSTED_BY_FOE'], self::$user[$user_id]['username_full']), 'U_AIM' => self::$user[$user_id]['aim_url'], 'U_EMAIL' => self::$user[$user_id]['email_url'], 'U_ICQ' => self::$user[$user_id]['icq_url'], 'U_JABBER' => self::$user[$user_id]['jabber_url'], 'U_MSN' => self::$user[$user_id]['msn_url'], 'U_PM' => self::$user[$user_id]['pm_url'], 'U_PROFILE' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&amp;u={$user_id}"), 'U_WWW' => self::$user[$user_id]['user_website'], 'U_YIM' => self::$user[$user_id]['yim_url'], 'S_CUSTOM_FIELDS' => isset(self::$user[$user_id]['cp_row']['blockrow']) ? true : false, 'S_ONLINE' => self::$user[$user_id]['status'], 'ONLINE_IMG' => self::$user[$user_id]['status'] ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE'), 'USER_EXTRA' => '', 'custom_fields' => $custom_fields);
     if ($config['allow_birthdays'] && !empty(self::$user[$user_id]['user_birthday'])) {
         list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', self::$user[$user_id]['user_birthday']));
         if ($bday_year) {
             $now = getdate(time() + $user->timezone + $user->dst - date('Z'));
             $diff = $now['mon'] - $bday_month;
             if ($diff == 0) {
                 $diff = $now['mday'] - $bday_day < 0 ? 1 : 0;
             } else {
                 $diff = $diff < 0 ? 1 : 0;
             }
             $output_data['AGE'] = (int) ($now['year'] - $bday_year - $diff);
         }
     }
     blog_plugins::plugin_do_ref('user_handle_data', $output_data);
     return $output_data;
 }
コード例 #10
0
ファイル: rate.php プロジェクト: EXreaction/User-Blog-Mod
$rating = request_var('rating', $config['user_blog_min_rating'] - 1);
$rating_data = get_user_blog_rating_data($user->data['user_id']);
$did_something = false;
if (!$delete_id && $rating != $config['user_blog_min_rating'] - 1 && !isset($rating_data[$blog_id]) && $rating >= $config['user_blog_min_rating'] && $rating <= $config['user_blog_max_rating']) {
    $sql_data = array('blog_id' => intval($blog_id), 'user_id' => $user->data['user_id'], 'rating' => $rating);
    $sql = 'INSERT INTO ' . BLOGS_RATINGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data);
    $db->sql_query($sql);
    $did_something = true;
} else {
    if ($delete_id && isset($rating_data[$blog_id])) {
        $sql = 'DELETE FROM ' . BLOGS_RATINGS_TABLE . ' WHERE blog_id = ' . $delete_id . ' AND user_id = ' . $user->data['user_id'];
        $db->sql_query($sql);
        $did_something = true;
    }
}
blog_plugins::plugin_do_ref('rate', $did_something);
if ($did_something) {
    $total_rating = $total_count = 0;
    $sql = 'SELECT * FROM ' . BLOGS_RATINGS_TABLE . ' WHERE blog_id = ' . intval($blog_id);
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $total_rating += $row['rating'];
        $total_count++;
    }
    $db->sql_freeresult($result);
    $average_rating = $total_count ? round($total_rating / $total_count, 2) : 0;
    $sql = 'UPDATE ' . BLOGS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array('rating' => $average_rating, 'num_ratings' => $total_count)) . ' WHERE blog_id = ' . intval($blog_id);
    $db->sql_query($sql);
    //$cache->destroy('_blog_rating_' . $user->data['user_id']);
}
blog_meta_refresh(0, $blog_urls['view_blog']);
コード例 #11
0
/**
 *  Check blog permissions
 *
 * @param string $page The page requested - blog, reply, mcp, install, upgrade, update, dev, resync
 * @param string $mode The mode requested - depends on the $page requested
 * @param bool $return If you would like this function to return true or false (if they have permission or not).  If it is false we give them a login box if they are not logged in, or give them the NO_AUTH error message
 * @param int $blog_id The blog_id requested (needed for some things, like blog edit, delete, etc
 * @param int $reply_id The reply_id requested, used for the same reason as $blog_id
 *
 * @return Returns
 *	- true if the user is authorized to do the requested action
 *	- false if the user is not authorized to do the requested action
 */
function check_blog_permissions($page, $mode, $return = false, $blog_id = 0, $reply_id = 0)
{
    global $user, $config, $auth, $blog_plugins;
    blog_plugins::plugin_do('function_check_blog_permissions');
    switch ($page) {
        case 'blog':
            switch ($mode) {
                case 'add':
                    $is_auth = $auth->acl_get('u_blogpost') ? true : false;
                    break;
                case 'edit':
                    $is_auth = $user->data['user_id'] != ANONYMOUS && ($auth->acl_get('u_blogedit') && $user->data['user_id'] == blog_data::$blog[$blog_id]['user_id'] || $auth->acl_get('m_blogedit')) ? true : false;
                    break;
                case 'delete':
                    if (blog_data::$blog[$blog_id]['blog_deleted'] == 0 || $auth->acl_get('a_blogdelete')) {
                        $is_auth = $user->data['user_id'] != ANONYMOUS && ($auth->acl_get('u_blogdelete') && $user->data['user_id'] == blog_data::$blog[$blog_id]['user_id'] || $auth->acl_get('m_blogdelete') || $auth->acl_get('a_blogdelete')) ? true : false;
                    } else {
                        $is_auth = false;
                    }
                    break;
                case 'undelete':
                    $is_auth = $auth->acl_gets('m_blogdelete', 'a_blogdelete') || blog_data::$blog[$blog_id]['blog_deleted'] == $user->data['user_id'] ? true : false;
                    break;
                case 'report':
                    $is_auth = $auth->acl_get('u_blogreport') ? true : false;
                    break;
                case 'approve':
                    $is_auth = $auth->acl_get('m_blogapprove') ? true : false;
                    break;
                case 'vote':
                    $is_auth = $auth->acl_get('u_blog_vote') && handle_user_blog_permissions($blog_id) ? true : false;
                    break;
            }
            break;
        case 'reply':
            switch ($mode) {
                case 'add':
                case 'quote':
                    $is_auth = $auth->acl_get('u_blogreply') && handle_user_blog_permissions($blog_id, false, 'reply') ? true : false;
                    break;
                case 'edit':
                    $is_auth = $user->data['user_id'] != ANONYMOUS && ($auth->acl_get('u_blogreplyedit') && $user->data['user_id'] == blog_data::$reply[$reply_id]['user_id'] || isset(blog_data::$blog[$blog_id]['user_id']) && $auth->acl_get('u_blogmoderate') && $user->data['user_id'] == blog_data::$blog[$blog_id]['user_id'] || $auth->acl_get('m_blogreplyedit')) ? true : false;
                    break;
                case 'delete':
                    if (blog_data::$reply[$reply_id]['reply_deleted'] == 0 || $auth->acl_get('a_blogreplydelete')) {
                        $is_auth = $user->data['user_id'] != ANONYMOUS && ($auth->acl_get('u_blogreplydelete') && $user->data['user_id'] == blog_data::$reply[$reply_id]['user_id'] || isset(blog_data::$blog[$blog_id]['user_id']) && $auth->acl_get('u_blogmoderate') && $user->data['user_id'] == blog_data::$blog[$blog_id]['user_id'] || $auth->acl_gets('a_blogreplydelete', 'm_blogreplydelete')) ? true : false;
                    } else {
                        $is_auth = false;
                    }
                    break;
                case 'undelete':
                    $is_auth = $auth->acl_gets('m_blogreplydelete', 'a_blogreplydelete') || blog_data::$reply[$reply_id]['reply_deleted'] == $user->data['user_id'] ? true : false;
                    break;
                case 'report':
                    $is_auth = $auth->acl_get('u_blogreport') ? true : false;
                    break;
                case 'approve':
                    $is_auth = $auth->acl_get('m_blogreplyapprove') ? true : false;
                    break;
            }
            break;
        case 'mcp':
            $is_auth = $auth->acl_gets('m_blogapprove', 'acl_m_blogreport') ? true : false;
            break;
        case 'rate':
            $is_auth = $user->data['is_registered'] ? true : false;
            break;
        case 'install':
        case 'update':
        case 'upgrade':
        case 'dev':
        case 'resync':
            $is_auth = $user->data['user_type'] == USER_FOUNDER ? true : false;
            $founder = true;
            break;
    }
    $temp = compact('is_auth', 'page', 'mode', 'blog_id', 'reply_id');
    blog_plugins::plugin_do_ref('permissions_end', $temp);
    extract($temp);
    // if $is_auth hasn't been set yet they are just viewing a blog/user/etc, if it has been set also check to make sure they can view blogs
    if (!isset($is_auth)) {
        $is_auth = $auth->acl_get('u_blogview') ? true : false;
    } else {
        // if it is the install page they will not have viewing permissions, but they already need to be a founder :P
        $is_auth = !$auth->acl_get('u_blogview') && $page != 'install' ? false : $is_auth;
    }
    if (!$return) {
        if (!$is_auth) {
            if (!$user->data['is_registered']) {
                global $template;
                $template->set_template();
                // reset the template.  Required because of user styles.
                login_box();
            } else {
                if (isset($founder) && $founder) {
                    trigger_error('MUST_BE_FOUNDER');
                } else {
                    trigger_error('NO_AUTH_OPERATION');
                }
            }
        }
    } else {
        return $is_auth;
    }
}
コード例 #12
0
ファイル: blog.php プロジェクト: EXreaction/User-Blog-Mod
// If some of the pages needed extra language files included, add them now.
if (isset($add_lang)) {
    $user->add_lang($add_lang);
}
if ($blog_id) {
    $subscribed = get_subscription_info($blog_id);
    $subscribed_title = $subscribed ? $user->lang['UNSUBSCRIBE_BLOG'] : $user->lang['SUBSCRIBE_BLOG'];
} else {
    if ($user_id) {
        $subscribed = get_subscription_info(false, $user_id);
        $subscribed_title = $subscribed ? $user->lang['UNSUBSCRIBE_USER'] : $user->lang['SUBSCRIBE_USER'];
    }
}
// Generate the common URL's
generate_blog_urls();
// Include the file(s) we need for the page.
if (!is_array($inc_file)) {
    include $phpbb_root_path . 'blog/' . $inc_file . '.' . $phpEx;
} else {
    foreach ($inc_file as $file) {
        include $phpbb_root_path . 'blog/' . $file . '.' . $phpEx;
    }
}
// Lets add credits for the User Blog Mod.  This is not the best way to do it, but it makes it so the person installing it has 1 less edit to do per style
// Sounds like the mod team will not accept this, so we are commenting it out for now and having the user just do the extra edit for each style.
//$user->lang['TRANSLATION_INFO'] = (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['BLOG_CREDITS'] . '<br />' . $user->lang['TRANSLATION_INFO'] : $user->lang['BLOG_CREDITS'];
// Add some data to the template
$template->assign_vars(array('MODE' => $mode, 'PAGE' => $page, 'BLOG_TITLE' => isset($user_settings[$user_id]) ? censor_text($user_settings[$user_id]['title']) : false, 'BLOG_DESCRIPTION' => isset($user_settings[$user_id]) ? generate_text_for_display($user_settings[$user_id]['description'], $user_settings[$user_id]['description_bbcode_uid'], $user_settings[$user_id]['description_bbcode_bitfield'], 7) : false, 'BLOG_CREDITS' => $user->lang['BLOG_CREDITS'], 'U_ADD_BLOG' => check_blog_permissions('blog', 'add', true) ? $blog_urls['add_blog'] : '', 'U_BLOG_MCP' => $auth->acl_gets('m_blogapprove', 'm_blogreport', 'm_blogreplyapprove', 'm_blogreplyreport') ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=blog') : '', 'U_BLOG_SELF' => $blog_urls['self_minus_print'], 'U_REPLY_BLOG' => $blog_id && check_blog_permissions('reply', 'add', true, $blog_id) ? $blog_urls['add_reply'] : '', 'U_VIEW_RESULTS' => $blog_urls['viewpoll'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_POST_ACTION' => $blog_urls['self'], 'S_POLL_ACTION' => $blog_urls['vote'], 'S_PRINT_MODE' => $print, 'S_WATCH_FORUM_TITLE' => $subscribed_title, 'S_WATCH_FORUM_LINK' => $subscribed ? $blog_urls['unsubscribe'] : ($user->data['user_id'] != $user_id || $blog_id ? $blog_urls['subscribe'] : ''), 'S_WATCHING_FORUM' => $subscribed, 'L_USERNAMES_BLOGS' => $username == $user->data['username'] ? $user->lang['MY_BLOG'] : sprintf($user->lang['USERNAMES_BLOGS'], $username), 'UA_GREY_STAR_SRC' => $blog_images_path . 'star_grey.gif', 'UA_GREEN_STAR_SRC' => $blog_images_path . 'star_green.gif', 'UA_RED_STAR_SRC' => $blog_images_path . 'star_red.gif', 'UA_ORANGE_STAR_SRC' => $blog_images_path . 'star_orange.gif', 'UA_MAX_RATING' => $config['user_blog_max_rating'], 'UA_MIN_RATING' => $config['user_blog_min_rating'], 'REPLY_IMG' => $user->img('button_topic_reply', 'POST_A_NEW_REPLY'), 'POLL_LEFT_CAP_IMG' => $user->img('poll_left'), 'POLL_RIGHT_CAP_IMG' => $user->img('poll_right'), 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'), 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'), 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'), 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'), 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'), 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'), 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'), 'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE')));
blog_plugins::plugin_do('blog_end');
// setup the page footer
page_footer();
コード例 #13
0
/**
* Get all blog categories
*/
function get_blog_categories($order = 'left_id')
{
    global $cache;
    $blog_categories = $cache->get('_blog_categories');
    if ($blog_categories === false) {
        global $db;
        $blog_categories = array();
        $sql = 'SELECT * FROM ' . BLOGS_CATEGORIES_TABLE . "\n\t\t\tORDER BY left_id ASC";
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $blog_categories[$row['left_id']] = $row;
        }
        $db->sql_freeresult($result);
        $cache->put('_blog_categories', $blog_categories);
    }
    if ($order != 'left_id') {
        $blog_cats = $blog_categories;
        $blog_categories = array();
        foreach ($blog_cats as $left_id => $row) {
            $blog_categories[$row[$order]] = $row;
        }
    }
    blog_plugins::plugin_do_ref('function_get_blog_categories', $blog_categories);
    return $blog_categories;
}
コード例 #14
0
ファイル: main.php プロジェクト: EXreaction/User-Blog-Mod
        $random_blog_ids = $blog_data->get_blog_data('random', 0, array('limit' => 1, 'category_id' => $category_id));
        $recent_blog_ids = $blog_data->get_blog_data('recent', 0, array('limit' => $limit, 'category_id' => $category_id));
        $recent_reply_ids = $blog_data->get_reply_data('recent', 0, array('limit' => $limit, 'category_id' => $category_id));
        $blog_data->get_user_data(false, true);
        update_edit_delete();
        // Output the random blog(s)
        if ($random_blog_ids !== false) {
            $template->assign_vars(array('S_RANDOM_BLOG' => true));
            // I've decided to use a foreach to display the random blogs so it is easier to change the limit if the board owner would like...
            foreach ($random_blog_ids as $id) {
                $template->assign_block_vars('random', array_merge($blog_data->handle_user_data(blog_data::$blog[$id]['user_id']), $blog_data->handle_blog_data($id, $config['user_blog_user_text_limit'])));
            }
        }
        // Output the recent blogs
        $template->assign_block_vars('column', array('SECTION_WIDTH' => '50', 'U_FEED' => $config['user_blog_enable_feeds'] ? blog_url(false, false, false, array('mode' => 'recent_blogs', 'feed' => 'explain')) : '', 'U_VIEW' => blog_url(false, false, false, array('mode' => 'recent_blogs')), 'TITLE' => $user->lang['RECENT_BLOGS'], 'L_NO_MSG' => $user->lang['NO_BLOGS']));
        if ($recent_blog_ids !== false) {
            foreach ($recent_blog_ids as $id) {
                $template->assign_block_vars('column.row', array_merge($blog_data->handle_user_data(blog_data::$blog[$id]['user_id']), $blog_data->handle_blog_data($id, $config['user_blog_text_limit'])));
            }
        }
        // Output the recent comments
        $template->assign_block_vars('column', array('SECTION_WIDTH' => '50', 'U_FEED' => $config['user_blog_enable_feeds'] ? blog_url(false, false, false, array('mode' => 'recent_comments', 'feed' => 'explain')) : '', 'U_VIEW' => blog_url(false, false, false, array('mode' => 'recent_comments')), 'TITLE' => $user->lang['RECENT_COMMENTS'], 'L_NO_MSG' => $user->lang['NO_REPLIES']));
        if ($recent_reply_ids !== false) {
            foreach ($recent_reply_ids as $id) {
                $template->assign_block_vars('column.row', array_merge($blog_data->handle_user_data(blog_data::$reply[$id]['user_id']), $blog_data->handle_reply_data($id, $config['user_blog_text_limit'])));
            }
        }
        $template->set_filenames(array('body' => 'blog/view_blog_main.html'));
}
blog_plugins::plugin_do('view_main_end');
コード例 #15
0
ファイル: report.php プロジェクト: EXreaction/User-Blog-Mod
}
// Was Cancel pressed? If so then redirect to the appropriate page
if ($cancel) {
    blog_meta_refresh(0, $blog_urls['view_reply'], true);
}
// Add the language Variables for the MCP
$user->add_lang('mcp');
// Setup the page header and sent the title of the page that will go into the browser header
page_header($user->lang['REPORT_REPLY']);
// Generate the breadcrumbs
generate_blog_breadcrumbs($user->lang['REPORT_REPLY']);
blog_plugins::plugin_do('reply_report');
// To close the reports
if (blog_data::$reply[$reply_id]['reply_reported'] && $auth->acl_get('m_blogreplyreport')) {
    if (confirm_box(true)) {
        blog_plugins::plugin_do('reply_report_confirm');
        $sql = 'UPDATE ' . BLOGS_REPLY_TABLE . '
			SET reply_reported = 0
			WHERE reply_id = ' . intval($reply_id);
        $db->sql_query($sql);
        handle_blog_cache('report_reply', $user_id);
        blog_meta_refresh(3, $blog_urls['view_reply']);
        $message = $user->lang['REPORT_CLOSED_SUCCESS'] . '<br /><br />';
        $message .= '<a href="' . $blog_urls['view_reply'] . '">' . $user->lang['VIEW_REPLY'] . '</a><br />';
        $message .= '<a href="' . $blog_urls['view_blog'] . '">' . $user->lang['VIEW_BLOG'] . '</a><br />';
        if ($user_id == $user->data['user_id']) {
            $message .= sprintf($user->lang['RETURN_BLOG_OWN'], '<a href="' . $blog_urls['view_user'] . '">', '</a>');
        } else {
            $message .= sprintf($user->lang['RETURN_BLOG_MAIN'], '<a href="' . $blog_urls['view_user'] . '">', blog_data::$user[$user_id]['username'], '</a>') . '<br />';
            $message .= sprintf($user->lang['RETURN_BLOG_OWN'], '<a href="' . $blog_urls['view_user_self'] . '">', '</a>');
        }
コード例 #16
0
ファイル: user.php プロジェクト: EXreaction/User-Blog-Mod
        }
    }
    // Output some data
    $template->assign_vars(array('META' => '<link rel="canonical" href="' . blog_url($user_id, false, false, $start > 0 ? array('start' => $start) : array()) . '" />', 'PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($total_blogs, $limit, $start), 'TOTAL_POSTS' => $total_blogs == 1 ? $user->lang['ONE_BLOG'] : sprintf($user->lang['CNT_BLOGS'], $total_blogs), 'U_BLOG_FEED' => $config['user_blog_enable_feeds'] ? blog_url($user_id, false, false, array('feed' => 'explain')) : '', 'U_PRINT_TOPIC' => !$user->data['is_bot'] ? $blog_urls['self_print'] : '', 'U_VIEW' => $blog_urls['self'], 'S_SORT' => true, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_VIEW_REPLY_COUNT' => true, 'L_NO_DELETED_BLOGS' => $sort_days == 0 ? $user->lang['NO_DELETED_BLOGS'] : sprintf($user->lang['NO_DELETED_BLOGS_SORT_DAYS'], $limit_days[$sort_days]), 'L_NO_BLOGS_USER' => $sort_days == 0 ? $user->lang['NO_BLOGS_USER'] : sprintf($user->lang['NO_BLOGS_USER_SORT_DAYS'], $limit_days[$sort_days]), 'BLOG_CSS' => isset($user_settings[$user_id]['blog_css']) ? $user_settings[$user_id]['blog_css'] : ''));
    unset($pagination);
    // parse and output the blogs
    if ($blog_ids !== false) {
        // Get the Attachment Data
        get_attachment_data($blog_ids, false);
        // read blogs, for updating the read count
        $read_blogs = array();
        foreach ($blog_ids as $id) {
            $blogrow = array_merge($blog_data->handle_user_data(blog_data::$blog[$id]['user_id']), $blog_data->handle_blog_data($id, $config['user_blog_user_text_limit']));
            $template->assign_block_vars('blogrow', $blogrow);
            if (!$blogrow['S_SHORTENED']) {
                // for updating the read count later
                array_push($read_blogs, $id);
            }
        }
        // to update the read count, we are only doing this if the user is not the owner, and the user doesn't view the shortened version, and we are not viewing the deleted blogs page
        if ($user->data['user_id'] != $user_id && $mode != 'deleted' && sizeof($read_blogs)) {
            $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_read_count = blog_read_count + 1 WHERE ' . $db->sql_in_set('blog_id', $read_blogs);
            $db->sql_query($sql);
        }
        unset($read_blogs);
    }
    blog_plugins::plugin_do('view_user_end');
    $template->set_filenames(array('body' => 'blog/view_blog.html'));
} else {
    feed_output($blog_ids, $feed);
}
コード例 #17
0
 function plugins($id, $mode)
 {
     global $config, $db, $user, $auth, $template;
     global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
     if (blog_plugins::load_all_plugins() === false) {
         trigger_error('PLUGINS_DISABLED');
     }
     $submit = isset($_POST['submit']) ? true : false;
     $action = request_var('action', '');
     $action_to = request_var('name', '');
     $this->tpl_name = 'acp_blog_plugins';
     $this->page_title = 'ACP_BLOG_PLUGINS';
     $template->assign_vars(array('U_ACTION' => $this->u_action));
     switch ($action) {
         case 'activate':
             blog_plugins::plugin_enable($action_to);
             break;
         case 'deactivate':
             blog_plugins::plugin_disable($action_to);
             break;
         case 'install':
             blog_plugins::plugin_install($action_to);
             break;
         case 'uninstall':
             if (confirm_box(true)) {
                 blog_plugins::plugin_uninstall($action_to);
             } else {
                 confirm_box(false, 'PLUGIN_UNINSTALL');
             }
             break;
         case 'update':
             blog_plugins::plugin_update($action_to);
             break;
         case 'move_up':
         case 'move_down':
             blog_plugins::plugin_move($action_to, $action);
             // We need to do a redirect here because the plugins list is not shown correctly after one is moved...and I see no easy way to resync the list
             redirect($this->u_action);
             break;
     }
     $i = 0;
     $installed_plugins = array();
     foreach (blog_plugins::$available_plugins as $name => $data) {
         $i++;
         $installed = array_key_exists($name, blog_plugins::$plugins) ? true : false;
         $active = $installed && blog_plugins::$plugins[$name]['plugin_enabled'] ? true : false;
         $s_actions = array();
         if ($installed) {
             if ($active) {
                 $s_actions[] = '<a href="' . $this->u_action . "&amp;action=deactivate&amp;name=" . $name . '">' . $user->lang['PLUGIN_DEACTIVATE'] . '</a>';
                 $s_actions[] = '<a href="' . $this->u_action . "&amp;action=uninstall&amp;name=" . $name . '">' . $user->lang['PLUGIN_UNINSTALL'] . '</a>';
             } else {
                 $s_actions[] = '<a href="' . $this->u_action . "&amp;action=activate&amp;name=" . $name . '">' . $user->lang['PLUGIN_ACTIVATE'] . '</a>';
                 $s_actions[] = '<a href="' . $this->u_action . "&amp;action=uninstall&amp;name=" . $name . '">' . $user->lang['PLUGIN_UNINSTALL'] . '</a>';
             }
             if ($i > 1) {
                 $s_actions[] = '<a href="' . $this->u_action . "&amp;action=move_up&amp;name=" . $name . '">' . $user->lang['MOVE_UP'] . '</a>';
             }
             if ($i != sizeof(blog_plugins::$plugins)) {
                 $s_actions[] = '<a href="' . $this->u_action . "&amp;action=move_down&amp;name=" . $name . '">' . $user->lang['MOVE_DOWN'] . '</a>';
             }
             if ($data['plugin_version'] != blog_plugins::$plugins[$name]['plugin_version']) {
                 $version = array('files' => explode('.', $data['plugin_version']), 'db' => explode('.', blog_plugins::$plugins[$name]['plugin_version']));
                 $i = 0;
                 $newer_files = false;
                 foreach ($version['files'] as $v) {
                     if ($v > $version['db'][$i]) {
                         $newer_files = true;
                         break;
                     } else {
                         if ($v < $version['db'][$i]) {
                             break;
                         }
                     }
                     $i++;
                 }
                 if ($newer_files) {
                     $s_actions[] = '<a href="' . $this->u_action . "&amp;action=update&amp;name=" . $name . '">' . $user->lang['PLUGIN_UPDATE'] . '</a>';
                 }
             }
         } else {
             $s_actions[] = '<a href="' . $this->u_action . "&amp;action=install&amp;name=" . $name . '">' . $user->lang['PLUGIN_INSTALL'] . '</a>';
         }
         if ($installed) {
             $installed_plugins[$name] = array('NAME' => isset($data['plugin_title']) ? $data['plugin_title'] : $name, 'DESCRIPTION' => isset($data['plugin_description']) ? $data['plugin_description'] : '', 'S_ACTIONS' => implode(' | ', $s_actions), 'COPYRIGHT' => isset($data['plugin_copyright']) ? $data['plugin_copyright'] : '', 'DATABASE_VERSION' => $installed ? blog_plugins::$plugins[$name]['plugin_version'] : false, 'FILES_VERSION' => isset($data['plugin_version']) ? $data['plugin_version'] : '');
         } else {
             $template->assign_block_vars('uninstalled', array('NAME' => isset($data['plugin_title']) ? $data['plugin_title'] : $name, 'DESCRIPTION' => isset($data['plugin_description']) ? $data['plugin_description'] : '', 'S_ACTIONS' => implode(' | ', $s_actions), 'COPYRIGHT' => isset($data['plugin_copyright']) ? $data['plugin_copyright'] : '', 'DATABASE_VERSION' => $installed ? blog_plugins::$plugins[$name]['plugin_version'] : false, 'FILES_VERSION' => isset($data['plugin_version']) ? $data['plugin_version'] : ''));
         }
     }
     foreach (blog_plugins::$plugins as $name => $row) {
         $template->assign_block_vars('installed', $installed_plugins[$name]);
     }
 }
コード例 #18
0
function tags_function_handle_basic_posting_data(&$args)
{
    global $blog_id, $template, $user;
    if ($args['page'] != 'blog') {
        return;
    }
    $args['panels']['tags-panel'] = $user->lang['TAGS'];
    $tags = '';
    if ($args['mode'] == 'edit' && isset(blog_data::$blog[$blog_id]['blog_tags'])) {
        $tags = implode("\n", get_tags_from_text(blog_data::$blog[$blog_id]['blog_tags']));
    }
    $template->assign_vars(array('TAGS' => request_var('tags', $tags, true)));
    $args['panel_data'] = blog_plugins::parse_template('blog/plugins/tags/tags_panel.html');
}
コード例 #19
0
ファイル: add.php プロジェクト: EXreaction/User-Blog-Mod
    handle_basic_posting_data(false, 'reply');
    // Assign some variables to the template parser
    $template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'MESSAGE' => $reply_text, 'SUBJECT' => $reply_subject, 'L_MESSAGE_BODY_EXPLAIN' => intval($config['max_post_chars']) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '', 'L_POST_A' => $user->lang['POST_A_NEW_REPLY']));
    $template->set_filenames(array('body' => 'blog/blog_posting_layout.html'));
} else {
    // insert array, not all of these really need to be inserted, since some are what the fields are as default, but I want it this way. :P
    $sql_data = array('blog_id' => $blog_id, 'user_id' => $user->data['user_id'], 'user_ip' => $user->data['user_ip'], 'reply_time' => time(), 'reply_subject' => $reply_subject, 'reply_text' => $message_parser->message, 'reply_checksum' => md5($message_parser->message), 'reply_approved' => $auth->acl_get('u_blogreplynoapprove') ? 1 : 0, 'enable_bbcode' => $post_options->enable_bbcode, 'enable_smilies' => $post_options->enable_smilies, 'enable_magic_url' => $post_options->enable_magic_url, 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'reply_edit_reason' => '', 'reply_attachment' => sizeof($blog_attachment->attachment_data) ? 1 : 0);
    blog_plugins::plugin_do_ref('reply_add_sql', $sql_data);
    $sql = 'INSERT INTO ' . BLOGS_REPLY_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data);
    $db->sql_query($sql);
    $reply_id = $db->sql_nextid();
    $blog_search->index('add', $blog_id, $reply_id, $message_parser->message, $reply_subject, $user->data['user_id']);
    // update the URLS to include the new reply_id
    generate_blog_urls();
    $blog_attachment->update_attachment_data(false, $reply_id);
    blog_plugins::plugin_do_arg('reply_add_after_sql', $reply_id);
    // Handle the subscriptions
    add_blog_subscriptions($blog_id, 'subscription_');
    handle_blog_cache('add_reply', $user_id);
    // update the reply count for the blog
    if ($sql_data['reply_approved']) {
        $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_reply_count = blog_reply_count + 1, blog_real_reply_count = blog_real_reply_count + 1 WHERE blog_id = ' . intval($blog_id);
        $db->sql_query($sql);
        set_config('num_blog_replies', ++$config['num_blog_replies'], true);
        handle_subscription('new_reply', censor_text($reply_subject), 0, $blog_id, $reply_id);
    } else {
        $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_real_reply_count = blog_real_reply_count + 1 WHERE blog_id = ' . intval($blog_id);
        $db->sql_query($sql);
        inform_approve_report('reply_approve', $reply_id);
    }
    $message = (!$sql_data['reply_approved'] ? $user->lang['REPLY_NEED_APPROVE'] : $user->lang['REPLY_SUBMIT_SUCCESS']) . '<br /><br />';
コード例 #20
0
ファイル: mcp_blog.php プロジェクト: EXreaction/User-Blog-Mod
 function main($id, $mode)
 {
     global $auth, $db, $user, $template;
     global $config, $phpbb_root_path, $phpEx, $action;
     global $blog_data, $blog_plugins, $blog_urls;
     $user->add_lang(array('mods/blog/common', 'mods/blog/mcp'));
     // include some files
     include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
     include $phpbb_root_path . 'blog/functions.' . $phpEx;
     // set some initial variables that we will use
     $blog_data = new blog_data();
     blog_plugins::plugin_do('mcp_start');
     $blog = strpos($mode, 'blogs') ? true : false;
     $start = request_var('start', 0);
     $limit = request_var('limit', 10);
     $sort_days = request_var('st', !empty($user->data['user_post_show_days']) ? $user->data['user_post_show_days'] : 0);
     $sort_key = request_var('sk', 't');
     $sort_dir = request_var('sd', 'd');
     $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
     $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
     $order_dir = $sort_dir == 'a' ? 'ASC' : 'DESC';
     if ($blog) {
         $sort_by_text = array('t' => $user->lang['POST_TIME']);
         $sort_by_sql = array('t' => 'blog_time');
     } else {
         $sort_by_text = array('t' => $user->lang['POST_TIME']);
         $sort_by_sql = array('t' => 'reply_time');
     }
     generate_blog_urls();
     $this->tpl_name = 'blog/mcp_blog';
     $this->page_title = $user->lang['MCP_BLOG_' . strtoupper($mode)];
     $template->assign_vars(array('L_TITLE' => $user->lang['MCP_BLOG_' . strtoupper($mode)], 'L_EXPLAIN' => $user->lang['MCP_BLOG_' . strtoupper($mode) . '_EXPLAIN'], 'S_BLOGS' => $blog, 'S_REPLIES' => !$blog));
     $extra_data = array('start' => $start, 'limit' => $limit, 'order_by' => $sort_by_sql[$sort_key], 'order_dir' => $order_dir, 'sort_days' => $sort_days);
     switch ($mode) {
         // Need to add counts here...
         case 'reported_blogs':
             $ids = $blog_data->get_blog_data('reported', false, $extra_data);
             break;
         case 'reported_replies':
             $ids = $blog_data->get_reply_data('reported', false, $extra_data);
             break;
         case 'disapproved_blogs':
             $ids = $blog_data->get_blog_data('disapproved', false, $extra_data);
             break;
         case 'disapproved_replies':
             $ids = $blog_data->get_reply_data('disapproved', false, $extra_data);
             break;
         default:
             blog_plugins::plugin_do_arg('mcp_default', $mode);
     }
     if ($blog) {
         $cnt_sql = 'SELECT count(blog_id) AS total FROM ' . BLOGS_TABLE . ' WHERE blog_' . (strpos($mode, 'reported') !== false ? 'reported = 1' : 'approved = 0');
     } else {
         $cnt_sql = 'SELECT count(reply_id) AS total FROM ' . BLOGS_REPLY_TABLE . ' WHERE ' . 'reply_' . (strpos($mode, 'reported') !== false ? 'reported = 1' : 'approved = 0');
     }
     $result = $db->sql_query($cnt_sql);
     $row = $db->sql_fetchrow($result);
     if ($row) {
         $count = $row['total'];
     }
     $db->sql_freeresult($result);
     unset($row, $cnt_sql);
     if ($ids === false) {
         $ids = array();
     }
     $blog_data->get_user_data(false, true);
     if ($blog) {
         $total_posts = $count == 1 ? $user->lang['ONE_BLOG'] : sprintf($user->lang['CNT_BLOGS'], $count);
         foreach ($ids as $id) {
             $user_id = blog_data::$blog[$id]['user_id'];
             $template->assign_block_vars('postrow', array('U_VIEW' => blog_url($user_id, $id), 'SUBJECT' => blog_data::$blog[$id]['blog_subject'], 'AUTHOR' => blog_data::$user[$user_id]['username_full'], 'TIME' => $user->format_date(blog_data::$blog[$id]['blog_time'])));
         }
     } else {
         $total_posts = $count == 1 ? $user->lang['ONE_REPLY'] : sprintf($user->lang['CNT_REPLIES'], $count);
         foreach ($ids as $id) {
             $user_id = blog_data::$reply[$id]['user_id'];
             $blog_id = blog_data::$reply[$id]['blog_id'];
             $template->assign_block_vars('postrow', array('U_VIEW' => blog_url($user_id, $blog_id, $id), 'SUBJECT' => blog_data::$reply[$id]['reply_subject'], 'AUTHOR' => blog_data::$user[$user_id]['username_full'], 'TIME' => $user->format_date(blog_data::$reply[$id]['reply_time'])));
         }
     }
     gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
     $pagination = generate_pagination($this->u_action . "&amp;limit={$limit}&amp;st={$sort_days}&amp;sk={$sort_key}&amp;sd={$sort_dir}", $count, $limit, $start, false);
     $template->assign_vars(array('PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($count, $limit, $start), 'TOTAL_POSTS' => $total_posts, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days));
     blog_plugins::plugin_do('mcp_end');
 }
コード例 #21
0
ファイル: ucp_blog.php プロジェクト: EXreaction/User-Blog-Mod
 function main($id, $mode)
 {
     global $auth, $cache, $template, $user, $db, $config, $phpEx, $phpbb_root_path;
     global $blog_plugins, $blog_plugins_path, $user_settings;
     $preview = isset($_POST['preview']) ? true : false;
     $submit = isset($_POST['submit']) ? true : false;
     $error = array();
     $user->add_lang(array('mods/blog/common', 'mods/blog/ucp'));
     include $phpbb_root_path . 'blog/functions.' . $phpEx;
     blog_plugins::plugin_do('ucp_start');
     get_user_settings($user->data['user_id']);
     switch ($mode) {
         case 'ucp_blog_settings':
             $subscription_types = get_blog_subscription_types();
             if ($submit) {
                 $sql_ary = array('instant_redirect' => request_var('instant_redirect', 0), 'blog_subscription_default' => 0, 'blog_style' => $auth->acl_get('u_blog_style') ? request_var('blog_style', '') : '', 'blog_css' => $auth->acl_get('u_blog_css') ? request_var('blog_css', '') : '');
                 if ($config['user_blog_subscription_enabled']) {
                     foreach ($subscription_types as $type => $name) {
                         if (request_var('subscription_' . $type, false)) {
                             $sql_ary['blog_subscription_default'] += $type;
                         }
                     }
                 }
                 update_user_blog_settings($user->data['user_id'], $sql_ary);
             } else {
                 if ($config['user_blog_subscription_enabled']) {
                     $subscribed = array();
                     if (isset($user_settings[$user->data['user_id']])) {
                         foreach ($subscription_types as $type => $name) {
                             // Bitwise check
                             if ($user_settings[$user->data['user_id']]['blog_subscription_default'] & $type) {
                                 $subscribed[$type] = true;
                             }
                         }
                     }
                     foreach ($subscription_types as $type => $name) {
                         $template->assign_block_vars('subscriptions', array('TYPE' => 'subscription_' . $type, 'NAME' => isset($user->lang[$name]) ? $user->lang[$name] : $name, 'S_CHECKED' => isset($subscribed[$type]) ? true : false));
                     }
                 }
                 if ($auth->acl_get('u_blog_style')) {
                     $available_styles = array(array('name' => $user->lang['NONE'], 'value' => 0, 'demo' => $phpbb_root_path . 'images/spacer.gif'));
                     $sql = 'SELECT * FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' st WHERE style_active = 1 AND s.template_id = st.template_id';
                     $result = $db->sql_query($sql);
                     while ($row = $db->sql_fetchrow($result)) {
                         $demo = $phpbb_root_path . 'images/spacer.gif';
                         if (@file_exists($phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.png')) {
                             $demo = $phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.png';
                         } else {
                             if (@file_exists($phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.gif')) {
                                 $demo = $phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.gif';
                             } else {
                                 if (@file_exists($phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.jpg')) {
                                     $demo = $phpbb_root_path . 'styles/' . $row['template_path'] . '/template/blog/demo.jpg';
                                 }
                             }
                         }
                         $available_styles[] = array('name' => $row['style_name'], 'value' => $row['style_id'], 'demo' => $demo);
                     }
                     $db->sql_freeresult($result);
                     $dh = @opendir($phpbb_root_path . 'blog/styles/');
                     if ($dh) {
                         while (($file = readdir($dh)) !== false) {
                             if (file_exists($phpbb_root_path . 'blog/styles/' . $file . '/style.' . $phpEx)) {
                                 // Inside of the style.php file, add to the $available_styles array
                                 include $phpbb_root_path . 'blog/styles/' . $file . '/style.' . $phpEx;
                             }
                         }
                         closedir($dh);
                     }
                     foreach ($available_styles as $row) {
                         if (isset($user_settings[$user->data['user_id']]) && $user_settings[$user->data['user_id']]['blog_style'] == $row['value'] && isset($row['demo']) && $row['demo']) {
                             $default_demo = $row['demo'];
                         }
                         $template->assign_block_vars('blog_styles', array('VALUE' => $row['value'], 'SELECTED' => isset($user_settings[$user->data['user_id']]) && $user_settings[$user->data['user_id']]['blog_style'] == $row['value'] ? true : false, 'NAME' => $row['name'], 'BLOG_CSS' => isset($row['blog_css']) && $row['blog_css'] ? true : false, 'DEMO' => isset($row['demo']) && $row['demo'] ? $row['demo'] : ''));
                     }
                 }
                 $template->assign_vars(array('S_BLOG_INSTANT_REDIRECT' => isset($user_settings[$user->data['user_id']]) ? $user_settings[$user->data['user_id']]['instant_redirect'] : 0, 'S_SUBSCRIPTIONS' => $config['user_blog_subscription_enabled'] ? true : false, 'S_BLOG_STYLE' => isset($available_styles) && sizeof($available_styles) > 1 ? true : false, 'S_BLOG_CSS' => $auth->acl_get('u_blog_css') ? true : false, 'DEFAULT_DEMO' => isset($default_demo) ? $default_demo : $phpbb_root_path . 'images/spacer.gif', 'BLOG_CSS' => isset($user_settings[$user->data['user_id']]) ? $user_settings[$user->data['user_id']]['blog_css'] : ''));
             }
             break;
         case 'ucp_blog_permissions':
             if (!$config['user_blog_user_permissions']) {
                 $error[] = $user->lang['USER_PERMISSIONS_DISABLED'];
                 $template->assign_vars(array('PERMISSIONS_DISABLED' => true));
             } else {
                 if ($submit) {
                     $sql_ary = array('perm_guest' => request_var('perm_guest', 1), 'perm_registered' => request_var('perm_registered', 2), 'perm_foe' => request_var('perm_foe', 0), 'perm_friend' => request_var('perm_friend', 2));
                     update_user_blog_settings($user->data['user_id'], $sql_ary, isset($_POST['resync']) ? true : false);
                 } else {
                     permission_settings_builder();
                 }
             }
             break;
         case 'ucp_blog_title_description':
             include $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
             include $phpbb_root_path . 'includes/message_parser.' . $phpEx;
             include $phpbb_root_path . 'blog/includes/functions_posting.' . $phpEx;
             if (!function_exists('display_custom_bbcodes')) {
                 include $phpbb_root_path . 'includes/functions_display.' . $phpEx;
             }
             $user->add_lang('posting');
             $post_options = new post_options();
             $post_options->set_status(true, true, true);
             $post_options->set_in_template();
             if ($submit || $preview) {
                 // see if they tried submitting a message or suject(if they hit preview or submit) put it in an array for consistency with the edit mode
                 $blog_title = utf8_normalize_nfc(request_var('title', '', true));
                 $blog_description = utf8_normalize_nfc(request_var('message', '', true));
                 // set up the message parser to parse BBCode, Smilies, etc
                 $message_parser = new parse_message();
                 $message_parser->message = $blog_description;
                 $message_parser->parse($post_options->enable_bbcode, $post_options->enable_magic_url, $post_options->enable_smilies, $post_options->img_status, $post_options->flash_status, $post_options->bbcode_status, $post_options->url_status);
             } else {
                 if (isset($user_settings[$user->data['user_id']])) {
                     $blog_title = $user_settings[$user->data['user_id']]['title'];
                     $blog_description = $user_settings[$user->data['user_id']]['description'];
                     decode_message($blog_description, $user_settings[$user->data['user_id']]['description_bbcode_uid']);
                 } else {
                     $blog_title = $blog_description = '';
                 }
             }
             if (!$submit || sizeof($error)) {
                 if ($preview && !sizeof($error)) {
                     $preview_message = $message_parser->format_display($post_options->enable_bbcode, $post_options->enable_magic_url, $post_options->enable_smilies, false);
                     // output some data to the template parser
                     $template->assign_vars(array('S_DISPLAY_PREVIEW' => true, 'PREVIEW_SUBJECT' => censor_text($blog_title), 'PREVIEW_MESSAGE' => $preview_message, 'POST_DATE' => $user->format_date(time())));
                 }
                 // Generate smiley listing
                 generate_smilies('inline', false);
                 // Build custom bbcodes array
                 display_custom_bbcodes();
                 $template->assign_vars(array('S_PREVIEW_BUTTON' => true, 'TITLE' => $blog_title, 'MESSAGE' => $blog_description));
             } else {
                 if ($submit) {
                     $sql_ary = array('user_id' => $user->data['user_id'], 'title' => $blog_title, 'description' => $message_parser->message, 'description_bbcode_bitfield' => $message_parser->bbcode_bitfield, 'description_bbcode_uid' => $message_parser->bbcode_uid);
                     unset($message_parser);
                     update_user_blog_settings($user->data['user_id'], $sql_ary);
                 }
             }
             break;
         default:
             $default = true;
             $temp = compact('mode', 'error', 'default');
             blog_plugins::plugin_do_ref('ucp_default', $temp);
             // make sure you set default to false if you use your own page
             extract($temp);
             if ($default) {
                 trigger_error('NO_MODE');
             }
     }
     blog_plugins::plugin_do('ucp_end');
     if ($submit && !sizeof($error)) {
         //$cache->destroy('_blog_settings_' . $user->data['user_id']);
         meta_refresh(3, $this->u_action);
         $message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
         trigger_error($message);
     }
     $template->assign_vars(array('L_TITLE' => $user->lang[strtoupper($mode)], 'L_TITLE_EXPLAIN' => $user->lang[strtoupper($mode) . '_EXPLAIN'], 'ERROR' => sizeof($error) ? implode($error, '<br />') : false, 'MODE' => $mode, 'S_UCP_ACTION' => $this->u_action));
     $this->tpl_name = 'blog/ucp_blog';
     $this->page_title = strtoupper($mode);
 }
コード例 #22
0
} else {
    if ($user_id != 0) {
        if (!$subscribed) {
            trigger_error('NOT_SUBSCRIBED');
        }
        if (confirm_box(true)) {
            blog_plugins::plugin_do('unsubscribe_user_confirm');
            $sql = 'DELETE FROM ' . BLOGS_SUBSCRIPTION_TABLE . '
			WHERE sub_user_id = ' . $user->data['user_id'] . '
				AND user_id = ' . intval($user_id);
            $db->sql_query($sql);
            //$cache->destroy("_blog_subscription_{$user_id}");
            $template->assign_vars(array('S_WATCH_FORUM_TITLE' => $user->lang['SUBSCRIBE_USER'], 'S_WATCH_FORUM_LINK' => $blog_urls['subscribe'], 'S_WATCHING_FORUM' => false));
            $message = $user->lang['SUBSCRIPTION_REMOVED'] . '<br /><br />';
            if ($user_id == $user->data['user_id']) {
                $message .= sprintf($user->lang['RETURN_BLOG_OWN'], '<a href="' . $blog_urls['view_user'] . '">', '</a>');
            } else {
                $message .= sprintf($user->lang['RETURN_BLOG_MAIN'], '<a href="' . $blog_urls['view_user'] . '">', blog_data::$user[$user_id]['username'], '</a>') . '<br />';
                $message .= sprintf($user->lang['RETURN_BLOG_OWN'], '<a href="' . $blog_urls['view_user_self'] . '">', '</a>');
            }
            blog_meta_refresh(3, $blog_urls['view_user']);
            trigger_error($message);
        } else {
            blog_plugins::plugin_do('unsubscribe_user');
            confirm_box(false, 'UNSUBSCRIBE_USER');
        }
    } else {
        trigger_error($user->lang['BLOG_USER_NOT_PROVIDED']);
    }
}
blog_meta_refresh(0, $blog_urls['main']);
コード例 #23
0
ファイル: single.php プロジェクト: EXreaction/User-Blog-Mod
get_attachment_data($blog_id, $reply_ids);
blog_plugins::plugin_do('view_blog_start');
// Output some data
$template->assign_vars(array('META' => '<link rel="canonical" href="' . blog_url($user_id, $blog_id, false, $start > 0 ? array('start' => $start) : array()) . '" />', 'BLOG_CSS' => isset($user_settings[$user_id]['blog_css']) ? $user_settings[$user_id]['blog_css'] : '', 'U_PRINT_TOPIC' => !$user->data['is_bot'] ? $blog_urls['self_print'] : '', 'U_VIEW' => $blog_urls['self'], 'S_CATEGORY_MODE' => $category_id ? true : false, 'S_SINGLE' => true, 'U_QUICK_REPLY' => blog_url($user_id, $blog_id, false, array('page' => 'reply', 'mode' => 'add')), 'S_QUICK_REPLY' => $user->data['is_registered'] && $config['user_blog_quick_reply'] ? true : false));
// Quick Reply
add_form_key('postform');
// Parse the blog data and output it to the template
$template->assign_block_vars('blogrow', array_merge($blog_data->handle_blog_data($blog_id), $blog_data->handle_user_data($user_id)));
blog_plugins::plugin_do('view_blog_after_blogrow');
// to update the read count, we are only doing this if the user is not the owner, and the user doesn't view the shortened version, and we are not viewing the deleted blogs page
if ($user->data['user_id'] != $user_id) {
    $sql = 'UPDATE ' . BLOGS_TABLE . ' SET blog_read_count = blog_read_count + 1 WHERE blog_id = ' . intval($blog_id);
    $db->sql_query($sql);
}
if ($total_replies > 0 || $sort_days != 0) {
    // for sorting and pagination
    gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
    $pagination = generate_blog_pagination($blog_urls['start_zero'], $total_replies, $limit, $start, false);
    $template->assign_vars(array('PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($total_replies, $limit, $start), 'TOTAL_POSTS' => $total_replies == 1 ? $user->lang['ONE_REPLY'] : sprintf($user->lang['CNT_REPLIES'], $total_replies), 'S_REPLIES' => true, 'S_SORT_REPLY' => true, 'S_SELECT_SORT_DIR' => $s_sort_dir, 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days));
    unset($pagination);
    // For the replies
    if ($reply_ids !== false) {
        // use a foreach to easily output the data
        foreach ($reply_ids as $id) {
            // send the data to the template
            $template->assign_block_vars('replyrow', array_merge($blog_data->handle_reply_data($id), $blog_data->handle_user_data(blog_data::$reply[$id]['user_id'])));
        }
    }
}
blog_plugins::plugin_do('view_blog_end');
$template->set_filenames(array('body' => 'blog/view_blog.html'));
コード例 #24
0
ファイル: delete.php プロジェクト: EXreaction/User-Blog-Mod
// Setup the page header and sent the title of the page that will go into the browser header
page_header($user->lang['DELETE_BLOG']);
// Generate the breadcrumbs
generate_blog_breadcrumbs($user->lang['DELETE_BLOG']);
if (blog_data::$blog[$blog_id]['blog_deleted'] != 0 && !$auth->acl_get('a_blogdelete')) {
    trigger_error('BLOG_ALREADY_DELETED');
}
$display_vars = array();
if ($auth->acl_get('a_blogdelete') && blog_data::$blog[$blog_id]['blog_deleted'] == 0) {
    $display_vars = array('legend1' => $user->lang['HARD_DELETE'], 'hard_delete' => array('lang' => 'HARD_DELETE', 'validate' => 'bool', 'type' => 'checkbox', 'default' => false, 'explain' => true));
}
blog_plugins::plugin_do_ref('blog_delete', $display_vars);
include "{$phpbb_root_path}blog/includes/functions_confirm.{$phpEx}";
$settings = blog_confirm('DELETE_BLOG', 'DELETE_BLOG_CONFIRM', $display_vars, 'yes/no');
if (is_array($settings)) {
    blog_plugins::plugin_do('blog_delete_confirm');
    // if it has already been soft deleted, and we want to hard delete it
    if ((isset($settings['hard_delete']) && $settings['hard_delete'] || blog_data::$blog[$blog_id]['blog_deleted'] != 0) && $auth->acl_get('a_blogdelete')) {
        // They selected the hard delete checkbox...so we must do a few things.
        if (blog_data::$blog[$blog_id]['blog_deleted'] == 0) {
            // Remove the search index
            $blog_search->index_remove($blog_id);
            // Update the blog_count for the user
            $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = blog_count - 1 WHERE user_id = ' . intval($user_id) . ' AND blog_count > 0';
            $db->sql_query($sql);
            set_config('num_blogs', --$config['num_blogs'], true);
            set_config('num_blog_replies', $config['num_blog_replies'] - blog_data::$blog[$blog_id]['blog_reply_count'], true);
            // Update the blog_count for all the categories it is in.
            put_blogs_in_cats($blog_id, array(), true, 'soft_delete');
        }
        // Delete the Attachments
コード例 #25
0
/**
* Obtain allowed extensions
*
* @return array allowed extensions array.
*/
function obtain_blog_attach_extensions()
{
    global $cache, $config;
    if (!$config['user_blog_enable_attachments']) {
        return;
    }
    if (($extensions = $cache->get('_blog_extensions')) === false) {
        global $db;
        $extensions = array('_allowed_blog' => array());
        // The rule is to only allow those extensions defined. ;)
        $sql = 'SELECT e.extension, g.*
			FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g
			WHERE e.group_id = g.group_id
				AND (g.allow_group = 1 OR g.allow_in_blog = 1)';
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $extension = strtolower(trim($row['extension']));
            $extensions[$extension] = array('display_cat' => (int) $row['cat_id'], 'download_mode' => (int) $row['download_mode'], 'upload_icon' => trim($row['upload_icon']), 'max_filesize' => (int) $row['max_filesize'], 'allow_group' => $row['allow_group'], 'allow_in_blog' => $row['allow_in_blog']);
            if ($row['allow_in_blog']) {
                $extensions['_allowed_blog'][$extension] = 0;
            }
        }
        $db->sql_freeresult($result);
        $cache->put('_blog_extensions', $extensions);
    }
    $return = array('_allowed_' => array());
    foreach ($extensions['_allowed_blog'] as $extension => $check) {
        $return['_allowed_'][$extension] = 0;
        $return[$extension] = $extensions[$extension];
    }
    blog_plugins::plugin_do_ref('function_obtain_blog_attach_extensions', $return);
    return $return;
}
コード例 #26
0
/**
* Get subscription types
*/
function get_blog_subscription_types()
{
    global $config, $blog_plugins;
    if (!$config['user_blog_subscription_enabled']) {
        return array();
    }
    // First is the subscription ID (which will use the bitwise operator), the second is the language variable.
    $subscription_types = array();
    if ($config['allow_privmsg']) {
        $subscription_types[1] = 'PRIVATE_MESSAGE';
    }
    if ($config['email_enable']) {
        $subscription_types[2] = 'EMAIL';
    }
    /* Remember, we use the bitwise operator to find out what subscription type is the users default, like the bbcode options.
    	So if you add more, use 1,2,4,8,16,32,64,etc and make sure to use the next available number, don't assume 4 is available! */
    blog_plugins::plugin_do_ref('function_get_subscription_types', $subscription_types);
    return $subscription_types;
}
コード例 #27
0
/**
* Build configuration template for confirm pages
*
* Originally from adm/index.php
*/
function build_blog_cfg_template($tpl_type, $name, $default)
{
    global $user;
    $tpl = '';
    $name = 'setting[' . $name . ']';
    switch ($tpl_type[0]) {
        case 'text':
        case 'password':
            $size = (int) $tpl_type[1];
            $maxlength = (int) $tpl_type[2];
            $tpl = '<input id="' . $name . '" type="' . $tpl_type[0] . '"' . ($size ? ' size="' . $size . '"' : '') . ' maxlength="' . ($maxlength ? $maxlength : 255) . '" name="' . $name . '" value="' . $default . '" />';
            break;
        case 'textarea':
            $rows = (int) $tpl_type[1];
            $cols = (int) $tpl_type[2];
            $tpl = '<textarea id="' . $name . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $default . '</textarea>';
            break;
        case 'radio':
            $name_yes = $default ? ' checked="checked"' : '';
            $name_no = !$default ? ' checked="checked"' : '';
            $tpl_type_cond = explode('_', $tpl_type[1]);
            $type_no = $tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled' ? false : true;
            $tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $name_no . ' class="radio" /> ' . ($type_no ? $user->lang['NO'] : $user->lang['DISABLED']) . '</label>';
            $tpl_yes = '<label><input type="radio" id="' . $name . '" name="' . $name . '" value="1"' . $name_yes . ' class="radio" /> ' . ($type_no ? $user->lang['YES'] : $user->lang['ENABLED']) . '</label>';
            $tpl = $tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled' ? $tpl_yes . ' ' . $tpl_no : $tpl_no . ' ' . $tpl_yes;
            break;
        case 'checkbox':
            $tpl = '<input type="checkbox" name="' . $name . '"  id="' . $name . '"' . ($default ? ' checked="checked"' : '') . ' />';
            break;
        default:
            $temp = compact('tpl_type', 'name', 'default', 'tpl');
            blog_plugins::plugin_do_ref('function_build_blog_cfg_template', $temp);
            extract($temp);
            break;
    }
    return $tpl;
}
コード例 #28
0
ファイル: approve.php プロジェクト: EXreaction/User-Blog-Mod
    trigger_error('BLOG_NOT_EXIST');
}
// Was Cancel pressed? If so then redirect to the appropriate page
if ($cancel) {
    blog_meta_refresh(0, $blog_urls['view_blog'], true);
}
// Add the language Variables for posting
$user->add_lang('posting');
// Setup the page header and sent the title of the page that will go into the browser header
page_header($user->lang['APPROVE_BLOG']);
// Generate the breadcrumbs
generate_blog_breadcrumbs($user->lang['APPROVE_BLOG']);
blog_plugins::plugin_do('blog_approve');
if (blog_data::$blog[$blog_id]['blog_approved'] == 0) {
    if (confirm_box(true)) {
        blog_plugins::plugin_do('blog_approve_confirm');
        $sql = 'UPDATE ' . BLOGS_TABLE . '
			SET blog_approved = 1
			WHERE blog_id = ' . intval($blog_id);
        $db->sql_query($sql);
        // Update the blog_count for the user
        $sql = 'UPDATE ' . USERS_TABLE . ' SET blog_count = blog_count + 1 WHERE user_id = ' . intval($user_id);
        $db->sql_query($sql);
        set_config('num_blogs', ++$config['num_blogs'], true);
        // Update the blog_count for all the categories it is in.
        $category_ids = array();
        $sql = 'SELECT category_id FROM ' . BLOGS_IN_CATEGORIES_TABLE . ' WHERE blog_id = ' . intval($blog_id);
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $category_ids[] = $row['category_id'];
        }
コード例 #29
0
ファイル: edit.php プロジェクト: EXreaction/User-Blog-Mod
} else {
    // insert array
    $sql_data = array('user_ip' => $user->data['user_id'] == $user_id ? $user->data['user_ip'] : blog_data::$blog[$blog_id]['user_ip'], 'blog_subject' => $blog_subject, 'blog_text' => $message_parser->message, 'blog_checksum' => md5($message_parser->message), 'blog_approved' => blog_data::$blog[$blog_id]['blog_approved'] == 1 || $auth->acl_get('u_blognoapprove') ? 1 : 0, 'enable_bbcode' => $post_options->enable_bbcode, 'enable_smilies' => $post_options->enable_smilies, 'enable_magic_url' => $post_options->enable_magic_url, 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'blog_edit_time' => time(), 'blog_edit_reason' => utf8_normalize_nfc(request_var('edit_reason', '', true)), 'blog_edit_user' => $user->data['user_id'], 'blog_edit_count' => blog_data::$blog[$blog_id]['blog_edit_count'] + 1, 'blog_edit_locked' => $auth->acl_get('m_bloglockedit') && $user->data['user_id'] != blog_data::$blog[$blog_id]['user_id'] ? request_var('lock_post', false) : false, 'perm_guest' => request_var('perm_guest', 1), 'perm_registered' => request_var('perm_registered', 2), 'perm_foe' => request_var('perm_foe', 0), 'perm_friend' => request_var('perm_friend', 2), 'blog_attachment' => sizeof($blog_attachment->attachment_data) ? 1 : 0, 'poll_title' => !empty($poll) ? $poll_title : '', 'poll_length' => !empty($poll) && $poll_length ? time() + $poll_length * 86400 : 0, 'poll_max_options' => !empty($poll) ? max($poll_max_options, 1) : 1, 'poll_vote_change' => !empty($poll) ? $poll_vote_change : 0);
    if ($original_poll_text != $poll_option_text) {
        $sql_data['poll_start'] = empty($poll) ? 0 : time();
    }
    blog_plugins::plugin_do_ref('blog_edit_sql', $sql_data);
    $sql = 'UPDATE ' . BLOGS_TABLE . '
		SET ' . $db->sql_build_array('UPDATE', $sql_data) . '
			WHERE blog_id = ' . intval($blog_id);
    $db->sql_query($sql);
    // Reindex the blog
    $blog_search->index('edit', $blog_id, 0, $message_parser->message, $blog_subject, $user_id);
    // Update the attachments
    $blog_attachment->update_attachment_data($blog_id, 0, blog_data::$blog[$blog_id]['user_id']);
    blog_plugins::plugin_do_arg('blog_edit_after_sql', $blog_id);
    // Submit the poll
    if ($auth->acl_get('u_blog_create_poll')) {
        submit_blog_poll($poll, $blog_id, 'edit');
    }
    // Handle the subscriptions
    add_blog_subscriptions($blog_id, 'subscription_');
    // Insert into the categories list
    if (sizeof($category_ary) > 1 || isset($category_ary[0]) && $category_ary[0] != 0) {
        $category_list = get_blog_categories('category_id');
        foreach ($category_ary as $i => $cat_id) {
            if (!isset($category_list[$cat_id])) {
                unset($category_ary[$i]);
            }
        }
    }
コード例 #30
0
ファイル: search.php プロジェクト: EXreaction/User-Blog-Mod
        $blog_data->get_user_data(false, true);
        update_edit_delete();
        foreach ($ids as $id) {
            if (isset($id['reply_id'])) {
                if (!$author || $uid == blog_data::$reply[$id['reply_id']]['user_id']) {
                    $template->assign_block_vars('searchrow', $blog_data->handle_reply_data($id['reply_id']) + $blog_data->handle_user_data(blog_data::$reply[$id['reply_id']]['user_id']));
                } else {
                    // they are selecting from a specific author and this is from a different author
                    $matches--;
                }
            } else {
                if (isset(blog_data::$blog[$id['blog_id']]) && (!$author || $uid == blog_data::$blog[$id['blog_id']]['user_id'])) {
                    $template->assign_block_vars('searchrow', $blog_data->handle_blog_data($id['blog_id']) + $blog_data->handle_user_data(blog_data::$blog[$id['blog_id']]['user_id']));
                } else {
                    // they don't have permission to view this blog, or they are selecting from a specific author and this is from a different author
                    $matches--;
                }
            }
        }
    } else {
        $matches = 0;
    }
    $pagination = generate_blog_pagination(blog_url(false, false, false, array('page' => 'search', 'author' => $author, 'keywords' => $keywords, 'terms' => $terms, 'sf' => $sf, 'start' => '*start*', 'limit' => $limit), array(), true), $matches, $limit, $start, false);
    $template->assign_vars(array('PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($matches, $limit, $start), 'TOTAL_POSTS' => $matches == 1 ? $user->lang['ONE_REPLY'] : sprintf($user->lang['CNT_REPLIES'], $matches), 'SEARCH_MATCHES' => $matches == 1 ? sprintf($user->lang['FOUND_SEARCH_MATCH'], $matches) : sprintf($user->lang['FOUND_SEARCH_MATCHES'], $matches), 'U_SEARCH_WORDS' => $search_url, 'SEARCH_WORDS' => $author . ' &bull; ' . $keywords));
    $template->set_filenames(array('body' => 'blog/search_results.html'));
} else {
    $template->assign_vars(array('U_BLOG_SEARCH' => blog_url(false, false, false, array('page' => 'search'), array(), true)));
    $template->set_filenames(array('body' => 'blog/search_body.html'));
}
blog_plugins::plugin_do('search_end');