vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Pull data from XML and put in postbit?! (https://vborg.vbsupport.ru/showthread.php?t=48462)

digitalJE5U5 02-03-2003 02:53 AM

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

Link14716 02-03-2003 10:39 AM

$post[field5] should show profile field 5. :)

digitalJE5U5 02-03-2003 11:27 AM

OK, but what I really need is some php code to place the rating into the postbit.

filburt1 02-03-2003 12:07 PM

Here are some XML parsing functions if it helps: http://www.php.net/manual/en/ref.xml.php

digitalJE5U5 02-03-2003 12:25 PM

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.

mr e 02-03-2003 09:19 PM

to print stuff out on the page in php do

PHP Code:

print "whatever will get printed to the page ex: $post[field5]"


digitalJE5U5 02-03-2003 11:28 PM

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?

digitalJE5U5 02-04-2003 12:38 AM

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

digitalJE5U5 02-09-2003 08:01 PM

*bump*

Bane 02-11-2003 07:01 PM

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.

digitalJE5U5 02-12-2003 04:27 AM

That is very good advice. I had not even thought of that. Unfortunately, I don't know how to do any of that.


All times are GMT. The time now is 01:57 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.01016 seconds
  • Memory Usage 1,741KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (11)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete