The Red Matrix
|
Functions | |
replace_macros ($s, $r) | |
random_string ($size=64, $type=RANDOM_STRING_HEX) | |
notags ($string) | |
escape_tags ($string) | |
purify_html ($s) | |
autoname ($len) | |
xmlify ($str) | |
unxmlify ($s) | |
if(!function_exists('hex2bin')) | paginate (&$a) |
alt_pager (&$a, $i, $more= '', $less= '') | |
expand_acl ($s) | |
sanitise_acl (&$item) | |
perms2str ($p) | |
item_message_id () | |
photo_new_resource () | |
attribute_contains ($attr, $s) | |
logger ($msg, $level=0) | |
dlogger ($msg, $level=0) | |
profiler ($t1, $t2, $label) | |
activity_match ($haystack, $needle) | |
get_tags ($s) | |
qp ($s) | |
get_mentions ($item, $tags) | |
contact_block () | |
chanlink_hash ($s) | |
chanlink_url ($s) | |
chanlink_cid ($d) | |
magiclink_url ($observer, $myaddr, $url) | |
micropro ($contact, $redirect=false, $class= '', $textmode=false) | |
search ($s, $id='search-box', $url='/search', $save=false) | |
valid_email ($x) | |
linkify ($s) | |
get_poke_verbs () | |
get_mood_verbs () | |
smilies ($s, $sample=false) | |
smile_encode ($m) | |
smile_decode ($m) | |
preg_heart ($x) | |
day_translate ($s) | |
normalise_link ($url) | |
link_compare ($a, $b) | |
prepare_body ($item, $attach=false) | |
prepare_text ($text, $content_type= 'text/bbcode') | |
zidify_callback ($match) | |
zidify_img_callback ($match) | |
zidify_links ($s) | |
feed_hublinks () | |
feed_salmonlinks ($nick) | |
get_plink ($item) | |
unamp ($s) | |
lang_selector () | |
return_bytes ($size_str) | |
generate_user_guid () | |
base64url_encode ($s, $strip_padding=true) | |
base64url_decode ($s) | |
cleardiv () | |
bb_translate_video ($s) | |
html2bb_video ($s) | |
array_xmlify ($val) | |
reltoabs ($text, $base) | |
item_post_type ($item) | |
normalise_openid ($s) | |
undo_post_tagging ($s) | |
fix_mce_lf ($s) | |
protect_sprintf ($s) | |
is_a_date_arg ($s) | |
legal_webbie ($s) | |
check_webbie ($arr) | |
ids_to_querystr ($arr, $idx= 'id') | |
xchan_query (&$items, $abook=true) | |
xchan_mail_query (&$item) | |
find_xchan_in_array ($xchan, $arr) | |
get_rel_link ($j, $rel) | |
magic_link ($s) | |
stringify_array_elms (&$arr, $escape=false) | |
jindent ($json) | |
Variables | |
const | RANDOM_STRING_HEX 0x00 |
const | RANDOM_STRING_TEXT 0x01 |
activity_match | ( | $haystack, | |
$needle | |||
) |
alt_pager | ( | & | $a, |
$i, | |||
$more = '' , |
|||
$less = '' |
|||
) |
Referenced by channel_content(), community_content(), directory_content(), message_content(), and network_content().
array_xmlify | ( | $val | ) |
apply xmlify() to all values of array $val, recursively
Referenced by api_apply_template(), and poco_init().
attribute_contains | ( | $attr, | |
$s | |||
) |
Referenced by lrdd().
autoname | ( | $len | ) |
generate a string that's random, but usually pronounceable. used to generate initial passwords
int | $len |
Referenced by check_php(), invite_post(), and lostpass_content().
base64url_decode | ( | $s | ) |
Referenced by aes_unencapsulate(), get_atom_elements(), import_post(), import_xchan(), oembed_init(), pemtome(), post_init(), post_post(), pubrsatome(), smile_decode(), and zfinger_init().
base64url_encode | ( | $s, | |
$strip_padding = true |
|||
) |
Referenced by aes_encapsulate(), allowed_public_recips(), atom_entry(), create_identity(), fix_system_urls(), get_item_elements(), get_mail_elements(), get_profile_elements(), identity_basic_export(), import_post(), import_xchan(), magic_init(), oembed_iframe(), post_post(), random_string(), salmon_key(), smile_encode(), zfinger_init(), zot_build_packet(), zot_fetch(), zot_import(), zot_new_uid(), and zot_register_hub().
bb_translate_video | ( | $s | ) |
Referenced by item_post().
chanlink_cid | ( | $d | ) |
chanlink_hash | ( | $s | ) |
Referenced by message_content(), and micropro().
chanlink_url | ( | $s | ) |
check_webbie | ( | $arr | ) |
Referenced by create_identity(), and new_channel_init().
cleardiv | ( | ) |
Referenced by allfriends_content(), common_content(), and match_content().
contact_block | ( | ) |
Referenced by profile_sidebar().
day_translate | ( | $s | ) |
Referenced by advanced_profile(), cal(), events_content(), format_event_diaspora(), format_event_html(), get_birthdays(), get_events(), ping_init(), and posted_dates().
dlogger | ( | $msg, | |
$level = 0 |
|||
) |
escape_tags | ( | $string | ) |
use this on "body" or "content" input where angle chars shouldn't be removed, and allow them to be safely displayed.
string | $string |
Referenced by admin_page_logs(), channel_content(), create_identity(), events_post(), fsuggest_post(), get_atom_elements(), item_post(), item_store(), item_store_update(), local_delivery(), mail_store(), message_content(), message_post(), network_content(), post_activity_item(), printable(), profiles_post(), and thing_init().
expand_acl | ( | $s | ) |
Referenced by collect_recipients(), enumerate_permissions(), and lockview_content().
feed_hublinks | ( | ) |
return atom link elements for all of our hubs
feed_salmonlinks | ( | $nick | ) |
find_xchan_in_array | ( | $xchan, | |
$arr | |||
) |
fix_mce_lf | ( | $s | ) |
Referenced by item_post(), message_post(), and profiles_post().
generate_user_guid | ( | ) |
get_mentions | ( | $item, | |
$tags | |||
) |
get_mood_verbs | ( | ) |
Referenced by mood_content(), and mood_init().
get_plink | ( | $item | ) |
Referenced by conversation(), and Item\get_template_data().
get_poke_verbs | ( | ) |
Referenced by poke_content(), and poke_init().
get_rel_link | ( | $j, | |
$rel | |||
) |
Referenced by localize_item(), remove_community_tag(), and tag_deliver().
get_tags | ( | $s | ) |
Referenced by item_post(), and photos_post().
html2bb_video | ( | $s | ) |
Referenced by api_statuses_mediap(), api_statuses_update(), and get_atom_elements().
ids_to_querystr | ( | $arr, | |
$idx = 'id' |
|||
) |
Referenced by channel_content(), display_content(), items_fetch(), network_content(), and search_content().
is_a_date_arg | ( | $s | ) |
Referenced by channel_content(), network_content(), and network_init().
item_message_id | ( | ) |
item_post_type | ( | $item | ) |
Referenced by notification().
jindent | ( | $json | ) |
Indents a flat JSON string to make it more human-readable.
string | $json | The original JSON string to process. |
lang_selector | ( | ) |
Referenced by nav().
legal_webbie | ( | $s | ) |
Referenced by check_webbie(), and new_channel_init().
link_compare | ( | $a, | |
$b | |||
) |
Compare two URLs to see if they are the same, but ignore slight but hopefully insignificant differences such as if one is https and the other isn't, or if one is www.something and the other isn't - and also ignore case differences.
Return true if the URLs match, otherwise false.
Referenced by consume_feed(), like_puller(), local_delivery(), tag_deliver(), tgroup_check(), and zid().
linkify | ( | $s | ) |
Function: linkify
Replace naked text hyperlink with HTML formatted hyperlink
Referenced by advanced_profile().
logger | ( | $msg, | |
$level = 0 |
|||
) |
Referenced by account_verify_password(), Item\add_child(), Conversation\add_thread(), advanced_profile(), allowed_public_recips(), api_call(), api_channel_stream(), api_export_basic(), api_favorites(), api_get_user(), api_login(), api_statuses_destroy(), api_statuses_mediap(), api_statuses_repeat(), api_statuses_show(), api_statuses_update(), api_statuses_user_timeline(), authenticate_success(), avatar_img(), base64url_decode(), channel_remove(), chanview_content(), check_config(), check_form_security_token_ForbiddenOnErr(), check_form_security_token_redirectOnErr(), consume_feed(), conversation(), create_account(), create_identity(), crepair_post(), cronhooks_run(), datetime_convert(), delete_imported_item(), deliver_run(), detect_language(), dfrn_deliver(), directory_content(), directory_run(), display_content(), email_send(), encode_item(), encode_mail(), expire_run(), feed_init(), fetch_lrdd_template(), fetch_xrd_links(), filer_content(), filerm_content(), fix_private_photos(), Conversation\get_template_data(), group_content(), guess_image_type(), head_set_icon(), http_status_exit(), import_author_xchan(), import_channel_photo(), import_directory_profile(), import_post(), import_profile_photo(), import_xchan(), install_plugin(), item_expire(), item_post(), item_store(), item_store_update(), like_content(), limit_body_size(), load_plugin(), local_delivery(), FKOAuth1\loginUser(), FKOAuthDataStore\lookup_consumer(), FKOAuthDataStore\lookup_token(), lrdd(), magic_init(), mail_store(), message_content(), message_post(), mini_group_select(), mood_init(), FKOAuthDataStore\new_access_token(), new_contact(), new_keypair(), FKOAuthDataStore\new_request_token(), notification(), notifier_run(), onepoll_run(), parse_url_content(), parse_xml_string(), photo_upload(), photos_post(), ping_init(), poco_init(), poco_load(), poke_init(), poller_run(), post_activity_item(), post_init(), post_post(), process_delivery(), process_mail_delivery(), process_profile_delivery(), profile_load(), dba_mysql\q(), dba_mysqli\q(), q(), queue_run(), redir_init(), register_content(), reload_plugins(), Item\remove_child(), remove_community_tag(), remove_queue_item(), scale_external_images(), search_ac_init(), enotify\send(), send_reg_approval_email(), Conversation\set_mode(), subthread_content(), syncdirs(), tag_deliver(), tagger_content(), tgroup_check(), uninstall_plugin(), unload_plugin(), update_imported_item(), update_queue_time(), webfinger(), webfinger_dfrn(), webpages_content(), xml2array(), xml_status(), zfinger_init(), zot_build_packet(), zot_fetch(), zot_finger(), zot_gethub(), zot_import(), zot_process_response(), zot_refresh(), and zot_register_hub().
magic_link | ( | $s | ) |
magiclink_url | ( | $observer, | |
$myaddr, | |||
$url | |||
) |
Referenced by item_redir_and_replace_images().
micropro | ( | $contact, | |
$redirect = false , |
|||
$class = '' , |
|||
$textmode = false |
|||
) |
Referenced by contact_block().
normalise_link | ( | $url | ) |
Referenced by best_link_url(), conversation(), delegate_content(), item_photo_menu(), link_compare(), local_delivery(), new_follower(), tag_deliver(), and tgroup_check().
normalise_openid | ( | $s | ) |
notags | ( | $string | ) |
This is our primary input filter.
The high bit hack only involved some old IE browser, forget which (IE5/Mac?) that had an XSS attack vector due to stripping the high-bit on an 8-bit character after cleansing, and angle chars with the high bit set could get through as markup.
This is now disabled because it was interfering with some legitimate unicode sequences and hopefully there aren't a lot of those browsers left.
Use this on any text input where angle chars are not valid or permitted They will be replaced with safer brackets. This may be filtered further if these are not allowed either.
string | $string | Input string |
Referenced by admin_page_logs_post(), admin_page_site_post(), community_content(), connections_content(), consume_feed(), conversation(), create_account(), directory_content(), dirfind_content(), follow_init(), get_atom_elements(), group_post(), help_content(), invite_post(), item_post(), item_store(), item_store_update(), like_content(), local_delivery(), lostpass_post(), mail_store(), message_post(), mood_init(), network_content(), new_follower(), oexchange_content(), photos_post(), poco_init(), poke_init(), profile_tabs(), profiles_post(), qsearch_init(), register_post(), sanitise_acl(), settings_post(), setup_content(), setup_post(), subthread_content(), tagger_content(), and xrd_init().
if (!function_exists('hex2bin')) paginate | ( | & | $a | ) |
perms2str | ( | $p | ) |
Referenced by events_post(), item_post(), photo_upload(), photos_post(), and settings_post().
photo_new_resource | ( | ) |
Referenced by consume_feed(), import_channel_photo(), import_profile_photo(), local_delivery(), and photo_upload().
preg_heart | ( | $x | ) |
prepare_body | ( | $item, | |
$attach = false |
|||
) |
Referenced by conversation(), email_send(), and Item\get_template_data().
prepare_text | ( | $text, | |
$content_type = 'text/bbcode' |
|||
) |
Referenced by advanced_profile(), and prepare_body().
profiler | ( | $t1, | |
$t2, | |||
$label | |||
) |
Referenced by conversation(), and network_content().
protect_sprintf | ( | $s | ) |
Referenced by acl_init(), api_statuses_mentions(), attach_count_files(), attach_list_files(), channel_content(), connections_content(), dirsearch_content(), file_tag_file_query(), item_permissions_sql(), items_fetch(), network_content(), permissions_sql(), photos_list_photos(), public_permissions_sql(), search_ac_init(), search_content(), and term_query().
purify_html | ( | $s | ) |
Referenced by get_atom_elements(), and post_activity_item().
qp | ( | $s | ) |
random_string | ( | $size = 64 , |
|
$type = RANDOM_STRING_HEX |
|||
) |
Referenced by aes_encapsulate(), attach_store(), build_sync_packet(), create_account(), create_identity(), dfrn_deliver(), event_store(), fsuggest_post(), generate_user_guid(), group_add(), item_message_id(), item_store(), local_delivery(), lostpass_content(), lostpass_post(), magic_init(), mail_store(), new_follower(), notification(), notifier_run(), prepare_body(), profiles_init(), redir_init(), removeme_content(), send_message(), send_reg_approval_email(), settings_post(), setup_post(), and thing_init().
reltoabs | ( | $text, | |
$base | |||
) |
Referenced by get_atom_elements().
replace_macros | ( | $s, | |
$r | |||
) |
This is our template processor
string | FriendicaSmarty | $s | the string requiring macro substitution, or an instance of FriendicaSmarty |
array | $r | key value pairs (search => replace) |
Referenced by admin_content(), admin_page_dbsync(), admin_page_logs(), admin_page_plugins(), admin_page_site(), admin_page_summary(), admin_page_themes(), admin_page_users(), advanced_profile(), allfriends_content(), alt_pager(), api_apply_template(), api_content(), apps_content(), App\build_pagehead(), categories_widget(), channel_content(), chanview_content(), check_config(), check_php(), common_content(), common_friends_visitor_widget(), connections_content(), construct_page(), contact_block(), conversation(), crepair_content(), delegate_content(), directory_content(), dirfind_content(), display_content(), editpost_content(), editwebpage_content(), events_content(), fbrowser_content(), field_timezone(), fileas_widget(), filer_content(), findpeople_widget(), follow_widget(), get_birthdays(), Item\get_comment_box(), get_events(), get_feed_for(), group_content(), group_side(), help_content(), hostxrd_init(), import_content(), intro_content(), invite_content(), lang_selector(), login(), lostpass_content(), lostpass_post(), manage_content(), match_content(), message_aside(), message_content(), micropro(), mini_group_select(), mood_content(), nav(), network_content(), new_channel_content(), new_follower(), nogroup_content(), notification(), notifications_content(), notify_content(), oembed_format_object(), oexchange_init(), opensearch_init(), photos_album_widget(), photos_content(), poco_init(), poke_content(), populate_acl(), posted_date_widget(), profile_sidebar(), profile_tabs(), profiles_content(), redbasic_form(), register_content(), removeme_content(), rmagic_content(), saved_searches(), search_content(), send_reg_approval_email(), send_verification_email(), settings_aside(), setup_content(), setup_post(), siteinfo_content(), suggest_content(), thing_content(), user_allow(), vcard_from_xchan(), viewconnections_content(), webpages_content(), and xrd_init().
return_bytes | ( | $size_str | ) |
sanitise_acl | ( | & | $item | ) |
search | ( | $s, | |
$id = 'search-box' , |
|||
$url = '/search' , |
|||
$save = false |
|||
) |
Referenced by saved_searches(), and search_content().
smile_decode | ( | $m | ) |
smile_encode | ( | $m | ) |
smilies | ( | $s, | |
$sample = false |
|||
) |
Function: smilies
Description: Replaces text emoticons with graphical images
: string $s
Returns string
It is expected that this function will be called using HTML text. We will escape text between HTML pre and code blocks from being processed.
At a higher level, the bbcode [nosmile] tag can be used to prevent this function from being executed by the prepare_text() routine when preparing bbcode source for HTML display
Referenced by message_content(), and smilies_content().
stringify_array_elms | ( | & | $arr, |
$escape = false |
|||
) |
Referenced by expand_groups(), identity_basic_export(), lockview_content(), notifier_run(), tagadelic(), and zot_import().
unamp | ( | $s | ) |
undo_post_tagging | ( | $s | ) |
Referenced by editpost_content(), and editwebpage_content().
unxmlify | ( | $s | ) |
Referenced by filer_content(), get_atom_elements(), and local_delivery().
valid_email | ( | $x | ) |
Referenced by check_account_email(), invite_post(), and settings_post().
xchan_mail_query | ( | & | $item | ) |
Referenced by notifier_run().
xchan_query | ( | & | $items, |
$abook = true |
|||
) |
Referenced by api_format_items(), api_statuses_home_timeline(), api_statuses_public_timeline(), api_statuses_show(), channel_content(), display_content(), events_content(), items_fetch(), network_content(), notification(), notifier_run(), page_content(), ping_init(), search_content(), share_init(), and zot_feed().
xmlify | ( | $str | ) |
escape text ($str) for XML transport
string | $str |
Referenced by array_xmlify(), atom_author(), atom_entry(), construct_activity_object(), construct_activity_target(), encode_rel_links(), get_atom_elements(), get_feed_for(), item_getfeedattach(), photos_post(), subthread_content(), tagger_content(), and xml_status().
zidify_callback | ( | $match | ) |
zidify_callback() and zidify_links() work together to turn any HTML a tags with class="zrl" into zid links These will typically be generated by a bbcode '[zrl]' tag. This is done inside prepare_text() rather than bbcode() because the latter is used for general purpose conversions and the former is used only when preparing text for immediate display.
Issues: Currently the order of HTML parameters in the text is somewhat rigid and inflexible. We assume it looks like and will not work if zrl and href appear in a different order.
zidify_img_callback | ( | $match | ) |
zidify_links | ( | $s | ) |
Referenced by notification().
const RANDOM_STRING_HEX 0x00 |
const RANDOM_STRING_TEXT 0x01 |
Referenced by aes_encapsulate(), and random_string().