/** * Send a multipart/alternative message with Text and HTML versions * * @param fromName name of the sender * @param fromEmail email fo the sender * @param replyTo replyTo address to direct responses * @param toEmail destination email address * @param messageSubject subject of the message * @param htmlVersion html version of the message * @param textVersion text only version of the message * @param additionalMailHeader additions to the smtp mail header * @param optional uid user id of the destination user */ public static function send($params) { call_hooks('emailer_send_prepare', $params); $email_textonly = False; if (x($params, "uid")) { $email_textonly = get_pconfig($params['uid'], "system", "email_textonly"); } $fromName = email_header_encode(html_entity_decode($params['fromName'], ENT_QUOTES, 'UTF-8'), 'UTF-8'); $messageSubject = email_header_encode(html_entity_decode($params['messageSubject'], ENT_QUOTES, 'UTF-8'), 'UTF-8'); // generate a mime boundary $mimeBoundary = rand(0, 9) . "-" . rand(10000000000, 99999999999) . "-" . rand(10000000000, 99999999999) . "=:" . rand(10000, 99999); // generate a multipart/alternative message header $messageHeader = $params['additionalMailHeader'] . "From: {$fromName} <{$params['fromEmail']}>\n" . "Reply-To: {$fromName} <{$params['replyTo']}>\n" . "MIME-Version: 1.0\n" . "Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\""; // assemble the final multipart message body with the text and html types included $textBody = chunk_split(base64_encode($params['textVersion'])); $htmlBody = chunk_split(base64_encode($params['htmlVersion'])); $multipartMessageBody = "--" . $mimeBoundary . "\n" . "Content-Type: text/plain; charset=UTF-8\n" . "Content-Transfer-Encoding: base64\n\n" . $textBody . "\n"; if (!$email_textonly && !is_null($params['htmlVersion'])) { $multipartMessageBody .= "--" . $mimeBoundary . "\n" . "Content-Type: text/html; charset=UTF-8\n" . "Content-Transfer-Encoding: base64\n\n" . $htmlBody . "\n"; } $multipartMessageBody .= "--" . $mimeBoundary . "--\n"; // message ending // send the message $hookdata = array('to' => $params['toEmail'], 'subject' => $messageSubject, 'body' => $multipartMessageBody, 'headers' => $messageHeader); //echo "<pre>"; var_dump($hookdata); killme(); call_hooks("emailer_send", $hookdata); $res = mail($hookdata['to'], $hookdata['subject'], $hookdata['body'], $hookdata['headers']); logger("header " . 'To: ' . $params['toEmail'] . "\n" . $messageHeader, LOGGER_DEBUG); logger("return value " . ($res ? "true" : "false"), LOGGER_DEBUG); return $res; }
function update_network_content(&$a) { $profile_uid = intval($_GET['p']); header("Content-type: text/html"); echo "<!DOCTYPE html><html><body>\r\n"; echo "<section>"; if (!get_pconfig($profile_uid, "system", "no_auto_update") or $_GET['force'] == 1) { $text = network_content($a, $profile_uid); } else { $text = ""; } $pattern = "/<img([^>]*) src=\"([^\"]*)\"/"; $replace = "<img\${1} dst=\"\${2}\""; $text = preg_replace($pattern, $replace, $text); $replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />'; $pattern = "/<\\s*audio[^>]*>(.*?)<\\s*\\/\\s*audio>/i"; $text = preg_replace($pattern, $replace, $text); $pattern = "/<\\s*video[^>]*>(.*?)<\\s*\\/\\s*video>/i"; $text = preg_replace($pattern, $replace, $text); $pattern = "/<\\s*embed[^>]*>(.*?)<\\s*\\/\\s*embed>/i"; $text = preg_replace($pattern, $replace, $text); $pattern = "/<\\s*iframe[^>]*>(.*?)<\\s*\\/\\s*iframe>/i"; $text = preg_replace($pattern, $replace, $text); echo str_replace("\t", ' ', $text); echo "</section>"; echo "</body></html>\r\n"; killme(); }
function nofed_post_local(&$a, &$b) { if ($b['created'] != $b['edited']) { return; } if ($b['mid'] !== $b['parent_mid']) { return; } if (local_channel() && local_channel() == $b['uid']) { if ($b['allow_cid'] || $b['allow_gid'] || $b['deny_cid'] || $b['deny_gid']) { return; } $nofed_post = get_pconfig(local_channel(), 'nofed', 'post'); if (!$nofed_post) { return; } $nofed_enable = $nofed_post && x($_REQUEST, 'nofed_enable') ? intval($_REQUEST['nofed_enable']) : 0; // if API is used, default to the chosen settings if ($_REQUEST['api_source'] && intval(get_pconfig(local_channel(), 'nofed', 'post_by_default'))) { $nofed_enable = 1; } if ($nofed_enable) { return; } if (strlen($b['postopts'])) { $b['postopts'] .= ','; } $b['postopts'] .= 'nodeliver'; } }
function curweather_plugin_settings(&$a, &$s) { if (!local_user()) { return; } /* Add our stylesheet to the curweather so we can make our settings look nice */ $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/curweather/curweather.css' . '" media="all" />' . "\r\n"; /* Get the current state of our config variable */ $curweather_loc = get_pconfig(local_user(), 'curweather', 'curweather_loc'); $enable = intval(get_pconfig(local_user(), 'curweather', 'curweather_enable')); $enable_checked = $enable ? ' checked="checked" ' : ''; /* Add some HTML to the existing form */ $s .= '<div class="settings-block">'; $s .= '<h3>' . t('Current Weather') . '</h3>'; $s .= '<div id="curweather-settings-wrapper">'; $s .= '<p>Find the location code for the airport/weather station nearest you <a href="http://en.wikipedia.org/wiki/International_Air_Transport_Association_airport_code" target="_blank">here</a>.</p>'; $s .= '<label id="curweather-location-label" for="curweather_loc">' . t('Weather Location: ') . '</label>'; $s .= '<input id="curweather-location" type="text" name="curweather_loc" value="' . $curweather_loc . '"/>'; $s .= '<div class="clear"></div>'; $s .= '<label id="curweather-enable-label" for="curweather_enable">' . t('Enable Current Weather') . '</label>'; $s .= '<input id="curweather-enable" type="checkbox" name="curweather_enable" value="1" ' . $enable_checked . '/>'; $s .= '<div class="clear"></div>'; $s .= '</div>'; /* provide a submit button */ $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="curweather-settings-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>'; }
function widgets_settings(&$a, &$o) { if (!local_user()) { return; } $key = get_pconfig(local_user(), 'widgets', 'key'); if ($key == '') { $key = mt_rand(); set_pconfig(local_user(), 'widgets', 'key', $key); } $widgets = array(); $d = dir(dirname(__FILE__)); while (false !== ($f = $d->read())) { if (substr($f, 0, 7) == "widget_") { preg_match("|widget_([^.]+).php|", $f, $m); $w = $m[1]; if ($w != "") { require_once $f; $widgets[] = array($w, call_user_func($w . "_widget_name")); } } } $t = file_get_contents(dirname(__FILE__) . "/settings.tpl"); $o .= replace_macros($t, array('$submit' => t('Generate new key'), '$baseurl' => $a->get_baseurl(), '$title' => "Widgets", '$label' => t('Widgets key'), '$key' => $key, '$widgets_h' => t('Widgets available'), '$widgets' => $widgets)); }
/** * * Called from the Plugin Setting form. * Add our own settings info to the page. * */ function altpager_settings(&$a, &$s) { if (!local_user()) { return; } $global = get_config("alt_pager", "global"); if ($global == 1) { return; } /* Add our stylesheet to the page so we can make our settings look nice */ $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/altpager/altpager.css' . '" media="all" />' . "\r\n"; /* Get the current state of our config variable */ $altpager = get_pconfig(local_user(), 'system', 'alt_pager'); if ($altpager === false) { $altpager = 0; } $checked = $altpager ? ' checked="checked" ' : ''; /* Add some HTML to the existing form */ $s .= '<div class="settings-block">'; $s .= '<h3>' . t('Alternate Pagination Setting') . '</h3>'; $s .= '<div id="altpager-wrapper">'; $s .= '<label id="altpager-label" for="altpager">' . t('Use links to "newer" and "older" pages in place of page numbers?') . '</label>'; $s .= '<input id="altpager-input" type="checkbox" name="altpager" value="1" ' . $checked . '/>'; $s .= '</div><div class="clear"></div>'; /* provide a submit button */ $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="altpager-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>'; }
/** * Theme settings */ function theme_content(&$a) { if (!local_user()) { return; } $font_size = get_pconfig(local_user(), 'diabook', 'font_size'); $line_height = get_pconfig(local_user(), 'diabook', 'line_height'); $resolution = get_pconfig(local_user(), 'diabook', 'resolution'); $color = get_pconfig(local_user(), 'diabook', 'color'); $TSearchTerm = get_pconfig(local_user(), 'diabook', 'TSearchTerm'); $ELZoom = get_pconfig(local_user(), 'diabook', 'ELZoom'); $ELPosX = get_pconfig(local_user(), 'diabook', 'ELPosX'); $ELPosY = get_pconfig(local_user(), 'diabook', 'ELPosY'); $close_pages = get_pconfig(local_user(), 'diabook', 'close_pages'); $close_mapquery = get_pconfig(local_user(), 'diabook', 'close_mapquery'); $close_profiles = get_pconfig(local_user(), 'diabook', 'close_profiles'); $close_helpers = get_pconfig(local_user(), 'diabook', 'close_helpers'); $close_services = get_pconfig(local_user(), 'diabook', 'close_services'); $close_friends = get_pconfig(local_user(), 'diabook', 'close_friends'); $close_twitter = get_pconfig(local_user(), 'diabook', 'close_twitter'); $close_lastusers = get_pconfig(local_user(), 'diabook', 'close_lastusers'); $close_lastphotos = get_pconfig(local_user(), 'diabook', 'close_lastphotos'); $close_lastlikes = get_pconfig(local_user(), 'diabook', 'close_lastlikes'); return diabook_form($a, $font_size, $line_height, $resolution, $color, $TSearchTerm, $ELZoom, $ELPosX, $ELPosY, $close_pages, $close_mapquery, $close_profiles, $close_helpers, $close_services, $close_friends, $close_twitter, $close_lastusers, $close_lastphotos, $close_lastlikes); }
function invite_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $tpl = get_markup_template('invite.tpl'); $invonly = false; if (get_config('system', 'invitation_only')) { $invonly = true; $x = get_pconfig(local_user(), 'system', 'invites_remaining'); if (!$x && !is_site_admin()) { notice(t('You have no more invitations available') . EOL); return ''; } } $dirloc = get_config('system', 'directory_submit_url'); if (strlen($dirloc)) { if ($a->config['register_policy'] == REGISTER_CLOSED) { $linktxt = sprintf(t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), dirname($dirloc) . '/siteinfo'); } elseif ($a->config['register_policy'] != REGISTER_CLOSED) { $linktxt = sprintf(t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), $a->get_baseurl()) . "\r\n" . "\r\n" . sprintf(t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'), dirname($dirloc) . '/siteinfo'); } } else { $o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.'); return $o; } $o = replace_macros($tpl, array('$invite' => t('Send invitations'), '$addr_text' => t('Enter email addresses, one per line:'), '$msg_text' => t('Your message:'), '$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n" . $linktxt . "\r\n" . "\r\n" . ($invonly ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') . t('Once you have registered, please connect with me via my profile page at:') . "\r\n" . "\r\n" . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n", '$submit' => t('Submit'))); return $o; }
/** @file */ function oembed_replacecb($matches) { $embedurl = $matches[1]; // implements a personal embed white/black list for logged in members if (local_channel()) { if ($x = get_pconfig(local_channel(), 'system', 'embed_deny')) { $l = explode("\n", $x); if ($l) { foreach ($l as $ll) { if (trim($ll) && strpos($embedurl, trim($ll)) !== false) { return '<a href="' . $embedurl . '">' . $embedurl . '</a>'; } } } } if ($x = get_pconfig(local_channel(), 'system', 'embed_allow')) { $found = false; $l = explode("\n", $x); if ($l) { foreach ($l as $ll) { if (trim($ll) && strpos($embedurl, trim($ll)) !== false) { $found = true; break; } } } if (!$found) { return '<a href="' . $embedurl . '">' . $embedurl . '</a>'; } } } $j = oembed_fetch_url($embedurl); $s = oembed_format_object($j); return $s; }
/** * @brief Change to another channel with current logged-in account. * * @param int $change_channel The channel_id of the channel you want to change to * * @return bool|array false or channel record of the new channel */ function change_channel($change_channel) { $ret = false; if ($change_channel) { $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and channel_account_id = %d and channel_removed = 0 limit 1", intval($change_channel), intval(get_account_id())); // It's not there. Is this an administrator, and is this the sys channel? if (is_developer()) { if (!$r) { if (is_site_admin()) { $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and channel_system = 1 and channel_removed = 0 limit 1", intval($change_channel)); } } } if ($r) { $hash = $r[0]['channel_hash']; $_SESSION['uid'] = intval($r[0]['channel_id']); get_app()->set_channel($r[0]); $_SESSION['theme'] = $r[0]['channel_theme']; $_SESSION['mobile_theme'] = get_pconfig(local_channel(), 'system', 'mobile_theme'); date_default_timezone_set($r[0]['channel_timezone']); $ret = $r[0]; } $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($hash)); if ($x) { $_SESSION['my_url'] = $x[0]['xchan_url']; $_SESSION['my_address'] = $r[0]['channel_address'] . '@' . substr(get_app()->get_baseurl(), strpos(get_app()->get_baseurl(), '://') + 3); get_app()->set_observer($x[0]); get_app()->set_perms(get_all_perms(local_channel(), $hash)); } if (!is_dir('store/' . $r[0]['channel_address'])) { @os_mkdir('store/' . $r[0]['channel_address'], STORAGE_DEFAULT_PERMISSIONS, true); } } return $ret; }
function langfilter_prepare_body(&$a, &$b) { if (get_pconfig(local_user(), 'langfilter', 'disable')) { return; } if (local_user()) { $langs = get_pconfig(local_user(), 'langfilter', 'languages'); } if ($langs) { $arr = explode(',', $langs); } else { return; } $found = false; $l = new Text_LanguageDetect(); $l->_name_mode = 2; // two letter codes $l->_threshold = 600; // make it a bit harder to be confident with a lng // IOW make it more possible that lng is correct $lng = $l->detectSimple($b['html']); if ($lng == null) { return; } if (!in_array($lng, $arr)) { $found = true; } if ($lng == null) { $found = false; } if ($found) { $rnd = random_string(8); $b['html'] = '<div id="langfilter-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'langfilter-' . $rnd . '\'); >' . sprintf(t('unspoken language %s - Click to open/close'), $lng) . '</div><div id="langfilter-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>'; } }
function change_channel($change_channel) { $ret = false; if ($change_channel) { $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and channel_account_id = %d and not ( channel_pageflags & %d) limit 1", intval($change_channel), intval(get_account_id()), intval(PAGE_REMOVED)); if ($r) { $hash = $r[0]['channel_hash']; $_SESSION['uid'] = intval($r[0]['channel_id']); get_app()->set_channel($r[0]); $_SESSION['theme'] = $r[0]['channel_theme']; $_SESSION['mobile_theme'] = get_pconfig(local_user(), 'system', 'mobile_theme'); date_default_timezone_set($r[0]['channel_timezone']); $ret = $r[0]; } $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($hash)); if ($x) { $_SESSION['my_url'] = $x[0]['xchan_url']; $_SESSION['my_address'] = $r[0]['channel_address'] . '@' . substr(get_app()->get_baseurl(), strpos(get_app()->get_baseurl(), '://') + 3); get_app()->set_observer($x[0]); get_app()->set_perms(get_all_perms(local_user(), $hash)); } if (!is_dir('store/' . $r[0]['channel_address'])) { @os_mkdir('store/' . $r[0]['channel_address'], STORAGE_DEFAULT_PERMISSIONS, true); } } return $ret; }
function pdledit_content(&$a) { if (!local_channel()) { notice(t('Permission denied.') . EOL); return; } if (argc() > 1) { $module = 'mod_' . argv(1) . '.pdl'; } else { $o .= '<h1>' . t('Edit System Page Description') . '</h1>'; $files = glob('mod/*'); if ($files) { foreach ($files as $f) { $name = basename($f, '.php'); $x = theme_include('mod_' . $name . '.pdl'); if ($x) { $o .= '<a href="pdledit/' . $name . '" >' . $name . '</a><br />'; } } } // list module pdl files return $o; } $t = get_pconfig(local_channel(), 'system', $module); if (!$t) { $t = file_get_contents(theme_include($module)); } if (!$t) { notice(t('Layout not found.') . EOL); return ''; } $o = replace_macros(get_markup_template('pdledit.tpl'), array('$header' => t('Edit System Page Description'), '$mname' => t('Module Name:'), '$help' => t('Layout Help'), '$module' => argv(1), '$content' => htmlspecialchars($t, ENT_COMPAT, 'UTF-8'), '$submit' => t('Submit'))); return $o; }
function search_doc_files($s) { $a = get_app(); $itemspage = get_pconfig(local_channel(), 'system', 'itemspage'); App::set_pager_itemspage(intval($itemspage) ? $itemspage : 20); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); $regexop = db_getfunc('REGEXP'); $r = q("select item_id.sid, item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and\n\t\tbody {$regexop} '%s' and item_type = %d {$pager_sql}", dbesc($s), intval(ITEM_TYPE_DOC)); $r = fetch_post_tags($r, true); for ($x = 0; $x < count($r); $x++) { $r[$x]['text'] = $r[$x]['body']; $r[$x]['rank'] = 0; if ($r[$x]['term']) { foreach ($r[$x]['term'] as $t) { if (stristr($t['term'], $s)) { $r[$x]['rank']++; } } } if (stristr($r[$x]['sid'], $s)) { $r[$x]['rank']++; } $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']), strtolower($s)); // bias the results to the observer's native language if ($r[$x]['lang'] === App::$language) { $r[$x]['rank'] = $r[$x]['rank'] + 10; } } usort($r, 'doc_rank_sort'); return $r; }
function snautofollow_settings(&$a, &$s) { if (!local_user()) { return; } /* Add our stylesheet to the page so we can make our settings look nice */ $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/snautofollow/snautofollow.css' . '" media="all" />' . "\r\n"; /* Get the current state of our config variable */ $snautofollow = get_pconfig(local_user(), 'system', 'ostatus_autofriend'); if ($snautofollow === false) { $snautofollow = false; } $snautofollow_checked = $snautofollow ? ' checked="checked" ' : ''; /* Add some HTML to the existing form */ $s .= '<span id="settings_snautofollow_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_snautofollow_expanded\'); openClose(\'settings_snautofollow_inflated\');">'; $s .= '<h3>' . t('StatusNet AutoFollow') . '</h3>'; $s .= '</span>'; $s .= '<div id="settings_snautofollow_expanded" class="settings-block" style="display: none;">'; $s .= '<span class="fakelink" onclick="openClose(\'settings_snautofollow_expanded\'); openClose(\'settings_snautofollow_inflated\');">'; $s .= '<h3>' . t('StatusNet AutoFollow') . '</h3>'; $s .= '</span>'; $s .= '<div id="snautofollow-wrapper">'; $s .= '<label id="snautofollow-label" for="snautofollow-checkbox">' . t('Automatically follow any StatusNet followers/mentioners') . '</label>'; $s .= '<input id="snautofollow-checkbox" type="checkbox" name="snautofollow" value="1" ' . $snautofollow_checked . '/>'; $s .= '</div><div class="clear"></div>'; /* provide a submit button */ $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="snautofollow-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>'; }
/** * * Called from the Plugin Setting form. * Add our own settings info to the page. * */ function startpage_settings(&$a, &$s) { if (!local_user()) { return; } /* Add our stylesheet to the page so we can make our settings look nice */ $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/startpage/startpage.css' . '" media="all" />' . "\r\n"; /* Get the current state of our config variable */ $page = get_pconfig(local_user(), 'startpage', 'startpage'); /* Add some HTML to the existing form */ $s .= '<span id="settings_startpage_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">'; $s .= '<h3>' . t('Startpage') . '</h3>'; $s .= '</span>'; $s .= '<div id="settings_startpage_expanded" class="settings-block" style="display: none;">'; $s .= '<span class="fakelink" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">'; $s .= '<h3>' . t('Startpage') . '</h3>'; $s .= '</span>'; $s .= '<div id="startpage-page-wrapper">'; $s .= '<label id="startpage-page-label" for="startpage-page">' . t('Home page to load after login - leave blank for profile wall') . '</label>'; $s .= '<input id="startpage-page" type="text" name="startpage" value="' . $page . '" />'; $s .= '</div><div class="clear"></div>'; $s .= '<div id="startpage-desc">' . t('Examples: "network" or "notifications/system"') . '</div>'; /* provide a submit button */ $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="startpage-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>'; }
/** @file */ function notes_init(&$a) { if (!local_channel()) { return; } $ret = array('success' => true); if (array_key_exists('note_text', $_REQUEST)) { $body = escape_tags($_REQUEST['note_text']); // I've had my notes vanish into thin air twice in four years. // Provide a backup copy if there were contents previously // and there are none being saved now. if (!$body) { $old_text = get_pconfig(local_channel(), 'notes', 'text'); if ($old_text) { set_pconfig(local_channel(), 'notes', 'text.bak', $old_text); } } set_pconfig(local_channel(), 'notes', 'text', $body); } // push updates to channel clones if (argc() > 1 && argv(1) === 'sync') { require_once 'include/zot.php'; build_sync_packet(); } logger('notes saved.', LOGGER_DEBUG); json_return_and_die($ret); }
function post() { $using_api = false; if (\App::$data['api_info'] && array_key_exists('media', $_FILES)) { $using_api = true; $user_info = \App::$data['api_info']; $nick = $user_info['screen_name']; $channel = get_channel_by_nick($user_info['screen_name']); } elseif (argc() > 1) { $channel = get_channel_by_nick(argv(1)); } if (!$channel) { killme(); } $observer = \App::get_observer(); $def_album = get_pconfig($channel['channel_id'], 'system', 'photo_path'); $def_attach = get_pconfig($channel['channel_id'], 'system', 'attach_path'); $r = attach_store($channel, $observer ? $observer['xchan_hash'] : '', '', array('source' => 'editor', 'visible' => 0, 'album' => $def_album, 'directory' => $def_attach, 'allow_cid' => '<' . $channel['channel_hash'] . '>')); if (!$r['success']) { notice($r['message'] . EOL); killme(); } if (intval($r['data']['is_photo'])) { $s = "\n\n" . $r['body'] . "\n\n"; } else { $s = "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n"; } if ($using_api) { return $s; } echo $s; killme(); }
function init() { $ret = array(); call_hooks('home_init', $ret); $splash = argc() > 1 && argv(1) === 'splash' ? true : false; $channel = \App::get_channel(); if (local_channel() && $channel && $channel['xchan_url'] && !$splash) { $dest = $channel['channel_startpage']; if (!$dest) { $dest = get_pconfig(local_channel(), 'system', 'startpage'); } if (!$dest) { $dest = get_config('system', 'startpage'); } if (!$dest) { $dest = z_root() . '/network'; } goaway($dest); } if (remote_channel() && !$splash && $_SESSION['atoken']) { $r = q("select * from atoken where atoken_id = %d", intval($_SESSION['atoken'])); if ($r) { $x = channelx_by_n($r[0]['atoken_uid']); if ($x) { goaway(z_root() . '/channel/' . $x['channel_address']); } } } if (get_account_id() && !$splash) { goaway(z_root() . '/new_channel'); } }
function feature_enabled($uid, $feature) { //return true; $x = get_pconfig($uid, 'feature', $feature); $arr = array('uid' => $uid, 'feature' => $feature, 'enabled' => $x); call_hooks('feature_enabled', $arr); return $arr['enabled']; }
function post() { $hash = $_POST['hash']; $time = $_POST['time']; $sig = $_POST['signature']; $resource = $_POST['resource']; $revision = intval($_POST['revision']); if (!$hash) { killme(); } $channel = channelx_by_hash($hash); if (!$channel || !$time || !$sig) { killme(); } $slop = intval(get_pconfig($channel['channel_id'], 'system', 'getfile_time_slop')); if ($slop < 1) { $slop = 3; } $d1 = datetime_convert('UTC', 'UTC', "now + {$slop} minutes"); $d2 = datetime_convert('UTC', 'UTC', "now - {$slop} minutes"); if ($time > $d1 || $time < $d2) { logger('time outside allowable range'); killme(); } if (!rsa_verify($hash . '.' . $time, base64url_decode($sig), $channel['channel_pubkey'])) { logger('verify failed.'); killme(); } $r = attach_by_hash($resource, $revision); if (!$r['success']) { notice($r['message'] . EOL); return; } $unsafe_types = array('text/html', 'text/css', 'application/javascript'); if (in_array($r['data']['filetype'], $unsafe_types)) { header('Content-type: text/plain'); } else { header('Content-type: ' . $r['data']['filetype']); } header('Content-disposition: attachment; filename="' . $r['data']['filename'] . '"'); if (intval($r['data']['os_storage'])) { $fname = dbunescbin($r['data']['data']); if (strpos($fname, 'store') !== false) { $istream = fopen($fname, 'rb'); } else { $istream = fopen('store/' . $channel['channel_address'] . '/' . $fname, 'rb'); } $ostream = fopen('php://output', 'wb'); if ($istream && $ostream) { pipe_streams($istream, $ostream); fclose($istream); fclose($ostream); } } else { echo dbunescbin($r['data']['data']); } killme(); }
/** * Theme settings */ function theme_content(&$a) { if (!local_user()) { return; } $align = get_pconfig(local_user(), 'quattro', 'align'); $color = get_pconfig(local_user(), 'quattro', 'color'); return quattro_form($a, $align, $color); }
function gnot_enotify_mail(&$a, &$b) { if (!$b['uid'] || !intval(get_pconfig($b['uid'], 'gnot', 'enable'))) { return; } if ($b['type'] == NOTIFY_COMMENT) { $b['subject'] = sprintf(t('[Friendica:Notify] Comment to conversation #%d'), $b['parent']); } }
/** * @static * @param int $uid * @return wdcal_local */ static function getInstanceByUser($uid = 0) { $dateformat = get_pconfig($uid, "dav", "dateformat"); $format = self::getInstance($dateformat); if ($format == null) { $format = self::getInstance(self::LOCAL_US); } return $format; }
/** * Builds a modal dialog for editing permissions, using acl_selector.tpl as the template. * * @param array $default Optional access control list for the initial state of the dialog. * @param boolean $show_jotnets Whether plugins for federated networks should be included in the permissions dialog * @param PermissionDescription $emptyACL_description - An optional description for the permission implied by selecting an empty ACL. Preferably an instance of PermissionDescription. * @param string $dialog_description Optional message to include at the top of the dialog. E.g. "Warning: Post permissions cannot be changed once sent". * @param string $context_help Allows the dialog to present a help icon. E.g. "acl_dialog_post" * @param boolean $readonly Not implemented yet. When implemented, the dialog will use acl_readonly.tpl instead, so that permissions may be viewed for posts that can no longer have their permissions changed. * * @return string html modal dialog built from acl_selector.tpl */ function populate_acl($defaults = null, $show_jotnets = true, $emptyACL_description = '', $dialog_description = '', $context_help = '', $readonly = false) { $allow_cid = $allow_gid = $deny_cid = $deny_gid = false; $showall_origin = ''; $showall_icon = 'fa-globe'; $role = get_pconfig(local_channel(), 'system', 'permissions_role'); if (!$emptyACL_description) { $showall_caption = t('Visible to your default audience'); } else { if (is_a($emptyACL_description, '\\Zotlabs\\Lib\\PermissionDescription')) { $showall_caption = $emptyACL_description->get_permission_description(); $showall_origin = $role === 'custom' ? $emptyACL_description->get_permission_origin_description() : ''; $showall_icon = $emptyACL_description->get_permission_icon(); } else { // For backwards compatibility we still accept a string... for now! $showall_caption = $emptyACL_description; } } if (is_array($defaults)) { $allow_cid = strlen($defaults['allow_cid']) ? explode('><', $defaults['allow_cid']) : array(); $allow_gid = strlen($defaults['allow_gid']) ? explode('><', $defaults['allow_gid']) : array(); $deny_cid = strlen($defaults['deny_cid']) ? explode('><', $defaults['deny_cid']) : array(); $deny_gid = strlen($defaults['deny_gid']) ? explode('><', $defaults['deny_gid']) : array(); array_walk($allow_cid, 'fixacl'); array_walk($allow_gid, 'fixacl'); array_walk($deny_cid, 'fixacl'); array_walk($deny_gid, 'fixacl'); } $channel = local_channel() ? \App::get_channel() : ''; $has_acl = false; $single_group = false; $just_me = false; $custom = false; if ($allow_cid || $allow_gid || $deny_gid || $deny_cid) { $has_acl = true; $custom = true; } if (count($allow_gid) === 1 && !$allow_cid && !$deny_gid && !$deny_cid) { $single_group = true; $custom = false; } if (count($allow_cid) === 1 && $channel && ($allow_cid[0] = $channel['channel_hash'] && !$allow_gid && !$deny_gid && !$deny_cid)) { $just_me = true; $custom = false; } $r = q("SELECT id, hash, gname FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", intval(local_channel())); if ($r) { foreach ($r as $rr) { $selected = $single_group && $rr['hash'] === $allow_gid[0] ? ' selected = "selected" ' : ''; $groups .= '<option id="' . $rr['id'] . '" value="' . $rr['hash'] . '"' . $selected . '>' . $rr['gname'] . '</option>' . "\r\n"; } } $tpl = get_markup_template("acl_selector.tpl"); $o = replace_macros($tpl, array('$showall' => $showall_caption, '$onlyme' => t('Only me'), '$groups' => $groups, '$public_selected' => $has_acl ? false : true, '$justme_selected' => $just_me, '$custom_selected' => $custom, '$showallOrigin' => $showall_origin, '$showallIcon' => $showall_icon, '$select_label' => t('Who can see this?'), '$custom' => t('Custom selection'), '$showlimitedDesc' => t('Select "Show" to allow viewing. "Don\'t show" lets you override and limit the scope of "Show".'), '$show' => t("Show"), '$hide' => t("Don't show"), '$search' => t("Search"), '$allowcid' => json_encode($allow_cid), '$allowgid' => json_encode($allow_gid), '$denycid' => json_encode($deny_cid), '$denygid' => json_encode($deny_gid), '$aclModalTitle' => t('Permissions'), '$aclModalDesc' => $dialog_description, '$aclModalDismiss' => t('Close'), '$helpUrl' => $context_help == '' ? '' : z_root() . '/help/' . $context_help)); return $o; }
/** * Theme settings */ function theme_content(&$a) { if (!local_user()) { return; } $font_size = get_pconfig(local_user(), 'dispy', 'font_size'); $line_height = get_pconfig(local_user(), 'dispy', 'line_height'); $colour = get_pconfig(local_user(), 'dispy', 'colour'); return dispy_form($a, $font_size, $line_height, $colour); }
function feature_enabled($uid, $feature) { $x = get_pconfig($uid, 'feature', $feature); if ($x === false) { $x = get_config('feature', $feature); } $arr = array('uid' => $uid, 'feature' => $feature, 'enabled' => $x); call_hooks('feature_enabled', $arr); return $arr['enabled']; }
public function __construct($mode, $preview, $prepared_item = '') { $this->set_mode($mode); $this->preview = $preview; $this->prepared_item = $prepared_item; $c = local_channel() ? get_pconfig(local_channel(), 'system', 'default_cipher') : ''; if ($c) { $this->cipher = $c; } }
function skeleton_settings(&$a, &$s) { $id = local_channel(); if (!$id) { return; } $some_setting = get_pconfig($id, 'skeleton', 'some_setting'); $sc = replace_macros(get_markup_template('field_input.tpl'), array('$field' => array('some_setting', t('Some setting'), $some_setting, t('A setting')))); $s .= replace_macros(get_markup_template('generic_addon_settings.tpl'), array('$addon' => array('skeleton', t('Skeleton Settings'), '', t('Submit')), '$content' => $sc)); }
function ostatus_subscribe_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED } $o = "<h2>" . t("Subsribing to OStatus contacts") . "</h2>"; $uid = local_user(); $a = get_app(); $counter = intval($_REQUEST['counter']); if (get_pconfig($uid, "ostatus", "legacy_friends") == "") { if ($_REQUEST["url"] == "") { return $o . t("No contact provided."); } $contact = probe_url($_REQUEST["url"]); if (!$contact) { return $o . t("Couldn't fetch information for contact."); } $api = $contact["baseurl"] . "/api/"; // Fetching friends $data = z_fetch_url($api . "statuses/friends.json?screen_name=" . $contact["nick"]); if (!$data["success"]) { return $o . t("Couldn't fetch friends for contact."); } set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]); } $friends = json_decode(get_pconfig($uid, "ostatus", "legacy_friends")); $total = sizeof($friends); if ($counter >= $total) { $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . $a->get_baseurl() . '/settings/connectors">'; del_pconfig($uid, "ostatus", "legacy_friends"); del_pconfig($uid, "ostatus", "legacy_contact"); $o .= t("Done"); return $o; } $friend = $friends[$counter++]; $url = $friend->statusnet_profile_url; $o .= "<p>" . $counter . "/" . $total . ": " . $url; $data = probe_url($url); if ($data["network"] == NETWORK_OSTATUS) { $result = new_contact($uid, $url, true); if ($result["success"]) { $o .= " - " . t("success"); } else { $o .= " - " . t("failed"); } } else { $o .= " - " . t("ignored"); } $o .= "</p>"; $o .= "<p>" . t("Keep this window open until done.") . "</p>"; $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . $a->get_baseurl() . '/ostatus_subscribe?counter=' . $counter . '">'; return $o; }