»

API Documentation


Table of Contents

LJ::CleanHTML::clean - Multifaceted HTML parse function
LJ::Cmdbuffer::flush - flush up to 500 rows of a given command type from the cmdbuffer table
LJ::Cmdbuffer::get_property - get a property of an async job type, either built-in or site-specific
LJ::Memories::count - Returns the number of memories that a user has.
LJ::Memories::create - Create a new memory for a user.
LJ::Memories::delete_by_id - Deletes a bunch of memories by memid.
LJ::Memories::get_by_ditemid - Get memory for a given journal entry.
LJ::Memories::get_by_id - Get memories given some memory ids.
LJ::Memories::get_by_keyword - Get memories given a user and a keyword/keyword id.
LJ::Memories::get_by_user - Get memories given a user.
LJ::Memories::get_keyword_counts - Get a list of keywords and the counts for memories, showing how many memories are under
LJ::Memories::get_keywordids - Get all keyword ids a user has used for a certain memory.
LJ::Memories::get_keywords - Retrieves keyword/keyids without big joins, returns a hashref.
LJ::Memories::update_memory - Updates the description and security of a memory.
LJ::Memories::updated_keywords - Deletes memcached keyword data.
LJ::S1::get_themeid - Loads or returns cached version of given color theme data.
LJ::Talk::can_delete - Determines if a user can delete a comment or entry. Basically, you can delete anything you've posted. You can delete anything posted in something you own (i.e. a comment in your journal, a comment to an entry you made in a community). You can also delete any item in an account you have the "A"dministration edge for.
LJ::Talk::delete_thread - Deletes an entire thread of comments.
LJ::Talk::freeze_comments - Freezes comments. This is the internal helper function called by
LJ::Talk::freeze_thread - Freezes an entire thread of comments.
LJ::Talk::get_comments_in_thread - Gets a list of comment ids that are contained within a thread, including the
LJ::Talk::get_talk2_row - Gets a row of data from talk2.
LJ::Talk::screening_level - Determines the screening level of a particular post given the relevent information.
LJ::Talk::unfreeze_thread - unfreezes an entire thread of comments.
LJ::User::dudata_set - Record or delete disk usage data for a journal
LJ::User::mogfs_userpic_key - Make a mogilefs key for the given pic for the user
LJ::_friends_do - Runs given sql, then deletes the given userid's friends from memcache
LJ::_get_rel_memcache - Helper function: returns memcached value for a given (userid, targetid, type) triple, if valid
LJ::_mod_rel_multi - Sets/Clears relationship edges for lists of user tuples.
LJ::_set_rel_memcache - Helper function: sets memcache values for a given (userid, targetid, type) triple
LJ::accept_comm_invite - Accepts an invitation a user has received. This does all the work to make the
LJ::acct_code_check - Checks the validity of a given account code
LJ::acct_code_decode - Breaks an account code down into its two parts
LJ::acct_code_encode - Given an account ID integer and a 5 digit auth code, returns a 12 digit account code.
LJ::acct_code_generate - Creates invitation code(s) from an optional userid for use by anybody.
LJ::acid_decode - Given an acid encoding from LJ::acid_encode, returns the original decimal number.
LJ::acid_encode - Given a decimal number, returns base 30 encoding using an alphabet of letters & numbers that are not easily mistaken for each other.
LJ::activate_userpics - Sets/unsets userpics as inactive based on account caps
LJ::add_friend - Simple interface to add a friend edge.
LJ::ago_text - Converts integer seconds to English time span
LJ::alldateparts_to_hash - Given a date/time format from MySQL, breaks it into a hash.
LJ::approve_pending_member - Approves someone's request to join a community. This updates the authactions table
LJ::are_hooks - Returns true if the site has one or more hooks installed for the given hookname.
LJ::auth_okay - Validates a user's password. The "clear" or "md5" argument must be present, and either the "actual" argument (the correct password) must be set, or the first argument must be a user object ($u) with the 'password' key set. Note that this is the preferred way to validate a password (as opposed to doing it by hand) since this function will use a pluggable authenticator if one is defined, so LiveJournal installations can be based off an LDAP server, for example.
LJ::auto_linkify - Takes a plain-text string and changes URLs into <a href> tags (auto-linkification)
LJ::bad_input - Returns common BML for reporting form validation errors in a bulletted list.
LJ::blocking_report - Log a report on the total amount of time used in a slow operation to a remote host via UDP.
LJ::can_manage - Given a user and a target user, will determine if the first user is an admin for the target user.
LJ::can_manage_other - Given a user and a target user, will determine if the first user is an admin for the target user, but not if the two are the same.
LJ::can_use_journal -
LJ::can_view - Checks to see if the remote user can view a given journal entry. Note: This is meant for use on single entries at a time, not for calling many times on every entry in a journal.
LJ::canonical_username -
LJ::check_form_auth - Verifies form authentication created with LJ::form_auth.
LJ::check_priv - Check to see if a user has a certain privilege.
LJ::check_referer - Checks if the user is coming from a given URI.
LJ::check_rel - Checks whether two users are in a specified relationship to each other.
LJ::clear_caches - This function is called from a HUP signal handler and is intentionally very very simple (1 line) so we don't core dump on a system without reentrant libraries. It just sets a flag to clear the caches at the beginning of the next request (see LJ::handle_caches). There should be no need to ever call this function directly.
LJ::clear_hooks - Removes all hooks.
LJ::clear_rel - Deletes a relationship between two users or all relationships of a particular type for one user, on either side of the relationship. One of userid,targetid -- bit not both -- may be '*'. In that case, if, say, userid is '*', then all relationship edges with target equal to targetid and of the specified type are deleted. If both userid and targetid are numbers, just one edge is deleted.
LJ::clear_rel_multi - Clear relationship edges for lists of user tuples.
LJ::cmd_buffer_add - Schedules some command to be run sometime in the future which would be too slow to do syncronously with the web request. An example is deleting a journal entry, which requires recursing through a lot of tables and deleting all the appropriate stuff.
LJ::color_fromdb - Takes a value of unknown type from the db and returns an #rrggbb string.
LJ::color_todb - Takes an #rrggbb value and returns a 24-bit decimal number.
LJ::comm_join_request - Registers an authaction to add a user to a community and sends an approval email to the maintainers
LJ::create_account - Creates a new basic account. Note: This function is not really too useful but should be extended to be useful so htdocs/create.bml can use it, rather than doing the work itself.
LJ::create_qr_div - Creates the hidden div that stores the Quick Reply form
LJ::date_to_view_links - Returns HTML of date with links to user's journal.
LJ::days_in_month - Figures out the number of days in a month.
LJ::debug - When $LJ::DEBUG is set, logs the given message to the Apache error log. Or, if $LJ::DEBUG is 2, then prints to STDOUT.
LJ::decode_url_string - Parse URL-style arg/value pairs into a hash.
LJ::delete_all_comments - deletes all comments from a post, permanently, for when a post is deleted
LJ::delete_comments - deletes comments, but not the relational information, so threading doesn't break
LJ::delete_entry - Deletes a user's journal entry
LJ::delete_user -
LJ::did_post - When web pages using cookie authentication, you can't just trust that the remote user wants to do the action they're requesting. It's way too easy for people to force other people into making GET requests to a server. What if a user requested http://server/delete_all_journal.bml and that URL checked the remote user and immediately deleted the whole journal. Now anybody has to do is embed that address in an image tag and a lot of people's journals will be deleted without them knowing. Cookies should only show pages which make no action. When an action is being made, check that it's a POST request.
LJ::disconnect_dbs - Clear cached DB handles and trackers/keepers to partitioned DBs.
LJ::do_to_cluster - Given a subref, this function will pick a random cluster and run the subref,
LJ::durl - Decodes a value that's URL-escaped. See also LJ::eurl.
LJ::ehtml - Escapes a value before it can be put in HTML.
LJ::ejs - Escapes a string value before it can be put in JavaScript.
LJ::end_request - Clears cached DB handles/trackers/keepers (if $LJ::DISCONNECT_DBS is true) and disconnects MemCache handles (if $LJ::DISCONNECT_MEMCACHE is true).
LJ::etags - Escapes < and > from a string
LJ::eurl - Escapes a value before it can be put in a URL. See also LJ::durl.
LJ::event_register - Logs a subscribable event, if anybody's subscribed to it.
LJ::exml - Escapes a value before it can be put in XML.
LJ::expand_embedded -
LJ::expunge_userpic - Expunges a userpic so that the system will no longer deliver this userpic. If
LJ::fill_groups_xmlrpc - Fills a hashref (presumably to be sent to an XMLRPC client, EG fotobilder) with user friend group information
LJ::fill_var_props - S1 utility function to interpolate %%variables%% in a variable. If a modifier is given like %%foo:var%%, then LJ::fvp_transform is called.
LJ::flush_cleanup_handlers - Runs all cleanup handlers registered in @LJ::CLEANUP_HANDLERS
LJ::form_auth - Creates an authentication token to be used later to verify that a form
LJ::fvp_transform - Called from LJ::fill_var_props to do trasformations.
LJ::get_authas_list - Get a list of usernames a given user can authenticate as
LJ::get_authas_user - Given a username, will return a user object if remote is an admin for the username. Otherwise returns undef
LJ::get_bio - gets a user bio, from db or memcache
LJ::get_cap - Given a user object or capability class bit mask and a capability/limit name, returns the maximum value allowed for given user or class, considering all the limits in each class the user is a part of.
LJ::get_cap_min - Just like LJ::get_cap, but returns the minimum value. Although it might not make sense at first, some things are better when they're low, like the minimum amount of time a user might have to wait between getting updates or being allowed to refresh a page.
LJ::get_cluster_def_reader - Returns a definitive cluster reader for a given user, used when the caller wants the master handle, but will only use it to read.
LJ::get_cluster_description - Get descriptive text for a cluster id.
LJ::get_cluster_master - Returns a cluster master for a given user, used when the caller might use it to do a write (insert/delete/update/etc...)
LJ::get_cluster_reader - Returns a cluster slave for a user, or cluster master if no slaves exist.
LJ::get_community_row - Gets data relevant to a community such as their membership level and posting access.
LJ::get_dbh - Given one or more roles, returns a database handle.
LJ::get_dbirole_dbh - Internal function for get_dbh(). Uses the DBIRole to fetch a dbh, with hooks into db stats-generation if that's turned on.
LJ::get_friend_group - Returns friendgroup row(s) for a given user.
LJ::get_friend_items - Return friend items for a given user, filter, and period.
LJ::get_friendofs - Returns userids of friendofs for a given user.
LJ::get_friends - Returns friends rows for a given user.
LJ::get_keyword_id - Get the id for a keyword.
LJ::get_lastcomment - Looks up the last talkid and journal the remote user posted in
LJ::get_lock - get a mysql lock on a given key/dbrole combination
LJ::get_logtext2 - Efficiently retrieves a large number of journal entry text, trying first slave database servers for recent items, then the master in cases of old items the slaves have already disposed of. See also: LJ::get_talktext2.
LJ::get_logtext2multi - Gets log text from clusters.
LJ::get_mood_picture - Loads a mood icon hashref given a themeid and moodid.
LJ::get_newids - Lookup an old global ID and see what journal it belongs to and its new ID.
LJ::get_pending_invites - Gets a list of pending invitations for a user to join a community.
LJ::get_pending_members - Gets a list of userids for people that have requested to be added to a community
LJ::get_pic_from_keyword - Given a userid and keyword, returns the pic row hashref
LJ::get_posts_raw - Gets raw post data (text and props) efficiently from clusters.
LJ::get_prop - This is used to retrieve a hashref of a row from the given tablename's proplist table. One difference from getting it straight from the database is that the 'id' key is always present, as a copy of the real proplist unique id for that table.
LJ::get_recent_items - Returns journal entries for a given account.
LJ::get_reluser_id - for reluser2, numbers 1 - 31999 are reserved for livejournal stuff, whereas numbers 32000-65535 are used for local sites. if you wish to add your own hooks to this, you should define a hook "get_reluser_id" in ljlib-local.pl no reluser2 types can be a single character, those are reserved for the reluser table so we don't have namespace problems.
LJ::get_remote - authenticates the user at the remote end based on their cookies and returns a hashref representing them
LJ::get_remote_noauth - returns who the remote user says they are, but doesn't check their login token. disadvantage: insecure, only use when you're not doing anything critical. advantage: faster.
LJ::get_sent_invites - Get a list of sent invitations from the past 30 days.
LJ::get_shared_journals - Gets an array of shared journals a user has access to.
LJ::get_talktext2 - Retrieves comment text. Tries slave servers first, then master.
LJ::get_timeupdate_multi - Get the last time a list of users updated
LJ::get_timezone - Gets the timezone offset for the user.
LJ::get_urls - Returns a list of all referenced URLs from a string
LJ::get_userid - Returns a userid given a username.
LJ::get_username - Returns a username given a userid.
LJ::get_userpic_info - Given a user gets their user picture info
LJ::handle_caches - clears caches if the CLEAR_CACHES flag is set from an earlier HUP signal that called LJ::clear_caches, otherwise does nothing.
LJ::hash_password -
LJ::help_icon - Returns BML to show a help link/icon given a help topic, or nothing if the site hasn't defined a URL for that topic. Optional arguments include HTML/BML to place before and after the link/icon, should it be returned.
LJ::http_to_time - Converts HTTP date to Unix time.
LJ::img - Returns an HTML <img> or <input> tag to an named image code, which each site may define with a different image file with its own dimensions. This prevents hard-coding filenames & sizes into the source. The real image data is stored in LJ::Img, which has default values provided in cgi-bin/imageconf.pl but can be overridden in cgi-bin/ljconfig.pl.
LJ::infohistory_add - Add a line of text to the infohistory table for an account.
LJ::is_ascii - checks if text is pure ASCII
LJ::is_banned - Checks to see if a user is banned from a journal.
LJ::is_friend - Checks to see if a user is a friend of another user.
LJ::is_utf8 - check text for UTF-8 validity
LJ::is_valid_authaction - Validates a shared secret (authid/authcode pair)
LJ::item_link - Returns URL to view an individual journal item.
LJ::item_toutf8 - convert one item's subject, text and props to UTF8. item can be an entry or a comment (in which cases props can be left empty, since there are no 8bit talkprops).
LJ::join_community - Makes a user join a community. Takes care of all reluser and friend stuff.
LJ::journal_base - Returns URL of a user's journal.
LJ::leave_community - Makes a user leave a community. Takes care of all reluser and friend stuff.
LJ::ljuser - Make link to userinfo/journal of user.
LJ::load_codes - Populates hashrefs with lookup data from the database or from memory, if already loaded in the past. Examples of such lookup data include state codes, country codes, color name/value mappings, etc.
LJ::load_log_props2 -
LJ::load_log_props2multi -
LJ::load_mood_theme - Loads and caches a mood theme, or returns immediately if already loaded.
LJ::load_moods -
LJ::load_props - Loads and caches one or more of the various *proplist tables: logproplist, talkproplist, and userproplist, which describe the various meta-data that can be stored on log (journal) items, comments, and users, respectively.
LJ::load_rel_target - Load user relationship information. Loads all relationships of type 'type' in which user 'targetid' participates on the right side (is the target of the relationship).
LJ::load_rel_user - Load user relationship information. Loads all relationships of type 'type' in which user 'userid' participates on the left side (is the source of the relationship).
LJ::load_talk_props2 -
LJ::load_user - Loads a user record given a username.
LJ::load_user_privs -
LJ::load_user_props - Given a user hashref, loads the values of the given named properties into that user hashref.
LJ::load_userid - Loads a user record given a userid.
LJ::load_userids_multiple - Loads a number of users at once, efficiently.
LJ::load_userpics - Loads a bunch of userpic at once.
LJ::make_auth_code - Makes a random string of characters of a given length.
LJ::make_authas_select - Given a u object and some options, determines which users the given user can switch to. If the list exists, returns a select list and a submit button with labels. Otherwise returns a hidden element.
LJ::make_cookie - Prepares cookie header lines.
LJ::make_graphviz_dot_file -
LJ::make_journal -
LJ::make_link - Takes a group of key=value pairs to append to a url
LJ::make_qr_link - Creates the link to toggle the QR reply form or if
LJ::make_qr_target - Returns a div usable for Quick Reply boxes
LJ::make_remote - Returns a minimal user structure ($remote-like) from a username and userid.
LJ::make_user_active - Record user activity per cluster to make per-activity cluster stats easier.
LJ::mark_comment_as_spam - Copies a comment into the global spamreports table
LJ::mark_dirty - Marks a given user as being $what type of dirty
LJ::may_lock - see if we COULD get a mysql lock on a given key/dbrole combination, but don't actually get it.
LJ::memcache_kill - Kills a memcache entry, given a userid and type
LJ::modify_caps - Given a list of caps to add and caps to remove, updates a user's caps
LJ::mysql_time -
LJ::name_caps - Given a user's capability class bit mask, returns a site-specific string representing the capability class name.
LJ::name_caps_short - Given a user's capability class bit mask, returns a site-specific short string code.
LJ::new_account_cluster - Which cluster to put a new account on. $DEFAULT_CLUSTER if it's a scalar, random element from @$DEFAULT_CLUSTER if it's arrayref. also verifies that the database seems to be available.
LJ::parse_vars - Parses S1 style data into hashref.
LJ::prepare_currents - do all the current music/mood/weather/whatever stuff. only used by ljviews.pl.
LJ::procnotify_add - Sends a message to all other processes on all clusters.
LJ::procnotify_callback - Call back function process notifications.
LJ::record_anon_comment_ip - Records the IP address of an anonymous comment
LJ::record_meme - Records a URL reference from a journal entry to the meme table.
LJ::register_authaction - Registers a secret to have the user validate.
LJ::register_hook - Installs a site-specific hook.
LJ::register_setter - Installs code to run for the "set" command in the console.
LJ::reject_comm_invite - Rejects an invitation a user has received.
LJ::reject_pending_member - Rejects someone's request to join a community. Updates authactions and generates
LJ::release_lock - release a mysql lock on a given key/dbrole combination
LJ::remote_has_priv - Check to see if the given remote user has a certain priviledge
LJ::remove_friend -
LJ::robot_meta_tags - Returns meta tags to block a robot from indexing or following links
LJ::run_hook - Runs single site-specific hook of the given name.
LJ::run_hooks - Runs all the site-specific hooks of the given name.
LJ::send_comm_invite - Sends an invitation to a user to join a community with the passed abilities.
LJ::send_mail - Sends email. Character set will only be used if message is not ascii.
LJ::server_down_html - Returns an HTML server down message.
LJ::set_interests - Change a user's interests
LJ::set_lastcomment - Sets the lastcomm Memcache key for this user's last comment
LJ::set_rel - Sets relationship information for two users.
LJ::set_rel_multi - Sets relationship edges for lists of user tuples.
LJ::set_userprop - Sets/deletes a userprop by name for a user.
LJ::shared_member_request - Registers an authaction to add a user to a shared journal and sends an approval email
LJ::start_request - Before a new web request is obtained, this should be called to determine if process should die or keep working, clean caches, reload config files, etc.
LJ::statushistory_add - Adds a row to a user's statushistory
LJ::strip_bad_code - Removes malicious/annoying HTML.
LJ::sysban_block - Notes a sysban in statushistory and returns a fake http error message to the user
LJ::sysban_check - Given a 'what' and 'value', checks to see if a ban exists
LJ::sysban_note - Inserts a properly-formatted row into statushistory noting that a ban has been triggered
LJ::text_compress - Compresses a chunk of text, to gzip, if configured for site. Can compress a scalarref in place, or return a compressed copy. Won't compress if value is too small, already compressed, or size would grow by compressing.
LJ::text_convert - convert old entries/comments to UTF-8 using user's default encoding
LJ::text_in - do appropriate checks on input text. Should be called on all user-generated text.
LJ::text_length - returns both byte length and character length of a string. In a non-Unicode environment, this means byte length twice. In a Unicode environment, the function assumes that its argument is a valid UTF-8 string.
LJ::text_out - force outgoing text into valid UTF-8
LJ::text_trim - truncate string according to requirements on byte length, char length, or both. "char length" means number of UTF-8 characters if $LJ::UNICODE is set, or the same thing as byte length otherwise.
LJ::text_uncompress - Uncompresses a chunk of text, from gzip, if configured for site. Can uncompress a scalarref in place, or return a compressed copy. Won't uncompress unless it finds the gzip magic number at the beginning of the text.
LJ::time_to_cookie - Converts unix time to format expected in a Set-Cookie header
LJ::time_to_http - Converts a Unix time to an HTTP date.
LJ::trim - Removes whitespace from left and right side of a string.
LJ::u_equals - Compares two user objects to see if they're the same user.
LJ::use_diff_db -
LJ::want_user - Returns user object when passed either userid or the user hash. Useful to functions that want to accept either.
LJ::want_userid - Returns userid when passed either userid or the user hash. Useful to functions that want to accept either. Forces its return value to be a number (for safety).