function viewsrc_content(&$a) { $o = ''; $item_id = argc() > 1 ? intval(argv(1)) : 0; $json = argc() > 2 && argv(2) === 'json' ? true : false; if (!local_user()) { notice(t('Permission denied.') . EOL); } if (!$item_id) { $a->error = 404; notice(t('Item not found.') . EOL); } if (local_user() && $item_id) { $r = q("select item_flags, body from item where item_restrict = 0 and uid = %d and id = %d limit 1", intval(local_user()), intval($item_id)); if ($r) { if ($r[0]['item_flags'] & ITEM_OBSCURED) { $r[0]['body'] = crypto_unencapsulate(json_decode($r[0]['body'], true), get_config('system', 'prvkey')); } $o = $json ? json_encode($r[0]['body']) : str_replace("\n", '<br />', $r[0]['body']); } } if (is_ajax()) { echo $o; killme(); } return $o; }
function blackout_redirect($a, $b) { // if we have a logged in user, don't throw her out if (local_user()) { return true; } if (!(version_compare(PHP_VERSION, '5.3.0') >= 0)) { return true; } // else... $mystart = get_config('blackout', 'begindate'); $myend = get_config('blackout', 'enddate'); $myurl = get_config('blackout', 'url'); $now = time(); $date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart); $date2 = DateTime::createFromFormat('Y-m-d G:i', $myend); if ($date1 && $date2) { $date1 = DateTime::createFromFormat('Y-m-d G:i', $mystart)->format('U'); $date2 = DateTime::createFromFormat('Y-m-d G:i', $myend)->format('U'); } else { $date1 = 0; $date2 = 0; } if ($date1 <= $now && $now <= $date2) { logger('redirecting user to blackout page'); goaway($myurl); } }
function repair_ostatus_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED } $o = "<h2>" . t("Resubsribing to OStatus contacts") . "</h2>"; $uid = local_user(); $a = get_app(); $counter = intval($_REQUEST['counter']); $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE\n `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)", intval($uid), dbesc(NETWORK_OSTATUS), intval(CONTACT_IS_FRIEND), intval(CONTACT_IS_SHARING)); if (!$r) { return $o . t("Error"); } $total = $r[0]["total"]; $r = q("SELECT `url` FROM `contact` WHERE\n `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)\n\t\tORDER BY `url`\n\t\tLIMIT %d, 1", intval($uid), dbesc(NETWORK_OSTATUS), intval(CONTACT_IS_FRIEND), intval(CONTACT_IS_SHARING), $counter++); if (!$r) { $o .= t("Done"); return $o; } $o .= "<p>" . $counter . "/" . $total . ": " . $r[0]["url"] . "</p>"; $o .= "<p>" . t("Keep this window open until done.") . "</p>"; $result = new_contact($uid, $r[0]["url"], true); $a->page['htmlhead'] = '<meta http-equiv="refresh" content="1; URL=' . $a->get_baseurl() . '/repair_ostatus?counter=' . $counter . '">'; return $o; }
function tagrm_content(&$a) { $o = ''; if (!local_user()) { goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); // NOTREACHED } $item = $a->argc > 1 ? intval($a->argv[1]) : 0; if (!$item) { goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); // NOTREACHED } $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($item), intval(local_user())); if (!count($r)) { goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); } $arr = explode(',', $r[0]['tag']); if (!count($arr)) { goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); } $o .= '<h3>' . t('Remove Item Tag') . '</h3>'; $o .= '<p id="tag-remove-desc">' . t('Select a tag to remove: ') . '</p>'; $o .= '<form id="tagrm" action="tagrm" method="post" >'; $o .= '<input type="hidden" name="item" value="' . $item . '" />'; $o .= '<ul>'; foreach ($arr as $x) { $o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x) . '" >' . bbcode($x) . '</input></li>'; } $o .= '</ul>'; $o .= '<input id="tagrm-submit" type="submit" name="submit" value="' . t('Remove') . '" />'; $o .= '<input id="tagrm-cancel" type="submit" name="submit" value="' . t('Cancel') . '" />'; $o .= '</form>'; return $o; }
function snautofollow_settings(&$a, &$s) { if (!local_user()) { return; } /* Add our stylesheet to the page so we can make our settings look nice */ $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/snautofollow/snautofollow.css' . '" media="all" />' . "\r\n"; /* Get the current state of our config variable */ $snautofollow = get_pconfig(local_user(), 'system', 'ostatus_autofriend'); if ($snautofollow === false) { $snautofollow = false; } $snautofollow_checked = $snautofollow ? ' checked="checked" ' : ''; /* Add some HTML to the existing form */ $s .= '<span id="settings_snautofollow_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_snautofollow_expanded\'); openClose(\'settings_snautofollow_inflated\');">'; $s .= '<h3>' . t('StatusNet AutoFollow') . '</h3>'; $s .= '</span>'; $s .= '<div id="settings_snautofollow_expanded" class="settings-block" style="display: none;">'; $s .= '<span class="fakelink" onclick="openClose(\'settings_snautofollow_expanded\'); openClose(\'settings_snautofollow_inflated\');">'; $s .= '<h3>' . t('StatusNet AutoFollow') . '</h3>'; $s .= '</span>'; $s .= '<div id="snautofollow-wrapper">'; $s .= '<label id="snautofollow-label" for="snautofollow-checkbox">' . t('Automatically follow any StatusNet followers/mentioners') . '</label>'; $s .= '<input id="snautofollow-checkbox" type="checkbox" name="snautofollow" value="1" ' . $snautofollow_checked . '/>'; $s .= '</div><div class="clear"></div>'; /* provide a submit button */ $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="snautofollow-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>'; }
function regmod_content(&$a) { global $lang; $_SESSION['return_url'] = $a->cmd; if (!local_user()) { info(t('Please login.') . EOL); $o .= '<br /><br />' . login($a->config['register_policy'] == REGISTER_CLOSED ? 0 : 1); return $o; } if (!is_site_admin() || x($_SESSION, 'submanage') && intval($_SESSION['submanage'])) { notice(t('Permission denied.') . EOL); return ''; } if ($a->argc != 3) { killme(); } $cmd = $a->argv[1]; $hash = $a->argv[2]; if ($cmd === 'deny') { user_deny($hash); goaway($a->get_baseurl() . "/admin/users/"); killme(); } if ($cmd === 'allow') { user_allow($hash); goaway($a->get_baseurl() . "/admin/users/"); killme(); } }
/** * * Called from the Plugin Setting form. * Add our own settings info to the page. * */ function startpage_settings(&$a, &$s) { if (!local_user()) { return; } /* Add our stylesheet to the page so we can make our settings look nice */ $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/startpage/startpage.css' . '" media="all" />' . "\r\n"; /* Get the current state of our config variable */ $page = get_pconfig(local_user(), 'startpage', 'startpage'); /* Add some HTML to the existing form */ $s .= '<span id="settings_startpage_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">'; $s .= '<h3>' . t('Startpage') . '</h3>'; $s .= '</span>'; $s .= '<div id="settings_startpage_expanded" class="settings-block" style="display: none;">'; $s .= '<span class="fakelink" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">'; $s .= '<h3>' . t('Startpage') . '</h3>'; $s .= '</span>'; $s .= '<div id="startpage-page-wrapper">'; $s .= '<label id="startpage-page-label" for="startpage-page">' . t('Home page to load after login - leave blank for profile wall') . '</label>'; $s .= '<input id="startpage-page" type="text" name="startpage" value="' . $page . '" />'; $s .= '</div><div class="clear"></div>'; $s .= '<div id="startpage-desc">' . t('Examples: "network" or "notifications/system"') . '</div>'; /* provide a submit button */ $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="startpage-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>'; }
function regmod_content(&$a) { global $lang; $_SESSION['return_url'] = $a->cmd; if (!local_user()) { info(t('Please login.') . EOL); $o .= '<br /><br />' . login($a->config['register_policy'] == REGISTER_CLOSED ? 0 : 1); return $o; } if (!is_site_admin()) { notice(t('Permission denied.') . EOL); return ''; } if ($a->argc != 3) { killme(); } $cmd = $a->argv[1]; $hash = $a->argv[2]; if ($cmd === 'deny') { if (!user_deny($hash)) { killme(); } } if ($cmd === 'allow') { if (!user_allow($hash)) { killme(); } } }
/** * * Called from the Plugin Setting form. * Add our own settings info to the page. * */ function altpager_settings(&$a, &$s) { if (!local_user()) { return; } $global = get_config("alt_pager", "global"); if ($global == 1) { return; } /* Add our stylesheet to the page so we can make our settings look nice */ $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/altpager/altpager.css' . '" media="all" />' . "\r\n"; /* Get the current state of our config variable */ $altpager = get_pconfig(local_user(), 'system', 'alt_pager'); if ($altpager === false) { $altpager = 0; } $checked = $altpager ? ' checked="checked" ' : ''; /* Add some HTML to the existing form */ $s .= '<div class="settings-block">'; $s .= '<h3>' . t('Alternate Pagination Setting') . '</h3>'; $s .= '<div id="altpager-wrapper">'; $s .= '<label id="altpager-label" for="altpager">' . t('Use links to "newer" and "older" pages in place of page numbers?') . '</label>'; $s .= '<input id="altpager-input" type="checkbox" name="altpager" value="1" ' . $checked . '/>'; $s .= '</div><div class="clear"></div>'; /* provide a submit button */ $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="altpager-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>'; }
function theme_post(&$a) { if (!local_user()) { return; } if (isset($_POST['diabook-settings-submit'])) { set_pconfig(local_user(), 'diabook', 'font_size', $_POST['diabook_font_size']); set_pconfig(local_user(), 'diabook', 'line_height', $_POST['diabook_line_height']); set_pconfig(local_user(), 'diabook', 'resolution', $_POST['diabook_resolution']); set_pconfig(local_user(), 'diabook', 'color', $_POST['diabook_color']); set_pconfig(local_user(), 'diabook', 'TSearchTerm', $_POST['diabook_TSearchTerm']); set_pconfig(local_user(), 'diabook', 'ELZoom', $_POST['diabook_ELZoom']); set_pconfig(local_user(), 'diabook', 'ELPosX', $_POST['diabook_ELPosX']); set_pconfig(local_user(), 'diabook', 'ELPosY', $_POST['diabook_ELPosY']); set_pconfig(local_user(), 'diabook', 'ELPosY', $_POST['diabook_ELPosY']); set_pconfig(local_user(), 'diabook', 'close_pages', $_POST['diabook_close_pages']); set_pconfig(local_user(), 'diabook', 'close_mapquery', $_POST['diabook_close_mapquery']); set_pconfig(local_user(), 'diabook', 'close_profiles', $_POST['diabook_close_profiles']); set_pconfig(local_user(), 'diabook', 'close_helpers', $_POST['diabook_close_helpers']); set_pconfig(local_user(), 'diabook', 'close_services', $_POST['diabook_close_services']); set_pconfig(local_user(), 'diabook', 'close_friends', $_POST['diabook_close_friends']); set_pconfig(local_user(), 'diabook', 'close_twitter', $_POST['diabook_close_twitter']); set_pconfig(local_user(), 'diabook', 'close_lastusers', $_POST['diabook_close_lastusers']); set_pconfig(local_user(), 'diabook', 'close_lastphotos', $_POST['diabook_close_lastphotos']); set_pconfig(local_user(), 'diabook', 'close_lastlikes', $_POST['diabook_close_lastlikes']); } }
function share_init(&$a) { $post_id = $a->argc > 1 ? intval($a->argv[1]) : 0; if (!$post_id || !local_user()) { killme(); } $r = q("SELECT item.*, contact.network FROM `item` \n\t\tleft join contact on `item`.`contact-id` = `contact`.`id` \n\t\tWHERE `item`.`id` = %d AND `item`.`uid` = %d LIMIT 1", intval($post_id), intval(local_user())); if (!count($r) || $r[0]['private'] == 1) { killme(); } if (intval(get_config('system', 'new_share'))) { if (strpos($r[0]['body'], "[/share]") !== false) { $pos = strpos($r[0]['body'], "[share"); $o = substr($r[0]['body'], $pos); } else { $o = "[share author='" . str_replace("'", "'", $r[0]['author-name']) . "' profile='" . $r[0]['author-link'] . "' avatar='" . $r[0]['author-avatar'] . "' link='" . $r[0]['plink'] . "' posted='" . $r[0]['created'] . "']\n"; if ($r[0]['title']) { $o .= '[b]' . $r[0]['title'] . '[/b]' . "\n"; } $o .= $r[0]['body']; $o .= "[/share]"; } } else { $o = ''; $o .= "♲" . ' [url=' . $r[0]['author-link'] . ']' . $r[0]['author-name'] . '[/url]' . "\n"; if ($r[0]['title']) { $o .= '[b]' . $r[0]['title'] . '[/b]' . "\n"; } $o .= $r[0]['body'] . "\n"; $o .= $r[0]['plink'] ? '[url=' . $r[0]['plink'] . ']' . t('link') . '[/url]' . "\n" : ''; } echo $o; killme(); }
function redir_init(&$a) { if (!local_user() || !($a->argc == 2) || !intval($a->argv[1])) { goaway(z_root()); } $cid = $a->argv[1]; $url = x($_GET, 'url') ? $_GET['url'] : ''; $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user())); if (!count($r) || $r[0]['network'] !== 'dfrn') { goaway(z_root()); } $dfrn_id = $orig_id = $r[0]['issued-id'] ? $r[0]['issued-id'] : $r[0]['dfrn-id']; if ($r[0]['duplex'] && $r[0]['issued-id']) { $orig_id = $r[0]['issued-id']; $dfrn_id = '1:' . $orig_id; } if ($r[0]['duplex'] && $r[0]['dfrn-id']) { $orig_id = $r[0]['dfrn-id']; $dfrn_id = '0:' . $orig_id; } $sec = random_string(); q("INSERT INTO `profile_check` ( `uid`, `cid`, `dfrn_id`, `sec`, `expire`)\n\t\tVALUES( %d, %s, '%s', '%s', %d )", intval(local_user()), intval($cid), dbesc($dfrn_id), dbesc($sec), intval(time() + 45)); logger('mod_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG); $dest = $url ? '&destination_url=' . $url : ''; goaway($r[0]['poll'] . '?dfrn_id=' . $dfrn_id . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest); }
function invite_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $tpl = get_markup_template('invite.tpl'); $invonly = false; if (get_config('system', 'invitation_only')) { $invonly = true; $x = get_pconfig(local_user(), 'system', 'invites_remaining'); if (!$x && !is_site_admin()) { notice(t('You have no more invitations available') . EOL); return ''; } } $dirloc = get_config('system', 'directory_submit_url'); if (strlen($dirloc)) { if ($a->config['register_policy'] == REGISTER_CLOSED) { $linktxt = sprintf(t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), dirname($dirloc) . '/siteinfo'); } elseif ($a->config['register_policy'] != REGISTER_CLOSED) { $linktxt = sprintf(t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), $a->get_baseurl()) . "\r\n" . "\r\n" . sprintf(t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'), dirname($dirloc) . '/siteinfo'); } } else { $o = t('Our apologies. This system is not currently configured to connect with other public sites or invite members.'); return $o; } $o = replace_macros($tpl, array('$invite' => t('Send invitations'), '$addr_text' => t('Enter email addresses, one per line:'), '$msg_text' => t('Your message:'), '$default_message' => t('You are cordially invited to join me and other close friends on Friendica - and help us to create a better social web.') . "\r\n" . "\r\n" . $linktxt . "\r\n" . "\r\n" . ($invonly ? t('You will need to supply this invitation code: $invite_code') . "\r\n" . "\r\n" : '') . t('Once you have registered, please connect with me via my profile page at:') . "\r\n" . "\r\n" . $a->get_baseurl() . '/profile/' . $a->user['nickname'] . "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendica.com') . "\r\n" . "\r\n", '$submit' => t('Submit'))); return $o; }
function hcard_init(&$a) { if (argc() > 1) { $which = argv(1); } else { notice(t('Requested profile is not available.') . EOL); $a->error = 404; return; } $profile = ''; $channel = $a->get_channel(); if (local_user() && argc() > 2 && argv(2) === 'view') { $which = $channel['channel_address']; $profile = argv(1); $r = q("select profile_guid from profile where id = %d and uid = %d limit 1", intval($profile), intval(local_user())); if (!$r) { $profile = ''; } $profile = $r[0]['profile_guid']; } $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which . '" />' . "\r\n"; if (!$profile) { $x = q("select channel_id as profile_uid from channel where channel_address = '%s' limit 1", dbesc(argv(1))); if ($x) { $a->profile = $x[0]; } } profile_load($a, $which, $profile); }
function fsuggest_content(&$a) { require_once 'include/acl_selectors.php'; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } if ($a->argc != 2) { return; } $contact_id = intval($a->argv[1]); $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval(local_user())); if (!count($r)) { notice(t('Contact not found.') . EOL); return; } $contact = $r[0]; $o = '<h3>' . t('Suggest Friends') . '</h3>'; $o .= '<div id="fsuggest-desc" >' . sprintf(t('Suggest a friend for %s'), $contact['name']) . '</div>'; $o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >'; $o .= contact_selector('suggest', 'suggest-select', false, array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true)); $o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . t('Submit') . '" /></div>'; $o .= '</form>'; return $o; }
function suggest_content(&$a) { $o = ''; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $a->page['aside'] .= follow_widget(); $a->page['aside'] .= findpeople_widget(); $o .= '<h2>' . t('Friend Suggestions') . '</h2>'; $r = suggestion_query(local_user()); if (!count($r)) { $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.'); return $o; } $tpl = get_markup_template('suggest_friends.tpl'); foreach ($r as $rr) { $connlnk = $a->get_baseurl() . '/follow/?url=' . ($rr['connect'] ? $rr['connect'] : $rr['url']); $o .= replace_macros($tpl, array('$url' => zrl($rr['url']), '$name' => $rr['name'], '$photo' => $rr['photo'], '$ignlnk' => $a->get_baseurl() . '/suggest?ignore=' . $rr['id'], '$ignid' => $rr['id'], '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$ignore' => t('Ignore/Hide'))); } $o .= cleardiv(); // $o .= paginate($a); return $o; }
function pdledit_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } if (argc() > 1) { $module = 'mod_' . argv(1) . '.pdl'; } else { $o .= '<h1>' . t('Edit System Page Description') . '</h1>'; $files = glob('mod/*'); if ($files) { foreach ($files as $f) { $name = basename($f, '.php'); $x = theme_include('mod_' . $name . '.pdl'); if ($x) { $o .= '<a href="pdledit/' . $name . '" >' . $name . '</a><br />'; } } } // list module pdl files return $o; } $t = get_pconfig(local_user(), 'system', $module); if (!$t) { $t = file_get_contents(theme_include($module)); } if (!$t) { notice(t('Layout not found.') . EOL); return ''; } $o = replace_macros(get_markup_template('pdledit.tpl'), array('$header' => t('Edit System Page Description'), '$mname' => t('Module Name:'), '$help' => t('Layout Help'), '$module' => argv(1), '$content' => htmlspecialchars($t, ENT_COMPAT, 'UTF-8'), '$submit' => t('Submit'))); return $o; }
function viewsrc_item_photo_menu(&$a, &$b) { if (!local_user() || local_user() != $b['item']['uid']) { return; } $b['menu'] = array_merge(array(t('View Source') => $a->get_baseurl() . '/viewsrc/' . $b['item']['id']), $b['menu']); }
function crepair_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $cid = $a->argc > 1 ? intval($a->argv[1]) : 0; if ($cid) { $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user())); } if (!count($r)) { notice(t('Contact not found.') . EOL); return; } $contact = $r[0]; $msg1 = t('Repair Contact Settings'); $msg2 = t('<strong>WARNING: This is highly advanced</strong> and if you enter incorrect information your communications with this contact may stop working.'); $msg3 = t('Please use your browser \'Back\' button <strong>now</strong> if you are uncertain what to do on this page.'); $o .= '<h2>' . $msg1 . '</h2>'; $o .= '<div class="error-message">' . $msg2 . EOL . EOL . $msg3 . '</div>'; $o .= EOL . '<a href="contacts/' . $cid . '">' . t('Return to contact editor') . '</a>' . EOL; $tpl = get_markup_template('crepair.tpl'); $o .= replace_macros($tpl, array('$label_name' => t('Name'), '$label_nick' => t('Account Nickname'), '$label_attag' => t('@Tagname - overrides Name/Nickname'), '$label_url' => t('Account URL'), '$label_request' => t('Friend Request URL'), '$label_confirm' => t('Friend Confirm URL'), '$label_notify' => t('Notification Endpoint URL'), '$label_poll' => t('Poll/Feed URL'), '$label_photo' => t('New photo from this URL'), '$contact_name' => $contact['name'], '$contact_nick' => $contact['nick'], '$contact_id' => $contact['id'], '$contact_url' => $contact['url'], '$request' => $contact['request'], '$confirm' => $contact['confirm'], '$notify' => $contact['notify'], '$poll' => $contact['poll'], '$contact_attag' => $contact['attag'], '$lbl_submit' => t('Submit'))); return $o; }
function allfriends_content(&$a) { $o = ''; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } if ($a->argc > 1) { $cid = intval($a->argv[1]); } if (!$cid) { return; } $c = q("select name, url, photo from contact where id = %d and uid = %d limit 1", intval($cid), intval(local_user())); $a->page['aside'] .= '<div class="vcard">' . '<div class="fn label">' . $c[0]['name'] . '</div>' . '<div id="profile-photo-wrapper">' . '<a href="/contacts/' . $cid . '"><img class="photo" width="175" height="175" src="' . $c[0]['photo'] . '" alt="' . $c[0]['name'] . '" /></div>' . '</div>'; if (!count($c)) { return; } $o .= '<h2>' . sprintf(t('Friends of %s'), $c[0]['name']) . '</h2>'; $r = all_friends(local_user(), $cid); if (!count($r)) { $o .= t('No friends to display.'); return $o; } $tpl = get_markup_template('common_friends.tpl'); foreach ($r as $rr) { $o .= replace_macros($tpl, array('$url' => $rr['url'], '$name' => $rr['name'], '$photo' => $rr['photo'], '$tags' => '')); } $o .= cleardiv(); // $o .= paginate($a); return $o; }
function starred_init(&$a) { $starred = 0; if (!local_user()) { killme(); } if ($a->argc > 1) { $message_id = intval($a->argv[1]); } if (!$message_id) { killme(); } $r = q("SELECT starred FROM item WHERE uid = %d AND id = %d LIMIT 1", intval(local_user()), intval($message_id)); if (!count($r)) { killme(); } if (!intval($r[0]['starred'])) { $starred = 1; } $r = q("UPDATE item SET starred = %d WHERE uid = %d and id = %d LIMIT 1", intval($starred), intval(local_user()), intval($message_id)); // See if we've been passed a return path to redirect to $return_path = x($_REQUEST, 'return') ? $_REQUEST['return'] : ''; if ($return_path) { $rand = '_=' . time(); if (strpos($return_path, '?')) { $rand = "&{$rand}"; } else { $rand = "?{$rand}"; } goaway($a->get_baseurl() . "/" . $return_path . $rand); } // the json doesn't really matter, it will either be 0 or 1 echo json_encode($starred); killme(); }
function curweather_plugin_settings(&$a, &$s) { if (!local_user()) { return; } /* Add our stylesheet to the curweather so we can make our settings look nice */ $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/curweather/curweather.css' . '" media="all" />' . "\r\n"; /* Get the current state of our config variable */ $curweather_loc = get_pconfig(local_user(), 'curweather', 'curweather_loc'); $enable = intval(get_pconfig(local_user(), 'curweather', 'curweather_enable')); $enable_checked = $enable ? ' checked="checked" ' : ''; /* Add some HTML to the existing form */ $s .= '<div class="settings-block">'; $s .= '<h3>' . t('Current Weather') . '</h3>'; $s .= '<div id="curweather-settings-wrapper">'; $s .= '<p>Find the location code for the airport/weather station nearest you <a href="http://en.wikipedia.org/wiki/International_Air_Transport_Association_airport_code" target="_blank">here</a>.</p>'; $s .= '<label id="curweather-location-label" for="curweather_loc">' . t('Weather Location: ') . '</label>'; $s .= '<input id="curweather-location" type="text" name="curweather_loc" value="' . $curweather_loc . '"/>'; $s .= '<div class="clear"></div>'; $s .= '<label id="curweather-enable-label" for="curweather_enable">' . t('Enable Current Weather') . '</label>'; $s .= '<input id="curweather-enable" type="checkbox" name="curweather_enable" value="1" ' . $enable_checked . '/>'; $s .= '<div class="clear"></div>'; $s .= '</div>'; /* provide a submit button */ $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="curweather-settings-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>'; }
function filer_content(&$a) { if (!local_user()) { killme(); } $term = unxmlify(trim($_GET['term'])); $item_id = $a->argc > 1 ? intval($a->argv[1]) : 0; logger('filer: tag ' . $term . ' item ' . $item_id); if ($item_id && strlen($term)) { // file item store_item_tag(local_user(), $item_id, TERM_OBJ_POST, TERM_FILE, $term, ''); // protect the entire conversation from periodic expiration $r = q("select parent from item where id = %d and uid = %d limit 1", intval($item_id), intval(local_user())); if ($r) { $x = q("update item set item_flags = ( item_flags | %d ) where id = %d and uid = %d limit 1", intval(ITEM_RETAINED), intval($r[0]['parent']), intval(local_user())); } } else { $filetags = array(); $r = q("select distinct(term) from term where uid = %d and type = %d order by term asc", intval(local_user()), intval(TERM_FILE)); if (count($r)) { foreach ($r as $rr) { $filetags[] = $rr['term']; } } $tpl = get_markup_template("filer_dialog.tpl"); $o = replace_macros($tpl, array('$field' => array('term', t("Save to Folder:"), '', '', $filetags, t('- select -')), '$submit' => t('Save'))); echo $o; } killme(); }
function follow_post(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED } if ($_REQUEST['cancel']) { goaway($_SESSION['return_url']); } $uid = local_user(); $url = notags(trim($_REQUEST['url'])); $return_url = $_SESSION['return_url']; // Makes the connection request for friendica contacts easier // This is just a precaution if maybe this page is called somewhere directly via POST $_SESSION["fastlane"] = $url; $result = new_contact($uid, $url, true); if ($result['success'] == false) { if ($result['message']) { notice($result['message']); } goaway($return_url); } elseif ($result['cid']) { goaway($a->get_baseurl() . '/contacts/' . $result['cid']); } info(t('Contact added') . EOL); if (strstr($return_url, 'contacts')) { goaway($a->get_baseurl() . '/contacts/' . $contact_id); } goaway($return_url); // NOTREACHED }
function notifications_content(&$a) { if (!local_user()) { notice(t('Permission denied') . EOL); goaway($a->get_baseurl()); } $o = ''; if ($a->argc > 1 && $a->argv[1] == 'all') { $sql_extra = ''; } else { $sql_extra = " AND `ignore` = 0 "; } $tpl = file_get_contents('view/intros-top.tpl'); $o .= replace_macros($tpl, array('$hide_url' => strlen($sql_extra) ? 'notifications/all' : 'notifications', '$hide_text' => strlen($sql_extra) ? t('Show Ignored Requests') : t('Hide Ignored Requests'))); $r = q("SELECT `intro`.`id` AS `intro-id`, `intro`.*, `contact`.* \n\t\tFROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`\n\t\tWHERE `intro`.`blocked` = 0 {$sql_extra} "); if ($r !== false && count($r)) { $tpl = file_get_contents("view/intros.tpl"); foreach ($r as $rr) { $o .= replace_macros($tpl, array('$intro_id' => $rr['intro-id'], '$dfrn-id' => $rr['issued-id'], '$uid' => $_SESSION['uid'], '$contact-id' => $rr['contact-id'], '$photo' => x($rr, 'photo') ? $rr['photo'] : "images/default-profile.jpg", '$fullname' => $rr['name'], '$knowyou' => $rr['knowyou'] ? t('yes') : t('no'), '$url' => $rr['url'], '$note' => $rr['note'])); } } else { notice(t('No notifications.') . EOL); } return $o; }
function login_content(&$a) { if (local_user()) { goaway(z_root()); } return login($a->config['system']['register_policy'] == REGISTER_CLOSED ? false : true); }
function bookmarks_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } require_once 'include/menu.php'; require_once 'include/conversation.php'; $channel = $a->get_channel(); $o = profile_tabs($a, true, $channel['channel_address']); $o .= '<h3>' . t('My Bookmarks') . '</h3>'; $x = menu_list(local_user(), '', MENU_BOOKMARK); if ($x) { foreach ($x as $xx) { $y = menu_fetch($xx['menu_name'], local_user(), get_observer_hash()); $o .= menu_render($y, '', true); } } $o .= '<h3>' . t('My Connections Bookmarks') . '</h3>'; $x = menu_list(local_user(), '', MENU_SYSTEM | MENU_BOOKMARK); if ($x) { foreach ($x as $xx) { $y = menu_fetch($xx['menu_name'], local_user(), get_observer_hash()); $o .= menu_render($y, '', true); } } return $o; }
function user_remove($uid) { if (!$uid) { return; } $a = get_app(); logger('Removing user: '******'authenticated']); unset($_SESSION['uid']); goaway($a->get_baseurl()); } }
function suggest_content(&$a) { require_once "mod/proxy.php"; $o = ''; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= follow_widget(); $r = suggestion_query(local_user()); if (!count($r)) { $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.'); return $o; } require_once 'include/contact_selectors.php'; foreach ($r as $rr) { $connlnk = $a->get_baseurl() . '/follow/?url=' . ($rr['connect'] ? $rr['connect'] : $rr['url']); $ignlnk = $a->get_baseurl() . '/suggest?ignore=' . $rr['id']; $photo_menu = array(array(t("View Profile"), zrl($rr["url"]))); $photo_menu[] = array(t("Connect/Follow"), $connlnk); $photo_menu[] = array(t('Ignore/Hide'), $ignlnk); $contact_details = get_contact_details_by_url($rr["url"], local_user()); $entry = array('url' => zrl($rr['url']), 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'img_hover' => $rr['url'], 'name' => $rr['name'], 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'ignlnk' => $ignlnk, 'ignid' => $rr['id'], 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'photo_menu' => $photo_menu, 'ignore' => t('Ignore/Hide'), 'network' => network_to_name($rr['network'], $rr['url']), 'id' => ++$id); $entries[] = $entry; } $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl, array('$title' => t('Friend Suggestions'), '$contacts' => $entries)); return $o; }
function oexchange_content(&$a) { if (!local_user()) { $o = login(false); return $o; } if ($a->argc > 1 && $a->argv[1] === 'done') { info(t('Post successful.') . EOL); return; } $url = x($_GET, 'url') && strlen($_GET['url']) ? urlencode(notags(trim($_GET['url']))) : ''; $title = x($_GET, 'title') && strlen($_GET['title']) ? '&title=' . urlencode(notags(trim($_GET['title']))) : ''; $description = x($_GET, 'description') && strlen($_GET['description']) ? '&description=' . urlencode(notags(trim($_GET['description']))) : ''; $tags = x($_GET, 'tags') && strlen($_GET['tags']) ? '&tags=' . urlencode(notags(trim($_GET['tags']))) : ''; $s = fetch_url($a->get_baseurl() . '/parse_url?f=&url=' . $url . $title . $description . $tags); if (!strlen($s)) { return; } require_once 'include/html2bbcode.php'; $post = array(); $post['profile_uid'] = local_user(); $post['return'] = '/oexchange/done'; $post['body'] = html2bbcode($s); $post['type'] = 'wall'; $_POST = $post; require_once 'mod/item.php'; item_post($a); }