Archive for the ‘CakePHP’ Category

03 May 09 _ How to flip text upside-down on Twitter

Here’s a little trick I just saw on Twitter that will let you tweet upside down. All you do is go to this website and enter the text that you want to flip and reverse:

http://www.revfad.com/flip.html

¡ǝldɯıs ʇɐɥʇ s,ʇı
It’s that simple!

Follow us on Twitter: @AWPNY

09 Mar 09 _ How to get CakePHP to work in a subdirectory

I recently had trouble getting CakePHP running properly in a subdirectory on the Mosso cloud. The main site URL is http://thinkandthrive.com, and the Cake app lives in a folder off the site root called “tw”. So I was able to connect to http://thinkandthrive.com/tw/, but not to http://thinkandthrive.com/tw (without the trailing slash).

The fix to get Cake working in the subdirectory was to add a single line to the .htaccess file in the Cake root directory ( the “/tw” folder in my case). The .htaccess file should look something like this:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]

Add this line after “RewriteEngine on”:

RewriteRule /YOURCAKESUBDIR$ /YOURCAKESUBDIR/ [L]

Obviously, replace “YOURCAKESUBDIR” with the subdirectory your Cake app in running in. So my .htaccess file now looks like this:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /tw/
RewriteRule /tw$ /tw/ [L]
RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]

(The third line, “RewriteBase /tw/”, is necessary to get CakePHP working in the Mosso hosting environment. If your Cake installation is at the server web root (the Mosso “content” directory) then it should read simply “RewriteBase /”. If your site is not hosted at Mosso just eliminate this line.)

Thanks to Jeff Loiselle for the quick fix: http://jeff.loiselles.com/wordpress/?p=22

14 Nov 08 _ MySQL Transactions With CakePHP 1.2

Whew, been a while since I’ve posted something useful.

Hopefully, everyone is aware of MySQL transactions and how useful they can be.  They come in especially handy when you want to save multiple related entries into different tables in your app.  Cake actually already uses this in a behind the scenes way with the Model::saveAll() function, which does some of this for you (you can read more about saving your data with saveAll() here).

But you can easily use Transactions for anything you want to do.

Note: for this to work at all you have to make sure whatever table you’re using transactions with are of the type InnoDB, and not the standard MyISAM type.

ALTER TABLE table_name type=InnoDB;

Ok, in your model, set the variable:

var $transactional = true;

Then, in a function you want to use transactions, call the datasource object:

$db =& ConnectionManager::getDataSource($this->useDbConfig);

Then, before you start interacting with the database, you call:

$db->begin($this);

If your action is successful, run:

$db->commit($this);

Or, if there’s a failure, you can roll back your DB with:

$db->rollback($this);

Note that your DB will automatically rollback if there’s not a commit() command anyway.

In the course of a Model class, the usage of these functions could look something like this:


class YourModel extends AppModel {

var $transactional = true;

function someCoolModelAction()
{

  # Grab DataSource Object #
  $db =& ConnectionManager::getDataSource($this->useDbConfig);

  # Start Transaction #
  $db->begin($this);

  /* SQL or Model Functions for whatever you need to do go here */

  # If your database interaction was successful, then commit the changes to the Database ( I'm assuming there is some boolean
  # variable, $successVar, that describes whether the action was successful or not).

  if ($successVar === true) {
       return $db->commit($this);
  } else {
       # If it wasn't successful, rollback any changes and you're good #
       $db->rollback($this);
       return false;
  }
}

}

As you can see, it’s pretty easy. And cool.

15 Jul 08 _ CakePHP 1.2 RC2 + Security Component

I’ve been wrangling with the Cake’s Security Component for the past day, not having the best time with it. If you’ve been trying to use it, you may have noticed that there seems to be near-total lack of documentation on it. Not cool.

So I was trying to use it to make some simple HTTP Authentication requests for a WebTree site of ours. It turns out that whenever the Security Component is initialized in a controller, it requires that all POST-ed data in that controller be validated through the Security Component. For this to work correctly, and not spit you out into a blank page “black hole,” you have to use the Form Helper for every form that needs to be submitted, making sure to use $form->end().

It looks like the Form Helper builds a Hash number based on the name of the fields included in the form and the Security Salt that you set in the config/core.php.

When the form is submitted, a function, __validatePost(), runs automatically, there is currently no way to turn it off, and tries to make the same hash value as all the fields present in the Controller’s $data variable. If the two hash values are the same, we know that no extra data is being submitted directly to the controller, and we proceed with the normal course of things. If they don’t match, we trigger the Black Hole callback function, and go down that route.

Except that in the current RC2 release (7296), there is a bug in the Security Component that will ensure that these two hashes will never be equal.

The problem is in line 662 of /cake/libs/controller/components/security.php:

$check = md5(urlencode(Security::hash(serialize($field) . Configure::read('Security.salt'))));

Should be:

$check = urlencode(Security::hash(serialize($field) . Configure::read('Security.salt')));

Take out the md5() function. Form Helper’s security function that generates the form’s hash value does not include the extra md5 hashing function. It looks like this was fixed in the nightly build.

This will alleviate some of your potential issues using the Security Component. However, if you just want to use some aspects of the component, such as HTTP Auth, there is no way to disable the POST validation, much to my chagrin. Maybe it will change in the future.

14 Jul 08 _ Sluggable Behavior + RC2

Ahh, yes. The shared pain/annoyance of upgrading Cake from RC1 to RC2 and finding that the SQL operator syntax has changed.  Sure it’s more sequre, sure it’s not as elegant looking, and sure there seems to be zero backward compatibility, but yeah, it happens.  It’s still a pre-release.  We deal.

So for those that currently use iano Iglesias’ super-helpful Sluggable Behavior, make sure to change line 121 from:

$conditions = array($Model->alias . '.' . $this->__settings[$Model->alias]['slug'] =>' LIKE ' . $slug . '%');

to:


$conditions = array($Model->alias . '.' . $this->__settings[$Model->alias]['slug'] . ' LIKE '=> $slug . '%');

The current version, 1.1.36, does not include this fix for Cake RC2. Without this, you’ll start getting duplicate slug values, lacking any numerical appending action.

  • guitar modification parts
  • butcher paper roll dispenser
  • makers of dog kennels
  • credit card debt relief program
  • billet grills
  • studio rta the bug computer desk
  • shark cordless cyclonic hand vacuum
  • toastmaster parts toaster
  • men's suits shirts barney
  • saucony shoes outlet stores
  • 1 2 decorative square post caps
  • fruit of the loom union suits
  • maine snowmobile insurance requirements
  • boyne mountain grand lodge and spa
  • triple pet natural toothpaste
  • used kids dirt bikes for sale
  • 30 inch slide in electric range
  • create pdf word embed fonts
  • wholesale jelly jars
  • water as fuel denny klein
  • couch replacement pillows
  • coleman bayside elite replacement parts
  • sponge bob crabby patty candy
  • wholesale winter gloves hats
  • best at home treatment for blackheads
  • tub refinishing pgh pa
  • tile shower seat vintage
  • caught wearing high heels split skirt
  • kawasaki kx85 parts and exploded view
  • india and business dress
  • kid's camp crafts
  • cuff bracelets wholesale
  • golf gps systems reviews
  • wholesale patio pool furniture
  • crystal on the plaza
  • global travel shoes
  • spectrum products tanning bed
  • 84 wide wooden window blinds
  • consigning my lilly pulitzer clothes
  • no smoking rooms in boston hotels
  • aubrey organics skin cleanser
  • home decor liquidators furniture and flooring
  • hair regrowth products reviews
  • black bean corn citrus vinegar
  • jt paintball gear
  • how to create finger nail designs
  • popup tent cleaning
  • knife sound editing
  • hippie chick costumes
  • miniature surveillance cameras detection
  • hd high def video edit
  • recycle styrofoam cups
  • bamboo patio door blinds
  • money order promise rings
  • resurfacing bathtubs
  • mens star earrings
  • spray face foundation
  • remote home thermostats
  • phoenix skin rejuvenation
  • shower enclosures walls
  • kawasaki 440 aircraft engine parts
  • women's clothing sleep shirts
  • material requirements planning mrp systems
  • cryoserver back email compliance archiving message
  • home flea infestation
  • cuisinart 9-speed hand mixer brushed chrome
  • wholesale military surgical caps
  • nike drawstring backpack lavender
  • acutane colon problems
  • mercedes 320 wagon tires
  • ucla womens basketball camps
  • vida international fruta
  • kids camp crafts
  • compliance corporate email
  • good feet store onalaska wi
  • coach purse party
  • women's shoulder handbags
  • diy exterior patio blinds
  • pivot tub shower enclosures
  • dog harness and collar
  • shoi racing helmets
  • free shawl knit patterns
  • thyme essential oil price
  • tubeless bicycle wheels road
  • black edition magazine man swimsuit
  • 5 star car wax
  • italian charm bracelets wholesale
  • sleep t shirts
  • audio cards upside down
  • dell 5100cn colour network laser printer
  • fj cruiser trailer hitch receivers
  • sell structured settlement payment
  • organizational monitor stands
  • prom decorations and costumes
  • cats on behavior medication
  • golf palm computer gps system
  • budget wedding planning checklist
  • movie theater popcorn maker canada
  • water pump 3-inch suction hose
  • invest in stocks cheap
  • nike max air inline skates
  • star wars galactic heroes bedding comforter
  • airsoft outfitters gear
  • cheap new chevy trucks
  • discounted airfares cheapest airfares erfurt
  • floral furniture throws
  • schutt baseball equipment
  • acrobat distiller settings for news print
  • 2.4 to 3.8 s10 truck conversion
  • westgate villia resorts
  • fuzzy bunny slippers adult
  • shock doctor mouth pieces
  • midwest family vacations
  • red kap highland uniform shirts
  • play euchre free online
  • rockport shoes rosemont
  • elo entuitive touchscreen drivers
  • decorative garden pond fountains
  • kids online cake decorating games
  • america west airlines dividend miles program
  • in kind giving from popcorn company
  • camera ccd industrial
  • outdoor furniture pool harrows
  • raymond waites spring garland
  • lil boosie new mixtapes
  • household and cleaning forum
  • video piggy 1.3.0 crack