authorize.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Authorize Livecoding.tv accounts.
  4. *
  5. * @package LCTVBadges\Authorize
  6. * @since 0.0.3
  7. */
  8. /** Initialize. */
  9. require_once( 'lctv_badges_init.php' );
  10. /** Load the API with no user. */
  11. $lctv_api = new LCTVAPI( array(
  12. 'client_id' => LCTV_CLIENT_ID,
  13. 'client_secret' => LCTV_CLIENT_SECRET,
  14. 'redirect_url' => LCTV_REDIRECT_URL,
  15. 'user' => '',
  16. ) );
  17. /** Authorization html output. */
  18. ?>
  19. <!DOCTYPE html>
  20. <html lang="en-US">
  21. <head>
  22. <title>LCTV Badges Authorization</title>
  23. </head>
  24. <body style="font-family:Helvetica,Arial,sans-serif;font-size:15px;font-weight:400;color:#111;">
  25. <div style="padding:20px;width:600px;margin:0 auto;">
  26. <?php if ( ! $lctv_api->is_authorized() ) : ?>
  27. <h1 style="font-size:24px;font-weight:400;">Authorize</h1>
  28. <p>Some badges require access to your Livecoding.tv account information. Authorize account access with the link below.</p>
  29. <p><a href="<?php echo $lctv_api->get_authorization_url(); ?>">Connect your account</a></p>
  30. <br><br>
  31. <h1 style="font-size:24px;font-weight:400;">Remove Authorization</h1>
  32. <?php if ( isset( $_GET['user'] ) && isset( $_GET['delete'] ) ) : ?>
  33. <p>The account &ldquo;<?php echo htmlspecialchars( $_GET['user'] ); ?>&rdquo; has been disconnected.</p>
  34. <?php else : ?>
  35. <p>This site saves an authorization token to access your Livecoding.tv account. You may delete this token so as to stop this site from further accessing your account information.</p>
  36. <p>To disconnect your account, first connect your account with the link above, even if you have previously done so. After authorization a disconnect link will appear.</p>
  37. <?php endif; ?>
  38. <?php else : ?>
  39. <h1 style="font-size:24px;font-weight:400;">Authorize</h1>
  40. <p>The account &ldquo;<?php echo htmlspecialchars( $lctv_api->user ); ?>&rdquo; is now connected.</p>
  41. <br><br>
  42. <h1 style="font-size:24px;font-weight:400;">Remove Authorization</h1>
  43. <p>This site saves an authorization token to access your Livecoding.tv account. You may delete this token so as to stop this site from further accessing your account information with the link below.</p>
  44. <p><a href="https://themetuxedo-andtrev.c9.io/lctv-api/authorize.php?user=<?php echo urlencode( $lctv_api->user ); ?>&delete=<?php echo urlencode( $lctv_api->token->delete_id ); ?>">Disconnect your account</a></p>
  45. <?php endif; ?>
  46. <br><br>
  47. <p><a href="./">Return Home</a></p>
  48. </div>
  49. </body>
  50. </html>
  51. <?php