Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <pre>
- <?php
- /**
- * Insert fake links in YOURLS
- *
- */
- // Load YOURLS
- require_once( dirname(__FILE__).'/includes/load-yourls.php' );
- // Add 10 links
- for( $i = 1; $i <= 10; $i++ ) {
- $url = generate_fake_URL();
- $title = 'Title ' . yourls_rnd_string( mt_rand(5, 20) );
- $return = yourls_add_new_link( $url, '', $title );
- $keyword = $return['url']['keyword'];
- // Add 10 hits per link
- for ( $h = 1; $h <= 10; $h++ ) {
- insert_fake_link( $keyword );
- }
- var_dump( $keyword );
- }
- // Generate fake URL
- function generate_fake_URL() {
- return yourls_rnd_string( mt_rand(2, 10) ) . '.com/' . yourls_rnd_string( mt_rand(2, 10) ) . '/';
- }
- // Generate fake IP
- function generate_fake_IP() {
- return long2ip(rand(0, 2147483647));
- }
- // Generate fake user agent
- function generate_fake_user_agent() {
- return 'Mozilla/' . mt_rand( 3, 5 ) . '.0 (' . yourls_rnd_string( mt_rand(5, 20) ) . ')';
- }
- // Insert fake hits on a link
- function insert_fake_link( $keyword ) {
- global $ydb;
- $table = YOURLS_DB_TABLE_LOG;
- $referrer = generate_fake_URL();
- $ua = generate_fake_user_agent();
- $ip = generate_fake_IP();
- $location = 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')" );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement