} if (isset($_POST[$dateOption . $dmy[1]])) { $mm = $_POST[$dateOption . $dmy[1]]; } else { $mm = 1; } if (isset($_POST[$dateOption . $dmy[2]])) { $yyyy = $_POST[$dateOption . $dmy[2]]; } else { $yyyy = date('Y', time()); } //echo $dd . "/" . $mm . "/" . $yyyy; $timestamp = mktime(0, 0, 0, $mm, $dd, $yyyy); //echo date('r', $timestamp); // Check if the options exists, then if the value compares otherwise update it. if (Options::exists($dateOption)) { // Compare the posted value to the value in the DB and update it if neccesarry if (htmlspecialchars(Options::get($dateOption)) !== htmlspecialchars($timestamp)) { // Set the option to the new value Options::set($dateOption, $timestamp); $changes = true; } } } if (isset($_POST['action']) && $_POST['action'] == 'update') { Options::set($_POST['option'], Options::get($_POST['option']), $_POST['type'], $_POST['group']); $changes = true; } if (isset($_POST['action']) && $_POST['action'] == 'add') { Options::set($_POST['option_name'], $_POST['option_value'], $_POST['type'], $_POST['group']); $changes = true;
public static function add($option, $value = '', $type = false, $group = false) { $db = Database::getDatabase(); /*if ($value == '') $value = Options::value($option);*/ if ($type == false) { $type = Options::type($option); } if ($group == false) { $group = Options::group($option); } if (Options::exists($option)) { $db->query('UPDATE options SET `value`=:value:, `type`=:type:, `group`=:group: WHERE `key`=:key:', array('key' => $option, 'value' => $value, 'type' => $type, 'group' => $group)); /*echo "Update option";*/ } else { $db->query('INSERT INTO options (`key`, `value`, `type`, `group`) VALUES (:key:, :value:, :type:, :group:)', array('key' => $option, 'value' => $value, 'type' => $type, 'group' => $group)); /*echo "Inserted new option";*/ } return $db->affectedRows(); }