本文整理汇总了PHP中Uri::Create方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::Create方法的具体用法?PHP Uri::Create怎么用?PHP Uri::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Uri
的用法示例。
在下文中一共展示了Uri::Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_404
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');
}
示例2: action_recover
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');
}
示例3: action_create
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;
}
}
示例4: after_load
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;
}
}
}
}
示例5: after
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;
}
示例6: get_urls
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;
}
示例7:
?>
</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>
示例8: elseif
<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) {
示例9:
</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 -->
示例10: elseif
} 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');
示例11: action_list
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);
}
示例12:
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>
示例13: action_view
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 {
//.........这里部分代码省略.........
示例14: force_login
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', 'meela@mee.la', 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'));
}
示例15:
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;
?>