X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Futil.php;h=62f7abc9ee6799f4c6740a02396c8e83d1cdfdde;hb=0876b60006da7f0ac2d6a4a01b50117a2ecca6b1;hp=b7226bd581c2260614e19f7e959904d975cd6ac7;hpb=c51d1521f030cf319ece276dbce25b2408b2e81e;p=quix0rs-gnu-social.git diff --git a/lib/util.php b/lib/util.php index b7226bd581..62f7abc9ee 100644 --- a/lib/util.php +++ b/lib/util.php @@ -194,11 +194,11 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL, $headercall= common_element_start('div', array('id' => 'wrap')); common_element_start('div', array('id' => 'header')); common_nav_menu(); - if ((is_string($config['site']['logo']) && (strlen($config['site']['logo']) > 0)) + if ((isset($config['site']['logo']) && is_string($config['site']['logo']) && (strlen($config['site']['logo']) > 0)) || file_exists(theme_file('logo.png'))) { common_element_start('a', array('href' => common_local_url('public'))); - common_element('img', array('src' => ($config['site']['logo']) ? + common_element('img', array('src' => isset($config['site']['logo']) ? ($config['site']['logo']) : theme_path('logo.png'), 'alt' => $config['site']['name'], 'id' => 'logo')); @@ -223,6 +223,14 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL, $headercall= common_element_start('div', array('id' => 'content')); } +# XXX: Refactor w/common_user_error() ? +function common_show_basic_auth_error() { + header('HTTP/1.1 401 Unauthorized'); + header('Content-type: text/plain'); + print("Could not authenticate you."); # exactly what Twitter says - no \n + exit(); +} + function common_show_footer() { global $xw, $config; common_element_end('div'); # content div @@ -245,7 +253,7 @@ function common_show_footer() { common_text(_('Unless otherwise specified, contents of this site are copyright by the contributors and available under the ')); common_element('a', array('class' => 'license', 'rel' => 'license', - href => $config['license']['url']), + 'href' => $config['license']['url']), $config['license']['title']); common_text(_('. Contributors should be attributed by full name or nickname.')); common_element_end('p'); @@ -700,7 +708,7 @@ function common_local_url($action, $args=NULL) { function common_fancy_url($action, $args=NULL) { switch (strtolower($action)) { case 'public': - if ($args && $args['page']) { + if ($args && isset($args['page'])) { return common_path('?page=' . $args['page']); } else { return common_path(''); @@ -734,6 +742,8 @@ function common_fancy_url($action, $args=NULL) { return common_path('settings/email'); case 'openidsettings': return common_path('settings/openid'); + case 'smssettings': + return common_path('settings/sms'); case 'newnotice': if ($args && $args['replyto']) { return common_path('notice/new?replyto='.$args['replyto']); @@ -749,7 +759,7 @@ function common_fancy_url($action, $args=NULL) { case 'subscribers': case 'all': case 'replies': - if ($args && $args['page']) { + if ($args && isset($args['page'])) { return common_path($args['nickname'].'/'.$action.'?page=' . $args['page']); } else { return common_path($args['nickname'].'/'.$action); @@ -761,7 +771,7 @@ function common_fancy_url($action, $args=NULL) { case 'userrss': return common_path($args['nickname'].'/rss'); case 'showstream': - if ($args && $args['page']) { + if ($args && isset($args['page'])) { return common_path($args['nickname'].'?page=' . $args['page']); } else { return common_path($args['nickname']); @@ -853,6 +863,16 @@ function common_date_w3dtf($dt) { return date(DATE_W3C, $t); } +function common_date_rfc2822($dt) { + $t = strtotime($dt); + return date("r", $t); +} + +function common_date_iso8601($dt) { + $t = strtotime($dt); + return date("c", $t); +} + function common_redirect($url, $code=307) { static $status = array(301 => "Moved Permanently", 302 => "Found", @@ -871,6 +891,7 @@ function common_redirect($url, $code=307) { function common_save_replies($notice) { # Alternative reply format + $tname = false; if (preg_match('/^T ([A-Z0-9]{1,64}) /', $notice->content, $match)) { $tname = $match[1]; } @@ -903,7 +924,7 @@ function common_save_replies($notice) { $id = $reply->insert(); if (!$id) { $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError'); - common_log(LOG_ERROR, 'DB error inserting reply: ' . $last_error->message); + common_log(LOG_ERR, 'DB error inserting reply: ' . $last_error->message); common_server_error(sprintf(_('DB error inserting reply: %s'), $last_error->message)); return; } @@ -928,7 +949,7 @@ function common_enqueue_notice($notice) { $result = $qi->insert(); if (!$result) { $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError'); - common_log(LOG_ERROR, 'DB error inserting queue item: ' . $last_error->message); + common_log(LOG_ERR, 'DB error inserting queue item: ' . $last_error->message); return false; } common_log(LOG_DEBUG, 'complete queueing notice ID = ' . $notice->id); @@ -942,17 +963,23 @@ function common_real_broadcast($notice, $remote=false) { require_once(INSTALLDIR.'/lib/omb.php'); $success = omb_broadcast_remote_subscribers($notice); if (!$success) { - common_log(LOG_ERROR, 'Error in OMB broadcast for notice ' . $notice->id); + common_log(LOG_ERR, 'Error in OMB broadcast for notice ' . $notice->id); } } if ($success) { require_once(INSTALLDIR.'/lib/jabber.php'); $success = jabber_broadcast_notice($notice); if (!$success) { - common_log(LOG_ERROR, 'Error in jabber broadcast for notice ' . $notice->id); + common_log(LOG_ERR, 'Error in jabber broadcast for notice ' . $notice->id); + } + } + if ($success) { + require_once(INSTALLDIR.'/lib/mail.php'); + $success = mail_broadcast_notice_sms($notice); + if (!$success) { + common_log(LOG_ERR, 'Error in sms broadcast for notice ' . $notice->id); } } - // XXX: broadcast notices to SMS // XXX: broadcast notices to other IM return $success; } @@ -1300,4 +1327,10 @@ function common_profile_uri($profile) { } # XXX: this is a very bad profile! return NULL; +} + +function common_canonical_sms($sms) { + # strip non-digits + preg_replace('/\D/', '', $sms); + return $sms; } \ No newline at end of file