Jump to content

ghurty

Members
  • Posts

    149
  • Joined

  • Last visited

Posts posted by ghurty

  1. I have narrowed it down to

    $thisminute = date("i") ;
    $calltime = date("Hi",mktime(date("H"),$thisminute+2,0,date("m"),date("d"),date("Y"))) ;
    $mincounter = 2 ;
    echo "";

     

    and

     

    if ($loopcounter == $maxlines) :
    $thisminute2 = date("i") ;
    if ($thisminute <> $thisminute2) :
      $mincounter = $mincounter + $callspread - 1 ;
    else :
      $mincounter = $mincounter + $callspread ;
    endif ;
    $calltime = date("Hi",mktime(date("H"),$thisminute2+$mincounter,0,date("m"),date("d"),date("Y"))) ;
    $thisminute = $thisminute2 ;
    $loopcounter = 1 ;
    else :
    $loopcounter = $loopcounter + 1 ;
    endif ;
    }
    mysql_close($link);

     

     

    The first one I was able to change by making

    $TIME= $_SERVER["argv"][4]; 
    $TIME= trim($TIME); 
    $TIME= ltrim($TIME);
    
    $calltime = $TIME

     

    Which worked for the first file generated, but how would I change it for the other files generated?

     

     

    Thanks

  2. As of now, this script works based on the current time. And makes multiple files per time period(based on $maxlines), after exhausting the amount allowed for that ime frame it moves over $callspread time to start again.  I am trying to modify it to work based on a time passed onto it as  $timetostart.

     

    What would I change to get it to work (Besides changing to $calltime = $timetostart) . Thanks

     

     

    $thisminute = date("i") ;
    $calltime = date("Hi",mktime(date("H"),$thisminute+2,0,date("m"),date("d"),date("Y"))) ;
    $mincounter = 2 ;
    
    $thisfile = $calltime . $loopcounter .  ".txt" ;
    
    fwrite($fptmp,$txt2write) ;
    $txt2write = "test: ". $test. "\n" ;
    
    fclose($fptmp) ;
    
    
    $tz = getdate();
    $tz['hours']   = substr( $calltime, 0, 2 );
    $tz['minutes'] = substr( $calltime, 2, 2 );
    $time_now = time( );
    $time2call = mktime( substr( $calltime, 0, 2 ), substr( $calltime, 2, 2 ), 0, $tz[mon], $tz[mday], $tz[year] );
    if ( $time2call <= $time_now )
    $time2call += 86400; 
    
    if ($loopcounter == $maxlines) :
    $thisminute2 = date("i") ;
    if ($thisminute <> $thisminute2) :
      $mincounter = $mincounter + $callspread - 1 ;
    else :
      $mincounter = $mincounter + $callspread ;
    endif ;
    $calltime = date("Hi",mktime(date("H"),$thisminute2+$mincounter,0,date("m"),date("d"),date("Y"))) ;
    $thisminute = $thisminute2 ;
    $loopcounter = 1 ;
    else :
    $loopcounter = $loopcounter + 1 ;
    endif ;
    }
    mysql_close($link);

  3. Here it is with the corrections:

     

    $spread=1 ;
    $thisminute = date("i") ;
    $calltime = date("Hi",mktime(date("H"),$thisminute+2,0,date("m"),date("d"),date("Y"))) ;
    $mincounter = 2 ;
    
    
    $loopcounter = 1 ;
    while ($row = mysql_fetch_array($result)) {
      $id =  $row["id"] ;
      
    
    
    $thisfile = $calltime . $loopcounter .  ".txt" ;
    $fromfile = "/tmp/" . $thisfile ;
    $tofile = "/tmp2/" . $thisfile ;
    $fptmp = fopen($fromfile, "w");
    
    
    fclose($fptmp) ;
    
    $tz = getdate();
    $tz['hours']   = substr( $calltime, 0, 2 );
    $tz['minutes'] = substr( $calltime, 2, 2 );
    $time_now = time( );
    $time2call = mktime( substr( $calltime, 0, 2 ), substr( $calltime, 2, 2 ), 0, $tz[mon], $tz[mday], $tz[year] );
    if ( $time2call <= $time_now )
    $time2call += 86400; 
    
    //touch($fromfile, $time2call, $time2call);
    touch($fromfile, $time2call);
    
    $copyok = copy($fromfile,"/tmp/tmp.txt") ;
    $moveok = rename($fromfile,$tofile);
    
    
    
    // fixed: if curr minute does not equal last minute calc then subtract one from calculation below
    
    if ($loopcounter == $maxlines) :
    $thisminute2 = date("i") ;
    if ($thisminute <> $thisminute2) :
      $mincounter = $mincounter + $spread - 1 ;
    else :
      $mincounter = $mincounter + $spread ;
    endif ;
    $calltime = date("Hi",mktime(date("H"),$thisminute2+$mincounter,0,date("m"),date("d"),date("Y"))) ;
    $thisminute = $thisminute2 ;
    $loopcounter = 1 ;
    else :
    $loopcounter = $loopcounter + 1 ;
    endif ;
    }
    mysql_close($link);
    
    
    
    
    // clean up file handlers etc.  
    fclose($stdin);  
    fclose($stdout);
    fclose($stdlog);  
    exit;

  4. I currently have this script that builds file names based on current time plus 2 ($spread variable) minutes. It continues to create files until it finishes the sql table. it creates numerous files per time frame based on how that the $maxlines variable is set to.

     

    How would I modify it so that I can pass on the variable $starttime and it will start generating based on that start time rather then the current time. I tried getting rid of lines 2,3,4 and replacing it will $calltime equals the time that is passed to the script, however that only worked for the first file it generated, and not for the other ones.

     

    Thanks

     

    $spread=1 ;
    $thisminute = date("i") ;
    $calltime = date("Hi",mktime(date("H"),$thisminute+2,0,date("m"),date("d"),date("Y"))) ;
    $mincounter = 2 ;
    
    
    $loopcounter = 1 ;
    while ($row = mysql_fetch_array($result)) {
      $id =  $row["id"] ;
      
    
    
    $thisfile = $calltime . $loopcounter .  ".txt" ;
    $fromfile = "/tmp/" . $thisfile ;
    $tofile = "/tmp2/" . $thisfile ;
    $fptmp = fopen($fromfile, "w");
    
    
    fclose($fptmp) ;
    
    $tz = getdate();
    $tz['hours']   = substr( $calltime, 0, 2 );
    $tz['minutes'] = substr( $calltime, 2, 2 );
    $time_now = time( );
    $time2call = mktime( substr( $calltime, 0, 2 ), substr( $calltime, 2, 2 ), 0, $tz[mon], $tz[mday], $tz[year] );
    if ( $time2call <= $time_now )
    $time2call += 86400; 
    
    //touch($fromfile, $time2call, $time2call);
    touch($fromfile, $time2call);
    
    $copyok = copy($fromfile,"/tmp/tmp.txt") ;
    $moveok = rename($fromfile,$tofile);
    
    
    
    // fixed: if curr minute does not equal last minute calc then subtract one from calculation below
    
    if ($loopcounter == $maxlines) :
    $thisminute2 = date("i") ;
    if ($thisminute <> $thisminute2) :
      $mincounter = $mincounter + spread - 1 ;
    else :
      $mincounter = $mincounter + spread ;
    endif ;
    $calltime = date("Hi",mktime(date("H"),$thisminute2+$mincounter,0,date("m"),date("d"),date("Y"))) ;
    $thisminute = $thisminute2 ;
    $loopcounter = 1 ;
    else :
    $loopcounter = $loopcounter + 1 ;
    endif ;
    }
    mysql_close($link);
    
    
    
    
    // clean up file handlers etc.  
    fclose($stdin);  
    fclose($stdout);
    fclose($stdlog);  
    exit;

  5. How would I go about this project of mine:

     

    Imagine if you had a building that had a 20 conference rooms. And you had users who would like to schedule time in the conference rooms. The maximum length of time allowed in a conference room is 5 minutes.

    So the user would browse to see when the room is available. They have 35 people that they want to put in the conference room. So they just an available time (3 PM). 20 of their people are in there between 3 to 3:05 when they are using all the available conference rooms. Then they have 15 people in between 3:05 and 3:10. This allows on 5 rooms available for a different user to use it with their people.

     

    Each individual user does not see who else is using it, rather just if it available or not. When the first user selected 3 PM. The system should give him an estimate that he will be done by 3:10. If a different user with 35 tried making an appointment for 3:05, it would realize that there are 5 slots available for 3:05, 20 for 3:10 and 20 for 3:15. So it would user 5 at 3:05, 20 at 3:10 and 10 at 3:15. So it would give an estimate of done by 3:20.

     

    Each user would not see the exact amount of slots available, just that there is availability at that time. As long as there is one slot available at that time, it would show availability. Just the length of time until completion would be longer.

     

    The user just chooses a starting time, and the system will book all the slots necessary.

     

     

     

    Any ideas of what would the best way to structure the script and the table.

     

     

    Thanks

  6. When I have the code like:

    $queryid = "SELECT `name` FROM `users` WHERE `group` = " . $GROUP;
    $resultid = mysql_query($queryid) or die("Web site query failed");
    $row = mysql_fetch_assoc($resultid);
    if ($debug) :
    fputs($stdlog, "Name has been set to={$row[`name`]}\n" ); 
    }

    It locks up and doesnt process it. It appears the problem is this line:

    fputs($stdlog, "Name has been set to={$row[`name`]}\n" ); 

    Because when I remove it, it does complete the script.

     

    When I have:

    fputs($stdlog, "Name has been set to= $row\n" ); 

     

    It displays:

    Name has been set to=Array

     

     

    Thank You

  7. I am trying to have a sql command pull up the "name" value for a "group" number of the same record. I have a table has both fields.

     

    $queryid = "SELECT 'name'  FROM `users` WHERE `group` = " . $GROUP;
    $resultid = mysql_query($queryid)
        or die("Web site query failed");
    
    if ($debug) :
    fputs($stdlog, "Name has been set to=". $resultid. "\n" ); 
    endif ;
    

     

    For some reason the debug is showing that it has been set to "resource #10".

     

    What should I change?

     

    Thank You

  8. Why is this query select not working.

    When I have this one, it is always writing a value of 1 to the tmp variable:

    $GROUP = $_SERVER["argv"][1]; 
    $GROUP = trim($GROUP); 
    $GROUP = ltrim($GROUP); 
    
    $USERID = $_SERVER["argv"][2]; 
    $USERID = trim($USERID); 
    $USERID = ltrim($USERID); 
    
    
    $link = mysql_connect("localhost", "root", "passw0rd")
        or die("Data base connection failed");
    mysql_select_db("dialer")
        or die("data base open failed");
    
    $query = "SELECT *  FROM `list` WHERE ( userid = '$USERID' AND group = '$GROUP' )";
    $result = mysql_query($query)
        or die("Web site query failed");
    
    
    $reccount = mysql_num_rows($result) ;
    
    write("SET VARIABLE tmp $reccount");
    

    However, if I set it like this, then it counts the amount of rows properly:

    $query = "SELECT *  FROM `list` WHERE `group` = " . $GROUP;

     

    The problem is that I want a count of the amount of records that have the both, the group# as well as userid#.

     

    Looking at the debug, I see the values for $GROUP and $USERID are passed onto the script.

     

    Thank You

×
×
  • 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.