Vodlix Function Reference Guide
This document provides a reference for the key and utility functions used within Vodlix, covering user-related, configuration, database handling, and debugging functions.
1. User-Related Functions
userid()
- Description: Retrieves the ID of the currently logged-in user.
- Usage: Returns the user ID as an integer.
- Example:
$current_user_id = userid();
get_user($uid)
- Description: Fetches the user object for a specific user by ID.
- Parameters:
- $uid (int): The ID of the user to retrieve.
- Example:
$user = get_user(123);
2. Debugging Functions
pre()
- Description: Outputs data for debugging purposes in a human-readable format.
- Usage: Wrap data in pre() for clean and formatted output.
- Example:
pre($array_data);
ppre()
- Description: Similar to pre() but immediately exits the script after output, useful for debugging specific blocks of code.
- Usage: Outputs and halts execution.
- Example:
ppre($variable);
3. Configuration Functions
config($key, $default = null)
- Description: Retrieves a configuration value.
- Parameters:
- $key (string): The configuration key to retrieve.
- $default (mixed, optional): Default value if the key is not found.
- Example:
$site_name = config('site_name', 'Vodlix Default');
get_config($key, $default = null)
- Description: Retrieves a configuration value.
- Parameters:
- $key (string): The configuration key to retrieve.
- $default (mixed, optional): Default value if the key is not found.
- $default (mixed, optional): Default value if the key is not found.
- Example:
$site_name = get_config('site_name', 'Vodlix Default');
set_config($field, $value)
- Description: Sets a configuration value.
- Parameters:
- $field (string): The configuration field name.
- $value (mixed): The value to set.
- Example:
set_config('site_name', 'Vodlix');
get_configs()
- Description: Retrieves website configuration details using the global $myquery object.
- Usage: Primarily used to get configurations.
- Example:
$configurations = get_configs();
4. Database-Related Functions
db_select()
- Description: Executes a SELECT query on the database and returns the result.
- Parameters:
- $query (string): SQL query to execute.
- Usage: Retrieves data from a specific table or with specific conditions.
- Example:
$result = db_select("SELECT * FROM users WHERE user_id = 1");
db_update()
- Description: Updates records in a database table.
- Parameters:
- $table (string): Table to update.
- $fields (array): Key-value pairs of fields to update.
- $conditions (array): Conditions to apply for the update.
- Usage:
db_update('users', ['name' => 'John Doe'], ['user_id' => 1]);
db_insert()
- Description: Inserts a new record into a database table.
- Parameters:
- $table (string): Table name.
- $fields (array): Data to insert as key-value pairs.
- Usage:
db_insert('users', ['name' => 'John Doe', 'email' => '[email protected]']);
db_delete($tbl, $where)
- Description: Deletes records from a database table based on conditions.
- Parameters:
- $tbl (string): Table name.
- $where (array): Conditions for deletion.
- Example:
db_delete(tbl("user"), ['user_id' => 1]);
db_query($query)
- Description: Executes a raw SQL query on the database.
- Parameters:
- $query (string): The SQL query to execute.
- Example:
db_query("DELETE FROM " . tbl("user") . " WHERE user_id = 1");
mysql_clean()
- Description: Sanitizes input to prevent SQL injection attacks.
- Parameters:
- $data (mixed): The data to be sanitized.
- Usage: Useful for cleaning inputs before database interactions.
- Example:
$safe_data = mysql_clean($user_input);
5. Video Management Functions
get_video($vid)
- Description: Retrieves video details for a specific video ID.
- Parameters:
- $vid (int): The ID of the video to retrieve.
- Example:
$video = get_video(123);
get_videos($filters)
- Description: Retrieves a list of videos based on the provided filters.
- Parameters:
- $filters (array): Associative array of filter conditions.
- Example:
$videos = get_videos(['videoid' => '123', 'active' => 'yes']);
update_video($array)
- Description: Updates video details in the database.
- Parameters:
- $array (array): Associative array containing video details to update.
- Example:
update_video(['videoid' => 123, 'title' => 'Updated Title']);
insert_video($details)
- Description: Insert a new video record into the database.
- Parameters:
- $details (array): Associative array of video details to insert.
- Example:
insert_video([
"title" => lang("Unknown title"),
"description" => lang("Unknown description"),
"tags" => "unknown",
"category" => [$cbvid->get_default_cid()],
"file_name" => Utils::filename(),
"file_directory" => Utils::file_directory(),
"userid" => userid(),
"thumbs_version" => THUMBS_VERSION,
"active" => "no",
"force_active_no" => true,
"status" => "Draft",
"process_status" => 0,
"file_type" => 2,
"content_type" => 1
]);
6. Series Management Functions
getSeries($params = [])
- Description: Retrieves a list of series based on provided parameters.
- Parameters:
- $params (array): Optional array of filter parameters.
- Example:
$series_list = getSeries(['active' => 'yes']);
getSeriesByID($series_id)
- Description: Retrieves details for a specific series by ID.
- Parameters:
- $series_id (int): The ID of the series to retrieve.
- Example:
$series = getSeriesByID(45);
7. URL and Link Generation Functions
These functions generate URLs for various content types and pages. They ensure consistency and handle SEO-friendly URL generation when configured.
watch_video_link($video)
- Description: Generates the URL for watching a video based on its ID.
- Parameters:
- $video (array): Video data array containing videoid and optional title.
- Example:
$watch_link = watch_video_link(['videoid' => 123, 'title' => 'Sample Video']);
episode_link_v2($video)
- Description: Creates a URL for an episode, supporting episodes treated as individual entities.
- Parameters:
- $video (array): Episode data containing series_id, videoid, and optional title.
- Example:
$episode_link = episode_link_v2(['series_id' => 10, 'videoid' => 123, 'title' => 'Episode 1']);
video_link_v2($video)
- Description: Generates a link to a video based on its content type.
- Parameters:
- $video (array): Video data including videoid, title, and content_type.
- Example:
$video_link = video_link_v2(['videoid' => 123, 'title' => 'Live Event', 'content_type' => '4']);
series_link($series)
- Description: Creates a URL for a TV series, based on the series ID.
- Parameters:
- $series (array): Series data with series_id and optional series_name.
- Example:
$series_link = series_link(['series_id' => 45, 'series_name' => 'Sample Series']);
tvshow_home_link()
- Description: Generates the URL for the TV shows home page.
- Example:
$tv_home = tvshow_home_link();
movies_home_link()
- Description: Generates the URL for the movies home page.
- Example:
$movies_home = movies_home_link();
content_list_link($content_list)
- Description: Creates a URL for a specific content list.
- Parameters:
- $content_list (array): Content list data including content_list_id and content_list_name.
- Example:
$content_list_link = content_list_link(['content_list_id' => 8, 'content_list_name' => 'Top 10']);
content_list_group_link($content_list_group)
- Description: Creates a URL for a content list group.
- Parameters:
- $content_list_group (array): Group data including content_list_group_id and content_list_group_name.
- Example:
$group_link = content_list_group_link(['content_list_group_id' => 5, 'content_list_group_name' => 'Top Shows']);
page_link($page)
- Description: Generates a URL for a given page.
- Parameters:
- $page (array): Page data with page_id and page_title.
- Example:
$page_link = page_link(['page_id' => 3, 'page_title' => 'About Us']);
page_link_v2($page)
- Description: Generates a URL for a page, taking into account if the page is part of a menu.
- Parameters:
- $page (array): Page data with page_id and page_title.
- Example:
$page_v2_link = page_link_v2(['page_id' => 3, 'page_title' => 'About Us']);
category_link_v2($category, $type = 'movies')
- Description: Generates a URL for a category within a specific content type.
- Parameters:
- $category (array): Category data including category_id and category_name.
- $type (string): Content type, default is 'movies'.
- Example:
$category_link = category_link_v2(['category_id' => 10, 'category_name' => 'Drama'], 'series');
category_api_link($category, $type = 'movies')
- Description: Generates an API URL for a category based on its content type.
- Parameters:
- $category (array): Category data with category_id.
- $type (string): Content type, such as 'movies' or 'live'.
- Example:
$api_link = category_api_link(['category_id' => 15], 'movies');
artist_link($artist)
- Description: Generates a URL for an artist profile.
- Parameters:
- $artist (array): Artist data including artist_id and name details.
- Example:
$artist_link = artist_link(['artist_id' => 12, 'first_name' => 'John', 'last_name' => 'Doe']);
search_link($query, $type = 'all')
- Description: Generates a search URL with a query.
- Parameters:
- $query (string): Search term.
- $type (string): Search type (e.g., 'movies', 'series'), default is 'all'.
- Example:
$search_url = search_link('action', 'movies');
tags_link($tags, $content_type, $sep = ', ', $class = "")
- Description: Generates HTML links for tags associated with a content type.
- Parameters:
- $tags (string): Comma-separated tags.
- $content_type (int): 2 for series, otherwise defaults to 'movies'.
- $sep (string): Separator for tags, default is ', '.
- $class (string): CSS class for each tag link.
- Example:
echo tags_link('action, drama, thriller', 1);
slug_name($phrase = '')
- Description: Converts a phrase into a URL-friendly slug.
- Parameters:
- $phrase (string): The phrase to slugify.
- Example:
$slug = slug_name('My New Show');
make_slug_url($url, $phrase = '')
- Description: Appends a slug to a URL, based on SEO configuration.
- Parameters:
- $url (string): Base URL.
- $phrase (string, optional): Phrase to convert to slug and append.
- Example:
$full_url = make_slug_url('/movies', 'My New Show');