コード例 #1
0
function ltc_fuzzy_suggest($ltc_request)
{
    if ($_SERVER['REQUEST_URI'] == '/') {
        # homepage redirect
        $keyword_supplied = FALSE;
    } else {
        $keyword_supplied = TRUE;
        header('X-PHP-Response-Code: 404', true, 404);
        global $ydb;
        $table_url = YOURLS_DB_TABLE_URL;
        $ltc_keyword = yourls_sanitize_keyword($ltc_request[0]);
        $query = $ydb->get_results("SELECT keyword, url, title, LEVENSHTEIN('{$ltc_keyword}', keyword) AS `lev_dist` FROM `{$table_url}` HAVING `lev_dist` < 3 ORDER BY `lev_dist` DESC");
        if ($query) {
            $suggested_results = TRUE;
        } else {
            $suggested_results = FALSE;
        }
    }
    $default_template_file = dirname(__FILE__) . '/template-default.php';
    $custom_template_file = dirname(__FILE__) . '/template.php';
    if (file_exists($custom_template_file)) {
        require $custom_template_file;
    } else {
        require $default_template_file;
    }
    die;
}
コード例 #2
0
ファイル: plugin.php プロジェクト: Efreak/YOURLS
function ozh_preview_loader_failed($args)
{
    $request = $args[0];
    $pattern = yourls_make_regexp_pattern(yourls_get_shorturl_charset());
    if (preg_match("@^([{$pattern}]+)" . OZH_PREVIEW_CHAR . "\$@", $request, $matches)) {
        $keyword = isset($matches[1]) ? $matches[1] : '';
        $keyword = yourls_sanitize_keyword($keyword);
        ozh_preview_show($keyword);
        die;
    }
}
コード例 #3
0
function insensitive_keyword_is_taken($return, $keyword)
{
    global $ydb;
    $keyword = yourls_sanitize_keyword($keyword);
    $taken = false;
    $table = YOURLS_DB_TABLE_URL;
    $already_exists = $ydb->get_var("SELECT COUNT(`keyword`) FROM `{$table}` WHERE LOWER(`keyword`) = LOWER('{$keyword}');");
    if ($already_exists) {
        $taken = true;
    }
    return yourls_apply_filter('keyword_is_taken', $taken, $keyword);
}
コード例 #4
0
$pattern = yourls_make_regexp_pattern(yourls_get_shorturl_charset());
// Now load required template and exit
yourls_do_action('pre_load_template', $request);
// At this point, $request is not sanitized. Sanitize in loaded template.
// Redirection:
if (preg_match("@^([{$pattern}]+)/?\$@", $request, $matches)) {
    $keyword = isset($matches[1]) ? $matches[1] : '';
    $keyword = yourls_sanitize_keyword($keyword);
    yourls_do_action('load_template_go', $keyword);
    require_once YOURLS_ABSPATH . '/yourls-go.php';
    exit;
}
// Stats:
if (preg_match("@^([{$pattern}]+)\\+(all)?/?\$@", $request, $matches)) {
    $keyword = isset($matches[1]) ? $matches[1] : '';
    $keyword = yourls_sanitize_keyword($keyword);
    $aggregate = isset($matches[2]) ? (bool) $matches[2] && yourls_allow_duplicate_longurls() : false;
    yourls_do_action('load_template_infos', $keyword);
    require_once YOURLS_ABSPATH . '/yourls-infos.php';
    exit;
}
// Prefix-n-Shorten sends to bookmarklet (doesn't work on Windows)
if (preg_match("@^[a-zA-Z]+://.+@", $request, $matches)) {
    $url = yourls_sanitize_url($matches[0]);
    if ($parse = yourls_get_protocol_slashes_and_rest($url, array('up', 'us', 'ur'))) {
        yourls_do_action('load_template_redirect_admin', $url);
        $parse = array_map('rawurlencode', $parse);
        // Redirect to /admin/index.php?up=<url protocol>&us=<url slashes>&ur=<url rest>
        yourls_redirect(yourls_add_query_arg($parse, yourls_admin_url('index.php')), 302);
        exit;
    }
コード例 #5
0
<?php

include 'header.php';
$url = isset($_REQUEST['url']) ? yourls_sanitize_url($_REQUEST['url']) : '';
$keyword = isset($_REQUEST['keyword']) ? yourls_sanitize_keyword($_REQUEST['keyword']) : '';
$title = isset($_REQUEST['title']) ? yourls_sanitize_title($_REQUEST['title']) : '';
?>

<div class="content">
	<h2><?php 
yourls_e('Enter a new URL to shorten', 'isq_translation');
?>
</h2>
	<form method="post" action="result.php" class="newurl">
		<div class="form-item full-width">
			<p><label for="url" class="primary"><?php 
yourls_e('Long URL', 'isq_translation');
?>
</label></p>
			<p><label for="url" class="secondary"><?php 
yourls_e('Paste the long URL here. This is required.', 'isq_translation');
?>
</label></p>
			<input type="url" id="url" name="url" value="<?php 
echo $url;
?>
" autofocus>
		</div>

		<div class="halves">
コード例 #6
0
ファイル: admin-ajax.php プロジェクト: Efreak/YOURLS
    case 'edit_save':
        yourls_verify_nonce('edit-save_' . $_REQUEST['id'], $_REQUEST['nonce'], false, 'omg error');
        $user = $_SESSION["user"];
        if (verifyUrlOwner(yourls_sanitize_keyword($_REQUEST['keyword']), $user["id"])) {
            $return = yourls_edit_link($_REQUEST['url'], $_REQUEST['keyword'], $_REQUEST['newkeyword'], $_REQUEST['title']);
            echo json_encode($return);
        } else {
            // TODO: SHOW ERROR!
            $keyword = $_REQUEST['keyword'];
            die("THE {$keyword} url does not seems to be from " . $user["id"]);
        }
        break;
    case 'delete':
        yourls_verify_nonce('delete-link_' . $_REQUEST['id'], $_REQUEST['nonce'], false, 'omg error');
        $user = $_SESSION["user"];
        if (verifyUrlOwner(yourls_sanitize_keyword($_REQUEST['keyword']), $user["id"])) {
            $query = yourls_delete_link_by_keyword($_REQUEST['keyword']);
            echo json_encode(array('success' => $query));
        } else {
            // TODO: SHOW ERROR!
            die;
        }
        break;
    case 'logout':
        // unused for the moment
        yourls_logout();
        break;
    default:
        yourls_do_action('yourls_ajax_' . $action);
}
die;
コード例 #7
0
ファイル: functions.php プロジェクト: steenhulthin/hult.in
/**
 * Converts keyword into stat link (prepend with YOURLS base URL, append +)
 *
 */
function yourls_statlink($keyword = '')
{
    $link = YOURLS_SITE . '/' . yourls_sanitize_keyword($keyword) . '+';
    if (yourls_is_ssl()) {
        $link = yourls_set_url_scheme($link, 'https');
    }
    return yourls_apply_filter('yourls_statlink', $link, $keyword);
}
コード例 #8
0
ファイル: index.php プロジェクト: 469306621/Languages
            break;
    }
}
// Get URLs Count for current filter, total links in DB & total clicks
list($total_urls, $total_clicks) = array_values(yourls_get_db_stats());
if ($where) {
    list($total_items, $total_items_clicks) = array_values(yourls_get_db_stats($where));
} else {
    $total_items = $total_urls;
    $total_items_clicks = false;
}
// This is a bookmarklet
if (isset($_GET['u'])) {
    $is_bookmark = true;
    $url = yourls_sanitize_url($_GET['u']);
    $keyword = isset($_GET['k']) ? yourls_sanitize_keyword($_GET['k']) : '';
    $title = isset($_GET['t']) ? yourls_sanitize_title($_GET['t']) : '';
    $return = yourls_add_new_link($url, $keyword, $title);
    // If fails because keyword already exist, retry with no keyword
    if (isset($return['status']) && $return['status'] == 'fail' && isset($return['code']) && $return['code'] == 'error:keyword') {
        $msg = $return['message'];
        $return = yourls_add_new_link($url, '', $ydb);
        $return['message'] .= ' (' . $msg . ')';
    }
    // Stop here if bookmarklet with a JSON callback function
    if (isset($_GET['jsonp']) && $_GET['jsonp'] == 'yourls') {
        $short = $return['shorturl'] ? $return['shorturl'] : '';
        $message = $return['message'];
        header('Content-type: application/json');
        echo "yourls_callback({'short_url':'{$short}','message':'{$message}'});";
        die;
コード例 #9
0
ファイル: functions.php プロジェクト: mimischi/gu-urlshorter
/**
 * Converts keyword into stat link (prepend with YOURLS base URL, append +)
 *
 */
function yourls_statlink($keyword = '')
{
    $link = YOURLS_SITE . '/' . yourls_sanitize_keyword($keyword) . '+';
    if (yourls_is_ssl()) {
        $link = str_replace('http://', 'https://', $link);
    }
    return yourls_apply_filter('yourls_statlink', $link, $keyword);
}
コード例 #10
0
ファイル: functions.php プロジェクト: momoim/momo-api
function yourls_link($keyword = '')
{
    return YOURLS_SITE . '/' . yourls_sanitize_keyword($keyword);
}