Advertisement
Guest User

Untitled

a guest
Feb 20th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1.     function __construct($options = null) {
  2.         if ($options == null) $this->data = isset($_POST['options']) ? stripslashes_deep($_POST['options']) : null;
  3.         else $this->data = $options;
  4.  
  5.         $this->action = isset($_REQUEST['act']) ? $_REQUEST['act'] : null;
  6.  
  7.         if (isset($_REQUEST['btn'])) $this->button_data = $_REQUEST['btn'];
  8.  
  9.         // Fields analysis
  10.         $fields = isset($_REQUEST['fields']) ? $_REQUEST['fields'] : null;
  11.         if (is_array($fields)) {
  12.             foreach ($fields as $name=>$type) {
  13.                 if ($type == 'datetime') {
  14.                     // Ex. The user insert 01/07/2012 14:30 and it set the time zone to +2. We cannot use the
  15.                     // mktime, since it uses the time zone of the machine. We create the time as if we are on
  16.                     // GMT 0 and then we subtract the GMT offset (the example date and time on GMT+2 happens
  17.                     // "before").
  18.  
  19.                     $time = gmmktime($_REQUEST[$name . '_hour'], 0, 0,
  20.                             $_REQUEST[$name . '_month'], $_REQUEST[$name . '_day'], $_REQUEST[$name . '_year']);
  21.                     $time -= get_option('gmt_offset') * 3600;
  22.                     $this->data[$name] = $time;
  23.                 }
  24.             }
  25.         }
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement