diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/admin.php | 1 | ||||
-rw-r--r-- | mod/appman.php | 102 | ||||
-rw-r--r-- | mod/apps.php | 32 | ||||
-rw-r--r-- | mod/chanview.php | 16 | ||||
-rw-r--r-- | mod/chat.php | 2 | ||||
-rw-r--r-- | mod/connections.php | 1 | ||||
-rw-r--r-- | mod/display.php | 20 | ||||
-rw-r--r-- | mod/editwebpage.php | 3 | ||||
-rwxr-xr-x | mod/events.php | 25 | ||||
-rw-r--r-- | mod/filestorage.php | 2 | ||||
-rw-r--r-- | mod/home.php | 7 | ||||
-rw-r--r-- | mod/import.php | 8 | ||||
-rw-r--r-- | mod/item.php | 53 | ||||
-rw-r--r-- | mod/mitem.php | 4 | ||||
-rwxr-xr-x | mod/mood.php | 11 | ||||
-rw-r--r-- | mod/network.php | 61 | ||||
-rw-r--r-- | mod/notes.php | 4 | ||||
-rw-r--r-- | mod/notify.php | 7 | ||||
-rw-r--r-- | mod/page.php | 1 | ||||
-rw-r--r-- | mod/photo.php | 34 | ||||
-rw-r--r-- | mod/photos.php | 13 | ||||
-rw-r--r-- | mod/post.php | 22 | ||||
-rw-r--r-- | mod/profiles.php | 11 | ||||
-rw-r--r-- | mod/rpost.php | 11 | ||||
-rw-r--r-- | mod/search.php | 23 | ||||
-rw-r--r-- | mod/settings.php | 14 | ||||
-rwxr-xr-x | mod/setup.php | 18 | ||||
-rw-r--r-- | mod/tagger.php | 3 | ||||
-rw-r--r-- | mod/webpages.php | 3 | ||||
-rw-r--r-- | mod/zfinger.php | 15 |
30 files changed, 366 insertions, 161 deletions
diff --git a/mod/admin.php b/mod/admin.php index 74e2d8f56..37a147df6 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -255,6 +255,7 @@ function admin_page_site_post(&$a){ $timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60); $delivery_interval = ((x($_POST,'delivery_interval'))? intval(trim($_POST['delivery_interval'])) : 0); $poll_interval = ((x($_POST,'poll_interval'))? intval(trim($_POST['poll_interval'])) : 0); + $maxloadavg = ((x($_POST,'maxloadavg'))? intval(trim($_POST['maxloadavg'])) : 50); // $ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0); /* if($ssl_policy != intval(get_config('system','ssl_policy'))) { diff --git a/mod/appman.php b/mod/appman.php new file mode 100644 index 000000000..f0a3c8a70 --- /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; + } + + $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..07d1968d2 100644 --- a/mod/apps.php +++ b/mod/apps.php @@ -1,16 +1,36 @@ <?php +require_once('include/apps.php'); + function apps_content(&$a) { - $apps = $a->get_apps(); + if(argc() == 2 && argv(1) == 'edit') + $mode = 'edit'; + else + $mode = 'list'; + + $apps = array(); + + $syslist = get_system_apps(); + + if(local_user()) { + $list = app_list(local_user()); + if($list) { + foreach($list as $x) { + $syslist[] = app_encode($x); + } + } + } + usort($syslist,'app_name_compare'); - if(count($apps) == 0) - notice( t('No installed applications.') . EOL); +// logger('apps: ' . print_r($syslist,true)); + foreach($syslist as $app) { + $apps[] = app_render($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/chat.php b/mod/chat.php index caf800f80..e2428f1f7 100644 --- a/mod/chat.php +++ b/mod/chat.php @@ -207,7 +207,7 @@ function chat_content(&$a) { '$header' => t('New Chatroom'), '$name' => array('room_name',t('Chatroom Name'),'', ''), '$permissions' => t('Permissions'), - '$acl' => populate_acl($channel_acl), + '$acl' => populate_acl($channel_acl,false), '$submit' => t('Submit') )); return $o; diff --git a/mod/connections.php b/mod/connections.php index 3c3a704b2..b9df3c2b7 100644 --- a/mod/connections.php +++ b/mod/connections.php @@ -233,6 +233,7 @@ function connections_content(&$a) { $a->argc = 1; unset($a->argv[1]); } + nav_set_selected('intros'); break; case 'unconnected': $search_flags = ABOOK_FLAG_UNCONNECTED; diff --git a/mod/display.php b/mod/display.php index f4d4c38c3..31cce95d3 100644 --- a/mod/display.php +++ b/mod/display.php @@ -55,7 +55,7 @@ function display_content(&$a, $update = 0, $load = false) { 'nickname' => $channel['channel_address'], 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - 'acl' => populate_acl($channel_acl, false), + 'acl' => populate_acl($channel_acl), 'bang' => '', 'visitor' => true, 'profile_uid' => local_user(), @@ -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,10 @@ function display_content(&$a, $update = 0, $load = false) { if($load || ($_COOKIE['jsAvailable'] != 1)) { $r = null; + + require_once('include/identity.php'); + $sys = get_sys_channel(); + if(local_user()) { $r = q("SELECT * from item WHERE item_restrict = 0 @@ -162,22 +166,24 @@ function display_content(&$a, $update = 0, $load = false) { $updateable = true; } + } if($r === null) { $r = q("SELECT * from item WHERE item_restrict = 0 and mid = '%s' - AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' + AND (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 ) - and owner_xchan in ( " . stream_perms_xchans(($observer) ? PERMS_NETWORK : PERMS_PUBLIC) . " )) + and owner_xchan in ( " . stream_perms_xchans(($observer) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " )) + OR owner_xchan = '%s') $sql_extra ) group by mid limit 1", - dbesc($target_item['parent_mid']) + dbesc($target_item['parent_mid']), + dbesc($sys['xchan_hash']) ); } - } else { $r = array(); diff --git a/mod/editwebpage.php b/mod/editwebpage.php index 38aef4a8b..b8b7a465c 100644 --- a/mod/editwebpage.php +++ b/mod/editwebpage.php @@ -157,7 +157,7 @@ function editwebpage_content(&$a) { '$baseurl' => $a->get_baseurl(), '$defloc' => $itm[0]['location'], '$visitor' => ($is_owner) ? true : false, - '$acl' => populate_acl($itm[0]), + '$acl' => populate_acl($itm[0],false), '$showacl' => ($is_owner) ? true : false, '$public' => t('Public post'), '$jotnets' => $jotnets, @@ -169,7 +169,6 @@ function editwebpage_content(&$a) { '$placeholdercategory' => t('Categories (comma-separated list)'), '$emtitle' => t('Example: bob@example.com, mary@example.com'), 'lockstate' => (((strlen($itm[0]['allow_cid'])) || (strlen($itm[0]['allow_gid'])) || (strlen($itm[0]['deny_cid'])) || (strlen($itm[0]['deny_gid']))) ? 'lock' : 'unlock'), - '$acl' => populate_acl($itm[0]), '$bang' => '', '$profile_uid' => (intval($owner)), '$preview' => ((feature_enabled(local_user(),'preview')) ? t('Preview') : ''), diff --git a/mod/events.php b/mod/events.php index 8bf8c6ce1..911b6c891 100755 --- a/mod/events.php +++ b/mod/events.php @@ -125,9 +125,10 @@ function events_post(&$a) { $datarray['created'] = $created; $datarray['edited'] = $edited; - $item_id = event_store($datarray); + $event = event_store_event($datarray); + $item_id = event_store_item($datarray,$event); - if(! $cid) + if($share) proc_run('php',"include/notifier.php","event","$item_id"); } @@ -158,10 +159,11 @@ function events_content(&$a) { } - $plaintext = true; + $plaintext = true; + + if(feature_enabled(local_user(),'richtext')) + $plaintext = false; - if(feature_enabled(local_user(),'richtext')) - $plaintext = false; $htpl = get_markup_template('event_head.tpl'); @@ -189,6 +191,10 @@ function events_content(&$a) { $mode = 'edit'; $event_id = argv(2); } + if(argc() > 2 && argv(1) === 'add') { + $mode = 'add'; + $item_id = intval(argv(2)); + } if(argv(1) === 'new') { $mode = 'new'; $event_id = ''; @@ -200,6 +206,11 @@ function events_content(&$a) { } } + if($mode === 'add') { + event_addtocal($item_id,local_user()); + killme(); + } + if($mode == 'view') { @@ -341,7 +352,7 @@ function events_content(&$a) { 'is_first'=>$is_first, 'item'=>$rr, 'html'=>$html, - 'plink' => array($rr['plink'],t('link to source'),'',''), + 'plink' => array($rr['plink'],t('Link to Source'),'',''), ); @@ -477,7 +488,7 @@ function events_content(&$a) { '$t_orig' => $t_orig, '$sh_text' => t('Share this event'), '$sh_checked' => $sh_checked, - '$acl' => (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults))), + '$acl' => (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults),false)), '$submit' => t('Submit') )); diff --git a/mod/filestorage.php b/mod/filestorage.php index ed7164070..bcf798e7b 100644 --- a/mod/filestorage.php +++ b/mod/filestorage.php @@ -111,7 +111,7 @@ function filestorage_content(&$a) { $cloudpath = get_cloudpath($f) . (($f['flags'] & ATTACH_FLAG_DIR) ? '?f=&davguest=1' : ''); - $aclselect_e = populate_acl($f); + $aclselect_e = populate_acl($f,false); $is_a_dir = (($f['flags'] & ATTACH_FLAG_DIR) ? true : false); $lockstate = (($f['allow_cid'] || $f['allow_gid'] || $f['deny_cid'] || $f['deny_gid']) ? 'lock' : 'unlock'); diff --git a/mod/home.php b/mod/home.php index 05626dcb5..6f7a0b5d7 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); } @@ -74,6 +76,7 @@ function home_content(&$a) { if(get_config('system','projecthome')) { $o .= file_get_contents('assets/home.html'); $a->page['template'] = 'full'; + $a->page['title'] = t('Red Matrix - "The Network"'); return $o; } diff --git a/mod/import.php b/mod/import.php index 5b3b53156..d3b237c3a 100644 --- a/mod/import.php +++ b/mod/import.php @@ -254,12 +254,18 @@ function import_post(&$a) { require_once('include/photo/photo_driver.php'); $photos = import_profile_photo($xchan['xchan_photo_l'],$xchan['xchan_hash']); - $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' + if($photos[4]) + $photodate = '0000-00-00 00:00:00'; + else + $photodate = $xchan['xchan_photo_date']; + + $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s', xchan_photo_date = '%s' where xchan_hash = '%s' limit 1", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), + dbesc($photodate), dbesc($xchan_hash) ); diff --git a/mod/item.php b/mod/item.php index 164b345f0..5ddafb709 100644 --- a/mod/item.php +++ b/mod/item.php @@ -262,28 +262,48 @@ function item_post(&$a) { if($orig_post) { - $str_group_allow = ((array_key_exists('group_allow',$_REQUEST)) - ? perms2str($_REQUEST['group_allow']) : $orig_post['allow_gid']); - $str_contact_allow = ((array_key_exists('contact_allow',$_REQUEST)) - ? perms2str($_REQUEST['contact_allow']) : $orig_post['allow_cid']); - $str_group_deny = ((array_key_exists('group_deny',$_REQUEST)) - ? perms2str($_REQUEST['group_deny']) : $orig_post['deny_gid']); - $str_contact_deny = ((array_key_exists('contact_deny',$_REQUEST)) - ? perms2str($_REQUEST['contact_deny']) : $orig_post['deny_cid']); + $private = 0; + // webpages are allowed to change ACLs after the fact. Normal conversation items aren't. + if($webpage) { + $str_group_allow = perms2str($_REQUEST['group_allow']); + $str_contact_allow = perms2str($_REQUEST['contact_allow']); + $str_group_deny = perms2str($_REQUEST['group_deny']); + $str_contact_deny = perms2str($_REQUEST['contact_deny']); + } + else { + $str_group_allow = $orig_post['allow_gid']; + $str_contact_allow = $orig_post['allow_cid']; + $str_group_deny = $orig_post['deny_gid']; + $str_contact_deny = $orig_post['deny_cid']; + } + + if((strlen($str_group_allow)) + || strlen($str_contact_allow) + || strlen($str_group_deny) + || strlen($str_contact_deny)) { + $private = 1; + } + $location = $orig_post['location']; $coord = $orig_post['coord']; $verb = $orig_post['verb']; $app = $orig_post['app']; $title = $_REQUEST['title']; $body = $_REQUEST['body']; - $private = $orig_post['item_private']; $item_flags = $orig_post['item_flags']; + + // force us to recalculate if we need to obscure this post + + if($item_flags & ITEM_OBSCURED) + $item_flags = ($item_flags ^ ITEM_OBSCURED); + $item_restrict = $orig_post['item_restrict']; $postopts = $orig_post['postopts']; $created = $orig_post['created']; $mid = $orig_post['mid']; $parent_mid = $orig_post['parent_mid']; $plink = $orig_post['plink']; + } else { @@ -356,6 +376,7 @@ function item_post(&$a) { } } + $expires = '0000-00-00 00:00:00'; if(feature_enabled($profile_uid,'content_expire')) { @@ -376,6 +397,7 @@ function item_post(&$a) { $body = z_input_filter($profile_uid,$body,$mimetype); } + // Verify ability to use html or php!!! $execflag = false; @@ -397,6 +419,7 @@ function item_post(&$a) { } } + if($mimetype === 'text/bbcode') { // BBCODE alert: the following functions assume bbcode input @@ -440,6 +463,10 @@ 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); + /** * @@ -488,6 +515,7 @@ function item_post(&$a) { $body = scale_external_images($body,false); + /** * Look for any tags and linkify them */ @@ -578,7 +606,6 @@ function item_post(&$a) { // BBCODE end alert - if(strlen($categories)) { $cats = explode(',',$categories); foreach($cats as $cat) { @@ -847,10 +874,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/mitem.php b/mod/mitem.php index e0aa1b87a..3240bb68b 100644 --- a/mod/mitem.php +++ b/mod/mitem.php @@ -132,7 +132,7 @@ function mitem_content(&$a) { '$menu_id' => $a->data['menu']['menu_id'], '$permissions' => t('Menu Item Permissions'), '$permdesc' => t("\x28click to open/close\x29"), - '$aclselect' => populate_acl($perm_defaults), + '$aclselect' => populate_acl($perm_defaults,false), '$mitem_desc' => array('mitem_desc', t('Link text'), '', '','*'), '$mitem_link' => array('mitem_link', t('URL of link'), '', '', '*'), '$usezid' => array('usezid', t('Use Red magic-auth if available'), true, ''), @@ -175,7 +175,7 @@ function mitem_content(&$a) { '$menu_id' => $a->data['menu']['menu_id'], '$permissions' => t('Menu Item Permissions'), '$permdesc' => t("\x28click to open/close\x29"), - '$aclselect' => populate_acl($mitem), + '$aclselect' => populate_acl($mitem,false), '$mitem_id' => intval(argv(2)), '$mitem_desc' => array('mitem_desc', t('Link text'), $mitem['mitem_desc'], '','*'), '$mitem_link' => array('mitem_link', t('URL of link'), $mitem['mitem_link'], '', '*'), diff --git a/mod/mood.php b/mod/mood.php index 5075f622d..ff765fcac 100755 --- a/mod/mood.php +++ b/mod/mood.php @@ -19,7 +19,7 @@ function mood_init(&$a) { $verbs = get_mood_verbs(); - if(! in_array($verb,$verbs)) + if(! array_key_exists($verb,$verbs)) return; $activity = ACTIVITY_MOOD . '#' . urlencode($verb); @@ -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/network.php b/mod/network.php index 8202b1044..f12471467 100644 --- a/mod/network.php +++ b/mod/network.php @@ -104,7 +104,6 @@ function network_content(&$a, $update = 0, $load = false) { $file = ((x($_GET,'file')) ? $_GET['file'] : ''); - if(x($_GET,'search') || x($_GET,'file')) $nouveau = true; if($cid) @@ -205,25 +204,11 @@ function network_content(&$a, $update = 0, $load = false) { // We only launch liveUpdate if you aren't filtering in some incompatible // way and also you aren't writing a comment (discovered in javascript). - $o .= '<div id="live-network"></div>' . "\r\n"; - $o .= "<script> var profile_uid = " . $_SESSION['uid'] - . "; var netargs = '" . substr($a->cmd,8) - . '?f=' - . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : '') - . ((x($_GET,'search')) ? '&search=' . $_GET['search'] : '') - . ((x($_GET,'star')) ? '&star=' . $_GET['star'] : '') - . ((x($_GET,'order')) ? '&order=' . $_GET['order'] : '') - . ((x($_GET,'liked')) ? '&liked=' . $_GET['liked'] : '') - . ((x($_GET,'conv')) ? '&conv=' . $_GET['conv'] : '') - . ((x($_GET,'spam')) ? '&spam=' . $_GET['spam'] : '') - . ((x($_GET,'cmin')) ? '&cmin=' . $_GET['cmin'] : '') - . ((x($_GET,'cmax')) ? '&cmax=' . $_GET['cmax'] : '') - . ((x($_GET,'file')) ? '&file=' . $_GET['file'] : '') - . ((x($_GET,'fh')) ? '&fh=' . $_GET['fh'] : '') - - . "'; var profile_page = " . $a->pager['page'] . ";</script>"; - + if($gid || $cid || $cmin || ($cmax != 99) || $star || $liked || $conv || $spam || $nouveau || $list) + $firehose = 0; + $o .= '<div id="live-network"></div>' . "\r\n"; + $o .= "<script> var profile_uid = " . $_SESSION['uid'] . "; var profile_page = " . $a->pager['page'] . ";</script>"; $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array( '$baseurl' => z_root(), @@ -329,13 +314,10 @@ function network_content(&$a, $update = 0, $load = false) { $uids = " and item.uid = " . local_user() . " "; } - $simple_update = (($update) ? " and ( item.item_flags & " . intval(ITEM_UNSEEN) . " ) " : ''); if($load) $simple_update = ''; - $start = dba_timer(); - if($nouveau && $load) { // "New Item View" - show all items unthreaded in reverse created date order @@ -389,8 +371,6 @@ function network_content(&$a, $update = 0, $load = false) { } } - $first = dba_timer(); - // Then fetch all the children of the parents that are on this page $parents_str = ''; $update_unseen = ''; @@ -406,22 +386,9 @@ function network_content(&$a, $update = 0, $load = false) { dbesc($parents_str) ); - $second = dba_timer(); - xchan_query($items); - - $third = dba_timer(); - $items = fetch_post_tags($items,true); - - $fourth = dba_timer(); - $items = conv_sort($items,$ordering); - - - - //logger('items: ' . print_r($items,true)); - } else { $items = array(); @@ -432,8 +399,6 @@ function network_content(&$a, $update = 0, $load = false) { } -// logger('items: ' . count($items)); - if(($update_unseen) && (! $firehose)) $r = q("UPDATE `item` SET item_flags = ( item_flags ^ %d) WHERE (item_flags & %d) AND `uid` = %d $update_unseen ", @@ -444,28 +409,10 @@ function network_content(&$a, $update = 0, $load = false) { $mode = (($nouveau) ? 'network-new' : 'network'); - $fifth = dba_timer(); - $o .= conversation($a,$items,$mode,$update,'client'); - $sixth = dba_timer(); - - if(($items) && (! $update)) $o .= alt_pager($a,count($items)); - if($load) { -// logger('mod_network: load: ' . count($items) . ' items', LOGGER_DATA); - - profiler($start,$first,'network parents'); - profiler($first,$second,'network children'); - profiler($second,$third,'network authors'); - profiler($third,$fourth,'network tags'); - profiler($fourth,$fifth,'network sort'); - profiler($fifth,$sixth,'network render'); - profiler($start,$sixth,'network total'); - profiler(1,1,'-- ' . count($items)); - } - return $o; } diff --git a/mod/notes.php b/mod/notes.php index e21e4386c..84f8a7093 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -1,9 +1,9 @@ <?php /** @file */ function notes_init(&$a) { + if(! local_user()) return; - logger('mod_notes: ' . print_r($_REQUEST,true)); $ret = array('success' => true); if($_REQUEST['note_text'] || $_REQUEST['note_text'] == '') { @@ -18,7 +18,7 @@ function notes_init(&$a) { build_sync_packet(); } - logger('notes saved.'); + logger('notes saved.', LOGGER_DEBUG); json_return_and_die($ret); } diff --git a/mod/notify.php b/mod/notify.php index 6ee4260ce..72534c7fd 100644 --- a/mod/notify.php +++ b/mod/notify.php @@ -11,15 +11,14 @@ function notify_init(&$a) { intval(local_user()) ); if($r) { - q("update notify set seen = 1 where ( link = '%s' or ( parent != '' and parent = '%s' and otype = '%s' )) and uid = %d", - dbesc($r[0]['link']), - intval($r[0]['parent']), + q("update notify set seen = 1 where (( parent != '' and parent = '%s' and otype = '%s' ) or link = '%s' ) and uid = %d", + dbesc($r[0]['parent']), dbesc($r[0]['otype']), + dbesc($r[0]['link']), intval(local_user()) ); goaway($r[0]['link']); } - goaway($a->get_baseurl(true)); } diff --git a/mod/page.php b/mod/page.php index df17dbf52..b3f53a227 100644 --- a/mod/page.php +++ b/mod/page.php @@ -111,7 +111,6 @@ function page_content(&$a) { xchan_query($r); $r = fetch_post_tags($r,true); - $o .= prepare_page($r[0]); return $o; 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/photos.php b/mod/photos.php index 2740f91f9..c43beb8d4 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -539,8 +539,8 @@ function photos_content(&$a) { $albumselect = '<select id="photos-upload-album-select" name="album" size="4">'; $albumselect .= '<option value="" ' . ((! $selname) ? ' selected="selected" ' : '') . '> </option>'; - if(count($albums)) { - foreach($albums as $album) { + if(count($albums['albums'])) { + foreach($albums['albums'] as $album) { if(! $album['text']) continue; $selected = (($selname === $album['text']) ? ' selected="selected" ' : ''); @@ -548,8 +548,6 @@ function photos_content(&$a) { } } - $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false); - $albumselect .= '</select>'; $uploader = ''; @@ -591,7 +589,7 @@ function photos_content(&$a) { } $albumselect_e = $albumselect; - $aclselect_e = (($_is_owner) ? populate_acl($channel_acl) : ''); + $aclselect_e = (($_is_owner) ? populate_acl($channel_acl,false) : ''); $tpl = get_markup_template('photos_upload.tpl'); $o .= replace_macros($tpl,array( @@ -929,6 +927,10 @@ function photos_content(&$a) { $edit = null; if($can_post) { + if(array_key_exists('albums', $a->data)) + $albums = get_app()->data['albums']; + else + $albums = photos_albums_list($a->data['channel'],$a->data['observer']); $album_e = $ph[0]['album']; $caption_e = $ph[0]['description']; @@ -939,6 +941,7 @@ function photos_content(&$a) { 'id' => $ph[0]['id'], 'rotatecw' => t('Rotate CW (right)'), 'rotateccw' => t('Rotate CCW (left)'), + 'albums' => $albums['albums'], 'album' => $album_e, 'newalbum' => t('New album name'), 'nickname' => $a->data['channel']['channel_address'], 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/profiles.php b/mod/profiles.php index 481680a12..2e91db600 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -419,13 +419,22 @@ function profiles_post(&$a) { dbesc($work), dbesc($education), intval($hide_friends), - intval($a->argv[1]), + intval(argv(1)), intval(local_user()) ); if($r) info( t('Profile updated.') . EOL); + $r = q("select * from profile where id = %d and uid = %d limit 1", + intval(argv(1)), + intval(local_user()) + ); + if($r) { + require_once('include/zot.php'); + build_sync_packet(local_user(),array('profile' => $r)); + } + $channel = $a->get_channel(); if($namechanged && $is_default) { diff --git a/mod/rpost.php b/mod/rpost.php index dc25444a3..309208870 100644 --- a/mod/rpost.php +++ b/mod/rpost.php @@ -62,6 +62,17 @@ function rpost_content(&$a) { unset($_SESSION['rpost']); } + if(array_key_exists('channel',$_REQUEST)) { + $r = q("select channel_id from channel where channel_account_id = %d and channel_address = '%s' limit 1", + intval(get_account_id()), + dbesc($_REQUEST['channel']) + ); + if($r) { + require_once('include/security.php'); + $change = change_channel($r[0]['channel_id']); + } + } + if($_REQUEST['remote_return']) { $_SESSION['remote_return'] = $_REQUEST['remote_return']; } diff --git a/mod/search.php b/mod/search.php index 82990913b..663d355e2 100644 --- a/mod/search.php +++ b/mod/search.php @@ -39,7 +39,8 @@ function search_content(&$a,$update = 0, $load = false) { $search = ((x($_GET,'tag')) ? trim(rawurldecode($_GET['tag'])) : ''); } - $o .= search($search,'search-box','/search',((local_user()) ? true : false)); + if((! local_user()) || (! feature_enabled(local_user(),'savedsearch'))) + $o .= search($search,'search-box','/search',((local_user()) ? true : false)); if(strpos($search,'#') === 0) { $tag = true; @@ -114,6 +115,10 @@ function search_content(&$a,$update = 0, $load = false) { $pub_sql = public_permissions_sql(get_observer_hash()); + require_once('include/identity.php'); + + $sys = get_sys_channel(); + if(($update) && ($load)) { $itemspage = get_pconfig(local_user(),'system','itemspage'); $a->set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); @@ -125,24 +130,24 @@ function search_content(&$a,$update = 0, $load = false) { if(local_user()) { $r = q("SELECT distinct mid, item.id as item_id, item.* from item WHERE item_restrict = 0 - AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 ) - OR ( `item`.`uid` = %d )) + AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 ) + OR ( `item`.`uid` = %d )) OR item.owner_xchan = '%s' ) $sql_extra group by mid ORDER BY created DESC $pager_sql ", intval(local_user()), - intval(ABOOK_FLAG_BLOCKED) - + dbesc($sys['xchan_hash']) ); } if($r === null) { $r = q("SELECT distinct mid, item.id as item_id, item.* from item WHERE item_restrict = 0 - AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' + AND (((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 ) - and owner_xchan in ( " . stream_perms_xchans(($observer) ? PERMS_NETWORK : PERMS_PUBLIC) . " )) - $pub_sql ) + and owner_xchan in ( " . stream_perms_xchans(($observer) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " )) + $pub_sql ) OR owner_xchan = '%s') $sql_extra - group by mid ORDER BY created DESC $pager_sql" + group by mid ORDER BY created DESC $pager_sql", + dbesc($sys['xchan_hash']) ); } } diff --git a/mod/settings.php b/mod/settings.php index 3ab34f145..c72fdc8c4 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, )); @@ -795,7 +792,8 @@ function settings_content(&$a) { $perm_opts = array( array( t('Nobody except yourself'), 0), array( t('Only those you specifically allow'), PERMS_SPECIFIC), - array( t('Anybody in your address book'), PERMS_CONTACTS), + array( t('Approved connections'), PERMS_CONTACTS), + array( t('Any connections'), PERMS_PENDING), array( t('Anybody on this website'), PERMS_SITE), array( t('Anybody in this network'), PERMS_NETWORK), array( t('Anybody authenticated'), PERMS_AUTHED), @@ -960,7 +958,7 @@ function settings_content(&$a) { '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), intval($channel['channel_max_friend_req']) , t('May reduce spam activity')), '$permissions' => t('Default Post Permissions'), '$permdesc' => t("\x28click to open/close\x29"), - '$aclselect' => populate_acl($perm_defaults), + '$aclselect' => populate_acl($perm_defaults,false), '$suggestme' => $suggestme, '$group_select' => $group_select, diff --git a/mod/setup.php b/mod/setup.php index 9eccffe75..69e026056 100755 --- a/mod/setup.php +++ b/mod/setup.php @@ -45,14 +45,14 @@ function setup_post(&$a) { break; // just in case return don't return :) case 3: $urlpath = $a->get_path(); - $dbhost = notags(trim($_POST['dbhost'])); - $dbport = intval(notags(trim($_POST['dbport']))); - $dbuser = notags(trim($_POST['dbuser'])); - $dbpass = notags(trim($_POST['dbpass'])); - $dbdata = notags(trim($_POST['dbdata'])); - $phpath = notags(trim($_POST['phpath'])); - $adminmail = notags(trim($_POST['adminmail'])); - $siteurl = notags(trim($_POST['siteurl'])); + $dbhost = trim($_POST['dbhost']); + $dbport = intval(trim($_POST['dbport'])); + $dbuser = trim($_POST['dbuser']); + $dbpass = trim($_POST['dbpass']); + $dbdata = trim($_POST['dbdata']); + $phpath = trim($_POST['phpath']); + $adminmail = trim($_POST['adminmail']); + $siteurl = trim($_POST['siteurl']); require_once('include/dba/dba_driver.php'); unset($db); @@ -547,7 +547,7 @@ function check_htaccess(&$checks) { $help = ""; $ssl_error = false; - $url = $a->get_baseurl() . '/test/rewrite'; + $url = $a->get_baseurl() . '/setup/testrewrite'; if (function_exists('curl_init')){ $test = z_fetch_url($url); diff --git a/mod/tagger.php b/mod/tagger.php index ec5c92184..3d8043f68 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -97,6 +97,9 @@ function tagger_content(&$a) { $bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s'); + // saving here for reference + // also check out x22d5 and x0d6b and x0db8 and x24d0 and xff20 !!! + $termlink = html_entity_decode('⌗') . '[zrl=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/zrl]'; $channel = $a->get_channel(); diff --git a/mod/webpages.php b/mod/webpages.php index dea034357..431caa628 100644 --- a/mod/webpages.php +++ b/mod/webpages.php @@ -84,7 +84,7 @@ function webpages_content(&$a) { 'nickname' => $a->profile['channel_address'], 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), 'bang' => (($group || $cid) ? '!' : ''), - 'acl' => ((local_user() && local_user() == $owner) ? populate_acl($channel_acl) : ''), + 'acl' => ((local_user() && local_user() == $owner) ? populate_acl($channel_acl,false) : ''), 'visitor' => true, 'profile_uid' => intval($owner), 'mimetype' => $mimetype, @@ -106,6 +106,7 @@ function webpages_content(&$a) { if($r) { $pages = array(); foreach($r as $rr) { + unobscure($rr); $pages[$rr['iid']][] = array('url' => $rr['iid'],'pagetitle' => $rr['sid'],'title' => $rr['title'],'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']),'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited'])); } } diff --git a/mod/zfinger.php b/mod/zfinger.php index dcc755992..ddfa37761 100644 --- a/mod/zfinger.php +++ b/mod/zfinger.php @@ -74,10 +74,15 @@ function zfinger_init(&$a) { */ $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash - where (( channel_pageflags & %d ) or not ( channel_pageflags & %d )) order by channel_id limit 1", - intval(PAGE_SYSTEM), - intval(PAGE_REMOVED) + where ( channel_pageflags & %d ) order by channel_id limit 1", + intval(PAGE_SYSTEM) ); + if(! $r) { + $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash + where not ( channel_pageflags & %d ) order by channel_id limit 1", + intval(PAGE_REMOVED) + ); + } } } else { @@ -116,8 +121,8 @@ function zfinger_init(&$a) { $profile['description'] = $p[0]['pdesc']; $profile['birthday'] = $p[0]['dob']; - if($profile['birthday'] != '0000-00-00') - $profile['next_birthday'] = z_birthday($p[0]['dob'],$e['channel_timezone']); + if(($profile['birthday'] != '0000-00-00') && (($bd = z_birthday($p[0]['dob'],$e['channel_timezone'])) !== '')) + $profile['next_birthday'] = $bd; if($age = age($p[0]['dob'],$e['channel_timezone'],'')) $profile['age'] = $age; |