yourls_e('Traffic sources'); ?> </strong></a></li> <?php } ?> <li><a href="#stat_tab_share"><strong><?php yourls_e('Share'); ?> </strong></a></li> </ul> </div> <?php if (yourls_do_log_redirect()) { ?> <div id="stat_tab_stats" class="tab"> <h2><?php yourls_e('Traffic statistics'); ?> </h2> <?php yourls_do_action('pre_yourls_info_stats', $keyword); ?> <?php if ($list_of_days) { ?>
/** * Display the Quick Share box * */ function yourls_share_box($longurl, $shorturl, $title = '', $text = '', $shortlink_title = '', $share_title = '', $hidden = false) { if ($shortlink_title == '') { $shortlink_title = '<h2>' . yourls__('Your short link') . '</h2>'; } if ($share_title == '') { $share_title = '<h2>' . yourls__('Quick Share') . '</h2>'; } // Allow plugins to short-circuit the whole function $pre = yourls_apply_filter('shunt_share_box', false); if (false !== $pre) { return $pre; } $text = $text ? '"' . $text . '" ' : ''; $title = $title ? "{$title} " : ''; $share = yourls_esc_textarea($title . $text . $shorturl); $count = 140 - strlen($share); $hidden = $hidden ? 'style="display:none;"' : ''; // Allow plugins to filter all data $data = compact('longurl', 'shorturl', 'title', 'text', 'shortlink_title', 'share_title', 'share', 'count', 'hidden'); $data = yourls_apply_filter('share_box_data', $data); extract($data); $_share = rawurlencode($share); $_url = rawurlencode($shorturl); ?> <div id="shareboxes" <?php echo $hidden; ?> > <?php yourls_do_action('shareboxes_before', $longurl, $shorturl, $title, $text); ?> <div id="copybox" class="share"> <?php echo $shortlink_title; ?> <p><input id="copylink" class="text" size="32" value="<?php echo yourls_esc_url($shorturl); ?> " /></p> <p><small><?php yourls_e('Long link'); ?> : <a id="origlink" href="<?php echo yourls_esc_url($longurl); ?> "><?php echo yourls_esc_url($longurl); ?> </a></small> <?php if (yourls_do_log_redirect()) { ?> <br/><small><?php yourls_e('Stats'); ?> : <a id="statlink" href="<?php echo yourls_esc_url($shorturl); ?> +"><?php echo yourls_esc_url($shorturl); ?> +</a></small> <input type="hidden" id="titlelink" value="<?php echo yourls_esc_attr($title); ?> " /> <?php } ?> </p> </div> <?php yourls_do_action('shareboxes_middle', $longurl, $shorturl, $title, $text); ?> <div id="sharebox" class="share"> <?php echo $share_title; ?> <div id="tweet"> <span id="charcount" class="hide-if-no-js"><?php echo $count; ?> </span> <textarea id="tweet_body"><?php echo $share; ?> </textarea> </div> <p id="share_links"><?php yourls_e('Share with'); ?> <a id="share_tw" href="http://twitter.com/home?status=<?php echo $_share; ?> " title="<?php yourls_e('Tweet this!'); ?> " onclick="share('tw');return false">Twitter</a> <a id="share_fb" href="http://www.facebook.com/share.php?u=<?php echo $_url; ?> " title="<?php yourls_e('Share on Facebook'); ?> " onclick="share('fb');return false;">Facebook</a> <?php yourls_do_action('share_links', $longurl, $shorturl, $title, $text); // Note: on the main admin page, there are no parameters passed to the sharebox when it's drawn. ?> </p> </div> <?php yourls_do_action('shareboxes_after', $longurl, $shorturl, $title, $text); ?> </div> <?php }
/** * Log a redirect (for stats) * * This function does not check for the existence of a valid keyword, in order to save a query. Make sure the keyword * exists before calling it. * * @since 1.4 * @param string $keyword short URL keyword * @return mixed Result of the INSERT query (1 on success) */ function yourls_log_redirect($keyword) { // Allow plugins to short-circuit the whole function $pre = yourls_apply_filter('shunt_log_redirect', false, $keyword); if (false !== $pre) { return $pre; } if (!yourls_do_log_redirect()) { return true; } global $ydb; $table = YOURLS_DB_TABLE_LOG; $keyword = yourls_escape(yourls_sanitize_string($keyword)); $referrer = isset($_SERVER['HTTP_REFERER']) ? yourls_escape(yourls_sanitize_url($_SERVER['HTTP_REFERER'])) : 'direct'; $ua = yourls_escape(yourls_get_user_agent()); $ip = yourls_escape(yourls_get_IP()); $location = yourls_escape(yourls_geo_ip_to_countrycode($ip)); return $ydb->query("INSERT INTO `{$table}` (click_time, shorturl, referrer, user_agent, ip_address, country_code) VALUES (NOW(), '{$keyword}', '{$referrer}', '{$ua}', '{$ip}', '{$location}')"); }
function yourls_share_box($longurl, $shorturl, $title = '', $text = '', $shortlink_title = '<h2>Your short link</h2>', $share_title = '<h2>Quick Share</h2>', $hidden = false) { $text = $text ? '"' . $text . '" ' : ''; $title = $title ? "{$title} " : ''; $share = htmlspecialchars_decode($title . $text . $shorturl); $_share = rawurlencode($share); $_url = rawurlencode($shorturl); $count = 140 - strlen($share); $hidden = $hidden ? 'style="display:none;"' : ''; ?> <div id="shareboxes" <?php echo $hidden; ?> > <?php yourls_do_action('shareboxes_before'); ?> <div id="copybox" class="share"> <?php echo $shortlink_title; ?> <p><input id="copylink" class="text" size="40" value="<?php echo $shorturl; ?> " /></p> <p><small>Long link: <a id="origlink" href="<?php echo $longurl; ?> "><?php echo $longurl; ?> </a></small> <?php if (yourls_do_log_redirect()) { ?> <br/><small>Stats: <a id="statlink" href="<?php echo $shorturl; ?> +"><?php echo $shorturl; ?> +</a></small> <input type="hidden" id="titlelink" value="<?php echo $title; ?> " /> <?php } ?> </p> </div> <?php yourls_do_action('shareboxes_middle'); ?> <div id="sharebox" class="share"> <?php echo $share_title; ?> <div id="tweet"> <span id="charcount" class="hide-if-no-js"><?php echo $count; ?> </span> <textarea id="tweet_body"><?php echo $share; ?> </textarea> </div> <p id="share_links">Share with <a id="share_tw" href="http://twitter.com/home?status=<?php echo $_share; ?> " title="Tweet this!" onclick="share('tw');return false">Twitter</a> <a id="share_fb" href="http://www.facebook.com/share.php?u=<?php echo $_url; ?> " title="Share on Facebook" onclick="share('fb');return false;">Facebook</a> <a id="share_ff" href="http://friendfeed.com/share/bookmarklet/frame#title=<?php echo $_share; ?> " title="Share on Friendfeed" onclick="javascript:share('ff');return false;">FriendFeed</a> <?php yourls_do_action('share_links', $longurl, $shorturl, $title, $text); ?> </p> </div> <?php yourls_do_action('shareboxes_after'); ?> </div> <?php }
/** * Display the Quick Share box * */ function yourls_share_box($longurl, $shorturl, $title = '', $text = '', $shortlink_title = '', $share_title = '', $hidden = false) { if ($shortlink_title == '') { $shortlink_title = '<h2>' . yourls__('Dein Kurzlink') . '</h2>'; } if ($share_title == '') { $share_title = '<h2>' . yourls__('Teilen') . '</h2>'; } // Allow plugins to short-circuit the whole function $pre = yourls_apply_filter('shunt_share_box', false); if (false !== $pre) { return $pre; } $text = $text ? '"' . $text . '" ' : ''; $title = $title ? "{$title} " : ''; $share = yourls_esc_textarea($title . $text . $shorturl); $count = 140 - strlen($share); $hidden = $hidden ? 'style="display:none;"' : ''; // Allow plugins to filter all data $data = compact('longurl', 'shorturl', 'title', 'text', 'shortlink_title', 'share_title', 'share', 'count', 'hidden'); $data = yourls_apply_filter('share_box_data', $data); extract($data); $_share = rawurlencode($share); $_url = rawurlencode($shorturl); ?> <!-- This is somewhat pointless --> <!-- <div id="shareboxes" <?php echo $hidden; ?> > --> <?php yourls_do_action('shareboxes_before', $longurl, $shorturl, $title, $text); ?> <div class="main-column"> <div id="copybox" class="panel panel-regular"> <div class="panel-header"> <?php echo $shortlink_title; ?> </div> <div class="panel-body"> <p><input id="copylink" class="form-control input-lg" value="<?php echo yourls_esc_url($shorturl); ?> " /></p> <p><?php yourls_e('Verweist auf'); ?> : <a id="origlink" href="<?php echo yourls_esc_url($longurl); ?> "><?php echo yourls_esc_url($longurl); ?> </a> <?php if (yourls_do_log_redirect()) { ?> <br/><?php yourls_e('Statistiken'); ?> : <a id="statlink" href="<?php echo yourls_esc_url($shorturl); ?> +"><?php echo yourls_esc_url($shorturl); ?> +</a> <input type="hidden" id="titlelink" value="<?php echo yourls_esc_attr($title); ?> " /> <?php } ?> </p> </div> </div> <?php yourls_do_action('shareboxes_middle', $longurl, $shorturl, $title, $text); ?> </div><!-- /.main-column --> <div class="sidebar-column"> <div class="panel panel-sidebar"> <?php echo $share_title; /* is h2 */ ?> <div class="panel-body"> <span class="caret"></span> <div id="tweet"> <!--<span id="charcount" class="hide-if-no-js"><?php echo $count; ?> </span>--> <textarea id="tweet_body" class="form-control" rows="5"><?php echo $share; ?> </textarea> </div> <p id="share_links"><?php yourls_e('Teilen über'); ?> <a id="share_tw" href="http://twitter.com/home?status=<?php echo $_share; ?> " title="<?php yourls_e('Tweet this!'); ?> " onclick="share('tw');return false">Twitter</a> <a id="share_fb" href="http://www.facebook.com/share.php?u=<?php echo $_url; ?> " title="<?php yourls_e('Share on Facebook'); ?> " onclick="share('fb');return false;">Facebook</a> <a id="share_ff" href="http://friendfeed.com/share/bookmarklet/frame#title=<?php echo $_share; ?> " title="<?php yourls_e('Share on Friendfeed'); ?> " onclick="share('ff');return false;">FriendFeed</a> <?php yourls_do_action('share_links', $longurl, $shorturl, $title, $text); // Note: on the main admin page, there are no parameters passed to the sharebox when it's drawn. ?> </p> </div> </div> </div><!-- /.sidebar-column --> <?php yourls_do_action('shareboxes_after', $longurl, $shorturl, $title, $text); ?> <!-- </div> /#shareboxes --> <?php }
function yourls_log_redirect($keyword) { if (!yourls_do_log_redirect()) { return true; } global $ydb; $table = YOURLS_DB_TABLE_LOG; $keyword = yourls_sanitize_string($keyword); $referrer = isset($_SERVER['HTTP_REFERER']) ? yourls_sanitize_url($_SERVER['HTTP_REFERER']) : 'direct'; $ua = yourls_get_user_agent(); $ip = yourls_get_IP(); $location = yourls_geo_ip_to_countrycode($ip); return $ydb->query("INSERT INTO `{$table}` VALUES ('', NOW(), '{$keyword}', '{$referrer}', '{$ua}', '{$ip}', '{$location}')"); }