function get() { if (!local_channel()) { return login(); } $content = '<h3>' . t('Configuration Editor') . '</h3>'; $content .= '<div class="descriptive-paragraph">' . t('Warning: Changing some settings could render your channel inoperable. Please leave this page unless you are comfortable with and knowledgeable about how to correctly use this feature.') . '</div>' . EOL . EOL; if (argc() == 3) { $content .= '<a href="pconfig">pconfig[' . local_channel() . ']</a>' . EOL; $content .= '<a href="pconfig/' . escape_tags(argv(1)) . '">pconfig[' . local_channel() . '][' . escape_tags(argv(1)) . ']</a>' . EOL . EOL; $content .= '<a href="pconfig/' . escape_tags(argv(1)) . '/' . escape_tags(argv(2)) . '" >pconfig[' . local_channel() . '][' . escape_tags(argv(1)) . '][' . escape_tags(argv(2)) . ']</a> = ' . get_pconfig(local_channel(), escape_tags(argv(1)), escape_tags(argv(2))) . EOL; if (in_array(argv(2), $this->disallowed_pconfig())) { notice(t('This setting requires special processing and editing has been blocked.') . EOL); return $content; } else { $content .= $this->pconfig_form(escape_tags(argv(1)), escape_tags(argv(2))); } } if (argc() == 2) { $content .= '<a href="pconfig">pconfig[' . local_channel() . ']</a>' . EOL; load_pconfig(local_channel(), escape_tags(argv(1))); foreach (\App::$config[local_channel()][escape_tags(argv(1))] as $k => $x) { $content .= '<a href="pconfig/' . escape_tags(argv(1)) . '/' . $k . '" >pconfig[' . local_channel() . '][' . escape_tags(argv(1)) . '][' . $k . ']</a> = ' . escape_tags($x) . EOL; } } if (argc() == 1) { $r = q("select * from pconfig where uid = " . local_channel()); if ($r) { foreach ($r as $rr) { $content .= '<a href="' . 'pconfig/' . escape_tags($rr['cat']) . '/' . escape_tags($rr['k']) . '" >pconfig[' . local_channel() . '][' . escape_tags($rr['cat']) . '][' . escape_tags($rr['k']) . ']</a> = ' . escape_tags($rr['v']) . EOL; } } } return $content; }
function import_config($channel, $configs) { if ($channel && $configs) { foreach ($configs as $config) { unset($config['id']); $config['uid'] = $channel['channel_id']; dbesc_array($config); $r = dbq("INSERT INTO pconfig (`" . implode("`, `", array_keys($config)) . "`) VALUES ('" . implode("', '", array_values($config)) . "')"); } load_pconfig($channel['channel_id']); } }
function get() { require_once 'include/acl_selectors.php'; require_once 'include/permissions.php'; $yes_no = array(t('No'), t('Yes')); $p = q("SELECT * FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", intval(local_channel())); if (count($p)) { $profile = $p[0]; } load_pconfig(local_channel(), 'expire'); $channel = \App::get_channel(); $global_perms = \Zotlabs\Access\Permissions::Perms(); $permiss = array(); $perm_opts = array(array(t('Nobody except yourself'), 0), array(t('Only those you specifically allow'), PERMS_SPECIFIC), array(t('Approved connections'), PERMS_CONTACTS), array(t('Any connections'), PERMS_PENDING), array(t('Anybody on this website'), PERMS_SITE), array(t('Anybody in this network'), PERMS_NETWORK), array(t('Anybody authenticated'), PERMS_AUTHED), array(t('Anybody on the internet'), PERMS_PUBLIC)); $limits = \Zotlabs\Access\PermissionLimits::Get(local_channel()); foreach ($global_perms as $k => $perm) { $options = array(); foreach ($perm_opts as $opt) { if (!strstr($k, 'view') && $opt[1] == PERMS_PUBLIC) { continue; } $options[$opt[1]] = $opt[0]; } $permiss[] = array($k, $perm, $limits[$k], '', $options); } $username = $channel['channel_name']; $nickname = $channel['channel_address']; $timezone = $channel['channel_timezone']; $notify = $channel['channel_notifyflags']; $defloc = $channel['channel_location']; $maxreq = $channel['channel_max_friend_req']; $expire = $channel['channel_expire_days']; $adult_flag = intval($channel['channel_pageflags'] & PAGE_ADULT); $sys_expire = get_config('system', 'default_expire_days'); // $unkmail = \App::$user['unkmail']; // $cntunkmail = \App::$user['cntunkmail']; $hide_presence = intval(get_pconfig(local_channel(), 'system', 'hide_online_status')); $expire_items = get_pconfig(local_channel(), 'expire', 'items'); $expire_items = $expire_items === false ? '1' : $expire_items; // default if not set: 1 $expire_notes = get_pconfig(local_channel(), 'expire', 'notes'); $expire_notes = $expire_notes === false ? '1' : $expire_notes; // default if not set: 1 $expire_starred = get_pconfig(local_channel(), 'expire', 'starred'); $expire_starred = $expire_starred === false ? '1' : $expire_starred; // default if not set: 1 $expire_photos = get_pconfig(local_channel(), 'expire', 'photos'); $expire_photos = $expire_photos === false ? '0' : $expire_photos; // default if not set: 0 $expire_network_only = get_pconfig(local_channel(), 'expire', 'network_only'); $expire_network_only = $expire_network_only === false ? '0' : $expire_network_only; // default if not set: 0 $suggestme = get_pconfig(local_channel(), 'system', 'suggestme'); $suggestme = $suggestme === false ? '0' : $suggestme; // default if not set: 0 $post_newfriend = get_pconfig(local_channel(), 'system', 'post_newfriend'); $post_newfriend = $post_newfriend === false ? '0' : $post_newfriend; // default if not set: 0 $post_joingroup = get_pconfig(local_channel(), 'system', 'post_joingroup'); $post_joingroup = $post_joingroup === false ? '0' : $post_joingroup; // default if not set: 0 $post_profilechange = get_pconfig(local_channel(), 'system', 'post_profilechange'); $post_profilechange = $post_profilechange === false ? '0' : $post_profilechange; // default if not set: 0 $blocktags = get_pconfig(local_channel(), 'system', 'blocktags'); $blocktags = $blocktags === false ? '0' : $blocktags; $timezone = date_default_timezone_get(); $opt_tpl = get_markup_template("field_checkbox.tpl"); if (get_config('system', 'publish_all')) { $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />'; } else { $profile_in_dir = replace_macros($opt_tpl, array('$field' => array('profile_in_directory', t('Publish your default profile in the network directory'), $profile['publish'], '', $yes_no))); } $suggestme = replace_macros($opt_tpl, array('$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', $yes_no))); $subdir = strlen(\App::get_path()) ? '<br />' . t('or') . ' ' . z_root() . '/channel/' . $nickname : ''; $tpl_addr = get_markup_template("settings_nick_set.tpl"); $prof_addr = replace_macros($tpl_addr, array('$desc' => t('Your channel address is'), '$nickname' => $nickname, '$subdir' => $subdir, '$basepath' => \App::get_hostname())); $stpl = get_markup_template('settings.tpl'); $acl = new \Zotlabs\Access\AccessList($channel); $perm_defaults = $acl->get(); require_once 'include/group.php'; $group_select = mini_group_select(local_channel(), $channel['channel_default_group']); require_once 'include/menu.php'; $m1 = menu_list(local_channel()); $menu = false; if ($m1) { $menu = array(); $current = get_pconfig(local_channel(), 'system', 'channel_menu'); $menu[] = array('name' => '', 'selected' => !$current ? true : false); foreach ($m1 as $m) { $menu[] = array('name' => htmlspecialchars($m['menu_name'], ENT_COMPAT, 'UTF-8'), 'selected' => $m['menu_name'] === $current ? ' selected="selected" ' : false); } } $evdays = get_pconfig(local_channel(), 'system', 'evdays'); if (!$evdays) { $evdays = 3; } $permissions_role = get_pconfig(local_channel(), 'system', 'permissions_role'); if (!$permissions_role) { $permissions_role = 'custom'; } $permissions_set = $permissions_role != 'custom' ? true : false; $perm_roles = \Zotlabs\Access\PermissionRoles::roles(); if (get_account_techlevel() < 4 && $permissions_role !== 'custom') { unset($perm_roles[t('Other')]); } $vnotify = get_pconfig(local_channel(), 'system', 'vnotify'); $always_show_in_notices = get_pconfig(local_channel(), 'system', 'always_show_in_notices'); if ($vnotify === false) { $vnotify = -1; } $o .= replace_macros($stpl, array('$ptitle' => t('Channel Settings'), '$submit' => t('Submit'), '$baseurl' => z_root(), '$uid' => local_channel(), '$form_security_token' => get_form_security_token("settings"), '$nickname_block' => $prof_addr, '$h_basic' => t('Basic Settings'), '$username' => array('username', t('Full Name:'), $username, ''), '$email' => array('email', t('Email Address:'), $email, ''), '$timezone' => array('timezone_select', t('Your Timezone:'), $timezone, '', get_timezones()), '$defloc' => array('defloc', t('Default Post Location:'), $defloc, t('Geographical location to display on your posts')), '$allowloc' => array('allow_location', t('Use Browser Location:'), get_pconfig(local_channel(), 'system', 'use_browser_location') ? 1 : '', '', $yes_no), '$adult' => array('adult', t('Adult Content'), $adult_flag, t('This channel frequently or regularly publishes adult content. (Please tag any adult material and/or nudity with #NSFW)'), $yes_no), '$h_prv' => t('Security and Privacy Settings'), '$permissions_set' => $permissions_set, '$server_role' => \Zotlabs\Lib\System::get_server_role(), '$perms_set_msg' => t('Your permissions are already configured. Click to view/adjust'), '$hide_presence' => array('hide_presence', t('Hide my online presence'), $hide_presence, t('Prevents displaying in your profile that you are online'), $yes_no), '$lbl_pmacro' => t('Simple Privacy Settings:'), '$pmacro3' => t('Very Public - <em>extremely permissive (should be used with caution)</em>'), '$pmacro2' => t('Typical - <em>default public, privacy when desired (similar to social network permissions but with improved privacy)</em>'), '$pmacro1' => t('Private - <em>default private, never open or public</em>'), '$pmacro0' => t('Blocked - <em>default blocked to/from everybody</em>'), '$permiss_arr' => $permiss, '$blocktags' => array('blocktags', t('Allow others to tag your posts'), 1 - $blocktags, t('Often used by the community to retro-actively flag inappropriate content'), $yes_no), '$lbl_p2macro' => t('Channel Permission Limits'), '$expire' => array('expire', t('Expire other channel content after this many days'), $expire, t('0 or blank to use the website limit.') . ' ' . (intval($sys_expire) ? sprintf(t('This website expires after %d days.'), intval($sys_expire)) : t('This website does not expire imported content.')) . ' ' . t('The website limit takes precedence if lower than your limit.')), '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), intval($channel['channel_max_friend_req']), t('May reduce spam activity')), '$permissions' => t('Default Access Control List (ACL)'), '$permdesc' => t("(click to open/close)"), '$aclselect' => populate_acl($perm_defaults, false, \Zotlabs\Lib\PermissionDescription::fromDescription(t('Use my default audience setting for the type of object published'))), '$allow_cid' => acl2json($perm_defaults['allow_cid']), '$allow_gid' => acl2json($perm_defaults['allow_gid']), '$deny_cid' => acl2json($perm_defaults['deny_cid']), '$deny_gid' => acl2json($perm_defaults['deny_gid']), '$suggestme' => $suggestme, '$group_select' => $group_select, '$role' => array('permissions_role', t('Channel permissions category:'), $permissions_role, '', $perm_roles), '$profile_in_dir' => $profile_in_dir, '$hide_friends' => $hide_friends, '$hide_wall' => $hide_wall, '$unkmail' => $unkmail, '$cntunkmail' => array('cntunkmail', t('Maximum private messages per day from unknown people:'), intval($channel['channel_max_anon_mail']), t("Useful to reduce spamming")), '$h_not' => t('Notification Settings'), '$activity_options' => t('By default post a status message when:'), '$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, '', $yes_no), '$post_joingroup' => array('post_joingroup', t('joining a forum/community'), $post_joingroup, '', $yes_no), '$post_profilechange' => array('post_profilechange', t('making an <em>interesting</em> profile change'), $post_profilechange, '', $yes_no), '$lbl_not' => t('Send a notification email when:'), '$notify1' => array('notify1', t('You receive a connection request'), $notify & NOTIFY_INTRO, NOTIFY_INTRO, '', $yes_no), '$notify2' => array('notify2', t('Your connections are confirmed'), $notify & NOTIFY_CONFIRM, NOTIFY_CONFIRM, '', $yes_no), '$notify3' => array('notify3', t('Someone writes on your profile wall'), $notify & NOTIFY_WALL, NOTIFY_WALL, '', $yes_no), '$notify4' => array('notify4', t('Someone writes a followup comment'), $notify & NOTIFY_COMMENT, NOTIFY_COMMENT, '', $yes_no), '$notify5' => array('notify5', t('You receive a private message'), $notify & NOTIFY_MAIL, NOTIFY_MAIL, '', $yes_no), '$notify6' => array('notify6', t('You receive a friend suggestion'), $notify & NOTIFY_SUGGEST, NOTIFY_SUGGEST, '', $yes_no), '$notify7' => array('notify7', t('You are tagged in a post'), $notify & NOTIFY_TAGSELF, NOTIFY_TAGSELF, '', $yes_no), '$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), $notify & NOTIFY_POKE, NOTIFY_POKE, '', $yes_no), '$lbl_vnot' => t('Show visual notifications including:'), '$vnotify1' => array('vnotify1', t('Unseen grid activity'), $vnotify & VNOTIFY_NETWORK, VNOTIFY_NETWORK, '', $yes_no), '$vnotify2' => array('vnotify2', t('Unseen channel activity'), $vnotify & VNOTIFY_CHANNEL, VNOTIFY_CHANNEL, '', $yes_no), '$vnotify3' => array('vnotify3', t('Unseen private messages'), $vnotify & VNOTIFY_MAIL, VNOTIFY_MAIL, t('Recommended'), $yes_no), '$vnotify4' => array('vnotify4', t('Upcoming events'), $vnotify & VNOTIFY_EVENT, VNOTIFY_EVENT, '', $yes_no), '$vnotify5' => array('vnotify5', t('Events today'), $vnotify & VNOTIFY_EVENTTODAY, VNOTIFY_EVENTTODAY, '', $yes_no), '$vnotify6' => array('vnotify6', t('Upcoming birthdays'), $vnotify & VNOTIFY_BIRTHDAY, VNOTIFY_BIRTHDAY, t('Not available in all themes'), $yes_no), '$vnotify7' => array('vnotify7', t('System (personal) notifications'), $vnotify & VNOTIFY_SYSTEM, VNOTIFY_SYSTEM, '', $yes_no), '$vnotify8' => array('vnotify8', t('System info messages'), $vnotify & VNOTIFY_INFO, VNOTIFY_INFO, t('Recommended'), $yes_no), '$vnotify9' => array('vnotify9', t('System critical alerts'), $vnotify & VNOTIFY_ALERT, VNOTIFY_ALERT, t('Recommended'), $yes_no), '$vnotify10' => array('vnotify10', t('New connections'), $vnotify & VNOTIFY_INTRO, VNOTIFY_INTRO, t('Recommended'), $yes_no), '$vnotify11' => array('vnotify11', t('System Registrations'), $vnotify & VNOTIFY_REGISTER, VNOTIFY_REGISTER, '', $yes_no), '$always_show_in_notices' => array('always_show_in_notices', t('Also show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), '$evdays' => array('evdays', t('Notify me of events this many days in advance'), $evdays, t('Must be greater than 0')), '$h_advn' => t('Advanced Account/Page Type Settings'), '$h_descadvn' => t('Change the behaviour of this account for special situations'), '$pagetype' => $pagetype, '$lbl_misc' => t('Miscellaneous Settings'), '$photo_path' => array('photo_path', t('Default photo upload folder'), get_pconfig(local_channel(), 'system', 'photo_path'), t('%Y - current year, %m - current month')), '$attach_path' => array('attach_path', t('Default file upload folder'), get_pconfig(local_channel(), 'system', 'attach_path'), t('%Y - current year, %m - current month')), '$menus' => $menu, '$menu_desc' => t('Personal menu to display in your channel pages'), '$removeme' => t('Remove Channel'), '$removechannel' => t('Remove this channel.'), '$firefoxshare' => t('Firefox Share $Projectname provider'), '$cal_first_day' => array('first_day', t('Start calendar week on monday'), get_pconfig(local_channel(), 'system', 'cal_first_day') ? 1 : '', '', $yes_no))); call_hooks('settings_form', $o); //$o .= '</form>' . "\r\n"; return $o; }
/** * @brief "Render" a conversation or list of items for HTML display. * * There are two major forms of display: * - Sequential or unthreaded ("New Item View" or search results) * - conversation view * * The $mode parameter decides between the various renderings and also * figures out how to determine page owner and other contextual items * that are based on unique features of the calling module. * * @param App &$a * @param array $items * @param string $mode * @param boolean $update * @param string $page_mode default traditional * @param string $prepared_item * @return string */ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $prepared_item = '') { $content_html = ''; $o = ''; require_once 'bbcode.php'; $ssl_state = local_channel() ? true : false; if (local_channel()) { load_pconfig(local_channel(), ''); } $arr_blocked = null; if (local_channel()) { $str_blocked = get_pconfig(local_channel(), 'system', 'blocked'); } if (!local_channel() && $mode == 'network') { $sys = get_sys_channel(); $id = $sys['channel_id']; $str_blocked = get_pconfig($id, 'system', 'blocked'); } if ($str_blocked) { $arr_blocked = explode(',', $str_blocked); for ($x = 0; $x < count($arr_blocked); $x++) { $arr_blocked[$x] = trim($arr_blocked[$x]); } } $profile_owner = 0; $page_writeable = false; $live_update_div = ''; $preview = $page_mode === 'preview' ? true : false; $previewing = $preview ? ' preview ' : ''; if ($mode === 'network') { $profile_owner = local_channel(); $page_writeable = true; if (!$update) { // The special div is needed for liveUpdate to kick in for this page. // We only launch liveUpdate if you aren't filtering in some incompatible // way and also you aren't writing a comment (discovered in javascript). $live_update_div = '<div id="live-network"></div>' . "\r\n" . "<script> var profile_uid = " . $_SESSION['uid'] . "; var netargs = '" . substr($a->cmd, 8) . '?f=' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : '') . (x($_GET, 'search') ? '&search=' . $_GET['search'] : '') . (x($_GET, 'star') ? '&star=' . $_GET['star'] : '') . (x($_GET, 'order') ? '&order=' . $_GET['order'] : '') . (x($_GET, 'bmark') ? '&bmark=' . $_GET['bmark'] : '') . (x($_GET, 'liked') ? '&liked=' . $_GET['liked'] : '') . (x($_GET, 'conv') ? '&conv=' . $_GET['conv'] : '') . (x($_GET, 'spam') ? '&spam=' . $_GET['spam'] : '') . (x($_GET, 'nets') ? '&nets=' . $_GET['nets'] : '') . (x($_GET, 'cmin') ? '&cmin=' . $_GET['cmin'] : '') . (x($_GET, 'cmax') ? '&cmax=' . $_GET['cmax'] : '') . (x($_GET, 'file') ? '&file=' . $_GET['file'] : '') . (x($_GET, 'uri') ? '&uri=' . $_GET['uri'] : '') . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n"; } } elseif ($mode === 'channel') { $profile_owner = $a->profile['profile_uid']; $page_writeable = $profile_owner == local_channel(); if (!$update) { $tab = notags(trim($_GET['tab'])); if ($tab === 'posts') { // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, // because browser prefetching might change it on us. We have to deliver it with the page. $live_update_div = '<div id="live-channel"></div>' . "\r\n" . "<script> var profile_uid = " . $a->profile['profile_uid'] . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n"; } } } elseif ($mode === 'display') { $profile_owner = local_channel(); $page_writeable = false; $live_update_div = '<div id="live-display"></div>' . "\r\n"; } elseif ($mode === 'page') { $profile_owner = $a->profile['uid']; $page_writeable = $profile_owner == local_channel(); $live_update_div = '<div id="live-page"></div>' . "\r\n"; } elseif ($mode === 'search') { $live_update_div = '<div id="live-search"></div>' . "\r\n"; } elseif ($mode === 'photos') { $profile_onwer = $a->profile['profile_uid']; $page_writeable = $profile_owner == local_channel(); $live_update_div = '<div id="live-photos"></div>' . "\r\n"; // for photos we've already formatted the top-level item (the photo) $content_html = $a->data['photo_html']; } $page_dropping = local_channel() && local_channel() == $profile_owner ? true : false; if (!feature_enabled($profile_owner, 'multi_delete')) { $page_dropping = false; } $channel = $a->get_channel(); $observer = $a->get_observer(); if ($update) { $return_url = $_SESSION['return_url']; } else { $return_url = $_SESSION['return_url'] = $a->query_string; } load_contact_links(local_channel()); $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview); call_hooks('conversation_start', $cb); $items = $cb['items']; $conv_responses = array('like' => array('title' => t('Likes', 'title')), 'dislike' => array('title' => t('Dislikes', 'title')), 'agree' => array('title' => t('Agree', 'title')), 'disagree' => array('title' => t('Disagree', 'title')), 'abstain' => array('title' => t('Abstain', 'title')), 'attendyes' => array('title' => t('Attending', 'title')), 'attendno' => array('title' => t('Not attending', 'title')), 'attendmaybe' => array('title' => t('Might attend', 'title'))); // array with html for each thread (parent+comments) $threads = array(); $threadsid = -1; $page_template = get_markup_template("conversation.tpl"); if ($items) { if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') { // "New Item View" on network page or search page results // - just loop through the items and format them minimally for display //$tpl = get_markup_template('search_item.tpl'); $tpl = 'search_item.tpl'; foreach ($items as $item) { if ($arr_blocked) { $blocked = false; foreach ($arr_blocked as $b) { if ($b && $item['author_xchan'] == $b) { $blocked = true; break; } } if ($blocked) { continue; } } $threadsid++; $comment = ''; $owner_url = ''; $owner_photo = ''; $owner_name = ''; $sparkle = ''; if ($mode === 'search' || $mode === 'community') { if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) { continue; } $nickname = $item['nickname']; } else { $nickname = $a->user['nickname']; } $profile_name = strlen($item['author-name']) ? $item['author-name'] : $item['name']; if ($item['author-link'] && !$item['author-name']) { $profile_name = $item['author-link']; } $tags = array(); $hashtags = array(); $mentions = array(); $sp = false; $profile_link = best_link_url($item, $sp); if ($sp) { $sparkle = ' sparkle'; } else { $profile_link = zid($profile_link); } $normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']); $profile_name = $item['author']['xchan_name']; $profile_link = $item['author']['xchan_url']; $profile_avatar = $item['author']['xchan_photo_m']; $location = format_location($item); localize_item($item); if ($mode === 'network-new') { $dropping = true; } else { $dropping = false; } $drop = array('pagedropping' => $page_dropping, 'dropping' => $dropping, 'select' => t('Select'), 'delete' => t('Delete')); $star = false; $isstarred = "unstarred icon-star-empty"; $lock = $item['item_private'] || strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid']) ? t('Private Message') : false; $likebuttons = false; $shareable = false; $verified = $item['item_flags'] & ITEM_VERIFIED ? t('Message signature validated') : ''; $forged = $item['sig'] && !($item['item_flags'] & ITEM_VERIFIED) ? t('Message signature incorrect') : ''; $unverified = ''; $tags = array(); $terms = get_terms_oftype($item['term'], array(TERM_HASHTAG, TERM_MENTION, TERM_UNKNOWN)); if (count($terms)) { foreach ($terms as $tag) { $tags[] = format_term_for_display($tag); } } $body = prepare_body($item, true); $tmp_item = array('template' => $tpl, 'toplevel' => 'toplevel_item', 'mode' => $mode, 'id' => $preview ? 'P0' : $item['item_id'], 'linktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, $profile_url), 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => $profile_name, 'sparkle' => $sparkle, 'lock' => $lock, 'thumb' => $profile_avatar, 'title' => $item['title'], 'body' => $body, 'tags' => $tags, 'hashtags' => $hashtags, 'mentions' => $mentions, 'verified' => $verified, 'unverified' => $unverified, 'forged' => $forged, 'txt_cats' => t('Categories:'), 'txt_folders' => t('Filed under:'), 'has_cats' => count($categories) ? 'true' : '', 'has_folders' => count($folders) ? 'true' : '', 'categories' => $categories, 'folders' => $folders, 'text' => strip_tags($body), 'ago' => relative_date($item['created']), 'app' => $item['app'], 'str_app' => sprintf(t(' from %s'), $item['app']), 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), 'editedtime' => $item['edited'] != $item['created'] ? sprintf(t('last edited: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r')) : '', 'expiretime' => $item['expires'] !== NULL_DATE ? sprintf(t('Expires: %s'), datetime_convert('UTC', date_default_timezone_get(), $item['expires'], 'r')) : '', 'location' => $location, 'indent' => '', 'owner_name' => $owner_name, 'owner_url' => $owner_url, 'owner_photo' => $owner_photo, 'plink' => get_plink($item, false), 'edpost' => false, 'isstarred' => $isstarred, 'star' => $star, 'drop' => $drop, 'vote' => $likebuttons, 'like' => '', 'dislike' => '', 'comment' => '', 'conv' => $preview ? '' : array('href' => z_root() . '/display/' . $item['mid'], 'title' => t('View in context')), 'previewing' => $previewing, 'wait' => t('Please wait'), 'thread_level' => 1); $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); // $threads[$threadsid]['id'] = $item['item_id']; $threads[] = $arr['output']; } } else { // Normal View // logger('conv: items: ' . print_r($items,true)); require_once 'include/ConversationObject.php'; require_once 'include/ItemObject.php'; $conv = new Conversation($mode, $preview, $prepared_item); // In the display mode we don't have a profile owner. if ($mode === 'display' && $items) { $conv->set_profile_owner($items[0]['uid']); } // get all the topmost parents // this shouldn't be needed, as we should have only them in our array // But for now, this array respects the old style, just in case $threads = array(); foreach ($items as $item) { // Check for any blocked authors if ($arr_blocked) { $blocked = false; foreach ($arr_blocked as $b) { if ($b && $item['author_xchan'] == $b) { $blocked = true; break; } } if ($blocked) { continue; } } // Check all the kids too if ($arr_blocked && $item['children']) { for ($d = 0; $d < count($item['children']); $d++) { foreach ($arr_blocked as $b) { if ($b && $item['children'][$d]['author_xchan'] == $b) { $item['children'][$d]['author_blocked'] = true; } } } } builtin_activity_puller($item, $conv_responses); if (!visible_activity($item)) { continue; } $item['pagedrop'] = $page_dropping; if ($item['id'] == $item['parent']) { $item_object = new Item($item); $conv->add_thread($item_object); if ($page_mode === 'list') { $item_object->set_template('conv_list.tpl'); $item_object->set_display_mode('list'); } } } $threads = $conv->get_template_data($conv_responses); if (!$threads) { logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG); $threads = array(); } } } if ($page_mode === 'traditional' || $page_mode === 'preview') { $page_template = get_markup_template("threaded_conversation.tpl"); } elseif ($update) { $page_template = get_markup_template("convobj.tpl"); } else { $page_template = get_markup_template("conv_frame.tpl"); $threads = null; } // if($page_mode === 'preview') // logger('preview: ' . print_r($threads,true)); // Do not un-comment if smarty3 is in use // logger('page_template: ' . $page_template); // logger('nouveau: ' . print_r($threads,true)); $o .= replace_macros($page_template, array('$baseurl' => $a->get_baseurl($ssl_state), '$photo_item' => $content_html, '$live_update' => $live_update_div, '$remove' => t('remove'), '$mode' => $mode, '$user' => $a->user, '$threads' => $threads, '$wait' => t('Loading...'), '$dropping' => $page_dropping ? t('Delete Selected Items') : False)); return $o; }
function rtof_post_hook(&$a, &$b) { /** * Post to Friendica */ // for now, just top level posts. if ($b['mid'] != $b['parent_mid']) { return; } if (!is_item_normal($b) || $b['item_private'] || $b['created'] !== $b['edited']) { return; } if (!perm_is_allowed($b['uid'], '', 'view_stream')) { return; } if (!strstr($b['postopts'], 'rtof')) { return; } logger('Red-to-Friendica post invoked'); load_pconfig($b['uid'], 'rtof'); $api = get_pconfig($b['uid'], 'rtof', 'baseapi'); if (substr($api, -1, 1) != '/') { $api .= '/'; } $username = get_pconfig($b['uid'], 'rtof', 'username'); $password = z_unobscure(get_pconfig($b['uid'], 'rtof', 'password')); $msg = $b['body']; $postdata = array('status' => $b['body'], 'title' => $b['title'], 'message_id' => $b['mid'], 'source' => 'Red Matrix'); if (strlen($b['body'])) { $ret = z_post_url($api . 'statuses/update', $postdata, 0, array('http_auth' => $username . ':' . $password, 'novalidate' => 1)); if ($ret['success']) { logger('rtof: returns: ' . print_r($ret['body'], true)); } else { logger('rtof: z_post_url failed: ' . print_r($ret['debug'], true)); } } }
function settings_content(&$a) { $o = ''; nav_set_selected('settings'); if (!local_channel() || $_SESSION['delegate']) { notice(t('Permission denied.') . EOL); return login(); } $channel = $a->get_channel(); if ($channel) { head_set_icon($channel['xchan_photo_s']); } $yes_no = array(t('No'), t('Yes')); if (argc() > 1 && argv(1) === 'oauth') { if (argc() > 2 && argv(2) === 'add') { $tpl = get_markup_template("settings_oauth_edit.tpl"); $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Submit'), '$cancel' => t('Cancel'), '$name' => array('name', t('Name'), '', t('Name of application')), '$key' => array('key', t('Consumer Key'), random_string(16), t('Automatically generated - change if desired. Max length 20')), '$secret' => array('secret', t('Consumer Secret'), random_string(16), t('Automatically generated - change if desired. Max length 20')), '$redirect' => array('redirect', t('Redirect'), '', t('Redirect URI - leave blank unless your application specifically requires this')), '$icon' => array('icon', t('Icon url'), '', t('Optional')))); return $o; } if (argc() > 3 && argv(2) === 'edit') { $r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d", dbesc(argv(3)), local_channel()); if (!count($r)) { notice(t("You can't edit this application.")); return; } $app = $r[0]; $tpl = get_markup_template("settings_oauth_edit.tpl"); $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$title' => t('Add application'), '$submit' => t('Update'), '$cancel' => t('Cancel'), '$name' => array('name', t('Name'), $app['name'], ''), '$key' => array('key', t('Consumer Key'), $app['client_id'], ''), '$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''), '$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''), '$icon' => array('icon', t('Icon url'), $app['icon'], ''))); return $o; } if (argc() > 3 && argv(2) === 'delete') { check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't'); $r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d", dbesc(argv(3)), local_channel()); goaway($a->get_baseurl(true) . "/settings/oauth/"); return; } $r = q("SELECT clients.*, tokens.id as oauth_token, (clients.uid=%d) AS my \n\t\t\t\tFROM clients\n\t\t\t\tLEFT JOIN tokens ON clients.client_id=tokens.client_id\n\t\t\t\tWHERE clients.uid IN (%d,0)", local_channel(), local_channel()); $tpl = get_markup_template("settings_oauth.tpl"); $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_oauth"), '$baseurl' => $a->get_baseurl(true), '$title' => t('Connected Apps'), '$add' => t('Add application'), '$edit' => t('Edit'), '$delete' => t('Delete'), '$consumerkey' => t('Client key starts with'), '$noname' => t('No name'), '$remove' => t('Remove authorization'), '$apps' => $r)); return $o; } if (argc() > 1 && argv(1) === 'featured') { $settings_addons = ""; $o = ''; $r = q("SELECT * FROM `hook` WHERE `hook` = 'feature_settings' "); if (!$r) { $settings_addons = t('No feature settings configured'); } call_hooks('feature_settings', $settings_addons); $tpl = get_markup_template("settings_addons.tpl"); $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_featured"), '$title' => t('Feature/Addon Settings'), '$settings_addons' => $settings_addons)); return $o; } /* * ACCOUNT SETTINGS */ if (argc() > 1 && argv(1) === 'account') { $account_settings = ""; call_hooks('account_settings', $account_settings); $email = $a->account['account_email']; $tpl = get_markup_template("settings_account.tpl"); $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_account"), '$title' => t('Account Settings'), '$password1' => array('npassword', t('Enter New Password:'******'', ''), '$password2' => array('confirm', t('Confirm New Password:'******'', t('Leave password fields blank unless changing')), '$submit' => t('Submit'), '$email' => array('email', t('Email Address:'), $email, ''), '$removeme' => t('Remove Account'), '$removeaccount' => t('Remove this account including all its channels'), '$account_settings' => $account_settings)); return $o; } if (argc() > 1 && argv(1) === 'features') { $arr = array(); $features = get_features(); foreach ($features as $fname => $fdata) { $arr[$fname] = array(); $arr[$fname][0] = $fdata[0]; foreach (array_slice($fdata, 1) as $f) { $arr[$fname][1][] = array('feature_' . $f[0], $f[1], intval(feature_enabled(local_channel(), $f[0])) ? "1" : '', $f[2], array(t('Off'), t('On'))); } } $tpl = get_markup_template("settings_features.tpl"); $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_features"), '$title' => t('Additional Features'), '$features' => $arr, '$submit' => t('Submit'))); return $o; } if (argc() > 1 && argv(1) === 'connectors') { $settings_connectors = ""; call_hooks('connector_settings', $settings_connectors); $r = null; $tpl = get_markup_template("settings_connectors.tpl"); $o .= replace_macros($tpl, array('$form_security_token' => get_form_security_token("settings_connectors"), '$title' => t('Connector Settings'), '$submit' => t('Submit'), '$settings_connectors' => $settings_connectors)); call_hooks('display_settings', $o); return $o; } /* * DISPLAY SETTINGS */ if (argc() > 1 && argv(1) === 'display') { $default_theme = get_config('system', 'theme'); if (!$default_theme) { $default_theme = 'default'; } $default_mobile_theme = get_config('system', 'mobile_theme'); if (!$mobile_default_theme) { $mobile_default_theme = 'none'; } $allowed_themes_str = get_config('system', 'allowed_themes'); $allowed_themes_raw = explode(',', $allowed_themes_str); $allowed_themes = array(); if (count($allowed_themes_raw)) { foreach ($allowed_themes_raw as $x) { if (strlen(trim($x)) && is_dir("view/theme/{$x}")) { $allowed_themes[] = trim($x); } } } $themes = array(); $files = glob('view/theme/*'); if ($allowed_themes) { foreach ($allowed_themes as $th) { $f = $th; $is_experimental = file_exists('view/theme/' . $th . '/experimental'); $unsupported = file_exists('view/theme/' . $th . '/unsupported'); $is_mobile = file_exists('view/theme/' . $th . '/mobile'); $is_library = file_exists('view/theme/' . $th . '/library'); $mobile_themes["---"] = t("No special theme for mobile devices"); if (!$is_experimental or $is_experimental && (get_config('experimentals', 'exp_themes') == 1 or get_config('experimentals', 'exp_themes') === false)) { $theme_name = $is_experimental ? sprintf(t('%s - (Experimental)'), $f) : $f; if (!$is_library) { if ($is_mobile) { $mobile_themes[$f] = $themes[$f] = $theme_name . ' (' . t('mobile') . ')'; } else { $mobile_themes[$f] = $themes[$f] = $theme_name; } } } } } $theme_selected = !x($_SESSION, 'theme') ? $default_theme : $_SESSION['theme']; $mobile_theme_selected = !x($_SESSION, 'mobile_theme') ? $default_mobile_theme : $_SESSION['mobile_theme']; $user_scalable = get_pconfig(local_channel(), 'system', 'user_scalable'); $user_scalable = $user_scalable === false ? '1' : $user_scalable; // default if not set: 1 $browser_update = intval(get_pconfig(local_channel(), 'system', 'update_interval')); $browser_update = $browser_update == 0 ? 80 : $browser_update / 1000; // default if not set: 40 seconds $itemspage = intval(get_pconfig(local_channel(), 'system', 'itemspage')); $itemspage = $itemspage > 0 && $itemspage < 101 ? $itemspage : 20; // default if not set: 20 items $nosmile = get_pconfig(local_channel(), 'system', 'no_smilies'); $nosmile = $nosmile === false ? '0' : $nosmile; // default if not set: 0 $title_tosource = get_pconfig(local_channel(), 'system', 'title_tosource'); $title_tosource = $title_tosource === false ? '0' : $title_tosource; // default if not set: 0 $theme_config = ""; if (($themeconfigfile = get_theme_config_file($theme_selected)) != null) { require_once $themeconfigfile; $theme_config = theme_content($a); } $tpl = get_markup_template("settings_display.tpl"); $o = replace_macros($tpl, array('$ptitle' => t('Display Settings'), '$d_tset' => t('Theme Settings'), '$d_ctset' => t('Custom Theme Settings'), '$d_cset' => t('Content Settings'), '$form_security_token' => get_form_security_token("settings_display"), '$submit' => t('Submit'), '$baseurl' => $a->get_baseurl(true), '$uid' => local_channel(), '$theme' => $themes ? array('theme', t('Display Theme:'), $theme_selected, '', $themes, 'preview') : false, '$mobile_theme' => $mobile_themes ? array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, '') : false, '$user_scalable' => array('user_scalable', t("Enable user zoom on mobile devices"), $user_scalable, '', $yes_no), '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), '$nosmile' => array('nosmile', t("Show emoticons (smilies) as images"), 1 - intval($nosmile), '', $yes_no), '$title_tosource' => array('title_tosource', t("Link post titles to source"), $title_tosource, '', $yes_no), '$layout_editor' => t('System Page Layout Editor - (advanced)'), '$theme_config' => $theme_config, '$expert' => feature_enabled(local_channel(), 'expert'), '$channel_list_mode' => array('channel_list_mode', t('Use blog/list mode on channel page'), get_pconfig(local_channel(), 'system', 'channel_list_mode'), t('(comments displayed separately)'), $yes_no), '$network_list_mode' => array('network_list_mode', t('Use blog/list mode on grid page'), get_pconfig(local_channel(), 'system', 'network_list_mode'), t('(comments displayed separately)'), $yes_no), '$channel_divmore_height' => array('channel_divmore_height', t('Channel page max height of content (in pixels)'), get_pconfig(local_channel(), 'system', 'channel_divmore_height') ? get_pconfig(local_channel(), 'system', 'channel_divmore_height') : 400, t('click to expand content exceeding this height')), '$network_divmore_height' => array('network_divmore_height', t('Grid page max height of content (in pixels)'), get_pconfig(local_channel(), 'system', 'network_divmore_height') ? get_pconfig(local_channel(), 'system', 'network_divmore_height') : 400, t('click to expand content exceeding this height')))); return $o; } if (argv(1) === 'channel') { require_once 'include/acl_selectors.php'; require_once 'include/permissions.php'; $p = q("SELECT * FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", intval(local_channel())); if (count($p)) { $profile = $p[0]; } load_pconfig(local_channel(), 'expire'); $channel = $a->get_channel(); $global_perms = get_perms(); $permiss = array(); $perm_opts = array(array(t('Nobody except yourself'), 0), array(t('Only those you specifically allow'), PERMS_SPECIFIC), array(t('Approved connections'), PERMS_CONTACTS), array(t('Any connections'), PERMS_PENDING), array(t('Anybody on this website'), PERMS_SITE), array(t('Anybody in this network'), PERMS_NETWORK), array(t('Anybody authenticated'), PERMS_AUTHED), array(t('Anybody on the internet'), PERMS_PUBLIC)); foreach ($global_perms as $k => $perm) { $options = array(); foreach ($perm_opts as $opt) { if (!$perm[2] && $opt[1] == PERMS_PUBLIC) { continue; } $options[$opt[1]] = $opt[0]; } $permiss[] = array($k, $perm[3], $channel[$perm[0]], $perm[4], $options); } // logger('permiss: ' . print_r($permiss,true)); $username = $channel['channel_name']; $nickname = $channel['channel_address']; $timezone = $channel['channel_timezone']; $notify = $channel['channel_notifyflags']; $defloc = $channel['channel_location']; $maxreq = $channel['channel_max_friend_req']; $expire = $channel['channel_expire_days']; $adult_flag = intval($channel['channel_pageflags'] & PAGE_ADULT); $sys_expire = get_config('system', 'default_expire_days'); // $unkmail = $a->user['unkmail']; // $cntunkmail = $a->user['cntunkmail']; $hide_presence = intval(get_pconfig(local_channel(), 'system', 'hide_online_status')); $expire_items = get_pconfig(local_channel(), 'expire', 'items'); $expire_items = $expire_items === false ? '1' : $expire_items; // default if not set: 1 $expire_notes = get_pconfig(local_channel(), 'expire', 'notes'); $expire_notes = $expire_notes === false ? '1' : $expire_notes; // default if not set: 1 $expire_starred = get_pconfig(local_channel(), 'expire', 'starred'); $expire_starred = $expire_starred === false ? '1' : $expire_starred; // default if not set: 1 $expire_photos = get_pconfig(local_channel(), 'expire', 'photos'); $expire_photos = $expire_photos === false ? '0' : $expire_photos; // default if not set: 0 $expire_network_only = get_pconfig(local_channel(), 'expire', 'network_only'); $expire_network_only = $expire_network_only === false ? '0' : $expire_network_only; // default if not set: 0 $suggestme = get_pconfig(local_channel(), 'system', 'suggestme'); $suggestme = $suggestme === false ? '0' : $suggestme; // default if not set: 0 $post_newfriend = get_pconfig(local_channel(), 'system', 'post_newfriend'); $post_newfriend = $post_newfriend === false ? '0' : $post_newfriend; // default if not set: 0 $post_joingroup = get_pconfig(local_channel(), 'system', 'post_joingroup'); $post_joingroup = $post_joingroup === false ? '0' : $post_joingroup; // default if not set: 0 $post_profilechange = get_pconfig(local_channel(), 'system', 'post_profilechange'); $post_profilechange = $post_profilechange === false ? '0' : $post_profilechange; // default if not set: 0 $blocktags = get_pconfig(local_channel(), 'system', 'blocktags'); $blocktags = $blocktags === false ? '0' : $blocktags; $timezone = date_default_timezone_get(); $opt_tpl = get_markup_template("field_checkbox.tpl"); if (get_config('system', 'publish_all')) { $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />'; } else { $profile_in_dir = replace_macros($opt_tpl, array('$field' => array('profile_in_directory', t('Publish your default profile in the network directory'), $profile['publish'], '', $yes_no))); } $suggestme = replace_macros($opt_tpl, array('$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', $yes_no))); $subdir = strlen($a->get_path()) ? '<br />' . t('or') . ' ' . $a->get_baseurl(true) . '/channel/' . $nickname : ''; $tpl_addr = get_markup_template("settings_nick_set.tpl"); $prof_addr = replace_macros($tpl_addr, array('$desc' => t('Your channel address is'), '$nickname' => $nickname, '$subdir' => $subdir, '$basepath' => $a->get_hostname())); $stpl = get_markup_template('settings.tpl'); $acl = new AccessList($channel); $perm_defaults = $acl->get(); require_once 'include/group.php'; $group_select = mini_group_select(local_channel(), $channel['channel_default_group']); require_once 'include/menu.php'; $m1 = menu_list(local_channel()); $menu = false; if ($m1) { $menu = array(); $current = get_pconfig(local_channel(), 'system', 'channel_menu'); $menu[] = array('name' => '', 'selected' => !$current ? true : false); foreach ($m1 as $m) { $menu[] = array('name' => htmlspecialchars($m['menu_name'], ENT_COMPAT, 'UTF-8'), 'selected' => $m['menu_name'] === $current ? ' selected="selected" ' : false); } } $evdays = get_pconfig(local_channel(), 'system', 'evdays'); if (!$evdays) { $evdays = 3; } $permissions_role = get_pconfig(local_channel(), 'system', 'permissions_role'); if (!$permissions_role) { $permissions_role = 'custom'; } $permissions_set = $permissions_role != 'custom' ? true : false; $vnotify = get_pconfig(local_channel(), 'system', 'vnotify'); $always_show_in_notices = get_pconfig(local_channel(), 'system', 'always_show_in_notices'); if ($vnotify === false) { $vnotify = -1; } $o .= replace_macros($stpl, array('$ptitle' => t('Channel Settings'), '$submit' => t('Submit'), '$baseurl' => $a->get_baseurl(true), '$uid' => local_channel(), '$form_security_token' => get_form_security_token("settings"), '$nickname_block' => $prof_addr, '$h_basic' => t('Basic Settings'), '$username' => array('username', t('Full Name:'), $username, ''), '$email' => array('email', t('Email Address:'), $email, ''), '$timezone' => array('timezone_select', t('Your Timezone:'), $timezone, '', get_timezones()), '$defloc' => array('defloc', t('Default Post Location:'), $defloc, t('Geographical location to display on your posts')), '$allowloc' => array('allow_location', t('Use Browser Location:'), get_pconfig(local_channel(), 'system', 'use_browser_location') ? 1 : '', '', $yes_no), '$adult' => array('adult', t('Adult Content'), $adult_flag, t('This channel frequently or regularly publishes adult content. (Please tag any adult material and/or nudity with #NSFW)'), $yes_no), '$h_prv' => t('Security and Privacy Settings'), '$permissions_set' => $permissions_set, '$perms_set_msg' => t('Your permissions are already configured. Click to view/adjust'), '$hide_presence' => array('hide_presence', t('Hide my online presence'), $hide_presence, t('Prevents displaying in your profile that you are online'), $yes_no), '$lbl_pmacro' => t('Simple Privacy Settings:'), '$pmacro3' => t('Very Public - <em>extremely permissive (should be used with caution)</em>'), '$pmacro2' => t('Typical - <em>default public, privacy when desired (similar to social network permissions but with improved privacy)</em>'), '$pmacro1' => t('Private - <em>default private, never open or public</em>'), '$pmacro0' => t('Blocked - <em>default blocked to/from everybody</em>'), '$permiss_arr' => $permiss, '$blocktags' => array('blocktags', t('Allow others to tag your posts'), 1 - $blocktags, t('Often used by the community to retro-actively flag inappropriate content'), $yes_no), '$lbl_p2macro' => t('Advanced Privacy Settings'), '$expire' => array('expire', t('Expire other channel content after this many days'), $expire, sprintf(t('0 or blank to use the website limit. The website expires after %d days.'), intval($sys_expire))), '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), intval($channel['channel_max_friend_req']), t('May reduce spam activity')), '$permissions' => t('Default Post Permissions'), '$permdesc' => t("(click to open/close)"), '$aclselect' => populate_acl($perm_defaults, false), '$suggestme' => $suggestme, '$group_select' => $group_select, '$role' => array('permissions_role', t('Channel permissions category:'), $permissions_role, '', get_roles()), '$profile_in_dir' => $profile_in_dir, '$hide_friends' => $hide_friends, '$hide_wall' => $hide_wall, '$unkmail' => $unkmail, '$cntunkmail' => array('cntunkmail', t('Maximum private messages per day from unknown people:'), intval($channel['channel_max_anon_mail']), t("Useful to reduce spamming")), '$h_not' => t('Notification Settings'), '$activity_options' => t('By default post a status message when:'), '$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, '', $yes_no), '$post_joingroup' => array('post_joingroup', t('joining a forum/community'), $post_joingroup, '', $yes_no), '$post_profilechange' => array('post_profilechange', t('making an <em>interesting</em> profile change'), $post_profilechange, '', $yes_no), '$lbl_not' => t('Send a notification email when:'), '$notify1' => array('notify1', t('You receive a connection request'), $notify & NOTIFY_INTRO, NOTIFY_INTRO, '', $yes_no), '$notify2' => array('notify2', t('Your connections are confirmed'), $notify & NOTIFY_CONFIRM, NOTIFY_CONFIRM, '', $yes_no), '$notify3' => array('notify3', t('Someone writes on your profile wall'), $notify & NOTIFY_WALL, NOTIFY_WALL, '', $yes_no), '$notify4' => array('notify4', t('Someone writes a followup comment'), $notify & NOTIFY_COMMENT, NOTIFY_COMMENT, '', $yes_no), '$notify5' => array('notify5', t('You receive a private message'), $notify & NOTIFY_MAIL, NOTIFY_MAIL, '', $yes_no), '$notify6' => array('notify6', t('You receive a friend suggestion'), $notify & NOTIFY_SUGGEST, NOTIFY_SUGGEST, '', $yes_no), '$notify7' => array('notify7', t('You are tagged in a post'), $notify & NOTIFY_TAGSELF, NOTIFY_TAGSELF, '', $yes_no), '$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), $notify & NOTIFY_POKE, NOTIFY_POKE, '', $yes_no), '$lbl_vnot' => t('Show visual notifications including:'), '$vnotify1' => array('vnotify1', t('Unseen grid activity'), $vnotify & VNOTIFY_NETWORK, VNOTIFY_NETWORK, '', $yes_no), '$vnotify2' => array('vnotify2', t('Unseen channel activity'), $vnotify & VNOTIFY_CHANNEL, VNOTIFY_CHANNEL, '', $yes_no), '$vnotify3' => array('vnotify3', t('Unseen private messages'), $vnotify & VNOTIFY_MAIL, VNOTIFY_MAIL, t('Recommended'), $yes_no), '$vnotify4' => array('vnotify4', t('Upcoming events'), $vnotify & VNOTIFY_EVENT, VNOTIFY_EVENT, '', $yes_no), '$vnotify5' => array('vnotify5', t('Events today'), $vnotify & VNOTIFY_EVENTTODAY, VNOTIFY_EVENTTODAY, '', $yes_no), '$vnotify6' => array('vnotify6', t('Upcoming birthdays'), $vnotify & VNOTIFY_BIRTHDAY, VNOTIFY_BIRTHDAY, t('Not available in all themes'), $yes_no), '$vnotify7' => array('vnotify7', t('System (personal) notifications'), $vnotify & VNOTIFY_SYSTEM, VNOTIFY_SYSTEM, '', $yes_no), '$vnotify8' => array('vnotify8', t('System info messages'), $vnotify & VNOTIFY_INFO, VNOTIFY_INFO, t('Recommended'), $yes_no), '$vnotify9' => array('vnotify9', t('System critical alerts'), $vnotify & VNOTIFY_ALERT, VNOTIFY_ALERT, t('Recommended'), $yes_no), '$vnotify10' => array('vnotify10', t('New connections'), $vnotify & VNOTIFY_INTRO, VNOTIFY_INTRO, t('Recommended'), $yes_no), '$vnotify11' => array('vnotify11', t('System Registrations'), $vnotify & VNOTIFY_REGISTER, VNOTIFY_REGISTER, '', $yes_no), '$always_show_in_notices' => array('always_show_in_notices', t('Also show new wall posts, private messages and connections under Notices'), $always_show_in_notices, 1, '', $yes_no), '$evdays' => array('evdays', t('Notify me of events this many days in advance'), $evdays, t('Must be greater than 0')), '$h_advn' => t('Advanced Account/Page Type Settings'), '$h_descadvn' => t('Change the behaviour of this account for special situations'), '$pagetype' => $pagetype, '$expert' => feature_enabled(local_channel(), 'expert'), '$hint' => t('Please enable expert mode (in <a href="settings/features">Settings > Additional features</a>) to adjust!'), '$lbl_misc' => t('Miscellaneous Settings'), '$photo_path' => array('photo_path', t('Default photo upload folder'), get_pconfig(local_channel(), 'system', 'photo_path'), t('%Y - current year, %m - current month')), '$attach_path' => array('attach_path', t('Default file upload folder'), get_pconfig(local_channel(), 'system', 'attach_path'), t('%Y - current year, %m - current month')), '$menus' => $menu, '$menu_desc' => t('Personal menu to display in your channel pages'), '$removeme' => t('Remove Channel'), '$removechannel' => t('Remove this channel.'), '$firefoxshare' => t('Firefox Share $Projectname provider'), '$cal_first_day' => array('first_day', t('Start calendar week on monday'), get_pconfig(local_channel(), 'system', 'cal_first_day') ? 1 : '', '', $yes_no))); call_hooks('settings_form', $o); $o .= '</form>' . "\r\n"; return $o; } }
function diabook_init(&$a) { set_template_engine($a, 'smarty3'); //print diabook-version for debugging $diabook_version = "Diabook (Version: 1.028)"; $a->page['htmlhead'] .= sprintf('<META NAME=generator CONTENT="%s"/>', $diabook_version); //init css on network and profilepages $cssFile = null; // Preload config load_config("diabook"); load_pconfig(local_user(), "diabook"); // adjust nav-bar, depending state of user if (local_user()) { $a->page['htmlhead'] .= ' <script> $(document).ready(function() { $("li#nav-site-linkmenu.nav-menu-icon").attr("style","display: block;"); $("li#nav-directory-link.nav-menu").attr("style","margin-right: 0px;"); $("li#nav-home-link.nav-menu").attr("style","display: block;margin-right: 8px;"); }); </script>'; } if ($a->argv[0] == "profile" && $a->argv[1] != $a->user['nickname']) { $a->page['htmlhead'] .= ' <script> $(document).ready(function() { $("li#nav-site-linkmenu.nav-menu-icon").attr("style","display: block;"); $("li#nav-directory-link.nav-menu").attr("style","margin-right: 0px;"); $("li#nav-home-link.nav-menu").attr("style","display: block;margin-right: 8px;"); }); </script>'; } //get statuses of boxes at right-hand-column $close_pages = get_diabook_config("close_pages", 1); $close_profiles = get_diabook_config("close_profiles", 0); $close_helpers = get_diabook_config("close_helpers", 0); $close_services = get_diabook_config("close_services", 0); $close_friends = get_diabook_config("close_friends", 0); $close_lastusers = get_diabook_config("close_lastusers", 0); $close_lastphotos = get_diabook_config("close_lastphotos", 0); $close_lastlikes = get_diabook_config("close_lastlikes", 0); $close_mapquery = get_diabook_config("close_mapquery", 1); //get resolution (wide/normal) $resolution = false; $resolution = get_pconfig(local_user(), "diabook", "resolution"); if ($resolution === false) { $resolution = "normal"; } //Add META viewport tag respecting the resolution to header for tablets if ($resolution == "wide") { $a->page['htmlhead'] .= '<meta name="viewport" content="width=1200" />'; } else { $a->page['htmlhead'] .= '<meta name="viewport" content="width=980" />'; } //get colour-scheme $color = get_diabook_config("color", "diabook"); if ($color == "diabook") { $color_path = "/"; } if ($color == "aerith") { $color_path = "/diabook-aerith/"; } if ($color == "blue") { $color_path = "/diabook-blue/"; } if ($color == "red") { $color_path = "/diabook-red/"; } if ($color == "pink") { $color_path = "/diabook-pink/"; } if ($color == "green") { $color_path = "/diabook-green/"; } if ($color == "dark") { $color_path = "/diabook-dark/"; } // remove doubled checkboxes at contacts-edit-page if ($a->argv[0] === "contacts" && $a->argv[1] != NULL && local_user()) { $a->page['htmlhead'] .= ' <script> $(document).ready(function() { $("span.group_unselected").attr("style","display: none;"); $("span.group_selected").attr("style","display: none;"); $("input.unticked.action").attr("style","float: left; margin-top: 5px;-moz-appearance: none;"); $("li.menu-profile-list").attr("style","min-height: 22px;"); }); </script>'; } //build personal menue at lefthand-col (id="profile_side") and boxes at right-hand-col at networkpages if ($a->argv[0] === "network" && local_user()) { // USER MENU if (local_user()) { $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid'])); $userinfo = array('icon' => count($r) ? $r[0]['micro'] : $a->get_baseurl() . "/images/default-profile-mm.jpg", 'name' => $a->user['username']); $ps = array('usermenu' => array()); $ps['usermenu']['status'] = array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations')); $ps['usermenu']['profile'] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), "", t('Your profile page')); $ps['usermenu']['contacts'] = array('contacts', t('Contacts'), "", t('Your contacts')); $ps['usermenu']['photos'] = array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos')); $ps['usermenu']['events'] = array('events/', t('Events'), "", t('Your events')); $ps['usermenu']['notes'] = array('notes/', t('Personal notes'), "", t('Your personal photos')); $ps['usermenu']['community'] = array('community/', t('Community'), "", ""); $ps['usermenu']['pgroups'] = array('http://dir.friendica.com/directory/forum', t('Community Pages'), "", ""); $tpl = get_markup_template('profile_side.tpl'); $a->page['aside'] = replace_macros($tpl, array('$userinfo' => $userinfo, '$ps' => $ps)) . $a->page['aside']; } $ccCookie = $close_pages + $close_mapquery + $close_profiles + $close_helpers + $close_services + $close_friends + $close_lastusers + $close_lastphotos + $close_lastlikes; //if all boxes closed, dont build right-hand-col and dont use special css if ($ccCookie != "9") { // COMMUNITY diabook_community_info(); // CUSTOM CSS if ($resolution == "normal") { $cssFile = $a->get_baseurl($ssl_state) . "/view/theme/diabook" . $color_path . "style-network.css"; } if ($resolution == "wide") { $cssFile = $a->get_baseurl($ssl_state) . "/view/theme/diabook" . $color_path . "style-network-wide.css"; } } } //build boxes at right_aside at profile pages if ($a->argv[0] . $a->argv[1] === "profile" . $a->user['nickname']) { if ($ccCookie != "9") { // COMMUNITY diabook_community_info(); // CUSTOM CSS if ($resolution == "normal") { $cssFile = $a->get_baseurl($ssl_state) . "/view/theme/diabook" . $color_path . "style-profile.css"; } if ($resolution == "wide") { $cssFile = $a->get_baseurl($ssl_state) . "/view/theme/diabook" . $color_path . "style-profile-wide.css"; } } } //write js-scripts to the head-section: //load jquery.cookie.js $cookieJS = $a->get_baseurl($ssl_state) . "/view/theme/diabook/js/jquery.cookie.js"; $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s"></script>', $cookieJS); //load jquery.ae.image.resize.js $imageresizeJS = $a->get_baseurl($ssl_state) . "/view/theme/diabook/js/jquery.ae.image.resize.min.js"; $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $imageresizeJS); //load jquery.ui.js if ($ccCookie != "9") { $jqueryuiJS = $a->get_baseurl($ssl_state) . "/view/theme/diabook/js/jquery-ui.min.js"; $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $jqueryuiJS); $jqueryuicssJS = $a->get_baseurl($ssl_state) . "/view/theme/diabook/jquery-ui.min.css"; $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $jqueryuicssJS); } //load jquery.mapquery.js if ($close_mapquery != "1") { $mqtmplJS = $a->get_baseurl($ssl_state) . "/view/theme/diabook/js/jquery.tmpl.js"; $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $mqtmplJS); $mapqueryJS = $a->get_baseurl($ssl_state) . "/view/theme/diabook/js/jquery.mapquery.core.js"; $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $mapqueryJS); $openlayersJS = $a->get_baseurl($ssl_state) . "/view/theme/diabook/js/OpenLayers.js"; $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $openlayersJS); $mqmouseposJS = $a->get_baseurl($ssl_state) . "/view/theme/diabook/js/jquery.mapquery.mqMousePosition.js"; $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $mqmouseposJS); $mousewheelJS = $a->get_baseurl($ssl_state) . "/view/theme/diabook/js/jquery.mousewheel.js"; $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $mousewheelJS); $mqlegendJS = $a->get_baseurl($ssl_state) . "/view/theme/diabook/js/jquery.mapquery.legend.js"; $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $mqlegendJS); $mqlayermanagerJS = $a->get_baseurl($ssl_state) . "/view/theme/diabook/js/jquery.mapquery.mqLayerManager.js"; $a->page['htmlhead'] .= sprintf('<script type="text/javascript" src="%s" ></script>', $mqlayermanagerJS); } $a->page['htmlhead'] .= ' <script> $(function() { $("a.lightbox").colorbox({maxHeight:"90%"}); // Select all links with lightbox class $("a#mapcontrol-link").colorbox({inline:true,onClosed: function() { $("#mapcontrol").attr("style","display: none;");}} ); $("a#closeicon").colorbox({inline:true,onClosed: function() { $("#boxsettings").attr("style","display: none;");}} ); }); $(window).load(function() { var footer_top = $(document).height() - 30; $("div#footerbox").attr("style", "border-top: 1px solid #D2D2D2; width: 70%;right: 15%;position: absolute;top:"+footer_top+"px;"); }); </script>'; //check if mapquerybox is active and print if ($close_mapquery != "1") { $ELZoom = get_diabook_config("ELZoom", 0); $ELPosX = get_diabook_config("ELPosX", 0); $ELPosY = get_diabook_config("ELPosY", 0); $a->page['htmlhead'] .= ' <script> $(function() { $("#map").mapQuery({ layers:[{ //add layers to your map; you need to define at least one to be able to see anything on the map type:"osm" //add a layer of the type osm (OpenStreetMap) }], center:({zoom:' . $ELZoom . ',position:[' . $ELPosX . ',' . $ELPosY . ']}), }); }); function open_mapcontrol() { $("div#mapcontrol").attr("style","display: block;width:900px;height:900px;"); $("#map2").mapQuery({ layers:[{type:"osm", label:"OpenStreetMap" }, {type:"wms", label:"Population density 2010", legend:{url:"http://mapserver.edugis.nl/cgi-bin/mapserv?map=maps/edugis/cache/population.map&version=1.1.1&service=WMS&request=GetLegendGraphic&layer=Bevolkingsdichtheid_2010&format=image/png"}, url:"http://t1.edugis.nl/tiles/tilecache.py?map=maps/edugis/cache/population.map", layers:"Bevolkingsdichtheid_2010" }, {type:"wms", label:"OpenLayers WMS", url:"http://labs.metacarta.com/wms/vmap0", layers:"basic" }], center:({zoom:' . $ELZoom . ',position:[' . $ELPosX . ',' . $ELPosY . ']})}); $("#mouseposition").mqMousePosition({ map: "#map2", x:"", y:"", precision:4 }); $("#layermanager").mqLayerManager({map:"#map2"}); $( "div#layermanager" ).accordion({header: ".mq-layermanager-element-header"}); $(".mq-layermanager-element-content").attr("style", ""); map = $("#map2").mapQuery().data("mapQuery"); textarea = document.getElementById("id_diabook_ELZoom"); textarea.value = "' . $ELZoom . '"; $("#map2").bind("mousewheel", function(event, delta) { if (delta > 0 && textarea.value < 18){ textarea.value = textarea.value - delta*-1; } if (delta < 0 && textarea.value > "0"){ textarea.value = textarea.value - delta*-1; } }); }; </script>'; } //check if community_home-plugin is activated and change css.. we need this, that the submit-wrapper doesn't overlay the login-panel if communityhome-plugin is active $nametocheck = "communityhome"; $r = q("select id from addon where name = '%s' and installed = 1", dbesc($nametocheck)); if (count($r) == "1" && $a->argv[0] === "home") { $a->page['htmlhead'] .= ' <script> $(function() { $("div#login-submit-wrapper").attr("style","padding-top: 120px;"); }); </script>'; } //comment-edit-wrapper on photo_view... we need this to workaround a global bug in photoview, where the comment-box is between the last comment the the comment before the last if ($a->argv[0] . $a->argv[2] === "photos" . "image") { $a->page['htmlhead'] .= ' <script> $(function(){ $(".comment-edit-form").css("display","table"); }); </script>'; } //restore (only) the order right hand col at settingspage if ($a->argv[0] === "settings" && local_user()) { $a->page['htmlhead'] .= ' <script> function restore_boxes(){ $.cookie("Boxorder",null, { expires: 365, path: "/" }); alert("Boxorder at right-hand column was restored. Please refresh your browser"); } </script>'; } if ($a->argv[0] . $a->argv[1] === "profile" . $a->user['nickname'] or $a->argv[0] === "network" && local_user()) { $a->page['htmlhead'] .= ' <script> $(function() { $(".oembed.photo img").aeImageResize({height: 400, width: 400}); }); </script>'; if ($ccCookie != "9") { $a->page['htmlhead'] .= ' <script> $("right_aside").ready(function(){ if(' . $close_pages . ') { document.getElementById( "close_pages" ).style.display = "none"; }; if(' . $close_mapquery . ') { document.getElementById( "close_mapquery" ).style.display = "none"; }; if(' . $close_profiles . ') { document.getElementById( "close_profiles" ).style.display = "none"; }; if(' . $close_helpers . ') { document.getElementById( "close_helpers" ).style.display = "none"; }; if(' . $close_services . ') { document.getElementById( "close_services" ).style.display = "none"; }; if(' . $close_friends . ') { document.getElementById( "close_friends" ).style.display = "none"; }; if(' . $close_lastusers . ') { document.getElementById( "close_lastusers" ).style.display = "none"; }; if(' . $close_lastphotos . ') { document.getElementById( "close_lastphotos" ).style.display = "none"; }; if(' . $close_lastlikes . ') { document.getElementById( "close_lastlikes" ).style.display = "none"; };} ); </script>'; } } //end js scripts // custom css if (!is_null($cssFile)) { $a->page['htmlhead'] .= sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $cssFile); } //footer $tpl = get_markup_template('footer.tpl'); $a->page['footer'] .= replace_macros($tpl, array()); // js_diabook_footer(); }
function twitter_post_hook(&$a, &$b) { /** * Post to Twitter */ if (!is_item_normal($b) || $b['item_private'] || $b['created'] !== $b['edited']) { return; } if (!perm_is_allowed($b['uid'], '', 'view_stream')) { return; } if (!strstr($b['postopts'], 'twitter')) { return; } if ($b['parent'] != $b['id']) { return; } logger('twitter post invoked'); load_pconfig($b['uid'], 'twitter'); $ckey = get_config('twitter', 'consumerkey'); $csecret = get_config('twitter', 'consumersecret'); $otoken = get_pconfig($b['uid'], 'twitter', 'oauthtoken'); $osecret = get_pconfig($b['uid'], 'twitter', 'oauthsecret'); $intelligent_shortening = get_pconfig($b['uid'], 'twitter', 'intelligent_shortening'); // Global setting overrides this if (get_config('twitter', 'intelligent_shortening')) { $intelligent_shortening = get_config('twitter', 'intelligent_shortening'); } if ($ckey && $csecret && $otoken && $osecret) { logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG); // If it's a repeated message from twitter then do a native retweet and exit // if (twitter_is_retweet($a, $b['uid'], $b['body'])) // return; require_once 'library/twitteroauth.php'; require_once 'include/bbcode.php'; $tweet = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); // in theory max char is 140 but T. uses t.co to make links // longer so we give them 10 characters extra if (!$intelligent_shortening) { $max_char = 130; // max. length for a tweet // we will only work with up to two times the length of the dent // we can later send to Twitter. This way we can "gain" some // information during shortening of potential links but do not // shorten all the links in a 200000 character long essay. if (!$b['title'] == '') { $tmp = $b['title'] . ' : ' . $b['body']; // $tmp = substr($tmp, 0, 4*$max_char); } else { $tmp = $b['body']; // substr($b['body'], 0, 3*$max_char); } // if [url=bla][img]blub.png[/img][/url] get blub.png $tmp = preg_replace('/\\[url\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\]\\[img\\](\\w+.*?)\\[\\/img\\]\\[\\/url\\]/i', '$2', $tmp); $tmp = preg_replace('/\\[zrl\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\]\\[zmg\\](\\w+.*?)\\[\\/zmg\\]\\[\\/zrl\\]/i', '$2', $tmp); // preserve links to images, videos and audios $tmp = preg_replace('/\\[img\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/img\\]/ism', '$3', $tmp); $tmp = preg_replace('/\\[\\/?img(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[zmg\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/zmg\\]/ism', '$3', $tmp); $tmp = preg_replace('/\\[\\/?zmg(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?video(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?youtube(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?vimeo(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?audio(\\s+.*?\\]|\\])/i', '', $tmp); $linksenabled = get_pconfig($b['uid'], 'twitter', 'post_taglinks'); // if a #tag is linked, don't send the [url] over to SN // that is, don't send if the option is not set in the // connector settings if ($linksenabled == '0') { // #-tags $tmp = preg_replace('/#\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', '#$2', $tmp); // @-mentions $tmp = preg_replace('/@\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', '@$2', $tmp); $tmp = preg_replace('/#\\[zrl\\=(\\w+.*?)\\](\\w+.*?)\\[\\/zrl\\]/i', '#$2', $tmp); // @-mentions $tmp = preg_replace('/@\\[zrl\\=(\\w+.*?)\\](\\w+.*?)\\[\\/zrl\\]/i', '@$2', $tmp); // recycle 1 } $tmp = preg_replace('/\\[url\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\](\\w+.*?)\\[\\/url\\]/i', '$2 $1', $tmp); // find all http or https links in the body of the entry and // apply the shortener if the link is longer then 20 characters if (strlen($tmp) > $max_char && $max_char > 0) { preg_match_all('/(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)/i', $tmp, $allurls); foreach ($allurls as $url) { foreach ($url as $u) { if (strlen($u) > 20) { $sl = short_link($u); $tmp = str_replace($u, $sl, $tmp); } } } } // ok, all the links we want to send out are save, now strip // away the remaining bbcode //$msg = strip_tags(bbcode($tmp, false, false)); $msg = bbcode($tmp, false, false); $msg = str_replace(array('<br>', '<br />'), "\n", $msg); $msg = strip_tags($msg); // quotes not working - let's try this $msg = html_entity_decode($msg); if (strlen($msg) > $max_char && $max_char > 0) { $shortlink = short_link($b['plink']); // the new message will be shortened such that "... $shortlink" // will fit into the character limit $msg = nl2br(substr($msg, 0, $max_char - strlen($shortlink) - 4)); $msg = str_replace(array('<br>', '<br />'), ' ', $msg); $e = explode(' ', $msg); // remove the last word from the cut down message to // avoid sending cut words to the MicroBlog array_pop($e); $msg = implode(' ', $e); $msg .= '... ' . $shortlink; } $msg = trim($msg); $image = ""; } else { $msgarr = twitter_shortenmsg($b); $msg = $msgarr["msg"]; $image = $msgarr["image"]; } // and now tweet it :-) // if(strlen($msg) and ($image != "")) { // $img_str = z_fetch_url($image); // $tempfile = tempnam(get_config("system","temppath"), "cache"); // file_put_contents($tempfile, $img_str); // Twitter had changed something so that the old library doesn't work anymore // so we are using a new library for twitter // To-Do: // Switching completely to this library with all functions require_once "addon/twitter/codebird.php"; // $cb = \Codebird\Codebird::getInstance(); // $cb->setConsumerKey($ckey, $csecret); // $cb->setToken($otoken, $osecret); // $post = array('status' => $msg, 'media[]' => $tempfile); // if ($iscomment) // $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9); // $result = $cb->statuses_updateWithMedia($post); // unlink($tempfile); // logger('twitter_post_with_media send, result: ' . print_r($result, true), LOGGER_DEBUG); // if ($result->errors OR $result->error) { // logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"'); // Workaround: Remove the picture link so that the post can be reposted without it // $msg .= " ".$image; // $image = ""; // } elseif ($iscomment) { // logger('twitter_post: Update extid '.$result->id_str." for post id ".$b['id']); // q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d", // dbesc("twitter::".$result->id_str), // dbesc($result->text), // intval($b['id']) // ); // } // } if (strlen($msg) and $image == "") { $url = 'statuses/update'; $post = array('status' => $msg); if ($iscomment) { $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9); } $result = $tweet->post($url, $post); logger('twitter_post send, result: ' . print_r($result, true), LOGGER_DEBUG); if ($result->errors) { logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"'); } // elseif ($iscomment) { // logger('twitter_post: Update extid '.$result->id_str." for post id ".$b['id']); // q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d", // dbesc("twitter::".$result->id_str), // intval($b['id']) // ); //q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d", // dbesc("twitter::".$result->id_str), // dbesc($result->text), // intval($b['id']) //); // } } } }
<?php if (!$a->install) { // Get the UID of the channel owner $uid = get_theme_uid(); if ($uid) { load_pconfig($uid, 'redbasic'); } // Load the owners pconfig $nav_bg = get_pconfig($uid, "redbasic", "nav_bg"); $nav_gradient_top = get_pconfig($uid, "redbasic", "nav_gradient_top"); $nav_gradient_bottom = get_pconfig($uid, "redbasic", "nav_gradient_bottom"); $nav_active_gradient_top = get_pconfig($uid, "redbasic", "nav_active_gradient_top"); $nav_active_gradient_bottom = get_pconfig($uid, "redbasic", "nav_active_gradient_bottom"); $nav_bd = get_pconfig($uid, "redbasic", "nav_bd"); $nav_icon_colour = get_pconfig($uid, "redbasic", "nav_icon_colour"); $nav_active_icon_colour = get_pconfig($uid, "redbasic", "nav_active_icon_colour"); $narrow_navbar = get_pconfig($uid, 'redbasic', 'narrow_navbar'); $banner_colour = get_pconfig($uid, 'redbasic', 'banner_colour'); $link_colour = get_pconfig($uid, "redbasic", "link_colour"); $schema = get_pconfig($uid, 'redbasic', 'schema'); $bgcolour = get_pconfig($uid, "redbasic", "background_colour"); $background_image = get_pconfig($uid, "redbasic", "background_image"); $toolicon_colour = get_pconfig($uid, 'redbasic', 'toolicon_colour'); $toolicon_activecolour = get_pconfig($uid, 'redbasic', 'toolicon_activecolour'); $item_colour = get_pconfig($uid, "redbasic", "item_colour"); $comment_item_colour = get_pconfig($uid, "redbasic", "comment_item_colour"); $comment_border_colour = get_pconfig($uid, "redbasic", "comment_border_colour"); $comment_indent = get_pconfig($uid, "redbasic", "comment_indent"); $body_font_size = get_pconfig($uid, "redbasic", "body_font_size"); $font_size = get_pconfig($uid, "redbasic", "font_size");
function twitter_post_hook(&$a, &$b) { /** * Post to Twitter */ require_once "include/network.php"; if (!get_pconfig($b["uid"], 'twitter', 'import')) { if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } } if ($b['parent'] != $b['id']) { logger("twitter_post_hook: parameter " . print_r($b, true), LOGGER_DATA); // Looking if its a reply to a twitter post if (substr($b["parent-uri"], 0, 9) != "twitter::" and substr($b["extid"], 0, 9) != "twitter::" and substr($b["thr-parent"], 0, 9) != "twitter::") { logger("twitter_post_hook: no twitter post " . $b["parent"]); return; } $r = q("SELECT * FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1", dbesc($b["thr-parent"]), intval($b["uid"])); if (!count($r)) { logger("twitter_post_hook: no parent found " . $b["thr-parent"]); return; } else { $iscomment = true; $orig_post = $r[0]; } $nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "\$1", $orig_post["author-link"]); $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]"; $nicknameplain = "@" . $nicknameplain; logger("twitter_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); if (strpos($b["body"], $nickname) === false and strpos($b["body"], $nicknameplain) === false) { $b["body"] = $nickname . " " . $b["body"]; } logger("twitter_post_hook: parent found " . print_r($orig_post, true), LOGGER_DATA); } else { $iscomment = false; if ($b['private'] or !strstr($b['postopts'], 'twitter')) { return; } } if ($b['verb'] == ACTIVITY_POST and $b['deleted']) { twitter_action($a, $b["uid"], substr($orig_post["uri"], 9), "delete"); } if ($b['verb'] == ACTIVITY_LIKE) { logger("twitter_post_hook: parameter 2 " . substr($b["thr-parent"], 9), LOGGER_DEBUG); if ($b['deleted']) { twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "unlike"); } else { twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "like"); } return; } if ($b['deleted'] || $b['created'] !== $b['edited']) { return; } // if post comes from twitter don't send it back if ($b['extid'] == NETWORK_TWITTER) { return; } if ($b['app'] == "Twitter") { return; } logger('twitter post invoked'); load_pconfig($b['uid'], 'twitter'); $ckey = get_config('twitter', 'consumerkey'); $csecret = get_config('twitter', 'consumersecret'); $otoken = get_pconfig($b['uid'], 'twitter', 'oauthtoken'); $osecret = get_pconfig($b['uid'], 'twitter', 'oauthsecret'); if ($ckey && $csecret && $otoken && $osecret) { logger('twitter: we have customer key and oauth stuff, going to send.', LOGGER_DEBUG); // If it's a repeated message from twitter then do a native retweet and exit if (twitter_is_retweet($a, $b['uid'], $b['body'])) { return; } require_once 'library/twitteroauth.php'; require_once 'include/bbcode.php'; $tweet = new TwitterOAuth($ckey, $csecret, $otoken, $osecret); $max_char = 140; require_once "include/plaintext.php"; $msgarr = plaintext($a, $b, $max_char, true, 8); $msg = $msgarr["text"]; if ($msg == "" and isset($msgarr["title"])) { $msg = shortenmsg($msgarr["title"], $max_char - 50); } $image = ""; if (isset($msgarr["url"]) and $msgarr["type"] != "photo") { $msg .= "\n" . $msgarr["url"]; } elseif (isset($msgarr["image"]) and $msgarr["type"] != "video") { $image = $msgarr["image"]; } // and now tweet it :-) if (strlen($msg) and $image != "") { $img_str = fetch_url($image); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); // Twitter had changed something so that the old library doesn't work anymore // so we are using a new library for twitter // To-Do: // Switching completely to this library with all functions require_once "addon/twitter/codebird.php"; $cb = \Codebird\Codebird::getInstance(); $cb->setConsumerKey($ckey, $csecret); $cb->setToken($otoken, $osecret); $post = array('status' => $msg, 'media[]' => $tempfile); if ($iscomment) { $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9); } $result = $cb->statuses_updateWithMedia($post); unlink($tempfile); logger('twitter_post_with_media send, result: ' . print_r($result, true), LOGGER_DEBUG); if ($result->source) { set_config("twitter", "application_name", strip_tags($result->source)); } if ($result->errors or $result->error) { logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"'); // Workaround: Remove the picture link so that the post can be reposted without it $msg .= " " . $image; $image = ""; } elseif ($iscomment) { logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']); q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d", dbesc("twitter::" . $result->id_str), dbesc($result->text), intval($b['id'])); } } if (strlen($msg) and $image == "") { $url = 'statuses/update'; $post = array('status' => $msg); if ($iscomment) { $post["in_reply_to_status_id"] = substr($orig_post["uri"], 9); } $result = $tweet->post($url, $post); logger('twitter_post send, result: ' . print_r($result, true), LOGGER_DEBUG); if ($result->source) { set_config("twitter", "application_name", strip_tags($result->source)); } if ($result->errors) { logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"'); $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid'])); if (count($r)) { $a->contact = $r[0]["id"]; } $s = serialize(array('url' => $url, 'item' => $b['id'], 'post' => $post)); require_once 'include/queue_fn.php'; add_to_queue($a->contact, NETWORK_TWITTER, $s); notice(t('Twitter post failed. Queued for retry.') . EOL); } elseif ($iscomment) { logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']); q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d", dbesc("twitter::" . $result->id_str), intval($b['id'])); //q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d", // dbesc("twitter::".$result->id_str), // dbesc($result->text), // intval($b['id']) //); } } } }
function statusnet_post_hook(&$a, &$b) { /** * Post to statusnet */ if (!strstr($b['postopts'], 'statusnet')) { logger('crosspost not enabled.'); return; } if (!is_item_normal($b) || $b['item_private'] || $b['created'] !== $b['edited']) { logger('not a usable post. ' . print_r($b, true), LOGGER_DEBUG); return; } if (!perm_is_allowed($b['uid'], '', 'view_stream')) { logger('permissions prevent crossposting.', LOGGER_DEBUG); return; } if ($b['parent'] != $b['id']) { logger('not a top level post.', LOGGER_DEBUG); return; } // if posts comes from statusnet don't send it back if ($b['app'] == "StatusNet") { logger('potential recursion. Crosspost ignored.'); return; } logger('statusnet post invoked'); load_pconfig($b['uid'], 'statusnet'); $api = get_pconfig($b['uid'], 'statusnet', 'baseapi'); $ckey = get_pconfig($b['uid'], 'statusnet', 'consumerkey'); $csecret = get_pconfig($b['uid'], 'statusnet', 'consumersecret'); $otoken = get_pconfig($b['uid'], 'statusnet', 'oauthtoken'); $osecret = get_pconfig($b['uid'], 'statusnet', 'oauthsecret'); $intelligent_shortening = get_pconfig($b['uid'], 'statusnet', 'intelligent_shortening'); // Global setting overrides this if (get_config('statusnet', 'intelligent_shortening')) { $intelligent_shortening = get_config('statusnet', 'intelligent_shortening'); } if ($ckey && $csecret && $otoken && $osecret) { require_once 'include/bbcode.php'; $dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $max_char = $dent->get_maxlength(); // max. length for a dent // we will only work with up to two times the length of the dent // we can later send to GNU social. This way we can "gain" some // information during shortening of potential links but do not // shorten all the links in a 200000 character long essay. $tempfile = ""; $intelligent_shortening = get_config('statusnet', 'intelligent_shortening'); if (!$intelligent_shortening) { if (!$b['title'] == '') { $tmp = $b['title'] . ": \n" . $b['body']; // $tmp = substr($tmp, 0, 4*$max_char); } else { $tmp = $b['body']; // substr($b['body'], 0, 3*$max_char); } // if [url=bla][img]blub.png[/img][/url] get blub.png $tmp = preg_replace('/\\[url\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\]\\[img\\](\\w+.*?)\\[\\/img\\]\\[\\/url\\]/i', '$2', $tmp); $tmp = preg_replace('/\\[zrl\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\]\\[zmg\\](\\w+.*?)\\[\\/zmg\\]\\[\\/zrl\\]/i', '$2', $tmp); // preserve links to images, videos and audios $tmp = preg_replace('/\\[img\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/img\\]/ism', '$3', $tmp); $tmp = preg_replace('/\\[\\/?img(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[zmg\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/zmg\\]/ism', '$3', $tmp); $tmp = preg_replace('/\\[\\/?zmg(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?video(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?audio(\\s+.*?\\]|\\])/i', '', $tmp); $linksenabled = get_pconfig($b['uid'], 'statusnet', 'post_taglinks'); // if a #tag is linked, don't send the [url] over to SN // that is, don't send if the option is not set in the // connector settings if ($linksenabled == '0') { // #-tags $tmp = preg_replace('/#\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', '#$2', $tmp); // @-mentions $tmp = preg_replace('/@\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', '@$2', $tmp); // #-tags $tmp = preg_replace('/#\\[zrl\\=(\\w+.*?)\\](\\w+.*?)\\[\\/zrl\\]/i', '#$2', $tmp); // @-mentions $tmp = preg_replace('/@\\[zrl\\=(\\w+.*?)\\](\\w+.*?)\\[\\/zrl\\]/i', '@$2', $tmp); // recycle 1 $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8'); $tmp = preg_replace('/' . $recycle . '\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', $recycle . '$2', $tmp); // recycle 2 (test) $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8'); $tmp = preg_replace('/' . $recycle . '\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', $recycle . '$2', $tmp); } // preserve links to webpages $tmp = preg_replace('/\\[url\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\](\\w+.*?)\\[\\/url\\]/i', '$2 $1', $tmp); $tmp = preg_replace('/\\[zrl\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\](\\w+.*?)\\[\\/zrl\\]/i', '$2 $1', $tmp); // find all http or https links in the body of the entry and // apply the shortener if the link is longer then 20 characters if (strlen($tmp) > $max_char && $max_char > 0) { preg_match_all('/(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)/i', $tmp, $allurls); foreach ($allurls as $url) { foreach ($url as $u) { if (strlen($u) > 20) { $sl = short_link($u); $tmp = str_replace($u, $sl, $tmp); } } } } // ok, all the links we want to send out are save, now strip // away the remaining bbcode $msg = bbcode($tmp, false, false, true); $msg = str_replace(array('<br>', '<br />'), "\n", $msg); $msg = strip_tags($msg); // quotes not working - let's try this $msg = html_entity_decode($msg); if (strlen($msg) > $max_char && $max_char > 0) { $shortlink = short_link($b['plink']); // the new message will be shortened such that "... $shortlink" // will fit into the character limit $msg = nl2br(substr($msg, 0, $max_char - strlen($shortlink) - 4)); $msg = str_replace(array('<br>', '<br />'), ' ', $msg); $e = explode(' ', $msg); // remove the last word from the cut down message to // avoid sending cut words to the MicroBlog array_pop($e); $msg = implode(' ', $e); $msg .= '... ' . $shortlink; } $msg = trim($msg); $postdata = array('status' => $msg); } else { $msgarr = statusnet_shortenmsg($b, $max_char); $msg = $msgarr["msg"]; $image = $msgarr["image"]; if ($image != "") { $x = z_fetch_url($image, true, 0, array('novalidate' => true)); if ($x['success']) { $imagedata = $x['body']; $tempfile = tempnam(get_config("system", "temppath"), "upload"); file_put_contents($tempfile, $imagedata); $postdata = array("status" => $msg, "media" => "@" . $tempfile); } } else { $postdata = array("status" => $msg); } } // and now dent it :-) if (strlen($msg)) { $result = $dent->post('statuses/update', $postdata); logger('statusnet_post send, result: ' . print_r($result, true) . "\nmessage: " . $msg, LOGGER_DEBUG); logger("Original post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true), LOGGER_DEBUG); if ($result->error) { logger('Send to GNU social failed: queued."' . $result->error . '"'); // @fixme - unable to queue media uploads if (!$image) { queue_insert(array('hash' => random_string(), 'account_id' => $b['aid'], 'channel_id' => $b['uid'], 'driver' => 'statusnet', 'posturl' => $api, 'msg' => $msg)); } } } if ($tempfile != "") { unlink($tempfile); } } }
function statusnet_post_hook(&$a, &$b) { /** * Post to GNU Social */ if (!get_pconfig($b["uid"], 'statusnet', 'import')) { if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } } $api = get_pconfig($b["uid"], 'statusnet', 'baseapi'); $hostname = preg_replace("=https?://([\\w\\.]*)/.*=ism", "\$1", $api); if ($b['parent'] != $b['id']) { logger("statusnet_post_hook: parameter " . print_r($b, true), LOGGER_DATA); // Looking if its a reply to a GNU Social post $hostlength = strlen($hostname) + 2; if (substr($b["parent-uri"], 0, $hostlength) != $hostname . "::" and substr($b["extid"], 0, $hostlength) != $hostname . "::" and substr($b["thr-parent"], 0, $hostlength) != $hostname . "::") { logger("statusnet_post_hook: no GNU Social post " . $b["parent"]); return; } $r = q("SELECT `item`.`author-link`, `item`.`uri`, `contact`.`nick` AS contact_nick\n\t\t\tFROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\tWHERE `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1", dbesc($b["thr-parent"]), intval($b["uid"])); if (!count($r)) { logger("statusnet_post_hook: no parent found " . $b["thr-parent"]); return; } else { $iscomment = true; $orig_post = $r[0]; } //$nickname = "@[url=".$orig_post["author-link"]."]".$orig_post["contact_nick"]."[/url]"; //$nicknameplain = "@".$orig_post["contact_nick"]; $nick = preg_replace("=https?://(.*)/(.*)=ism", "\$2", $orig_post["author-link"]); $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]"; $nicknameplain = "@" . $nick; logger("statusnet_post_hook: comparing " . $nickname . " and " . $nicknameplain . " with " . $b["body"], LOGGER_DEBUG); if (strpos($b["body"], $nickname) === false and strpos($b["body"], $nicknameplain) === false) { $b["body"] = $nickname . " " . $b["body"]; } logger("statusnet_post_hook: parent found " . print_r($orig_post, true), LOGGER_DEBUG); } else { $iscomment = false; if ($b['private'] or !strstr($b['postopts'], 'statusnet')) { return; } } if ($b['verb'] == ACTIVITY_POST and $b['deleted']) { statusnet_action($a, $b["uid"], substr($orig_post["uri"], $hostlength), "delete"); } if ($b['verb'] == ACTIVITY_LIKE) { logger("statusnet_post_hook: parameter 2 " . substr($b["thr-parent"], $hostlength), LOGGER_DEBUG); if ($b['deleted']) { statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "unlike"); } else { statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "like"); } return; } if ($b['deleted'] || $b['created'] !== $b['edited']) { return; } // if posts comes from GNU Social don't send it back if ($b['extid'] == NETWORK_STATUSNET) { return; } if ($b['app'] == "StatusNet") { return; } logger('GNU Socialpost invoked'); load_pconfig($b['uid'], 'statusnet'); $api = get_pconfig($b['uid'], 'statusnet', 'baseapi'); $ckey = get_pconfig($b['uid'], 'statusnet', 'consumerkey'); $csecret = get_pconfig($b['uid'], 'statusnet', 'consumersecret'); $otoken = get_pconfig($b['uid'], 'statusnet', 'oauthtoken'); $osecret = get_pconfig($b['uid'], 'statusnet', 'oauthsecret'); if ($ckey && $csecret && $otoken && $osecret) { // If it's a repeated message from GNU Social then do a native retweet and exit if (statusnet_is_retweet($a, $b['uid'], $b['body'])) { return; } require_once 'include/bbcode.php'; $dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $max_char = $dent->get_maxlength(); // max. length for a dent set_pconfig($b['uid'], 'statusnet', 'max_char', $max_char); $tempfile = ""; require_once "include/plaintext.php"; require_once "include/network.php"; $msgarr = plaintext($a, $b, $max_char, true, 7); $msg = $msgarr["text"]; if ($msg == "" and isset($msgarr["title"])) { $msg = shortenmsg($msgarr["title"], $max_char - 50); } $image = ""; if (isset($msgarr["url"]) and $msgarr["type"] != "photo") { if (strlen($msgarr["url"]) > 20 and strlen($msg . " \n" . $msgarr["url"]) > $max_char) { $msg .= " \n" . short_link($msgarr["url"]); } else { $msg .= " \n" . $msgarr["url"]; } } elseif (isset($msgarr["image"]) and $msgarr["type"] != "video") { $image = $msgarr["image"]; } if ($image != "") { $img_str = fetch_url($image); $tempfile = tempnam(get_temppath(), "cache"); file_put_contents($tempfile, $img_str); $postdata = array("status" => $msg, "media[]" => $tempfile); } else { $postdata = array("status" => $msg); } // and now dent it :-) if (strlen($msg)) { if ($iscomment) { $postdata["in_reply_to_status_id"] = substr($orig_post["uri"], $hostlength); logger('statusnet_post send reply ' . print_r($postdata, true), LOGGER_DEBUG); } // New code that is able to post pictures require_once "addon/statusnet/codebird.php"; $cb = \CodebirdSN\CodebirdSN::getInstance(); $cb->setAPIEndpoint($api); $cb->setConsumerKey($ckey, $csecret); $cb->setToken($otoken, $osecret); $result = $cb->statuses_update($postdata); //$result = $dent->post('statuses/update', $postdata); logger('statusnet_post send, result: ' . print_r($result, true) . "\nmessage: " . $msg, LOGGER_DEBUG . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true)); if ($result->source) { set_pconfig($b["uid"], "statusnet", "application_name", strip_tags($result->source)); } if ($result->error) { logger('Send to GNU Social failed: "' . $result->error . '"'); } elseif ($iscomment) { logger('statusnet_post: Update extid ' . $result->id . " for post id " . $b['id']); q("UPDATE `item` SET `extid` = '%s', `body` = '%s' WHERE `id` = %d", dbesc($hostname . "::" . $result->id), dbesc($result->text), intval($b['id'])); } } if ($tempfile != "") { unlink($tempfile); } } }
<?php require_once 'view/theme/frio/php/PHPColors/Color.php'; if (!$a->install) { // Get the UID of the channel owner $uid = get_theme_uid(); if ($uid) { load_pconfig($uid, 'frio'); } // Load the owners pconfig $schema = get_pconfig($uid, "frio", "schema"); $nav_bg = get_pconfig($uid, "frio", "nav_bg"); $nav_icon_color = get_pconfig($uid, "frio", "nav_icon_color"); $link_color = get_pconfig($uid, "frio", "link_color"); $bgcolor = get_pconfig($uid, "frio", "background_color"); $contentbg_transp = get_pconfig($uid, "frio", "contentbg_transp"); $background_image = get_pconfig($uid, "frio", "background_image"); $bg_image_option = get_pconfig($uid, "frio", "bg_image_option"); } // Now load the scheme. If a value is changed above, we'll keep the settings // If not, we'll keep those defined by the schema // Setting $schema to '' wasn't working for some reason, so we'll check it's // not --- like the mobile theme does instead. // Allow layouts to over-ride the schema if ($_REQUEST['schema']) { $schema = $_REQUEST['schema']; } if ($schema && $schema != '---') { // Check it exists, because this setting gets distributed to clones if (file_exists('view/theme/frio/schema/' . $schema . '.php')) { $schemefile = 'view/theme/frio/schema/' . $schema . '.php';
/** * @brief Get a particular channel's config variable given the category name * ($family) and a key. * * Get a particular channel's config value from the given category ($family) * and the $key from a cached storage in $a->config[$uid]. * * Returns false if not set. * * @param string $uid * The channel_id * @param string $family * The category of the configuration value * @param string $key * The configuration key to query * @param boolean $instore (deprecated, without function) * @return mixed Stored value or false if it does not exist */ function get_pconfig($uid, $family, $key, $instore = false) { // logger('include/config.php: get_pconfig() deprecated instore param used', LOGGER_DEBUG); global $a; if ($uid === false) { return false; } if (!array_key_exists($uid, $a->config)) { load_pconfig($uid); } if (!array_key_exists($family, $a->config[$uid]) || !array_key_exists($key, $a->config[$uid][$family])) { return false; } return !is_array($a->config[$uid][$family][$key]) && preg_match('|^a:[0-9]+:{.*}$|s', $a->config[$uid][$family][$key]) ? unserialize($a->config[$uid][$family][$key]) : $a->config[$uid][$family][$key]; }
function get_pconfig($uid, $family, $key, $instore = false) { global $a; if ($uid === false) { return false; } if (!array_key_exists($uid, $a->config)) { load_pconfig($uid); } if (!array_key_exists($family, $a->config[$uid]) || !array_key_exists($key, $a->config[$uid][$family])) { return false; } return !is_array($a->config[$uid][$family][$key]) && preg_match('|^a:[0-9]+:{.*}$|s', $a->config[$uid][$family][$key]) ? unserialize($a->config[$uid][$family][$key]) : $a->config[$uid][$family][$key]; }
function statusnet_post_hook(&$a, &$b) { /** * Post to statusnet */ if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } if (!strstr($b['postopts'], 'statusnet')) { return; } load_pconfig($b['uid'], 'statusnet'); $api = get_pconfig($b['uid'], 'statusnet', 'baseapi'); $ckey = get_pconfig($b['uid'], 'statusnet', 'consumerkey'); $csecret = get_pconfig($b['uid'], 'statusnet', 'consumersecret'); $otoken = get_pconfig($b['uid'], 'statusnet', 'oauthtoken'); $osecret = get_pconfig($b['uid'], 'statusnet', 'oauthsecret'); if ($ckey && $csecret && $otoken && $osecret) { require_once 'include/bbcode.php'; $dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $max_char = $dent->get_maxlength(); // max. length for a dent // we will only work with up to two times the length of the dent // we can later send to StatusNet. This way we can "gain" some // information during shortening of potential links but do not // shorten all the links in a 200000 character long essay. if (!$b['title'] == '') { $tmp = $b['title'] . ' : ' . $b['body']; // $tmp = substr($tmp, 0, 4*$max_char); } else { $tmp = $b['body']; // substr($b['body'], 0, 3*$max_char); } // if [url=bla][img]blub.png[/img][/url] get blub.png $tmp = preg_replace('/\\[url\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\]\\[img\\](\\w+.*?)\\[\\/img\\]\\[\\/url\\]/i', '$2', $tmp); // preserve links to images, videos and audios $tmp = preg_replace('/\\[img\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/img\\]/ism', '$3', $tmp); $tmp = preg_replace('/\\[\\/?img(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?video(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?youtube(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?vimeo(\\s+.*?\\]|\\])/i', '', $tmp); $tmp = preg_replace('/\\[\\/?audio(\\s+.*?\\]|\\])/i', '', $tmp); $linksenabled = get_pconfig($b['uid'], 'statusnet', 'post_taglinks'); // if a #tag is linked, don't send the [url] over to SN // that is, don't send if the option is not set in the // connector settings if ($linksenabled == '0') { // #-tags $tmp = preg_replace('/#\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', '#$2', $tmp); // @-mentions $tmp = preg_replace('/@\\[url\\=(\\w+.*?)\\](\\w+.*?)\\[\\/url\\]/i', '@$2', $tmp); } // preserve links to webpages $tmp = preg_replace('/\\[url\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\](\\w+.*?)\\[\\/url\\]/i', '$2 $1', $tmp); $tmp = preg_replace('/\\[bookmark\\=(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)\\](\\w+.*?)\\[\\/bookmark\\]/i', '$2 $1', $tmp); // find all http or https links in the body of the entry and // apply the shortener if the link is longer then 20 characters if (strlen($tmp) > $max_char && $max_char > 0) { preg_match_all('/(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\\$\\!\\+\\,]+)/i', $tmp, $allurls); foreach ($allurls as $url) { foreach ($url as $u) { if (strlen($u) > 20) { $sl = short_link($u); $tmp = str_replace($u, $sl, $tmp); } } } } // ok, all the links we want to send out are save, now strip // away the remaining bbcode $msg = strip_tags(bbcode($tmp)); // quotes not working - let's try this $msg = html_entity_decode($msg); if (strlen($msg) > $max_char && $max_char > 0) { $shortlink = short_link($b['plink']); // the new message will be shortened such that "... $shortlink" // will fit into the character limit $msg = nl2br(substr($msg, 0, $max_char - strlen($shortlink) - 4)); $msg = str_replace(array('<br>', '<br />'), ' ', $msg); $e = explode(' ', $msg); // remove the last word from the cut down message to // avoid sending cut words to the MicroBlog array_pop($e); $msg = implode(' ', $e); $msg .= '... ' . $shortlink; } // and now dent it :-) if (strlen($msg)) { $result = $dent->post('statuses/update', array('status' => $msg)); logger('statusnet_post send, result: ' . print_r($result, true), LOGGER_DEBUG); if ($result->error) { logger('Send to StatusNet failed: "' . $result->error . '"'); } } } }