Jump to content

1RV34

Members
  • Posts

    9
  • Joined

  • Last visited

About 1RV34

  • Birthday 04/03/1993

1RV34's Achievements

Newbie

Newbie (1/7)

1

Reputation

  1. Combined the shutdown function & timestamp method a bit and came up with this: <?php $run = basename($_SERVER['PHP_SELF'], '.php') . '.run'; if (!file_exists($run) { touch($run); register_shutdown_function('shutdown', $run); $microtime = microtime(); file_put_contents($run, $microtime); } else { echo "Already running!"; exit; } // ... (some code) sleep($waitForFirstStartup);// dynamic calculated value while (file_exists($run) && file_get_contents($run) == $microtime) { // ... (rest of code) sleep($waitBetweenStuffToDo);// dynamic calculated value } function shutdown($run) { unlink($run); }?> I think it's pretty fail-proof now
  2. Ok threw out the complete css animation.. used javascript instead: function animation(elem) { var fullHeight = document.getElementById(elem).offsetHeight; document.getElementById(elem).style.height = 0; document.getElementById(elem).style.opacity = 0; var step = fullHeight / 80; var count = 0; var theInterval = setInterval(function () { count += step; document.getElementById(elem).style.height = count; if (count == fullHeight) { theInterval = clearInterval(theInterval); count = 0; var theInterval2 = setInterval(function () { count++; document.getElementById(elem).style.opacity = count / 10; if (count == 10) { theInterval2 = clearInterval(theInterval2); } }, 10); } }, 5);} This topic can close..
  3. What do you mean?There is a long script on the position of // ... (rest of code) and I only want one instance of that script running at a time.It is a script that can run from 4 seconds to 15 minutes and I want to make sure it can't be run twice at the same time.
  4. I have seen a lot of ways to determen if a PHP script is already running but I wonder which solution is the best.Currently I'm using this: <?php $run = basename($_SERVER['PHP_SELF'], '.php') . '.run'; if (!file_exists($run) { touch($run); } else { echo "Already running!"; exit; } // ... (rest of code)?> But I already have seen a lot examples using pid's & sid's and everything. I'm sure my solution is not the best at all and so I'm asking you all to discuss your solutions with me.
  5. First i have 2 files, index.html and check.php, the index's source is:index.html <html><head> <title>potatoes</title> <style type="text/css">@-webkit-keyframes potatointro {0% { opacity: 0; }100% { opacity: 1; }}.potato {-webkit-animation: potatointro 1s;}</style> <script type="text/javascript">function loadXMLDoc() {var xmlhttp;if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest();}else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById('potatoes').innerHTML = xmlhttp.responseText + document.getElementById('potatoes').innerHTML; }}xmlhttp.open("GET","check.php",true);xmlhttp.send();}</script></head><body> <div id="potatoes"> <div class="potato"> <p>abc</p> </div> </div></body></html> the check.php may return this: <div class="potato"> <p>def</p> </div> but at times also multiple ones: <div class="trade"> <p>ghi</p> </div> <div class="trade"> <p>def</p> </div> running loadXMLDoc() changes the body of index.html from <body> <div id="potatoes"> <div class="potato"> <p>abc</p> </div> </div></body> to <body> <div id="potatoes"> <div class="potato"> <p>def</p> </div> <div class="potato"> <p>abc</p> </div> </div></body> and that is EXACTLY what is supposed to happen, BUT as you see on the style i have a little kind of "intro" and instead of just doing that animation on the inserted part it does it on the existing ones too. i've been struggling around with insertBefore() and appendChild() and more but just can't do what i want to do.I'm kinda trying to get the effect of a timeline like in twitter, facebook or youtube when there is a new tweet/post/comment. I hope i've been clear enough and anyone could help. If there are any questions ofcourse feel free to ask.Any help would be welcome before i'll pull my hair out Edit: to clarify, i'm trying to recreate the effect like in https://twitter.com/...s/widget_search.
  6. I tried using intval() but it didn't help a thing at al. I already had tried bcsub() but it didn't work so now I tried gmp_sub() and that even returned that the function doesn't exist!Well I tried bcsub() again but this time I made the values strings & this time it did work! SolutionParse the values as strings and use bcsub().<?php $var = '76561197999467389';// will be dynamic $sum = bcsub($var, '76561197960265728');// will always be subtracted by the same value echo $sum;// returns 39201661?> Thanks you both for your help!
  7. i might could change the order of the conversion so i can subtract by less but the first is returned by another server & not determined by me so i cant do anything about thati will try it with intval() tomorrow, now im on my phone & cant access a computer
  8. yea they need to be so big & actually I don't think so either because I need it for an algorythm to convert a certain type of 64bit id to another type of id (but that one is a string & also I had no problems with the rest of the conversion, just this part)
  9. ProblemIt should return 39201661 but instead it returns 39201664. <?php $var = 76561197999467389;// will be dynamic $sum = $var - 76561197960265728;// will always be subtracted by the same value echo $sum;// returns 39201664?> What I've triedI've looked around & saw a function called bcsub() & tried to use that one but it returned 0.While looking around for an answer I also found out it might be caused by the storage of the numbers before subtraction. What I would like to knowIf it really is a storage problem, is there a workaround to get the right value anyway?If it isn't what might have caused it then? Edit: solved!
×
×
  • Create New...