From 2ebfad68c1d3ce19a1d6895691a41276279b2aa6 Mon Sep 17 00:00:00 2001 From: Sophia Atkinson Date: Sat, 24 Sep 2022 06:29:29 +0000 Subject: [PATCH] Upload files to '' --- .htaccess | 9 + .user.ini | 3 + api.php | 13 ++ index.php | 149 +++++++++++++ robots.txt | 8 + yourls-api.php | 53 +++++ yourls-go.php | 28 +++ yourls-infos.php | 555 ++++++++++++++++++++++++++++++++++++++++++++++ yourls-loader.php | 61 +++++ 9 files changed, 879 insertions(+) create mode 100644 .htaccess create mode 100644 .user.ini create mode 100644 api.php create mode 100644 index.php create mode 100644 robots.txt create mode 100644 yourls-api.php create mode 100644 yourls-go.php create mode 100644 yourls-infos.php create mode 100644 yourls-loader.php diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..6c795ea --- /dev/null +++ b/.htaccess @@ -0,0 +1,9 @@ +# BEGIN YOURLS + +RewriteEngine On +RewriteBase / +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^.*$ /yourls-loader.php [L] + +# END YOURLS diff --git a/.user.ini b/.user.ini new file mode 100644 index 0000000..1493fe9 --- /dev/null +++ b/.user.ini @@ -0,0 +1,3 @@ +open_basedir=/www/wwwroot/sop.wtf/:/tmp/:/proc/:/www/php_session/sop.wtf/ +session.save_path=/www/php_session/sop.wtf/ +session.save_handler = files \ No newline at end of file diff --git a/api.php b/api.php new file mode 100644 index 0000000..d7dd61f --- /dev/null +++ b/api.php @@ -0,0 +1,13 @@ + + + + + recaptchaV3SecretKey, 'response' => $token))); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($ch); + curl_close($ch); + $arrResponse = json_decode($response, true); + + // verify the response + if($arrResponse["success"] == '1' && $arrResponse["action"] == $action && $arrResponse["score"] >= 0.5) { + // reCAPTCHA succeeded + shorten(); + } else { + // reCAPTCHA failed + $message = "reCAPTCHA failed"; + } + } else { + // Don't use reCAPTCHA + shorten(); + } + } + + function shorten() { + // Get parameters -- they will all be sanitized in yourls_add_new_link() + $url = $_REQUEST['url']; + $keyword = isset( $_REQUEST['keyword'] ) ? $_REQUEST['keyword'] : '' ; + $title = isset( $_REQUEST['title'] ) ? $_REQUEST['title'] : '' ; + $text = isset( $_REQUEST['text'] ) ? $_REQUEST['text'] : '' ; + + // Create short URL, receive array $return with various information + $return = yourls_add_new_link( $url, $keyword, $title ); + + // Make visible to UI + global $shorturl, $message, $status, $title; + + $shorturl = isset( $return['shorturl'] ) ? $return['shorturl'] : ''; + $message = isset( $return['message'] ) ? $return['message'] : ''; + $title = isset( $return['title'] ) ? $return['title'] : ''; + $status = isset( $return['status'] ) ? $return['status'] : ''; + + // Stop here if bookmarklet with a JSON callback function ("instant" bookmarklets) + if( isset( $_GET['jsonp'] ) && $_GET['jsonp'] == 'yourls' ) { + $short = $return['shorturl'] ? $return['shorturl'] : ''; + $message = "Short URL (Ctrl+C to copy)"; + header('Content-type: application/json'); + echo yourls_apply_filter( 'bookmarklet_jsonp', "yourls_callback({'short_url':'$short','message':'$message'});" ); + die(); + } + } +?> + +
+
+
+
+ + + +
+ +
+ +
+

Your shortened link

+ +
+
+
+ + +
+ QR Code & See Link Preview ~ +
+
+
+ +
+
+
+
Logo
+ + + + + + + + +
+ +
+
+ © +
+ $val): ?> + + +
+
+
+
+
+ + + diff --git a/robots.txt b/robots.txt new file mode 100644 index 0000000..73be9a3 --- /dev/null +++ b/robots.txt @@ -0,0 +1,8 @@ +User-agent: * +Disallow: /admin +Disallow: /css +Disallow: /images +Disallow: /includes +Disallow: /js +Disallow: /user + diff --git a/yourls-api.php b/yourls-api.php new file mode 100644 index 0000000..e58d640 --- /dev/null +++ b/yourls-api.php @@ -0,0 +1,53 @@ + 'yourls_api_action_shorturl', + 'stats' => 'yourls_api_action_stats', + 'db-stats' => 'yourls_api_action_db_stats', + 'url-stats' => 'yourls_api_action_url_stats', + 'expand' => 'yourls_api_action_expand', + 'version' => 'yourls_api_action_version', +); +$api_actions = yourls_apply_filter( 'api_actions', $api_actions ); + +// Register API actions +foreach( (array) $api_actions as $_action => $_callback ) { + yourls_add_filter( 'api_action_' . $_action, $_callback, 99 ); +} + +// Try requested API method. Properly registered actions should return an array. +$return = yourls_apply_filter( 'api_action_' . $action, false ); +if ( false === $return ) { + $return = array( + 'errorCode' => 400, + 'message' => 'Unknown or missing "action" parameter', + 'simple' => 'Unknown or missing "action" parameter', + ); +} + +if( isset( $_REQUEST['callback'] ) ) + $return['callback'] = $_REQUEST['callback']; +elseif ( isset( $_REQUEST['jsonp'] ) ) + $return['callback'] = $_REQUEST['jsonp']; + +$format = ( isset( $_REQUEST['format'] ) ? $_REQUEST['format'] : 'xml' ); + +yourls_api_output( $format, $return ); + +die(); \ No newline at end of file diff --git a/yourls-go.php b/yourls-go.php new file mode 100644 index 0000000..51968dd --- /dev/null +++ b/yourls-go.php @@ -0,0 +1,28 @@ + $keyword_list); + } else { + $keyword_range = '= :keyword'; + $keyword_binds = array('keyword' => $keyword); + } + + + // *** Referrers *** + $sql = "SELECT `referrer`, COUNT(*) AS `count` FROM `$table` WHERE `shorturl` $keyword_range GROUP BY `referrer`;"; + $sql = yourls_apply_filter('stat_query_referrer', $sql); + $rows = $ydb->fetchObjects($sql, $keyword_binds); + + // Loop through all results and build list of referrers, countries and hits per day + foreach( (array)$rows as $row ) { + if ( $row->referrer == 'direct' ) { + $direct = $row->count; + continue; + } + + $host = yourls_get_domain( $row->referrer ); + if( !array_key_exists( $host, $referrers ) ) + $referrers[$host] = array( ); + if( !array_key_exists( $row->referrer, $referrers[$host] ) ) { + $referrers[$host][$row->referrer] = $row->count; + $notdirect += $row->count; + } else { + $referrers[$host][$row->referrer] += $row->count; + $notdirect += $row->count; + } + } + + // Sort referrers. $referrer_sort is a array of most frequent domains + arsort( $referrers ); + $referrer_sort = array(); + $number_of_sites = count( array_keys( $referrers ) ); + foreach( $referrers as $site => $urls ) { + if( count($urls) > 1 || $number_of_sites == 1 ) + $referrer_sort[$site] = array_sum( $urls ); + } + arsort($referrer_sort); + + + // *** Countries *** + $sql = "SELECT `country_code`, COUNT(*) AS `count` FROM `$table` WHERE `shorturl` $keyword_range GROUP BY `country_code`;"; + $sql = yourls_apply_filter('stat_query_country', $sql); + $rows = $ydb->fetchObjects($sql, $keyword_binds); + + // Loop through all results and build list of countries and hits + foreach( (array)$rows as $row ) { + if ("$row->country_code") + $countries["$row->country_code"] = $row->count; + } + + // Sort countries, most frequent first + if ( $countries ) + arsort( $countries ); + + + // *** Dates : array of $dates[$year][$month][$day] = number of clicks *** + $sql = "SELECT + DATE_FORMAT(`click_time`, '%Y') AS `year`, + DATE_FORMAT(`click_time`, '%m') AS `month`, + DATE_FORMAT(`click_time`, '%d') AS `day`, + COUNT(*) AS `count` + FROM `$table` + WHERE `shorturl` $keyword_range + GROUP BY `year`, `month`, `day`;"; + $sql = yourls_apply_filter('stat_query_dates', $sql); + $rows = $ydb->fetchObjects($sql, $keyword_binds); + + // Loop through all results and fill blanks + foreach( (array)$rows as $row ) { + if( !array_key_exists($row->year, $dates ) ) + $dates[$row->year] = array(); + if( !array_key_exists( $row->month, $dates[$row->year] ) ) + $dates[$row->year][$row->month] = array(); + if( !array_key_exists( $row->day, $dates[$row->year][$row->month] ) ) + $dates[$row->year][$row->month][$row->day] = $row->count; + else + $dates[$row->year][$row->month][$row->day] += $row->count; + } + + // Sort dates, chronologically from [2007][12][24] to [2009][02][19] + ksort( $dates ); + foreach( $dates as $year=>$months ) { + ksort( $dates[$year] ); + foreach( $months as $month=>$day ) { + ksort( $dates[$year][$month] ); + } + } + + // Get $list_of_days, $list_of_months, $list_of_years + reset( $dates ); + if( $dates ) { + $_lists = yourls_build_list_of_days( $dates ); + $list_of_days = $_lists['list_of_days']; + $list_of_months = $_lists['list_of_months']; + $list_of_years = $_lists['list_of_years']; + unset($_lists); + } + + $offset = yourls_get_time_offset(); + + // *** Last 24 hours : array of $last_24h[ $hour ] = number of click *** + $sql = "SELECT + DATE_FORMAT(DATE_ADD(`click_time`, INTERVAL " . $offset . " HOUR), '%H %p') AS `time`, + COUNT(*) AS `count` + FROM `$table` + WHERE `shorturl` $keyword_range AND DATE_ADD(`click_time`, INTERVAL " . $offset . " HOUR) > (DATE_ADD(CURRENT_TIMESTAMP, INTERVAL " . $offset . " HOUR) - INTERVAL 1 DAY) + GROUP BY `time`;"; + $sql = yourls_apply_filter('stat_query_last24h', $sql); + $rows = $ydb->fetchObjects($sql, $keyword_binds); + + $_last_24h = array(); + foreach( (array)$rows as $row ) { + if ( isset( $row->time ) ) + $_last_24h[ "$row->time" ] = $row->count; + } + + $now = intval( date('U') ); + for ($i = 23; $i >= 0; $i--) { + $h = date('H A', ($now - ($i * 60 * 60) + ($offset * 60 * 60)) ); + // If the $last_24h doesn't have all the hours, insert missing hours with value 0 + $last_24h[ $h ] = array_key_exists( $h, $_last_24h ) ? $_last_24h[ $h ] : 0 ; + } + unset( $_last_24h ); + + // *** Queries all done, phew *** + + // Filter all this junk if applicable. Be warned, some are possibly huge datasets. + $referrers = yourls_apply_filter( 'pre_yourls_info_referrers', $referrers ); + $referrer_sort = yourls_apply_filter( 'pre_yourls_info_referrer_sort', $referrer_sort ); + $direct = yourls_apply_filter( 'pre_yourls_info_direct', $direct ); + $notdirect = yourls_apply_filter( 'pre_yourls_info_notdirect', $notdirect ); + $dates = yourls_apply_filter( 'pre_yourls_info_dates', $dates ); + $list_of_days = yourls_apply_filter( 'pre_yourls_info_list_of_days', $list_of_days ); + $list_of_months = yourls_apply_filter( 'pre_yourls_info_list_of_months', $list_of_months ); + $list_of_years = yourls_apply_filter( 'pre_yourls_info_list_of_years', $list_of_years ); + $last_24h = yourls_apply_filter( 'pre_yourls_info_last_24h', $last_24h ); + $countries = yourls_apply_filter( 'pre_yourls_info_countries', $countries ); + + // I can haz debug data + /** + echo "
";
+	echo "referrers: "; print_r( $referrers );
+	echo "referrer sort: "; print_r( $referrer_sort );
+	echo "direct: $direct\n";
+	echo "notdirect: $notdirect\n";
+	echo "dates: "; print_r( $dates );
+	echo "list of days: "; print_r( $list_of_days );
+	echo "list_of_months: "; print_r( $list_of_months );
+	echo "list_of_years: "; print_r( $list_of_years );
+	echo "last_24h: "; print_r( $last_24h );
+	echo "countries: "; print_r( $countries );
+	die();
+	**/
+
+}
+
+yourls_html_head( 'infos', yourls_s( 'Statistics for %s', YOURLS_SITE.'/'.$keyword ) );
+yourls_html_logo();
+yourls_html_menu();
+?>
+
+

+ +

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

+

:

+ +
+
+
    + +
  • +
  • +
  • + +
  • +
+
+ + + +
+

+ + + + + + yourls__( 'Last 24 hours' ), + '7' => yourls__( 'Last 7 days' ), + '30' => yourls__( 'Last 30 days' ), + 'all'=> yourls__( 'All time' ), + ); + + // Which graph to generate ? + $do_all = $do_30 = $do_7 = $do_24 = false; + $hits_all = array_sum( $list_of_days ); + $hits_30 = array_sum( array_slice( $list_of_days, -30 ) ); + $hits_7 = array_sum( array_slice( $list_of_days, -7 ) ); + $hits_24 = array_sum( $last_24h ); + if( $hits_all > 0 ) + $do_all = true; // graph for all days range + if( $hits_30 > 0 && count( array_slice( $list_of_days, -30 ) ) == 30 ) + $do_30 = true; // graph for last 30 days + if( $hits_7 > 0 && count( array_slice( $list_of_days, -7 ) ) == 7 ) + $do_7 = true; // graph for last 7 days + if( $hits_24 > 0 ) + $do_24 = true; // graph for last 24 hours + + // Which graph to display ? + $display_all = $display_30 = $display_7 = $display_24 = false; + if( $do_24 ) { + $display_24 = true; + } elseif ( $do_7 ) { + $display_7 = true; + } elseif ( $do_30 ) { + $display_30 = true; + } elseif ( $do_all ) { + $display_all = true; + } + ?> + + + + + + + +
+ + $graphtitle ) { + if( ${'do_'.$graph} == true ) { + $display = ( ${'display_'.$graph} === true ? 'display:block' : 'display:none' ); + echo "
"; + echo '

' . yourls_s( 'Number of hits : %s' , $graphtitle ) . '

'; + switch( $graph ) { + case '24': + yourls_stats_line( $last_24h, "stat_line_$graph" ); + break; + + case '7': + case '30': + $slice = array_slice( $list_of_days, intval( $graph ) * -1 ); + yourls_stats_line( $slice, "stat_line_$graph" ); + unset( $slice ); + break; + + case 'all': + yourls_stats_line( $list_of_days, "stat_line_$graph" ); + break; + } + echo "
\n"; + } + } ?> + +
+

+ +

+
+
    + $graphtitle ) { + if ( ${'do_'.$graph} ) { + $link = "$graphtitle"; + } else { + $link = $graphtitle; + } + $stat = ''; + if( ${'do_'.$graph} ) { + switch( $graph ) { + case '7': + case '30': + $stat = yourls_s( '%s per day', round( ( ${'hits_'.$graph} / intval( $graph ) ) * 100 ) / 100 ); + break; + case '24': + $stat = yourls_s( '%s per hour', round( ( ${'hits_'.$graph} / 24 ) * 100 ) / 100 ); + break; + case 'all': + if( $ago > 0 ) + $stat = yourls_s( '%s per day', round( ( ${'hits_'.$graph} / $ago ) * 100 ) / 100 ); + } + } + $hits = sprintf( yourls_n( '%s hit', '%s hits', ${'hits_'.$graph} ), ${'hits_'.$graph} ); + echo "
  • $link $hits $stat
  • \n"; + } + ?> +
+
+ +

+ +

%1$s hit on %2$s', '%1$s hits on %2$s', $best['max'] ), $best['max'], yourls_date_i18n( yourls_get_date_format("F j, Y"), strtotime( $best['day'] ) ) ); ?>. +

+ + +
+ + + + ' . yourls__( 'No traffic yet. Get some clicks first!' ) . '

'; + } ?> +
+ + +
+

+ + + + + + + + + + +
+

+ +

+ + +
+

+ +
+ + + + ' . yourls__( 'No country data.' ) . '

'; + } ?> +
+ + +
+

+ + + + + + + + + + + +
+

+ 1 ) + $referrer_sort[ yourls__( 'Others' ) ] = count( $referrers ); + yourls_stats_pie( $referrer_sort, 5, '440x220', 'stat_tab_source_ref' ); + unset( $referrer_sort[yourls__('Others')] ); + ?> +

+
    + $count ) { + $i++; + $favicon = yourls_get_favicon_url( $site ); + echo "
  • $site: $count " . yourls__( '(details)' ) . "
  • \n"; + echo "\n"; + unset( $referrers[$site] ); + } + // Any referrer left? Group in "various" + if ( $referrers ) { + echo "
  • " . yourls__( 'Various:' ) . " ". count( $referrers ). " " . yourls__( '(details)' ) . "
  • \n"; + echo "\n"; + } + ?> + +
+ +
+

+ $direct, yourls__( 'Referrers' ) => $notdirect ), 5, '440x220', 'stat_tab_source_direct' ); + ?> +

%s hit', '%s hits', $direct ), $direct ); ?>

+

%s hit', '%s hits', $notdirect ), $notdirect ); ?>

+ +
+ + + + ' . yourls__( 'No referrer data.' ) . '

'; + } ?> + +
+ + + + +
+

+ + ' . yourls__( 'Short link' ) . '', '

' . yourls__( 'Quick Share' ) . '

'); ?> + +
+ +
+ + + diff --git a/yourls-loader.php b/yourls-loader.php new file mode 100644 index 0000000..eb4b6d4 --- /dev/null +++ b/yourls-loader.php @@ -0,0 +1,61 @@ +&us=&ur= + yourls_redirect( yourls_add_query_arg( $parse , yourls_admin_url( 'index.php' ) ), 302 ); + exit; +} + +// if request is an existing short URL keyword ('abc') or stat page ('abc+') or an existing page : +if ( yourls_keyword_is_taken($keyword) or yourls_is_page($keyword) ) { + + // we have a short URL or a page + if( $keyword && !$stats ) { + yourls_do_action( 'load_template_go', $keyword ); + require_once( YOURLS_ABSPATH.'/yourls-go.php' ); + exit; + } + + // we have a stat page + if( $keyword && $stats ) { + $aggregate = $stats_all && yourls_allow_duplicate_longurls(); + yourls_do_action( 'load_template_infos', $keyword ); + require_once( YOURLS_ABSPATH.'/yourls-infos.php' ); + exit; + } + +} + +// Past this point this is a request the loader could not understand : not a valid shorturl, not a bookmarklet +yourls_do_action( 'redirect_keyword_not_found', $keyword ); +yourls_do_action( 'loader_failed', $request ); +yourls_redirect( YOURLS_SITE, 302 ); +exit;