Post Reply 
Need help with php
Plugin->Zinga's plugin username colors
Author Message
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #21
RE: Need help with php
YAY ITS WORKING! THANK YOU, but its not {$username}, your function checks {username} so its {username} not with $, i want to try this by my self, i want it just with hex color, but let me try this from not on, if i need more help i will post.

You said that its slow, how can i put it faster? creating a file with the database part and put require_once filename at the begin of the functions.php?

EDIT, ok its working well now, no need to put the span, etc, just #hexcolor.

THIS IS AWESOME, THANK YOU SO MUCH, i just don't know how to put things faster, it isn't slow because its just one user, but if i have more users using that it will probably be slow. Im using the cache folder as cache instead of db, and im using the css folder for css, so it doesn't requires the db too often. but what do you do to increase the speed?

(This post was last modified: 11/09/2007 04:23 AM by Pirata Nervo.)
11/09/2007 04:20 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #22
RE: Need help with php
Ok i put the font working too:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function format_name($username, $usergroup, $displaygroup="")
{
    global $db;
    $queryC = $db->query("SELECT fid5 FROM ".TABLE_PREFIX."userfields f LEFT JOIN ".TABLE_PREFIX."users u ON u.uid = f.ufid WHERE u.username = '".$db->escape_string($username)."'");
	$queryF = $db->query("SELECT fid6 FROM ".TABLE_PREFIX."userfields f LEFT JOIN ".TABLE_PREFIX."users u ON u.uid = f.ufid WHERE u.username = '".$db->escape_string($username)."'");
    $color = $db->fetch_field($queryC, 'fid5');
    $font = $db->fetch_field($queryF, 'fid6');
	
	if($color && $font)
	{
		$format = "<span style=\"color:{$color};\"><span style=\"font-family:{$font}\">{username}</span></span>";
	}
	
	if($font && !$color)
	{
		 $format = "<span style=\"font-family:{$font}\">{username}</font>";
	}
	
	if($color && !$font)
	{
		 $format = "<span style=\"color:{$color}\">{username}</span>";
	}

	$userin = substr_count($format, "{username}"); // function that counts how many times {username} substring is in the $formats string
    if($userin == 0) // if {username} substring wasnt found in the $format string, then
    {
        $format = "{username}"; // the $format string = "{username}"
    }
    return str_replace("{username}", $username, stripslashes($format));
}


But asi disabled some plugins it still fast, and i already have some users using font and color. How do i speed up the site? as you said that will slow down.


11/09/2007 04:05 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #23
RE: Need help with php
The speed will depend on some things.
The main issue is the number of SQL queries run.  Let's say there's 30 users in the "who's online today" list - 30 queries must be done to perform the formatting.
Doesn't matter how you do it, your method will require a lot of queries.  If it doesn't make it noticeably slower, well then stick with it.

The cache store in files only affects the datacache (the mybb_datacache table).


My implementation actually doesn't require any new queries.  It does require about 30 code edits however.  Speed is basically unaffected.
Also my implementation allows extra code to be inserted manually by me, which is how I rigged hibbyware's posts :P
11/09/2007 08:50 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #24
RE: Need help with php
ooooooooooooooooooooo ok, you should put username size too.
Lol@hibby posts.

12/09/2007 01:43 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #25
RE: Need help with php
what did you do to don't use the database?

12/09/2007 07:36 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #26
RE: Need help with php
It uses the database, but doesn't perform any extra queries.  I just modified existing queries to allow it to retrieve name formatting info.  In fact, the only thing changed was retrieving an extra field (no new joins are created), which is why speed is basically unaffected.

As I said, it does require a lot of code edits however.
12/09/2007 03:32 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #27
RE: Need help with php
ok thanks anyway. i have a doubt, can't i save the info in one file instead of using the db?

12/09/2007 03:55 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #28
RE: Need help with php
^ You can if you want.  Really more work than necessary, and probably actually slows down everything even more...
12/09/2007 04:11 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #29
RE: Need help with php
lol ok then.

12/09/2007 04:22 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Pirata Nervo
NervOS Developer

Posts: 699.4765
Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
Offline
Post: #30
RE: Need help with php
hi again , sry if im annoying you too much, but can you tell me how you did it?? like you did with muppet modding, if you could tell me....:D :D :please:

17/09/2007 01:16 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: