' . $_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']; switch( is_get_antispam_method() ) { case 'login': if( !yourls_is_valid_user() ) { display_error( yourls__( 'You are not logged in - please go back and try again.', 'isq_translation' ) ); } break; case 'recaptcha_v3': $recaptcha_data = get_remote_file( 'https://www.google.com/recaptcha/api/siteverify?secret=' . ISQ::$recaptcha_v3['secret'] . '&response=' . $_POST['recaptcha_token'] ); $recaptcha = json_decode( $recaptcha_data ); if( $recaptcha->success != true || $recaptcha->action != 'homepage' || $recaptcha->score < ISQ::$recaptcha_v3['threshold'] ) { display_error( yourls__( 'Are you a bot? Google certainly thinks you are.', 'isq_translation' ) ); } break; case 'recaptcha': // Google reCAPTCHA is enabled $recaptcha_data = get_remote_file( 'https://www.google.com/recaptcha/api/siteverify?secret=' . ISQ::$recaptcha['secret'] . '&response=' . $_POST['g-recaptcha-response'] ); $recaptcha_json = json_decode( $recaptcha_data, true ); // What happens when the reCAPTCHA was completed incorrectly if ( $recaptcha_json['success'] != 'true' ) { display_error( yourls__( 'Are you a bot? Google certainly thinks you are.', 'isq_translation' ) ); } break; case 'basic': // Basic antispam protection fallback // What happens when it was not completed correctly if( !empty( $_POST['basic_antispam'] ) ) { display_error( yourls__( 'Are you a bot? The anti-spam check was not completed successfully.', 'isq_translation' ) ); } break; default: // No anti-spam check was completed at all display_error( yourls__( 'Are you a bot? No anti-spam check was completed successfully.', 'isq_translation' ) ); break; } // Get parameters -- they will all be sanitized in yourls_add_new_link() $url = $_REQUEST['url']; $keyword = isset( $_REQUEST['keyword'] ) ? $_REQUEST['keyword'] : '' ; $title = isset( $_REQUEST['title'] ) ? $_REQUEST['title'] : '' ; $text = isset( $_REQUEST['text'] ) ? $_REQUEST['text'] : '' ; // Create short URL, receive array $return with various information $return = yourls_add_new_link( $url, $keyword, $title ); $shorturl = isset( $return['shorturl'] ) ? $return['shorturl'] : ''; $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); // Add dependencies $dependencies[] = 'clipboard.js'; ?>