Jump to content

tmallen

Members
  • Posts

    112
  • Joined

  • Last visited

    Never

Everything posted by tmallen

  1. Taking a stab since you didn't really state your requirements...this passes your test at least. <?php function humanize($input){ return preg_replace('/ (?<=[\]})]) # Closing char to the left (?=[A-Za-z]) # Letter to the right /x', ' ', # Insert a space preg_replace('/ (?<=[A-Za-z]) # Letter to the left (?=[[({]) # Opening char to the right /x', ' ', $input) # Insert a space ); } $string = 'test Test TesT test[test] test(test) test[test test] test[test]test'; echo humanize($string);
  2. That's not really a usable recommendation...
  3. If you want to make a cell span more than one column, which is what you said you wanted to do, use the "colspan" attribute: http://www.w3.org/TR/html401/struct/tables.html#adef-colspan This code is inherently wrong because it is outputting HTML in little bits, mixed with programming logic. I suggest you replace this code when you can to make it more accessible to other developers.
  4. I only have experience with one-way encryption in PHP (the md5 and sha1 algorithms), but from what I understand, there are ways of performing two-way encryption (what you want) with the mcrypt library. http://php.net/manual/en/book.mcrypt.php http://www.phpro.org/classes/Two-Way-Encryption-With-PHP-Mcrypt.html
  5. if (true && 2 >1) The (bool) value of each operand, that is, the value of each expression (left and right-hand) when cast as boolean, evaluate to true, so the full "&&" statement evaluates to true. http://www.php.net/manual/en/language.operators.logical.php http://www.php.net/manual/en/language.operators.precedence.php
  6. Does anybody know of a simple, reliable PHP-based URL routing library? I have found two candidates, neither of which meets my requirements: routemap: http://code.google.com/p/routemap/ Horde Routes: http://dev.horde.org/routes/ routemap is too direct: It dispatches directly to static class methods, thus enforcing a structure. Horde Routes do not behave as documented on the website. Note that the returned match array below has no controller set. <?php $map = new Horde_Routes_Mapper(); $map->createRegs(array('test', 'cat', 'dog')); $map->connect(':controller/:action/:id'); var_dump($map->match('/test')); // array with action => 'index' and id => null
  7. ob_get_flush returns the contents of the output buffer. After the clean, shouldn't the include add to the buffer, being the contents of that returned string?
  8. The cache file is created, but it's empty. I can pass in a debug string which is written successfully. <?php function page($name, $params = array(), $cache = false) { if(is_array($params)) { extract($params); } else { $title = $params; } function put_page($name) { ob_start(); include sprintf('pages/%s.php', $name); $content = ob_get_clean(); include 'pages/page.php'; return ob_get_flush(); } if($cache) { $cache_file = sprintf('cache/page/%s.html', $name); if(file_exists($cache_file)) { echo file_get_contents($cache_file); unlink($cache_file); } else { if(!is_dir('cache/page')) { mkdir('cache/page'); } $cached = fopen($cache_file, 'w'); fwrite($cached, put_page($name)); fclose($cached); } } else { put_page($name); } }
  9. In the end, I just had to open 3306 to the other IP (no MySQL setting was required).
  10. Thanks! I had the first parts (grant privileges from the remote IP, point mysql_connect vice versa) but I didn't know about external connection allowance.
  11. I'm working on a multi-server setup, and I have a big problem: How do I make my application server talk to a separate database server? I know that I can't just point mysql_connect to the other IP address. Does anyone know of good resources about configuring each server to talk to the other?
  12. By government sites I mean that they're advertising the sale of government-owned properties (for DC firms) and licensing opportunities. Sort of a gray area, not quite the same as hosting a DOD site; I'd expect the government to provide a secure host in that case.
  13. I tried Linode, and that was a living hell. I'm a web developer, not a server administrator, and while I can set up a nice LAMP stack, I'll be damned if I can pull the same off for DNS, email, FTP, etc. Where's the (affordable) middle ground? Linode is $20-30 a month for a reasonable server, and I pay $13 a month on Hostgator for, most importantly, unlimited bandwidth. This is important because I host a government site there that has several enormous PDFs for download.
  14. So is it more likely that the mail server on my shared host is being abused by a separate party? I use HostGator, and one would expect that a host of that size would by now have solved this problem for their customers, which is why I'm apprehensive to believe so.
  15. I have a simple "contact us" form on my website, and I think it may be used to send spam. Email from my mail server (off of a shared host) is now being rejected by Craigslist, and on occasion (maybe once a month) I get a "viagra!" type of bounceback for an undeliverable message. I've always hard-coded the email address in the mail() call, but I wouldn't be surprised if I'm doing something wrong here. What can I do to audit this? There are a few other contact forms on the same server for two other sites. All of the direct email forms have a hard-coded "to" parameter for mail(), and the two that send an email based on an email form value also write to the database. I checked over the database for these two, and of 120 people who have submitted the form, perhaps ten appear to be junk. So, what's going on, if anything? How can I know? I get this feeling...that my domain name will be blacklisted or has been already, but I'm pretty careful when I use mail(). Of course, I'm no hacker nor a security expert.
  16. My team at work needs a new FTP client (our current one is awful), and we all work on Windows boxes. Now, to put it simply, I needed someone to show me how to use Outlook and other basic Windows skills when I joined up because I'd only worked on Linux and Macs in the past. My favorite FTP client is ncftp, followed by Transmit (for its OSX integration), and I really don't have an opinion on Windows clients. I tried WinSCP today which seemed nice (for the MC bindings), but I thought it would be best to seek a few second opinions. For the Windows users here: Which FTP client (free or paid, doesn't matter) do you prefer? One thing I've noticed is how few FTP clients on Windows have keybindings for common actions.
  17. For anyone who comes across this, the answer was to put the echo statement at the bottom of the page (or include tree) so that it displays errors. Seems obvious now.
  18. Any ideas? Don't worry, this is the last time I'll bump this post...I guess that I should head to comp.lang.php next time I have something tough to solve.
  19. I'll bet that display_errors is off and you have a little syntax error there. Note that I haven't read the previous seven or so pages, so sorry if I'm missing something.
  20. Based on: I made an educated guess that this was in adherence to some style guide, organized or not. Also, even with one link per page, it still would become a maintenance nightmare pretty quickly. Linking to the stylesheet means you can use the same styles for each and every page, and you save a tiny amount of bandwidth (I remember when that was a big argument around '99 for CSS). Of course, the chances that the OP continued following this thread after they found their solution is...
  21. Just curious, what info exposed could really compromise security? Sure, a hacker would have more information on hand about my server, but I only see this being a problem if my software is out of date and known exploits can be determined...oh, I guess that it is a security risk.
  22. I mean, I explained the reasoning throughout and it's clear that the solution is a bit over-engineered for a single style change. But it surely doesn't hurt to educate, and your "who are you to assume..." stance contrasts pretty sharply with the fact that you don't like me suggesting useful, accurate, relevant information here. Next time I'll just highlight and bold "BAD" so that people insistent on judging a post based on a negative word can get to the point faster.
  23. This is what I do for a living, so it's always on my mind. Like I said above though (in my code examples), even if it's just one link, there's still some reason. I can't remember a single time I've edited a site, built a comp, etc. where such a simple style was used only once in the site. In any case, it's better to isolate the CSS in the <head> even with non-descriptive class names than to use inline styles which are pretty much unmaintainable.
  24. Er, pretty please? I can't find anything on this (which may be why nobody's answered it so far...), or on providing a wrapper element for error messages.
  25. I thought it's an interesting discussion on CSS and web usability, but that's just me. In any case, let me get a word in: Links shouldn't be colored at random. It confuses users. That is, unless you're treating the web as an artistic medium (which would put you in a tiny minority of web designers) rather than as a way to deliver information and engage users.
×
×
  • 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.