1 Star 0 Fork 0

Changkey/YOURLS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
yourls-go.php 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
LeoColomb 提交于 2013-04-07 12:52 . Fix end of line
<?php
define( 'YOURLS_GO', true );
require_once( dirname( __FILE__ ) . '/includes/load-yourls.php' );
// Variables should be defined in yourls-loader.php, if not try GET request (old behavior of yourls-go.php)
if( !isset( $keyword ) && isset( $_GET['id'] ) )
$keyword = $_GET['id'];
$keyword = yourls_sanitize_string( $keyword );
// First possible exit:
if ( !isset( $keyword ) ) {
yourls_do_action( 'redirect_no_keyword' );
yourls_redirect( YOURLS_SITE, 301 );
}
// Get URL From Database
$url = yourls_get_keyword_longurl( $keyword );
// URL found
if( !empty( $url ) ) {
yourls_do_action( 'redirect_shorturl', $url, $keyword );
// Update click count in main table
$update_clicks = yourls_update_clicks( $keyword );
// Update detailed log for stats
$log_redirect = yourls_log_redirect( $keyword );
yourls_redirect( $url, 301 );
// URL not found. Either reserved, or page, or doesn't exist
} else {
// Do we have a page?
if ( file_exists( YOURLS_PAGEDIR . "/$keyword.php" ) ) {
yourls_page( $keyword );
// Either reserved id, or no such id
} else {
yourls_do_action( 'redirect_keyword_not_found', $keyword );
yourls_redirect( YOURLS_SITE, 302 ); // no 404 to tell browser this might change, and also to not pollute logs
}
}
exit();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/changkey/YOURLS.git
[email protected]:changkey/YOURLS.git
changkey
YOURLS
YOURLS
master

搜索帮助