From 1ee65b690d3d33fcbbc128cab7f54df5f951c4ee Mon Sep 17 00:00:00 2001 From: Tom Slominski Date: Fri, 1 Nov 2013 18:15:39 +0000 Subject: [PATCH] Rudimentary basic two-file structure. This should make the code more readable and easier to edit, but we'll see how we go. It's called two file since only two files here are important. I've split the form and the results page together, and the header.php and footer.php are just additional files so we don't double the code. --- footer.php | 16 ++++ header.php | 167 ++++++++++++++++++++++++++++++++++ index.php | 259 ++--------------------------------------------------- result.php | 56 ++++++++++++ 4 files changed, 248 insertions(+), 250 deletions(-) create mode 100644 footer.php create mode 100644 header.php create mode 100644 result.php diff --git a/footer.php b/footer.php new file mode 100644 index 0000000..89af061 --- /dev/null +++ b/footer.php @@ -0,0 +1,16 @@ +
+

+

+ + + + + +
+ + + + + \ No newline at end of file diff --git a/header.php b/header.php new file mode 100644 index 0000000..4ec7ed5 --- /dev/null +++ b/header.php @@ -0,0 +1,167 @@ + +' . yourls__( 'An error has occured :(', 'isq_translation') . ''; + +if ( $message = $url. yourls__( 'added to database', 'isq_translation') ) { + $error = '

' . yourls__( 'URL shortened successfully', 'isq_translation') . '

' . yourls__( 'View the details of your short URL below.', 'isq_translation') . '

'; + } elseif ( $message = $url. yourls__( 'already exists in database', 'isq_translation') ) { + $error = $genericerror . '

' . yourls__( 'This URL already exists in this database. This website does not allow a single URL to have multiple short links.', 'isq_translation') . '

'; + } elseif ( $message = yourls__( 'Short URL', 'isq_translation') . $url . yourls__( 'already exists in database or is reserved', 'isq_translation') ) { + $error = $genericerror . '

' . yourls__( 'This short URL already exists in this database or is reserved. This website does not allow a single URL to have multiple short links. It could\'ve also been reserved by the admin.', 'isq_translation') . '

'; + } elseif ( $message = yourls__( 'Missing URL input', 'isq_translation') ) { + $error = $genericerror . '

' . yourls__( 'You did not enter the URL you want to shorten or the server lost it. Please try again.', 'isq_translation') . '

'; + } elseif ( $message = yourls__( 'This URL is a short URL', 'isq_translation') ) { + $error = $genericerror . '

' . yourls__( 'You cannot shorten a short URL!', 'isq_translation') . '

'; + } +?> + + + +<?php echo $ISQtitle; ?> + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

+ +
+
\ No newline at end of file diff --git a/index.php b/index.php index 6b22030..7d19f2a 100644 --- a/index.php +++ b/index.php @@ -1,227 +1,6 @@ - -' . yourls__( 'An error has occured :(', 'isq_translation') . ''; - -if ( $message = $url. yourls__( 'added to database', 'isq_translation') ) { - $error = '

' . yourls__( 'URL shortened successfully', 'isq_translation') . '

' . yourls__( 'View the details of your short URL below.', 'isq_translation') . '

'; - } elseif ( $message = $url. yourls__( 'already exists in database', 'isq_translation') ) { - $error = $genericerror . '

' . yourls__( 'This URL already exists in this database. This website does not allow a single URL to have multiple short links.', 'isq_translation') . '

'; - } elseif ( $message = yourls__( 'Short URL', 'isq_translation') . $url . yourls__( 'already exists in database or is reserved', 'isq_translation') ) { - $error = $genericerror . '

' . yourls__( 'This short URL already exists in this database or is reserved. This website does not allow a single URL to have multiple short links. It could\'ve also been reserved by the admin.', 'isq_translation') . '

'; - } elseif ( $message = yourls__( 'Missing URL input', 'isq_translation') ) { - $error = $genericerror . '

' . yourls__( 'You did not enter the URL you want to shorten or the server lost it. Please try again.', 'isq_translation') . '

'; - } elseif ( $message = yourls__( 'This URL is a short URL', 'isq_translation') ) { - $error = $genericerror . '

' . yourls__( 'You cannot shorten a short URL!', 'isq_translation') . '

'; - } -?> - - - -<?php echo $ISQtitle; ?> - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

- -
-
- ' . yourls__( 'Antispam check failed!', 'isq_translation') . '

'); - } - - $url = yourls_sanitize_url( $_REQUEST['url'] ); - $keyword = isset( $_REQUEST['keyword'] ) ? yourls_sanitize_keyword( $_REQUEST['keyword'] ): '' ; - $title = isset( $_REQUEST['title'] ) ? yourls_sanitize_title( $_REQUEST['title'] ) : '' ; - $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'] : ''; - - if (!empty(ISQ::$social['facebook'])) { $ISQfacebook = ''; } - if (!empty(ISQ::$social['twitter'])) { $ISQtwitter = ''; } - if (!empty(ISQ::$social['plus'])) { $ISQplus = '
'; } - if (!empty(ISQ::$social['linkedin'])) { $ISQlinkedin = ''; } - if (!empty(ISQ::$general['qr'])) { $ISQqr = '

' . yourls__( 'QR code', 'isq-translation' ) . '

' . yourls__( 'Share your link with external devices', 'isq-translation' ) . '

QR'; } - if (!empty(ISQ::$general['clipboard'])) { $ISQlongcopy = ''; } - if (!empty(ISQ::$general['clipboard'])) { $ISQshortcopy = ''; } - if (!empty(ISQ::$general['clipboard'])) { $ISQstatscopy = ''; } - - $output_original = yourls__( 'Original URL:', 'isq_translation'); - $output_short = yourls__( 'Short URL:', 'isq_translation'); - /* translators: This is short for statistics */ - $output_stats = yourls__( 'Stats:', 'isq_translation'); - $output_copy = yourls__( 'Click on a link and press Ctrl+C to quickly copy it.', 'isq_translation'); - $output_share_h2 = yourls__( 'Share', 'isq_translation'); - $output_share_p = yourls__( 'Share your short URL', 'isq_translation'); - - echo << -

$ISQlongcopy

-

$ISQshortcopy

-

$ISQstatscopy

-

$output_copy

-
- - $ISQqr - -

$output_share_h2

-

$output_share_p

- $ISQfacebook - $ISQtwitter - $ISQplus - $ISQlinkedin -RESULT; - - // Part to be executed when no form has been submitted - } else { - $site = YOURLS_SITE; $site_enter = yourls__( 'Enter a new URL to shorten', 'isq_translation'); @@ -233,40 +12,20 @@ RESULT; $site_title = yourls__( 'Optional title:', 'isq_translation'); $site_title_hover = yourls__( 'Optional title used when sharing a link from YOURLS', 'isq_translation'); $site_submit = yourls__( 'Shorten', 'isq_translation'); - $antispam_title = yourls__( 'Antispam check', 'isq_translation'); - $antispam_value = yourls__( 'Are you a bot or a human?', 'isq_translation'); + $antispam_title = yourls__( 'This is an antispam check. Sorry, we have to do this to prevent the database being overrun by bots!', 'isq_translation'); + $antispam_value = yourls__( 'reCAPTCHA', 'isq_translation'); $antispam_bot = yourls__( 'Bot', 'isq_translation'); $antispam_human = yourls__( 'Human', 'isq_translation'); +?> - echo <<$site_enter +

$site_hover

-
+

-

$antispam_bot $antispam_human

+

$captcha

-HTML; - } - ?> -
- -
-

-

- - - - - -
- - -
- - \ No newline at end of file + \ No newline at end of file diff --git a/result.php b/result.php new file mode 100644 index 0000000..5a75d9f --- /dev/null +++ b/result.php @@ -0,0 +1,56 @@ +' . yourls__( 'Antispam check failed!', 'isq_translation') . '

'); + // } + + $url = yourls_sanitize_url( $_REQUEST['url'] ); + $keyword = isset( $_REQUEST['keyword'] ) ? yourls_sanitize_keyword( $_REQUEST['keyword'] ): '' ; + $title = isset( $_REQUEST['title'] ) ? yourls_sanitize_title( $_REQUEST['title'] ) : '' ; + $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'] : ''; + + if (!empty(ISQ::$social['facebook'])) { $ISQfacebook = ''; } + if (!empty(ISQ::$social['twitter'])) { $ISQtwitter = ''; } + if (!empty(ISQ::$social['plus'])) { $ISQplus = '
'; } + if (!empty(ISQ::$social['linkedin'])) { $ISQlinkedin = ''; } + if (!empty(ISQ::$general['qr'])) { $ISQqr = '

' . yourls__( 'QR code', 'isq-translation' ) . '

' . yourls__( 'Share your link with external devices', 'isq-translation' ) . '

QR'; } + if (!empty(ISQ::$general['clipboard'])) { $ISQlongcopy = ''; } + if (!empty(ISQ::$general['clipboard'])) { $ISQshortcopy = ''; } + if (!empty(ISQ::$general['clipboard'])) { $ISQstatscopy = ''; } + + $output_original = yourls__( 'Original URL:', 'isq_translation'); + $output_short = yourls__( 'Short URL:', 'isq_translation'); + /* translators: This is short for statistics */ + $output_stats = yourls__( 'Stats:', 'isq_translation'); + $output_copy = yourls__( 'Click on a link and press Ctrl+C to quickly copy it.', 'isq_translation'); + $output_share_h2 = yourls__( 'Share', 'isq_translation'); + $output_share_p = yourls__( 'Share your short URL', 'isq_translation'); + +?> + $error +
+

$ISQlongcopy

+

$ISQshortcopy

+

$ISQstatscopy

+

$output_copy

+
+ + $ISQqr + +

$output_share_h2

+

$output_share_p

+ $ISQfacebook + $ISQtwitter + $ISQplus + $ISQlinkedin + + \ No newline at end of file