function user_allow($hash) { $a = get_app(); $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($hash)); if (!count($register)) { return false; } $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($register[0]['uid'])); if (!count($user)) { killme(); } $r = q("DELETE FROM `register` WHERE `hash` = '%s'", dbesc($register[0]['hash'])); $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d", intval($register[0]['uid'])); $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1", intval($user[0]['uid'])); if (count($r) && $r[0]['net-publish']) { $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname']; if ($url && strlen(get_config('system', 'directory'))) { proc_run('php', "include/directory.php", "{$url}"); } } push_lang($register[0]['language']); send_register_open_eml($user[0]['email'], $a->config['sitename'], $a->get_baseurl(), $user[0]['username'], $register[0]['password']); pop_lang(); if ($res) { info(t('Account approved.') . EOL); return true; } }
function search_doc_files($s) { $a = get_app(); $itemspage = get_pconfig(local_channel(), 'system', 'itemspage'); App::set_pager_itemspage(intval($itemspage) ? $itemspage : 20); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); $regexop = db_getfunc('REGEXP'); $r = q("select item_id.sid, item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and\n\t\tbody {$regexop} '%s' and item_type = %d {$pager_sql}", dbesc($s), intval(ITEM_TYPE_DOC)); $r = fetch_post_tags($r, true); for ($x = 0; $x < count($r); $x++) { $r[$x]['text'] = $r[$x]['body']; $r[$x]['rank'] = 0; if ($r[$x]['term']) { foreach ($r[$x]['term'] as $t) { if (stristr($t['term'], $s)) { $r[$x]['rank']++; } } } if (stristr($r[$x]['sid'], $s)) { $r[$x]['rank']++; } $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']), strtolower($s)); // bias the results to the observer's native language if ($r[$x]['lang'] === App::$language) { $r[$x]['rank'] = $r[$x]['rank'] + 10; } } usort($r, 'doc_rank_sort'); return $r; }
function wfinger_init(&$a) { $result = array(); $scheme = ''; if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) { $scheme = 'https'; } elseif (x($_SERVER, 'SERVER_PORT') && intval($_SERVER['SERVER_PORT']) == 443) { $scheme = 'https'; } // Don't complain to me - I'm just implementing the spec. if ($scheme !== 'https') { header($_SERVER["SERVER_PROTOCOL"] . ' ' . 500 . ' ' . 'Webfinger requires HTTPS'); killme(); } $resource = $_REQUEST['resource']; $r = null; if ($resource) { if (strpos($resource, 'acct:') === 0) { $channel = str_replace('acct:', '', $resource); if (strpos($channel, '@') !== false) { $host = substr($channel, strpos($channel, '@') + 1); if (strcasecmp($host, get_app()->get_hostname())) { goaway('https://' . $host . '/.well-known/webfinger?resource=' . $resource); } $channel = substr($channel, 0, strpos($channel, '@')); } } if (strpos($resource, 'http') === 0) { $channel = str_replace('~', '', basename($resource)); } $r = q("select * from channel left join xchan on channel_hash = xchan_hash \n\t\t\twhere channel_address = '%s' limit 1", dbesc($channel)); } header('Access-Control-Allow-Origin: *'); header('Content-type: application/jrd+json'); if ($resource && $r) { $h = q("select hubloc_addr from hubloc where hubloc_hash = '%s'", dbesc($r[0]['channel_hash'])); $result['subject'] = $resource; $aliases = array(z_root() . '/channel/' . $r[0]['channel_address'], z_root() . '/~' . $r[0]['channel_address']); if ($h) { foreach ($h as $hh) { $aliases[] = 'acct:' . $hh['hubloc_addr']; } } $result['aliases'] = array(); $result['properties'] = array('http://webfinger.net/ns/name' => $r[0]['channel_name']); foreach ($aliases as $alias) { if ($alias != $resource) { $result['aliases'][] = $alias; } } $result['links'] = array(array('rel' => 'http://webfinger.net/rel/avatar', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_l']), array('rel' => 'http://webfinger.net/rel/profile-page', 'href' => z_root() . '/profile/' . $r[0]['channel_address']), array('rel' => 'http://webfinger.net/rel/blog', 'href' => z_root() . '/channel/' . $r[0]['channel_address']), array('rel' => 'http://purl.org/zot/protocol', 'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'])); } else { header($_SERVER["SERVER_PROTOCOL"] . ' ' . 400 . ' ' . 'Bad Request'); killme(); } $arr = array('channel' => $r[0], 'request' => $_REQUEST, 'result' => $result); call_hooks('webfinger', $arr); echo json_encode($arr['result']); killme(); }
function checksites_run($argv, $argc) { cli_startup(); $a = get_app(); logger('checksites: start'); if ($argc > 1 && $argv[1]) { $site_id = $argv[1]; } if ($site_id) { $sql_options = " and site_url = '" . dbesc($argv[1]) . "' "; } $days = intval(get_config('system', 'sitecheckdays')); if ($days < 1) { $days = 30; } $r = q("select * from site where site_dead = 0 and site_update < %s - INTERVAL %s and site_type = %d {$sql_options} ", db_utcnow(), db_quoteinterval($days . ' DAY'), intval(SITE_TYPE_ZOT)); if (!$r) { return; } foreach ($r as $rr) { if (!strcasecmp($rr['site_url'], z_root())) { continue; } $x = ping_site($rr['site_url']); if ($x['success']) { logger('checksites: ' . $rr['site_url']); q("update site set site_update = '%s' where site_url = '%s' ", dbesc(datetime_convert()), dbesc($rr['site_url'])); } else { logger('marking dead site: ' . $x['message']); q("update site set site_dead = 1 where site_url = '%s' ", dbesc($rr['site_url'])); } } return; }
/** * Returns information from a single calendar object, based on it's object * uri. * * The returned array must have the same keys as getCalendarObjects. The * 'calendardata' object is required here though, while it's not required * for getCalendarObjects. * * @param string $calendarId * @param string $objectUri * @throws Sabre_DAV_Exception_FileNotFound * @return array */ function getCalendarObject($calendarId, $objectUri) { $a = get_app(); $user_id = $a->user["uid"]; $obj = FriendicaVirtualCalSourceBackend::getItemsByUri($user_id, $objectUri); return array("id" => IntVal($obj["data_uri"]), "calendardata" => $obj["ical"], "uri" => $obj["data_uri"], "lastmodified" => $obj["date"], "calendarid" => $calendarId, "etag" => $obj["ical_etag"], "size" => IntVal($obj["ical_size"])); }
function user_allow($hash) { $a = get_app(); $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($hash)); if (!count($register)) { return false; } $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($register[0]['uid'])); if (!count($user)) { killme(); } $r = q("DELETE FROM `register` WHERE `hash` = '%s' LIMIT 1", dbesc($register[0]['hash'])); $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d LIMIT 1", intval($register[0]['uid'])); $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1", intval($user[0]['uid'])); if (count($r) && $r[0]['net-publish']) { $url = $a->get_baseurl() . '/profile/' . $user[0]['nickname']; if ($url && strlen(get_config('system', 'directory_submit_url'))) { proc_run('php', "include/directory.php", "{$url}"); } } push_lang($register[0]['language']); $email_tpl = get_intltext_template("register_open_eml.tpl"); $email_tpl = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => $user[0]['username'], '$email' => $user[0]['email'], '$password' => $register[0]['password'], '$uid' => $user[0]['uid'])); $res = mail($user[0]['email'], sprintf(t('Registration details for %s'), $a->config['sitename']), $email_tpl, 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit'); pop_lang(); if ($res) { info(t('Account approved.') . EOL); return true; } }
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 edit($staff_id) { $app = get_app(); $staff = Staff::find_by_id($staff_id); //GET if ($app->request()->isGet()) { render_with_layout('misc.php', 'Staffs/edit.php', compact('staff')); } //POST if ($app->request()->isPost()) { $post = $app->request()->post(); // $staff->identifier = $post['identifier']; $staff->name = $post['name']; $staff->short = $post['short']; $staff->group_id = $post['group_id']; if (!$staff->is_valid()) { $app->flashNow('errors', $staff->errors); render_with_layout('misc.php', 'Staffs/add.php', compact('staff')); } else { $staff->save(); $app->flash('success', '员工信息更新成功!'); redirect('/staffs'); } } }
function onedirsync_run($argv, $argc) { cli_startup(); $a = get_app(); logger('onedirsync: start ' . intval($argv[1])); if ($argc > 1 && intval($argv[1])) { $update_id = intval($argv[1]); } if (!$update_id) { logger('onedirsync: no update'); return; } $r = q("select * from updates where ud_id = %d limit 1", intval($update_id)); if (!$r) { return; } if ($r[0]['ud_flags'] & UPDATE_FLAGS_UPDATED || !$r[0]['ud_addr']) { return; } // Have we probed this channel more recently than the other directory server // (where we received this update from) ? // If we have, we don't need to do anything except mark any older entries updated $x = q("select * from updates where ud_addr = '%s' and ud_date > '%s' and ( ud_flags & %d ) order by ud_date desc limit 1", dbesc($r[0]['ud_addr']), dbesc($r[0]['ud_date']), intval(UPDATE_FLAGS_UPDATED)); if ($x) { $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and not ( ud_flags & %d ) and ud_date < '%s' ", intval(UPDATE_FLAGS_UPDATED), dbesc($r[0]['ud_addr']), intval(UPDATE_FLAGS_UPDATED), dbesc($x[0]['ud_date'])); return; } update_directory_entry($r[0]); return; }
/** * Adds a path into the Twig Filesystem Loader. * * @param $path the path to add * @param bool $default If true will send the path to the beginning, this means the most important path * @param bool $weight path into a specif place * * @return boolean. */ function add_twig_path($path, $default = false, $weight = false) { $app = get_app(); if ($default === true) { $app->getTwigLoader()->prependPath($path); return true; } elseif ($default === false && $weight === false) { $app->getTwigLoader()->addPath($path); return true; } $paths = $app->getTwigLoader()->getPaths(); $reindexed_paths = array(); if (count($paths) < $weight) { //Higer than current paths so goes last. $app->getTwigLoader()->addPath($path); return true; } if (count($paths) > 0) { $reindexed_paths[] = array_shift($paths); //Defaults keeps being the default. } $index = 0; while ($current_path = array_shift($paths)) { // Look a position for the current weight. if ($index == $weight) { $reindexed_paths[] = $path; } else { $reindexed_paths[] = $current_path; } $index++; } $app->getTwigLoader()->setPaths($reindexed_paths); return true; }
function view($id) { //file_id $app = get_app(); $file = File::find_by_id($id); $app->render('Files/view.php', compact('file')); }
function page_content(&$a) { $observer = $a->get_observer(); $ob_hash = $observer ? $observer['xchan_hash'] : ''; $perms = get_all_perms($a->profile['profile_uid'], $ob_hash); if (!$perms['view_pages']) { notice(t('Permission denied.') . EOL); return; } if (argc() < 3) { notice(t('Invalid item.') . EOL); return; } $channel_address = argv(1); $page_id = argv(2); $u = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($channel_address)); if (!$u) { notice(t('Channel not found.') . EOL); return; } if ($_REQUEST['rev']) { $revision = " and revision = " . intval($_REQUEST['rev']) . " "; } else { $revision = " order by revision desc "; } require_once 'include/security.php'; $sql_options = item_permissions_sql($u[0]['channel_id']); $r = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$sql_options} {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE)); if (!$r) { // Check again with no permissions clause to see if it is a permissions issue $x = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE)); if ($x) { // Yes, it's there. You just aren't allowed to see it. notice(t('Permission denied.') . EOL); } else { notice(t('Page not found.') . EOL); } return; } if ($r[0]['layout_mid']) { $l = q("select body from item where mid = '%s' and uid = %d limit 1", dbesc($r[0]['layout_mid']), intval($u[0]['channel_id'])); if ($l) { require_once 'include/comanche.php'; comanche_parser(get_app(), $l[0]['body']); } } // logger('layout: ' . print_r($a->layout,true)); // Use of widgets should be determined by Comanche, but we don't have it on system pages yet, so... if ($perms['write_pages']) { $chan = $a->channel['channel_id']; $who = $channel_address; $which = $r[0]['id']; $o .= writepages_widget($who, $which); } xchan_query($r); $r = fetch_post_tags($r, true); $o .= prepare_page($r[0]); return $o; }
public function get_template_file($file, $root = '') { $a = get_app(); $template_file = get_template_file($a, SMARTY3_TEMPLATE_FOLDER . '/' . $file, $root); $template = new FriendicaSmarty(); $template->filename = $template_file; return $template; }
function view($unit_id) { $app = get_app(); $unit = Unit::find_by_id($unit_id); if ($unit) { $app->render('Units/view.php', compact('unit')); } }
function page_init(&$a) { // We need this to make sure the channel theme is always loaded. $which = argv(1); $profile = 0; profile_load($a, $which, $profile); if ($a->profile['profile_uid']) { head_set_icon($a->profile['thumb']); } // load the item here in the init function because we need to extract // the page layout and initialise the correct theme. $observer = $a->get_observer(); $ob_hash = $observer ? $observer['xchan_hash'] : ''; $perms = get_all_perms($a->profile['profile_uid'], $ob_hash); if (!$perms['view_pages']) { notice(t('Permission denied.') . EOL); return; } if (argc() < 3) { notice(t('Invalid item.') . EOL); return; } $channel_address = argv(1); $page_id = argv(2); $u = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($channel_address)); if (!$u) { notice(t('Channel not found.') . EOL); return; } if ($_REQUEST['rev']) { $revision = " and revision = " . intval($_REQUEST['rev']) . " "; } else { $revision = " order by revision desc "; } require_once 'include/security.php'; $sql_options = item_permissions_sql($u[0]['channel_id']); $r = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$sql_options} {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE)); if (!$r) { // Check again with no permissions clause to see if it is a permissions issue $x = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE)); if ($x) { // Yes, it's there. You just aren't allowed to see it. notice(t('Permission denied.') . EOL); } else { notice(t('Page not found.') . EOL); } return; } if ($r[0]['layout_mid']) { $l = q("select body from item where mid = '%s' and uid = %d limit 1", dbesc($r[0]['layout_mid']), intval($u[0]['channel_id'])); if ($l) { require_once 'include/comanche.php'; comanche_parser(get_app(), $l[0]['body']); get_app()->pdl = $l[0]['body']; } } $a->data['webpage'] = $r; }
function Markdown($text) { $a = get_app(); $stamp1 = microtime(true); # Read file and pass content through the Markdown parser $html = MarkdownExtra::defaultTransform($text); $a->save_timestamp($stamp1, "parser"); return $html; }
public function getKey($key) { $prefix = self::DEFAULT_KEY_PREFIX; $config = get_app()->config(); if (!empty($config['cache']['prefix'])) { $prefix = $config['cache']['prefix']; } return $prefix . '_' . $key; }
function lookup_consumer($consumer_key) { logger('consumer_key: ' . $consumer_key, LOGGER_DEBUG); $r = q("SELECT client_id, pw, redirect_uri FROM clients WHERE client_id = '%s'", dbesc($consumer_key)); if ($r) { get_app()->set_oauth_key($consumer_key); return new OAuth1Consumer($r[0]['client_id'], $r[0]['pw'], $r[0]['redirect_uri']); } return null; }
function get_post($field, $default = '') { $app = get_app(); $value = $app->request()->post($field); if ($value == '') { return $default; } else { return $value; } }
function get_root($with_domain = false) { $app = get_app(); $path = $app->request()->getRootUri(); if ($with_domain) { return 'http://' . $_SERVER['SERVER_NAME'] . $path; } else { return $path; } }
function ostatus_subscribe_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED } $o = "<h2>" . t("Subsribing to OStatus contacts") . "</h2>"; $uid = local_user(); $a = get_app(); $counter = intval($_REQUEST['counter']); if (get_pconfig($uid, "ostatus", "legacy_friends") == "") { if ($_REQUEST["url"] == "") { return $o . t("No contact provided."); } $contact = probe_url($_REQUEST["url"]); if (!$contact) { return $o . t("Couldn't fetch information for contact."); } $api = $contact["baseurl"] . "/api/"; // Fetching friends $data = z_fetch_url($api . "statuses/friends.json?screen_name=" . $contact["nick"]); if (!$data["success"]) { return $o . t("Couldn't fetch friends for contact."); } set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]); } $friends = json_decode(get_pconfig($uid, "ostatus", "legacy_friends")); $total = sizeof($friends); if ($counter >= $total) { $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . $a->get_baseurl() . '/settings/connectors">'; del_pconfig($uid, "ostatus", "legacy_friends"); del_pconfig($uid, "ostatus", "legacy_contact"); $o .= t("Done"); return $o; } $friend = $friends[$counter++]; $url = $friend->statusnet_profile_url; $o .= "<p>" . $counter . "/" . $total . ": " . $url; $data = probe_url($url); if ($data["network"] == NETWORK_OSTATUS) { $result = new_contact($uid, $url, true); if ($result["success"]) { $o .= " - " . t("success"); } else { $o .= " - " . t("failed"); } } else { $o .= " - " . t("ignored"); } $o .= "</p>"; $o .= "<p>" . t("Keep this window open until done.") . "</p>"; $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . $a->get_baseurl() . '/ostatus_subscribe?counter=' . $counter . '">'; return $o; }
function get_theme_config_file($theme) { $base_theme = get_app()->theme_info['extends']; if (file_exists("view/theme/{$theme}/php/config.php")) { return "view/theme/{$theme}/php/config.php"; } if (file_exists("view/theme/{$base_theme}/php/config.php")) { return "view/theme/{$base_theme}/php/config.php"; } return null; }
function cal_content() { $a = get_app(); $o = ""; if ($a->argc == 1) { $o .= "<h3>" . t('Event Export') . "</h3><p>" . t('You can download public events from: ') . $a->get_baseurl() . "/cal/username/export/ical</p>"; } elseif ($a->argc == 4) { // get the parameters from the request we just received $username = $a->argv[1]; $do = $a->argv[2]; $format = $a->argv[3]; // check that there is a user matching the requested profile $r = q("SELECT uid FROM user WHERE nickname='" . $username . "' LIMIT 1;"); if (count($r)) { $uid = $r[0]['uid']; } else { killme(); } // if we shall do anything other then export, end here if (!$do == 'export') { killme(); } // check if the user allows us to share the profile $enable = get_pconfig($uid, 'cal', 'enable'); if (!$enable == 1) { info(t('The user does not export the calendar.')); return; } // we are allowed to show events // get the timezone the user is in $r = q("SELECT timezone FROM user WHERE uid=" . $uid . " LIMIT 1;"); if (count($r)) { $timezone = $r[0]['timezone']; } // does the user who requests happen to be the owner of the events // requested? then show all of your events, otherwise only those that // don't have limitations set in allow_cid and allow_gid if (local_user() == $uid) { $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location` FROM `event` WHERE `uid`=" . $uid . " and `cid`=0;"); } else { $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location` FROM `event` WHERE `allow_cid`='' and `allow_gid`='' and `uid`='" . $uid . "' and `cid`='0';"); } // we have the events that are available for the requestor // now format the output according to the requested format $res = cal_format_output($r, $format, $timezone); if (!$res == '') { info($res); } } else { // wrong number of parameters killme(); } return $o; }
function deliver_hooks_run($argv, $argc) { cli_startup(); $a = get_app(); if ($argc < 2) { return; } $r = q("select * from item where id = '%d'", intval($argv[1])); if ($r) { call_hooks('notifier_normal', $r[0]); } }
function rename($folder_id) { $app = get_app(); $name = $app->request()->post('name'); if ($name) { $folder = Folder::find_by_id($folder_id); if ($folder) { $folder->name = $name; $folder->save(); } } }
function findpeople_widget() { $a = get_app(); $inv = $a->config['register_policy'] != REGISTER_CLOSED ? t('Invite Friends') : ''; if (get_config('system', 'invitation_only')) { $x = get_pconfig(local_user(), 'system', 'invites_remaining'); if ($x || is_site_admin()) { $a->page['aside'] .= '<div class="side-link" id="side-invite-remain">' . sprintf(tt('%d invitation available', '%d invitations available', $x), $x) . '</div>' . $inv; } } return replace_macros(get_markup_template('peoplefind.tpl'), array('$findpeople' => t('Find People'), '$desc' => t('Enter name or interest'), '$label' => t('Connect/Follow'), '$hint' => t('Examples: Robert Morgenstein, Fishing'), '$findthem' => t('Find'), '$suggest' => t('Friend Suggestions'), '$similar' => t('Similar Interests'), '$inv' => $inv)); }
function execute($app, $action) { //传递进来的参数为空的话,才去获取URL的地址 if (empty($app)) { $app = get_app(); } if (empty($action)) { $action = get_action(); } $new_action = $action . '_Action'; $ac = new $new_action(); $ac->execute(); }
function update_threads_mention() { $a = get_app(); $users = q("SELECT `uid`, `nickname` FROM `user` ORDER BY `uid`"); foreach ($users as $user) { $self = normalise_link($a->get_baseurl() . '/profile/' . $user['nickname']); $selfhttps = str_replace("http://", "https://", $self); $parents = q("SELECT DISTINCT(`parent`) FROM `item` WHERE `uid` = %d AND\n\t\t\t\t((`owner-link` IN ('%s', '%s')) OR (`author-link` IN ('%s', '%s')))", $user["uid"], $self, $selfhttps, $self, $selfhttps); foreach ($parents as $parent) { q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", $parent["parent"]); } } }
function deliver_run($argv, $argc) { cli_startup(); $a = get_app(); if ($argc < 2) { return; } logger('deliver: invoked: ' . print_r($argv, true), LOGGER_DATA); for ($x = 1; $x < $argc; $x++) { $dresult = null; $r = q("select * from outq where outq_hash = '%s' limit 1", dbesc($argv[$x])); if ($r) { $notify = json_decode($r[0]['outq_notify'], true); // Messages without an outq_msg will need to go via the web, even if it's a // local delivery. This includes conversation requests and refresh packets. if ($r[0]['outq_posturl'] === z_root() . '/post' && $r[0]['outq_msg']) { logger('deliver: local delivery', LOGGER_DEBUG); // local delivery // we should probably batch these and save a few delivery processes if ($r[0]['outq_msg']) { $m = json_decode($r[0]['outq_msg'], true); if (array_key_exists('message_list', $m)) { foreach ($m['message_list'] as $mm) { $msg = array('body' => json_encode(array('success' => true, 'pickup' => array(array('notify' => $notify, 'message' => $mm))))); zot_import($msg, z_root()); } } else { $msg = array('body' => json_encode(array('success' => true, 'pickup' => array(array('notify' => $notify, 'message' => $m))))); $dresult = zot_import($msg, z_root()); } remove_queue_item($r[0]['outq_hash']); if ($dresult && is_array($dresult)) { foreach ($dresult as $xx) { if (is_array($xx) && array_key_exists('message_id', $xx)) { if (delivery_report_is_storable($xx)) { q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", dbesc($xx['message_id']), dbesc($xx['location']), dbesc($xx['recipient']), dbesc($xx['status']), dbesc(datetime_convert($xx['date'])), dbesc($xx['sender'])); } } } } q("delete from dreport where dreport_queue = '%s'", dbesc($argv[$x])); } } // otherwise it's a remote delivery - call queue_deliver(); queue_deliver($r[0], true); } } }
function load_doc_file($s) { $lang = get_app()->language; if (!isset($lang)) { $lang = 'en'; } $b = basename($s); $d = dirname($s); if (file_exists("{$d}/{$lang}/{$b}")) { return file_get_contents("{$d}/{$lang}/{$b}"); } if (file_exists($s)) { return file_get_contents($s); } return ''; }