vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   [How-To] vBulletin API Basics: Variables, Functions, Objects (https://vborg.vbsupport.ru/showthread.php?t=98047)

Lea Verou 11-13-2005 02:38 AM

I'm trying to make a mod to display referrer statistics, so that a forum can have referrer contests etc. I've seen this requested many times in the modification requests and I would also like it for my forum. :)
I have lots of learning to do though in order to make it, but I'm determined :p :p

akanevsky 11-13-2005 02:42 AM

Quote:

Originally Posted by Michelle
I'm trying to make a mod to display referrer statistics, so that a forum can have referrer contests etc. I've seen this requested many times in the modification requests and I would also like it for my forum. :)
I have lots of learning to do though in order to make it, but I'm determined :p :p

Ah, great, I remember back in 2.3.x days there was a "vbStats 230.b created by Bane for Talkloud.NET" hack, but that project was abandoned (or at least it is not free anymore). Even though I PM-ed them many times :(... Then I forgot about it, but now if you going to make it, that'd be great, and I'll gladly help you :)

EDIT:

Yes, I thought so. They have it, but they do not release it anymore:
http://www.talkloud.net/forums/vbsta...on=memberrefer :(

Lea Verou 11-13-2005 02:48 AM

Thanks so much!!! :D
How can I ask you if I have a question? In this thread or via pm? :nervous:
I wish I could code for hours today, I am really eager to do it but I have a trip so I have to start packing in about an hour, so I'll continue working at night when I arrive (it's 6:46 in the morning here) :)
Anyway, when I really want to make something I can sit at the computer for hours till I make it, lol :p I made smilie maker in one night and for my (low) level of knowledge that's an achievement :p

Quote:

Originally Posted by Psionic Vision
Yes, I thought so. They have it, but they do not release it anymore:
http://www.talkloud.net/forums/vbsta...on=memberrefer :(

That's really mean of them. :(
Anyway mine will be better :p

OMG I am totally insane! :p
I postponed my trip 5 hours so I can work at the script! LOOOOOOOOOOL!!! :p

akanevsky 11-13-2005 11:17 AM

Quote:

How can I ask you if I have a question? In this thread or via pm?
It's better via PM or even AIM, so as not to clutter up this thread :)

Quote:

Anyway, when I really want to make something I can sit at the computer for hours till I make it, lol
Same here. :)

Quote:

Anyway mine will be better
Nice attitude :)

Quote:

I postponed my trip 5 hours so I can work at the script!
Wow. Hopefully it wasn't a business trip or an interview appointment lol.

Update:
Added "Authentication Storage" section, based on a random Kirby's post that I've found.

FamilyCorner 11-14-2005 03:36 PM

I hope someone here can help me :( I have a hack that stopped working after upgrading to 3.5.1. I have already made the change for "db" from "DB_site", but this page seems to still be having a problem:
http://www.familycorner.com/forums/contest.php3

You will see if you scroll down to where it says "Posts Today" in a purple box that the total number of posts are missing. This is what the post count is calling from:

PHP Code:

<?php 
while ($user $db->fetch_array($users)) 

$username $user["username"]; 
echo (
"$username<br>"); 

echo (
"<br>"); 
while (
$user $db->fetch_array($admin)) 

$username $user["username"]; 
echo (
"$username<br>"); 

?> 
<br> 
</font> 
</td> 
<td align="center"> 
<FONT face="verdana,verdana" size="2"> 
<br> 
<?php 
$db
->data_seek(0,$users); 
while (
$user $db->fetch_array($users)) 

$count $user["count"]; 
echo (
"$count<br>"); 

echo (
"<br>"); 
$db->data_seek(0,$admin); 
while (
$user $db->fetch_array($admin)) 

$count $user["count"]; 
echo (
"$count<br>"); 

?>

What else do I need to change from the old version code to update it to work on 3.5.1?

THANK YOU!

Sorry, I should have posted this as well. This code is at the top of the page, just under the body tag:

PHP Code:

<?php
$date1 
"UNIX_TIMESTAMP(\"2005-11-10\")";
$date2 "UNIX_TIMESTAMP(\"2005-11-11\")";

$users $db->query(
"SELECT post.userid, count(post.userid) as count, user.username from " .
"post, user WHERE post.dateline >= $date1 and post.dateline <= $date2 " .
"and post.userid = user.userid and user.username <> 'Dawn' group ".

"by post.userid order by count DESC");
$admin $db->query(
"SELECT post.userid, count(post.userid) as count, user.username from " .
"post, user WHERE post.dateline >= $date1 and post.dateline <= $date2 " .
"and post.userid = user.userid and user.username = 'Dawn' group ".
"by post.userid order by count DESC");

 
?>

and this is at the very top of the page, before the HTML tag:

PHP Code:

<?php require("global.php3"); ?>


vietkieu_cz 02-05-2006 08:24 AM

Some screenshot please?

bairy 03-08-2006 09:06 PM

Not exactly related to the first post but some things I find very very useful when coding.

At the bottom of includes/functions.php I have the following:

PHP Code:

function pre($var) {
    if (
$_SERVER['REMOTE_ADDR'] == 'xxx.xxx.xxx.xxx' or $_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
        echo 
"<pre>";
        
print_r($var);
        echo 
"</pre><br />";
    }
}

function 
echoa($var) {
    if (
$_SERVER['REMOTE_ADDR'] == 'xxx.xxx.xxx.xxx' or $_SERVER['REMOTE_ADDR'] == '127.0.0.1') echo $var;
}

class 
microtimer {
// Starts, Ends and Displays Page Creation Time
   
function getmicrotime() {
       list(
$usec$sec) = explode(" "microtime());
       return ((float)
$usec + (float)$sec);
   }
   
   function 
s() {
   
$this->st $this->getmicrotime();
   }
       
   function 
e() {
       
$this->et $this->getmicrotime();
       if (
$_SERVER['REMOTE_ADDR'] == 'xxx.xxx.xxx.xxx' or $_SERVER['REMOTE_ADDR'] == 'xxx.xxx.xxx.xxx') echo round(($this->et $this->st), 6);
   }
}
$tm = new microtimer

where xxx.xxx.xxx.xxx is your internet IP and 127.0.0.1 is if you have an installation on your pc.

All of the above were taken off user comments at php.net


Usages:
PHP Code:

pre($var);

e.gpre($vbulletin->userinfo); 

This will print_r a variable in a formatted way (print_r is a php function that outputs the value of variables, good for arrays).
Extremely useful for seeing what vB knows at any point, especially if you need to call some of that data. A tip: don't pre($vbulletin), it's really messy.

PHP Code:

echoa $var

Does what echo $var does, but as you can see from the code, it only shows you so it doesn't disrupt the board.

PHP Code:

$tm->s(); 

and
PHP Code:

$tm->e(); 

This is a microtimer, put the s() just before the code you want to time, and the e() after, and it will echo the time it took in seconds. Change the 6 to control the number of decimal places. So:
PHP Code:

$tm->s();
for (
$i=0;$i 1000000$i++) {
  
$tmp 1;


That will tell you how long it takes the system to assign a value to a variable 1 million times (I got 0.35secs on a 2.4ghz P4, if anyone cares).


These are all bound to your IP or localhost to save unnecessary outputting to the board.

DrewM 06-15-2006 07:43 PM

Quote:

$db->mysql_insert_id();
Input: None.
Returns: int Row ID of the latest INSERT operation.
this isn't right it's $db->insert_id();

akanevsky 06-15-2006 07:57 PM

Thank you for pointing that out. Corrected.

Antivirus 06-16-2006 08:30 PM

Thanks for taking the time to put this together anthony, i have been using it as a reference quite frequently.


All times are GMT. The time now is 11:36 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02982 seconds
  • Memory Usage 1,783KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_php_printable
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete