Advertisement Plugin for Yourls Shorten Url Script?

  • (2 Pages)
  • +
  • 1
  • 2

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

#16 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,886
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 09:29 AM

Funny thing about php code, it's server side so I can't view it from your url. If you want help troubleshooting the code, you will need to post it here.

Also, the link you provided me linked me to http://www.codingfor...ad.php?t=285068
Was This Post Helpful? 0
  • +
  • -

#17 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:35 AM

Sorry for that
Here is the code:
<?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=$url');
}
?>


And yes, its the correct url which you are seeing.
Now this url is http://taimoorsultan.com/url/n linking to our this thread.
Was This Post Helpful? 0
  • +
  • -

#18 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,886
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 09:38 AM

Your using $url in your redirection. What value does it contain?

What output does the following provide?
<?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
        if(!isset($url)) {
                echo "url was not set";
        } else {
                // Troubleshooting
                echo "Redirecting to ".$url;
                // Redirect in 10 seconds
                header('Refresh:10;url=$url');
        }
}
?>


Was This Post Helpful? 0
  • +
  • -

#19 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:42 AM

$url contains the destination url for every shorten url.

This is the output of the url after placing the code you have given.
http://taimoorsultan.com/url/n
Was This Post Helpful? 0
  • +
  • -

#20 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,886
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 09:47 AM

View Posttaim, on 31 December 2012 - 11:42 AM, said:

$url contains the destination url for every shorten url.

I know what you want it to contain. I'm trying to get you to think about it more programmatically. There is a common issue with new developers known as "do what I want, not what I say". You can remove this confusion by outputting variables for visual verification.
Was This Post Helpful? 0
  • +
  • -

#21 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,886
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 09:53 AM

If the following doesn't work, then I don't have an answer. My mockup works fine, but when you plug that into your yourls, there must be some sort of conflict. Without knowing more about the product, I couldn't tell you what the issue is.

<?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 Header information
       if(!isset($url)) {
                echo "url was not set";
        } else {
                // Troubleshooting
                echo "Redirecting to ".$url;
                // Redirect in 10 seconds
                header('Refresh:10;url='.$url);
        }        
        // 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 } ?>



** Edit **
Made a small edit to the url in the header line. Single quotes do not evaluate (or shouldn't) php strings. So either change that line to double quotes, or use it how I provided it. I dont' think that's the error, but it's more correct, imo.
Was This Post Helpful? 0
  • +
  • -

#22 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 - 10:12 AM

:/ same output with that code.
ok, if I give your ftp and Yourls login details, can you check it then?
Thanks again!
Was This Post Helpful? 0
  • +
  • -

#23 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,886
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 10:22 AM

Hrm, how about you show me where I ever suggested you use the following code :

Quote

<script type="text/javascript">
window.location="http://www.dreamincode.net/forums/topic/305274-advertisement-plugin-for-yourls-shorten-url-script";
</script>


Getting help from more than one place is fine, but it really wastes my time when someone else's suggestions are overstepping mine.
Was This Post Helpful? 0
  • +
  • -

#24 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 - 10:30 AM

I have posted this question in lot of forums but still not a single reply from any of them. And I want to thank you for your time, as till now we have a long conversation.
Thanks
Was This Post Helpful? 0
  • +
  • -

#25 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,886
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 12:00 PM

Can you post your current code?
Was This Post Helpful? 0
  • +
  • -

#26 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 - 12:22 PM

<?php
/*
Plugin Name: Ad Redirect
*/

// 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
	
  header( "refresh:5;url=$url" );
  echo 'You\'ll be redirected in about 5 secs.';

        // Now die so the normal flow of event is interrupted
        die();				
}




Well, thanks to you. :) I some how managed to make it wait for 5 seconds, but don't know to show ads on that page.
As, this link http://taimoorsultan.com/url/o is going to twitter after 5 secs. :)
Oh, Happy New Year.. :D
Was This Post Helpful? 0
  • +
  • -

#27 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,886
  • Joined: 10-May 07

Re: Advertisement Plugin for Yourls Shorten Url Script?

Posted 31 December 2012 - 12:27 PM

Somehow? It's because you passed refresh:5 to the header...

<?php
/*
Plugin Name: Ad Redirect
*/

// 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];
  
        // Redirect after 5 seconds
        header( "refresh:5;url=$url" );
?>
<!-- Place HTML/Javascript for Google Ads here -->
<?php 
        // End Function warning_redirection
} 
?>



The above should give you what you need.
Was This Post Helpful? 1
  • +
  • -

#28 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 - 12:43 PM

Yes, its working after I play with it a little.

Now, this code is working exactly how I wish..

<?php
/*
Plugin Name: Ad Redirect
*/

// 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
		
  header( "refresh:5;url=$url" );
  echo 'You\'ll be redirected in about 5 secs.';
   
?>
<div style="margin:auto;">
<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></div>
<?php 
        // Now die so the normal flow of event is interrupted
        die();
				
}





Thank you very much... :)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2