예제 #1
0
파일: admin.php 프로젝트: simonfork/phpmark
 public function before()
 {
     parent::before();
     if (!Auth::member(100) and Request::active()->action != 'login') {
         Response::redirect('admin/login');
     }
 }
예제 #2
0
 public function action_index()
 {
     //初期表示
     $view = View::forge('login/index');
     //既にログインしてたら、home画面へリダイレクト
     AUth::check() and Response::redirect('home');
     //エラー文のセット
     $error = null;
     //認証インスタンスの生成
     $auth = Auth::instance();
     //入力項目の取得
     if (Input::post()) {
         //DBとの比較
         if ($auth->login(Input::post('username'), Input::post('password'))) {
             //ログインするユーザのグループが1(学生)の場合
             if (Auth::member(1)) {
                 //学生用home画面にリダイレクト
                 Response::redirect('home');
             } else {
                 if (Auth::member(100)) {
                     //管理者用home画面にリダイレクト
                     Response::redirect('admin');
                 }
             }
         } else {
             $error = 'ユーザ名かパスワードに誤りがあります。';
             $view = View::forge('login/index');
             $view->set('error', $error);
         }
     }
     return $view;
 }
 public function before()
 {
     parent::before();
     // check for admin
     if (!Auth::member(5)) {
         \Response::redirect_back('home');
     }
 }
예제 #4
0
 public function before()
 {
     parent::before();
     // Check if the current user is an administrator
     if (!\Auth::member(6)) {
         \Messages::info(__('user.login.permission-denied'));
         \Response::redirect();
     }
 }
 public function action_remove($user_id)
 {
     // check for admin
     if (!Auth::member(5)) {
         \Response::redirect_back('home');
     }
     $user = Model_User::query()->where('id', $user_id)->get_one();
     $user->delete();
     Response::Redirect('users');
 }
예제 #6
0
파일: admin.php 프로젝트: wushian/MDD
 public function before()
 {
     parent::before();
     if (Auth::check()) {
         if (!Auth::member(100) and !in_array(Request::active()->action, array('login', 'logout'))) {
             Session::set_flash('error', e('You don\'t have access to the admin panel'));
             Response::redirect('/');
         }
     } else {
         Response::redirect('admin/login');
     }
 }
예제 #7
0
 public function before()
 {
     parent::before();
     // Check if the current user is an administrator
     if (!\Auth::member(6)) {
         \Messages::warnig(__('user.login.permission-denied'));
         \Response::redirect(\Router::get('backend'));
     }
     $this->template->title = "RN | ADMIN";
     // Set global
     $this->template->title = \Config::get('application.seo.backend.title');
 }
예제 #8
0
 public function before()
 {
     parent::before();
     //ログインしていなければ
     if (!Auth::check()) {
         //ログインページへ移動
         Response::redirect('user/login');
         //ログインしていてもAdminでなければ
     } elseif (!Auth::member(100)) {
         //user/indexページへ移動
         Response::redirect('user/index');
     }
 }
예제 #9
0
 public function before()
 {
     parent::before();
     if (Request::active()->controller !== 'Controller_Admin' or !in_array(Request::active()->action, array('login', 'logout'))) {
         if (Auth::check()) {
             $admin_group_id = Config::get('auth.driver', 'Simpleauth') == 'Ormauth' ? 6 : 100;
             if (!Auth::member($admin_group_id)) {
                 Session::set_flash('error', e('You don\'t have access to the Admin panel'));
                 Response::redirect('/');
             }
         } else {
             Response::redirect('admin/login');
         }
     }
 }
 public function after($response)
 {
     $response = parent::after($response);
     if (Uri::Current() != Uri::Create('login')) {
         if (Settings::get('maintenance_mode') === true) {
             if (!Auth::member(5)) {
                 $this->template->content = View::Forge('core/maintenance');
             } elseif (Uri::Current() != Uri::Create('admin/settings')) {
                 // YOUR GOOD
                 Response::Redirect(Uri::Create('admin/settings'));
             }
         }
     }
     return $response;
 }
예제 #11
0
파일: admin.php 프로젝트: vano00/jobs
 public function before()
 {
     parent::before();
     // Without this line, templating won't work!
     if (\Auth::check()) {
         // Check if the current user is an administrator
         if (!\Auth::member(100)) {
             \Session::set_flash('error', 'You don\'t have the required access');
             \Response::redirect('auth');
         }
         # Set user info
         $this->template->set_global('auth', ['user' => ['screen_name' => \Auth::get_screen_name(), 'group' => \Auth::group()->get_name()]], false);
     } else {
         \Response::redirect('auth');
     }
 }
예제 #12
0
 public function action_login()
 {
     // Already logged in
     Auth::member(100) and Response::redirect('admin');
     $val = Validation::forge();
     if (Input::method() == 'POST') {
         $val->add('email', 'Email or Username')->add_rule('required');
         $val->add('password', 'Password')->add_rule('required');
         if ($val->run()) {
             $auth = Auth::instance();
             // check the credentials. This assumes that you have the previous table created
             if (Auth::check() or $auth->login(Input::post('email'), Input::post('password'))) {
                 // credentials ok, go right in
                 $current_user = Model_User::find_by_username(Auth::get_screen_name());
                 Session::set_flash('success', e('Welcome, ' . $current_user->username));
                 Response::redirect('admin');
             } else {
                 $this->template->set_global('login_error', 'Fail');
             }
         }
     }
     $this->template->title = 'Login';
     $this->template->content = View::forge('admin/login', array('val' => $val), false);
 }
예제 #13
0
 public function action_delete($url_id)
 {
     $url = Model_Url::find($url_id);
     if ($url->user_id != static::$user_id && !Auth::member(5)) {
         Session::set('error', 'This isn\'t your URL!');
         Response::Redirect_Back('user/urls');
     } else {
         if ($url->delete()) {
             $url_stats = Model_Url_Stat::query()->where('url_id', $url_id)->rows_limit(1)->limit(1)->count();
             if (empty($url_stats) === false) {
                 $url_stats = DB::delete('url_stats')->where('url_id', $url_id)->execute();
             }
             Session::set('success', 'Url has been deleted!');
             Response::Redirect_Back('user/urls');
         } else {
             Session::set('error', 'Unknown Error!');
             Response::Redirect_Back('user/urls');
         }
     }
 }
 public function action_view($all = null)
 {
     $limit = 25;
     if (empty($all) === false) {
         // check for admin
         if (!Auth::member(5)) {
             Response::Redirect(Uri::Create('user'));
         }
     }
     // Total Urls
     $data['total_urls'] = Model_Url::query();
     if (empty($all) === true) {
         $data['total_urls']->where('user_id', static::$user_id);
     }
     $data['total_urls'] = $data['total_urls']->count();
     if (Uri::Current() == Uri::Create('admin')) {
         $keys = \Settings::Get('character_set');
         if (empty($keys) === true) {
             $keys = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
         }
         $random_length = \Settings::Get('random_url_length');
         if (empty($random_length) === true) {
             $random_length = 5;
         }
         $url_sample_space = DB::select(DB::expr('count(id) as count'))->from('urls')->where(DB::expr('char_length(short_url)'), $random_length)->limit(1)->execute()->as_array();
         $data['urls_left'] = Controller_Dashboard::mathFact(strlen($keys)) / (Controller_Dashboard::mathFact(strlen($keys) - $random_length) * Controller_Dashboard::mathFact($random_length)) - $url_sample_space[0]['count'];
     }
     // Total Hits
     $data['total_hits'] = DB::select(DB::Expr('SUM(hits) as hits'))->from('urls');
     if (empty($all) === true) {
         $data['total_hits']->where('user_id', static::$user_id);
     }
     $data['total_hits'] = $data['total_hits']->execute()->as_array();
     $data['total_hits'] = reset($data['total_hits']);
     $data['total_hits'] = $data['total_hits']['hits'];
     // No Clicks
     $data['no_clicks'] = Model_Url::query()->where('hits', 0);
     if (empty($all) === true) {
         $data['no_clicks']->where('user_id', static::$user_id);
     }
     $data['no_clicks'] = $data['no_clicks']->count();
     // Total Custom Urls
     $data['total_custom_urls'] = Model_Url::query()->where('custom', 1);
     if (empty($all) === true) {
         $data['total_custom_urls']->where('user_id', static::$user_id);
     }
     $data['total_custom_urls'] = $data['total_custom_urls']->count();
     // Created Today Urls
     $data['created_today'] = Model_Url::query()->where('created_at', '>=', strtotime('today 12:01 AM'));
     if (empty($all) === true) {
         $data['created_today']->where('user_id', static::$user_id);
     }
     $data['created_today'] = $data['created_today']->count();
     // Most visted Urls
     $data['most_visited'] = Model_Url::query();
     if (empty($all) === true) {
         $data['most_visited']->where('user_id', static::$user_id);
     }
     $data['most_visited']->order_by('hits', 'desc')->limit($limit);
     $data['most_visited'] = $data['most_visited']->get();
     // Created Today Urls
     $data['recently_created'] = Model_Url::query();
     if (empty($all) === true) {
         $data['recently_created']->where('user_id', static::$user_id);
     }
     $data['recently_created']->order_by('created_at', 'desc')->limit($limit);
     $data['recently_created'] = $data['recently_created']->get();
     if (empty($all) === true) {
         $data['recently_viewed'] = Model_Url::query()->order_by('updated_at', 'desc')->where('updated_at', '!=', 'created_at')->where('user_id', static::$user_id)->limit($limit)->get();
     } else {
         $data['recently_viewed'] = Model_Url::query()->order_by('updated_at', 'desc')->where('updated_at', '!=', null)->limit($limit)->get();
     }
     // Short URL Stats string for google graphs
     $m = date("m");
     $de = date("d");
     $y = date("Y");
     $new_results = '';
     if (empty($all) === true) {
         $date_vist_counts = DB::query('  
             SELECT
             COUNT(url_stats.id) as hits,
             DAY(FROM_UNIXTIME(url_stats.created_at)) as day,
             MONTH(FROM_UNIXTIME(url_stats.created_at)) as month,
             YEAR(FROM_UNIXTIME(url_stats.created_at)) as year
             FROM `url_stats`
             INNER JOIN `urls` ON urls.id = url_stats.url_id
             WHERE url_stats.created_at >= ' . strtotime('12:01 AM TODAY - 15 days') . '
             AND urls.user_id = ' . static::$user_id . '
             GROUP BY year,month,day')->execute()->as_array();
         $date_created_counts = DB::query('  
             SELECT
             COUNT(id) as created,
             DAY(FROM_UNIXTIME(created_at)) as day,
             MONTH(FROM_UNIXTIME(created_at)) as month,
             YEAR(FROM_UNIXTIME(created_at)) as year
             FROM `urls`
             WHERE created_at >= ' . strtotime('12:01 AM TODAY - 15 days') . '
             AND user_id = ' . static::$user_id . '
             GROUP BY year,month,day')->execute()->as_array();
     } else {
         $date_vist_counts = DB::query('  
             SELECT
             COUNT(id) as hits,
             DAY(FROM_UNIXTIME(created_at)) as day,
             MONTH(FROM_UNIXTIME(created_at)) as month,
             YEAR(FROM_UNIXTIME(created_at)) as year
             FROM `url_stats`
             WHERE created_at >= ' . strtotime('12:01 AM TODAY - 15 days') . '
             GROUP BY year,month,day')->execute()->as_array();
         $date_created_counts = DB::query('  
             SELECT
             COUNT(id) as created,
             DAY(FROM_UNIXTIME(created_at)) as day,
             MONTH(FROM_UNIXTIME(created_at)) as month,
             YEAR(FROM_UNIXTIME(created_at)) as year
             FROM `urls`
             WHERE created_at >= ' . strtotime('12:01 AM TODAY - 15 days') . '
             GROUP BY year,month,day')->execute()->as_array();
     }
     $created_counts_array = null;
     foreach ($date_created_counts as $created_counts) {
         $created_counts_array[$created_counts['year'] . '-' . $created_counts['month'] . '-' . $created_counts['day']] = $created_counts;
     }
     foreach ($date_vist_counts as $vists) {
         if (isset($created_counts_array[$vists['year'] . '-' . $vists['month'] . '-' . $vists['day']]) === true) {
             $created_count = $created_counts_array[$vists['year'] . '-' . $vists['month'] . '-' . $vists['day']]['created'];
         } else {
             $created_count = 0;
         }
         $date_timestamp = strtotime($vists['year'] . '-' . $vists['month'] . '-' . $vists['day']);
         $new_results .= "['" . date('l dS F Y', $date_timestamp) . "', " . $vists['hits'] . ", " . $created_count . "], ";
     }
     $data['short_url_stats'] = $new_results;
     $new_results = '';
     // Get countries Stats
     if (empty($all) === true) {
         $countries = DB::select('country', DB::expr('count(url_stats.id) as hits'))->from('url_stats')->join('urls', 'LEFT')->on('urls.id', '=', 'url_stats.url_id')->where('urls.user_id', static::$user_id)->group_by('country');
     } else {
         $countries = DB::select('country', DB::expr('count(id) as hits'))->from('url_stats')->group_by('country');
     }
     $countries = $countries->execute()->as_array();
     if (empty($countries) === false) {
         foreach ($countries as $country) {
             $new_results .= "['" . $country['country'] . "', " . $country['hits'] . "], ";
         }
     }
     $data['country_stats'] = $new_results;
     $data['short_urls'] = Model_Url::query();
     if (empty($all) === true) {
         $data['short_urls']->where('user_id', static::$user_id);
     }
     $data['short_urls']->rows_limit($limit);
     $data['short_urls'] = $data['short_urls']->get();
     $this->template->content = View::Forge('dashboard/index', $data);
 }
예제 #15
0
        } else {
            ?>
                                            <td>
                                                <a data-text="This URL will be removed!" class="confirm" href="<?php 
            echo Uri::Create('url/delete/' . $url->id);
            ?>
">
                                                    <i class="icon-remove"></i></a> <a target="_blank" id="url_<?php 
            echo $url->id;
            ?>
" href="<?php 
            echo $url->url;
            ?>
">
                                                    <?php 
            if (Auth::member(5) && Uri::Create('admin/urls') == Uri::Current()) {
                $url_parts = parse_url($url->url);
                $host = $url_parts['host'];
                ?>
                                                            <a class="confirm" data-text="All URLs LIKE <?php 
                echo $host;
                ?>
 will be blocked!" href="<?php 
                echo Uri::Create('admin/add_blocked/' . str_replace('.', '-', $host) . '');
                ?>
">
                                                                <i class="icon-ban-circle"></i>
                                                            </a>
                                                        <?php 
            }
            ?>
예제 #16
0
파일: list.php 프로젝트: uzura8/flockbird
        ?>
	<td class="small"><?php 
        echo $user->id;
        ?>
</td>
	<td><?php 
        echo $user->username;
        ?>
</td>
	<td><?php 
        echo \Admin\Site_AdminUser::get_gruop_name($user->group, true);
        ?>
</td>
	<td>
<?php 
        if (Auth::member(100)) {
            ?>
		<?php 
            echo $user->email;
        } else {
            ?>
		<?php 
            echo sprintf('<span class="text-muted">%s</span>', term('site.set_already'));
        }
        ?>
	</td>
	<td><?php 
        echo site_get_time($user->created_at, 'relative', 'Y/m/d H:i');
        ?>
</td>
</tr>
            <ul class="nav navbar-nav pull-right">
                <?php 
if (Uri::base(false) . Uri::string() != Uri::Base()) {
    ?>
                    <li><a href="<?php 
    echo Uri::Base();
    ?>
" title="Home">Home</a></li>
                <?php 
}
?>
                <?php 
if (Auth::check()) {
    ?>
                    <?php 
    if (Auth::member(5)) {
        ?>
                        <li><a href="<?php 
        echo Uri::Create('admin');
        ?>
" title="Admin Panel">Admin</a></li>
                    <?php 
    }
    ?>
                    
                    <li><a href="<?php 
    echo Uri::Create('user');
    ?>
" title="User Dashboard">Dashboard</a></li>
                    <li><a href="<?php 
    echo Uri::Create('user/settings');
예제 #18
0
<?php

Route::filter('auth.clientzone', function () {
    if (!Auth::member()->check()) {
        if (Request::ajax()) {
            return Response::make('Unauthorized', 401);
        } else {
            return Redirect::route('client.login');
        }
    } else {
        if (Auth::member()->get()->status == 3) {
            return Redirect::route('client.member.forced_profile');
        }
    }
});
# LOGIN PAGE
Route::match(['GET', 'POST'], 'login', ['as' => 'client.login', 'uses' => 'Auth\\AuthController@login']);
#REGISTRATION PAGE
Route::match(['GET', 'POST'], 'registration/{status?}', ['as' => 'client.registration', 'uses' => 'Auth\\AuthController@registration']);
#ACCOUNT ACTIVATION PAGE
Route::get('activate', ['as' => 'client.activate', 'uses' => 'Auth\\AuthController@activate']);
#REMINDER PAGE
Route::match(['GET', 'POST'], 'reminder', ['as' => 'client.reminder', 'uses' => 'Auth\\AuthController@reminder']);
#RESET PASSWORD PAGE
Route::match(['GET', 'POST'], 'reset/{token}', ['as' => 'client.reset', 'uses' => 'Auth\\AuthController@reset']);
#RESET PASSWORD PAGE
Route::match(['GET', 'POST'], 'user-profile', ['as' => 'client.member.forced_profile', 'uses' => 'Auth\\AuthController@profile']);
#RESET PASSWORD PAGE
Route::match(['GET', 'POST'], 'resend', ['as' => 'client.resend', 'uses' => 'Auth\\AuthController@resend']);
# CLIENTZONE AFTER LOGIN
Route::group(['before' => 'auth.clientzone'], function () {
예제 #19
0
</div>
		<div class="post-index"><?php 
        echo $item->post_index;
        ?>
</div>
		<div class="address"><?php 
        echo $item->address;
        ?>
</div>
		<div class="action">
			<i class="fa fa-comment<?php 
        echo $item->memo ? '' : ' hidden';
        ?>
" aria-hidden="true"></i>
			<?php 
        if (Auth::member(\Config::get('my.groups.superadmin'))) {
            ?>
			<i class="fa fa-pencil-square-o vendor-edit-button" aria-hidden="true"></i>
			<?php 
        }
        ?>
		</div>
	</div>
					
<?php 
    }
    ?>

</div>

<?php 
예제 #20
0
 public function action_approve($id = null)
 {
     if (Auth::member(6)) {
         $text = Model_Text::find($id);
         $text->approved = true;
         if ($text->save(false)) {
             $this->send_approved_email($text);
             Session::set_flash('success', e('Approved translation #' . $id));
         } else {
             Session::set_flash('error', e('Could not approve translation #' . $id));
         }
         \Fuel\Core\Response::redirect('admin/dashboard');
     } else {
         Response::redirect('admin/text');
     }
 }
예제 #21
0
 public function action_admincreate()
 {
     // Check if the current user is an administrator
     if (!\Auth::member(6)) {
         \Messages::info(__('user.login.not-logged'));
         \Response::redirect(\Router::get('login'));
     }
     if (Input::method() == 'POST') {
         try {
             /*
              * Unique serial based off timestamp and rand()
              *  for user saved in EAV table by FuelPHP
              */
             $user = \Auth::create_user(Input::post('email'), Input::post('email'), Input::post('email'), 1, array('author' => true, 'first_name' => Input::post('first_name'), 'last_name' => Input::post('last_name')));
             $email = Input::post('email');
             \Messages::success("Created author {$email}");
         } catch (Exception $e) {
             \Messages::error($error = $e->getMessage());
         }
         \Response::redirect_back();
     }
     return View::forge('user/admin/create');
 }
예제 #22
0
<script type="text/javascript">
$(document).ready(function() {
	$('#form_body').summernote({
<?php 
if (\Auth::member(50)) {
    ?>
		toolbar: [
			['font', ['bold', 'italic', 'underline', 'clear']],
			['insert', ['link', 'picture']],
			['view', ['fullscreen']]
		],
<?php 
}
?>
		keyMap: {
			pc: {'ENTER': ''},
			mac: {'ENTER': ''}
		},
		lang: 'ja-JP',
		height: 300,
		minHeight: 150
	});
});
</script>