本文整理汇总了PHP中App::get_baseurl方法的典型用法代码示例。如果您正苦于以下问题:PHP App::get_baseurl方法的具体用法?PHP App::get_baseurl怎么用?PHP App::get_baseurl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::get_baseurl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fbrowser_content
/**
* @param App $a
*/
function fbrowser_content($a)
{
if (!local_user()) {
killme();
}
if ($a->argc == 1) {
killme();
}
//echo "<pre>"; var_dump($a->argv); killme();
switch ($a->argv[1]) {
case "image":
$path = array(array($a->get_baseurl() . "/fbrowser/image/", t("Photos")));
$albums = false;
$sql_extra = "";
$sql_extra2 = " ORDER BY created DESC LIMIT 0, 10";
if ($a->argc == 2) {
$albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d ", intval(local_user()));
// anon functions only from 5.3.0... meglio tardi che mai..
function folder1($el)
{
return array(bin2hex($el['album']), $el['album']);
}
$albums = array_map("folder1", $albums);
}
$album = "";
if ($a->argc == 3) {
$album = hex2bin($a->argv[2]);
$sql_extra = sprintf("AND `album` = '%s' ", dbesc($album));
$sql_extra2 = "";
$path[] = array($a->get_baseurl() . "/fbrowser/image/" . $a->argv[2] . "/", $album);
}
$r = q("SELECT `resource-id`, `id`, `filename`, min(`scale`) AS `hiq`,max(`scale`) AS `loq`, `desc` \n\t\t\t\t\tFROM `photo` WHERE `uid` = %d {$sql_extra}\n\t\t\t\t\tGROUP BY `resource-id` {$sql_extra2}", intval(local_user()));
function files1($rr)
{
global $a;
return array($a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['hiq'] . '.jpg', template_escape($rr['filename']), $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.jpg');
}
$files = array_map("files1", $r);
$tpl = get_markup_template("filebrowser.tpl");
echo replace_macros($tpl, array('$type' => 'image', '$baseurl' => $a->get_baseurl(), '$path' => $path, '$folders' => $albums, '$files' => $files));
break;
case "file":
if ($a->argc == 2) {
$files = q("SELECT id, filename, filetype FROM `attach` WHERE `uid` = %d ", intval(local_user()));
function files2($rr)
{
global $a;
list($m1, $m2) = explode("/", $rr['filetype']);
$filetype = file_exists("images/icons/{$m1}.png") ? $m1 : "zip";
return array($a->get_baseurl() . '/attach/' . $rr['id'], template_escape($rr['filename']), $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
}
$files = array_map("files2", $files);
//echo "<pre>"; var_dump($files); killme();
$tpl = get_markup_template("filebrowser.tpl");
echo replace_macros($tpl, array('$type' => 'file', '$baseurl' => $a->get_baseurl(), '$path' => array(array($a->get_baseurl() . "/fbrowser/image/", t("Files"))), '$folders' => false, '$files' => $files));
}
break;
}
killme();
}
示例2: z_root
/**
* @brief Returns the baseurl.
*
* @see App::get_baseurl()
*
* @return string
*/
function z_root()
{
return App::get_baseurl();
}
示例3: admin_page_logs
/**
* @brief Logs admin page.
*
* @param App $a
* @return string
*/
function admin_page_logs(&$a)
{
$log_choices = array(LOGGER_NORMAL => 'Normal', LOGGER_TRACE => 'Trace', LOGGER_DEBUG => 'Debug', LOGGER_DATA => 'Data', LOGGER_ALL => 'All');
$t = get_markup_template('admin_logs.tpl');
$f = get_config('system', 'logfile');
$data = '';
if (!file_exists($f)) {
$data = t("Error trying to open <strong>{$f}</strong> log file.\r\n<br/>Check to see if file {$f} exist and is \nreadable.");
} else {
$fp = fopen($f, 'r');
if (!$fp) {
$data = t("Couldn't open <strong>{$f}</strong> log file.\r\n<br/>Check to see if file {$f} is readable.");
} else {
$fstat = fstat($fp);
$size = $fstat['size'];
if ($size != 0) {
if ($size > 5000000 || $size < 0) {
$size = 5000000;
}
$seek = fseek($fp, 0 - $size, SEEK_END);
if ($seek === 0) {
$data = escape_tags(fread($fp, $size));
while (!feof($fp)) {
$data .= escape_tags(fread($fp, 4096));
}
}
}
fclose($fp);
}
}
return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Logs'), '$submit' => t('Submit'), '$clear' => t('Clear'), '$data' => $data, '$baseurl' => $a->get_baseurl(true), '$logname' => get_config('system', 'logfile'), '$debugging' => array('debugging', t("Debugging"), get_config('system', 'debugging'), ""), '$logfile' => array('logfile', t("Log file"), get_config('system', 'logfile'), t("Must be writable by web server. Relative to your Red top-level directory.")), '$loglevel' => array('loglevel', t("Log level"), get_config('system', 'loglevel'), "", $log_choices), '$form_security_token' => get_form_security_token('admin_logs')));
}
示例4: fbpost_post_hook
/**
* @param App $a
* @param object $b
* @return mixed
*/
function fbpost_post_hook(&$a, &$b)
{
logger('fbpost_post_hook: Facebook post invoked', LOGGER_DEBUG);
if ($b['deleted'] || $b['created'] !== $b['edited']) {
return;
}
logger('fbpost_post_hook: Facebook post first check successful', LOGGER_DEBUG);
// if post comes from facebook don't send it back
if ($b['extid'] == NETWORK_FACEBOOK) {
return;
}
if ($b['app'] == "Facebook" and $b['verb'] != ACTIVITY_LIKE) {
return;
}
logger('fbpost_post_hook: Facebook post accepted', LOGGER_DEBUG);
/**
* Post to Facebook stream
*/
require_once 'include/group.php';
require_once 'include/html2plain.php';
$reply = false;
$likes = false;
$deny_arr = array();
$allow_arr = array();
$toplevel = $b['id'] == $b['parent'] ? true : false;
$linking = get_pconfig($b['uid'], 'facebook', 'no_linking') ? 0 : 1;
if (!$toplevel && $linking) {
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($b['parent']), intval($b['uid']));
//$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
// dbesc($b['parent-uri']),
// intval($b['uid'])
//);
// is it a reply to a facebook post?
// A reply to a toplevel post is only allowed for "real" facebook posts
if (count($r) && substr($r[0]['uri'], 0, 4) === 'fb::') {
$reply = substr($r[0]['uri'], 4);
} elseif (count($r) && substr($r[0]['extid'], 0, 4) === 'fb::' and $r[0]['id'] != $r[0]['parent']) {
$reply = substr($r[0]['extid'], 4);
} else {
return;
}
$u = q("SELECT * FROM user where uid = %d limit 1", intval($b['uid']));
if (!count($u)) {
return;
}
// only accept comments from the item owner. Other contacts are unknown to FB.
if (!link_compare($b['author-link'], $a->get_baseurl() . '/profile/' . $u[0]['nickname'])) {
return;
}
logger('fbpost_post_hook: facebook reply id=' . $reply);
}
if (strstr($b['postopts'], 'facebook') || $b['private'] || $reply) {
if ($b['private'] && $reply === false) {
$allow_people = expand_acl($b['allow_cid']);
$allow_groups = expand_groups(expand_acl($b['allow_gid']));
$deny_people = expand_acl($b['deny_cid']);
$deny_groups = expand_groups(expand_acl($b['deny_gid']));
$recipients = array_unique(array_merge($allow_people, $allow_groups));
$deny = array_unique(array_merge($deny_people, $deny_groups));
$allow_str = dbesc(implode(', ', $recipients));
if ($allow_str) {
logger("fbpost_post_hook: private post to: " . $allow_str, LOGGER_DEBUG);
$r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( {$allow_str} ) AND `network` = 'face'");
if (count($r)) {
foreach ($r as $rr) {
$allow_arr[] = $rr['notify'];
}
}
}
$deny_str = dbesc(implode(', ', $deny));
if ($deny_str) {
$r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( {$deny_str} ) AND `network` = 'face'");
if (count($r)) {
foreach ($r as $rr) {
$deny_arr[] = $rr['notify'];
}
}
}
if (count($deny_arr) && !count($allow_arr)) {
// One or more FB folks were denied access but nobody on FB was specifically allowed access.
// This might cause the post to be open to public on Facebook, but only to selected members
// on another network. Since this could potentially leak a post to somebody who was denied,
// we will skip posting it to Facebook with a slightly vague but relevant message that will
// hopefully lead somebody to this code comment for a better explanation of what went wrong.
notice(t('Post to Facebook cancelled because of multi-network access permission conflict.') . EOL);
return;
}
// if it's a private message but no Facebook members are allowed or denied, skip Facebook post
if (!count($allow_arr) && !count($deny_arr)) {
return;
}
}
if ($b['verb'] == ACTIVITY_LIKE) {
$likes = true;
logger('fbpost_post_hook: liking ' . print_r($b, true), LOGGER_DEBUG);
//.........这里部分代码省略.........
示例5: z_root
/**
* @brief Returns the baseurl.
*
* @see App::get_baseurl()
*
* @return string
*/
function z_root()
{
global $a;
return App::get_baseurl();
}
示例6: profile_tabs
/**
* @brief
*
* @param App $a
* @param boolean $is_owner default false
* @param string $nickname default null
* @return void|string
*/
function profile_tabs($a, $is_owner = false, $nickname = null)
{
// Don't provide any profile tabs if we're running as the sys channel
if ($a->is_sys) {
return;
}
$channel = $a->get_channel();
if (is_null($nickname)) {
$nickname = $channel['channel_address'];
}
$uid = $a->profile['profile_uid'] ? $a->profile['profile_uid'] : local_channel();
if (get_pconfig($uid, 'system', 'noprofiletabs')) {
return;
}
if (x($_GET, 'tab')) {
$tab = notags(trim($_GET['tab']));
}
$url = $a->get_baseurl() . '/channel/' . $nickname;
$pr = $a->get_baseurl() . '/profile/' . $nickname;
$tabs = array(array('label' => t('Channel'), 'url' => $url, 'sel' => argv(0) == 'channel' ? 'active' : '', 'title' => t('Status Messages and Posts'), 'id' => 'status-tab'));
$p = get_all_perms($uid, get_observer_hash());
if ($p['view_profile']) {
$tabs[] = array('label' => t('About'), 'url' => $pr, 'sel' => argv(0) == 'profile' ? 'active' : '', 'title' => t('Profile Details'), 'id' => 'profile-tab');
}
if ($p['view_photos']) {
$tabs[] = array('label' => t('Photos'), 'url' => $a->get_baseurl() . '/photos/' . $nickname, 'sel' => argv(0) == 'photos' ? 'active' : '', 'title' => t('Photo Albums'), 'id' => 'photo-tab');
}
if ($p['view_storage']) {
$tabs[] = array('label' => t('Files'), 'url' => $a->get_baseurl() . '/cloud/' . $nickname . (get_observer_hash() ? '' : '?f=&davguest=1'), 'sel' => argv(0) == 'cloud' || argv(0) == 'sharedwithme' ? 'active' : '', 'title' => t('Files and Storage'), 'id' => 'files-tab');
}
if ($p['chat']) {
require_once 'include/chat.php';
$has_chats = chatroom_list_count($uid);
if ($has_chats) {
$tabs[] = array('label' => t('Chatrooms'), 'url' => $a->get_baseurl() . '/chat/' . $nickname, 'sel' => argv(0) == 'chat' ? 'active' : '', 'title' => t('Chatrooms'), 'id' => 'chat-tab');
}
}
require_once 'include/menu.php';
$has_bookmarks = menu_list_count(local_channel(), '', MENU_BOOKMARK) + menu_list_count(local_channel(), '', MENU_SYSTEM | MENU_BOOKMARK);
if ($is_owner && $has_bookmarks) {
$tabs[] = array('label' => t('Bookmarks'), 'url' => $a->get_baseurl() . '/bookmarks', 'sel' => argv(0) == 'bookmarks' ? 'active' : '', 'title' => t('Saved Bookmarks'), 'id' => 'bookmarks-tab');
}
if ($is_owner && feature_enabled($uid, 'webpages')) {
$tabs[] = array('label' => t('Webpages'), 'url' => $a->get_baseurl() . '/webpages/' . $nickname, 'sel' => argv(0) == 'webpages' ? 'active' : '', 'title' => t('Manage Webpages'), 'id' => 'webpages-tab');
} else {
/**
* @FIXME we probably need a listing of events that were created by
* this channel and are visible to the observer
*/
}
$arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab ? $tab : false, 'tabs' => $tabs);
call_hooks('profile_tabs', $arr);
$tpl = get_markup_template('common_tabs.tpl');
return replace_macros($tpl, array('$tabs' => $arr['tabs']));
}
示例7: handle_tag
/**
* @brief This function removes the tag $tag from the text $body and replaces it
* with the appropiate link.
*
* @param App $a
* @param[in,out] string &$body the text to replace the tag in
* @param[in,out] string &$access_tag used to return tag ACL exclusions e.g. @!foo
* @param[in,out] string &$str_tags string to add the tag to
* @param int $profile_uid
* @param string $tag the tag to replace
* @param boolean $diaspora default false
* @return boolean true if replaced, false if not replaced
*/
function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $diaspora = false)
{
$replaced = false;
$r = null;
$match = array();
$termtype = strpos($tag, '#') === 0 ? TERM_HASHTAG : TERM_UNKNOWN;
$termtype = strpos($tag, '@') === 0 ? TERM_MENTION : $termtype;
$termtype = strpos($tag, '#^[') === 0 ? TERM_BOOKMARK : $termtype;
//is it a hash tag?
if (strpos($tag, '#') === 0) {
if (strpos($tag, '#^[') === 0) {
if (preg_match('/#\\^\\[(url|zrl)(.*?)\\](.*?)\\[\\/(url|zrl)\\]/', $tag, $match)) {
$basetag = $match[3];
$url = substr($match[2], 0, 1) === '=' ? substr($match[2], 1) : $match[3];
$replaced = true;
}
} elseif (strpos($tag, '[zrl=') || strpos($tag, '[url=')) {
//...do nothing
return $replaced;
}
if ($tag == '#getzot') {
$basetag = 'getzot';
$url = 'http://hubzilla.org';
$newtag = '#[zrl=' . $url . ']' . $basetag . '[/zrl]';
$body = str_replace($tag, $newtag, $body);
$replaced = true;
}
if (!$replaced) {
//base tag has the tags name only
if (substr($tag, 0, 7) === '#"' && substr($tag, -6, 6) === '"') {
$basetag = substr($tag, 7);
$basetag = substr($basetag, 0, -6);
} else {
$basetag = str_replace('_', ' ', substr($tag, 1));
}
//create text for link
$url = $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag);
$newtag = '#[zrl=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/zrl]';
//replace tag by the link. Make sure to not replace something in the middle of a word
// The '=' is needed to not replace color codes if the code is also used as a tag
// Much better would be to somehow completely avoiding things in e.g. [color]-tags.
// This would allow writing things like "my favourite tag=#foobar".
$body = preg_replace('/(?<![a-zA-Z0-9=])' . preg_quote($tag, '/') . '/', $newtag, $body);
$replaced = true;
}
//is the link already in str_tags?
if (!stristr($str_tags, $newtag)) {
//append or set str_tags
if (strlen($str_tags)) {
$str_tags .= ',';
}
$str_tags .= $newtag;
}
return array('replaced' => $replaced, 'termtype' => $termtype, 'term' => $basetag, 'url' => $url, 'contact' => $r[0]);
}
//is it a person tag?
if (strpos($tag, '@') === 0) {
// The @! tag will alter permissions
$exclusive = strpos($tag, '!') === 1 && !$diaspora ? true : false;
//is it already replaced?
if (strpos($tag, '[zrl=')) {
return $replaced;
}
//get the person's name
$name = substr($tag, $exclusive ? 2 : 1);
// The name or name fragment we are going to replace
$newname = $name;
// a copy that we can mess with
$tagcid = 0;
$r = null;
// is it some generated name?
$forum = false;
$trailing_plus_name = false;
// @channel+ is a forum or network delivery tag
if (substr($newname, -1, 1) === '+') {
$forum = true;
$newname = substr($newname, 0, -1);
}
// Here we're looking for an address book entry as provided by the auto-completer
// of the form something+nnn where nnn is an abook_id or the first chars of xchan_hash
// If there's a +nnn in the string make sure there isn't a space preceding it
$t1 = strpos($newname, ' ');
$t2 = strrpos($newname, '+');
if ($t1 && $t2 && $t1 < $t2) {
$t2 = 0;
}
if ($t2 && !$diaspora) {
//.........这里部分代码省略.........
示例8: map_content
function map_content($a)
{
if (argc() > 1 && argv(1) === 'import') {
logger('map import launching');
return map_import($a);
}
//$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/map/map.css' . '" media="all" />' . "\r\n";
head_add_css('/addon/map/view/css/map.css');
// $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
// '$baseurl' => $a->get_baseurl(),
// '$editselect' => 'none',
// '$ispublic' => ' ', // t('Visible to <strong>everybody</strong>'),
// '$geotag' => '',
// '$nickname' => $channel['channel_address'],
// '$confirmdelete' => t('Delete webpage?')
// ));
if ($_SESSION['data_cache'] !== null) {
$data_cache = json_encode($_SESSION['data_cache']);
} else {
$data_cache = '';
}
$o .= replace_macros(get_markup_template('map.tpl', 'addon/map'), array('$header' => t('Map'), '$text' => $text, '$data_cache' => $data_cache, '$loginbox' => login()));
$o .= '<script type="text/javascript" src="' . App::get_baseurl() . '/addon/map/view/js/underscore-min.js"></script>' . "\r\n";
$o .= '<script type="text/javascript" src="' . App::get_baseurl() . '/addon/map/view/js/backbone-min.js"></script>' . "\r\n";
$o .= '<script type="text/javascript" src="' . App::get_baseurl() . '/addon/map/view/js/ol.js"></script>' . "\r\n";
$o .= '<script type="text/javascript" src="' . App::get_baseurl() . '/addon/map/view/js/map.js?version=' . map_get_version() . '"></script>' . "\r\n";
return $o;
}
示例9: privacy_image_cache_ping_xmlize_hook
/**
* @param App $a
* @param string $o
*/
function privacy_image_cache_ping_xmlize_hook(&$a, &$o)
{
if ($o["photo"] != "" && !privacy_image_cache_is_local_image($o["photo"])) {
$o["photo"] = $a->get_baseurl() . "/privacy_image_cache/?url=" . escape_tags(addslashes(rawurlencode($o["photo"])));
}
}
示例10: dbesc
$recipients = array_diff($recipients, $deny);
$conversant_str = dbesc(implode(', ', $conversants));
}
$r = q("SELECT * FROM `contact` WHERE `id` IN ( {$conversant_str} ) AND `blocked` = 0 AND `pending` = 0");
if (!count($r)) {
killme();
}
$contacts = $r;
$tomb_template = file_get_contents('view/atom_tomb.tpl');
$item_template = file_get_contents('view/atom_item.tpl');
$cmnt_template = file_get_contents('view/atom_cmnt.tpl');
}
$feed_template = file_get_contents('view/atom_feed.tpl');
$mail_template = file_get_contents('view/atom_mail.tpl');
$atom = '';
$atom .= replace_macros($feed_template, array('$feed_id' => xmlify($a->get_baseurl()), '$feed_title' => xmlify($owner['name']), '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00', 'Y-m-d\\TH:i:s\\Z')), '$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), '$photo' => xmlify($owner['photo']), '$thumb' => xmlify($owner['thumb']), '$picdate' => xmlify(datetime_convert('UTC', 'UTC', $owner['avatar-date'] . '+00:00', 'Y-m-d\\TH:i:s\\Z')), '$uridate' => xmlify(datetime_convert('UTC', 'UTC', $owner['uri-date'] . '+00:00', 'Y-m-d\\TH:i:s\\Z')), '$namdate' => xmlify(datetime_convert('UTC', 'UTC', $owner['name-date'] . '+00:00', 'Y-m-d\\TH:i:s\\Z'))));
if ($cmd == 'mail') {
$atom .= replace_macros($mail_template, array('$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), '$thumb' => xmlify($owner['thumb']), '$item_id' => xmlify($item['uri']), '$subject' => xmlify($item['title']), '$created' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00', 'Y-m-d\\TH:i:s\\Z')), '$content' => xmlify($item['body']), '$parent_id' => xmlify($item['parent-uri'])));
} else {
if ($followup) {
foreach ($items as $item) {
if ($item['id'] == $item_id) {
$atom .= replace_macros($cmnt_template, array('$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), '$thumb' => xmlify($owner['thumb']), '$item_id' => xmlify($item['uri']), '$title' => xmlify($item['title']), '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00', 'Y-m-d\\TH:i:s\\Z')), '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00', 'Y-m-d\\TH:i:s\\Z')), '$content' => xmlify($item['body']), '$parent_id' => xmlify($item['parent-uri']), '$comment_allow' => 0));
}
}
} else {
foreach ($items as $item) {
if ($item['deleted']) {
$atom .= replace_macros($tomb_template, array('$id' => xmlify($item['uri']), '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00', 'Y-m-d\\TH:i:s\\Z'))));
} else {
foreach ($contacts as $contact) {
示例11: fbrowser_content
/**
* @param App $a
*/
function fbrowser_content($a)
{
if (!local_user()) {
killme();
}
if ($a->argc == 1) {
killme();
}
$template_file = "filebrowser.tpl";
$mode = "";
if (x($_GET, 'mode')) {
$template_file = "filebrowser_plain.tpl";
$mode = "?mode=" . $_GET['mode'];
}
//echo "<pre>"; var_dump($a->argv); killme();
switch ($a->argv[1]) {
case "image":
$path = array(array("", t("Photos")));
$albums = false;
$sql_extra = "";
$sql_extra2 = " ORDER BY created DESC LIMIT 0, 10";
if ($a->argc == 2) {
$albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d ", intval(local_user()));
// anon functions only from 5.3.0... meglio tardi che mai..
$folder1 = function ($el) use($mode) {
return array(bin2hex($el['album']), $el['album']);
};
$albums = array_map($folder1, $albums);
}
$album = "";
if ($a->argc == 3) {
$album = hex2bin($a->argv[2]);
$sql_extra = sprintf("AND `album` = '%s' ", dbesc($album));
$sql_extra2 = "";
$path[] = array($a->argv[2], $album);
}
$r = q("SELECT `resource-id`, `id`, `filename`, type, min(`scale`) AS `hiq`,max(`scale`) AS `loq`, `desc`\n\t\t\t\t\tFROM `photo` WHERE `uid` = %d {$sql_extra}\n\t\t\t\t\tGROUP BY `resource-id` {$sql_extra2}", intval(local_user()));
function files1($rr)
{
global $a;
$types = Photo::supportedTypes();
$ext = $types[$rr['type']];
if ($a->theme['template_engine'] === 'internal') {
$filename_e = template_escape($rr['filename']);
} else {
$filename_e = $rr['filename'];
}
return array($a->get_baseurl() . '/photo/' . $rr['resource-id'] . '.' . $ext, $filename_e, $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.' . $ext);
}
$files = array_map("files1", $r);
$tpl = get_markup_template($template_file);
$o = replace_macros($tpl, array('$type' => 'image', '$baseurl' => $a->get_baseurl(), '$path' => $path, '$folders' => $albums, '$files' => $files, '$cancel' => t('Cancel'), '$nickname' => $a->user['nickname']));
break;
case "file":
if ($a->argc == 2) {
$files = q("SELECT id, filename, filetype FROM `attach` WHERE `uid` = %d ", intval(local_user()));
function files2($rr)
{
global $a;
list($m1, $m2) = explode("/", $rr['filetype']);
$filetype = file_exists("images/icons/{$m1}.png") ? $m1 : "zip";
if ($a->theme['template_engine'] === 'internal') {
$filename_e = template_escape($rr['filename']);
} else {
$filename_e = $rr['filename'];
}
return array($a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
}
$files = array_map("files2", $files);
//echo "<pre>"; var_dump($files); killme();
$tpl = get_markup_template($template_file);
$o = replace_macros($tpl, array('$type' => 'file', '$baseurl' => $a->get_baseurl(), '$path' => array(array("", t("Files"))), '$folders' => false, '$files' => $files, '$cancel' => t('Cancel'), '$nickname' => $a->user['nickname']));
}
break;
}
if (x($_GET, 'mode')) {
return $o;
} else {
echo $o;
killme();
}
}
示例12: wdcal_getSettingsPage
/**
* @param App $a
* @return string
*/
function wdcal_getSettingsPage(&$a)
{
if (!local_user()) {
notice(t('Permission denied.') . EOL);
return '';
}
if (isset($_REQUEST["save"])) {
check_form_security_token_redirectOnErr($a->get_baseurl() . '/dav/settings/', 'calprop');
set_pconfig($a->user["uid"], "dav", "dateformat", $_REQUEST["wdcal_date_format"]);
info(t('The new values have been saved.'));
}
$o = "";
$o .= "<a href='" . $a->get_baseurl() . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
$o .= '<h3>' . t('Calendar Settings') . '</h3>';
$current_format = wdcal_local::getInstanceByUser($a->user["uid"]);
$o .= '<form method="POST" action="' . $a->get_baseurl() . '/dav/settings/">';
$o .= "<input type='hidden' name='form_security_token' value='" . get_form_security_token('calprop') . "'>\n";
$o .= '<label for="wdcal_date_format">' . t('Date format') . ':</label><select name="wdcal_date_format" id="wdcal_date_format" size="1">';
$classes = wdcal_local::getInstanceClasses();
foreach ($classes as $c) {
$o .= '<option value="' . $c::getID() . '" ';
if ($c::getID() == $current_format::getID()) {
$o .= 'selected';
}
$o .= '>' . escape_tags($c::getName()) . '</option>';
}
$o .= '</select><br>';
$o .= '<label for="wdcal_time_zone">' . t('Time zone') . ':</label><input id="wdcal_time_zone" value="' . $a->timezone . '" disabled><br>';
$o .= '<input type="submit" name="save" value="' . t('Save') . '">';
$o .= '</form>';
$o .= "<br><h3>" . t("Limitations") . "</h3>";
$o .= "- The native friendica events are embedded as read-only, half-transparent in the calendar.<br>";
$o .= "<br><h3>" . t("Warning") . "</h3>";
$o .= "This plugin still is in a very early stage of development. Expect major bugs!<br>";
$o .= "<br><h3>" . t("Synchronization (iPhone, Thunderbird Lightning, Android, ...)") . "</h3>";
$o .= 'This plugin enables synchronization of your dates and contacts with CalDAV- and CardDAV-enabled programs or devices.<br>
As an example, the instructions how to set up two-way synchronization with an iPhone/iPodTouch are provided below.<br>
Unfortunately, Android does not have native support for CalDAV or CardDAV, so an app has to be installed.<br>
On desktops, the Lightning-extension to Mozilla Thunderbird should be able to use this plugin as a backend.<br><br>';
$o .= '<h4>' . t('Synchronizing this calendar with the iPhone') . '</h4>';
$o .= "<ul>\n\t<li>Go to the settings</li>\n\t<li>Mail, contacts, settings</li>\n\t<li>Add a new account</li>\n\t<li>Other...</li>\n\t<li>Calendar -> CalDAV-Account</li>\n\t<li><b>Server:</b> " . $a->get_baseurl() . "/dav/ / <b>Username/Password:</b> <em>the same as your friendica-login</em></li>\n\t</ul>";
$o .= '<h4>' . t('Synchronizing your Friendica-Contacts with the iPhone') . '</h4>';
$o .= "<ul>\n\t<li>Go to the settings</li>\n\t<li>Mail, contacts, settings</li>\n\t<li>Add a new account</li>\n\t<li>Other...</li>\n\t<li>Contacts -> CardDAV-Account</li>\n\t<li><b>Server:</b> " . $a->get_baseurl() . "/dav/ / <b>Username/Password:</b> <em>the same as your friendica-login</em></li>\n\t</ul>";
return $o;
}
示例13: fb_consume_like
/**
* @param App $a
* @param array $user
* @param array $self
* @param string $fb_id
* @param bool $wall
* @param array $orig_post
* @param object $likes
*/
function fb_consume_like(&$a, &$user, &$self, $fb_id, $wall, &$orig_post, &$likes)
{
$top_item = $orig_post['id'];
$uid = IntVal($user[0]['uid']);
if (!$orig_post) {
return;
}
// If we posted the like locally, it will be found with our url, not the FB url.
$second_url = $likes->id == $fb_id ? $self[0]['url'] : 'http://facebook.com/profile.php?id=' . $likes->id;
$r = q("SELECT * FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `verb` = '%s'\n \tAND ( `author-link` = '%s' OR `author-link` = '%s' ) LIMIT 1", dbesc($orig_post['uri']), intval($uid), dbesc(ACTIVITY_LIKE), dbesc('http://facebook.com/profile.php?id=' . $likes->id), dbesc($second_url));
if (count($r)) {
return;
}
$likedata = array();
$likedata['parent'] = $top_item;
$likedata['verb'] = ACTIVITY_LIKE;
$likedata['gravity'] = 3;
$likedata['uid'] = $uid;
$likedata['wall'] = $wall ? 1 : 0;
$likedata['uri'] = item_new_uri($a->get_baseurl(), $uid);
$likedata['parent-uri'] = $orig_post['uri'];
if ($likes->id == $fb_id) {
$likedata['contact-id'] = $self[0]['id'];
} else {
$r = q("SELECT * FROM `contact` WHERE `notify` = '%s' AND `uid` = %d AND `blocked` = 0 AND `readonly` = 0 LIMIT 1", dbesc($likes->id), intval($uid));
if (count($r)) {
$likedata['contact-id'] = $r[0]['id'];
}
}
if (!x($likedata, 'contact-id')) {
$likedata['contact-id'] = $orig_post['contact-id'];
}
$likedata['app'] = 'facebook';
$likedata['verb'] = ACTIVITY_LIKE;
$likedata['author-name'] = $likes->name;
$likedata['author-link'] = 'http://facebook.com/profile.php?id=' . $likes->id;
$likedata['author-avatar'] = 'https://graph.facebook.com/' . $likes->id . '/picture';
$author = '[url=' . $likedata['author-link'] . ']' . $likedata['author-name'] . '[/url]';
$objauthor = '[url=' . $orig_post['author-link'] . ']' . $orig_post['author-name'] . '[/url]';
$post_type = t('status');
$plink = '[url=' . $orig_post['plink'] . ']' . $post_type . '[/url]';
$likedata['object-type'] = ACTIVITY_OBJ_NOTE;
$likedata['body'] = sprintf(t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
$likedata['object'] = '<object><type>' . ACTIVITY_OBJ_NOTE . '</type><local>1</local>' . '<id>' . $orig_post['uri'] . '</id><link>' . xmlify('<link rel="alternate" type="text/html" href="' . xmlify($orig_post['plink']) . '" />') . '</link><title>' . $orig_post['title'] . '</title><content>' . $orig_post['body'] . '</content></object>';
item_store($likedata);
}
示例14: wdcal_getSettingsPage
/**
* @param App $a
* @return string
*/
function wdcal_getSettingsPage(&$a)
{
if (!local_user()) {
notice(t('Permission denied.') . EOL);
return '';
}
if (isset($_REQUEST["save"])) {
check_form_security_token_redirectOnErr('/dav/settings/', 'calprop');
set_pconfig($a->user["uid"], "dav", "dateformat", $_REQUEST["wdcal_date_format"]);
info(t('The new values have been saved.'));
}
if (isset($_REQUEST["save_cals"])) {
check_form_security_token_redirectOnErr('/dav/settings/', 'calprop');
$r = q("SELECT * FROM %s%scalendars WHERE `namespace` = " . CALDAV_NAMESPACE_PRIVATE . " AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($a->user["uid"]));
foreach ($r as $cal) {
$backend = wdcal_calendar_factory($cal["namespace"], $cal["namespace_id"], $cal["uri"], $cal);
$change_sql = "";
$col = substr($_REQUEST["color"][$cal["id"]], 1);
if (strtolower($col) != strtolower($cal["calendarcolor"])) {
$change_sql .= ", `calendarcolor` = '" . dbesc($col) . "'";
}
if (!is_subclass_of($backend, "Sabre_CalDAV_Backend_Virtual")) {
if ($_REQUEST["uri"][$cal["id"]] != $cal["uri"]) {
$change_sql .= ", `uri` = '" . dbesc($_REQUEST["uri"][$cal["id"]]) . "'";
}
if ($_REQUEST["name"][$cal["id"]] != $cal["displayname"]) {
$change_sql .= ", `displayname` = '" . dbesc($_REQUEST["name"][$cal["id"]]) . "'";
}
}
if ($change_sql != "") {
q("UPDATE %s%scalendars SET `ctag` = `ctag` + 1 {$change_sql} WHERE `id` = %d AND `namespace_id` = %d AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $cal["id"], CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]));
info(t('The calendar has been updated.'));
}
}
if (isset($_REQUEST["uri"]["new"]) && $_REQUEST["uri"]["new"] != "" && $_REQUEST["name"]["new"] && $_REQUEST["name"]["new"] != "") {
$order = q("SELECT MAX(`calendarorder`) ord FROM %s%scalendars WHERE `namespace_id` = %d AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]));
$neworder = $order[0]["ord"] + 1;
q("INSERT INTO %s%scalendars (`namespace`, `namespace_id`, `calendarorder`, `calendarcolor`, `displayname`, `timezone`, `uri`, `has_vevent`, `ctag`)\n\t\t\t\tVALUES (%d, %d, %d, '%s', '%s', '%s', '%s', 1, 1)", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]), $neworder, dbesc(strtolower(substr($_REQUEST["color"]["new"], 1))), dbesc($_REQUEST["name"]["new"]), dbesc($a->timezone), dbesc($_REQUEST["uri"]["new"]));
info(t('The new calendar has been created.'));
}
}
if (isset($_REQUEST["remove_cal"])) {
check_form_security_token_redirectOnErr('/dav/settings/', 'del_cal', 't');
$c = q("SELECT * FROM %s%scalendars WHERE `id` = %d AND `namespace_id` = %d AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($_REQUEST["remove_cal"]), CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]));
if (count($c) != 1) {
killme();
}
$calobjs = q("SELECT `id` FROM %s%scalendarobjects WHERE `calendar_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($_REQUEST["remove_cal"]));
$newcal = q("SELECT * FROM %s%scalendars WHERE `id` != %d AND `namespace_id` = %d AND `namespace_id` = %d ORDER BY `calendarcolor` LIMIT 0,1", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($_REQUEST["remove_cal"]), CALDAV_NAMESPACE_PRIVATE, IntVal($a->user["uid"]));
if (count($newcal) != 1) {
killme();
}
q("UPDATE %s%scalendarobjects SET `calendar_id` = %d WHERE `calendar_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($newcal[0]["id"]), IntVal($c[0]["id"]));
foreach ($calobjs as $calobj) {
renderCalDavEntry_calobj_id($calobj["id"]);
}
q("DELETE FROM %s%scalendars WHERE `id` = %s", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($_REQUEST["remove_cal"]));
q("UPDATE %s%scalendars SET `ctag` = `ctag` + 1 WHERE `id` = " . CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $newcal[0]["id"]);
info(t('The calendar has been deleted.'));
}
$o = "";
$o .= "<a href='" . $a->get_baseurl() . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
$o .= '<h3>' . t('Calendar Settings') . '</h3>';
$current_format = wdcal_local::getInstanceByUser($a->user["uid"]);
$o .= '<form method="POST" action="' . $a->get_baseurl() . '/dav/settings/">';
$o .= "<input type='hidden' name='form_security_token' value='" . get_form_security_token('calprop') . "'>\n";
$o .= '<label for="wdcal_date_format">' . t('Date format') . ':</label><select name="wdcal_date_format" id="wdcal_date_format" size="1">';
$classes = wdcal_local::getInstanceClasses();
foreach ($classes as $c) {
$o .= '<option value="' . $c::getID() . '" ';
if ($c::getID() == $current_format::getID()) {
$o .= 'selected';
}
$o .= '>' . escape_tags($c::getName()) . '</option>';
}
$o .= '</select><br>';
$o .= '<label for="wdcal_time_zone">' . t('Time zone') . ':</label><input id="wdcal_time_zone" value="' . $a->timezone . '" disabled><br>';
$o .= '<input type="submit" name="save" value="' . t('Save') . '">';
$o .= '</form>';
$o .= '<br><br><h3>' . t('Calendars') . '</h3>';
$o .= '<form method="POST" action="' . $a->get_baseurl() . '/dav/settings/">';
$o .= "<input type='hidden' name='form_security_token' value='" . get_form_security_token('calprop') . "'>\n";
$o .= "<table><tr><th>Type</th><th>Color</th><th>Name</th><th>URI (for CalDAV)</th><th>ICS</th></tr>";
$r = q("SELECT * FROM %s%scalendars WHERE `namespace` = " . CALDAV_NAMESPACE_PRIVATE . " AND `namespace_id` = %d", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($a->user["uid"]));
$private_max = 0;
$num_non_virtual = 0;
foreach ($r as $x) {
$backend = wdcal_calendar_factory($x["namespace"], $x["namespace_id"], $x["uri"], $x);
if (!is_subclass_of($backend, "Sabre_CalDAV_Backend_Virtual")) {
$num_non_virtual++;
}
}
foreach ($r as $x) {
$p = explode("private-", $x["uri"]);
if (count($p) == 2 && $p[1] > $private_max) {
$private_max = $p[1];
//.........这里部分代码省略.........
示例15: delivery_run
//.........这里部分代码省略.........
* permissions issues.
*
*/
if (!$top_level && $parent['wall'] == 0 && !$expire && stristr($target_item['uri'], $localhost)) {
logger('relay denied for delivery agent.');
/* no relay allowed for direct contact delivery */
continue;
}
if (strlen($parent['allow_cid']) || strlen($parent['allow_gid']) || strlen($parent['deny_cid']) || strlen($parent['deny_gid'])) {
$public_message = false;
// private recipients, not public
}
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `blocked` = 0 AND `pending` = 0", intval($contact_id));
if (count($r)) {
$contact = $r[0];
}
$hubxml = feed_hublinks();
logger('notifier: slaps: ' . print_r($slaps, true), LOGGER_DATA);
require_once 'include/salmon.php';
if ($contact['self']) {
continue;
}
$deliver_status = 0;
switch ($contact['network']) {
case NETWORK_DFRN:
logger('notifier: dfrndelivery: ' . $contact['name']);
$feed_template = get_markup_template('atom_feed.tpl');
$mail_template = get_markup_template('atom_mail.tpl');
$atom = '';
$birthday = feed_birthday($owner['uid'], $owner['timezone']);
if (strlen($birthday)) {
$birthday = '<dfrn:birthday>' . xmlify($birthday) . '</dfrn:birthday>';
}
$atom .= replace_macros($feed_template, array('$version' => xmlify(FRIENDICA_VERSION), '$feed_id' => xmlify($a->get_baseurl() . '/profile/' . $owner['nickname']), '$feed_title' => xmlify($owner['name']), '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00', ATOM_TIME)), '$hub' => $hubxml, '$salmon' => '', '$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), '$photo' => xmlify($owner['photo']), '$thumb' => xmlify($owner['thumb']), '$picdate' => xmlify(datetime_convert('UTC', 'UTC', $owner['avatar-date'] . '+00:00', ATOM_TIME)), '$uridate' => xmlify(datetime_convert('UTC', 'UTC', $owner['uri-date'] . '+00:00', ATOM_TIME)), '$namdate' => xmlify(datetime_convert('UTC', 'UTC', $owner['name-date'] . '+00:00', ATOM_TIME)), '$birthday' => $birthday, '$community' => $owner['page-flags'] == PAGE_COMMUNITY ? '<dfrn:community>1</dfrn:community>' : ''));
foreach ($items as $item) {
if (!$item['parent']) {
continue;
}
// private emails may be in included in public conversations. Filter them.
if ($public_message && $item['private'] == 1) {
continue;
}
$item_contact = get_item_contact($item, $icontacts);
if (!$item_contact) {
continue;
}
if ($normal_mode) {
if ($item_id == $item['id'] || $item['id'] == $item['parent']) {
$atom .= atom_entry($item, 'text', null, $owner, true, $top_level ? $contact['id'] : 0);
}
} else {
$atom .= atom_entry($item, 'text', null, $owner, true);
}
}
$atom .= '</feed>' . "\r\n";
logger('notifier: ' . $atom, LOGGER_DATA);
$basepath = implode('/', array_slice(explode('/', $contact['url']), 0, 3));
// perform local delivery if we are on the same site
if (link_compare($basepath, $a->get_baseurl())) {
$nickname = basename($contact['url']);
if ($contact['issued-id']) {
$sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id']));
} else {
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id']));
}
$x = q("SELECT\t`contact`.*, `contact`.`uid` AS `importer_uid`,\n\t\t\t\t\t\t`contact`.`pubkey` AS `cpubkey`,\n\t\t\t\t\t\t`contact`.`prvkey` AS `cprvkey`,\n\t\t\t\t\t\t`contact`.`thumb` AS `thumb`,\n\t\t\t\t\t\t`contact`.`url` as `url`,\n\t\t\t\t\t\t`contact`.`name` as `senderName`,\n\t\t\t\t\t\t`user`.*\n\t\t\t\t\t\tFROM `contact`\n\t\t\t\t\t\tINNER JOIN `user` ON `contact`.`uid` = `user`.`uid`\n\t\t\t\t\t\tWHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\t\t\tAND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'\n\t\t\t\t\t\t{$sql_extra}\n\t\t\t\t\t\tAND `user`.`account_expired` = 0 AND `user`.`account_removed` = 0 LIMIT 1", dbesc(NETWORK_DFRN), dbesc($nickname));