Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update url-shortner.php
Who write this Code? No Exception Handling, no validation.
Don't use short opener for examples. php.ini is not unique configured!
Add simple HTML-Required-Attr.
  • Loading branch information
Assimilationstheorie authored Jun 9, 2018
commit 51067fc8facb320a5edf8961618e93e8d912db6e
13 changes: 6 additions & 7 deletions examples/url-shortener.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,33 +112,32 @@
$short = $service->url->insert($url);
$_SESSION['access_token'] = $client->getAccessToken();
}

?>

<div class="box">
<?php if (isset($authUrl)): ?>
<div class="request">
<a class='login' href='<?= $authUrl ?>'>Connect Me!</a>
<a class='login' href='<?php echo $authUrl; ?>'>Connect Me!</a>
</div>
<?php elseif (empty($short)): ?>
<form id="url" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']); ?>">

This comment was marked as spam.

<input name="url" class="url" type="text">
<input name="url" class="url" type="text" placeholder="URL" required>
<input type="hidden" name="csrf_token" value="<?php echo getCsrfToken() ?>" />
<input type="submit" value="Shorten">
</form>
<form id="logout" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']); ?>">

This comment was marked as spam.

<input type="hidden" name="logout" value="" />
<input type="hidden" name="logout" />
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token']; ?>" />
<input type="submit" value="Logout">
</form>
<?php else: ?>
You created a short link! <br />
<a href="<?= $short['id'] ?>"><?= $short['id'] ?></a>
<a href="<?php echo $short['id']; ?>"><?php echo $short['id']; ?></a>
<div class="shortened">
<pre><?php var_export($short) ?></pre>
</div>
<a href="<?= htmlspecialchars($_SERVER['PHP_SELF']); ?>">Create another</a>
<a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">Create another</a>
<?php endif ?>
</div>

<?= pageFooter(__FILE__);
<?php echo pageFooter(__FILE__);