Jump to content

Time expiration script help?


smile

Recommended Posts

Hello, I'm using tipso.js to make a tooltip on an image. Then I use PHP time expiration script to show current or expired image with it's tooltip. I then use the <?php @readfile("URL to the php file"); ?>

The script is in domain1, the @readfile stuff is pasted in domain2. The file reading is from remote domain.

This pulls the whole code and inserts it in the page where it must appear.

I would happily use a javascript if it can replace the PHP altogether, but I don't know how to do this I'm not much of a programmer

"<script src="http://static.jsbin.com/js/vendor/traceur.js"></script><script src="https://code.jquery.com/jquery-3.3.1.min.js" type="text/javascript"></script>
<script src="https://tipso.object505.com/tipso.js"></script>
<link rel="stylesheet" href="https://tipso.object505.com/tipso.css">

<script>
jQuery(document).ready(function(){
jQuery('.img-tipso').tipso({
//useTitle: '',
//content : 'My HTML content here?',
background: '#666666',
//position: 'top-left'
});
});
</script>

<?php
//SET THE TIME ZONE
date_default_timezone_set('Europe/Vilnius');
//BEGIN
$today = strtotime(date("Y-m-d"));
$expireDate = strtotime("2017-12-31");
if ($today <= $expireDate) {
//ACTIVE
echo '<a href="http://www.example.com" target="_blank"><img src="http://www.petmd.com/sites/all/modules/breedopedia/images/thumbnails/cat/tn-sokoke-forest-cat.jpg" class="img-tipso" data-tipso-title="Tooltip title" data-tipso-content="<img src=\'http://www.petmd.com/sites/all/modules/breedopedia/images/thumbnails/cat/tn-sokoke-forest-cat.jpg\'/>">';
} else {
//EXPIRED
echo '<a href="http://www.example.com" target="_blank"><img src="http://www.petmd.com/sites/all/modules/breedopedia/images/thumbnails/cat/tn-sokoke-forest-cat.jpg" class="img-tipso" data-tipso-title="Tooltip title" data-tipso-content="<img src=\'http://www.petmd.com/sites/all/modules/breedopedia/images/thumbnails/cat/tn-sokoke-forest-cat.jpg\'/>">';
}

?>"

 

test http://phpfiddle.org/lite

Link to comment
Share on other sites

"Okay, making sense so far... What's your question?"

Well it works just fine with PHP but new CMS like pagekit etc. do not allow PHP code in pages other then templates. So the PHP method does not work. I'm trying to make js solution to do the same.

Link to comment
Share on other sites

Thank you everyone for your replies.

 

"Alright.

Your active and expired links/images are the same. What is supposed to be different?"

I copied the image code from internet and did not find same size different image but trust me the code works. I would appreciate help with 
barebones from my PHP code to JS so I can adapt it by populating with my data.
 

Link to comment
Share on other sites

WHAT DATA?

You've copied some code from somewhere that doesn't do what you want, said you needed to do what you want, but not really explained what you want.

Maybe what you need to do is show us the PHP that does what you want and we can change it into Javascript?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.