sKunKbad
Members-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by sKunKbad
-
In theory, both ways are sending the cookies, and both ways can be determined to work based on the fact that the cookie IS in the header, but I still can't get either way to work on the production server. I thought for sure when I woke up that it would be because of the line endings difference between my WAMP server at home and normal Linux shared hosting on the production server, but after changing the line endings from \r\n to \n, it still didn't work.
-
Actually, I did make changes there too, but as soon as the User-Agent is commented out, it doesn't work anymore. You are right about that line being something critical, because initially I had it wrong, and it was only through examining some request headers that I found the proper way to set more than one cookie. Now that I'm testing on the production server, it doesn't work again! I have to go to bed, and try again in the morning. Too tired to go on...
-
So, apparently all I needed to do was supply a User-Agent in the header, and my original code works: if(isset($_COOKIE['bwd_data']) && isset($_COOKIE['bwd'])){ $cookie_val = $_COOKIE['bwd_data']; $cookie_val2 = $_COOKIE['bwd']; $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Host: localhost\r\n" . "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10\r\n" . //"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 \r\n" . //"Accept-language: en-us,en;q=0.5\r\n" . //"Accept-Encoding: gzip,deflate\r\n" . //"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" . //"Keep-Alive: 300\r\n" . //"Connection: keep-alive\r\n" . //"Referer: http://localhost/brianswebdesign.com/\r\n" . "Cookie: bwd=" . $cookie_val2 . "; " . "bwd_data=" . $cookie_val . "\r\n" ) ); $context = stream_context_create($opts); echo(file_get_contents(url::site('httperrors','http'), FALSE , $context)); }else{ echo(file_get_contents(url::site('httperrors','http'))); }
-
So, I tried it your way, but this doesn't work either: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, url::site('httperrors','http')); $cookie_val = $_COOKIE['bwd_data']; $cookie_val2 = $_COOKIE['bwd']; curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_COOKIE, "bwd=" . $cookie_val2); curl_setopt($ch, CURLOPT_COOKIE, "bwd_data=" . $cookie_val); $content = curl_exec($ch); curl_close($ch); echo "<pre>".$content."</pre>";
-
I need to send two cookie name/value pairs to the page I am trying to open using file_get_contents, in order for the person viewing the page to have associated dynamic content, but it isn't working, and I'm wondering if I'm setting it up right: if(isset($_COOKIE['bwd_data']) && isset($_COOKIE['bwd'])){ $cookie_val = $_COOKIE['bwd_data']; $cookie_val2 = $_COOKIE['bwd']; $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: en\r\n" . "Cookie: bwd_data=" . $cookie_val . "\r\n" . "Cookie: bwd=" . $cookie_val2 ) ); $context = stream_context_create($opts); echo(file_get_contents(url::site('httperrors','http'), FALSE , $context)); }else{ echo(file_get_contents(url::site('httperrors','http'))); }
-
I've been using the Kohana framework, and also CodeIgniter framework. I have my forms post back to the same controller that produced them, run some validation if the post token = session token, and if all is well I use cURL to post to a processing script that returns a confirmation or error message, which is then pushed into the view. If there were errors in validation, the cURL post is not done, and errors messages are pushed into the view, and the form is prefilled with the data that passed validation. If the post token != session token, the user simply gets the standard view, sans any prefilled form data. I could send you my contact controller file if you want to see, but I don't want to post it here.
-
I'm sure you can find something already made at phpclasses.org, or a similar free script site.
-
I think your options are to use javascript to get the window size, and alter the width by changing the style per your calculation inside javascript, or just go with a static width and forget about it.
-
Submitting a form in the background? Possible???
sKunKbad replied to lip9000's topic in PHP Coding Help
you can use cURL -
Why not build your table by modifying what you already have: This is what you have: while($row = mysql_fetch_array($result)) { echo $row['id'] . " " . $row['name'] . " " . $row['num'] . " " . $row['sup']; } and you could be doing this: echo "<table>"; while($row = mysql_fetch_array($result)) { echo "<tr> <td>" .$row['id'] . "</td> <td>" . $row['name'] . "</td> <td>" . $row['num'] . "</td> <td>" . $row['sup'] . "</td> </tr>"; } echo "</table>";
-
grab the data = the mysql_query() function sort the data = include "ORDER BY 'some_field'" in your query then there are numerous ways to use the returned resource and output a table, but there isn't anything automatic. joke >> maybe in php7 they will implement a new hocus_pocus() function!
-
Smashing magazine just had an article on CSS sprites, and there's probably a lot of references to code you can look at there: http://www.smashingmagazine.com/2009/04/27/the-mystery-of-css-sprites-techniques-tools-and-tutorials/ I noticed while reading some of the tutorials that IE does have issues, so some reading should point out the problem so you can fix it.
-
You might have to have some other type of layout for IE to render it right. Width, height .....
-
php outputs html. echo "html";
-
deactivating right mouse click in a php gallery
sKunKbad replied to javivilchis's topic in PHP Coding Help
No matter what javascript you use to "protect" your images, you will never be able to stop people from stealing them. They will just disable javascript. -
I did have a session variable that I was setting to null, and it was the same name as a post variable. Basically, I was setting a token for a contact form, and after the form was submitted successfully, I wanted to make sure that the user couldn't resubmit by hitting the back button or refreshing the browser. So, I just set it to 'no duplicates please', and all is well. Thanks for your help.
-
Id rather find out what is causing the problem, if possible. I'm wondering what kind of code triggers this error. If I know, then I can probably fix it. How would a person initialize a session variable in the global scope? This is apparently what is causing the error, but I'm not sure what that means.
-
I've got pretty good at tracking down errors, and learning what errors mean, but I got this one today, and I'm wondering what it means:
-
You might take a look at your php.ini, and see if you are allowing yourself to open files via URL.
-
It depends on what the included file is doing, and how you are "getting" the data. I think in your case you could just use: echo(file_get_contents('index.php')); or include 'index.php'; but this will show the contents of index.php exactly where you have put this in the code. So if you need this content in a specific spot, use this code there.
-
Show more code.
-
You could use cURL, and the URL could be generated within PHP, and validated by PHP.
-
What exactly to you mean by change the path? Obviously you know how to make an HTML link, but in the context of whatever you are doing, your question is not clear.