コード例 #1
0
 public function action_profile()
 {
     $data = null;
     $data['user'] = Model_User::query()->related('user_providers')->where('id', static::$user_id)->get_one();
     $data['api_key'] = Auth::get('api_key');
     if (Input::Method() == 'POST') {
         $new_password = Input::Post('new_password');
         $current_password = Input::Post('current_password');
         if (empty($new_password) === false) {
             if (empty($current_password) === true) {
                 Session::set('error', 'You must enter your old password in first!');
                 $this->template->content = View::Forge('settings/profile', $data);
                 return;
             } else {
                 if (Auth::change_password($current_password, $new_password) === false) {
                     Session::set('error', 'Wrong Password');
                     $this->template->content = View::Forge('settings/profile', $data);
                     return;
                 } else {
                     Session::delete('current_password');
                 }
             }
         }
         // update the data for the current user
         try {
             Auth::update_user(array('email' => Input::Post('email'), 'fullname' => Input::Post('full_name')));
         } catch (Exception $e) {
             Session::set('error', $e->getMessage());
             $this->template->content = View::Forge('settings/profile', $data);
             return;
         }
         Session::set('success', 'Your profile has been updated');
     }
     $this->template->content = View::Forge('settings/profile', $data);
 }
コード例 #2
0
ファイル: dashboard.php プロジェクト: brano97/site-monitoring
 public function Action_Index()
 {
     if (!Auth::check()) {
         return Response::redirect('auth/login?url=' . Input::uri());
     }
     $data["auth_username"] = Auth::get('username', 'Unnamed');
     $this->template->title = "F**k you!";
     $this->template->auth_username = $data["auth_username"];
     $this->template->content = View::Forge('dashboard/index', $data);
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 public function action_index()
 {
     $data['settings'] = Settings::get_all();
     if (\Input::method() == 'POST') {
         Controller_Settings::update(Input::Post());
         $data['settings'] = Settings::get_all(true);
     }
     $data['blocked'] = $blacklist_item = Model_Blacklist::query()->get();
     $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_Admin::mathFact(strlen($keys)) / (Controller_Admin::mathFact(strlen($keys) - $random_length) * Controller_Admin::mathFact($random_length)) - $url_sample_space[0]['count'];
     $this->template->content = View::Forge('admin/index', $data);
 }
コード例 #5
0
<?php

echo View::Forge('core/menu');
?>
<style>
	.meelab{
		margin-bottom: 20px;
	}
</style>
<div class="container">
    <?php 
if (Uri::Current() === Uri::Create('admin')) {
    ?>
      <div class="row meela-pods">
            <div class="col-lg-12" style="font-size: 40px;width: 100%;display: block;text-align: center;padding-left: 0px ;padding-right: 0px;">
                <?php 
    if (empty($style) === false) {
        ?>
                        <div style="font-size:15px;" class="alert alert-danger">Please change the random length for your URLs!</div>
                    <?php 
    }
    ?>
                <div class="pod-3 meela-bg">
                    
                    <span class="title">Unique URLs Left</span>
                    <?php 
    $threshold = Settings::get('url_limit_threshold');
    if (empty($threshold) === true) {
        $threshold = 1000;
    }
    if ($urls_left < $threshold) {
コード例 #6
0
 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);
 }
コード例 #7
0
 public function action_list($all = false, $images = false, $screenshots = false)
 {
     if (Auth::check() === false) {
         Response::Redirect(Uri::Create('login'));
     }
     if ($all == 'false' || $all === false) {
         $all = false;
     } else {
         $all = true;
     }
     if ($screenshots == "true") {
         $image = false;
         $data['screenshots'] = true;
     }
     if ($images == "true") {
         $data['images'] = true;
         $per_page = Settings::get('images_per_page');
         if (empty($per_page) === true) {
             $per_page = 5;
         }
     } else {
         $per_page = Settings::get('data_per_page');
         if (empty($per_page) === true) {
             $per_page = 25;
         }
     }
     if ($all === false) {
         // check for admin
         if (!Auth::member(5)) {
             Response::Redirect(Uri::Create('user/urls'));
         }
     }
     if (Input::Method() === 'GET' && Input::Get('search')) {
         $data['total_count'] = Controller_Search::get_urls($all, null, $images);
         $pagination = Settings::pagination($data['total_count'], $per_page);
         $data['search'] = Input::GET('search');
         $data['my_urls'] = Controller_Search::get_urls($all, $pagination, $images);
     } else {
         if ($all === true) {
             $data['total_count'] = Model_Url::query();
             if ($images == "true") {
                 $data['total_count']->where('url', 'LIKE', Uri::Create('assets/screenshots') . '%');
             } else {
                 $data['total_count']->where('url', 'NOT LIKE', Uri::Create('assets/screenshots') . '%');
             }
             $data['total_count'] = $data['total_count']->count();
         } else {
             $data['total_count'] = Model_Url::query()->where('user_id', static::$user_id);
             if ($images == "true") {
                 $data['total_count']->where('url', 'LIKE', Uri::Create('assets/screenshots') . '%');
             } else {
                 $data['total_count']->where('url', 'NOT LIKE', Uri::Create('assets/screenshots') . '%');
             }
             $data['total_count'] = $data['total_count']->count();
         }
         $pagination = Settings::pagination($data['total_count'], $per_page);
         $data['my_urls'] = Model_Url::query();
         if ($all === false) {
             $data['my_urls']->where('user_id', static::$user_id);
         }
         if ($images == "true") {
             $data['my_urls']->where('url', 'LIKE', Uri::Create('assets/screenshots') . '%');
         } else {
             $data['my_urls']->where('url', 'NOT LIKE', Uri::Create('assets/screenshots') . '%');
         }
         $data['my_urls'] = $data['my_urls']->order_by('created_at', 'DESC')->rows_offset($pagination->offset)->rows_limit($per_page)->get();
     }
     $data['pagination'] = $pagination->render();
     $this->template->content = View::Forge('url/list', $data);
 }