Archive for the 'PHP' Category

Post via script

I just whipped up some PHP and threw it in the root of a brand new Wordpress 2.9.2 install:

<?php
include_once('wp-config.php');
include_once('wp-load.php');
include_once('wp-includes/wp-db.php');

$my_post = array();
$my_post['post_title'] = 'My post';
$my_post['post_content'] = 'This is my post.';
$my_post['post_status'] = 'publish';
$my_post['post_author'] = 1;

wp_insert_post( $my_post );
?>

Voila. The post appeared when navigating to the .php file.

See: http://codex.wordpress.org/Function_Reference/wp_insert_post.

For more creativity, get into the database: http://codex.wordpress.org/Function_Reference/wpdb_Class

Posted by Karl Herrick on March 11th, 2010 in Wordpress, PHP, Web Development | No Comments »

Portfolio

I have gathered some of the better work that I have done over the years, took some screenshots, and posted them to a running instance of MooFlow. Hopefully it can serve as a portfolio for others to view and discuss.

See it at the following url: http://karlherrick.com/portfolio/

Posted by Karl Herrick on October 11th, 2009 in Wordpress, Javascript, PHP, XML, Web Development, Firefox, Hosting | No Comments »

iUI and the iPhone

My employer recently purchased a set of iPhones from AT&T for those in the workforce that have a need for such a thing. One of our first priorities was getting our rolodex accessible (read only) from the road. The main problem is that the data is in a restrictive, old school database. Until we can find time to move it into a more open platform I did the following:

Checkout the screenshots:

Login  Search  Results  Info

It’s pretty cool, because if the contact in the rolodex has a telephone number, address, email address, or webpage associated with them, the data will be displayed and linked to iPhone friendly functions… For example, the telephone number, when clicked on will provide a call button. An address clicked on will link to the built in maps app. Email links open up directly in the built in mail app. Finally, of course, webpages openup in Safari.

So here’s for getting the world more connected… one app at at time.

Posted by Karl Herrick on December 8th, 2008 in Javascript, Apple, PHP | 2 Comments »

Goldfish and forged spam

Recently I had the goldfish autoresponder (vacation responses / email auto reply) setup for a user for about one week. Checking their inbox about half way through this time period revealed it having over 47,000 unread messages. What was happening is that spammers were sending email with forged headers. Have you ever received a spam message that apparently has been sent from yourself?

I suppose it can be accomplished via a variety of ways, however I was able to reproduce this particular issue via generating one of these tasty spam mails via the following (all internally of course… I am not a spammer):

telnet smtp.example.com 25

and then issuing these commands:

ehlo workstation.example.com
mail from:<emailuser@example.com>
rcpt to:<emailuser@example.com>
data
From: <emailuser@example.com>
To: <emailuser@example.com>
Subject: testing a loop
Message text
.
quit

Notice the mail is being sent to the user… and from the user…

  1. The server would receive the email addressed to emailuser@example.com
  2. goldfish would parse the message and notice it needed to respond to… emailuser@example.com
  3. The mail was delivered
  4. Rinse, wash, repeat

The source of the message looked something like this:

root@server:/var/local/vmail/example.com/emailuser# cat new/1220557062.P6882Q0M652544.server\,S\=1082
Return-Path: <emailuser@example.com>
Delivered-To: emailuser@example.com
Received: from localhost (localhost [127.0.0.1]) by server.example.com (Postfix) with ESMTP id 923E9185F7 for <emailuser@example.com>; Thu, 4 Sep 2008 15:37:42 -0400 (EDT)
X-Virus-Scanned: Debian amavisd-new at server.example.com
Received: from server.example.com ([127.0.0.1]) by localhost (server.example.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q3tScOaitRoS for <emailuser@example.com>; Thu, 4 Sep 2008 15:37:42 -0400 (EDT)
Received: from workstation.example.com (workstation.example.com [xx.xxx.xxx.xx]) by server.example.com (Postfix) with ESMTP id B89E1185EB for <emailuser@example.com>; Thu, 4 Sep 2008 15:37:25 -0400 (EDT)
From: <emailuser@example.com>
To: <emailuser@example.com>
Subject: testing a loop

Message-Id: <20080904193728.B89E1185EB@server.example.com>
Date: Thu, 4 Sep 2008 15:37:25 -0400 (EDT)

Message text

and to prevent goldfish from causing havoc on the particular inbox (or mitigating what was already done… and preventing future issues), I added the following PHP:

//strip the line break from $address for checks
$addressCheck = substr($address,0,strlen($address)-1);
if ($addressCheck==$email)
{
        $log->addLine("Email address from autoresponder table is the same as the intended recipient! Not sending the mail!");
        break;
}

just before letting the mail being sent…

mail($address, $subject, $message, $headers);

I love goldfish. It’s like a do it yourself autoresponder! Keep in mind, this code works on Version 002, patch level 1, but could very well not work on any future releases (there have been indications that a newer version is in the works). Maybe I will post a few more tweaks in upcoming posts if the latest stable stays around for much longer.

Posted by Karl Herrick on September 9th, 2008 in PHP, Linux, Cron | 2 Comments »

Autoresponders - a loop

This past week I encountered an interesting situation between two web applications I work with regularly. The first is the goldfish autoresponder for postfix. The second is RT: Request Tracker.

The situation went something like this:

Every five minutes a new ticket was being created in RT because of goldfish’s configuration and cron job being set to run that often. I caught the cycle happening when the incoming queue of tickets had three or four created with their subjects typical of those created by an autoresponder.

Posted by Karl Herrick on August 2nd, 2008 in PHP, Linux, Cron | 2 Comments »