diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/appman.php | 102 | ||||
-rw-r--r-- | mod/apps.php | 35 | ||||
-rw-r--r-- | mod/chanview.php | 16 | ||||
-rw-r--r-- | mod/display.php | 6 | ||||
-rwxr-xr-x | mod/events.php | 13 | ||||
-rw-r--r-- | mod/home.php | 6 | ||||
-rw-r--r-- | mod/item.php | 11 | ||||
-rwxr-xr-x | mod/mood.php | 9 | ||||
-rw-r--r-- | mod/photo.php | 34 | ||||
-rw-r--r-- | mod/post.php | 22 | ||||
-rw-r--r-- | mod/settings.php | 9 | ||||
-rw-r--r-- | mod/viewconnections.php | 16 |
12 files changed, 237 insertions, 42 deletions
diff --git a/mod/appman.php b/mod/appman.php new file mode 100644 index 000000000..0cc108079 --- /dev/null +++ b/mod/appman.php @@ -0,0 +1,102 @@ +<?php /** @file */ + +require_once('include/apps.php'); + +function appman_post(&$a) { + + if(! local_user()) + return; + + if($_POST['url']) { + $arr = array( + 'uid' => intval($_REQUEST['uid']), + 'url' => escape_tags($_REQUEST['url']), + 'guid' => escape_tags($_REQUEST['guid']), + 'author' => escape_tags($_REQUEST['author']), + 'addr' => escape_tags($_REQUEST['addr']), + 'name' => escape_tags($_REQUEST['name']), + 'desc' => escape_tags($_REQUEST['desc']), + 'photo' => escape_tags($_REQUEST['photo']), + 'version' => escape_tags($_REQUEST['version']), + 'price' => escape_tags($_REQUEST['price']), + 'sig' => escape_tags($_REQUEST['sig']) + ); + + $_REQUEST['appid'] = app_install(local_user(),$arr); + + if(app_installed(local_user(),$arr)) + info( t('App installed.') . EOL); + + return; + } + + + $papp = app_decode($_POST['papp']); + + if(! is_array($papp)) { + notice( t('Malformed app.') . EOL); + return; + } + + if($_POST['install']) { + app_install(local_user(),$papp); + if(app_installed(local_user(),$papp)) + info( t('App installed.') . EOL); + } + + if($_POST['delete']) { + app_destroy(local_user(),$papp); + } + + if($_POST['edit']) { + return; + } + + if($_SESSION['return_url']) + goaway(z_root() . '/' . $_SESSION['return_url']); + goaway(z_root() . '/apps/personal'); + + +} + + +function appman_content(&$a) { + + if(! local_user()) { + notice( t('Permission denied.') . EOL); + return; + } +logger('content'); + $channel = $a->get_channel(); + $app = null; + $embed = null; + if($_REQUEST['appid']) { + $r = q("select * from app where app_id = '%s' and app_channel = %d limit 1", + dbesc($_REQUEST['appid']), + dbesc(local_user()) + ); + if($r) + $app = $r[0]; + $embed = array('embed', t('Embed code'), app_encode($app,true),'', 'onclick="this.select();"'); + + } + + return replace_macros(get_markup_template('app_create.tpl'), array( + + '$banner' => (($app) ? t('Edit App') : t('Create App')), + '$app' => $app, + '$guid' => (($app) ? $app['app_id'] : ''), + '$author' => (($app) ? $app['app_author'] : $channel['channel_hash']), + '$addr' => (($app) ? $app['app_addr'] : $channel['xchan_addr']), + '$name' => array('name', t('Name of app'),(($app) ? $app['app_name'] : ''), t('Required')), + '$url' => array('url', t('Location (URL) of app'),(($app) ? $app['app_url'] : ''), t('Required')), + '$desc' => array('desc', t('Description'),(($app) ? $app['app_desc'] : ''), ''), + '$photo' => array('photo', t('Photo icon URL'),(($app) ? $app['app_photo'] : ''), t('80 x 80 pixels - optional')), + '$version' => array('version', t('Version ID'),(($app) ? $app['app_version'] : ''), ''), + '$price' => array('price', t('Price of app'),(($app) ? $app['app_price'] : ''), ''), + '$page' => array('page', t('Location (URL) to purchase app'),(($app) ? $app['app_page'] : ''), ''), + '$embed' => $embed, + '$submit' => t('Submit') + )); + +} diff --git a/mod/apps.php b/mod/apps.php index 43540a3de..e88c54c66 100644 --- a/mod/apps.php +++ b/mod/apps.php @@ -1,16 +1,39 @@ <?php +require_once('include/apps.php'); + function apps_content(&$a) { - $apps = $a->get_apps(); - if(count($apps) == 0) - notice( t('No installed applications.') . EOL); + if(argc() == 1 || (! local_user())) { + + $apps = get_system_apps(); + + // $o .= print_r($apps,true); + + // return $o; + + return replace_macros(get_markup_template('apps.tpl'), array( + '$title' => t('Apps'), + '$apps' => $apps, + )); + } + + if(argc() == 3 && argv(2) == 'edit') + $mode = 'edit'; + else + $mode = 'list'; + $apps = array(); + $list = app_list(local_user()); + if($list) { + foreach($list as $app) { + $apps[] = app_render(app_encode($app),$mode); + } + } - $tpl = get_markup_template("apps.tpl"); - return replace_macros($tpl, array( - '$title' => t('Applications'), + return replace_macros(get_markup_template('myapps.tpl'), array( + '$title' => t('Apps'), '$apps' => $apps, )); diff --git a/mod/chanview.php b/mod/chanview.php index ca3410c8f..449a98bb1 100644 --- a/mod/chanview.php +++ b/mod/chanview.php @@ -84,15 +84,17 @@ function chanview_content(&$a) { $url = zid($url); // let somebody over-ride the iframed viewport presentation + // or let's just declare this a failed experiment. - if((! local_user()) || (get_pconfig(local_user(),'system','chanview_full'))) - goaway($url); +// if((! local_user()) || (get_pconfig(local_user(),'system','chanview_full'))) + + goaway($url); - $o = replace_macros(get_markup_template('chanview.tpl'),array( - '$url' => $url, - '$full' => t('toggle full screen mode') - )); +// $o = replace_macros(get_markup_template('chanview.tpl'),array( +// '$url' => $url, +// '$full' => t('toggle full screen mode') +// )); - return $o; +// return $o; }
\ No newline at end of file diff --git a/mod/display.php b/mod/display.php index f4d4c38c3..efc3265c8 100644 --- a/mod/display.php +++ b/mod/display.php @@ -77,8 +77,8 @@ function display_content(&$a, $update = 0, $load = false) { $target_item = null; - $r = q("select id, uid, mid, parent_mid, item_restrict from item where mid = '%s' limit 1", - dbesc($item_hash) + $r = q("select id, uid, mid, parent_mid, item_restrict from item where mid like '%s' limit 1", + dbesc($item_hash . '%') ); if($r) { @@ -149,6 +149,7 @@ function display_content(&$a, $update = 0, $load = false) { if($load || ($_COOKIE['jsAvailable'] != 1)) { $r = null; + if(local_user()) { $r = q("SELECT * from item WHERE item_restrict = 0 @@ -177,7 +178,6 @@ function display_content(&$a, $update = 0, $load = false) { ); } - } else { $r = array(); diff --git a/mod/events.php b/mod/events.php index d243f61ba..8bf8c6ce1 100755 --- a/mod/events.php +++ b/mod/events.php @@ -158,8 +158,17 @@ function events_content(&$a) { } + $plaintext = true; + + if(feature_enabled(local_user(),'richtext')) + $plaintext = false; + + $htpl = get_markup_template('event_head.tpl'); - $a->page['htmlhead'] .= replace_macros($htpl,array('$baseurl' => $a->get_baseurl())); + $a->page['htmlhead'] .= replace_macros($htpl,array( + '$baseurl' => $a->get_baseurl(), + '$editselect' => (($plaintext) ? 'none' : 'textareas') + )); $o =""; // tabs @@ -400,7 +409,6 @@ function events_content(&$a) { if($orig_event['event_xchan']) $sh_checked .= ' disabled="disabled" '; - $tpl = get_markup_template('event_form.tpl'); $sdt = ((x($orig_event)) ? $orig_event['start'] : 'now'); $fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now'); @@ -439,6 +447,7 @@ function events_content(&$a) { 'deny_gid' => $channel['channel_deny_gid'] ); + $tpl = get_markup_template('event_form.tpl'); $o .= replace_macros($tpl,array( diff --git a/mod/home.php b/mod/home.php index 05626dcb5..862f6303c 100644 --- a/mod/home.php +++ b/mod/home.php @@ -12,9 +12,11 @@ function home_init(&$a) { $channel = $a->get_channel(); if(local_user() && $channel && $channel['xchan_url']) { - $dest = get_pconfig(local_user(),'system','startpage'); + $dest = $channel['channel_startpage']; if(! $dest) - $dest = z_root() . '/network'; + $dest = get_pconfig(local_user(),'system','startpage'); + if(! $dest) + $dest = z_root() . '/apps'; goaway($dest); } diff --git a/mod/item.php b/mod/item.php index 164b345f0..68582e580 100644 --- a/mod/item.php +++ b/mod/item.php @@ -440,6 +440,11 @@ function item_post(&$a) { $body = preg_replace_callback('/\[\$b64url(.*?)\[\/(url)\]/ism','red_unescape_codeblock',$body); $body = preg_replace_callback('/\[\$b64code(.*?)\[\/(code)\]/ism','red_unescape_codeblock',$body); + // fix any img tags that should be zmg + + $body = preg_replace_callback('/\[img(.*?)\](.*?)\[\/img\]/ism','red_zrlify_img_callback',$body); + + /** * @@ -847,10 +852,10 @@ function item_content(&$a) { require_once('include/security.php'); if((argc() == 3) && (argv(1) === 'drop') && intval(argv(2))) { + require_once('include/items.php'); - $i = q("select id, uid, author_xchan, owner_xchan, source_xchan, item_restrict from item where id = %d and uid = %d limit 1", - intval(argv(2)), - intval(local_user()) + $i = q("select id, uid, author_xchan, owner_xchan, source_xchan, item_restrict from item where id = %d limit 1", + intval(argv(2)) ); if($i) { diff --git a/mod/mood.php b/mod/mood.php index 5075f622d..5508fcb5a 100755 --- a/mod/mood.php +++ b/mod/mood.php @@ -60,7 +60,7 @@ function mood_init(&$a) { $mid = item_message_id(); - $action = sprintf( t('%1$s is currently %2$s'), '[zrl=' . $poster['xchan_url'] . ']' . $poster['xchan_name'] . '[/zrl]' , $verbs[$verb]); + $action = sprintf( t('%1$s is %2$s','mood'), '[zrl=' . $poster['xchan_url'] . ']' . $poster['xchan_name'] . '[/zrl]' , $verbs[$verb]); $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_UNSEEN; if(! $parent_mid) $item_flags |= ITEM_THREAD_TOP; @@ -93,14 +93,7 @@ function mood_init(&$a) { $item_id = $post['item_id']; if($item_id) { -// q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", -// dbesc($a->get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id), -// intval($uid), -// intval($item_id) -// ); - proc_run('php',"include/notifier.php","activity", $item_id); - } call_hooks('post_local_end', $arr); diff --git a/mod/photo.php b/mod/photo.php index 1319f9569..9302278b6 100644 --- a/mod/photo.php +++ b/mod/photo.php @@ -80,6 +80,22 @@ function photo_init(&$a) { * Other photos */ + /* Check for a cookie to indicate display pixel density, in order to detect high-resolution + displays. This procedure was derived from the "Retina Images" by Jeremey Worboys, + used in accordance with the Creative Commons Attribution 3.0 Unported License. + Project link: https://github.com/Retina-Images/Retina-Images + License link: http://creativecommons.org/licenses/by/3.0/ + */ + $cookie_value = false; + if (isset($_COOKIE['devicePixelRatio'])) { + $cookie_value = intval($_COOKIE['devicePixelRatio']); + } + else { + // Force revalidation of cache on next request + $cache_directive = 'no-cache'; + $status = 'no cookie'; + } + $resolution = 0; if(strpos($photo,'.') !== false) @@ -88,7 +104,23 @@ function photo_init(&$a) { if(substr($photo,-2,1) == '-') { $resolution = intval(substr($photo,-1,1)); $photo = substr($photo,0,-2); + // If viewing on a high-res screen, attempt to serve a higher resolution image: + if ($resolution == 2 && ($cookie_value > 1)) + { + $resolution = 1; + } } + + // If using resolution 1, make sure it exists before proceeding: + if ($resolution == 1) + { + $r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND scale = %d LIMIT 1", + dbesc($photo), + intval($resolution) + ); + if (!($r)) + $resolution = 2; + } $r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND scale = %d LIMIT 1", dbesc($photo), @@ -125,7 +157,7 @@ function photo_init(&$a) { dbesc($photo), intval($resolution) ); - + if($r) { logger('mod_photo: forbidden. ' . $a->query_string); $observer = $a->get_observer(); diff --git a/mod/post.php b/mod/post.php index 1f817aa40..05053e798 100644 --- a/mod/post.php +++ b/mod/post.php @@ -646,6 +646,28 @@ function post_post(&$a) { intval($hub['hubloc_id']) ); + // a dead hub came back to life - reset any tombstones we might have + + if($hub['hubloc_status'] & HUBLOC_OFFLINE) { + q("update hubloc set hubloc_status = (hubloc_status ^ %d) where hubloc_id = %d limit 1", + intval(HUBLOC_OFFLINE), + intval($hub['hubloc_id']) + ); + if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) { + q("update hubloc set hubloc_flags = (hubloc_flags ^ %d) where hubloc_id = %d limit 1", + intval(HUBLOC_FLAGS_ORPHANCHECK), + intval($hub['hubloc_id']) + ); + } + q("update xchan set xchan_flags = (xchan_flags ^ %d) where (xchan_flags & %d) and xchan_hash = '%s' limit 1", + intval(XCHAN_FLAGS_ORPHAN), + intval(XCHAN_FLAGS_ORPHAN), + dbesc($hub['hubloc_hash']) + ); + } + + + /** * This hub has now been proven to be valid. * Any hub with the same URL and a different sitekey cannot be valid. diff --git a/mod/settings.php b/mod/settings.php index 3ab34f145..e1ae0b8ec 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -150,12 +150,12 @@ function settings_post(&$a) { set_pconfig(local_user(),'system','mobile_theme',$mobile_theme); } - $chanview_full = ((x($_POST,'chanview_full')) ? intval($_POST['chanview_full']) : 0); +// $chanview_full = ((x($_POST,'chanview_full')) ? intval($_POST['chanview_full']) : 0); set_pconfig(local_user(),'system','update_interval', $browser_update); set_pconfig(local_user(),'system','itemspage', $itemspage); set_pconfig(local_user(),'system','no_smilies',$nosmile); - set_pconfig(local_user(),'system','chanview_full',$chanview_full); +// set_pconfig(local_user(),'system','chanview_full',$chanview_full); if ($theme == $a->channel['channel_theme']){ @@ -714,7 +714,7 @@ function settings_content(&$a) { $unsupported = file_exists('view/theme/' . $th . '/unsupported'); $is_mobile = file_exists('view/theme/' . $th . '/mobile'); if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){ - $theme_name = (($is_experimental) ? sprintf("%s - \x28Experimental\x29", $f) : $f); + $theme_name = (($is_experimental) ? sprintf(t('%s - (Experimental)'), $f) : $f); if($is_mobile) { $mobile_themes[$f]=$theme_name; } @@ -736,8 +736,6 @@ function settings_content(&$a) { $nosmile = get_pconfig(local_user(),'system','no_smilies'); $nosmile = (($nosmile===false)? '0': $nosmile); // default if not set: 0 - $chanview = intval(get_pconfig(local_user(),'system','chanview_full')); - $theme_config = ""; if( ($themeconfigfile = get_theme_config_file($theme_selected)) != null){ require_once($themeconfigfile); @@ -757,7 +755,6 @@ function settings_content(&$a) { '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), '$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, ''), - '$chanview_full' => array('chanview_full', t('Do not view remote profiles in frames'), $chanview, t('By default open in a sub-window of your own site')), '$layout_editor' => t('System Page Layout Editor - (advanced)'), '$theme_config' => $theme_config, )); diff --git a/mod/viewconnections.php b/mod/viewconnections.php index f5e7ab213..b6a6b483c 100644 --- a/mod/viewconnections.php +++ b/mod/viewconnections.php @@ -28,11 +28,19 @@ function viewconnections_content(&$a) { return; } + $is_owner = ((local_user() && local_user() == $a->profile['uid']) ? true : false); + + $abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF; + $xchan_flags = XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED; + if(! $is_owner) { + $abook_flags = $abook_flags | ABOOK_FLAGS_HIDDEN; + $xchan_flags = $xchan_flags | XCHAN_FLAGS_HIDDEN; + } $r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not (abook_flags & %d ) and not ( xchan_flags & %d ) ", intval($a->profile['uid']), - intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF), - intval(XCHAN_FLAGS_HIDDEN|XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED) + intval($abook_flags), + intval($xchan_flags) ); if($r) { $a->set_pager_total($r[0]['total']); @@ -40,8 +48,8 @@ function viewconnections_content(&$a) { $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not ( abook_flags & %d ) and not ( xchan_flags & %d ) order by xchan_name LIMIT %d , %d ", intval($a->profile['uid']), - intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF), - intval(XCHAN_FLAGS_HIDDEN|XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED), + intval($abook_flags), + intval($xchan_flags), intval($a->pager['start']), intval($a->pager['itemspage']) ); |