From a681ca011e9d291e19a86ee0fd3d9713bc6ffdbc Mon Sep 17 00:00:00 2001 From: ozhozh Date: Thu, 17 Sep 2009 20:29:59 +0000 Subject: [PATCH] Allow multiple short URLs for the same long URL. Fixes Issue 35. git-svn-id: http://yourls.googlecode.com/svn/trunk@181 12232710-3e20-11de-b438-597f59cd7555 --- images/chart_bar_add.png | Bin 0 -> 626 bytes includes/config-sample.php | 5 +++++ includes/functions.php | 21 ++++++++++++++++++-- readme.html | 4 ++++ yourls-infos.php | 38 +++++++++++++++++++++++++++++++++++-- 5 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 images/chart_bar_add.png diff --git a/images/chart_bar_add.png b/images/chart_bar_add.png new file mode 100644 index 0000000000000000000000000000000000000000..d283e846a29f929681435f01c961faf486f274a6 GIT binary patch literal 626 zcmV-&0*(ENP)v?QT{`n=t5=RT+5AJm{BbjCAW=lY$)Da?%jsp?V9`R99QPKcuTq)0YGwL-(m(ExjR zzuclKmIO;e`|<-qG<-6WDBZP8-RFN8Ox*-kikvBOrm?96F3M(~{l;?gmI5KBPtkOY!&7>tk<7nGEZ-Y!L3%G}C~r6|OhNInrl zqM|;42>1ZrLyRHVOl)v{XpDkl^VKAerZ3ijA_ypt(BA64R z80Y(Hh{E@82W;)EvAMI#{Pa^6UeD0o(N$jIQP(YWX%`EErHrMF_GXrsb|5O2g|h>< zS^xBg@!?5ceO{!qsIvO;9rd3>6eoS>vAY)*fLY))&;Sget_col( "SELECT `keyword` FROM `$table` WHERE `url` = '$longurl'" ); } \ No newline at end of file diff --git a/readme.html b/readme.html index 5d64e16..c5e2467 100644 --- a/readme.html +++ b/readme.html @@ -309,6 +309,10 @@
  • YOURLS_PRIVATE
    Private means protected with login/pass as defined below. Set to false for public usage
    Example: 'true'
  • +
  • YOURLS_UNIQUE_URLS
    + Allow multiple short URLs for a same long URL
    + Set to true to allow only one pair of shortURL/longURL (default YOURLS behavior), or to false to allow creation of multiple short URLs pointing to the same long URL (as bit.ly does)
    + Example: 'true'
  • YOURLS_COOKIEKEY
    A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated. Hint: generate a unique one at http://yourls.org/cookie
    Example: 'qQ4KhL_pu|s@Zm7n#%:b^{A[vhm'
  • diff --git a/yourls-infos.php b/yourls-infos.php index ce55728..eb79765 100644 --- a/yourls-infos.php +++ b/yourls-infos.php @@ -6,18 +6,35 @@ if ( !isset( $_GET['id'] ) ) yourls_redirect( YOURLS_SITE, 307 ); + +$aggregate = false; +if ( isset( $_GET['all'] ) && $_GET['all'] == 1 && yourls_allow_duplicate_longurls() ) + $aggregate = true; // Get basic infos for this shortened URL $keyword = yourls_sanitize_string( $_GET['id'] ); $longurl = yourls_get_keyword_longurl( $keyword ); $clicks = yourls_get_keyword_clicks( $keyword ); $timestamp = yourls_get_keyword_timestamp( $keyword ); + if ( $longurl === false ) yourls_redirect( YOURLS_SITE, 307 ); + +// Duplicate keywords, if applicable +$keyword_list = yourls_get_duplicate_keywords( $longurl ); // Fetch all information from the table log $table = YOURLS_DB_TABLE_LOG; -$hits = $ydb->get_results( "SELECT `click_time`, `referrer`, `user_agent`, `country_code` FROM `$table` WHERE `shorturl` = '$keyword';" ); + + +if( $aggregate ) { + $keywords = join( "', '", $keyword_list ); + // Fetch information for all keywords pointing to $longurl + $hits = $ydb->get_results( "SELECT `shorturl`, `click_time`, `referrer`, `user_agent`, `country_code` FROM `$table` WHERE `shorturl` IN ( '$keywords' );" ); +} else { + // Fetch information for current keyword only + $hits = $ydb->get_results( "SELECT `click_time`, `referrer`, `user_agent`, `country_code` FROM `$table` WHERE `shorturl` = '$keyword';" ); +} $referrers = array(); $direct = 0; @@ -145,7 +162,24 @@

    Informations

    -

    Short URL:

    +

    Short URL: + 1 ) + echo ' '; +} ?>

    Long URL:

    -- 2.45.0