Jump to content

AviNahum

Members
  • Posts

    170
  • Joined

  • Last visited

Everything posted by AviNahum

  1. hello, i have an event reservation system. i need to make sure that every time someone is booking a new time, it's not overlap another reservation. for example lets say i have an event reserved starting at X and ending at Y X = Wed Sep 10 2014 07:30:00 GMT+0000 Y = Wed Sep 10 2014 08:00:00 GMT+0000 and now im reserving a new event start = Wed Sep 10 2014 09:30:00 GMT+0000 end = Wed Sep 10 2014 09:30:00 GMT+0000 how can i check if they are not crushing? lets say the first event starts at 12:00 and end 14:00, i need to make sure that the new event is not held between these hours. it need to be started and end before 12:00 or after 14:00. thanks in advance!
  2. i suggest you take a look at this post i wrote http://avinahum.com/simple-yet-powerful-login-session-class-2/
  3. hello, i was thinking about start selling on codecanyon lately. i always bought there stuff but never thought to sell there and im not sure if it's worth to waste my time on trying to sell there. im not looking for a main income, just a few dollars a month will be good enough. is the competition is hard there? thanks in advance!
  4. or just start with putting your code in a CODE tag?
  5. hey there, lately im was working on a new application that required alot of ajax requests... i was wondering, many websites return fom the server a json object and then creates the html elements with javasript and then appending it to the document. why not return the html from the server and then just append it to a div, which is more easier! for example, lets say i want to print a table with shop items and their prices, why should i return a json object and then print a table with javascript with the data insted of return the whole html table from the server? am i missing something? thanks in advance.
  6. i have no problem to draw something on the screen, my main problem is to do the math and get the X,Y points...
  7. i'll explain better... i have a div with a background, i call it the galaxy... inside the galaxy div there a few div's with absalute position, i call each div like this a star... i need that each star will be surounded with a polygon as i demostrated in the picture...
  8. thr problem is that the number of stars and their positions are dynamic...
  9. Thanks... i know how to use the GD library, my problem is doing the math...
  10. hey... im making a simple game, and im trying to draw a dynamic polygon around each star in the game to show the stars area. for example, lets say "STAR A" positioned on X=50,Y=100 on the map, in the database i have a colum that determine the star's surended area for example, area=100; is that posible to darw a polygon around each star depending on the star area on the DB? another think is that each polygon shuold be in diffrent color. im not asking for the full soultion, but if someone can please give me some directions how to do it... im not good at math :| i made an image to demostarate what im trying to reach... Thanks in advance...
  11. as i see it now, it works perfectly! Thank you! Thanks for clearing this up to everyone ^^
  12. well, i still insist not to use cron :|
  13. first of all Thanks! second, it almost work... i set the time i have to get tickets to 14:19, and i did get this tickets, so the next time should be 15:19... insted it tells the next time is 15:00... another thing is that i have to handle minutes too... for example, lets say the last time i got tickets wast 12:20, then the next time i logged in is 14:10 so i have to get 30 tickets for 2 hours, and take in account that i have to get tickets again in the next 10 minutes! and yea, for the purpose im doing this tickets it is make a diffrence if a user will get tickets a few minutes after he registered :| Thanks again!
  14. im using the time() function... i dont using a cron cuz the time the user have to get the tickets depends on the time he registered... i dont want someone who registered in 13:59 to get tickets on 14:00
  15. it should be done with JS... javascript has onSubmit event. just make a function that alerts a message, and call this function on form submit event...
  16. hey i trying to find a specific plugin, but searches in google haven't helped me :| i looking for a plugin that doing these things: lets assume i have an image 2500X2500. i putting this image as a background on a div sized 600X600 now all i need is a buttons that will move the div background and content! for example lets say the div is 100X100 and i putting some text in a floating div positioned in x=300, y=500 which mean out of the range of the view. now if i want watch this text i need to move with arrows/buttons to see it. is there a plugin like that? Thanks in advance ** sorry for poor english **
  17. hey, im building a web based browser game. what im trying to do is to give the user 15 tickets every hour. what i did is to store the time the user got the tickets last time, and when the user loging in again, or refresh the page, i check how many hours passed from the last time he got tickets, then i update his tickets to 15*$hours. the problem is that it updates the tickets all the time :| here is my code so far: $member_id = intval($this->member['id']); if ($member_id != 0) { $ticketsToAdd = 0; $lastTicket = $this->member['last_tickets']; // last time the user got tickets $ticketsJump = $INFO['tickets_jump']; // how many tickets to add the user, set to 15 $ticketsJumpTime = $INFO['tickets_jump_time']; // after how many hours update the user tickets, set to 1 $timeDiff = $std->timePassed($lastTicket); // calculate the time diffrence between now and the last time the user got tikets if ($timeDiff['hours'] >= $ticketsJumpTime) { $ticketsToAdd = $ticketsJump * $timeDiff['hours']; if ($timeDiff['minutes'] != 0) { $lastTicketWorkAround = time() - ($timeDiff['minutes']*60); } else { $lastTicketWorkAround = time(); } $DB->query("UPDATE users SET tickets = tickets+".$ticketsToAdd.", last_tickets='".$lastTicketWorkAround."' WHERE id='".$this->member['id']."'"); } } public function timePassed($str) { $sec = time() - $str; return array( "hours" => intval($sec / 60 / 60), "minutes" => intval($sec / 60)); # if($sec < 60) { /* if less than a minute, return seconds */ # return $sec . " seconds ago"; # } # else if($sec < 60*60) { /* if less than an hour, return minutes */ # return intval($sec / 60) . " minutes ago"; # } # else if($sec < 24*60*60) { /* if less than a day, return hours */ # return intval($sec / 60 / 60) . " hours ago"; # } # else { /* else returns days */ # return intval($sec / 60 / 60 / 24) . " days ago"; # } } i add some comments to the code so you can understend better. the whole code is a part from a class... Thanks in advance!
  18. $test_ar = array('a','b','c','d','e'); for($i=1;$i<=10;$i++){ $output = $i; foreach($test_ar as $count){ $output .= " $count-"; } $output .= "<br>"; echo $output; }
  19. i trying to rewrite a whole js file into php code and i have some issues with a few functions Date.prototype.ConvertToUTCDate = function() { var utcDate = new Date(this.getUTCFullYear(), this.getUTCMonth(), this.getUTCDate(), this.getUTCHours() + WinnerConsts.TIME_ZONE, this.getUTCMinutes(), this.getUTCSeconds()); return utcDate; } parseLineDates: function(lgObj) { lgObj.FullDate = parseInner(lgObj.FullDate); lgObj.Day = parseInner(lgObj.Day); lgObj.Time = parseInner(lgObj.Time); function parseInner(d) { d = d.substr(6); d = parseInt(d); d = (new Date(d)).ConvertToUTCDate(); return d; } } function fromUTCArray(A) { var D = new Date; while (A.length < 7) A.push(0); var T = A.splice(3, A.length); D.setUTCFullYear.apply(D, A); D.setUTCHours.apply(D, T); return D; } // ReParsing from Json Cloning. function parseLineDates(lgObj) { lgObj.FullDate = parseInner(lgObj.FullDate); lgObj.Day = parseInner(lgObj.Day); lgObj.Time = parseInner(lgObj.Time); function parseInner(d) { //return new Date(Date.parse(d)); return parseTest(d); } } function parseTest(s) { var D, M = [], hm, min = 0, d2, Rx = /([\d:]+)(\.\d+)?(Z|(([+\-])(\d\d)\d\d))?)?$/; D = s.substring(0, 10).split('-'); if (s.length > 11) { M = s.substring(11).match(Rx) || []; if (M[1]) D = D.concat(M[1].split(':')); if (M[2]) D.push(Math.round(M[2] * 1000)); // msec } for (var i = 0, L = D.length; i < L; i++) { D[i] = parseInt(D[i], 10); } D[1] -= 1; while (D.length < 6) D.push(0); if (M[4]) { min = parseInt(M[6]) * 60 + parseInt(M[7], 10); // timezone not UTC if (M[5] == '+') min *= -1; } try { d2 = fromUTCArray(D); if (min) d2.setUTCMinutes(d2.getUTCMinutes() + min); } catch (er) { // bad input } return d2; } i dont have any idea how to convert this into PHP and would like to get some help... Thank in advanced and sorry for poor english...
  20. as i said, it's my first time dealing with regex... it's works great! thank alot!
  21. thanks for your replay... it's not working at all :|
  22. hey, im trying to recognize an email address in a text paragraph, for example: and replace it to: it's my first time dealing with regex and so far i reached this: $text = "1111111 <br/> 123emailaddress123@gmail.com <br/> 22222"; $post_eregi = '/(.)([^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4})(.)/'; echo preg_replace($post_eregi, "<a href='mailto:$2'>$2</a>", $text); unfortunately it doesnt work but if i remove the breakline tag before the email address it's works grate! any suggestions or ideas what wrong? thanks in advance!
×
×
  • 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.