ghurty
-
Posts
149 -
Joined
-
Last visited
Posts posted by ghurty
-
-
How would I right it to check to see if there is a current directory "$directory" is in a particular path /temp/
and if it isn't, create it with permissions that other php scripts can write to it?
Thanks
-
The problem starts when it moves over to the next time frame.
-
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
-
I tried that, and I it allowed that the first file it generated was based on the time I passed. But every other file it created was based on current time.
Thanks
-
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);
-
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;
-
I noticed that I left out some "$" by the "spread" a few times, but in my script I have them
-
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;
-
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
-
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
-
I will try to use oni-kun's example, but is there a better way?
Thanks
-
I just need the value that is in the "name" field.
How would I rewrite it to get that value?
Thanks
-
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
-
Oh I get it.
Thank you.
I worded it differently I it works now.
$query = "SELECT * FROM `list` WHERE `userid` = " . $USERID . " AND `group` = " . $GROUP;
Thanks
-
So why is the second version working?
Thanks
-
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
-
I am providing someone with some php code that I wrote, and I dont want them modifcations on it without having to come back to me.
They would want to modify the image variables.
So I want to use php (not js) code to make sure it stays the same, and I would obfuscate that code.
Thakns
-
I have the following html part of my code: <img src="images/top01.jpg" height="162" width="800">
I would like to write a little PHP code to place somewhere else in the script that if any of the info is changed in that line, it will display an error on the page and halt it from loading.
How would the code go.
Thanks
-
I tried:
<? echo "<img src="images/top01.jpg" height="345" width="800">";
?>
But that doesnt seem to work.
Thanks
-
Can you elaborate a little or give me a small example. Thanks
-
Is there any way to encrypt html part of a php file?
The software on encrypts the php part.
Thank You
-
I have the files stored in a path not part of the website:
The PHP file is in : /var/www/html
The orig folder is in:/orig/
The destination folder is in: /var/spool/test
So I have it:
$origdirectory='/orig/' . date('mdy').'/';
$destdirectory='/var/spool/test';
I run it, and the files dont go anywhere.
Thanks
-
I figured it out.
Once you had it with a "t":
$destdirectory='process/';
The other time without a "t":
rename($origdirectory.$file,$desdirectory.$file);
I fixed it and it worked, Thanks
-
I am trying your script:
In the root I have the php file.
It is copying the file out, but instead of to the process folder, it is copying into the root directory (the same directory that I have the php file in).
$destdirectory='process/';
Thank You
What would the proper way of writing: $tofile = "/dialer/$calldate/"
in PHP Coding Help
Posted
What would the proper way of writing:
$tofile = "/dialer/$calldate/"
So that you can use the variable in the path?