Yep, I am trying to have a php web page change the linux system
date/time, but obviously running into the snag that /bin/date, while
"chmod 775" doesn't allow a user to set the date/time. Why is that,
given the permissions? Sure it makes sense, but it's annoying. Ideas on
how to circumvent this problem? 

-rwxr-xr-x    1 root     root        26780 Jul 23  2001 /bin/date

Seems to me that anyone should be able to use it then right? Where is
the "write" portion defined? The 'info date' page says, "You must have
appropriate privileges to set the system clock." But it doesn't say what
that is or how to change them.

If anyone cares, here's a nice bit-o-code:

<?php
        if ($year == "") $year = date("Y");
        if ($month == "") $month = date("m");
        if ($day == "") $day = date("d");
        if ($hour == "") $hour = date("h");
        if ($minute == "") $minute = date("i");
        
        $NewDateTime = date ("m/d/Y H:i", mktime
($hour,$minute,0,$month,$day,$year));

        $binDate = date ("mdhiY", mktime
($hour,$minute,0,$month,$day,$year));
        exec("/bin/date ".$binDate); //TODO: um, yeah, how do you expect
this to work? you have to be root to do this!!!!
?>
<CENTER>
<table border=0 class=componentBox>
<TR><TD COLSPAN=8 class=Header>Change Time / Date</TD></TR>
<TR>
<FORM ACTION="<?=$SCRIPT_NAME?>" METHOD="POST">
<TD>
<TABLE BORDER=0>
<TR><TD class=Menu>New Date</TD><TD>
                <select name="month">
        <?php
                for($i = 1; $i <= 12; $i++)
                {
                        echo "<option";
                                if ($month == $i) echo " SELECTED";
                        printf(">%02d\n",$i);
                }
        ?>
        </select> / 
        <select name="day">
        <?php
                for($i = 1; $i <= 31; $i++)
                {
                        echo "<option";
                                if ($day == $i) echo " SELECTED";
                        printf(">%02d\n",$i);
                }
        ?>
        </select> / 
        <select name="year">
                <option <?php if ($year == "2003") echo " SELECTED";
?>>2003
                <option <?php if ($year == "2004") echo " SELECTED";
?>>2004
                <option <?php if ($year == "2005") echo " SELECTED";
?>>2005
                <option <?php if ($year == "2006") echo " SELECTED";
?>>2006
        </select>
</TR>
<TR><TD class=Menu>New Time</TD><TD>
        <select name="hour">
        <?php
                for($i = 0; $i <= 23; $i++)
                {
                        echo "<option";
                                if ($hour == $i) echo " SELECTED";
                        printf(">%02d\n",$i);
                }
        ?>
        </select> : 
        <select name="minute">
        <?php
                for($i = 0; $i <= 59; $i++)
                {
                        echo "<option";
                                if ($minute == $i) echo " SELECTED";
                        printf(">%02d\n",$i);
                }
        ?>
        </select>
</TR>


<TR><TD COLSPAN=2 ALIGN=RIGHT>
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Set Time / Date" class=button>
</TD></FORM></TR>
</TABLE>
</TD></TR></TABLE><p>


<?php
        if (!checkdate($month,$day,$year)) print "\n<P><B>You entered an
invalid date, so it was converted to ".$NewDateTime."</B><P>\n";
?>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to