2013-11-01 18:15:39 +00:00
< ? php
2015-03-08 16:04:10 +00:00
$dependencies = array ();
2015-03-07 19:20:32 +00:00
2013-11-01 18:15:39 +00:00
include ( 'header.php' );
2015-03-08 16:04:10 +00:00
if ( ISQ :: $general [ 'clipboard' ] ) {
$dependencies [] = 'ZeroClipboard' ;
};
2015-07-09 00:13:35 +01:00
function display_error ( $message , $action ) {
echo '<div class="content error">' ;
echo '<p class="message">' . $message . '</p>' ;
if ( ! empty ( $action ) ) {
echo $action ;
} else {
echo '<p class="action"><a href="javascript:history.go(-1)" class="button">' . yourls__ ( '← Go back and try again' , 'isq_translation' ) . '</a></p>' ;
}
echo '</div>' ;
2015-03-02 22:51:20 +00:00
include ( 'footer.php' );
die ();
}
2015-03-08 18:02:41 +00:00
if ( empty ( $_REQUEST [ 'url' ] ) ) {
2015-07-09 00:13:35 +01:00
display_error ( yourls__ ( 'You haven\'t entered a URL to shorten.' , 'isq_translation' ) );
2015-03-08 18:02:41 +00:00
};
2015-07-09 00:13:35 +01:00
if ( ! yourls_keyword_is_reserved ( $_REQUEST [ 'keyword' ] ) ) {
display_error ( sprintf ( yourls__ ( 'The keyword %1$s is reserved.' ), '<span class="key">' . $_REQUEST [ 'keyword' ] . '</span>' ) );
}
if ( function_exists ( 'advanced_reserved_urls' ) ) {
if ( advanced_reserved_urls ( $_REQUEST [ 'keyword' ] ) ) {
display_error ( sprintf ( yourls__ ( 'The keyword %1$s is restricted.' ), '<span class="key">' . $_REQUEST [ 'keyword' ] . '</span>' ) );
}
}
2015-03-22 18:36:25 +00:00
// Check what CAPTCHA method was used
$antispam_method = $_REQUEST [ 'antispam_method' ];
if ( $antispam_method == 'user_login' ) {
// User is logged into YOURLS
} else if ( $antispam_method == 'recaptcha' ) {
// Google reCAPTCHA is enabled
2015-03-08 15:30:54 +00:00
$recaptcha_data = file_get_contents ( 'https://www.google.com/recaptcha/api/siteverify?secret=' . ISQ :: $recaptcha [ 'secret' ] . '&response=' . $_REQUEST [ 'g-recaptcha-response' ]);
$recaptcha_json = json_decode ( $recaptcha_data , TRUE );
2015-03-22 18:36:25 +00:00
// What happens when the reCAPTCHA was completed incorrectly
2015-03-08 15:30:54 +00:00
if ( $recaptcha_json [ 'success' ] != 'true' ) {
2015-07-09 00:13:35 +01:00
display_error ( yourls__ ( 'Are you a bot? Google certainly thinks you are.' , 'isq_translation' ) );
2015-03-08 15:30:54 +00:00
}
2015-03-22 18:36:25 +00:00
} else if ( $antispam_method == 'basic' ) {
// Basic antispam protection fallback
// What happens when it was not completed correctly
2015-03-08 15:30:54 +00:00
if ( $_REQUEST [ 'basic_antispam' ] != " " ) {
2015-07-09 00:13:35 +01:00
display_error ( yourls__ ( 'Are you a bot? The verification was not completed successfully.' , 'isq_translation' ) );
2015-03-08 15:30:54 +00:00
}
2015-03-22 18:36:25 +00:00
} else {
// No antispam protection was detected
2015-07-09 00:13:35 +01:00
display_error ( yourls__ ( 'Are you a bot? No antispam protection was completed successfully.' , 'isq_translation' ) );
2015-03-22 18:36:25 +00:00
}
2015-03-08 15:30:54 +00:00
2015-03-08 18:29:27 +00:00
// 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 );
2015-02-21 21:36:45 +03:00
2015-02-24 15:24:27 +00:00
$shorturl = isset ( $return [ 'shorturl' ] ) ? $return [ 'shorturl' ] : '' ;
$message = isset ( $return [ 'message' ] ) ? $return [ 'message' ] : '' ;
$title = isset ( $return [ 'title' ] ) ? $return [ 'title' ] : '' ;
2015-03-08 18:29:27 +00:00
$status = isset ( $return [ 'status' ] ) ? $return [ 'status' ] : '' ;
2015-02-24 16:01:40 +00:00
2015-03-08 18:29:27 +00:00
// URL encoded links used in the social sharing buttons
2015-03-08 00:48:16 +00:00
$encoded_shorturl = urlencode ( $shorturl );
$encoded_title = urlencode ( $title );
2015-02-24 22:41:58 +00:00
// QR code shenanigans
2015-03-01 21:41:26 +00:00
if ( ISQ :: $general [ 'qr' ] ) {
2015-02-24 22:41:58 +00:00
2015-03-22 18:54:19 +00:00
// PHP QR Code is LGPL licensed
2015-03-01 21:41:26 +00:00
include ( 'public/phpqrcode/qrlib.php' );
$qrContainerId = 'url-qr-code' ;
$saveToFile = false ;
$imageWidth = 600 ; // in pixels
$qrCode = QRcode :: svg ( $url , $qrContainerId , $saveToFile , QR_ECLEVEL_L , $imageWidth );
};
2015-02-24 22:41:58 +00:00
2013-11-01 18:15:39 +00:00
?>
2015-03-07 00:12:28 +00:00
< div class = " content " >
<!-- Error reporting -->
< ? php isset ( $error ) ? $error : '' ; ?>
<!-- Default output -->
< h2 >< ? php yourls_e ( 'Your short URL' , 'isq_translation' ); ?> </h2>
< div class = " output " >
< div class = " form-item full-width " >
2015-03-07 00:25:50 +00:00
< label for = " longurl " class = " primary " >< ? php yourls_e ( 'Original URL' , 'isq_translation' ); ?> </label>
2015-03-07 01:12:23 +00:00
< input type = " text " name = " longurl " id = " longurl " onclick = " this.select(); " onload = " this.select(); " value = " <?php echo $url ; ?> " >
2015-03-21 15:36:43 +03:00
< ? php if ( ISQ :: $general [ 'clipboard' ] ) { echo '<button data-clipboard-target="longurl" class="desktop-only copy-button button">' . yourls__ ( 'Copy to clipboard' , 'isq_translation' ) . '</button>' ; } ?>
2015-03-07 00:12:28 +00:00
</ div >
< div class = " halves " >
2013-11-01 19:19:35 +00:00
2015-03-07 00:12:28 +00:00
< div class = " form-item half-width left " >
2015-03-07 00:25:50 +00:00
< label for = " shorturl " class = " primary " >< ? php yourls_e ( 'Short URL' , 'isq_translation' ); ?> </label>
2015-03-07 01:12:23 +00:00
< input type = " text " name = " shorturl " id = " shorturl " onclick = " this.select(); " value = " <?php echo $shorturl ; ?> " >
2015-03-21 15:36:43 +03:00
< ? php if ( ISQ :: $general [ 'clipboard' ] ) { echo '<button data-clipboard-target="shorturl" class="desktop-only copy-button button">' . yourls__ ( 'Copy to clipboard' , 'isq_translation' ) . '</button>' ; } ?>
2015-03-07 00:12:28 +00:00
</ div >
< div class = " form-item half-width right " >
2015-03-07 00:25:50 +00:00
< label for = " stats " class = " primary " >< ? php /* translators: This is short for statistics */ yourls_e ( 'Stats' , 'isq_translation' ); ?> </label>
2015-03-07 01:12:23 +00:00
< input type = " text " name = " stats " id = " stats " onclick = " this.select(); " value = " <?php echo $shorturl . '+'; ?> " id = " stats-copy " >
2015-03-21 15:36:43 +03:00
< ? php if ( ISQ :: $general [ 'clipboard' ] ) { echo '<button data-clipboard-target="stats" class="desktop-only copy-button button">' . yourls__ ( 'Copy to clipboard' , 'isq_translation' ) . '</button>' ; } ?>
2015-03-07 00:12:28 +00:00
</ div >
</ div >
< p class = " desktop-only " >< ? php yourls_e ( 'Click on a link and press Ctrl+C to quickly copy it.' , 'isq_translation' ); ?> </p>
</ div >
<!-- Social sharers -->
< h2 >< ? php yourls_e ( 'Share' , 'isq_translation' ); ?> </h2>
< p >< ? php yourls_e ( 'Share your short URL' , 'isq_translation' ); ?> </p>
2015-03-08 00:48:16 +00:00
< div class = " social-sharing " >
< ? php
if ( ISQ :: $social [ 'twitter' ] ) { echo '<span onclick="window.open(\'https://twitter.com/intent/tweet?url=' . $encoded_shorturl . '&text=' . $encoded_title . '\',\'_blank\',\'width=550,height=380\')" class="button social-button twitter" title="Share on Twitter">' . file_get_contents ( 'public/images/twitter.svg' ) . '</span>' ; }
if ( ISQ :: $social [ 'appdotnet' ] ) { echo '<span onclick="window.open(\'https://account.app.net/intent/post/?text=' . $encoded_title . '&url=' . $encoded_shorturl . '\',\'_blank\',\'width=550,height=380\')" class="button social-button appdotnet" title="Share on App.net">' . file_get_contents ( 'public/images/appdotnet.svg' ) . '</span>' ; }
if ( ISQ :: $social [ 'facebook' ] ) { echo '<span onclick="window.open(\'https://www.facebook.com/sharer/sharer.php?u=' . $shorturl . '\',\'_blank\',\'width=550,height=380\')" class="button social-button facebook" title="Share on Facebook">' . file_get_contents ( 'public/images/facebook.svg' ) . '</span>' ; }
if ( ISQ :: $social [ 'tumblr' ] ) { echo '<span onclick="window.open(\'http://www.tumblr.com/share/link?url=' . $encoded_shorturl . '&name=' . $encoded_title . '\',\'_blank\',\'width=550,height=380\')" class="button social-button tumblr" title="Share on Tumblr">' . file_get_contents ( 'public/images/tumblr.svg' ) . '</span>' ; }
if ( ISQ :: $social [ 'linkedin' ] ) { echo '<span onclick="window.open(\'https://www.linkedin.com/shareArticle?mini=true&url=' . $encoded_shorturl . '&title=' . $encoded_title . '\',\'_blank\',\'width=550,height=380\')" class="button social-button linkedin" title="Share on LinkedIn">' . file_get_contents ( 'public/images/linkedin.svg' ) . '</span>' ; }
if ( ISQ :: $social [ 'googleplus' ] ) { echo '<span onclick="window.open(\'https://plus.google.com/share?url=' . $encoded_shorturl . '\',\'_blank\',\'width=550,height=380\')" class="button social-button googleplus" title="Share on LinkedIn">' . file_get_contents ( 'public/images/googleplus.svg' ) . '</span>' ; }
?>
</ div >
2015-03-07 00:12:28 +00:00
<!-- QR code -->
2015-03-21 15:36:43 +03:00
< ? php if ( ISQ :: $general [ 'qr' ] ) { echo '<h2>' . yourls__ ( 'QR code' , 'isq_translation' ) . '</h2><p>' . yourls__ ( 'Share your link with external devices' , 'isq_translation' ) . '</p>' . $qrCode ; } ?>
2015-03-07 00:12:28 +00:00
</ div >
2015-03-01 21:50:58 +00:00
2015-02-24 22:41:58 +00:00
< ? php include ( 'footer.php' ); ?>