Jump to content

AviNahum

Members
  • Posts

    170
  • Joined

  • Last visited

Posts 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. 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! :)

  3. 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.

  4. 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...

  5. 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...


    post-71948-0-69375800-1363704545_thumb.png

  6.  

    What about this? I'm about 90% clear on what you require, so I'm using my judgement.

     

     

    $member_id = intval($this->member['id']);
     
     if($member_id >= 1) {
       $lastTickets    = $this->member['last_tickets'];
       $ticketsPerHour = $INFO['tickets_jump'];
       
       $timeDifference = $_SERVER['REQUEST_TIME'] - $lastTickets;
       $timeHours      = floor($timeDifference/60/60);
       $lastHour       = $lastTickets+($timeHours*60*60);
       
       if($timeHours >= 1) {
         $ticketsToAdd = ($ticketsPerHour*$timeHours);
         
         $query = "UPDATE `users` SET `tickets` = `tickets`+{$ticketsToAdd}, `last_tickets` = {$lastHour} WHERE `id` = {$member_id}";
     
         echo $ticketsToAdd .' - '. $lastHour .'<br>';
         echo $query;
       }     
     }

     

    as i see it now, it works perfectly!

    Thank you!

     

    No one benefits from sarcastic posts, get over it.

     

    The way I look at it, relating it to games:

     

    - One uses a cron job to calculate something that is publicly available. For instance, a score in a leaderboard in a game. Its imporatnt that this is always up to date even if the user itself is no longer online

    - One uses a regular page load /script to calculate stuff that only the user itself sees. For instance, the "resources" I have for a game. I dont care if I have a lot of them, or even a little. As long as the number is correct the moment I log in, I will not see any difference.

     

    In this case, I dont see how a cron job would improve the script.

     

    Thanks for clearing this up to everyone ^^

  7. 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!

  8. 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 **

  9. 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!

  10. 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...

  11. hey,

    im trying to recognize an email address in a text paragraph, for example:

     

    1111111 <br/> 123emailaddress123@gmail.com <br/> 22222

     

    and replace it to:

     

    1111111 <br/> <a href="mailto:123emailaddress123@gmail.com">123emailaddress123@gmail.com</a> <br/> 22222

     

    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.