Upload files to 'includes'

This commit is contained in:
2022-10-30 14:11:56 -07:00
parent 5e82f002b9
commit bd403ce047
19 changed files with 532 additions and 245 deletions

View File

@ -84,6 +84,7 @@ function yourls_add_new_link( $url, $keyword = '', $title = '' ) {
yourls_trim_long_string($url), preg_replace('!https?://!', '', yourls_get_yourls_site()) . '/'. $url_exists->keyword );
$return['title'] = $url_exists->title;
$return['shorturl'] = yourls_link($url_exists->keyword);
$return['errorCode'] = $return['statusCode'] = '400'; // 400 Bad Request
return yourls_apply_filter( 'add_new_link_already_stored_filter', $return, $url, $keyword, $title );
}
@ -168,11 +169,6 @@ function yourls_add_new_link( $url, $keyword = '', $title = '' ) {
* @return string Acceptable charset for short URLS keywords
*/
function yourls_get_shorturl_charset() {
static $charset = null;
if ( $charset !== null ) {
return $charset;
}
if ( defined( 'YOURLS_URL_CONVERT' ) && in_array( YOURLS_URL_CONVERT, [ 62, 64 ] ) ) {
$charset = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
}
@ -233,6 +229,8 @@ function yourls_keyword_is_reserved( $keyword ) {
/**
* Delete a link in the DB
*
* @param string $keyword Short URL keyword
* @return int Number of links deleted
*/
function yourls_delete_link_by_keyword( $keyword ) {
// Allow plugins to short-circuit the whole function
@ -251,8 +249,12 @@ function yourls_delete_link_by_keyword( $keyword ) {
/**
* SQL query to insert a new link in the DB. Returns boolean for success or failure of the inserting
*
* @param string $url
* @param string $keyword
* @param string $title
* @return bool true if insert succeeded, false if failed
*/
function yourls_insert_link_in_db( $url, $keyword, $title = '' ) {
function yourls_insert_link_in_db($url, $keyword, $title = '' ) {
$url = yourls_sanitize_url($url);
$keyword = yourls_sanitize_keyword($keyword);
$title = yourls_sanitize_title($title);
@ -304,8 +306,13 @@ function yourls_long_url_exists( $url ) {
/**
* Edit a link
*
* @param string $url
* @param string $keyword
* @param string $newkeyword
* @param string $title
* @return array Result of the edit and link information if successful
*/
function yourls_edit_link( $url, $keyword, $newkeyword='', $title='' ) {
function yourls_edit_link($url, $keyword, $newkeyword='', $title='' ) {
// Allow plugins to short-circuit the whole function
$pre = yourls_apply_filter( 'shunt_edit_link', null, $keyword, $url, $keyword, $newkeyword, $title );
if ( null !== $pre )
@ -375,6 +382,9 @@ function yourls_edit_link( $url, $keyword, $newkeyword='', $title='' ) {
/**
* Update a title link (no checks for duplicates etc..)
*
* @param string $keyword
* @param string $title
* @return int number of rows updated
*/
function yourls_edit_link_title( $keyword, $title ) {
// Allow plugins to short-circuit the whole function
@ -487,10 +497,14 @@ function yourls_get_keyword_infos( $keyword, $use_cache = true ) {
}
/**
* Return (string) selected information associated with a keyword. Optional $notfound = string default message if nothing found
* Return information associated with a keyword (eg clicks, URL, title...). Optional $notfound = string default message if nothing found
*
* @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
* @return mixed|string
*/
function yourls_get_keyword_info( $keyword, $field, $notfound = false ) {
function yourls_get_keyword_info($keyword, $field, $notfound = false ) {
// Allow plugins to short-circuit the whole function
$pre = yourls_apply_filter( 'shunt_get_keyword_info', false, $keyword, $field, $notfound );
@ -510,6 +524,9 @@ function yourls_get_keyword_info( $keyword, $field, $notfound = false ) {
/**
* Return title associated with keyword. Optional $notfound = string default message if nothing found
*
* @param string $keyword Short URL keyword
* @param false|string $notfound Optional string to return if keyword not found
* @return mixed|string
*/
function yourls_get_keyword_title( $keyword, $notfound = false ) {
return yourls_get_keyword_info( $keyword, 'title', $notfound );
@ -518,6 +535,9 @@ function yourls_get_keyword_title( $keyword, $notfound = false ) {
/**
* Return long URL associated with keyword. Optional $notfound = string default message if nothing found
*
* @param string $keyword Short URL keyword
* @param false|string $notfound Optional string to return if keyword not found
* @return mixed|string
*/
function yourls_get_keyword_longurl( $keyword, $notfound = false ) {
return yourls_get_keyword_info( $keyword, 'url', $notfound );
@ -526,6 +546,9 @@ function yourls_get_keyword_longurl( $keyword, $notfound = false ) {
/**
* Return number of clicks on a keyword. Optional $notfound = string default message if nothing found
*
* @param string $keyword Short URL keyword
* @param false|string $notfound Optional string to return if keyword not found
* @return mixed|string
*/
function yourls_get_keyword_clicks( $keyword, $notfound = false ) {
return yourls_get_keyword_info( $keyword, 'clicks', $notfound );
@ -534,6 +557,9 @@ function yourls_get_keyword_clicks( $keyword, $notfound = false ) {
/**
* Return IP that added a keyword. Optional $notfound = string default message if nothing found
*
* @param string $keyword Short URL keyword
* @param false|string $notfound Optional string to return if keyword not found
* @return mixed|string
*/
function yourls_get_keyword_IP( $keyword, $notfound = false ) {
return yourls_get_keyword_info( $keyword, 'ip', $notfound );
@ -542,6 +568,9 @@ function yourls_get_keyword_IP( $keyword, $notfound = false ) {
/**
* Return timestamp associated with a keyword. Optional $notfound = string default message if nothing found
*
* @param string $keyword Short URL keyword
* @param false|string $notfound Optional string to return if keyword not found
* @return mixed|string
*/
function yourls_get_keyword_timestamp( $keyword, $notfound = false ) {
return yourls_get_keyword_info( $keyword, 'timestamp', $notfound );