Jump to content

SidewinderX

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

SidewinderX's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "C:/"); curl_setopt($ch, CURLOPT_COOKIEFILE, "C:/"); curl_setopt($ch, CURLOPT_URL,$host."myaccount.php"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "login_username=".$username."&login_password=".$password.""); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_exec($ch); $fp = fopen($host."accounts.php?ac_serverid=4", "r"); curl_close ($ch); fclose($fp); echo $fp; Yields: Not exactly what im looking for ???
  2. the direct link to the iframe would be $host."accounts.php?ac_serverid=4" so how would i go about doing that?
  3. Ive created a script to login to a site which works fine, but when I login, that site has an iframe I want to grab data from. The problem is the iframe displays a 404 error because the file it is looking for is account.php which is not on my server, but the server i am logging into. Using my script, how can I get access to the file thats in the iframe? <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "C:/"); curl_setopt($ch, CURLOPT_COOKIEFILE, "C:/"); curl_setopt($ch, CURLOPT_URL, $host."/myaccount.php?"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "login_username=".$username."&login_password=".$password.""); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_exec($ch); curl_close ($ch); ?>
  4. ok, well at first I wasnt sure if the problem persisted with all https connections, but I tested a few others and it is indded a problem with https. I emailed my host and after a few emails they replyed: [quote]Hi, Please check your script now.  We have opened outgoing connections to 443 on the server. Thank you.[/quote] Now, other https connections work, but not the one I want. Here is my current code: [code]<?php // create a new curl resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065"); curl_setopt($ch, CURLOPT_USERAGENT,  "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); curl_setopt($ch, CURLOPT_HEADER, 0); // grab URL and pass it to the browser curl_exec($ch); // close curl resource, and free up system resources curl_close($ch); ?>[/code] Also note, if i connect using a proxy it DOES work, but i would rather not use a proxy. Any other ideas?
  5. I built a program on my local server and it worked perfectly, I then uploaded it to my remote webserver and it does not work. I debuged it and found out it is a problem with the second line... the file_get_contents() function; it dosnt work for a particular URL. I tested this and it worked fine: [code]<?php $url = "http://www.google.com"; $content = file_get_contents($url); echo $content; ?>[/code] but when i try this code with the different url it dosnt work: [code]<?php $url = "https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065"; $content = file_get_contents($url); echo $content; ?>[/code] When i first started using this code on my local server I hade a problem with this also, and the issue was that https wasnt a registered stream, but i installed OpenSSL and it worked fine on my local server, however even on my remote server https is a registered stream and OpenSSL is installed. I then thought that novaworld.com may bock my from using file_get_conents (possable?). So rather than using file_get_contents I used a curl script to do the same thing. [code]<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); ?> [/code] Much to my dismay that didnt work either. Finally i did a #curl https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065 on my linux box i get: [quote]<html><head><title>Object moved</title></head><body><ht>Object moved to <a href='/Players/Search.aspx'>here</a>.</h2></body></html>[/quote] Could this be a cookie issue even though i dont go through 2 pages? Someone also mentioned they may filter the user-agent in requests. I have no idea what they are or how to combat that, but surley there is a way to connect to that website. I welcome all help. Thank you for taking your time to read this. Sidewinder
  6. The source looks like this for the portion im trying to parse (the whole source is attached) [quote]Player Statistics for Delta Force - Black Hawk Down Ozymandias. Rank: 1-Star General ( 14 ) [/quote] EDIT: ok this script works with the regex...and does exactley what i want, but i need some help cleaning it up (dont laugh LOL) [code]<?php $url = "https://www.novaworld.com/Players/Stats.aspx?id=8542545489&p=616065"; //Gets the content of the submited URL; $content = file_get_contents($url); //Strips the tags of the $content; $strip = strip_tags($content); preg_match('#Down (.*?) Rank#', $strip, $matches); $str = $matches[1]; echo $str; ?>[/code] [attachment deleted by admin]
  7. thats exactley the problem, i know the regex works fine, it just has to be the content of the string isnt matching the regex pattern. When the content is passed through these functions $content = file_get_contents($url); $strip = strip_tags($content); and then echoed, the output (echo $strip;) must be different then the actual content ($strip), no? like $strip might equal "Down<br>Ozymandias.<br>Rank" but when it is outputed the html is not displayed or something.....
  8. i believe thats a configuration issue on your part, check your php info and see if https is a registered stream, i dont think it is. For me: [quote][b]Registered PHP Streams[/b]  php, file, http, ftp, compress.zlib, compress.bzip2, https, ftps [/quote] EDIT: Well at first my errors werent on but i enabled theme and there were only a few warnings due to undefined variables, i fixed them but that didnt fix the overall problem as suspected; and yes, i have echoed every step of the way and it does exactley what i want. Infact i have parsed 100 stats from this page using a different parseing method and they all work fine. However because I am parseing a name which can be 16 alphanumeric characters including hypehns, underscores and spaces (and not just a number) only a regex would work for this. Thank You for your input, any other ideas? p.s. when i echo $stats in the first code it yields this: [quote]Hawk Down Ozymandias. Rank: 1-Star General ( 14 ) PCID: A13-3E71AC Player Created: June 9, 2006 TABLE.statsx TD, TABLE.statsx TH { height: 24px; font-size: 10pt; white-space: nowrap; } TABLE.statsx TD.left { background: url(/Images/Stats/cont_grn_01.gif); width: 2px; } TABLE.statsx TH { background: url(/Images/Stats/cont_grn_02.gif); text-align: left; font-weight: bold; } TABLE.statsx TD { background: url(/Images/Stats/cont_grn_02.gif); text-align: right; } TABLE.statsx TD.right { background: url(/Images/Stats/cont_grn_03.gif); width: 2px; } TABLE.statsx TR.spacer TD { background: url(/Images/Stats/spacer.gif); height: 2px; } Total Team Games Played: 568 Total Time Played: 4d 6h 50m Total Kills: 9596 Team Win Percentage: 60.21% Favorite Weapon Class: Assault Rifle Minutes in Zone (KOTH) 1300 Flags Captured (FB) 2 Targets Destroyed (A&D) 258 Awards Received Army Commendation Medal with 1 Bronze Oak Leaf Cluster Bronze Star with 1 Bronze Oak Leaf Cluster CQB Badge 1st Award Headhunter's Medal 1st Award Hill Giant Medal 1st Award Combat Infantryman Badge 1st Award Marksman Badge Combat Medical Badge 1st Award Purple Heart (12) Sapper's Badge 1st Award Overall Statistics TABLE.statsy TD, TABLE.statsy TH { height: 24px; font-size: 10pt; } TABLE.statsy TD.left { background: url(/Images/Stats/cont_blue_01.gif); width: 2px; } TABLE.statsy TH { background: url(/Images/Stats/cont_blue_02.gif); text-align: left; font-weight: bold; } TABLE.statsy TD { background: url(/Images/Stats/cont_blue_02.gif); text-align: right; } TABLE.statsy TD.right { background: url(/Images/Stats/cont_blue_03.gif); width: 2px; } TABLE.statsy TR.spacer TD { background: url(/Images/Stats/spacer.gif); height: 2px; } TABLE.statsz TD, TABLE.statsz TH { height: 24px; font-size: 10pt; } TABLE.statsz TD.left { background: url(/Images/Stats/cont_blk_01.gif); width: 2px; } TABLE.statsz TH { background: url(/Images/Stats/cont_blk_02.gif); text-align: left; font-weight: bold; white-space: nowrap; } TABLE.statsz TD { background: url(/Images/Stats/cont_blk_02.gif); text-align: center; } TABLE.statsz TD.right { background: url(/Images/Stats/cont_blk_03.gif); width: 2px; } TABLE.statsz TR.spacer TD { background: url(/Images/Stats/spacer.gif); height: 2px; } TABLE.statsz TR.header TH { background: url(/Images/Stats/spacer.gif); text-align: center; } IMG[/quote] and the regex is set up perfectly to parse that because it works in my pseudo code
  9. ok so i have this script that displays the content of a webpage [code] <?php $url = "https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065"; //Gets the content of the submited URL; $content = file_get_contents($url); //Strips the tags of the $content; $strip = strip_tags($content); //Removes Everything in the up to For:; $remove = stristr($strip, 'Hawk Down'); //Declares $remove as $getstats; $stats = $remove; echo $stats; ?> [/code] what i want to do is parse the name Ozymandias. from the $stats string. While trying to build my regex i used a pseudo-code so i could avoide the long load of getting the actual content of the website. The psuedo code is below: [code]<?php $string = 'Down Ozymandias. Rank: 1-Star General ( 14 ) PCID: A13-3E71AC Player Created: June 9, 2006 TABLE.statsx '; preg_match('#Down (.*?) Rank#', $string, $matches); $str = $matches[1]; echo $str; ?>[/code] the $string is a word for word exerpt from the $stats string in the first code. So i figured I could use $string to test out my regex and when i get it to work just replace the static $string with the dynamic string ($stats). The regex above works fine with the static string but when i encorperated it into the larger script it does not work. [code]<?php $url = "https://www.novaworld.com/Players/Stats.aspx?id=33680801261&p=616065"; //Gets the content of the submited URL; $content = file_get_contents($url); //Strips the tags of the $content; $strip = strip_tags($content); //Removes Everything in the up to For:; $remove = stristr($strip, 'Hawk Down'); //Declares $remove as $getstats; $stats = $remove; preg_match('#Down (.*?) Rank#', $stats, $matches); $str = $matches[1]; echo $str; ?>[/code] I have NO idea whats wrong, this is the only part of the code that is holding me back from completing this script. If someone could please help me solve this problem i would really appreciate it. Thank you
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.