Search Results for 'code'
-
AuthorSearch Results
-
July 29, 2007 at 11:12 pm #59563
In reply to: How to evaluate server speed?
fel64
MemberUse the port of a pretty cool wp server diagnostics plugin. https://bbpress.org/forums/topic/front-page-takes-50-mysql-queries?replies=15#post-9140
Just add
define( 'SAVEQUERIES', true );
to your config.php and activate this. Then go to View > Page Source and scroll to the bottom to see the diagnostics. (You can ignore all the stuff about queries. Just check out query time, page time, page render time. This tells you about the server bottlenecks.)I just checked the numbers on my server, and I had 3.399 once and about twenty minutes later I had 0.436. This sort of thing can vary a lot, especially on shared hosting.
July 29, 2007 at 5:18 pm #51575In reply to: Full Content of Most Recent Post on Front-Page?
fel64
MemberI don’t know which ones you had problems with but it’s worth noting that some automatically echo and some don’t.
<?php user_profile_link(); ?>
=
<?php echo get_user_profile_link(); ?>
If they’re
get_anything
then you have to echo them yourself, if they don’t haveget_*
then it’ll echo on its own.[Edit] Also remember most functions don’t need a $user_id passed as parameter but won’t work in this case unless you do pass it.
July 29, 2007 at 5:18 pm #59450In reply to: How to link to favorites of logged user
_ck_
ParticipantOh if you are trying to do it from an integrated WordPress you’ll need to do this:
<?
if function_exists("get_currentuserinfo") {global $user_ID;}
else { $user_ID=bb_get_current_user_info( 'id' )}
if ($user_ID) { echo '<a href="/forums/profile.php?id='.$user_ID.'&tab=favorites">favorites</a>';} ?>untested – change /forums/ to whatever your bbpress path is.
July 29, 2007 at 5:10 pm #2181Topic: Protection against human spamming and double e-mail
in forum Troubleshootingnexlamar
MemberHi!
For my bbpress I need a check against human spam attacks.
For this I just need a random generated question in my language (the one that the spammers cannot speak
) and a check if the postet answert is correct. I tried to implement this into register.php, but my checks are ignored by bbpress. Is there anybody who can give me a hint, who maybe works on the same problem?
I also figured out that I can register twice with the same e-mail adress. How can I check if the adress already exists?
Thanks for your help,
Markus
July 29, 2007 at 4:43 pm #51574In reply to: Full Content of Most Recent Post on Front-Page?
outchy
Memberyes, that worked, thank you.
i’m going through the template-functions.php trying to find how to display the last poster’s username and his/her profile link, as well as the link to the topic itself but the only ones i can get to work are these:
<?php echo $latestpost->post_text; ?>
<?php echo $latestpost->poster_id; ?>
<?php echo $latestpost->post_time; ?>
any suggestions?
July 29, 2007 at 1:46 pm #59539In reply to: “My Threads” – User Specific Views
Sam Bauers
Participant> Any idea what I could be doing wrong here?
Are you using the latest trunk or the standard 0.8.2.1 release?
Latest trunk won’t work with the above code.
July 29, 2007 at 1:33 pm #59537In reply to: “My Threads” – User Specific Views
howtogeek
MemberI activated this plugin, but when I click on the link for “topics i’ve started”, all I get is a white page… looking at a sql trace, it doesn’t appear to be running the code at all.
Any idea what I could be doing wrong here?
July 29, 2007 at 1:18 pm #59558In reply to: transfering wp and bb to the same db
fel64
MemberNot a problem as long as you have access to the databases.
Open phpMyAdmin through your administration panel of your web hosting account, go to your database, open wp_usermeta and then click the ‘Search’ tab. Put into the “search conditions” field
user_id = 1 AND meta_key = 'bb_capabilities'
(this should be the user_id of your admin account). Edit the (hopefully) one result that comes up, and change the meta_value toa:1:{s:9:"keymaster";b:1;}
. Then you should be keymaster.July 29, 2007 at 12:55 pm #59327In reply to: Strange (?) (404) report i Firebug
Sam Bauers
ParticipantApache processes rewrite directives in the order they are found.
First the main Apache config file is used, then (if they are allowed) the .htaccess files are used in the order they are encountered from the root of the website out through the directories until the final directory that contains the file that is being accessed.
So if you have a page at http://www.example.com/blog/forum, then the order of processing is like:
Apache config
|
+-> /path/to/site/www.example.com/.htaccess
|
+-> /path/to/site/www.example.com/blog/.htaccess
|
+-> /path/to/site/www.example.com/blog/forum/.htaccessSo the “blog” rewrite rules will be assessed first. This means that you may want to place your bbPress rewrite rules in the same .htaccess file as your blog rules, before the blog rules, as they are more specific and should be handled first.
Also, there were some problems with WordPress throwing 404 errors based on what mod_rewrite was doing. This was specifically with version 2.1 I think, so your WordPress may need to be upgraded.
July 29, 2007 at 12:27 pm #49633In reply to: Emoticons For bbPress?
fel64
MemberIt’s Javascript. PHP files are just like HTML files, and anything outside the
<?php ... ?>
is treated as HTML. Calling the particular function around that makes it go to that place and then go through and output the HTML (which happens to be JS).July 29, 2007 at 12:12 pm #59534In reply to: “My Threads” – User Specific Views
Sam Bauers
Participant> is there a method way to delete a view
In current trunk…
bb_deregister_view( $view )
July 29, 2007 at 11:35 am #59532In reply to: “My Threads” – User Specific Views
_ck_
ParticipantUgh. So that breaks a view things I’ve done.
I’m waiting for an addition to the plugin svn and I’ll just update there at this point. I also missed checking if the user is logged in, now fixed.
I don’t run the newest trunk so I don’t have a way to test. Looks like I’ll have to setup a test account and install it again.
and I just put the finishes on a nice dropdown view box too…
function views_dropdown() {
$views_dropdown='<form name="views_dropdown" id="views_dropdown">
<select size=1 name="views_dropdown_select" onchange="if (this.selectedIndex != 0) {location=this.options[this.selectedIndex].value;}}">
<option value="#">SHOW ME
> </option>';
$views=get_views(); foreach ($views as $view => $title ) {
$views_dropdown.='<option value="'.get_view_link($view).'">'.$views[$view].'</option>';
}
$views_dropdown.='</select></form>'; echo $views_dropdown;
}July 29, 2007 at 11:30 am #59531In reply to: “My Threads” – User Specific Views
Sam Bauers
ParticipantYou should be aware that views are registered differently in the latest versions in trunk. Views are now constructed using the BB_Query class.
See the latest Support Forum plugin for a way to use both the new and old, although it is wrapped in a Class in there so the basic idea is:
if (is_callable('bb_register_view')) { // Build 876+
$query = <SOME ARRAY ACCEPTABLE TO BB_QUERY>;
bb_register_view('myview', __('My view name'), $query);
} else { // Build 214-875
add_filter('bb_views', 'my_addView');
add_action('bb_custom_view', 'my_processView');
}July 29, 2007 at 10:07 am #49632In reply to: Emoticons For bbPress?
mazdakam
Memberhi again i want to know why the function grin(tag) { is out of php code
why it need to be out side?
July 29, 2007 at 9:03 am #59030In reply to: Plugin: Private Forums v4.0
_ck_
ParticipantOh figured out how to fix the moderator’s profile, very easy to do when using my additional function – just attached more “where filters”:
function private_forums_filter_private($where,$prefix=''){
if (function_exists("private_forums_custom_get_options")) {
$private_forums = private_forums_custom_get_options('private_forums');
foreach($private_forums as $forum => $role) {
if(!private_forums_check_user_access_to_forum($role)) {
$where.=" AND ".$prefix."forum_id != ".$forum." ";
}
}
}
return $where;
}
add_filter( 'get_latest_topics_where', 'private_forums_filter_private');
add_filter( 'get_latest_posts_where', 'private_forums_filter_private');
add_filter( 'get_recent_user_replies_where', 'private_forums_filter_private');
add_filter( 'get_recent_user_threads_where', 'private_forums_filter_private');July 29, 2007 at 8:49 am #59530In reply to: “My Threads” – User Specific Views
_ck_
ParticipantWow I was making it too complicated! Try this…
I managed to use internal functions but there’s a catch with get_recent_user_replies in that all topic data is not attached properly so I have to run through get_topic to pull all the cache data out again (the only proper way to do it without peeking in the cache directly)
<?php
/*
Plugin Name: my views
Description: views for a user's topics started and other participated topics
Plugin URI:
Author:
Version: 0.01
*/
function my_views_filter( $views ) {
global $views;
$views['my-topics'] = "Topics I've Started";
$views['my-posts'] = "Topics I've Participated In";
return $views;
}
add_filter('bb_views', 'my_views_filter');
function my_views_action( $view ) {
global $bbdb, $topics, $view_count; $user_id=bb_get_current_user_info( 'id' );
if ($view=='my-topics') {$topics=get_recent_user_threads($user_id); $view_count = count($topics);}
if ($view=='my-posts') {
$posts=get_recent_user_replies($user_id); $topics="";
foreach ($posts as $post) {$topics[]=get_topic($post->topic_id );}
$topics=bb_append_meta( $topics, 'topic' );
$view_count = count($topics);}
}
add_action( 'bb_custom_view', 'my_views_action' );
if (!function_exists(bb_get_view_title)) {
function bb_get_view_title($title) {
if (is_view()) {$title = get_view_name(). ' « ' . bb_get_option( 'name' ); }
return $title;
}
add_filter( 'bb_get_title', 'bb_get_view_title' );
}
?>July 29, 2007 at 7:50 am #59476In reply to: {Request plugin:} auto complete tags
mazdakam
Memberhummm i am listeing to good news
July 29, 2007 at 7:20 am #59528In reply to: “My Threads” – User Specific Views
_ck_
ParticipantI haven’t seen them (doesn’t mean it doesnt exist) but I’ve figured out the framework on how to build and attach a view if you’d like to copy my homework
This is the code I whipped up for “most-views” and “least-views” (which requires the view count plugin to be installed (and inserting the views column in view.php)
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 least_views_views( $views ) {
global $views;
$views['least-views'] = 'Topics with the least views';
return $views;
}
add_filter('bb_views', 'least_views_views');
function most_views( $view ) {
global $bbdb, $topics, $view_count;
if ($view=='most-views') {$sort="DESC";}
if ($view=='least-views') {$sort="ASC";}
if ($view=='least-views' || $view=='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) $sort 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_status=0 AND 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' );
}
else {do_action( 'bb_custom_view', $view );}
}
add_action( 'bb_custom_view', 'most_views' );As you can see a new view requires both 1. an action 2. a filter
Easy once you’ve seen it, but try figuring it out from scratch!
This bit adds the title to view pages (missing by default in bbpress)
function bb_get_view_title($title) {
if (is_view()) {$title = get_view_name(). ' « ' . bb_get_option( 'name' ); }
return $title;
}
add_filter( 'bb_get_title', 'bb_get_view_title' );July 29, 2007 at 4:37 am #59243In reply to: Plugin: Plugin browser for bbPress
Sam Bauers
ParticipantMy other option is to make the update check more atomic. Here, your pagination idea could help. So instead of fetching all the plugins, I could just fetch the first page, then the second etc. etc. on request. More complicated to code, but it might be the best long term solution to keep the best of both worlds. I could also add a way to list installed plugins first, or even have a separate view of installed plugins.
I wouldn’t think Trac is faster, it has a few more overheads on the server side I think. I don’t think it will come down to that though.
Neither the Trac site nor the SVN repository use compression on their output, so gzip is useless, but that was a good suggestion. I’m not sure the SVN repository could use gzip anyway as it would potentially get in the way of some SVN clients, I’m not sure SVN even supports compression techniques like that (although it probably should).
July 29, 2007 at 4:23 am #51573In reply to: Full Content of Most Recent Post on Front-Page?
Sam Bauers
ParticipantYou’ll need to order that query by using
ORDER BY post_time DESC
. There is no guarantee that the last row of a table is the last row that was added.July 29, 2007 at 3:50 am #59474In reply to: {Request plugin:} auto complete tags
_ck_
ParticipantAuto closing formatting is being worked on by mdawaffe now I believe.
It’s a single boolean bug (true/false) so I should hope it doesn’t take too long
July 29, 2007 at 3:35 am #51572In reply to: Full Content of Most Recent Post on Front-Page?
outchy
Memberok cool, thank you. it’s doing something so that’s good
this is what i’m using:
<?php
$latestpost = $bbdb->get_row("
SELECT *
FROM $bbdb->posts
WHERE post_status = 0
LIMIT 1
");
?>
<?php echo $latestpost->post_text; ?>it’s displaying the first post from forum 3 for some reason, not the most recent post. i’ve posted a few new posts since then in other forums and it never changes on the front page, it still shows that first post from that forum 3. any idea how come?
(thanks for your help on this)
July 29, 2007 at 3:16 am #51571In reply to: Full Content of Most Recent Post on Front-Page?
fel64
MemberSure that’s possible.
You want a query that gives you the last post. Forget anything messing around with the forum or the topic. You want the last post, right?
There’s no API function to do this AFAIK, so you will have to use a query. I think the structure could go something like this:
$latestpost = $bbdb->get_row("
SELECT *
FROM $bbdb->posts
WHERE post_status = 0
LIMIT 1
");And then
$latestpost
has$latestpost->post_text, poster_id
and so on. But unfortunately not filtered, so you’d need to apply all those. Which is a bit nasty.But this is all unchecked and unresearched, you’ll need to play around with it.
All this is is a bare start.
July 29, 2007 at 2:33 am #51570In reply to: Full Content of Most Recent Post on Front-Page?
outchy
Memberi want to display the most recent post, no matter what forum it happens to be from. is that possible?
i tried doing what you said but maybe i messed it up because i’m getting a mysql syntax error. here is what i have, forgive me if it looks glaringly stupid:
<?php
$forum_id = 1;
$forum_one_topics = $bbdb->get_row("SELECT * FROM $bbdb->topics WHERE forum_id = $forum_id ORDER BY topic_time DESC ") ?>
<?php
$forum_one_topic_posts = get_thread( $forum_one_topics->topic_id); ?>
Re: <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a>
<span class="gray">
<a href="<?php get_user_profile_link( $id = 0, $page = 1 ); ?>">
<?php echo $forum_one_topics->topic_last_poster_name; ?></a> said:</span> <span class="justify"><?php echo $forum_one_topic_posts[0]->post_text;
?></span>sorry, i’m really trying to get it
July 28, 2007 at 9:41 pm #59500In reply to: Working on new theme…
-
AuthorSearch Results