Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. Yes, you only need to escape a character that is also a format code. Generally you should keep your date format string as free of extra characters as possible. So if you want to output something like this: Welcome, the current date and time is: 2/26/2012 7:17 Rather than include that whole string in the date call, you just do the date part and concatenate that to the rest: $now = date('m/d/Y g:i'); echo 'Welcome, the current date and time is: <b>'.$now.'</b>';
  2. Intranet just refers to your local area network. In other words all your computers are networked together via a switch/router so they can talk to each other. The intranet is the part of that which is on the private side of the router (the public such as me cannot access it). Once you have all your computers networked together and talking to each other, it's just a matter of what services you want on your intranet. if you want a website you need to setup a webserver such as apache to handle that. Maybe Mysql and PHP if you need them for your site. When that is setup all your other computers can just browse to the server computers IP and use the site. You can setup a name to use rather than IP by adding entries to each computers host file, or setting up a local DNS server.
  3. I'm not sure the proper way to cast in java, but you can determine if a number has a decimal value by casting it to an int, and subtracting it from the original double. If the result is 0 then there is no decimal value. Something like: if (answer-(int)answer == 0){ //is int } else { //is double }
  4. Your only going to be able to access the server via your phone if your phone is connected to the same network using WiFi. If your using 3g or something then you wont be able to connect (unless your server has a public ip).
  5. What you have is close. You would add your checks to determine if someone died inside the switch statement, one for each case. Your bottom while condition should use &&, not ||. You only want it to keep looping if both the player and the monster are alive, not if just either one is alive. Your also starting them out with one damage each, probably it should start at zero. You also shouldn't quote numeric values in your script. <?php $whosTurn = 'player'; $hp=10; $mhp = 10; $mtotaldam=0; $totaldam=0; do { switch ($whosTurn){ case 'player': $damdone = 1*rand(1,2) + rand(1,2) + 1 + 1; echo "You hit the monster for $damdone.<br />"; $totaldam+=$damdone; if ($totaldam >= $mhp){ echo "You have killed the monster!"; } $whosTurn='monster'; break; case 'monster': $damtaken = 1*rand(1,3) + rand(1,4) + 1 + 1; echo "The monster hit you for $damtaken. <br />"; $mtotaldam+=$damtaken; if ($mtotaldam >= $hp){ echo "You have been killed!"; } $whosTurn='player'; break; } } while ($totaldam < $mhp && $mtotaldam < $hp);
  6. This is just pseudo code, you'll have to implement it your self, but your basic setup would go something like this: $whosTurn = 'player'; do { switch ($whosTurn){ case 'player': //generate & print players attack $whosTurn='monster'; break; case 'monster': //generate & print monsters attack $whosTurn='player'; break; } } while ($player->isAlive() && $monster->isAlive()); In other words, you only do one attack per loop iteration, and have a state variable to keep track of whos turn it is so.
  7. Not sure if I really understand what your question is, but... The value attribute of a button just controls what text is displayed in the button. A value of 'Next →' would end up in a button with a label that looks like Next ->. From the scripts point of view, the value of a button is fairly meaningless. Usually you just check if a button was clicked by looking for it's name, eg: if (isset($_POST['btnNext'])){ would test if the next button was pressed, assuming you have name="btnNext" in your HTML code.
  8. When you get it on a new server post back and I will look at it more. For now, the ads are far too annoying to do any kind of serious testing. I was getting popups / overlays on every single page load.
  9. $newpass is also undefined, so essentially your setting it to an empty string. You probably want $pass_conf.
  10. It's preferable to keep your variables tied to the functions that need them. In the case when a value is needed in multiple functions you should pass it as a parameter. If you are going to just create the variables in a top scope so that all the functions can access it, you should, at the very least, isolate them in their own scope rather than use the global scope. This prevents any conflicts when you start dealing with multiple scripts. You can create your own scope by wrapping all your code in a large anonymous function, such as: (function(window,undefined){ //declare all your top scope variables here //put the code here })(this); What that does is create an anonymous function and then immediately execute it. So long as you declare your variables with the var keyword they will be isolated to that function and you will not pollute the global namespace.
  11. Whether the file is included in the head/body or externally/internally doesn't matter, it all runs in the same context. If your button is not disabling then my first guess would be that your script can't find it and the getElementById call is failing. You should get an error message if this is the case (unless it's being caught somewhere which some frameworks do if your using one). We'll need to see more code to help much further. The HTML code at least, maybe more of the JS. Try splitting your lines and logging the variable between steps to see what is going on. var check = document.getElementById("check"); console.log(check); if(AjResp == 'YES'){ console.log('disable=false'); check.disabled=false; } else { console.log('disable=true'); check.disabled=true; }
  12. The only way to do it without cron is to either a) Code your own server app that works like cron and will run the code periodically. -or- b) run the code on any page load, regardless of who did it. That way even if that player is gone, so long as someone is hitting your site it wil run. Really though, the correct way to do this would be a cron job. Why are you trying to avoid it?
  13. Their code relies on ctx being in the global scope, but in your case it is not. The reason it is in their code is because they did not preceed it with the word var when they assigned it, which causes it to be assigned as a global variable. Since you used var in your code, you have limited it in scope to only that function. Quick fix would be to remove the var from where you assign the variable, and add a var ctx; line toward the top of the script to declare it as a global.
  14. You replace this: var_dump( linear_regression(array(1, 2, 3, 4), array(1.5, 1.6, 2.1, 3.0)) ); with my code. var_dump() is just something you use for debugging and testing. Once you verify whatever you need to know (in this case, the return value of linear_regression) then you just replace it with whatever you actually want the code to do.
  15. I have no idea what you are asking.
  16. If you're talking about after the function call, you get them by saving the return value and accessing them through there. $result = linear_regression(array(1, 2, 3, 4), array(1.5, 1.6, 2.1, 3.0)) ); echo $result['m']; echo '<br>'; echo $result['b'];
  17. There's no need to first select the number of fonts, then select each font individually. Just select all the fonts at once and loop the results. $sql = 'SELECT * FROM fonts'; $res = mysql_query($query); echo '<select>'; while ($row=mysql_fetch_array($res)){ if ($row['id'] == $font){ $selected='selected="selected"'; } else { $selected=''; } echo '<option value="'.$row['id'].'" '.$selected.'>'.$row['font'].'</option>'; } echo '</select>';
  18. The $i++ does not get executed until the entire inner-loop has been completed. Your inner for loop (using $j) is what makes up the body of the outter for loop (using $i). So each time the $i loop runs (for $i=1 then $i=1) the $j loop will run completely (all the way from $j=1 to $j=2). It might make more sense if you used a different number of iterations for each loop, eg: for ($i = 1; $i < 4; $i = $i + 1) { for ($j = 1; $j < 10; $j = $j + 1) { echo "'i' is {$i}, 'j' is {$j}<br />"; } } In that case, the $i loop goes from 1 to 3. The $j loop goes from 1 to 9. So when it is run it: //begin $i=1 -- $j goes from 1 to 9 $i=2 -- $j once again goes from 1 to 9 $i=3 -- $j once again goes from 1 to 9 //Finish
  19. Yes, you serve the file via PHP. Use header to set the correct content-type and content-length headers, then use readfile to dump the file's content. Your access restrictions set in your .htaccess have absolutely no effect on PHP's ability to read the file. eg: $file = 'script/script.jar'; //the file to download. header('Content-type: application/octet-stream'); //Change this too the proper mime type. Google if you don't know it. header('Content-length: '.filesize($file)); readfile($file); exit;
  20. Just have a column in your table that indicates whether a thread is stuck or not. When you pull the list of threads sort by that column so the stuck threads come first.
  21. They do, it's called a prepared statement. You send the SQL and the data in separate streams so there is no need to escape it at all.
  22. You can use $_SERVER['QUERY_STRING'] to access the raw query string which is just everything after the ?. Should be able to pull the number from there.
  23. A brute-force attack is always "possible". The way you defend against it is by limiting the number of attempts a person can make and also using an algorithm that is expensive time-wise so it takes a long time to generate a lot of tries. It's impractical to try every combination in a brute-force attack as there are simply too many and it takes too much time. This is why people will use rainbow tables and dictionary lists to try common words and variations. You defend against rainbow tables by using a random salt value. Defending against dictionary lists is just a matter of trying to get your users to use good passwords by having some rules like length and requiring numbers/mixed case.
  24. Try setting in your php.ini: fastcgi.logging=1 Seems to work for me in my test setup.
  25. Never heard of/used that cms. Google seems to indicate it's a .net app though which would lead me to believe the connection details for the db probably go into the Web.config file, likely in the site's root folder. As for the DB, if you have a backup from the old DB you probably just need to use the restore functionality to bring it back on the new server. If you have access to sql management studio it's pretty easy to do from there.
×
×
  • 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.