From 87fda224620190910840e12ecf1543fa2debde42 Mon Sep 17 00:00:00 2001 From: Tom Slominski Date: Sun, 24 Jul 2016 13:08:48 +0100 Subject: [PATCH] More error checking when shortening URLs. Fixes #23. --- result.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/result.php b/result.php index addaaf8..9ac2ac6 100644 --- a/result.php +++ b/result.php @@ -27,6 +27,11 @@ if ( !empty( $_REQUEST['keyword'] ) && yourls_keyword_is_reserved( $_REQUEST['ke display_error( sprintf( yourls__( 'The keyword %1$s is reserved.'), '' . $_REQUEST['keyword'] . '' ) ); } +// Check if the keyword is taken +if ( !empty( $_REQUEST['keyword'] ) && yourls_keyword_is_taken( $_REQUEST['keyword'] ) ) { + display_error( sprintf( yourls__( 'The keyword %1$s is taken.'), '' . $_REQUEST['keyword'] . '' ) ); +} + // Check what CAPTCHA method was used $antispam_method = $_REQUEST['antispam_method']; @@ -74,6 +79,11 @@ $message = isset( $return['message'] ) ? $return['message'] : ''; $title = isset( $return['title'] ) ? $return['title'] : ''; $status = isset( $return['status'] ) ? $return['status'] : ''; +// Check for all other errors +if( empty( $shorturl ) ) { + display_error( yourls__( 'The URL could not be shortened.', 'isq_translation' ) ); +} + // URL encoded links used in the social sharing buttons $encoded_shorturl = urlencode($shorturl); $encoded_title = urlencode($title);