[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/includes/ -> functions-shorturls.php (summary)

(no description)

File Size: 636 lines (25 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 21 functions

  yourls_add_new_link()
  yourls_get_shorturl_charset()
  yourls_is_shorturl()
  yourls_keyword_is_reserved()
  yourls_delete_link_by_keyword()
  yourls_insert_link_in_db()
  yourls_long_url_exists()
  yourls_edit_link()
  yourls_edit_link_title()
  yourls_keyword_is_free()
  yourls_is_page()
  yourls_keyword_is_taken()
  yourls_get_keyword_infos()
  yourls_get_keyword_info()
  yourls_get_keyword_title()
  yourls_get_keyword_longurl()
  yourls_get_keyword_clicks()
  yourls_get_keyword_IP()
  yourls_get_keyword_timestamp()
  yourls_get_keyword_stats()
  yourls_get_longurl_keywords()

Functions
Functions that are not part of a class:

yourls_add_new_link( $url, $keyword = '', $title = '' )   X-Ref
Add a new link in the DB, either with custom keyword, or find one

The return array will contain at least the following keys:
status: string, 'success' or 'fail'
message: string, a descriptive localized message of what happened in any case
code: string, a short descriptivish and untranslated message describing what happened
errorCode: string, a HTTP status code
statusCode: string, a HTTP status code
Depending on the operation, it will contain any of the following keys:
url: array, the short URL creation information, with keys: 'keyword', 'url', 'title', 'date', 'ip', 'clicks'
title: string, the URL title
shorturl: string, the proper short URL in full (eg 'http://sho.rt/abc')
html: string, the HTML part used by the ajax to update the page display if any

For compatibility with early consumers and third parties, when people asked for various data and data formats
before the internal API was really structured, the return array now collects several redundant information.

return: array            array with error/success state and short URL information
param: string $url      URL to shorten
param: string $keyword  optional "keyword"
param: string $title    option title

yourls_get_shorturl_charset()   X-Ref
Determine the allowed character set in short URLs

return: string    Acceptable charset for short URLS keywords

yourls_is_shorturl( $shorturl )   X-Ref
Is a URL a short URL? Accept either 'http://sho.rt/abc' or 'abc'

return: bool               true if registered short URL, false otherwise
param: string $shorturl   short URL

yourls_keyword_is_reserved( $keyword )   X-Ref
Check to see if a given keyword is reserved (ie reserved URL or an existing page). Returns bool

return: bool              True if keyword reserved, false if free to be used
param: string $keyword   Short URL keyword

yourls_delete_link_by_keyword( $keyword )   X-Ref
Delete a link in the DB

return: int               Number of links deleted
param: string $keyword   Short URL keyword

yourls_insert_link_in_db($url, $keyword, $title = '' )   X-Ref
SQL query to insert a new link in the DB. Returns boolean for success or failure of the inserting

return: bool true if insert succeeded, false if failed
param: string $url
param: string $keyword
param: string $title

yourls_long_url_exists( $url )   X-Ref
Check if a long URL already exists in the DB. Return NULL (doesn't exist) or an object with URL informations.

This function supersedes function yourls_url_exists(), deprecated in 1.7.10, with a better naming.

return: mixed        NULL if does not already exist in DB, or object with URL information as properties (eg keyword, url, title, ...)
since: 1.7.10
param: string $url  URL to check if already shortened

yourls_edit_link($url, $keyword, $newkeyword='', $title='' )   X-Ref
Edit a link

return: array Result of the edit and link information if successful
param: string $url
param: string $keyword
param: string $newkeyword
param: string $title

yourls_edit_link_title( $keyword, $title )   X-Ref
Update a title link (no checks for duplicates etc..)

return: int number of rows updated
param: string $keyword
param: string $title

yourls_keyword_is_free( $keyword )   X-Ref
Check if keyword id is free (ie not already taken, and not reserved). Return bool.

return: bool               true if keyword is taken (ie there is a short URL for it), false otherwise
param: string $keyword    short URL keyword

yourls_is_page($keyword)   X-Ref
Check if a keyword matches a "page"

return: bool             true if is page, false otherwise
since: 1.7.10
param: string $keyword  Short URL $keyword

yourls_keyword_is_taken( $keyword, $use_cache = true )   X-Ref
Check if a keyword is taken (ie there is already a short URL with this id). Return bool.

return: bool               true if keyword is taken (ie there is a short URL for it), false otherwise
param: string $keyword    short URL keyword
param: bool   $use_cache  optional, default true: do we want to use what is cached in memory, if any, or force a new SQL query

yourls_get_keyword_infos( $keyword, $use_cache = true )   X-Ref
Return array of all information associated with keyword. Returns false if keyword not found. Set optional $use_cache to false to force fetching from DB

Sincere apologies to native English speakers, we are aware that the plural of 'info' is actually 'info', not 'infos'.
This function yourls_get_keyword_infos() returns all information, while function yourls_get_keyword_info() (no 's') return only
one information. Blame YOURLS contributors whose mother tongue is not English :)

return: false|object       false if not found, object with URL properties if found
since: 1.4
param: string $keyword    Short URL keyword
param: bool   $use_cache  Default true, set to false to force fetching from DB

yourls_get_keyword_info($keyword, $field, $notfound = false )   X-Ref
Return information associated with a keyword (eg clicks, URL, title...). Optional $notfound = string default message if nothing found

return: mixed|string
param: string $keyword          Short URL keyword
param: string $field            Field to return (eg 'url', 'title', 'ip', 'clicks', 'timestamp', 'keyword')
param: false|string $notfound   Optional string to return if keyword not found

yourls_get_keyword_title( $keyword, $notfound = false )   X-Ref
Return title associated with keyword. Optional $notfound = string default message if nothing found

return: mixed|string
param: string $keyword          Short URL keyword
param: false|string $notfound   Optional string to return if keyword not found

yourls_get_keyword_longurl( $keyword, $notfound = false )   X-Ref
Return long URL associated with keyword. Optional $notfound = string default message if nothing found

return: mixed|string
param: string $keyword          Short URL keyword
param: false|string $notfound   Optional string to return if keyword not found

yourls_get_keyword_clicks( $keyword, $notfound = false )   X-Ref
Return number of clicks on a keyword. Optional $notfound = string default message if nothing found

return: mixed|string
param: string $keyword          Short URL keyword
param: false|string $notfound   Optional string to return if keyword not found

yourls_get_keyword_IP( $keyword, $notfound = false )   X-Ref
Return IP that added a keyword. Optional $notfound = string default message if nothing found

return: mixed|string
param: string $keyword          Short URL keyword
param: false|string $notfound   Optional string to return if keyword not found

yourls_get_keyword_timestamp( $keyword, $notfound = false )   X-Ref
Return timestamp associated with a keyword. Optional $notfound = string default message if nothing found

return: mixed|string
param: string $keyword          Short URL keyword
param: false|string $notfound   Optional string to return if keyword not found

yourls_get_keyword_stats( $shorturl )   X-Ref
Return array of stats for a given keyword

This function supersedes function yourls_get_link_stats(), deprecated in 1.7.10, with a better naming.

return: array            stats
since: 1.7.10
param: string $shorturl short URL keyword

yourls_get_longurl_keywords( $longurl, $order = 'ASC' )   X-Ref
Return array of keywords that redirect to the submitted long URL

return: array array of keywords
since: 1.7
param: string $longurl long url
param: string $order Optional SORT order (can be 'ASC' or 'DESC')



Generated: Tue Sep 27 05:10:01 2022 Cross-referenced by PHPXref 0.7.1