Jump to content

HaLo2FrEeEk

Members
  • Posts

    724
  • Joined

  • Last visited

    Never

Everything posted by HaLo2FrEeEk

  1. The URL does work in a browser, you just have to provide a username for an online user. If the user is not currently online, the return will simply be: [ ] if the usr doesn't exist, or no name is provided, then you'll get an error page with an "HTTP Status 409" message. Try going here: http://www.stickam.com/servlet/ajax/sessionMembers?sessionType=live And getting a username from the list, it'll be the first value in each of the arrays. Put that username after the URL: http://www.stickam.com/servlet/ajax/getLiveUser?uname= And it should work. Like I said, I can do it just fine using the same script on my local computer's Apache server. I literally wrote the script on my local server, got it working, then saved the same script to my FTP and tried to load it. Is there some way to create a stream context using an exact copy of the header data that the browser requesting the page used? Come to think of it, is there actually any way to view the header data that my browser sent?
  2. I'm writing a quick little script to grab some information from Stickam.com, specifically using the "API" they have set up to get a user id from a provided username, and a username from a provided userid. These are both publically accessible pieces of information, so I'm not getting into anything I shouldn't, I'm just using the publically accessible API instead of scraping the HTML. For some reason I can't explain though, I can't seem to get the contents of the page using PHP. Here's my code: $username = @$_GET['username']; if(!$username) { die("no username"); } $url = "http://www.stickam.com/servlet/ajax/getLiveUser?uname=".$username; $html = file_get_contents($url, false, $context); echo "<pre>"; echo $html; echo "</pre>"; But everytime I load this page on my server, I get this response: Warning: file_get_contents(http://www.stickam.com/servlet/ajax/getLiveUser?uname=[username]) [function.file-get-contents]: failed to open stream: Connection timed out in [file] on line 7 I can load it just fine on my Apache server running on my personal computer, and in my browser (both IE9 and Firefox), but not on my website. I've tried mimicking the headers that my browser sends and creating a stream context to send with the file_get_contents() call, but so far nothing seems to work. Any ideas?
  3. Wow, it's like my very long, very descriptive post detailing examples of use and english translations for each type of loop (except do-while,) just doesn't exist. Sure am glad I took all that time to write it all up.
  4. If you plan to display all these sub categories on a single page (unlike Google, which only displays two or three subcategories for each main category,) then you'll need to look into recursive functions. Basically the code runs over and over as deep as the tree goes until it hits an end, hen it goes back up to the next and prints the next sub-sub-sub whatever category. If you're looking to make it exactly like Google, where only a few sub categories are shown for each main category, then as you click a main category all the sub categories are shown (I'm getting really tired of typing the word category,) that'll be a lot simpler. You'll basically just pass the current category's name (or ID) to the script, which will look up all sub categories (or whatever is at the bottom, if there are no sub categories,) and print them to the page. All you'll need to define in the database is each sub category's parent category. Here's a very simple example: http://infectionist.com/tutorials/ This is a page on my own site that lists the different tutorial categories that I have available. Click on one of these main categories and you'll be presented with a page that lists each individual tutorial for that category. Seriously, tired of typing that word!
  5. That's not how things work here at PHP Freaks. We're not here to give you the answers, or do the work for you, or give you intricate details on how to do something. We're here to help YOU find the answers, to point you in the right direction. Give a man a fish he eats for a day, teach him to fish and he eats for the rest of his life. Now, I'm assuming you're using a Windows server, since you mentioned you have Windows 7. Unfortunately I would only know how to help you if it were a linux server, in which case the answer would be CRON. As far as Windows servers go, though, I don't know how to schedule a php script to execute.
  6. I've always thought of for loops as more defined while loops. Here is an example: for($i = 1; $i <= 10; $i++) { echo "This is line " . $i . "<br>\n"; } In plain English, here is what's happening: The variable $i is defined with a value of 1 The loop is set to run while the value of $i is less than or equal to 10 (so it'll run 10 times) The loop is instructed to increase the value of $i after each iteration (each time it runs the loop) The code executes, printing 10 lines reading "This is line 1"..."This is line 10" The loop exits. The same can be done with a while loop: $i = 1; while($i <= 10) { echo "This is line " . $i . "<br>\n"; $i++; } Almost the exact same thing is happening here, only in a different order: $i is defined with a value of 1 The loop is instructed to continue running, as long as the value of $i is less than or equal to 10 (so it'll run 10 times) The first line executes, printing the line "This is line 1" The second line executes, increasing the value of $i to 2 The loop checks that the value of $i is still less than or equal to 10, if it is, it prints the next line The loop continues until the line "This is line 10" prints The value of $i is increased to 11 The loop exits since the value of $i (11) is now greater than 10. Foreach loops are probably my favorite type of loop. They're great for working with arrays: $array = array("Hello" => "World"); foreach($array as $key => $value) { echo "The item with key \"" . $key . "\" has a value of \"" . $value . "\".<br>\n"; } They're also very simple to explain: For each item in the array $array, define $key as that item's key, and define $value as that item's value (ex. ["Hello"] = "World") Using the above example, I would get a line that looked like this: The item with key "Hello" has a value of "World". The loop continues until all items in the array have been processed. Once you understand them, loops are actually quite easy to work with and they REALLY come in handy. If you have any more questions please feel free to let me know and I'll do my best to help you out.
  7. I can think of a few reasons you might be having an issue. If you solved this already then great, but I'd still like to put in my $0.02 (two cents.) First, unless you're just not posting it, I don't see an end to your while loop. You're missing the closing } Next, you're using mysql_fetch_array, which returns a numerically-indexed array, not an associative array, yet you're trying to get the value from the result using $row['name'], you should change mysql_fetch_array() to mysql_fetch_assoc(). And finally, $row is an array, not a string, so when echoing it you're only going to get this: Array() What you should do is something like this: $query = mysql_query("SELECT * FROM $tbl_name") or die(mysql_error()); while($row = mysql_fetch_assoc($query)) { echo = "p_doctor_name=" . $row['name'] . "&p_name_type=A&p_search_type=BEGINS"; echo "<br>\n"; } This will print the POST info that you want. Alternatively, if you want to use the POST info later in the script, you could change the first echo line in the loop, to this: $postinfo[] = "p_doctor_name=" . $row['name'] . "&p_name_type=A&p_search_type=BEGINS"; And remove the echo "<br>\n"; line. That will create an array containing each of the lines, which you can then iterate through in a foreach loop.
  8. You call for a variable named $refid in your query, yet this variable doesn't exist before the query is executed, thus the variable's value will be empty, making your query look like this: SELECT * FROM reference.users WHERE reference.user_name = users.user_name AND reference.refid = '' I would also recommend that you capitilize the keywords in your query, like SELECT, FROM, WHERE, and AND. If makes t easier to read. Anyway, so right now you're selecting everything from the reference.users table where reference.user_name is equal to users.user_name and where the reference.refid is empty. Unless I'm missing something. I think the problem is here: WHERE reference.user_name = users.user_name You're telling it to select everything from the reference users table where the names are the same, which you said they were. You collect the POST variable user_name, why not use that in your query? $user_name = $_POST['user_name']; $refid = $_POST['refid']; $query = "SELECT * FROM reference.users WHERE reference.user_name = '".$user_name."' AND reference.refid = '".$refid."'"; Without more background into what exactly you're doing (I'm having difficulties understanding your description,) I can't help much more.
  9. Or perhaps if someone gave you a link you should click it and read it and learn. Hmmmm... I understand that, yes, you can learn from reading the code, but only if you actually understand what is being done. Why don't you try it yourself. Here's an assignment: Write a script that will delete all files in a single folder, but not the actual folder itself.
  10. Next time try googling. And don't expect anyone to write you code, that's way presumptious...especially when you're asking people to write code to delete all files on a server. The whole point of this forum is to learn.
  11. I'm trying to create a QRCode decoder in PHP. I'm not sure if something like this has been created already, but from my searching, I don't think it has. If you don't know what QRCodes are, they're basically 2D barcodes that let you store a lot of information. Here's an example: (mouse over for the whole thing) This code is simple, just contains the text "0123456789", but it's just for testing purposes. I'm basically working my way up a QRCode generator script, doing everything in reverse. it's obviously possible to decode them, there are many barcode readers for mobile phones capable of doing it, and there's also this site: http://zxing.org/w/decode.jspx But the source for that web-based decoder isn't available, and I'd like to try and figure it out on my own. Ok, so now that you know the context, here's what I'm doing. First, I read the image and get it's width and height, which should always be equal. I start at the top-left corner and work my way down 1 pixel at a time in a diagonal line until I find a pixel of a different color (the border is always white, but not always the same width.) Once I've found a different colored pixel, I know how wide my border is. Starting at the border offset, I again recurse down until I hit another white pixel, this gives me my block width (the width and height of each square in the image.) I then find the "smallsize" of the image, the size I have to make it so that each square is a single pixel, without the border. I then do an imagecopyresized() to shrink the image down to it's smallest size, making each square a single pixel. And this is where I'm stuck. I need to read the value of each of the pixels, BUT, I need to ignore some as well. The larger squares in the top-left and right, and bottom-left are positioning data, used to tell mobile scanners how to rotate the image to read it. I don't need their pixel data. Each of the positioning squares are 8x8. There are also lines of timing data. I'm not sure what it's for, but it's not part of the data and I don't need it's pixel value either. Here's another version of that same image above, but with the data pixels turned red: The 3 8x8 squares in the corners and the black pixels apart from those need to be ignored. Basically what I'm doing now is I'm just iterating through every pixel, like this: $x = 0; while($x < $smallsize) { // while x is less than 21 $y = 0; while($y < $smallsize) { // while y is less than 21 $vals[$x][$y] = imagecolorat($shrink, $x, $y); $y++; } $x++; } And that gives me an array or each pixel's on/off value. So since Idon't need the positioning and timing pixels, how would I go about ignoring them?
  12. You know what it was, something completely stupid. DOCTYPE! When I'm testing scripts like this I usually don't make them fully HTML compliant, after all I'm just testing a concept. When I put them into the working environment I abviously put them into compliant pages. Well, apparently using the position: fixed attribute requires that a strict or XHTML doctype be set. Adding that single line in fixed everything right up. I now have a working PHP progress bar: http://halo3shots.infectionist.com/progress.php
  13. I'm trying to make a div position itself at the bottom of the window, fixed location so that regardless of my scroll position it always stays at the bottom, and inside it has layered children divs. Basically I've got a wrapper div, and inside I've got 2 child divs. One of the child divs displays completion percentage text, the other a progress bar. I want the text div to be on top of the progress bar div, and all of it to be inside the wrapper div, at the bottom of the window. Here is my HTML and CSS: CSS <style> body { margin: 0px; } #progress_wrapper { position: fixed; bottom: 0px; margin: 0px auto; width: 100%; height: 20px; background-color: gray; z-index: 0; } #progress { position: absolute; bottom: 0px; left: 0px; height: 100%; border-right: 1px solid black; background-color: #0f81a7; z-index: 50; } #progress_text { position: absolute; bottom: 0px; left: 0px; width: 100%; height: 100%; color: #FAFAFA; text-align: center; z-index: 100; } </style> HTML <div id="progress_wrapper"> <div id="progress_text">Loading...</div> <div id="progress" style="width: 0%;"></div> </div> This should work, but what I get instead is the wrapper div positioned at the top of the window and the text and progress bar positioned at the bottom, layered properly, and it still won't stay fixed, both the wrapper at the top and the progress and text bars at the bottom scroll with the window, I need their position to be fixed at the bottom. There has to be a way to make this work! Please, I tried asking at another forum and the question got completely ignored. This is a brick wall in my development and I can't get any further without figuring this out, please someone help me!
  14. Yeah uhm...I'm gonna let his reply speak for me.
  15. Ok, so I found out that if I output more than 64kb to the browser, it'll get sent, so basically all I have to do is output 64kb+ every iteration of my loop. Since that's not feasible, and since I know it's not a browser issue, I've written my host's tech support and they're working with me on the problem. The reason I know it's not a browser thing is because it does the same thing in both Internet Explorer and Firefox. It does this whether I have output buffering on or off and whether I ob_flush() and flush() or not.
  16. I'll try it, but I don't see how it's gonna help, we're talking about text here, not images or anything. I will try though and edit. Edit: Didn't make any difference. So I've created my own php.ini, and I know it's being used because I changed the value of output_buffering from 4096 to Off and the change was reflected in a phpinfo() print. Is there anything else I should change? changing the output_buffering setting didn't help. I've got zlib.output_compression set to Off also.
  17. I tried it but all that's happening is the script loads completely, waiting through the entire loop, then at the end the progress bar counts up really quickly while it executes all the Javascript. It doesn't output the buffer contents between each loop. I've contacted Dreamhost and they said that I can create my own local installation of php specific to my account, and I can apply it to a single domain. My PHP's output_buffering value is set to 4096, so I think I need to send more than 4096 bytes each time for the buffer to actually be output. I'll do a test and see if it works.
  18. I understand what you're saying, but I disagree. I know it's not my browser because every tool that I've used to check whether it's requesting compressed content reports that it indeed is. I've also checked Firefox with the same results. I know it's not my ISP because of the same thing I said above, how would those pages know I was requesting compressed content if it was being blocked by my ISP? Also, I can view other pages using this method, such as this one here: http://www.johnboy.com/php-upload-progress-bar/ Works just fine in both IE (my main browser) and Firefox. Also, my host tells me that gzip is disabled for this domain, so do all the tools I've used to check. That leaves php, which brings me back to the question I've asked multiple times now. Could this have something to do with PHP's own gzip capabilities and how would I test it? How can I disable php's gzip and try this page without it? I just used this page: http://www.port80software.com/products/httpzip/ To check the compression on my site. It turns out that while the root domain is indeed uncompressed, php pages are still being compressed. I checked with http://halo3shots.infectionist.com and it showed uncompressed, but when I checked http://halo3shots.infectionist.com/progress.php (the page I'm using to test the progress bar) it showed compressed. So there's my problem, how can I disable php's gzip comprssion? Edit: WAIT. I must've made a spelling error when I typed in the php page's url and it was reading the error page. Turns out the progress.php page is actually uncompressed...I'd still like to know how to turn off php gzip compression though.
  19. That still didn't work. I just had to wait 20 seconds and all 20 numbers were printed at once. This is weird, because I've seen it done! I read everywhere that having gzip enabled disrupts this, so I had my host turn off gzip for that domain. Here are 2 pages that report that gzip is indeed turned off: http://www.whatsmyip.org/http_compression/?url=aHR0cDovL2hhbG8zc2hvdHMuaW5mZWN0aW9uaXN0LmNvbQ== http://www.port80software.com/tools/compresscheck.asp?url=halo3shots.infectionist.com Both report that this particular subdomain is not being gzipped. I asked my hosting provider if php's gzip could have something to do with it but they weren't able to answer. I also asked on another forum and they asked about whether I had APC installed. I don't know if I have it installed, like I said I'm on a shared hosting plan with Dreamhost, but I'd really like to get this working. I have a script that can run for up to a minute and I don't want my members wondering what the heck is going on. I tried thinking how I could use AJAX for it, but I can't seem to wrap my head around it. Basically I'd have to have the main page make an AJAX call for another page which would do part of the work (luckily the script is running a long time because of multiple tasks, not just one), then when that other page finishes I'd send the result back to the server and make another call. The part I'm not getting is how I'd tell the Javascript to wait until the task is finished to send the next request, everytime I try sending multiple AJAX requests it sends them all at the same time. Either way will work, I'd prefer the PHP method though.
  20. Ok, I know ths is possible, an example is here: http://www.johnboy.com/php-upload-progress-bar/ It uses the ob_flush() and flush() functions of PHP. From what I've read, these functions have no effect if mod_gzip is enabled in your apache server. I'm on a shared hosting plan with Dreamhost and they have mod_gzip enabled, but you can request to have it turned off for certain subdomains. I did so, but it seems that it didn't have an effect. Here is my code: <?php ob_start(); for ($i = 0; $i < 5; $i++) { echo $i . "<br>"; ob_end_flush(); ob_flush(); flush(); sleep(1); ob_start(); } ob_end_flush(); ?> This should output numbers from 0 to 5 over 5 seconds, sequentially, WHILE the page is loading. Instead it just takes 5 seconds for the page to load and then outputs the whole thing at once. I need to know how to make this work. I have a script that can take 30-45 seconds to run and I want something for my users to look at. Using Flash really isn't an option because I don't know flash. I COULD use AJAX and simply send a request to another script, but I'd like to try to avoid anything that requires Javascript. Please, if you guys could help me out, I'd be super grateful!
  21. Bump! Why is it that every question I ask here isn't getting answered? Seriously the last like, 4 questions I've asked have been completely ignored!
  22. I've been using stream_context_create() to send cookies along with a file_get_contents() call when requesting a remote page. This is useful if I need to pass information to the remote page that my server can't pass, like a login form. This works perfectly well when I've got a single cookie, or multiple cookies on the same domain and path, but what if I need to send multiple cookies that work for multiple different domains or paths? Here's an example code: <?php $cookies = array("Cookie: testcookie=blah; testcookie2=haha; path=/; domain=infectionist.com;"); $opts = array('http' => array('header' => $cookies)); $context = stream_context_create($opts); $html = file_get_contents("http://infectionist.com/misc/testing/cookie.php?do=view", false, $context); echo $html; ?> This will utilize a quick script that I wrote that displays the values of 2 cookies named "testcookie" and "testcookie2". Notice in the cookies array, I've got both cookies set, and since both work on the same path and domain, they both appear properly. But I've got a page that I need to retrieve while sending multiple cookies from multiple domains (actually subdomains of the requested domain) and/or paths. How might I accomplish this? I tried making my cookies array have multiple values, like this: $cookies = array("Cookie: testcookie=blah; path=/; domain=infectionist.com;", "Cookie: testcookie2=haha; path=/; domain=infectionist.com;"); But that didn't work, only the first cookie was set. I can't seem to figure out how this might be done, but I'm sure someone else has done it before. Any help with this will be greatly appreciated!
  23. There's a website that I want to parse for links, but the site employs a AgeGate, to prevent underage people from downloading the videos. They're game videos, I'll clarify that, NOT adult-related videos. The game is simply rated M so the AgeGate is for legal reasons. As I said, I want to be able to parse the pages for links to these videos. The way the AgeGate works is, I assume, if you don't have a cookie with a certain value, then you're presented with a page containing a form. In this form you enter your birthdate in this format: MM/DD/YYYY and click "Confirm Age." This shoots off a bunch of Javascript and does some doPostBack() stuff, then lets you download the video. If you already HAVE the cookie on your computer, clicking the page will just automatically download the video file. I've managed to figure out exactly what's happening with the Javascript and make a bookmarklet out of it, this is the Javascript being run in that bookmarklet: javascript: (function () { options = new WebForm_PostBackOptions('ctl00$mainContent$ageSubmit', '', true, '', '', false, true); document.getElementById('ctl00_mainContent_userAge').value = '08/17/1989'; __doPostBack(options.eventTarget, options.eventArgument); })(); Basically what's happening is I'm setting up my PostBack options array into the options variable. I then set the text field of the form to my birthdate, then I fire off the __doPostBack() function. I'd like to know how to bypass this form and just get at the direct link to the video file (which is provided for me once I've filled out the form, I just want to automate it on my server with PHP.) I'm trying to find if there's a way to pass the age value to the page via a url parameter but I don't think there is. So basically, is there any way to run this Javascript on this page using my server? Can I fetch the page (using something like file_get_contents()) and then run this Javascript on it so I can get at the link? Btw, I tried running get_headers() on the video link, this was my result: Array ( [0] => HTTP/1.1 200 OK [Connection] => close [Date] => Thu, 25 Mar 2010 09:26:26 GMT [server] => Microsoft-IIS/6.0 [P3P] => CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo TELo" [X-Powered-By] => ASP.NET [X-AspNet-Version] => 2.0.50727 [X-Blam] => Frog blast the vent core! [set-Cookie] => BlamDotNet=EDM=312449634; domain=bungie.net; path=/ [Cache-Control] => no-cache, no-store [Pragma] => no-cache [Expires] => -1 [Content-Type] => text/html; charset=utf-8 [Content-Length] => 47417 ) If I could figure out the cookie value being set by the page, could I spoof that on my server when I request the page? EDIT: By the way, it's a session cookie being used to remembe the birthdate entered, because using Developer Tools in IE8 to clear session cookies, or closing and reopening the browser, resets the page and I have to enter my birthday again (or use my bookmarklet.) If this helps at all...
  24. If I understand your question properly, because I would still have the problem of returning the result of that query back to my calling script. However, I did figure this out. I was having the issue because I was using this code: while($info = mysql_fetch_assoc(fetch_news())) { [...] } When I should have been doing this: $news = fetch_news(); while($info = mysql_fetch_assoc($news)){ [...] } Changing that little bit made it work.
×
×
  • 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.