doulan4371 2014-12-28 19:12
浏览 41

在服务器端执行php操作

Im projecting some web based game. Basicially i want to perform this schema:

  1. Player click on refill stock of product
  2. There is some time to needed to perform action above, for example 1 minute and 30 seconds
  3. Player change tab to product list and go back to shop overview
  4. After one hour he go back to product page and stock is refilled.

I don't know how to perform delayed php action on server side just after clicking one button by user.

I know that i can do it by simply creating another mysql table and collect there any action performed by player and create on product page simple jquery countdown with time got from sql query.

But how to do that without this table?

Also how to create some random actions such us selling product for virtual person, generate some random power cuts etc. Is it even possible with AJAX or JQuery?

Maybe i should use some cronjobs such us IPBoard one's.

Literally i don't know where to start. I know that probably i don't have skills to create some more advanced web game, but i just want to try and learn something new.

  • 写回答

2条回答 默认 最新

  • doueta6642 2014-12-28 19:15
    关注

    One way to achieve this, depending on your environment and permissions on the server, would be to just create a bash script and call the bash script with

    exec('sh /path/to/file.sh')
    

    from your php file, for example wrapped in an ajax call.

    The bash script can contain something like

    #!/bin/bash\
    echo php /path/to/file.php | at now + 2 min # << or whatever time you want
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?