php-general Digest 19 Sep 2010 05:05:21 -0000 Issue 6948

Topics (messages 308185 through 308188):

Re: 1984 (Big Brother)
        308185 by: chris h

Re: How to store data that doesn't change?
        308186 by: chris h
        308187 by: Ashley Sheridan
        308188 by: chris h

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
So whenever the boss is in a meeting and his screen saver kicks on then the
business shuts down.  Also I think we've established that thumbdrive +
database = disaster.

Maybe a thumbdrive that has file with some random hash.  Then create a cron
that checks for the existence of that file each minute.  When the boss
leaves the cron doesn't find the file and shuts down the DB, when the boss
comes in the cron will see it and starts it up.

But Tedd, I'm still thinking that a "dead man's switch" is the way to go.
 :)

Chris.

On Sat, Sep 18, 2010 at 8:03 AM, TR Shaw <[email protected]> wrote:

> If you mean "not logoff properly" as, for instance, getting up and leaving
> his office for the day without logging off you can run a script when the
> machine "sleeps" or the screen saver runs and runs again when the machine
> transitions back to run.
>
> If your talking about powering off, same scripting approach as above (or
> just put DB on Boss' machine and if its off or crashes access ceases.
>
> As a crazy approach, put the DB on a thumb drive and attach the thumb to
> the Boss' car or house keys. He plugs the thumb in when he wants to "grant"
> access and takes it when he leaves because he need his keys.
>
> On Sep 17, 2010, at 11:44 PM, viraj wrote:
>
> >>
> >> Remind him that he must logout normally to lock the DB
> >
> > if you follow the thread closely, this is a requirement. boss may not
> > logout properly :)
> >
> > that's why all suggest a mechanical ways for the job. pressure
> > sensors, cameras etc etc
> >
> > ~viraj
> >
> >>
> >>
> >>
> >> On Sep 12, 2010, at 12:37 PM, Joshua Kehn wrote:
> >>
> >>> Tedd-
> >>>
> >>> Would he consider access to another database? I.e. a separate, say
> memcached db which stores the "boss" status?
> >>>
> >>> An issue with the temporary file would also be session length, if the
> session expires without the user explicitly logging off, the file wouldn't
> be removed. A way to bypass this would be to add some sort of session
> expiration header to the file and update that.
> >>>
> >>> And couldn't you make a simple check if the boss is logged in or not by
> the ability to access the database?
> >>>
> >>> Regards,
> >>>
> >>> -Josh
> >>> ____________________________________
> >>> Joshua Kehn | [email protected]
> >>> http://joshuakehn.com
> >>>
> >>> On Sep 12, 2010, at 12:32 PM, tedd wrote:
> >>>
> >>>> Hi gang:
> >>>>
> >>>> I have a client who wants his employees' access to their online
> business database restricted to only times when he is logged on. (Don't ask
> why)
> >>>>
> >>>> In other words, when the boss is not logged on, then his employees
> cannot access the business database in any fashion whatsoever including
> checking to see if the boss is logged on, or not. No access whatsoever!
> >>>>
> >>>> Normally, I would just set up a field in the database and have that
> set to "yes" or "no" as to if the employees could access the database, or
> not. But in this case, the boss does not want even that type of access to
> the database permitted. Repeat -- No access whatsoever!
> >>>>
> >>>> I was thinking of the boss' script writing to a file that accomplished
> the "yes" or "no" thing, but if the boss did not log off properly then the
> file would remain in the "yes" state allowing employees undesired access.
> That would not be acceptable.
> >>>>
> >>>> So, what methods would you suggest?
> >>>>
> >>>> Cheers,
> >>>>
> >>>> tedd
> >>>>
> >>>> --
> >>>> -------
> >>>> http://sperling.com/
> >>>>
> >>>> --
> >>>> PHP General Mailing List (http://www.php.net/)
> >>>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>>
> >>>
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
When you really NEED a global resource I'm a fan of a registry class.  It's
a little slower but not noticeable in most cases.

With a registry you can store all global data in a single, controlled area.
 You can also store arrays and resources instead of just strings.  One down
side to most registry classes is that it's not truly "constant" data, but
with magic methods you can correct that.


In this class you can store values globally, and once they are set they
can't be easily changed.

myRegistry::get()->test = array('abc','xyz');
myRegistry::get()->test = 1234;

echo myRegistry::get()->test[1];  // should echo 'xyz'


I just typed this up real quick so there may be errors; but if you want to
try it, it should at least give you the just of it.
-------------untested code----------------
class myRegistry {

private $_Data = array();

static private $_Object = null;


static public function get () {

  if( !( self::$_Object instanceof self ))
    self::$_Object = new self();

  return self::$_Object;

}


private function __construct () { }


public function __get ($name) {

  if (isset( $this->_Data[$name] ))
    return $this->_Data[$name];

  return null;

}


public function __set ($name, $value) {

  if (isset( $this->_Data[$name] ))
    return false;

  return $this->_Data[$name] = $value;

}

}
------------------

On Thu, Sep 16, 2010 at 10:50 AM, tedd <[email protected]> wrote:

> At 8:46 AM -0400 9/15/10, Peter van der Does wrote:
>
>> Hi,
>>
>> How do you people store data that doesn't change, an example of this
>> would be the version number of your software. You might want to use it
>> through out your program but how to you store it?
>>
>> As far as I can see there are several options to use this data.
>> 1. Global Variable
>> 2. Store it in a registry class
>> 3. Store it in a named constant.
>> 4. Use a function that will return the data (kind of like a regsitry
>> class but it's not a class)
>>
>> Personally I don't like option 1 but what about the other options. Is
>> any of them faster then the others. What other pros and cons are there.
>>
>
> Make it's a Constant -- it's simply a Global that doesn't change.
>
> I typically hold such things in a global configuration file that can be
> included when needed.
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Sat, 2010-09-18 at 12:21 -0400, chris h wrote:

> When you really NEED a global resource I'm a fan of a registry class.  It's
> a little slower but not noticeable in most cases.
> 
> With a registry you can store all global data in a single, controlled area.
>  You can also store arrays and resources instead of just strings.  One down
> side to most registry classes is that it's not truly "constant" data, but
> with magic methods you can correct that.
> 
> 
> In this class you can store values globally, and once they are set they
> can't be easily changed.
> 
> myRegistry::get()->test = array('abc','xyz');
> myRegistry::get()->test = 1234;
> 
> echo myRegistry::get()->test[1];  // should echo 'xyz'
> 
> 
> I just typed this up real quick so there may be errors; but if you want to
> try it, it should at least give you the just of it.
> -------------untested code----------------
> class myRegistry {
> 
> private $_Data = array();
> 
> static private $_Object = null;
> 
> 
> static public function get () {
> 
>   if( !( self::$_Object instanceof self ))
>     self::$_Object = new self();
> 
>   return self::$_Object;
> 
> }
> 
> 
> private function __construct () { }
> 
> 
> public function __get ($name) {
> 
>   if (isset( $this->_Data[$name] ))
>     return $this->_Data[$name];
> 
>   return null;
> 
> }
> 
> 
> public function __set ($name, $value) {
> 
>   if (isset( $this->_Data[$name] ))
>     return false;
> 
>   return $this->_Data[$name] = $value;
> 
> }
> 
> }
> ------------------
> 
> On Thu, Sep 16, 2010 at 10:50 AM, tedd <[email protected]> wrote:
> 
> > At 8:46 AM -0400 9/15/10, Peter van der Does wrote:
> >
> >> Hi,
> >>
> >> How do you people store data that doesn't change, an example of this
> >> would be the version number of your software. You might want to use it
> >> through out your program but how to you store it?
> >>
> >> As far as I can see there are several options to use this data.
> >> 1. Global Variable
> >> 2. Store it in a registry class
> >> 3. Store it in a named constant.
> >> 4. Use a function that will return the data (kind of like a regsitry
> >> class but it's not a class)
> >>
> >> Personally I don't like option 1 but what about the other options. Is
> >> any of them faster then the others. What other pros and cons are there.
> >>
> >
> > Make it's a Constant -- it's simply a Global that doesn't change.
> >
> > I typically hold such things in a global configuration file that can be
> > included when needed.
> >
> > Cheers,
> >
> > tedd
> >
> > --
> > -------
> > http://sperling.com/
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >



You might want to add in some error returns from the setters instead of
just false, as attempting to overwrite a real constant would issue a
notice.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Sat, Sep 18, 2010 at 12:37 PM, Ashley Sheridan
<[email protected]>wrote:

>  On Sat, 2010-09-18 at 12:21 -0400, chris h wrote:
>
> When you really NEED a global resource I'm a fan of a registry class.  It's
> a little slower but not noticeable in most cases.
>
> With a registry you can store all global data in a single, controlled area.
>  You can also store arrays and resources instead of just strings.  One down
> side to most registry classes is that it's not truly "constant" data, but
> with magic methods you can correct that.
>
>
> In this class you can store values globally, and once they are set they
> can't be easily changed.
>
> myRegistry::get()->test = array('abc','xyz');
> myRegistry::get()->test = 1234;
>
> echo myRegistry::get()->test[1];  // should echo 'xyz'
>
>
> I just typed this up real quick so there may be errors; but if you want to
> try it, it should at least give you the just of it.
> -------------untested code----------------
> class myRegistry {
>
> private $_Data = array();
>
> static private $_Object = null;
>
>
> static public function get () {
>
>   if( !( self::$_Object instanceof self ))
>     self::$_Object = new self();
>
>   return self::$_Object;
>
> }
>
>
> private function __construct () { }
>
>
> public function __get ($name) {
>
>   if (isset( $this->_Data[$name] ))
>     return $this->_Data[$name];
>
>   return null;
>
> }
>
>
> public function __set ($name, $value) {
>
>   if (isset( $this->_Data[$name] ))
>     return false;
>
>   return $this->_Data[$name] = $value;
>
> }
>
> }
> ------------------
>
> On Thu, Sep 16, 2010 at 10:50 AM, tedd <[email protected]> wrote:
>
> > At 8:46 AM -0400 9/15/10, Peter van der Does wrote:
> >
> >> Hi,
> >>
> >> How do you people store data that doesn't change, an example of this
> >> would be the version number of your software. You might want to use it
> >> through out your program but how to you store it?
> >>
> >> As far as I can see there are several options to use this data.
> >> 1. Global Variable
> >> 2. Store it in a registry class
> >> 3. Store it in a named constant.
> >> 4. Use a function that will return the data (kind of like a regsitry
> >> class but it's not a class)
> >>
> >> Personally I don't like option 1 but what about the other options. Is
> >> any of them faster then the others. What other pros and cons are there.
> >>
> >
> > Make it's a Constant -- it's simply a Global that doesn't change.
> >
> > I typically hold such things in a global configuration file that can be
> > included when needed.
> >
> > Cheers,
> >
> > tedd
> >
> > --
> > -------
> > http://sperling.com/
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
>
> You might want to add in some error returns from the setters instead of
> just false, as attempting to overwrite a real constant would issue a notice.
>
>
>   Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>

I agree Ash, good idea and thanks for the feedback! :)

--- End Message ---

Reply via email to