From 63dcbe1e6e4dc49de9ce9be82421c043cc751007 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 23 Jun 2008 20:15:23 -0400 Subject: add jabber library and use it darcs-hash:20080624001523-34904-8d0c052f12301d86aeb9107149b34f22c94da1c4.gz --- lib/jabber.php | 33 +++++++++++++++++++++++++++++++++ lib/util.php | 19 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 lib/jabber.php (limited to 'lib') diff --git a/lib/jabber.php b/lib/jabber.php new file mode 100644 index 000000000..141b9231f --- /dev/null +++ b/lib/jabber.php @@ -0,0 +1,33 @@ +. + */ + +if (!defined('LACONICA')) { exit(1); } + +function jabber_valid_base_jid($jid) { + # Cheap but effective + return Validate::email($jid); +} + +function jabber_normalize_jid($jid) { + preg_match("/(?:([^\@]+)\@)?([^\/]+)(?:\/(.*))?$/", $jid, $matches); + $node = $matches[1]; + $server = $matches[2]; + $resource = $matches[3]; + return strtolower($node.'@'.$server); +} diff --git a/lib/util.php b/lib/util.php index d990b8e1f..7a9bed2c9 100644 --- a/lib/util.php +++ b/lib/util.php @@ -319,6 +319,25 @@ function common_input($id, $label, $value=NULL,$instructions=NULL) { common_element_end('p'); } +function common_checkbox($id, $label, $value='true', + $instructions=NULL) +{ + common_element_start('p'); + $attrs = array('name' => $id, + 'type' => 'checkbox', + 'id' => $id, + 'value' => $value); + if ($value) { + $attrs['value'] = htmlspecialchars($value); + } + common_element('input', $attrs); + common_element('label', array('for' => $id), $label); + if ($instructions) { + common_element('span', 'input_instructions', $instructions); + } + common_element_end('p'); +} + function common_hidden($id, $value) { common_element('input', array('name' => $id, 'type' => 'hidden', -- cgit v1.2.3-54-g00ecf