diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/bbcode.php | 22 | ||||
-rw-r--r-- | include/comanche.php | 75 | ||||
-rw-r--r-- | include/conversation.php | 48 | ||||
-rw-r--r-- | include/enotify.php | 6 | ||||
-rwxr-xr-x | include/items.php | 74 | ||||
-rw-r--r-- | include/nav.php | 2 | ||||
-rw-r--r-- | include/notifier.php | 4 | ||||
-rwxr-xr-x | include/text.php | 104 | ||||
-rw-r--r-- | include/zot.php | 19 |
9 files changed, 279 insertions, 75 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index 4647b8567..997cbac2e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -106,48 +106,28 @@ function bb_ShareAttributes($match) { $author = ""; preg_match("/author='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") - $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); - - preg_match('/author="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $author = $matches[1]; + $author = urldecode($matches[1]); $link = ""; preg_match("/link='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $link = $matches[1]; - preg_match('/link="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $link = $matches[1]; - $avatar = ""; preg_match("/avatar='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $avatar = $matches[1]; - preg_match('/avatar="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $avatar = $matches[1]; - $profile = ""; preg_match("/profile='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $profile = $matches[1]; - preg_match('/profile="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $profile = $matches[1]; - $posted = ""; preg_match("/posted='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $posted = $matches[1]; - preg_match('/posted="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $posted = $matches[1]; - // FIXME - this should really be a wall-item-ago so it will get updated on the client $reldate = (($posted) ? relative_date($posted) : ''); diff --git a/include/comanche.php b/include/comanche.php index cf7ecd7c5..56a16fd3b 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -17,16 +17,10 @@ function pdl_selector($uid,$current="") { $o = ''; - // You can use anybody's Comanche layouts on this site that haven't been protected in some way - $sql_extra = item_permissions_sql($uid); - // By default order by title (therefore at this time pdl's need a unique title across this system), - // though future work may allow categorisation - // based on taxonomy terms - - $r = q("select title, mid from item where (item_restrict & %d) $sql_extra order by title", - intval(ITEM_PDL) + $r = q("select item_id.*, mid from item_id left join item on iid = item.id where item_id.uid = %d and item_id.uid = item.uid and service = 'PDL' order by sid asc", + intval($owner) ); $arr = array('channel_id' => $uid, 'current' => $current, 'entries' => $r); @@ -39,7 +33,7 @@ function pdl_selector($uid,$current="") { $entries[] = array('title' => t('Default'), 'mid' => ''); foreach($entries as $selection) { $selected = (($selection == $current) ? ' selected="selected" ' : ''); - $o .= "<option value=\"{$selection['mid']}\" $selected >{$selection['title']}</option>"; + $o .= "<option value=\"{$selection['mid']}\" $selected >{$selection['sid']}</option>"; } $o .= '</select>'; @@ -51,21 +45,29 @@ function pdl_selector($uid,$current="") { function comanche_parser(&$a,$s) { - $cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $matches, $s); + $cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $s, $matches); if($cnt) $a->page['template'] = trim($matches[1]); - $cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $matches, $s); + $cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $s, $matches); if($cnt) $a->layout['theme'] = trim($matches[1]); - $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $matches, $s, PREG_SET_ORDER); + $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { $a->layout['region_' . $mtch[1]] = comanche_region($a,$mtch[2]); } } + $cnt = preg_match_all("/\[webpage\](.*?)\[\/webpage\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + // only the last webpage definition is used if there is more than one + foreach($matches as $mtch) { + $a->layout['webpage'] = comanche_webpage($a,$mtch[1]); + } + } + } @@ -77,10 +79,47 @@ function comanche_menu($name) { function comanche_replace_region($match) { $a = get_app(); - if(array_key_exists($match[1],$a->page)) + if(array_key_exists($match[1],$a->page)) { return $a->page[$match[1]]; + } +} + +function comanche_block($name) { + $o = ''; + $r = q("select * from item left join item_id on iid = item_id and item_id.uid = item.uid and service = 'BUILDBLOCK' and sid = '%s' limit 1", + dbesc($name) + ); + if($r) { + $o = '<div class="widget bblock">'; + if($r[0]['title']) + $o .= '<h3>' . $r[0]['title'] . '</h3>'; + $o .= prepare_text($r[0]['body'],$r[0]['mimetype']); + $o .= '</div>'; + + } + return $o; +} + +// This doesn't really belong in Comanche, but it could also be argued that it is the perfect place. +// We need to be able to select what kind of template and decoration to use for the webpage at the heart of our content. +// For now we'll allow an '[authored]' element which defaults to name and date, or 'none' to remove these, and perhaps +// 'full' to provide a social network style profile photo. +// But leave it open to have richer templating options and perhaps ultimately discard this one, once we have a better idea +// of what template and webpage options we might desire. + +function comanche_webpage(&$a,$s) { + + $ret = array(); + $cnt = preg_match_all("/\[authored\](.*?)\[\/authored\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $ret['authored'] = $mtch[1]; + } + } + return $ret; } + // Widgets will have to get any operational arguments from the session, // the global app environment, or config storage until we implement argument passing @@ -96,16 +135,22 @@ function comanche_widget($name,$args = null) { function comanche_region(&$a,$s) { - $cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $matches, $s, PREG_SET_ORDER); + $cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { $s = str_replace($mtch[0],comanche_menu(trim($mtch[1])),$s); } } + $cnt = preg_match_all("/\[block\](.*?)\[\/block\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $s = str_replace($mtch[0],comanche_block(trim($mtch[1])),$s); + } + } // need to modify this to accept parameters - $cnt = preg_match_all("/\[widget\](.*?)\[\/widget\]/ism", $matches, $s, PREG_SET_ORDER); + $cnt = preg_match_all("/\[widget\](.*?)\[\/widget\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { $s = str_replace($mtch[0],comanche_widget(trim($mtch[1])),$s); diff --git a/include/conversation.php b/include/conversation.php index 2157f8291..0c1479356 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1009,9 +1009,34 @@ function status_editor($a,$x,$popup=false) { $geotag = (($x['allow_location']) ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : ''); $plaintext = true; + if(feature_enabled(local_user(),'richtext')) $plaintext = false; + $mimeselect = ''; + if(array_key_exists('mimetype',$x) && $x['mimetype']) { + if($x['mimetype'] != 'text/bbcode') + $plaintext = true; + if($x['mimetype'] === 'choose') { + $mimeselect = mimetype_select($x['profile_uid']); + } + else + $mimeselect = '<input type="hidden" name="mimetype" value="' . $x['mimetype'] . '" />'; + } + + $layoutselect = ''; + if(array_key_exists('layout',$x) && $x['layout']) { + if($x['layout'] === 'choose') { + $layoutselect = layout_select($x['profile_uid']); + } + else + $layoutselect = '<input type="hidden" name="layout_mid" value="' . $x['layout'] . '" />'; + } + + + + $webpage = ((x($x,'webpage')) ? $x['webpage'] : ''); + $tpl = get_markup_template('jot-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array( @@ -1042,7 +1067,7 @@ function status_editor($a,$x,$popup=false) { '$return_path' => $a->query_string, '$action' => $a->get_baseurl(true) . '/item', '$share' => (x($x,'button') ? $x['button'] : t('Share')), - '$webpage' => (x($x,'webpage') ? '1' : ''), + '$webpage' => $webpage, '$placeholdpagetitle' => t('Page link title'), '$pagetitle' => (x($x,'pagetitle') ? $x['pagetitle'] : ''), '$upload' => t('Upload photo'), @@ -1061,7 +1086,7 @@ function status_editor($a,$x,$popup=false) { '$shortnoloc' => t('clear location'), '$title' => "", '$placeholdertitle' => t('Set title'), - '$catsenabled' => ((feature_enabled($x['profile_uid'],'categories')) ? 'categories' : ''), + '$catsenabled' => ((feature_enabled($x['profile_uid'],'categories') && (! $webpage)) ? 'categories' : ''), '$category' => "", '$placeholdercategory' => t('Categories (comma-separated list)'), '$wait' => t('Please wait'), @@ -1079,6 +1104,8 @@ function status_editor($a,$x,$popup=false) { '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $x['lockstate'], '$acl' => $x['acl'], + '$mimeselect' => $mimeselect, + '$layoutselect' => $layoutselect, '$showacl' => ((array_key_exists('showacl',$x)) ? $x['showacl'] : 'yes'), '$bang' => $x['bang'], '$profile_uid' => $x['profile_uid'], @@ -1234,12 +1261,21 @@ function render_location_default($item) { function prepare_page($item) { + + $a = get_app(); + $naked = ((get_pconfig($item['uid'],'system','nakedpage')) ? 1 : 0); + if(array_key_exists('webpage',$a->layout) && array_key_exists('authored',$a->layout['webpage'])) { + if($a->layout['webpage']['authored'] === 'none') + $naked = 1; + // ... other possible options + } + return replace_macros(get_markup_template('page_display.tpl'),array( - '$author' => $item['author']['xchan_name'], - '$auth_url' => $item['author']['xchan_url'], - '$date' => datetime_convert('UTC',date_default_timezone_get(),$item['created'],'Y-m-d H:i'), + '$author' => (($naked) ? '' : $item['author']['xchan_name']), + '$auth_url' => (($naked) ? '' : $item['author']['xchan_url']), + '$date' => (($naked) ? '' : datetime_convert('UTC',date_default_timezone_get(),$item['created'],'Y-m-d H:i')), '$title' => smilies(bbcode($item['title'])), - '$body' => smilies(bbcode($item['body'])) + '$body' => prepare_text($item['body'],$item['mimetype']) )); } diff --git a/include/enotify.php b/include/enotify.php index a15e42b73..b2a4f5856 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -379,11 +379,9 @@ function notification($params) { logger('notification: sending notification email'); - $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n", - $body))),ENT_QUOTES,'UTF-8')); + $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r", "\\n"), array( "", "\n"), $body))),ENT_QUOTES,'UTF-8')); - $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), - "<br />\n",$body))), ENT_QUOTES,'UTF-8'); + $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r","\\n"), array("","<br />\n"),$body))), ENT_QUOTES,'UTF-8'); // use $_SESSION['zid_override'] to force zid() to use diff --git a/include/items.php b/include/items.php index c695a9b72..cd3ef7f68 100755 --- a/include/items.php +++ b/include/items.php @@ -220,16 +220,18 @@ function get_public_feed($channel,$params) { $start = 0; $records = 40; $direction = 'desc'; + $pages = 0; if(! $params) $params = array(); - $params['type'] = ((x($params,'type')) ? $params['type'] : 'xml'); - $params['begin'] = ((x($params,'begin')) ? $params['begin'] : '0000-00-00 00:00:00'); - $params['end'] = ((x($params,'end')) ? $params['end'] : datetime_convert('UTC','UTC','now')); - $params['start'] = ((x($params,'start')) ? $params['start'] : 0); - $params['records'] = ((x($params,'records')) ? $params['records'] : 40); - $params['direction'] = ((x($params,'direction')) ? $params['direction'] : 'desc'); + $params['type'] = ((x($params,'type')) ? $params['type'] : 'xml'); + $params['begin'] = ((x($params,'begin')) ? $params['begin'] : '0000-00-00 00:00:00'); + $params['end'] = ((x($params,'end')) ? $params['end'] : datetime_convert('UTC','UTC','now')); + $params['start'] = ((x($params,'start')) ? $params['start'] : 0); + $params['records'] = ((x($params,'records')) ? $params['records'] : 40); + $params['direction'] = ((x($params,'direction')) ? $params['direction'] : 'desc'); + $params['pages'] = ((x($params,'pages')) ? intval($params['pages']) : 0); switch($params['type']) { case 'json': @@ -250,9 +252,15 @@ function get_feed_for($channel, $observer_hash, $params) { if(! channel) http_status_exit(401); - if(! perm_is_allowed($channel['channel_id'],$observer_hash,'view_stream')) - http_status_exit(403); + if($params['pages']) { + if(! perm_is_allowed($channel['channel_id'],$observer_hash,'view_pages')) + http_status_exit(403); + } + else { + if(! perm_is_allowed($channel['channel_id'],$observer_hash,'view_stream')) + http_status_exit(403); + } $items = items_fetch(array( 'wall' => '1', 'datequery' => $params['begin'], @@ -260,6 +268,7 @@ function get_feed_for($channel, $observer_hash, $params) { 'start' => $params['start'], // FIXME 'records' => $params['records'], // FIXME 'direction' => $params['direction'], // FIXME + 'pages' => $params['pages'], 'order' => 'post' ), $channel, $observer_hash, CLIENT_MODE_NORMAL, get_app()->module); @@ -1361,6 +1370,17 @@ function item_store($arr,$allow_exec = false) { return 0; } + // If a page layout is provided, ensure it exists and belongs to us. + + if(array_key_exists('layout_mid',$arr) && $arr['layout_mid']) { + $l = q("select item_restrict from item where mid = '%s' and uid = %d limit 1", + dbesc($arr['layout_mid']), + intval($arr['uid']) + ); + if((! $l) || (! ($l[0]['item_restrict'] & ITEM_PDL))) + unset($arr['layout_mid']); + } + // Don't let anybody set these, either intentionally or accidentally if(array_key_exists('id',$arr)) @@ -1386,20 +1406,16 @@ function item_store($arr,$allow_exec = false) { $arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : 0 ); $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : 0 ); - // this is a bit messy - we really need an input filter chain that temporarily undoes obscuring - if($arr['mimetype'] != 'text/html' && $arr['mimetype'] != 'application/x-php') { - if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false)) - $arr['body'] = escape_tags($arr['body']); - if((strpos($arr['title'],'<') !== false) || (strpos($arr['title'],'>') !== false)) - $arr['title'] = escape_tags($arr['title']); - } + $arr['title'] = escape_tags($arr['title']); // only detect language if we have text content, and if the post is private but not yet // obscured, make it so. if(! ($arr['item_flags'] & ITEM_OBSCURED)) { $arr['lang'] = detect_language($arr['body']); + // apply the input filter here - if it is obscured it has been filtered already + $arr['body'] = z_input_filter($arr['uid'],$arr['body'],$arr['mimetype']); $allowed_languages = get_pconfig($arr['uid'],'system','allowed_languages'); @@ -2003,8 +2019,13 @@ function tag_deliver($uid,$item_id) { intval($item['parent']), intval($uid) ); - if(($x) && ($x[0]['item_flags'] & ITEM_UPLINK) && ($x[0]['author_xchan'] == $item['author_xchan'])) { - logger('tag_deliver: creating second delivery chain for owner comment.'); + +// issue #59 +// FIXME - check security on post and allowed senders, right now we just allow it. The author *may* be foreign and the original owner is lost on our copy of the post. So this could be very hard to verify. For instance what happens if the top-level post was a wall-to-wall? +// if(($x) && ($x[0]['item_flags'] & ITEM_UPLINK) && ($x[0]['author_xchan'] == $item['author_xchan'])) { + if(($x) && ($x[0]['item_flags'] & ITEM_UPLINK)) { +// logger('tag_deliver: creating second delivery chain for owner comment.'); + logger('tag_deliver: creating second delivery chain for comment to tagged post.'); // now change this copy of the post to a forum head message and deliver to all the tgroup members // also reset all the privacy bits to the forum default permissions @@ -2926,9 +2947,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { $o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n"; $o .= '<published>' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '</published>' . "\r\n"; $o .= '<updated>' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '</updated>' . "\r\n"; - $o .= '<zot:env>' . base64url_encode($body, true) . '</zot:env>' . "\r\n"; - // FIXME for other content types - $o .= '<content type="' . $type . '" >' . xmlify((($type === 'html') ? bbcode($body) : $body)) . '</content>' . "\r\n"; + + $o .= '<content type="' . $type . '" >' . xmlify(prepare_text($body,$item['mimetype'])) . '</content>' . "\r\n"; $o .= '<link rel="alternate" type="text/html" href="' . xmlify($item['plink']) . '" />' . "\r\n"; if($item['location']) { @@ -3698,11 +3718,17 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C require_once('include/security.php'); $sql_extra .= item_permissions_sql($channel['channel_id']); + if($arr['pages']) + $item_restrict = " AND (item_restrict & " . ITEM_WEBPAGE . ") "; + else + $item_restrict = " AND item_restrict = 0 "; + + if($arr['nouveau'] && ($client_mode & CLIENT_MODELOAD) && $channel) { // "New Item View" - show all items unthreaded in reverse created date order $items = q("SELECT item.*, item.id AS item_id FROM item - WHERE $item_uids AND item_restrict = 0 + WHERE $item_uids $item_restrict $simple_update $sql_extra $sql_nets ORDER BY item.received DESC $pager_sql " @@ -3729,7 +3755,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $r = q("SELECT distinct item.id AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan - WHERE $item_uids AND item.item_restrict = 0 + WHERE $item_uids $item_restrict AND item.parent = item.id and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets @@ -3742,7 +3768,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C // update $r = q("SELECT item.parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan - WHERE $item_uids AND item.item_restrict = 0 $simple_update + WHERE $item_uids $item_restrict $simple_update and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets ", intval(ABOOK_FLAG_BLOCKED) @@ -3758,7 +3784,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $parents_str = ids_to_querystr($r,'item_id'); $items = q("SELECT item.*, item.id AS item_id FROM item - WHERE $item_uids AND item.item_restrict = 0 + WHERE $item_uids $item_restrict AND item.parent IN ( %s ) $sql_extra ", dbesc($parents_str) diff --git a/include/nav.php b/include/nav.php index 626caf981..dd11f10d5 100644 --- a/include/nav.php +++ b/include/nav.php @@ -200,7 +200,7 @@ EOT; $a->page['nav'] .= replace_macros($tpl, array( '$baseurl' => $a->get_baseurl(), - '$langselector' => lang_selector(), + '$langselector' => ((get_config('system','select_language')) ? lang_selector() : ''), '$sitelocation' => $sitelocation, '$nav' => $nav, '$banner' => $banner, diff --git a/include/notifier.php b/include/notifier.php index 2a0301357..5dcd7b58c 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -257,6 +257,10 @@ function notifier_run($argv, $argc){ return; } + if($target_item['item_restrict'] & ITEM_PDL) { + logger('notifier: target item ITEM_PDL', LOGGER_DEBUG); + return; + } $s = q("select * from channel where channel_id = %d limit 1", intval($target_item['uid']) diff --git a/include/text.php b/include/text.php index 99d5c9d78..ac82e4429 100755 --- a/include/text.php +++ b/include/text.php @@ -81,6 +81,34 @@ function escape_tags($string) { } +function z_input_filter($channel_id,$s,$type = 'text/bbcode') { + + if($type === 'text/bbcode') + return escape_tags($s); + if($type === 'text/markdown') + return escape_tags($s); + if($type == 'text/plain') + return escape_tags($s); + $r = q("select account_id, account_roles from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", + intval($channel_id) + ); + if($r && ($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE)) { + if(local_user() && (get_account_id() == $r[0]['account_id'])) { + return $s; + } + } + + if($type === 'text/html') + return purify_html($s); + + return escape_tags($s); + +} + + + + + function purify_html($s) { require_once('library/HTMLPurifier.auto.php'); require_once('include/html2bbcode.php'); @@ -1127,6 +1155,7 @@ function prepare_body(&$item,$attach = false) { function prepare_text($text,$content_type = 'text/bbcode') { + switch($content_type) { case 'text/plain': @@ -1171,6 +1200,8 @@ function prepare_text($text,$content_type = 'text/bbcode') { break; } +//logger('prepare_text: ' . $s); + return $s; } @@ -1290,9 +1321,64 @@ function unamp($s) { return str_replace('&', '&', $s); } +function layout_select($channel_id, $current = '') { + $r = q("select mid,sid from item left join item_id on iid = item.id where service = 'PDL' and item.uid = item_id.uid and item_id.uid = %d and (item_restrict & %d)", + intval($channel_id), + intval(ITEM_PDL) + ); + if($r) { + $o = t('Select a page layout: '); + $o .= '<select name="layout_mid" id="select-layout_mid" >'; + $empty_selected = (($current === '') ? ' selected="selected" ' : ''); + $o .= '<option value="" ' . $empty_selected . '>' . t('default') . '</option>'; + foreach($r as $rr) { + $selected = (($rr['mid'] == $current) ? ' selected="selected" ' : ''); + $o .= '<option value="' . $rr['mid'] . '"' . $selected . '>' . $rr['sid'] . '</option>'; + } + $o .= '</select>'; + } + + return $o; +} + + +function mimetype_select($channel_id, $current = 'text/bbcode') { + + $x = array( + 'text/bbcode', + 'text/html', + 'text/markdown', + 'text/plain' + ); + + $r = q("select account_id, account_roles from account left join channel on account_id = channel_account_id where + channel_id = %d limit 1", + intval($channel_id) + ); + + if($r) { + if($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) { + if(local_user() && get_account_id() == $r[0]['account_id']) + $x[] = 'application/x-php'; + } + } + + $o = t('Page content type: '); + $o .= '<select name="mimetype" id="mimetype-select">'; + foreach($x as $y) { + $select = (($y == $current) ? ' selected="selected" ' : ''); + $o .= '<option name="' . $y . '"' . $select . '>' . $y . '</option>'; + } + $o .= '</select>'; + + return $o; + +} + + function lang_selector() { global $a; @@ -1740,4 +1826,20 @@ function json_decode_plus($s) { $x = json_decode(str_replace(array('\\"','\\\\'),array('"','\\'),$s),true); return $x; -}
\ No newline at end of file +} + + +function design_tools() { +// FIXME - this should be a template + + $o = '<div class="widget design-tools">'; + $o .= '<h3>' . t('Design') . '</h3>'; + $o .= '<a href="blocks">' . t('Blocks') . '</a>' . EOL; + $o .= '<a href="menu">' . t('Menus') . '</a>' . EOL; + $o .= '<a href="layout">' . t('Layouts') . '</a>' . EOL; + $o .= '<a href="webpages">' . t('Pages') . '</a>' . EOL; + $o .= '</div>'; + return $o; + +} + diff --git a/include/zot.php b/include/zot.php index 49f58c3bd..33522b485 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1523,10 +1523,22 @@ function import_site($arr,$pubkey) { if($arr['register_policy'] == 'approve') $register_policy = REGISTER_APPROVE; + $access_policy = 0; + if(array_key_exists('access_policy',$arr)) { + if($arr['access_policy'] === 'private') + $access_policy = ACCESS_PRIVATE; + if($arr['access_policy'] === 'paid') + $access_policy = ACCESS_PAID; + if($arr['access_policy'] === 'free') + $access_policy = ACCESS_FREE; + } + + if($update) { - $r = q("update site set site_flags = %d, site_directory = '%s', site_register = %d, site_update = '%s' + $r = q("update site set site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s' where site_url = '%s' limit 1", intval($site_directory), + intval($access_policy), dbesc(htmlentities($arr['directory_url'],ENT_COMPAT,'UTF-8',false)), intval($register_policy), dbesc(datetime_convert()), @@ -1537,10 +1549,11 @@ function import_site($arr,$pubkey) { } } else { - $r = q("insert into site ( site_url, site_flags, site_update, site_directory, site_register ) - values ( '%s', %d, '%s', '%s', %d )", + $r = q("insert into site ( site_url, site_acccess, site_flags, site_update, site_directory, site_register ) + values ( '%s', %d, %d, '%s', '%s', %d )", dbesc(htmlentities($arr['url'],ENT_COMPAT,'UTF-8',false)), intval($site_directory), + intval($access_policy), dbesc(datetime_convert()), dbesc(htmlentities($arr['directory_url'],ENT_COMPAT,'UTF-8',false)), intval($register_policy) |