Advertisement Plugin for Yourls Shorten Url Script?

  • (2 Pages)
  • +
  • 1
  • 2

27 Replies - 5542 Views - Last Post: 31 December 2012 - 12:43 PM Rate Topic: -----

#1 taim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 31-December 12

Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 08:00 AM

Hi,
Just registered here and hope gurus will help me in my issue as I'm totally a newbie in php/javascript.
I installed Yourls (Url Shorterning Script yourls.org), its working fine. But I want to add a feature which can show an Advertisement page for 5-10 seconds before redirecting user to the destination page.
I have read on their (Yourls) site that plugins are best way to add any feature. But unfortunately, my knowledge of php is zero.
I will be very grateful if any one can help me..
Any suggestions or advices are warmly welcome.
This is their latest version of Yourls script:
http://code.google.com/p/yourls/downloads/detail?name=yourls-1.5.1.zip&can=2&q=


Is This A Good Question/Topic? 0
  • +

Replies To: Advertisement Plugin for Yourls Shorten Url Script?

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5382
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 08:03 AM

The way I would attack this is to first grab the url in php, & parse the $_GET array. This is how you read the values name, zip, & whatever can is.

Then show your advertisement, log anything you need in your database, & use header() to kick them to a new site.

The problem with the 'timer' is that this will be a Javascript function, because PHP is a server side language it has not idea of a timer, as it doesn't process on the clients browser.

If the above is not accurate for your project please feel free to say so.
Was This Post Helpful? 0
  • +
  • -

#3 taim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 31-December 12

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 08:06 AM

Thanks alot for your quick reply.
Okay if I can just simple place a link for user to click and manually redirect to the destination page?
Can you please explain it?
Thank you again
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5382
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 08:10 AM

The link will not redirect them.

Say your site is example.com, the html href link would be normal :
<a href="http://example.com">Example Link</a>


However to redirect, your index.php on example.com would look like so :

<?php
  echo "Redirecting...";
  header('Location: http://google.com/');
?>



That will have the href point to your site, & your site kicks them to another page.
Was This Post Helpful? 0
  • +
  • -

#5 taim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 31-December 12

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 08:14 AM

Currently its working in this way you can check: http://taimoorsultan.com/url/k
It shows where user is going to be redirected and gives link to press for redirection. What I just want is to have some ads on that page basically.
Hope you understand it. Thank you! :)
Was This Post Helpful? 0
  • +
  • -

#6 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5382
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 08:18 AM

Alright, using my example above :

<?php
  /* http://taimoorsultan.com/url/k */
  echo "<p>This is an example advertisement</p>
  header('Location: http://www.dreamincode.net/forums');
?>



That removes Google from the example, & replaces it with the link in your example.
Was This Post Helpful? 0
  • +
  • -

#7 taim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 31-December 12

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 08:24 AM

Sorry to say but I still can't get it. :dontgetit:
You mean to say that I need to put my ad in <p></p> but I'm unable to place adsense or some other ad which have javascript with them, between <p></p>
Actually this is my current code of plugin which shows this warning/information before redirection:
<?php
/*
Plugin Name: Redirection Ads

*/

// Hook our custom function into the 'pre_redirect' event
yourls_add_action( 'pre_redirect', 'warning_redirection' );

// Our custom function that will be triggered when the event occurs
function warning_redirection( $args ) {
        $url  = $args[0];
        $code = $args[1];
        
        // Print the message	
        echo "<p>This is a redirection page to: $url";
        echo "<p>Click <a href='$url'>here</a> to proceed</p>";
        
		
		// Now die so the normal flow of event is interrupted
        die();
}

// And that's it!


How can I place adsense or bidvertiser ads on that page? thank you!
Was This Post Helpful? 0
  • +
  • -

#8 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5382
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 08:34 AM

View Posttaim, on 31 December 2012 - 10:24 AM, said:

Sorry to say but I still can't get it. :dontgetit:
You mean to say that I need to put my ad in <p></p>

I'm just going off your example.

View Posttaim, on 31 December 2012 - 10:24 AM, said:

How can I place adsense or bidvertiser ads on that page?

You want to place adsense on a site that you only display for five to ten seconds? That doesn't seem right...

Lets start from the beginning.

Someone clicks on a link, it takes them to your site (that you provided an example), you want that page to display for five to ten seconds, & then auto redirect? Yes?

If you are not collecting any data from the visitor, I wouldn't bother using PHP for this. You can redirect just as easily with Javascript. & if the visitor doesn't allow for Javascript, your timer won't work anyhow.

& yes, you can put your Javascript in the example file. Not in the paragraph tags, but your php doesn't need to only be two lines. I'm not going to write the entire thing for you, it was just an example.

View Posttaim, on 31 December 2012 - 10:24 AM, said:

How can I place adsense or bidvertiser ads on that page?


<?php
/*
Plugin Name: Redirection Ads

*/

// Hook our custom function into the 'pre_redirect' event
yourls_add_action( 'pre_redirect', 'warning_redirection' );

// Our custom function that will be triggered when the event occurs
function warning_redirection( $args ) {
        $url  = $args[0];
        $code = $args[1];
        
        // Print the message	
        echo "html off add here";
        header('Location: http://www.dreamincode.net/forums');		
}

// And that's it!



Not sure how to use yourls_add_action, so I'll take your word that the function warning_redirection is executed. Assuming it is, the above should do what you want.
Was This Post Helpful? 0
  • +
  • -

#9 taim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 31-December 12

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 08:41 AM

Yes, you are right.
Suppose I use YOURLS script (which is already installed on http://taimoorsultan.com/url) to shorten a long URL (suppose this: https://www.facebook.com/dreamincode), now I share this shorten link on my website or any other site saying its going to DreaminCode's Fb Page. When user clicks on the shorten link (http://taimoorsultan.com/url/l) he will be taken to my site, where he will se ads/banner for 5-10 seconds, and then Automatically or through Manual click, he will be redirected to the DreaminCode's FB Page.
This is the whole process I want to have.
What I'm missing in above process is to have a feature/Plugin, which will show ads/banners on Shorten link (http://taimoorsultan.com/url/l) for 5-10 seconds.
I know you can not write whole thing it its too heavy. But it will be helpful if you can tell me from where I can get it done for some money.
Thank you!
Was This Post Helpful? 0
  • +
  • -

#10 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5382
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 08:44 AM

Hrm, after reading over the header page (that I provided a link to) it looks like it does offer a timer. You should be all set if you use the refresh option.

What you are asking for is not at all difficult, it just requires 10 minutes of reading & experimenting. It's nothing ground breaking ;)
Was This Post Helpful? 0
  • +
  • -

#11 taim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 31-December 12

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 08:51 AM

So, it means you can do it? :bored:
Was This Post Helpful? 0
  • +
  • -

#12 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5382
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 08:57 AM

http://yardsalesgalore.com/example.php
Was This Post Helpful? 0
  • +
  • -

#13 taim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 31-December 12

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 09:03 AM

Oh really? Yeah, exactly what i'm looking for.
Now can you pleaseee explain how can I achieve this?
Was This Post Helpful? 0
  • +
  • -

#14 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5382
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 09:07 AM

Quote

Now can you pleaseee explain how can I achieve this?

I have....

This is the code form that page.
<?php
  header('Refresh:7;url=http://dreamincode.net/forums');
?>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-3096305097062678";
/* 125x125, created 1/21/11 */
google_ad_slot = "3050924195";
google_ad_width = 125;
google_ad_height = 125;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>



To use with your example :

<?php
/*
Plugin Name: Redirection Ads

*/

// Hook our custom function into the 'pre_redirect' event
yourls_add_action( 'pre_redirect', 'warning_redirection' );

// Our custom function that will be triggered when the event occurs
function warning_redirection( $args ) {
        $url  = $args[0];
        $code = $args[1];
        // Output AdSense
?>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-3096305097062678";
/* 125x125, created 1/21/11 */
google_ad_slot = "3050924195";
google_ad_width = 125;
google_ad_height = 125;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

<?php
        // Redirect in 10 seconds
        header('Refresh:10;url=http://dreamincode.net/forums');
}
?>


Was This Post Helpful? 0
  • +
  • -

#15 taim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 31-December 12

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 09:26 AM

Thank you but refreshing is not working :/ and it is not showing anything between.
http://taimoorsultan.com/url/m
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2