|
php:<? try { $rs = $this->db->CacheExecute($sql, $username); $this->user = $rs->FetchRow(); } catch(Exception $e) { $this->user = array(); } return $rs == true; ?>
|
# ¿ Dec 18, 2008 21:18 |
|
|
# ¿ May 21, 2024 05:54 |
|
Nope. And IP addresses shouldn't really tell you what timezone someone is in unless you try and lookup where it's coming from. But even then, you'd probably get the wrong timezone because the internet is like that. Do I need to unset any class variables in __destruct() or does it do that by itself?
|
# ¿ Dec 20, 2008 23:39 |
|
CSS AND PHP would work if you want. Just change the style for that one link and add some sort of check to see where you are on the site.
|
# ¿ Dec 24, 2008 21:29 |
|
If this is Apache you can enable mod_expires. I have an htaccess with something like this: code:
|
# ¿ Jan 7, 2009 03:50 |
|
S is for a session key. Since you're logged in, you shouldn't see a session key.
|
# ¿ Jan 11, 2009 07:42 |
|
What would be the best way to setup a bunch of obfuscated links like ?action=150jsZ that work only once and or expire after a few minutes? I was thinking sessions but I want something more reliable. Maybe storing them onto MySQL or something but I don't want to eat up all my RAM. Ideas?
|
# ¿ Apr 29, 2009 01:00 |
|
Supervillin posted:Base it on the current timestamp (or some hash of the time if you want it to be less obvious to the end user), then compare the time in your target script. How do I measure the differences in time for the hash?
|
# ¿ Apr 29, 2009 01:46 |
|
Whats a good way to encrypt and decrypt a variable with a specific salt?
|
# ¿ May 7, 2009 04:13 |
|
Begby posted:Do you want to encrypt some text and store it and decode it with a password or keyphrase later? Or are you trying to encrypt a password for storing in a db? This. I want to be able to encrypt and store in the DB and later decrypt it. Any easy ways of doing this?
|
# ¿ May 7, 2009 23:47 |
|
They probably have terrible pings since you're likely somewhere in North America and they're XX hours away by plane.
|
# ¿ May 15, 2009 18:45 |
|
Is this kind of memory usage too high? I have 1GB of RAM. final: 607.7265625kB peak: 860.96484375kB took 0.010162115097 seconds edit: I'm doing three sql queries and processing the table data of one of the result sets in this page. Acer Pilot fucked around with this message at 03:56 on May 21, 2009 |
# ¿ May 21, 2009 03:54 |
|
supster posted:lol no Thank god. What would be too high for three sql queries? I haven't seen anything go over 1 megabyte.
|
# ¿ May 21, 2009 04:09 |
|
Thanks, I've stopped worrying about it now. Here's another one, what do you guys use for templating your pages? Other than Smarty that is. Do you roll your own systems or just put the HTML in with your code? I've been using Smarty personally but it seems a little too much for what I need to do.
|
# ¿ May 22, 2009 19:37 |
|
Do any of these have anything in common? I saw someone making two way hashes like this and I'd like to try and do the same: 2ed3cbd5 11e1d49a 478c139d d72d0f17 They look like they're hexadecimal and from what I see it's supposed to be related to the number 1073. Is there something in mcrypt that encodes variables like this? edit: it looks like it has something to do with pack() and unpack() Acer Pilot fucked around with this message at 01:39 on May 25, 2009 |
# ¿ May 25, 2009 01:19 |
|
It'll be a bit trickier if they're uploading MS Word docs and various other text formats but if you're somehow storing the resumes in a textfield, you can use fulltext search in MySQL most likely.
|
# ¿ Jun 2, 2009 00:29 |
|
Are there any reasons as to why this function gets occasionally slow?php:<? public function show_map($sector, $galaxy, $distance = 2) { $start_sector = $this->galaxies[$galaxy]['start_sector']; $width = $this->galaxies[$galaxy]['width']; $end_sector = $start_sector + ( ($width * $this->galaxies[$galaxy]['height']) - 1 ); $min = $distance * -1; $tile = 0; $map = array(); for($l = $min; $l <= $distance; $l++) { $mid_of_line = ($sector + ($width * $l)); if( ($mid_of_line < $start_sector) || ($mid_of_line > $end_sector)) $mid_of_line = -1; $line = ceil(($mid_of_line - $start_sector + 1) / $width); $start_of_line = $width * ($line - 1) + $start_sector; $end_of_line = $start_of_line + $width; for($s = $min; $s <= $distance; $s++) { $current = $mid_of_line + $s; if( ($current < $start_of_line) || ($current >= $end_of_line) || ($current > $end_sector) ) $current = -1; if($current > 0) { $map[$tile] = $this->info[$current]; $map[$tile]['sector'] = $current; $css = "sector"; if($current == $sector) $css .= " current"; if( in_array($current, $this->get_exits($sector)) ) { $css .= " linked"; $map[$tile]['link'] = "./move.php?sector=$current"; } } else $css = "explored sector"; $map[$tile]['css'] = $css; $tile++; } } return $map; }?>
|
# ¿ Jun 5, 2009 09:21 |
|
Sorry about the lack of comments. Here's a picture of what this actually does. In this example $sector = 288 and $galaxy = 1. The green circle is where we are and the yellow boxes are where we can go. $galaxy is not important right now and I've commented the code below to include their values. php:<? giant wall of code?> $this->get_exits($sector) gets an array of sectors that the sector links to. A list of all sectors and their links is gathered at the beginning of the page through MySQL and is stored in $this->info. get_exits() just gets the row $sector from the result array. It shouldn't be calling any new queries. I appreciate any attempts at even reading this. Thanks! Acer Pilot fucked around with this message at 08:37 on Jun 12, 2009 |
# ¿ Jun 5, 2009 19:14 |
|
Thanks, I've moved the $this->get_exits($sector) out of the loop and put it at the start of the function in a variable called $exits. Was there something wrong with my loop: for($s = $min; $s <= $distance; $s++) ? I think I set the value of $min and $distance at the start properly. edit: Maybe I'll add a count for the exit checking so it won't do an in_array check after there are for exits.
|
# ¿ Jun 7, 2009 00:47 |
|
Thanks for the advice. Now if only my VPS were online...
|
# ¿ Jun 8, 2009 01:22 |
|
I'm storing a list of integers in a comma separated textfield on MySQL and then explodin them into an array. I then check through a list of 25 integers and see if they are on the original list. Is there a better way to do this?php:<? $galaxy = "144,145,119,118,117,92,93,68,69,70,91,116"; $explored = explode(",", $galaxy); // this is done in a loop up to 25 times if( in_array($current, $explored) ) { echo "blah"; } ?>
|
# ¿ Jun 18, 2009 04:38 |
|
You're using two different character encodings.
|
# ¿ Jun 22, 2009 05:36 |
|
How come it won't let me overload this function with time()? I seem to be able to do it with array()...php:<? public function get_foo_bar( $cutoff = time() ) { // }?>
|
# ¿ Jun 23, 2009 08:51 |
|
Cool, thanks for the explanations.
|
# ¿ Jun 23, 2009 10:27 |
|
I'm currently using ADODB to handle MySQL abstraction on my website but I recently updated to PHP5 and thought it might be a better idea to use something like mysqli or PDO. Which of the two should I use to handle all my MySQL transactions? If it matters, I use "update" a lot.
|
# ¿ Jul 1, 2009 03:01 |
|
Hmmm. Binding parameters one by one is a little troublesome, but then again I only need to bind three or four at max... If using adodb seems to be "slow" would that be an issue with adodb or MySQL?
|
# ¿ Jul 1, 2009 09:36 |
|
It takes a few seconds every once and awhile but not always.
|
# ¿ Jul 1, 2009 13:14 |
|
Is there anyway to do the following with PDO? Original Array ( [0] => Array ( [map_id] => 1 [name] => Peanut Butter [width] => 25 [height] => 15 [start_sector] => 1 ) [1] => Array ( [map_id] => 2 [name] => Cold Lamb Sandwhich [width] => 11 [height] => 15 [start_sector] => 376 ) ) Array Index is map_id Array ( [1] => Array ( [name] => Peanut Butter [width] => 25 [height] => 15 [start_sector] => 1 ) [2] => Array ( [name] => Cold Lamb Sandwhich [width] => 11 [height] => 15 [start_sector] => 376 ) ) I'm using fetchAll(PDO::FETCH_ASSOC) right now.
|
# ¿ Jul 9, 2009 09:48 |
|
Begby posted:I don't believe so. But it is pretty easy to create a function that will take your array from pdo and spit out your new fancy array. Like Thanks, I did something like that instead. Is there a nicer way to do this? php:<? function rekey($array) { $out = array(); $max = count($array); for($i = 0; $i < $max; $i++) { $keys = array_values($array[$i]); if(is_numeric($keys[0])) { array_shift($array[$i]); $out[$keys[0]] = $array[$i]; } } return $out; } ?>
|
# ¿ Jul 10, 2009 00:33 |
|
Right now I've got a try-catch in every function I have. Should I keep doing this or just have my functions throw exceptions and catch them all in the script that's calling them?
|
# ¿ Aug 1, 2009 20:21 |
|
Hm. No replies in almost 3 days. I've gotten rid of most of the try catch statements in my functions and now have them throwing exceptions if it doesn't meet a requirement. Not sure if that's how I should be handling errors though.
|
# ¿ Aug 4, 2009 22:28 |
|
fletcher posted:Is it an exception you want to show the user? Or do you want them to see a generic "there is a problem with this page" type of thing? Thanks, I was looking into set_exception_handler but didn't know how to use it properly . Can you use an object in there? Like set_exception_handler($e->handler) It doesn't look like you can and I'd like to try and keep the logging, etc in a separate file. ninja edit Acer Pilot fucked around with this message at 23:04 on Aug 4, 2009 |
# ¿ Aug 4, 2009 23:00 |
|
Ah, thanks. I've never really looked into autoload. Got some reading to do!
|
# ¿ Aug 5, 2009 00:52 |
|
How would I go about making sure something happens 75% or n% of the time? If that didn't make sense, how can I make a random event happen n% of the time whenever a page is loaded. I tried this but this doesn't seem right. php:<? $r = rand(1,100); if($r <= 75) echo "hit"; else echo "miss";?>
|
# ¿ Dec 17, 2009 05:26 |
|
What's a good way to obfuscate my links without giant overhead/killing MySQL? Right now I have links like move.php?sector=42 and would prefer something a bot can't easily read like action.php?whatever=HASH_GOES_HERE The hashes should change whenever a player uses one... Any ideas?
|
# ¿ Mar 24, 2010 22:58 |
|
fletcher posted:Can you describe the problem you are trying to solve a bit more? Right now, I have plain html links like this: <a href="./move.php?sector=42">#42</a> I want them to be something like this: <a href="./action.php?cmd=HASHED_VALUE">#42</a> move.php right now basically is this: $sector = intval(stripslashes($_REQUEST['sector'])); rt4 posted:Maybe you could make those links come out on the page as md5($sectorID), and then Something like this could work since we already have a hash stored for the current session but that might not be enough if we want a new hash every move, right? Don't exactly want to update the session table every time we move though so hmm. edit: Also thanks for the replies guys.
|
# ¿ Mar 24, 2010 23:42 |
|
fletcher posted:What exactly does this solve though? Are you trying to prevent them from just changing the link to sector=43? That's basically it. Right now I'm trying to make a hash like this: code:
|
# ¿ Mar 25, 2010 00:32 |
|
fletcher posted:Check out the php crypt/mcrypt stuff. I'll take a look at it, thanks. And the server already knows if it's a valid move or not, I just don't want them to be able to make the move without clicking a link.
|
# ¿ Mar 25, 2010 01:04 |
|
fletcher posted:Short of a good CAPTCHA, a bot will be able to do pretty much anything a human could do on your site. Doesn't really matter if you use anchors or js. Also, a bot can click on a link to move.php?sector=42 just as easily as action.php?sector=SOMESCARYHASH so that really does nothing. True, hm. I guess I'll just deal with the bot issue if this thing ever gets popular enough for someone to want to use a bot.
|
# ¿ Mar 25, 2010 01:13 |
|
So I'm trying to come up with a way to get players to cat with each other while playing a game. I looked up some of those PHP/ajax/json scripts that are out for free but they all look like they'd kill my server if there were too many clients on. Any suggestions for a lightweight chat system? And I likely don't want to use IRC because my host doesn't allow that and I need to force players to keep their assigned name in chat.
|
# ¿ Mar 29, 2010 20:45 |
|
|
# ¿ May 21, 2024 05:54 |
|
epswing posted:Or as a university prof of mine put it, "'all the elephants in the room are pink' is a true statement". Was this in a MACM class and was he Russian and awesome? I think I know who you're talking about.
|
# ¿ Apr 5, 2010 23:37 |