Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 23,276 through 23,300 (of 32,468 total)
  • Author
    Search Results
  • #31889
    Gautam
    Member

    I have developed an ajaxed chat plugin, which uses phpfreechat.net script. That script has multiple themes, multiple languages, and multiple features.

    There is also a settings page in which you can save various parameters/config for the script.

    There can be 2 types of storages – mysql & file, default is mysql, it automatically uses the bbPress db you are using and makes tableprefixajaxed_chat table.

    You can see the various commands that can be used in chat, and the FAQ at phpfreechat.net

    There are 2 ways you can call the chat:

    http://yoursite.com/?chat

    or by placing this code anywhere in your template:

    <?php if (function_exists('ajaxed_chat_load')) ajaxed_chat_load(); ?>

    Live Demo (At my test forums): http://forum.gaut.am/ (inside template) or http://forum.gaut.am/?chat (full screen)

    Download Link – http://gaut.am/uploads/ajaxed-chat-1.0-beta.zip

    Note – It is beta version, not a release (for now)

    I still need to work on the admin settings page, but still its not too bad for now.

    Comments, feedback & suggestions are welcomed!

    #79780
    <?php
    /*
    * Plugin Name: Say My Name
    * Plugin Description: Sends a notification email if someone mentions your name in a post (based on Notify Post by Thomas Klaiber).
    * Author: <a href="http://www.ellequadro.net">Matteo Crippa</a>, updated for bbPress 1.0 by Kawauso
    * Version: 0.2
    */

    function say_my_name ( $post_id, $args ) {

    global $bbdb, $topic;

    if ( isset( $args[ 'post_id' ] ) && false !== $args[ 'post_id' ] ) // Don't run on edits
    return;

    $post = strtolower( $args[ 'post_text' ] );

    $all_users = $bbdb->get_results( "SELECT * FROM $bbdb->users WHERE user_status=0" );

    foreach( $all_users as $userdata ) {

    if( !is_smn( $userdata->ID ) )
    continue;

    /* $notify = false;
    */ $display_name = strtolower( $userdata->display_name );

    /* if( strpos( $display_name, ' ' ) === false ) { // Use word-by-word searching if the display name is one word
    if( !isset( $words ) )
    $words = explode( ' ', $post ); // Only create the word list if necessary

    foreach ( $words as $word ) {

    if( $display_name == $word || "@$display_name" == $word ) {

    $notify = true;
    break;

    }

    }
    }

    else*/ if( strpos( " $post", " $display_name" ) !== false || strpos( " $post", " @$display_name" ) !== false) // Always require a leading space
    /* $notify = true;

    if( $notify ) */{

    $message = __( "Someone called you on: %1$s nn%2$s " );
    @mail( $userdata->user_email, bb_get_option( 'name' ) . ':' . __( 'Notification' ), sprintf( $message, $topic->topic_title, get_topic_link( $topic_id ) ), 'From: ' . bb_get_option( 'admin_email' ) );

    }

    }

    }
    add_action( 'bb_insert_post', 'say_my_name', 1, 2 );

    function smn_profile() {

    if( !bb_is_user_logged_in() )
    return;

    global $user_id;

    if( is_smn( $user_id ) )
    $checked = ' checked="checked"';
    else
    $checked = '';

    ?>
    </fieldset>
    <fieldset>
    <legend>Say My Name Notification</legend>
    <p><?php _e('If you want to get an email when someone call your name in a new post.')?></p>
    <table width="100%">
    <tr>
    <th width="21%" scope="row"><?php _e('Activate')?>:</th>
    <td width="79%"><input name="smn" id="smn" type="checkbox" value="1"<?php echo $checked?> /></td>
    </tr>
    </table>
    <?php
    }
    add_action( 'extra_profile_info', 'smn_profile' );

    function smn_edit() {
    global $user_id;

    if( $_POST[ 'smn' ] )
    bb_update_usermeta( $user_id, "smn", true );
    else
    bb_update_usermeta( $user_id, "smn", false );

    }
    add_action( 'profile_edited', 'smn_edit' );

    function is_smn ( $user_id ) {
    $user = bb_get_user( $user_id );
    if ( $user->smn )
    return true;
    else
    return false;
    }
    ?>

    Take out the /* */ around the commented out parts of the code if you want to re-enable the foreach() loop method for single word display names. I couldn’t find much of a difference in speed, but then again it might be quite different on a live server. You can also just delete all that code too if you want to make the file smaller :P I’ll upload this to the Extend section someday, along with the other plugin I keep meaning to finish and upload.

    Edit: Added support for @ :P

    This should be 100% case insensitive, but I’ve not tested with anything unicode. It’ll always look for a space before the name to avoid false positives, but if it’s at the very start of the post, it’ll still be detected.

    #79778

    Okay, I’ve managed to optimise the code for this a bit. I’m a bit stuck though.

    At the moment, it’s checking for usernames, rather than display names and checking word-by-word. That’s fine for usernames, because they’re essentially always one word, but display names can be more than one and I intend to use those.

    Explosion took 0.000307083129883 seconds

    Strpos took 3.00407409668E-5 seconds

    :D

    #78176
    notprathap
    Member

    Oh My! Thanks mazzhe! you saved my day! :)

    #79776

    Great! Knew both of them but not the fact that ipstenu is a female developer.

    Actually female developers get me impressed pretty quick. I guess its cuz of my love for code and love for ladies ;)

    #79773
    johnhiler
    Member

    We have a number of female developers on the bbPress forums… they’re some of our most active members actually. :-)

    If you’re using a number of _ck_s plugins, I recommend you restore from backups and go back to 0.9 btw…

    #79772
    brad_langdon
    Member

    Thanks, I thought CK was a dude… lol. Typical male I am ;)

    #31884
    Mark-k
    Participant

    The problem seems to be that wordpress adds slashes to the input in its initialization, and them comes bbpress and adds slashes once again, and since the code assumes that slashes were added only once, stange things happen.

    solution that work for me: in bb-settings.php change

    // Sanitise external input

    $_GET = bb_global_sanitize( $_GET );

    $_POST = bb_global_sanitize( $_POST );

    $_COOKIE = bb_global_sanitize( $_COOKIE, false );

    $_SERVER = bb_global_sanitize( $_SERVER );

    to

    if ( !defined( 'ABSPATH' ) ) { // no need to sanitize if wp had done it

    // Sanitise external input

    $_GET = bb_global_sanitize( $_GET );

    $_POST = bb_global_sanitize( $_POST );

    $_COOKIE = bb_global_sanitize( $_COOKIE, false );

    $_SERVER = bb_global_sanitize( $_SERVER );

    }

    #79697

    In reply to: Need A Project ShowOff

    kernow
    Member

    I’m impressed, it looks very good. The only problem I can see is that it reminds me that I need to learn more about coding and I don’t have the time :)

    #79724

    Doesn’t make sense if the path in the plugin bb_attachments was changed by itself :/

    #72125
    defue
    Member

    I’ve found a solution for this. You need to edit bbpress/bb-includes/functions.bb-posts.php and replace the function bb_get_post (it is the first function in file) with

    function bb_get_post( $post_id ) {
    global $bbdb;
    $post_id = (int) $post_id;
    if ( false === $post = wp_cache_get( $post_id, 'bb_post' ) ) {
    $post = $bbdb->get_row( $bbdb->prepare( "SELECT * FROM $bbdb->posts WHERE post_id = %d", $post_id ) );
    $post = bb_append_meta( $post, 'post' );
    wp_cache_set( $post_id, $post, 'bb_post' );
    }
    //here is the only new line for stripping slashes
    $post->post_text = stripslashes($post->post_text);
    return $post;
    }

    Not sure that it is the elegant solution but it works for me.

    #79696

    In reply to: Need A Project ShowOff

    C’mon no comments on the design or implementation? :(

    #76884
    Josh Leuze
    Member

    Disregard my last post, that link is ooooold as dirt :)

    Let’s cross our fingers that someone is on the job though!

    #79753

    In reply to: WordPress Integration

    gerikg
    Member
    define('AUTH_KEY', 'put your unique phrase here');
    define('SECURE_AUTH_KEY', 'put your unique phrase here');
    define('LOGGED_IN_KEY', 'put your unique phrase here');
    define('NONCE_KEY', 'put your unique phrase here');

    replace those with the 8 keys

    you do the same in bb-config.php

    and add “BB_”

    define('BB_AUTH_KEY', 'put your unique phrase here');

    #79742

    In reply to: WordPress Integration

    c4central
    Member

    ashfame – it was your tutorial that I tried so many times.

    When I say the login doesn’t work, I mean when I try to login to bbpress it says the user “admin” doesn’t exist!

    ashfame, I also sent you an email after trying your tutorial over and over, asking for help.

    gerikg, I will give that a try. I did not upgrade from an old wordpress, this is a fresh installation. I should have a few minutes to try that this afternoon.

    Once we get this up and running, maybe you guys can point me in the right direction to get the themes/header matching. Actually, that is a project for another day :-)

    I’ll post my results!

    #79741

    In reply to: WordPress Integration

    gerikg
    Member

    Use this link: https://api.wordpress.org/secret-key/1.1/salt It has 8 keys.

    NOTE: do NOT use any “www.” anywhere when entering information.

    1. Open wp-config line replace your new keys with the one from that link. (lines 55-61)

    2. Copy the same keys to bb-config just add BB_ after define(‘ in each key so it will be define('BB_AUTH_KEY', '(lines 41-44)

    3. Install & activate BBpress Intergration plugin https://wordpress.org/extend/plugins/bbpress-integration/

    4. Get the information from the plugin and put it in line 20 in wp-config and line 13 in bb-config. (if you’re using WPMU take out the HASH line when you put it in bb-config)

    5. Log into your BBpress admin section and navigate to SETTINGS -> WORDPRESS INTEGRATION enter all the information it ask for, save.

    6. Clear you cache and you should be ready to go.

    If you upgraded from a previous WP version take out define( 'WP_AUTH_COOKIE_VERSION', 1 ); because it doesn’t work on 2.8.4

    #79736
    gerikg
    Member

    html.css (line 329) calls for it…

    ul, menu, dir {
    display:block;
    list-style-type:disc;
    margin:1em 0;
    }

    add this to your style.css

    #navigation ul {
    list-style-type:none;
    }

    If you use Firefox get a plugin called firebug. http://getfirebug.com/ it will help you with all your css needs.

    #79689
    gerikg
    Member

    I had a problem with a css file that wouldn’t import a php file. (@import url(css/loader.php);)

    look at the main css file and see if there is any importing involved.

    #79734
    gerikg
    Member

    1. Add this to you style.css in your forum theme

    #megaContainer {
    background-color:#FFFFFF;
    border-left:thin solid #666666;
    border-right:thin solid #666666;
    margin-left:auto;
    margin-right:auto;
    min-height:100%;
    position:relative;
    width:840px;
    }

    2. change <div class="megaContainer"> to <div id="megaContainer"> in your theme header.php

    #79663

    In reply to: HTML in Topics.

    Peter A. Gebhardt
    Participant

    Although someone could tweak the size of the Topic or Post Title to a a size which does not interfere with the positioning of the “Add Tag” section in the topic view – it would be nice we could use say <br /> too.

    As an example, I’ve changed this section of “topic.php” in “kakumei”:

    From:

    <div id="topic-info">
    <span id="topic_labels"><?php bb_topic_labels(); ?></span>
    <h2<?php topic_class( 'topictitle' ); ?>><?php topic_title(); ?></h2>

    To:

    <div id="topic-info">
    <!-- <span id="topic_labels"><?php bb_topic_labels(); ?></span> -->
    <div style="width:500px"><h2<?php topic_class( 'topictitle' ); ?>><?php topic_title(); ?></h2></div>

    Which is required for all templates and prone to finetuning errors.

    #77217

    Never mind – I got it, thanks to an old post from two years ago.

    The code has changed a bit, so here’s how I fixed it:

    1) open up /bb-includes/functions.bb-template.php

    2) replace line 1074 with:

    return stripslashes(apply_filters( ‘get_topic_title’, $topic->topic_title, $id ));

    3) and line 1782:

    return stripslashes(apply_filters( ‘get_post_text’, $bb_post->post_text, $bb_post->post_id ));

    That did the trick for me.

    #79427
    chrishajer
    Participant

    To answer your question about the closing ?> being missing, yes you can leave that off. wp-config.php starting coming like that. It concerned me at first but it turns out it’s OK and might be a good thing to do.

    http://activeblogging.com/info/can-you-leave-off-the-closing-php-tag-in-your-source-code/

    http://php.net/basic-syntax.instruction-separation

    #64936
    chrishajer
    Participant

    Yes, that’s fine. If you create a Page in WordPress called Forums (actually the slug just needs to be forums), you don’t even need any content on the page. WordPress will direct traffic there. That works with permalinks on. Not sure what happens if you don’t use permalinks. If you don’t create a Page called Forums, with a slug of forums, then you just won’t have a link in your menu to the forums. There are plugins to get around that though, if you need it. Try the Page first though and see if it works.

    #31876

    Topic: Aligning Logo

    in forum Installation
    #79425

    All my code is written against 1.0.2 SVN, so it’s not 0.9-only :) and yeah, $allowed_tags is meant to be changed and then back again, not the cleanest way of doing things, but it should work. The copy that’s working live at the moment is below (I just realised I forgot to turn on the validation code too, oops):

    <?php
    /*
    Plugin Name: Restrict Topic Tags
    Description: Restricts tags to a pre-defined list.
    Author: Kawauso
    Version: 0.1.1
    */

    $allowed_tags = array(
    'test4',
    'test 3',
    'test3',
    'test2',
    );

    function restrict_topic_tags_form( $args = null )
    {
    $defaults = array( 'topic' => 0, 'submit' => __('Add ยป'), 'list_id' => 'tags-list' );
    $args = wp_parse_args( $args, $defaults );
    extract( $args, EXTR_SKIP );

    if ( !$topic = get_topic( get_topic_id( $topic ) ) ) {
    return false;
    }

    if ( !bb_current_user_can( 'edit_tag_by_on', bb_get_current_user_info( 'id' ), $topic->topic_id ) ) {
    return false;
    }

    global $page, $allowed_tags;

    $current_tags = bb_get_topic_tags( $topic->topic_id );
    $allowed_tags = array_flip( $allowed_tags ); // CHANGE PLACES!
    foreach( $current_tags as $tag ) {
    if( isset( $allowed_tags[ $tag->name ] ) )
    unset( $allowed_tags[ $tag->name ] );
    }
    $allowed_tags = array_flip( $allowed_tags ); // CHANGE PLACES!

    if( is_array( $allowed_tags ) && !empty( $allowed_tags ) ) { ?>
    <form id="tag-form" method="post" action="<?php bb_uri('tag-add.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>" class="add:<?php echo esc_attr( $list_id ); ?>:">
    <p>
    <select name="tag" id="tag">
    <option value=""><?php _e("Select a tag")?></option>
    <?php foreach( $allowed_tags as $tag ) { ?>
    <option value="<?php echo $tag?>"><?php echo $tag?></option>
    <?php } ?>
    </select>
    <input type="hidden" name="id" value="<?php echo $topic->topic_id; ?>" />
    <input type="hidden" name="page" value="<?php echo $page; ?>" />
    <?php bb_nonce_field( 'add-tag_' . $topic->topic_id ); ?>
    <input type="submit" name="submit" id="tagformsub" value="<?php echo esc_attr( $submit ); ?>" />
    </p>
    </form>
    <?php
    } // End if

    } // End function

    function restrict_topic_tags( $tag ) {

    global $allowed_tags;

    if( !in_array( $tag, $allowed_tags ) )
    return array();

    return array($tag);
    }

    add_filter( 'bb_add_topic_tags', 'restrict_topic_tags' );

Viewing 25 results - 23,276 through 23,300 (of 32,468 total)
Skip to toolbar