Created
February 8, 2013 00:28
-
-
Save ryankinal/4735530 to your computer and use it in GitHub Desktop.
WTF strlen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// config file | |
define('STOP_MESSAGE', ' (txt "STOP" to cancel)'); | |
// form handling | |
$length = 157 - strlen(STOP_MESSAGE) - strlen($keyword->getAttribute('word')); | |
$reply = isset($_POST['reply']) ? $_POST['reply'] : false; | |
if (strlen($reply) <= $length) | |
{ | |
$keyword->setAttribute('auto_reply', $reply); | |
if ($keyword->save()) // save shit to the database all ORM style | |
{ | |
$success = true; | |
} | |
else | |
{ | |
$error = 'There was a problem saving your auto reply. Please try again.'; | |
} | |
} | |
else | |
{ | |
$error = "Hold up. That's a little too long."; | |
} | |
// On API call | |
$text = $keyword->getAttribute('auto_reply'); | |
$text = $keyword->getAttribute('word').': '.$text.' '.STOP_MESSAGE; | |
// echo as XML | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment