_ck_ (@_ck_)

Forum Replies Created

Viewing 25 replies - 2,076 through 2,100 (of 2,186 total)

  • _ck_
    Participant

    @_ck_

    Okee, will try and report back in a minute.

    Thanks as always!

    *** cries tears of joy ****

    it works, yay!

    (note I had to manually delete the two options already inserted into bbpress to get it to load the entire plugin list)

    Wow, very nice work…

    idea: “power user toggle” that will turn the revision number into a hotlink to the svn directory so I can directly preview the source and maybe show the filesize since curl/fopen has to pull the entire file down anyway so it knows the size

    a tally at the bottom of how many plugins shown would be interesting to see too… will it paginate if one day there are over a hundred plugins?


    _ck_
    Participant

    @_ck_

    I think I found the answer to my question with a bit of sendmail/exim research.

    Apparently adding “-odq” to the end of the mail() options will force it to queue only, which means instant response back to the user. However that delays mail of course until the next exim run. “-odb” is supposed to be the default, running the delivery in the background and not while mail() waits, but I seem to get the best of both worlds, instant delivery and no wait on mail() when I force it, so forced it is.

    Recommended for other plugins that use mail:

    mail($to,$subject,$message,$headers,”-odb”);


    _ck_
    Participant

    @_ck_

    Automatically adding a user’s new topic to their own favorites is as simple as this plugin. I’ve unhooked the notification plugin so users don’t get emailed for their own new topics starting.

    <?php
    /*
    * Plugin Name: User Topics To Favorites
    * Plugin Description: automatically adds new topics created by a user to their favorites
    * Author: _ck_
    * Author URI: http://CKon.wordpress.com
    * Plugin URI: http://CKon.wordpress.com
    * Version: 0.1
    */

    function user_topics_to_favorites($topic_id) {
    remove_action('bb_new_post', 'notification_new_post'); // don't email users about their new topic
    $topic = get_topic( get_topic_id( $topic_id ) ); // fetch topic poster's id
    bb_add_user_favorite( $topic->topic_poster, $topic_id );
    }
    add_action('bb_new_topic', 'user_topics_to_favorites');

    ?>


    _ck_
    Participant

    @_ck_

    Oh sweet. Heading off to try it.

    Thanks for making it use curl.

    *pout* still no list…

    “The plugin list was updated from revision 0 to revision 519.”

    but I don’t see any plugins listed

    Warning: preg_match() expects parameter 2 to be string, array given in /home/example/public_html/forums/my-plugins/plugin-browser.php on line 309


    _ck_
    Participant

    @_ck_

    Update: I found the problem. It’s the same one I reported here:

    https://trac.bbpress.org/ticket/704

    If a forum page has sub-forums visible, it messes up any function that depends on calculating the current forum_id. It will instead return the last sub-forum’s id.

    So the pagination didn’t think there was anything to paginate.

    Should be interesting to see how they fix that.

    In reply to: forum.wp-persian.com

    _ck_
    Participant

    @_ck_

    That’s actually pretty impressive to see.

    I think I’ve seen wordpress/bbpress on some Israeli sites too but in Hebrew.


    _ck_
    Participant

    @_ck_

    Coming soon:

    don't allow reports on moderators
    don't allow reports from members less than x days old
    security check if user is in the right topic for the post being reported


    _ck_
    Participant

    @_ck_

    And a report post plugin is born – tested working!

    Needs a few features but gets the job done for now:

    <?php
    /*
    Plugin Name: report post
    Description: allows members to report a post to admin/moderators
    Plugin URI: http://CKon.wordpress.com
    Author: _ck_
    Author URI: http://CKon.wordpress.com
    Version: 0.1
    */

    /*
    instructions: install, activate and put <? report_post_link(); ?> in your post.php template where you want the link to be seen
    optional in stylesheet: a.report_post {color:red;}

    todo:
    1. don't let them report more than once on a post - or more than too many times per minute/hour
    2. auto-delete post if more than x reports from different members
    3. auto-post report into a specified moderator's forum #
    4. maybe ajax xmlhttp call instead of real form post so there's no page movement
    5. it's technically possible to alert a browing mod with a popup directing to the reported post, no email needed
    */

    function report_post_link($post_id=0) {
    if (bb_current_user_can('participate') ) :
    $post_id= get_post_id( $post_id );
    if (get_post_author_id($post_id) != bb_get_current_user_info( 'id' )) {
    echo '<a class=report_post title="report post to moderator" href="#post-'.$post_id.'" onClick="report_post('.$post_id.');return false;">Report</a>';
    }
    endif;
    }

    function report_post_form() {
    if (bb_current_user_can('participate')) :
    if (isset($_POST['report_post_id']) && isset($_POST['report_post_reason'])) {
    echo '<scr'.'ipt type="text/javascript">alert("Thank you for the report. A moderator has been notified.");</scr'.'ipt>';
    $post_id=intval($_POST['report_post_id']);
    // todo: custom response if invalid id, problem sending email - maybe flush output buffer so member gets alert faster
    $to = bb_get_option('admin_email');
    $subject = " reported post by member for moderation";
    $headers = "From: ".bb_get_option('admin_email');
    $message ="report by: ".bb_get_current_user_info( 'name' )." (".bb_get_current_user_info( 'id' ).") email: ".bb_get_current_user_info( 'email' )."rnrn";
    $message.="report: ".wordwrap(strip_tags(substr($_POST['report_post_reason'],0,255)),70)."rnrn".get_post_link($post_id)."rn";
    $message.="post by: ". get_post_author($post_id)."rn"; // add "member since", total posts, blah blah
    $message.="rnrnReport Trace:rn";
    $message.="IP: ".$_SERVER['REMOTE_ADDR']."rn";
    $message.="Host: ".gethostbyaddr($_SERVER['REMOTE_ADDR'])."rn"; // useful but can add a few seconds
    $message.="Agent: ".$_SERVER['HTTP_USER_AGENT']."rn";
    $message.="Refer: ". $_REQUEST['refer']."rn";
    $message.="URL: http://".$_SERVER['HTTP_HOST'].$GLOBALS["HTTP_SERVER_VARS"]["REQUEST_URI"]."rn";
    mail( $to, $subject, $message,$headers);
    }
    echo '<form method="POST" name="report_post_form" id="report_post_form" style="display:none;visibility:hidden"><input type=hidden name="report_post_id"><input type=hidden name="report_post_reason"></form>';
    echo '<scr'.'ipt type="text/javascript">
    function report_post(post_id) {
    var report_post_reason = prompt("Please enter a short but descriptive reason why a moderator needs to review this post:", "");
    if (report_post_reason && report_post_reason.length>9) {
    document.report_post_form.report_post_id.value=post_id;
    document.report_post_form.action="#post-"+post_id;
    document.report_post_form.report_post_reason.value=report_post_reason;
    document.report_post_form.submit();
    } else {alert("report cancelled, incomplete description"); }
    }
    </scr'.'ipt>';
    endif;
    }
    add_action('bb_foot', 'report_post_form');

    ?>


    _ck_
    Participant

    @_ck_

    Interesting, but I want something more direct.

    Actually, I have a working prototype now and will post a very early beta in an hour or so.


    _ck_
    Participant

    @_ck_

    I’ve created couple of enhancements to the view count plugin which I’ve attached to the plugin’s page.

    It’s very easy to edit the templates.

    (Oh and xml-rpc is the first thing I disable in any blog configuration – it’s a spammer & evil hacker’s dream)

    The WordPress (and bbpress) community is very dis-organized, which is probably to be expected given the nature of blogging itself, everyone just does their own thing and hopes someone else shows up and comes along for the ride.

    In reply to: No ajax on replies

    _ck_
    Participant

    @_ck_

    It’s fairly straightforward to look backwards on trac and see if it ever really was ajaxed. Post deletions and favorite additions are ajaxed but I’ve not noticed anything else. Kind of a waste for the huge javascripts that are loaded.


    _ck_
    Participant

    @_ck_

    Someone will need to correct me if i am wrong but “Headers already sent” is sometimes an indication of whitespace above or below a plugin which will cause php to think content is being sent and flush the headers.


    _ck_
    Participant

    @_ck_

    Actually, I just realized there is a cheat way to do zero extra mysql queries and link to the profile.

    <td class="num"><a href="/forums/profile.php?id=<? echo $topic->topic_last_poster; ?>"><?php topic_last_poster(); ?></a></td>

    untested but should work in theory

    This will just use the stored last posted id # instead of forcing bbpress to lookup all their meta data and profile link in the database.

    If your forum uses permalinks, it will just rewrite the url on display.


    _ck_
    Participant

    @_ck_

    outchy, this plugin is for a completely different purpose.

    You already have the latest posters on the front page, if you want to turn their names into profile links you need to do something like this in your front-page.php

    <td class="num"><a href="<? user_profile_link( get_post_author_id( ) ); ?>"><?php topic_last_poster(); ?></a></td>

    (untested)

    Note because of the way user data is not cached on the front page, this will cause several extra queries per topic listed and probably not a good idea for very busy forums.

    In reply to: Plugin: Avatar Upload

    _ck_
    Participant

    @_ck_

    Ah good to know fel64. But considering it’s not in 0.8.2.1 and we’re not altering the cache data (just reading it) my technique should be okay until everyone is using the newer core. Which might be awhile.

    (Yeah I suspected the user meta was in the cache. I really was happy to find a straightforward way to reduce those queries!)

    In reply to: Plugin: bb-Topic-Views

    _ck_
    Participant

    @_ck_

    I’ve now come up with an extremely easy/fast way to grab and display the views per forum in the forum list on the front page (or forums with sub-forums.

    Here’s the plugin:

    function forums_views_append($forums) {
    global $bbdb; $sum_meta_value="SUM(meta_value)";
    $forums_views = $bbdb->get_results(" SELECT $sum_meta_value,forum_id FROM $bbdb->topicmeta LEFT JOIN $bbdb->topics ON $bbdb->topicmeta.topic_id = $bbdb->topics.topic_id WHERE $bbdb->topicmeta.meta_key='views' GROUP BY $bbdb->topics.forum_id");
    foreach ($forums_views as $forum_views) {$forums[$forum_views->forum_id]->views=$forum_views->$sum_meta_value; }
    return $forums;
    }
    add_filter('get_forums','forums_views_append');

    To display the views, edit your front-page.php template and insert a views header and views column like so:

    <th><?php _e('Views'); ?></th>
    <th><?php _e('Topics'); ?></th>
    <th><?php _e('Posts'); ?></th>

    .

    <td><?php echo $forum->views; ?></td>
    <td><?php forum_topics(); ?></td>
    <td><?php forum_posts(); ?></td>

    Since there is no clean way to store forum meta data right now in bbpress (apparently an oversight) this will run on every time the forums list is displayed. Maybe not such a good idea for very busy forums, even though it’s a single mysql query (nifty eh?).

    Eventually I’ll figure out a nice way to store this and only update upon new posts or new topics to reduce overhead (or a cron job perhaps).


    _ck_
    Participant

    @_ck_

    Would it be possible for you to properly use fsockopen or curl instead of “file()” for remote files? Like many hosts, I disable file() for remote urls for security vulnerability reasons which cripples your plugin. You’re likely to get many complaints that “nothing happens”

    Warning: file() [function.file]: URL file-access is disabled in the server configuration in /home/example/public_html/forums/bb-admin/admin-functions.php on line 798

    .

    update: actually this is not directly your fault, though you are trying to use a bb-admin function that was meant for local file access to do remote file access?

    If I am not mistaken, you just found a bbpress security loophole.

    ps. any concerns about eventually 2,000-20,000 bbpress users hammering the svn with so many file downloads to examine all the plugin headers?

    In reply to: Plugin: Avatar Upload

    _ck_
    Participant

    @_ck_

    @box87, be aware that single upload class is larger than most of the the entire bbpress core code itself – massive overkill unless you really, really really need it’s extra features?

    @louisedade – I found a major caching bug where you are not taking advantage of user meta data that has already been loaded previously in the same execution – this causes 10-30 extra mysql queries for every topic that is displayed depending on how many posts are displayed at once.

    Here’s a hacked workaround, though I am not sure it’s a good idea to tap into the user_cache directly. I’d otherwise suggest nicely using bb_get_user() as it checks the cache first but the problem with that is it fetches ALL the data if not in the cache which is overkill. Too bad there isn’t a bb_get_user_meta($id,’metaname’) but oh well – for now replace this top section of code:

    function avatarupload_get_avatar($id, $fulluri=1, $force_db=0)
    {
    global $bbdb, $user, $bb_user_cache;

    if ($force_db == 0 && ($id == $user->ID || !empty($bb_user_cache[$id])) )
    {
    if (!empty($user->avatar_file)) {
    $a = explode("|", $user->avatar_file);
    } else {
    if (!empty($bb_user_cache[$id]->avatar_file)) {
    $a = explode("|", $bb_user_cache[$id]->avatar_file);
    }
    else {return false;}
    }
    }
    else

    Drops my topic queries by 20 per page while still functioning correctly in all other cases.

    Discovered this problem via bb-benchmark


    _ck_
    Participant

    @_ck_

    Views don’t have proper titles either apparently, here’s plugin to fix that.

    function bb_get_view_title($title) {
    if (is_view()) {$title = get_view_name(). ' &laquo; ' . bb_get_option( 'name' ); }
    return $title;
    }
    add_filter( 'bb_get_title', 'bb_get_view_title' );

    In reply to: Plugin: bb-Topic-Views

    _ck_
    Participant

    @_ck_

    Here’s a plugin to extend the topic-views plugin and add a “most-views” view page (ie. view.php?view=most-views)

    It does it with a minimum number of mysql calls, just 10 to display an entire page on my setup. You have to hack your views.php template to add the views column, use $topic->views for the view count to use the cached data in memory instead of an extra mysql query for each topic.

    function most_views_views( $views ) {
    global $views;
    $views['most-views'] = 'Topics with the most views';
    return $views;
    }
    add_filter('bb_views', 'most_views_views');

    function most_views( $view ) {
    global $bbdb, $topics, $view_count;
    switch ( $view ) :
    case 'most-views' :
    $limit = bb_get_option('page_topics');
    $where = apply_filters('get_latest_topics_where','');
    $most_views = $bbdb->get_results("SELECT topic_id FROM $bbdb->topicmeta WHERE meta_key='views' ORDER BY cast(meta_value as UNSIGNED) DESC LIMIT $limit");
    foreach (array_keys($most_views) as $i) {$trans[$most_views[$i]->topic_id] =& $most_views[$i];} $ids = join(',', array_keys($trans));
    $topics ="SELECT * FROM $bbdb->topics WHERE topic_id IN ($ids) $where ORDER BY FIELD(topic_id, $ids)";
    $topics = $bbdb->get_results($topics);
    $view_count = count($topics);
    $topics = bb_append_meta( $topics, 'topic' );
    break;
    default :
    do_action( 'bb_custom_view', $view );
    endswitch;
    }
    add_action( 'bb_custom_view', 'most_views' );

    In reply to: Plugin: bb-Topic-Views

    _ck_
    Participant

    @_ck_

    The topic metadata is returned with every set of topics returned to bbpress.

    In the front page (or any topic page) for example, in the loop it can be found as $topic->views

    There is no need for an extra mysql query. It’s possible to make a function that’s called with $topic if you don’t want to do it as simple as above.


    _ck_
    Participant

    @_ck_

    Well there’s no way around the fact that “use display names for admin” basically MUST fetch the display name from the wp_users table when asked for it – and if it’s not been accessed before it’s not cached so it must hit the mysql db directly.

    However, since “use display names” forces the forums table to store the display name properly, there’s no need to run the last poster id through the routine again and force a fetch of the display name, it’s already in the username field for last poster.

    The good news however is between that tweak, a couple other bits of fine tuning and the undocumented $bb->load_options = true; I was able to get the queries down to just 10 for the front page for visitors and 13 for logged in members. This includes an extensive number of plugins, including useronline trackline (not the simplified one here but a port from wordpress).

    It’s never been faster and rather impressive :-)


    _ck_
    Participant

    @_ck_

    I’ve never heard anyone on the various bbPress related channels talk about a need for poll features

    Do you realise the irony in that if this thread had a poll, we could more easily evaluate how many people are interested in a poll feature. LOL. Also evaluate in other threads how much interest there is in wp+bb integration.

    I simply want more people and therefore more talent in the fray that is bbpress. I’ve tried various clever google search patterns to try to determine the unique number of bbpress installs (that are publicly indexed) and I come up with around 200 installs. How many of these are active and have more than a few members is unknown of course. I’d like to see that number be 2000 by January and the only way for that to happen is to have certain common forum perks available. “Competitive frenzy” is one way to see it but inaccurate to my thoughts. I’d just call it feature motivation ;-)


    _ck_
    Participant

    @_ck_

    bug report:

    private forum topics show up in the moderator’s profile & favorites for any viewer


    _ck_
    Participant

    @_ck_

    er, omg, tracing the code I think the option has already been written into bbpress and just not documented?

    $bb->load_options = true

    put into config.php ?

    can it be that easy? does it work or not ready for primetime?

Viewing 25 replies - 2,076 through 2,100 (of 2,186 total)