|
What kind of timestamps are these? 12314 12345 12356 12367 12378 12456 12859
|
# ¿ Apr 1, 2008 02:43 |
|
|
# ¿ Apr 30, 2024 14:27 |
|
It's in a MySQL table that I don't have access to yet. All I have is a printout of what the table looks like.
|
# ¿ Apr 1, 2008 02:58 |
|
How can I improve this system of including/defining?code:
|
# ¿ Apr 3, 2008 01:57 |
|
How do I search for <br /> with preg_match_all?
|
# ¿ Apr 9, 2008 04:45 |
|
Can I assume that #\n# will find all new lines?
|
# ¿ Apr 9, 2008 05:27 |
|
e: php4 I've got a $variable filled with a large amount of text separated by new lines (\n). I want to split the $variable into two giant chunks after a certain amount of lines, is that possible? I thought about using split() but that would just make a new array value for every sentence and that might not be an effective way of doing it. Thanks
|
# ¿ Apr 9, 2008 21:42 |
|
Didn't know where to put this question but since I'm writing in PHP... Should I stick to using a timestamp like this YYYY-MM-DD or use the Unix timestamp? Is it okay to use both (eg. one for one system and one for another)?
|
# ¿ May 8, 2008 02:06 |
|
So last night I wrote a fairly simple calendar function. It seems to work fine but it looks inefficient. Keeping within the same principles... how would you make it better?php:<? function getMonth($month, $year) { $first = mktime(0, 0, 0, $month, 1, $year); $start_day = date('D', $first); $day_offset = $this->getDayOffset($start_day); $days = cal_days_in_month(0, $month, $year); $block = 0; $block_limit = 35; if($day_offset == 6) $block_limit = 42; while($day_offset > 0) { $this->days[$block] = null; $day_offset--; $block++; } $day = 1; while($day <= $days) { $timestamp = mktime(0,0,0, $month, $day, $year); $this->days[$block]['day'] = $day; if(isset($this->events[$timestamp])) { $this->days[$block]['venue'] = $this->events[$timestamp]['venue']; $this->days[$block]['location'] = $this->events[$timestamp]['location']; } $day++; $block++; } while($block < $block_limit) { $this->days[$block] = null; $block++; } }?> The output is being stored in a multidimensional array. Acer Pilot fucked around with this message at 22:28 on May 8, 2008 |
# ¿ May 8, 2008 22:05 |
|
Begby posted:The first thing to do to make this better is to maybe comment it then tell us what it is supposed to do and why. Sorry about that. php:<? function getMonth($month, $year) { $first = mktime(0, 0, 0, $month, 1, $year); // first date of the month in unix time $start_day = date('D', $first); // starting 'day' eg. mon, tues, wed, etc $day_offset = $this->getDayOffset($start_day); // how many days from sunday does the calendar start $days = cal_days_in_month(0, $month, $year); // how many days in this month? $block = 0; // init the block count $block_limit = 35; // how many days to include on the calendar with offsets if($day_offset == 6) $block_limit = 42; // exception the month starts on a saturday // add all the empty blocks before the first day while($day_offset > 0) { $this->days[$block] = null; $day_offset--; $block++; } $day = 1; // add all the days to the calendar while($day <= $days) { $timestamp = mktime(0,0,0, $month, $day, $year); $this->days[$block]['day'] = $day; // current day number if(isset($this->events[$timestamp])) // there's an event on this day { $this->days[$block]['venue'] = $this->events[$timestamp]['venue']; $this->days[$block]['location'] = $this->events[$timestamp]['location']; } $day++; $block++; } // add more blocks to make calendar symmetrical. while($block < $block_limit) { $this->days[$block] = null; $block++; } }?>
|
# ¿ May 9, 2008 20:16 |
|
cal_days_in_month() is fun too.
|
# ¿ May 31, 2008 00:32 |
|
What's the best or easiest way to add language support? By language support I mean we can display an error message in English or maybe French rather than just English.
|
# ¿ Jun 3, 2008 01:04 |
|
So how do I disable PHP in one specific folder (for security reasons)?
|
# ¿ Jun 6, 2008 23:57 |
|
Mine GO BOOM posted:In .htaccess: I'm more worried about being hit by PHP files disguised as images. Is there a way to get the engine to ignore a specific folder? I tried the php_admin commands in an htacess but it just gave internal server errors.
|
# ¿ Jun 7, 2008 06:19 |
|
Bruno_me posted:'php_flag engine 0' should do it Doesn't seem to be working. Do I have to change any settings on the server?
|
# ¿ Jun 7, 2008 10:13 |
|
Lacithe posted:In Apache you need to have AllowOverride Options (or All). I'm so confused, it's already set to All. I'm running on mod_php.
|
# ¿ Jun 7, 2008 10:48 |
|
I saw a thread about this a long time ago but I can't find it anymore so... How do you do the authentication system like they have on AwfulYearbook. If you don't know what I'm talking about, it's where a website checks to see if you have a specific line of text written onto a certain page. I hope that made sense.
|
# ¿ Jun 13, 2008 06:06 |
|
Zorilla posted:Probably include an activation token in the table of users. A random MD5 ought to do the job. I was wondering more on how they did the actual checking of the website.
|
# ¿ Jun 13, 2008 06:30 |
|
Use some regex on it? I'm sure a regex genius will post how to do this in a few mins.
|
# ¿ Jun 17, 2008 22:00 |
|
So I want to write a small/simple/safe search engine for our MySQL database. How would I start this off? The fields I want to search are varchar(64) and longtext. Any specific links or tutorials?
|
# ¿ Jun 18, 2008 00:07 |
|
Bruno_me posted:Assuming you're using MyISAM, and you don't have more than 500,000 or so rows to search through, Fulltext indexes are the way to go. You pretty much add the index and write a query like this: That was pretty easy to setup and it was fun. Thanks.
|
# ¿ Jun 18, 2008 03:12 |
|
So I'm trying to implement Dijkstra's algorithm for a side project I'm working on but I'm having difficulty grasping how the whole thing works... I've setup a map where each location a player can be go to is identified as a sector. Each sector knows whether it connects to any of the sectors to the north, east, south, or west of it. In MySQL, the table for sectors looks like this: table: sectors sector_id | north | east | south | west If the current sector connects with another (eg. north) then it would have the sector_id in that field. Otherwise the value of 0 would be in the field. Would the connecting sectors be the vertices? To illustrate it, the map array might look something like this: code:
Acer Pilot fucked around with this message at 00:34 on Jul 11, 2008 |
# ¿ Jul 11, 2008 00:31 |
|
Does anyone have any idea on how to efficiently create a random maze via PHP? I found this one but I'm not quite sure on how to make it better. It takes quite awhile for it to make 20x20 maze as it seems to make them by going through every cell in the grid. Anyone happen to know the name of the formula that makes up a maze?
|
# ¿ Jul 17, 2008 12:06 |
|
Jam2 posted:I am catching my rear end to enable the gd library in php5. Is there a specific error message and did you compile it with GD enabled?
|
# ¿ Jul 30, 2008 01:35 |
|
I want to keep track of all the places somebody's been on a map in an array (possibly). What would the best way to store this on MySQL? Note: they may not be visiting these places in order. The places will just be represented by numbers. I was thinking textfield in the database separated by commas. But that doesn't sound so efficient.
|
# ¿ Aug 2, 2008 03:18 |
|
Thanks but unfortunately we don't have PHP5 installed yet . How crappy and or efficient are serialize and unserialize? The array may reach up to 375 items per person and map so I'm a little worried about how well it would handle if there are, worst case, 5000 users and 15 maps.
|
# ¿ Aug 2, 2008 10:31 |
|
MrEnigma posted:You can install the JSON stuff through PECL if you want (I believe this will work through PHP4), or ZendFramework has one also. What are your thoughts on just using implode/explode?
|
# ¿ Aug 3, 2008 13:50 |
|
Is this:php:<? function check_explored($sector, &$map) { $explored = $this->search_explored(0, (count($map)-1), $sector, $map); if($explored < 0) return -1; return $map[$explored]; } function search_explored($start, $end, $key, &$map) { if($start > $end) return -1; $mid = round(($start + $end)/2); if($map[$mid] == $key) return $mid; elseif($key < $map[$mid]) return $this->search_explored($start, ($mid-1), $key, $map); return $this->search_explored(($mid+1), $end, $key, $map); }?>
|
# ¿ Aug 19, 2008 04:30 |
|
Gotcha. Now for another question I haven't seen in awhile... How should I store passwords in MySQL? The only way I know of is to MD5 it with a salt. How would a security conscious goon do it?
|
# ¿ Aug 21, 2008 10:46 |
|
Zorilla posted:That's pretty much it, I think. You could make the login process done through SSL or use Javascript to MD5 the password on the client side so it isn't sent out cleartext, but you're on the right track so far. Well I did get a free SSL certificate from Namecheap a week or two back so I'll give that a shot as well, thanks. MononcQc posted:Use SHA-1. Otherwise, salting it is pretty much the right thing to do. Is there a huge difference between MD5 and SHA-1 other than the bit lengths? I would like to try something new, SHA-1 in this case, but I would like to keep our user accounts fairly safe from tampering. Thanks for help so far goons.
|
# ¿ Aug 21, 2008 23:30 |
|
So would you add a salt before and after?
|
# ¿ Aug 22, 2008 00:06 |
|
I have a div with a set width and height and a background image. How do I place images (in other divs possibly) randomly inside the main div? I want to try doing this without them overlapping. If PHP is overkill, could I do this with Javascript?
|
# ¿ Oct 15, 2008 11:40 |
|
How can I make this simpler and or better?php:<? if($curr_sector < $start_of_line) $curr_sector = -1; elseif($curr_sector >= $start_of_line + $size) $curr_sector = -1; elseif($curr_sector > $end_sector) $curr_sector = -1;?>
|
# ¿ Oct 18, 2008 11:52 |
|
KuruMonkey posted:
Oh god, thanks. None of this was registering last night.
|
# ¿ Oct 19, 2008 01:33 |
|
With an array like this:php:<? Array ( [0] => Array ( [0] => -3 [1] => -2 [2] => -1 [3] => 0 [4] => -1 ) [1] => Array ( [0] => -3 [1] => -2 [2] => -1 [3] => 0 [4] => -1 ) [2] => Array ( [0] => -1 [1] => -1 [2] => 1 [3] => 2 [4] => 3 ) [3] => Array ( [0] => -1 [1] => -1 [2] => 26 [3] => 27 [4] => 28 ) [4] => Array ( [0] => -1 [1] => -1 [2] => 51 [3] => 52 [4] => 53 ) )?>
|
# ¿ Oct 27, 2008 00:47 |
|
Zorilla posted:PHP has quite a few functions for searching for things in arrays or running callbacks for things in arrays, etc. Would in_array() work for what you need? I actually need to run through everything in the array and output something, if the value is less than 1 it's supposed to output something as well. I'm thinking two for loops and some conditional statements but that doesn't sound too memory efficient.
|
# ¿ Oct 27, 2008 01:29 |
|
Begby posted:Looping through an array is not that memory intensive in php. You can probably increase that array to include a couple of thousand elements and not notice too much of a hit. Try creating a loop from 1 to 10,000 that generates an array like this, then loop through it and see how much of a difference it makes. Thanks to all for the replies.
|
# ¿ Oct 28, 2008 03:22 |
|
Are you using pconnect? Also the page might be pushing your server loads up. You might want to try tinkering with the my.cnf
|
# ¿ Nov 20, 2008 17:58 |
|
Why is this:php:<? while ( preg_match( "#<span style=['\"]font-size:?(.+?)pt;?\s+?line-height:?\s+?100%['\"]>(.+?)</span>#is", $txt ) ) ?> <span style='font-size:10pt;line-height:100%'>[color=red]Click everyday & feed the hungry for free!:[/color]</span> <span style='font-size:10pt;line-height:100%'>thehungersite.com</span> Acer Pilot fucked around with this message at 04:28 on Dec 8, 2008 |
# ¿ Dec 8, 2008 01:29 |
|
Zorilla posted:Uncheck "Automatically parse URLs" and edit those out. That didn't work Bug on the forum? jasonbar posted:I don't know if this is why, but your "\s" needs to be "\\s" I'll give it a shot in a second. edit that didn't work. HEre's more of the code php:<? while ( preg_match( "#<span style=['\"]font-size:?(.+?)pt;?\s+?line-height:?\s+?100%['\"]>(.+?)</span>#is", $txt ) ) { $txt = preg_replace_callback( "#<span style=['\"]font-size:?(.+?)pt;?\s+?line-height:?\s+?100%['\"]>(.+?)</span>#is" , array( &$this, 'unconvert_size' ), $txt ); }?> Acer Pilot fucked around with this message at 04:35 on Dec 8, 2008 |
# ¿ Dec 8, 2008 04:29 |
|
|
# ¿ Apr 30, 2024 14:27 |
|
Zorilla posted:...gonna use this double post to break up my thoughts... Hm. I got an error about the first ] (it being unexpected). Regex continues to hurt my brain. Thanks for trying though.
|
# ¿ Dec 8, 2008 09:26 |