vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.7 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=228)
-   -   Integration with vBulletin - vbulletin-xml-rpc-server for instant Desktop Notification (https://vborg.vbsupport.ru/showthread.php?t=194180)

ZomgStuff 10-22-2008 04:30 PM

I've got it figured out, for those who don't use prefix's for their tables here are the two changes
forum.php
PHP Code:

<?php
/**
 * forum.php
 * 
 * This file contains user relevant functions. 
 * 
 * @author  Sword^Fish <swordfish@nsuers.com>
 * @version 1
 * @since   Release 1
 * @package vbulletin-xml-rpc-server
 * 
*/
require_once("server.php");

/**
 * returns detail of latest thread
 *
 * @global Database $GLOBALS['DB']  database connection object
 * @param  string   $args[0] token
 * @return array
 * @todo   check usergroup permission
*/

function forum_latest_thread($method_name$args$app_data)
{
    
    
$obj_token = new Token($args[0]);
    
/* check: token is assigned to an user */
    
if($obj_token->userid == null)
    {        
        return array(
'faultCode'   => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['SERVICE_TOKEN_INVALID']['code'],
                     
'faultString' => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['SERVICE_TOKEN_INVALID']['string']);    
        
    } 
    
/* check: token is alive (not expired) */
    
if($obj_token->is_alive == 0)
    {        
        return array(
'faultCode'   => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['SERVICE_TOKEN_EXPIRED']['code'],
                     
'faultString' => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['SERVICE_TOKEN_EXPIRED']['string']);        
    }     
    
    
/* we shall use this token, so increase  usages counter */        
    
$obj_token->update_count($obj_token->token);
                
    
/* prepare query string */            
    
$query="SELECT 
                f.forumid AS forum_id, f.title AS forum_name,
                t.threadid AS topic_id, t.title AS topic_title,
                p.postid AS post_id, p.dateline AS post_time,
                u.userid AS user_id, u.username
            FROM thread t, forum f, post p, user u 
            WHERE   t.threadid = p.threadid
                AND f.forumid  = t.forumid
                AND p.postid   = t.lastpostid 
                AND p.userid   = u.userid                 
            ORDER BY t.lastpostid DESC LIMIT 1"
;
                
    
/* run query string */
    
$rows $GLOBALS['DB']->run($query);

    if(
$rows)
    {
        return 
$rows[0];
    }    
    return array(
'faultCode'   => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['SERVICE_FAIL']['code'],
                 
'faultString' => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['SERVICE_FAIL']['string']);    
}
?>

user.php
PHP Code:

<?php
/**
 * user.php
 * 
 * This file contains user relevant functions.
 * 
 * @author  Sword^Fish <swordfish@nsuers.com>
 * @version 1
 * @since   Release 1
 * @package vbulletin-xml-rpc-server
*/

require_once("server.php");

/**
 * authenticates a user and returns user id
 * Check for valid username and password.
 * Username must be associated with a registered account in vBulletin database.
 * User account must be verified one. 
 *
 * @global Database $GLOBALS['DB']  database connection object
 * @param  string $args[0] username
 * @param  string $args[1] password
 * @return mixed  returns int userid or array on login failure
 * @todo   check for verified account
 * @todo   check for banned account
*/

function user_login($method_name$args$app_data)
{    
    
    
//checkpost: valid username
    
if(_is_valid_username($args[0]) == false)
    {
        return array(
'faultCode'   => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['USER_SERVICE_USERNAME_DNE']['code'],
                     
'faultString' => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['USER_SERVICE_USERNAME_DNE']['string']);                
    }
    
/* TODO: checkpost: email verified */
    
    /* TODO: checkpost: userid is not in banned group */
    
    /* checkpost: valid password */
    
$GLOBALS['DB']->set_entity("user"," ");    
    
$resource $GLOBALS['DB']->fetch(array("userid"), 
                                         
$filter = array("username LIKE '{$args[0]}'",
                                                      
" AND ",
                                                      
"password LIKE MD5(CONCAT(MD5('" $args[1] . "'), salt))"),
                                      
null,
                                      
0,
                                      
1);    

    if(
$resource/* valid query returned valid user id */
    
{
        
        
/* create token */
        
$token $GLOBALS['OBJ_TOKEN']->create($resource[0]['userid']);     
        if(
$token/* return token string */
        
{            
            return (string)
$token;
        } else {
            return array(
'faultCode'   => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['SERVICE_TOKEN_GENERATION']['code'],
                         
'faultString' => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['SERVICE_TOKEN_GENERATION']['string']);
        }
                
    } elseif(
$resource === false) { /* query error */
        
return array('faultCode'   => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['SERVICE_FAIL']['code'],
                     
'faultString' => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['SERVICE_FAIL']['string']);        
        
    }
    
/* login is invalid */    
    
return array('faultCode'   => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['USER_SERVICE_LOGIN']['code'],
                 
'faultString' => $GLOBALS['VBULLETIN_XML_RPC_ERROR_DB']['USER_SERVICE_LOGIN']['string']);        
}

/**
 * verifies userid existence
 *
 * @global Database $GLOBALS['DB']  database connection object
 * @param  int      $userid         userid
 * @return boolean 
*/
function _is_valid_username($username)
{
    
$GLOBALS['DB']->set_entity("user"," ");
    return 
$GLOBALS['DB']->check_record($username'username');
}

?>


River_rush 10-22-2008 05:16 PM

Quote:

Originally Posted by River_rush (Post 1650464)
Hi, i am getting

com.nsuers.vbulletin_xml_rpc_client.ServiceError
at com.nsuers.vbulletin_xml_rpc_client.VbulletinXmlRp cJClient.require_token(VbulletinXmlRpcJClient.java :97)
at com.nsuers.vbulletin_xml_rpc_client.ForumServ.get_ latest_tread(ForumServ.java:33)
at Notifier$AutoCheck.run(Notifier.java:213)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)

in the error log and no messages via the notifier other than its running

also what command do i run to uninstall the sql code from this should I require too please?

Hi did you see this post please/? I should add that if I put your forum details in it works ok!

ZomgStuff 10-22-2008 05:32 PM

A recommendation I would add is to display the avatar of the person who made the post in the pop-up.

sf.nsuers 10-22-2008 05:41 PM

Quote:

Originally Posted by River_rush (Post 1650568)
Hi did you see this post please/? I should add that if I put your forum details in it works ok!

yes.. I've updated MOD description and mentioned possible reasons for getting such errors. Please make sure you're running php5 and php is compiled with xmlrpc-epi lib.

sf.nsuers 10-22-2008 05:42 PM

Quote:

Originally Posted by ZomgStuff (Post 1650574)
A recommendation I would add is to display the avatar of the person who made the post in the pop-up.

C00L! Thanks for this idea. added in TODO list.

ZomgStuff 10-22-2008 05:53 PM

Quote:

Originally Posted by sf.nsuers (Post 1650584)
C00L! Thanks for this idea. added in TODO list.

A couple other reommendations here.
1) Forum checking. Currently all people using it will get notifications from any new post in any forum, including those that they do not have access to.

Should be something simple along the lines of
PHP Code:

fetch_permissions($row["forumid"]) & $vbulletin->bf_ugp_forumpermissions['canview'

2) Have a link to go directly to the new post in the pop-up, and also having the option to right click the tasktray icon as well...

3) Don't display latest messages made by yourself. After you make your own post it will tell you that there's a new message by you several seconds later.

5) Add support for private-messages

6) Add support for new registrations.

I'd be willing to co-author this mod with you if you would like, I see a lot of potential in this. I'd be able to work more on the back-end of the PHP, SQL, and vBulletin integration than the Java portion. PM me if you'd be interested.

Darkstarproject 10-22-2008 07:33 PM

Love this mod!

Is there a way you can make it notify for a new PM ?

WarLion 10-22-2008 08:07 PM

is a shame i dont have php5 i have to unistall

River_rush 10-23-2008 12:04 AM

Quote:

Originally Posted by sf.nsuers (Post 1650582)
yes.. I've updated MOD description and mentioned possible reasons for getting such errors. Please make sure you're running php5 and php is compiled with xmlrpc-epi lib.

I will have to uninstall this then as lunarpages (a major host) is still running PHP Version 4.4.9

sf.nsuers 10-23-2008 12:05 AM

Quote:

Originally Posted by ZomgStuff (Post 1650594)
A couple other reommendations here.
1) Forum checking. Currently all people using it will get notifications from any new post in any forum, including those that they do not have access to.

Should be something simple along the lines of
PHP Code:

fetch_permissions($row["forumid"]) & $vbulletin->bf_ugp_forumpermissions['canview'

2) Have a link to go directly to the new post in the pop-up, and also having the option to right click the tasktray icon as well...

3) Don't display latest messages made by yourself. After you make your own post it will tell you that there's a new message by you several seconds later.

5) Add support for private-messages

6) Add support for new registrations.

I'd be willing to co-author this mod with you if you would like, I see a lot of potential in this. I'd be able to work more on the back-end of the PHP, SQL, and vBulletin integration than the Java portion. PM me if you'd be interested.

excellent! I'll PM you about project hosting details by tonight. :-D


All times are GMT. The time now is 08:30 AM.

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

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01389 seconds
  • Memory Usage 1,812KB
  • 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
  • (4)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (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