-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
I was thinking of the possibility that maybe somewhere down the network (the router or ISP) IPv6 traffic is dropped or mis-routed which would lead to a connection attempt just lingering for a while until something times it out, rather than it being refused. Do you know if your network actually supports IPv6? Can you connect to something using IPv6 using another utility like wget or netcat?
-
The spec says space separated. Whether browsers allow it or not I don't know, I have not really dealt with such stuff yet. You should have the origin header value somewhere. It's a required header as part of the CORS stuff. If your using a CGI setup you may need to configure the server to forward that header along to PHP.
-
Just because it isn't documented doesn't mean it isn't there. Do a print_r($_SERVER) and look. Generally all the headers sent in a request will get put into the $_SERVER array with a HTTP_ prefix.
-
Have you tried a higher timeout value? Perhaps it is hitting your timeout before it has a chance to get an error using IPv6, thus never trying IPv4. I've tested on PHP 5.4 connecting to the host on two different machines and it worked fine. On my VPS it connected via ip6 since it is available. On my dedicated box it connected via ip4 since there is no ip6 network connectivity available (ip6 is enabled in the os, the network just does not support it).
-
A remember me feature is inherently insecure. You have to use a cookie for it to work as that is the only thing that will survive from one browser run to the next. What you do is generate some sort of hash value unique to that user and store that as the cookie value. When the user comes on the site check for that cookie and if it exists, check if the hash is in the database. If the hash exists then log them in as the associated user. Some things you may consider to try and improve the inherent insecurity would be to: - re-generate the hash on each page load; if someone managed to steal it the window of opportunity to use it would be small - require a password still to do any type of profile-changing or other "important" stuff
-
That is 100% the wrong way to do it. You should be setting those values as different rows in either that or another table. Eg: create table users ( userid int name varchar(100) ); create table user_items ( userid int, itemvalue varchar(100) ); You'd store the main user details in the users table, then for every item you want to add you create a new row in the user_items table with the user's id and item data.
-
If your using an object tag to display HTML (like this) that is effectively the same as using an iframe. You may as well use an iframe in such a case for better browser compatibility and ease of use. As for this question: Yes, you can set a width and height on your iframe to a percentage using CSS. You can do that with pretty much any element.
-
I leave it out in all my pure php files like class definitions, function libraries, configs, etc. There's no need to have it and I have encountered issues with it being there from other developers adding a bunch of whitespace after the ending ?>.
-
Remove the @ before the fsockopen call so you can see any warnings that may be emitted. Does your PHP install have SSL enabled?
-
You need to make sure that your code only runs if you have submitted a number. You can do that by wrapping the whole block of code in a if() statement that checks whether $_POST['i'] exists or not if (isset($_POST['i'])){ .... }
-
<object> isn't going to help you as far as reloading the page interrupting the music. The only way to handle that is to popup a separate music player as requinix said. That your ajax-ify the entire site so that you never actually reload the page and just swap a div content.
-
We had kind of spotty internet for a while and what I did was setup something to ping my ISP's dns servers a few times every hour. I don't think a few pings every couple minutes or a couple DNS lookups would cause any issues, probably nobody would even notice. If I were going to setup something again I'd probably ping my linode VPS (or just try and wget the homepage) to test for a connection. Trying to hit some external device is really about the only effective way to test. You just need to decide what device, how to hit it, and how often.
-
You don't have to replace all the areas that call the lock_and_write function, you would just replace that functions body. function lock_and_write($file, $body, $append = 0){ $flags = LOCK_EX; if ($append){ $flags = $flags|FILE_APPEND; } file_put_contents($file, $body, $flags); }
-
file_put_contents('yourfile.txt', "Today I make a ". $var1. " and then ". $var2 . " but finally i get only ". $var3 ." dollars instead of ". $var4); That will create a file named yourfile.txt which contains the text Today I make a test and then foo but finally i get only 55 dollars instead of 12345
-
Write the variable to a file with one of the file functions such as file_put_contents file_put_contents('myvar.txt', $var);
-
php_value error_reporting -1 You can't use the named constants like E_ALL in .htaccess, you have to use a numerical value. Have you verified that $body contains the proper data? I'd speculate that there is a problem elsewhere causing $body to be blank. Also what OS is this being run on? Some form of linux I am guessing.
-
I'm not really much of an excel person, but if you take that line of code and tab it out to show how things line up, you can see where you have a problem: =IF( D17<$B$5, (D17*$D$5), IF( AND(D17>=B6, D17<=C6), (((D17-20000)*D6)+E6) ) IF( AND(D17>=B6, D17<=C6), (((D17-20000)*D6)+E6) ) ) Your last IF() is not in the correct place. I am assuming you intended to do something like this: =IF( D17<$B$5, (D17*$D$5), IF( AND(D17>=B6, D17<=C6), (((D17-20000)*D6)+E6), IF( AND(D17>=B6, D17<=C6), (((D17-20000)*D6)+E6) ) ) )
-
Since you're passing an int, strpos is searching for the character defined by chr($a), not (string)$a. if (false !== strpos($content, (string)$a)){ side note your call to fopen() is completely unnecessary and can be removed.
-
use var_dump($content) and var_dump($a) to verify that those variables contain what you think they contain.
-
Note that if your search item is the very first thing in your file, you will get a false result because strpos will return 0 (found at position zero) which is loosely equal to false (which is returned when not found). The proper way to test for whether the item is found or not would be: if (false !== strpos($content, $a)){ $search = "TTRUE"; } else { $search = "FFALSE"; }
-
There are other companies than Godaddy that you could go to and be able to exec() something like ffmpeg. For instance a friend of mine used to host with Arvixe and they support ffmpeg. I'm running under the assumption that ffmpeg will do the conversion you need, you'll need to verify that somehow. Depending on your needs an option might be to buy a cheap VPS from somewhere and install the tools you need to do the conversion on that VPS. Then just make a request to there to do the conversion and send back the results.
-
The problem there is that PHP is trying to treat your $newUserName variable as an array and index into it, but it can't understand your index of 0-9. I personally have no idea what exactly you're trying to accomplish with said line. If $newUserName is an array, and you have a string index '0-9' you would use: $ifExsist = "SELECT COUNT( player_id ) FROM players WHERE player_id LIKE '{$newUserName['0-9']}'"; If $newUserName is not an array but just a string, and you want that string to be followed by the string '[0-9]', you'd use: $ifExsist = "SELECT COUNT( player_id ) FROM players WHERE player_id LIKE '{$newUserName}[0-9]'"; If neither of those is what you mean you'll have to explain what your end goal is.
-
Rather than go through the hassle of creating a server script you can just use something like memcached to store whatever shared data you need. For instance if you had the concept of "rooms" then you would store any messages or other data related to a given room in memcached under a unique identifier (such as the room's name). For anyone trying to view that room you would just access the data from memcached using the same identifier. If on the other hand you want to go through the hassle of making a script, you would create a PHP script that opens a listening socket on a given port and accepts connections. You'd then have your other scripts connect via a socket to that server-script to store/get messages or other information. Setting up a system like this can be a bit complicated to do properly so you'll need to invest some time into it and learning how to manage sockets and protocols. As far as displaying the messages to the end user you'd likely be using an ajax setup to poll the server for new messages every x seconds in the background. That or just set the page to auto-reload every x seconds. A background poll using ajax would be ideal from a user experience point of view, and would not be too hard when using a library such as jQuery.
-
If you're just trying to validate user entered emails (rather than extract them from text or something) then I'd recommend you just use PHP's filter_var function with the email filter rather than try and re-invent the wheel writing your own regex.
-
The issue is that you're not saving the output you generate in each child loop back to the $output variable. In this part here: if(array_key_exists("children", $thisArray[$key])) { $result = listRequirements($thisArray[$key]['children'], $output); } You are passing the current value of $output to the child loop. In that child loop you append the new a, b, and c requirements to $output. Once that instance of the function returns though, $output goes back to how it was before. Each instance of your function gets it's own copy of the $output variable. Whatever it does to it is isolated to just that particular instance of the function. Any changes made will not affect the other instances' value. There are two ways to solve this problem. 1) Have your function return the new value of $output, and then save that value in the parent instance: if(array_key_exists("children", $thisArray[$key])) { $output = listRequirements($thisArray[$key]['children'], $output); } and then at the end of the function you would add return $output; (you have it but it's commented out) -or- 2) Make $output a pass-by-reference parameter so that changes made to it inside the function are visible from outside the function as well. To do that you're function definition would change to: function listRequirements($thisArray, &$output) Then when you call it you would just do: if(array_key_exists("children", $thisArray[$key])) { listRequirements($thisArray[$key]['children'], $output); } and the initial call would be: listRequirements($testArray, $output); echo $output;