Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-03-2003, 02:53 AM
digitalJE5U5 digitalJE5U5 is offline
 
Join Date: Sep 2002
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Pull data from XML and put in postbit?!

OK, I'm completely lost. But I know this is simple stuff for you guys. I have a Age of Mythology Clan site, and I want to put the users rating into the postbit, under their name.

I think I've found out how to access this rating, which is ever-changing by going here:

http://aom.stats.zone.msn.com/AOM_RC0/query/query.aspx?<?xml version="1.0"?><clr><cmd v="query"/><co g="AOM_RC0" s="100" z="1.0.3"/><qer id="ESO.Query.Example.68.184.73.72" np="0" nn="0" si="0" en="GX_Iron" et="ZS_Human" md="ZS_Lightning" rn="ZS_TopPlayers" tp="ZS_AllTime"/></clr>

In the example above, GX_Iron should be a variable ($post[field5]) . My problem is how do I extract the field (parse?) "primaryrating" from the above resulting XML(link has the XML) and place(print?) it in the postbit?

I've searched everywhere for this, but can't find a simple answer.

Please help.

Thanks,
/DJ
Reply With Quote
  #2  
Old 02-03-2003, 10:39 AM
Link14716's Avatar
Link14716 Link14716 is offline
 
Join Date: Jun 2002
Location: Georgia, USA
Posts: 2,519
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$post[field5] should show profile field 5.
Reply With Quote
  #3  
Old 02-03-2003, 11:27 AM
digitalJE5U5 digitalJE5U5 is offline
 
Join Date: Sep 2002
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, but what I really need is some php code to place the rating into the postbit.
Reply With Quote
  #4  
Old 02-03-2003, 12:07 PM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here are some XML parsing functions if it helps: http://www.php.net/manual/en/ref.xml.php
Reply With Quote
  #5  
Old 02-03-2003, 12:25 PM
digitalJE5U5 digitalJE5U5 is offline
 
Join Date: Sep 2002
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ive read that as well as serveral others. Im beginning to understand some of it, but I don' know how to code php. If I had a sample bit of code, I know enough to be able to edit the code, but I certainly cannot write the code from scratch.
Reply With Quote
  #6  
Old 02-03-2003, 09:19 PM
mr e's Avatar
mr e mr e is offline
 
Join Date: Dec 2001
Posts: 461
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

to print stuff out on the page in php do

PHP Code:
print "whatever will get printed to the page ex: $post[field5]"
Reply With Quote
  #7  
Old 02-03-2003, 11:28 PM
digitalJE5U5 digitalJE5U5 is offline
 
Join Date: Sep 2002
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok, but what I want to "print" is in an XML file at that link. How do I take "primary rating" out of the XML file and "print" that?
Reply With Quote
  #8  
Old 02-04-2003, 12:38 AM
digitalJE5U5 digitalJE5U5 is offline
 
Join Date: Sep 2002
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, below is some code that takes the "rating" off that page.
PHP Code:
function getmicrotime()
{
  list($usec, $sec) = explode(" ",microtime()); 
  return ((float)$usec + (float)$sec); 

$starttime = getmicrotime();

$t = time();        
$url = "http://aom.stats.zone.msn.com/AOM_RC0/query/query.aspx";
$q = "<?xml%20version=\"1.0\"?><clr><cmd%20v=\"query\"/>";
$q .= "<co%20g=\"AOM_RC0\"%20s=\"100\"%20z=\"1.0.3\"%20t=\"".$t."\"%20U=\"6\"/>";
$q .= "<qer%20id=\"0\"%20np=\"0\"%20nn=\"20\"%20si=\"0\"%20et=\"ZS_Human\"%20md=\"ZS_Supremacy\"%20rn=\"ZS_TopPlayers\"%20tp=\"ZS_AllTime\"/>";
$q .= "</clr>";
        
$top20 = array();
$rdf = parse_url($url);
$fp = fsockopen($rdf['host'], 80, $errno, $errstr, 30);
if (!$fp) {
    echo "Problem loading ESO Stats Data";
    return;
    }
if ($fp) {
    fputs($fp, "GET " . $rdf['path'] . "?" . $q . " HTTP/1.0\r\n");
    fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n");
    $string    = "";
    $pagetext = "";
    while(!feof($fp)) {
        $pagetext .= chop(fgetc($fp));
    }
    fputs($fp,"Connection: close\r\n\r\n");
    fclose($fp);
    $string = chop($pagetext);
    $items = explode("\"",$string);
    $lines = count($items);
    $offset = 1;
    for ($i=23;$i<$lines;$i+=12) {
        $top20[$offset]["name"] = $items[$i];
        $top20[$offset]["rank"] = $items[$i+2];
        $top20[$offset]["rating"] = intval($items[$i+6]);
        $offset++;
    }
        ## Hint:  Changing the "6" below to a larger number will increase the number of players displayed.  Max. = 20 ##
    for ($j=1;$j<2;$j++) {
        $rating .= $top20[$j]["rating"];
    }
}
Maybe that better illustrates what Im trying to do. Now, I did NOT by any means write that code. I found it, and modified it to do what I need.

2 things:
1- What extranious things can I remove from that code, so its more streamlined? Can I 86 the microtime stuff?
2- Where in global.php should I put the finished code, so that I can pull $rating and have it show up wherever I put that variable?

Thanks alot for the help guys.
/DJ
Reply With Quote
  #9  
Old 02-09-2003, 08:01 PM
digitalJE5U5 digitalJE5U5 is offline
 
Join Date: Sep 2002
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

*bump*
Reply With Quote
  #10  
Old 02-11-2003, 07:01 PM
Bane's Avatar
Bane Bane is offline
 
Join Date: Oct 2001
Posts: 411
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are you trying to do this every post? This is going to slow you down A LOT I would think. Maybe you should make some sort of script to run once a day to grab the rankings and put them in a user field.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:47 PM.


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.11055 seconds
  • Memory Usage 2,262KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete