Jump to content

tmallen

Members
  • Posts

    112
  • Joined

  • Last visited

    Never

Posts 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. Does anybody know of a simple, reliable PHP-based URL routing library? I have found two candidates, neither of which meets my requirements:

    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

     

  3. 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);
        }
    }

  4. 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.

  5. 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.

  6. 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.

  7. it's come up blank again and i'm using php 5.2.6

    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.

  8. Based on:

    Ive added a hyperlink to our esite which is working but it appears underlined.

    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...

  9. 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.

  10. 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.

  11. 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.

  12. 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.