Skip to content

Commit

Permalink
Improve: show http code on error page
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroProfundis committed Jan 17, 2014
1 parent d707c2c commit acddd33
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 18 deletions.
6 changes: 3 additions & 3 deletions all.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<?php
$statuses = $t->homeTimeline();
if ($statuses === false) {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}
$empty = count($statuses) == 0? true: false;
if ($empty) {
Expand All @@ -43,7 +43,7 @@

$statuses = $t->replies();
if ($statuses === false) {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}
$empty = count($statuses) == 0? true: false;
if ($empty) {
Expand All @@ -65,7 +65,7 @@

$messages = $t->directMessages();
if ($messages === false) {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}
$empty = count($messages) == 0? true: false;
if ($empty) {
Expand Down
8 changes: 5 additions & 3 deletions error.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
<div id="login_area">
<div id="error">
<?php
if ( isset($_GET['t'])){
switch($_GET['t']){
if (isset($_GET['t'])) {
switch($_GET['t']) {
case 1:
echo '<p>Fail to connect Twitter right now. Please <a href="index.php">go back</a> or <a href="logout.php">sign in</a> minutes later.</p>';
break;
default:
echo '<p>Ooops, an unknown error occured. Please <a href="index.php">go back</a> or <a href="logout.php">sign in</a> again.</p>';
}
} else{
} else if (isset($_GET['code'])) {
echo '<p>Ooops, an error <a href="https://dev.twitter.com/docs/error-codes-responses">'.$code.'</a> occured. Please <a href="index.php">go back</a> or <a href="logout.php">sign in</a> again.</p>';
} else {
echo '<p>Ooops, an unknown error occured. Please <a href="index.php">go back</a> or <a href="logout.php">sign in</a> again.</p>';
}
?>
Expand Down
2 changes: 1 addition & 1 deletion favor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

$statuses = $t->getFavorites($user_id, $since_id, $max_id);
if ($statuses === false) {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}
$empty = count($statuses) == 0 ? true : false;
if ($empty) {
Expand Down
2 changes: 1 addition & 1 deletion inc/sentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
$t = getTwitter();
$user = $t->veverify();
if ($user === false) {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}
$empty = count($user) == 0 || !isset($user->status) || $user->status->text == '';
if ($empty) {
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
$statuses = $t->homeTimeline($since_id, $max_id);
if ($statuses == false)
{
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}
$count = count($statuses);
$empty = $count == 0 ? true : false;
Expand Down
2 changes: 1 addition & 1 deletion list.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
$statuses = $t->listStatus($id, $since_id, $max_id);
$listInfo = $t->listInfo($id);
if ($statuses === false) {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}

$isFollower = $t->isFollowedList($id);
Expand Down
2 changes: 1 addition & 1 deletion lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
$prelist = $lists->previous_cursor;
$lists = $lists->lists;
if ($lists === false) {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}


Expand Down
2 changes: 1 addition & 1 deletion message.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
$messages = $t->directMessages($since_id, $max_id);
}
if ($messages === false) {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}

$count_t = count($messages);
Expand Down
2 changes: 1 addition & 1 deletion profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

$statuses = $t->userTimeline(false, $since_id, $max_id);
if ($statuses === false) {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}
$empty = count($statuses) == 0? true: false;
if ($empty) {
Expand Down
2 changes: 1 addition & 1 deletion replies.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

$statuses = $t->replies($since_id, $max_id);
if ($statuses === false) {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}

$count_t = count($statuses);
Expand Down
4 changes: 2 additions & 2 deletions status.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
$statusid = $_GET['id'];
$status = $t->showStatus($statusid);
if (!$status) {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}
$user = $status->user;
$date = format_time($status->created_at);
$text = formatEntities($status->entities,$status->text);
} else {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}
?>

Expand Down
4 changes: 2 additions & 2 deletions user.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div id="statuses" class="column round-left">
<?php
if (!loginStatus() || !isset($_GET['id'])) {
header('location: error.php');exit();
header('location: error.php?code='.$t->http_code);exit();
}

$t = getTwitter();
Expand All @@ -25,7 +25,7 @@
}

if ($statuses === false) {
header('location: error.php');exit;
header('location: error.php?code='.$t->http_code);exit;
}
if ($t->http_code == 429) {
$apiout = true;
Expand Down

0 comments on commit acddd33

Please sign in to comment.