Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kitelife committed Mar 18, 2015
1 parent d40d9e1 commit cb26990
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
29 changes: 29 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
server {
listen 80;
server_name localhost;

root /var/www/feed-world;

location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}

location ~ ^/(protected|vendor|logs|templates) {
deny all;
}

location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}

location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}
2 changes: 1 addition & 1 deletion protected/Handlers/UserHandlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected static function newUser($app, $userInfo) {
$insertNewUser = 'INSERT INTO user (`from_where`, `id_from`, `name_from`) VALUES (:from_where, :id_from, :name_from)';
$stmt = $app->db->prepare($insertNewUser);
$stmt->execute(array(
':from_wehre' => $userInfo['from_where'],
':from_where' => $userInfo['from_where'],
':id_from' => $userInfo['id_from'],
':name_from' => $userInfo['name_from']
));
Expand Down
13 changes: 9 additions & 4 deletions protected/Middlewares/UserSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ class UserSession extends \Slim\Middleware
public function call()
{
$app = $this->app;
$app->log->debug($app->request->getPath());
if (\FeedWorld\Helpers\CommonUtils::checkLogin($app) === false
&& strcmp($app->request->getPath(), '/user/login') !== 0
) {

$hasLogin = \FeedWorld\Helpers\CommonUtils::checkLogin($app);
$toLogin = strpos($app->request->getPathInfo(), '/user/login') !== 0 ? false : true;

if (!$hasLogin && !$toLogin) {
if ($app->request->isAjax()) {
\FeedWorld\Helpers\ResponseUtils::responseError(\FeedWorld\Helpers\CodeStatus::REQUIRE_LOGIN);
return false;
}
$this->app->response->redirect('/user/login', 302);
}

if ($hasLogin && $toLogin) {
$this->app->response->redirect('/', 302);
}
$this->next->call();
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion protected/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

return array(
'database' => array(
'name' => 'rss_world',
'name' => 'feed_world',
'host' => '127.0.0.1',
'port' => '3306',
'username' => 'root',
Expand Down

0 comments on commit cb26990

Please sign in to comment.