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

Reply
 
Thread Tools Display Modes
  #11  
Old 11-01-2001, 05:16 PM
Saint's Avatar
Saint Saint is offline
 
Join Date: Oct 2001
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Mark Hensler
[B]Wait.. do you want only those 2 pairs (login server, aol legends), or all 14 pairs? (I'm looking at pairs as the text and image)

Sorry all the 14 pairs.
Yes, pairs as in the text and image.


I'm still trying to absorb your code.
Am a newbie at this.


Thanks
Reply With Quote
  #12  
Old 11-02-2001, 01:44 AM
Mark Hensler's Avatar
Mark Hensler Mark Hensler is offline
 
Join Date: Oct 2001
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Let me try to break it down for you..
PHP Code:
// suck the remote file into a string
$remote_site join(''file("http://remote.domain.com/index.php") );

// now, pattern match for the desired text, in this case,
// $matches[3] will contain the value of the first red block (the name-like thingy)
//$matches[5] will contain the value of the second red block (the image source)
preg_match_all(
    
"|<tr>(.*)<a name=\"(.*)\">(.*):</a>(.*)<IMG SRC=\"(.*)\"(.*)</tr>|Ui",
    
$remote_site$matches);

/**
 * $matches now looks like this:
 * $matches[3][0] = first match for the name block
 * $matches[5][0] = first match for the image block
 * $matches[3][1] = second match for the name block
 * $matches[5][1] = second match for the image block
 * etc.
 */

// loop through all the matches
for ($i=0$i<count($matches[3]); $i++) {
    
// put the name/image info into more user friendly variables
    
$name $matches[3];
    
$image $matches[5];
    
    
// find out what the image source was...
    
if (strstr($image,'grnball.gif')) {
        
// the image source contains "grnball.gif",
    
}
    else {
        
// the imag source does not contain "grnball.gif",
        // so it must be "redball.gif"
    
}
    
    
// do your thingy
    // you might print a new table using the $name/$image from the other site

I hope that helps (probably not =P). If you have a specific question, those are easier to answer.
Reply With Quote
  #13  
Old 11-02-2001, 06:18 AM
Saint's Avatar
Saint Saint is offline
 
Join Date: Oct 2001
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

means I got to repeat that 14 times for the pairs?

and add $matches(0) for all the pairs?
Reply With Quote
  #14  
Old 11-02-2001, 06:37 AM
Mark Hensler's Avatar
Mark Hensler Mark Hensler is offline
 
Join Date: Oct 2001
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, it is already looping through all the pairs. See where I said "// do your thingy"?

Try it.. just make a new file, and through this in there....
PHP Code:
<?
$remote_site = join('', file("http://remote.domain.com/index.php") );

preg_match_all(
    "|<tr>(.*)<a name=\"(.*)\">(.*):</a>(.*)<IMG SRC=\"(.*)\"(.*)</tr>|Ui",
    $remote_site, $matches);

for ($i=0; $i<count($matches[3]); $i++) {
    $name = $matches[3];
    $image = $matches[5];

    echo "|" . $name . "|" . $image . "|";

    if (strstr($image,'grnball.gif')) {
        echo "the image is a green ball" . "|";
    }
    else {
        echo "the image is a red ball" . "|";
    }
    
    echo "<br>\n";
}
?>
Reply With Quote
  #15  
Old 11-02-2001, 06:54 AM
Saint's Avatar
Saint Saint is offline
 
Join Date: Oct 2001
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Warning: file("http://ulitma.lightning.net/uo/index.html") - Undefined error: 0 in /usr/local/www/vhosts/nettiq.com/htdocs/serverstats.php on line 2

Warning: Bad arguments to join() in /usr/local/www/vhosts/nettiq.com/htdocs/serverstats.php on line 2

I got this error when I try to run the php script.
Reply With Quote
  #16  
Old 11-02-2001, 02:57 PM
Mark Hensler's Avatar
Mark Hensler Mark Hensler is offline
 
Join Date: Oct 2001
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That URL doesn't work for me.
Reply With Quote
  #17  
Old 11-02-2001, 03:12 PM
Saint's Avatar
Saint Saint is offline
 
Join Date: Oct 2001
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

my mistake
typo
http://ultima.lightning.net/uo/index.html

I corrected it and when i run the php
it gives me a blank screen.
Reply With Quote
  #18  
Old 11-02-2001, 06:28 PM
Mark Hensler's Avatar
Mark Hensler Mark Hensler is offline
 
Join Date: Oct 2001
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try this:
PHP Code:
<?
echo "Yes, I'm running<BR>\n";

$remote_site = join('', file("http://remote.domain.com/index.php") );

preg_match_all(
    "|<tr>(.*)<a name=\"(.*)\">(.*):</a>(.*)<IMG SRC=\"(.*)\"(.*)</tr>|Ui",
    $remote_site, $matches);

echo "begining loop<BR>\n";

for ($i=0; $i<count($matches[3]); $i++) {
    $name = $matches[3][$i];
    $image = $matches[5][$i];

    echo "|" . $name . "|" . $image . "|";

    if (strstr($image,'grnball.gif')) {
        echo "the image is a green ball" . "|";
    }
    else {
        echo "the image is a red ball" . "|";
    }
    
    echo "<br>\n";
}
?>
Reply With Quote
  #19  
Old 11-02-2001, 06:38 PM
Saint's Avatar
Saint Saint is offline
 
Join Date: Oct 2001
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

trying now.
Reply With Quote
  #20  
Old 11-02-2001, 06:43 PM
Saint's Avatar
Saint Saint is offline
 
Join Date: Oct 2001
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nope.

Only get this 2 line

Yes, I'm running
begining loop

I should replace just the

$remote_site = join('', file("http://remote.domain.com/index.php") );

to http://ultima.lightning.net/uo/index.html right?

all the code stays.
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 08:04 AM.


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.04572 seconds
  • Memory Usage 2,271KB
  • Queries Executed 13 (?)
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
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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_postinfo_query
  • fetch_postinfo
  • 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