public function action_404() { // Lets see if theres a URL to redirect // $url = trim($_SERVER['REQUEST_URI'],'/'); $url = str_replace(Uri::Base(), '', Uri::Create($_SERVER['REQUEST_URI'])); $parts = preg_split('/\\//', $url); // var_dump($parts); if (count($parts) == 1) { $url = str_replace('%20', ' ', $url); static::$url_found = Model_Url::query()->where('short_url', $url)->get_one(); if (empty(static::$url_found) === false) { return Controller_Url::action_view(static::$url_found); } } else { if (count($parts) == 2) { // $url = str_replace('%20',' ',$url[1]); $url = explode('/', $url); $url = $url[1]; static::$url_found = Model_Url::query()->where('short_url', $url)->get_one(); if (empty(static::$url_found) === false) { return Controller_Url::action_view(static::$url_found); } } } $data = new stdClass(); $this->template->content = View::forge('core/404'); }
public function action_recover($hash = null) { if (Input::Method() === "POST") { if ($user = \Model\Auth_User::find_by_email(Input::POST('email'))) { // generate a recovery hash $hash = \Auth::instance()->hash_password(\Str::random()) . $user->id; // and store it in the user profile \Auth::update_user(array('lostpassword_hash' => $hash, 'lostpassword_created' => time()), $user->username); // send an email out with a reset link \Package::load('email'); $email = \Email::forge(); $html = 'Your password recovery link <a href="' . Uri::Create('login/recover/' . $hash) . '">Recover My Password!</a>'; // use a view file to generate the email message $email->html_body($html); // give it a subject $email->subject(\Settings::Get('site_name') . ' Password Recovery'); // GET ADMIN EMAIL FROM SETTINGS? $admin_email = Settings::get('admin_email'); if (empty($admin_email) === false) { $from = $admin_email; } else { $from = 'support@' . str_replace('http:', '', str_replace('/', '', Uri::Base(false))); } $email->from($from); $email->to($user->email, $user->fullname); // and off it goes (if all goes well)! try { // send the email $email->send(); Session::set('success', 'Email has been sent to ' . $user->email . '! Please check your spam folder!'); } catch (\Exception $e) { Session::Set('error', 'We failed to send the eamil , contact ' . $admin_email); \Response::redirect_back(); } } else { Session::Set('error', 'Sorry there is not a matching email!'); } } elseif (empty($hash) === false) { $hash = str_replace(Uri::Create('login/recover/'), '', Uri::current()); $user = substr($hash, 44); if ($user = \Model\Auth_User::find_by_id($user)) { // do we have this hash for this user, and hasn't it expired yet , must be within 24 hours if (isset($user->lostpassword_hash) and $user->lostpassword_hash == $hash and time() - $user->lostpassword_created < 86400) { // invalidate the hash \Auth::update_user(array('lostpassword_hash' => null, 'lostpassword_created' => null), $user->username); // log the user in and go to the profile to change the password if (\Auth::instance()->force_login($user->id)) { Session::Set('current_password', Auth::reset_password($user->username)); Response::Redirect(Uri::Create('user/settings')); } } } Session::Set('error', 'Invalid Hash!'); } $this->template->content = View::forge('login/recover'); }
public function action_create() { $url = Input::Get('url'); $custom = Input::Get('custom'); $api = Input::Get('api_key'); if (empty($api) === true) { $api = true; } if (empty($url) === false) { // Check to see if its a valid url if (filter_var($url, FILTER_VALIDATE_URL) === false) { echo 'You did not enter a valid url in, please try again'; die; } // Check black list! $blocked = Model_Blacklist::query()->get(); if (empty($blocked) === false) { foreach ($blocked as $block) { // Check aginst the blocked if (preg_match('/' . strtolower($block['blocked']) . '/', strtolower($url))) { echo 'URL Blacklisted'; die; } } } // Lets generate them a url $safe = \Settings::Get('google_safe_api_key'); // Is it safe? if (empty($safe) === false) { $m_url = 'https://sb-ssl.google.com/safebrowsing/api/lookup?client=api&apikey=' . $safe . '&appver=1.0&pver=3.0&url=' . $url; $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, $m_url); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); $buffer = curl_exec($curl_handle); curl_close($curl_handle); if (empty($buffer) === false) { echo 'This website has been blocked because of ' . $buffer; die; } } $length = strlen($url); $data['short_url_raw'] = Controller_Url::shortenit($url, $custom, $api); $data['url'] = $url; $data['short_url'] = $data['short_url_raw']['short_url']; echo \Uri::Create($data['short_url']); die; } else { echo 'Error'; die; } }
public function after_load(Model_Url $url) { if (Uri::Current() != Uri::Create('core/404')) { if (strpos($url->url, Uri::Create('assets/screenshots')) !== false) { if ($url->custom == false) { $url->custom = $url->url; $url->url = 'Image URL'; } else { $url->custom = $url->url; $url->url = 'Image : ' . $url->short_url; } } } }
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; }
public static function get_urls($all, $pagination = null, $images = false) { $term = Input::GET('search'); $results = Model_Url::query()->where('short_url', 'LIKE', '%' . $term . '%')->or_where('url', 'LIKE', '%' . $term . '%'); if ($all === false) { $results->where('user_id', static::$user_id); } if ($images == false || $images == "false") { $results->where('url', 'NOT LIKE', Uri::Create('assets/screenshots') . '%'); } else { $results->where('url', 'LIKE', Uri::Create('assets/screenshots') . '%'); } if (empty($pagination) === false) { $results = $results->rows_offset($pagination->offset)->rows_limit($pagination->per_page)->get(); } else { $results = $results->count(); } return $results; }
?> </div> <?php } if (empty($success) === false) { Session::delete('success'); ?> <div style="text-align: center;" class="alert alert-success"><?php echo $success; ?> </div> <?php } ?> <p> Your config could not be created, please copy and paste the following into file "<?php echo DOCROOT; ?> fuel/app/config/production/db.php" </p> <pre> <?php echo '<?php<br>' . $config; ?> </pre> <a href="<?php Uri::Create('install/force_login'); ?> ">Finish Installer</a>
<br><br> <?php if (\Settings::Get('qr_code') == 1 && \Settings::Get('social_media') == 1) { ?> <div class="meela-bg"> <div class="row"> <div class="col-lg-6 text-center"> <img src="https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=<?php echo $base_url . $short_url; ?> " /> </div> <div class="col-lg-6"> <a href="<?php echo Uri::Create('stats/' . $short_url); ?> " target="_blank" class="margin-top-27 btn btn-large btn-block btn-primary">URL Stats</a> <a href="http://www.facebook.com/sharer.php?u=<?php echo $base_url . $short_url; ?> " target="_blank" class="margin-top-10 btn btn-large btn-block btn-facebook"><i class="icon-facebook-sign"></i> Facebook</a> <a href="https://twitter.com/share?url=<?php echo $base_url . $short_url; ?> " target="_blank" class="margin-top-10 btn btn-large btn-block btn-twitter"><i class="icon-twitter"></i> Twitter</a> </div> </div> </div> <?php } elseif (\Settings::Get('qr_code') == 0 && \Settings::Get('social_media') == 1) {
</a></li> <li><a href="<?php echo Uri::Create('logout'); ?> " title="Logout"><i class="icon-off icon-white"></i></a></li> <?php } else { ?> <?php $admin_only = \Settings::Get('admin_only'); if (empty($admin_only) === true || $admin_only) { ?> <li><a href="<?php echo Uri::Create('login'); ?> " title="Login">Login</a></li> <li class="active"><a href="<?php echo Uri::Create('signup'); ?> " title="Signup">Sign Up</a></li> <?php } ?> <?php } ?> </ul> </div><!-- /.nav-collapse --> </div><!-- /.container --> </div><!-- /.navbar -->
} elseif (\Settings::Get('bookmarklet') === true) { ?> <a href="javascript:void(location.href='<?php echo Uri::Base(); ?> api/create?url='+encodeURIComponent(location.href))+'&api_key=<?php echo $api_key; ?> " title="<?php echo \Settings::Get('site_name'); ?> Bookmarklet">Bookmarklet</a> | <?php } } ?> <?php if (\Settings::Get('api') === true) { ?> <a href="<?php echo Uri::Create('api'); ?> " title="Developer API">Developer</a> | <?php } ?> Copyright © <?php echo date('Y'); ?> - <?php echo \Settings::Get('site_name');
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); }
echo Asset::css('bootstrap.css'); ?> <?php echo Asset::css('main.css'); ?> <?php echo Asset::css('jquery-ui.min.css'); ?> <?php //echo Asset::css('jquery-ui.theme.min.css'); ?> <?php echo Asset::css('tags/jquery.tag-editor.css'); ?> <link type="text/css" rel="stylesheet" href="<?php echo Uri::Create('assets/font-awesome/css/font-awesome.min.css'); ?> " /> <style> body { margin: 50px; } </style> <?php echo View::forge("js/variables"); echo Asset::js(array('jquery-1.11.1.min.js', 'bootstrap.min.js', 'jquery-ui.min.js', 'tags/jquery.caret.min.js', 'tags/jquery.tag-editor.min.js', 'script.js')); ?> <script> $(function () { $('.topbar').dropdown(); }); </script>
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); }
public function force_login() { if (DBUtil::table_exists('v2_urls')) { if (DB::count_records('urls') < DB::count_records('v2_urls')) { \Controller_Migrate::migrate(); } } if (Input::Method() === 'POST') { // call Auth to create this user $new_user = \Auth::create_user(Input::POST('username'), Input::POST('password'), Input::POST('email'), 5, array('fullname' => Input::POST('name'))); } else { // call Auth to create this user $new_user = \Auth::create_user('meela', 'password', '*****@*****.**', 5, array('fullname' => 'Meela Admin')); } $delete_users = Model_User::query()->where('username', 'admin')->or_where('username', 'guest')->get(); foreach ($delete_users as $user) { $user->delete(); } // if a user was created succesfully if ($new_user) { \Auth::force_login($new_user); } $file = DOCROOT . 'assets/url_stats_countries.csv'; // Insert data into temporary table from file $query = 'LOAD DATA LOCAL INFILE "' . $file . '" INTO TABLE url_stats_countries fields terminated by "," enclosed by \'"\' lines terminated by "\\n" (id,start_ip,end_ip,country,created_at,updated_at)'; \DB::query($query)->execute(); Response::Redirect(Uri::Create('admin/settings')); }
echo Casset::render_css(); ?> <!--[if IE 7]> <link href="<?php echo Uri::Create('assets/css/font-awesome-ie7.min.css'); ?> " rel="stylesheet"> <![endif]--> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- fav icon --> <link rel="shortcut icon" href="<?php echo Uri::Create('assets/img/favicon.ico'); ?> "> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> </head> <body> <div id="wrap"> <div class="external-drop top"></div> <div class="external-drop right"></div> <div class="external-drop bottom"></div> <div class="external-drop left"></div> <?php echo $header; ?>
public function action_index() { \Controller_Migrate::migrate(); Response::Redirect(Uri::Create('/')); }
<th>Full Name</th> <th>Email</th> <th>User Level</th> <th>API Key</th> </thead> <tbody> <?php $options = array('Admin' => '5', 'Member' => '4', 'User' => '3', 'Banned' => '1'); foreach ($users as $user) { ?> <tr> <td><a data-text="<?php echo $user->email; ?> will be removed!" class="confirm" href="<?php echo Uri::Create('users/remove/' . $user->id); ?> "><i style="cursor: pointer;" class='icon-remove'></i></a> <?php echo $user['user_fname']; ?> </td> <td><?php echo $user->email; ?> </td> <td> <select name="user_role_<?php echo $user->id; ?> "> <?php
" class="margin-top-10 pull-left btn btn-large btn-block btn-primary btn-embossed"><i class="icon-google-sign"></i> Connect Google Login</a> <?php } else { ?> <a target="_blank" href="https://accounts.google.com/b/0/IssuedAuthSubTokens?hl=en" class="margin-top-10 pull-left btn btn-large btn-block btn-primary btn-embossed"><i class="icon-google-sign"></i> Disconnect Google Login</a> <?php } } ?> <?php if (empty($twitter_api) === false) { if (empty($provider_array) === true || in_array('Twitter', $provider_array) === false) { ?> <a href="<?php echo Uri::Create('auth/login/twitter'); ?> " class="margin-top-10 pull-left btn btn-large btn-block btn-twitter btn-embossed"><i class="icon-twitter-sign"></i> Connect Twitter Login</a> <?php } else { ?> <a target="_blank" href="https://twitter.com/settings/applications" class="margin-top-10 pull-left btn btn-large btn-block btn-twitter btn-embossed"><i class="icon-twitter-sign"></i> Disconnect Twitter Login</a> <?php } } ?> <?php if (!empty($facebook_api) || !empty($google_api) || !empty($twitter_api)) {
</thead> <tbody> <?php if (empty($most_visited) === false) { foreach ($most_visited as $url) { ?> <tr> <td><a target="_blank" href="<?php echo isset($base_url) === true ? $base_url . '/' . $url->short_url : Uri::Create($url->short_url); ?> "><?php echo $cut_url; ?> </a></td> <td><a target="_blank" href="<?php echo isset($base_url) === true ? $base_url . '/' . $url->short_url : Uri::Create($url->short_url); ?> "><?php echo $url->short_url; ?> </a></td> <td><?php echo number_format($url->hits); ?> </td> <td><?php echo Settings::time_ago($url->updated_at); ?> </td> <td><a href="<?php echo \Uri::Base() . 'stats/' . $url->short_url;
</li> <?php } ?> <?php if (Auth::member(5)) { ?> <li> <?php if (!Session::get('profiler')) { ?> <a href="<?php echo Uri::Create('admin/profiler'); ?> ">Enable Profiler</a> <?php } else { ?> <a href="<?php echo Uri::Create('admin/profiler'); ?> ">Disable Profiler</a> <?php } ?> </li> <?php } ?> </ul>