duanpei8853 2015-11-24 09:35
浏览 38
已采纳

按当天动态更改应用内容

I'm developing an app (using HTML / PHP / Java Script) for Facebook.

When the app is opened, there is button Start. After clicking, it should show some pictures.

App duration is from 1st of December to 25th of December.

Each day after clicking Open It should show different image. For example on 1st of December should show 1.jpg, on 2nd of December should show 2.jpg and so on.

What is best way to achieve It? Should I create Cron Job? Should I create separate files for everyday? 1.php, 2.php and etc? Or I have to create game.php and add there different DIVS for everyday and with Java Script show required DIV for current day?

Index.html looks like:

<div id="main" class="main">
    <img src="images/background.png" alt="Christmas Game" class="background_main">
    <input type="image" src="images/start.png" alt="Start Game" class="start_btn" onClick="parent.location='game.php'" />
</div>

By click button from index.html It should redirect me to correct content of current day.

Game.php looks like this:

<div id="main" class="main">

    <img src="images/day1/game.png" alt="Christmas Game" class="game">

    <a href="downloads/coupon.jpg" download="coupon.jpg" title="Prize Coupon">

        <img src="images/day1/download.png" alt="Download Coupon" class="download">

    </a>            

</div>

Somehow I need to make It dynamic that everyday opened different images / pages.

If something unclear - ask me, I will try provide more details.

  • 写回答

2条回答 默认 最新

  • doumen5895 2015-11-24 09:50
    关注

    Here's a simple and secured way to do it. What I would suggest you to do is, to save all the image files with an encrypted name. You can use php hash function to generate a complex hash which would be impossible to break.

    Generate 25 images names in this way.

    $imgName = hash('sha512', '1'); //this would generate a complex hash, which would be for pic 1.png
    $imgName = hash('sha512', '2'); //this would generate a complex hash, which would be for pic 2.png
    

    Now using php, you can easily display these images. Look at this.

    <?php
    //get today's date.
    $currentDate = date('d'); //24 - current date
    $imgName = hash('sha512', $currentDate).".png";//now this would generate a really long file name, which will be impossible for a user to guess
    ?>
    
    <!-- Now to display the image, just do this -->
    <img src="yourimagedirector/<?php echo $imgName; ?>">
    

    My code first gets the current date, then builds up the fileName (like we stored before), then fetches it up and shows it. Simple, fast and secure!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 MATLAB动图的问题
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名