function handleEditPage() { include_once 'login.php'; include_once 'showEventFunction.php'; $backURL = "<br/><a href = \"index.php\">Back to Home</a>"; // client side validation, if error, disable submit // if form is set and not empty, continue $showError = true; $errOutput = isFormFilled($showError); if ($errOutput) { $output = "<h1>Error</h1>"; return $output . $errOutput . $backURL; } $event = array(); $errMsg = array(); // prevent sql injection & data sanitize foreach ($_POST as $field => $value) { $event[$field] = sanitizeData($value); } include_once 'database_conn.php'; $columnLengthSql = "\n\t\tSELECT COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH\n\t\tFROM INFORMATION_SCHEMA.COLUMNS\n\t\tWHERE TABLE_NAME = 'te_events'\n\t\tAND (column_name = 'eventTitle'\n\t\tOR column_name = 'eventDescription')"; //, DATA_TYPE $COLUMN_LENGTH = getColumnLength($conn, $columnLengthSql); // check data type and length validation $isError = false; $errMsg[] = validateStringLength($event['title'], $COLUMN_LENGTH['eventTitle']); //title $errMsg[] = validateStringLength($event['desc'], $COLUMN_LENGTH['eventDescription']); //desc $errMsg[] = validateDate($event['startTime']); //startTime $errMsg[] = validateDate($event['endTime']); //endTime $errMsg[] = validateDecimal($event['price']); //price for ($i = 0; $i < count($errMsg); $i++) { if (!($errMsg[$i] === true)) { $pageHeader = "Error"; $output = "<h1>{$pageHeader}</h1>"; $output . "{$errMsg[$i]}"; $isError = true; } } //if contain error, halt continue executing the code if ($isError) { return $output . $backURL; } // prepare sql statement $sql = "UPDATE te_events SET \n\t\teventTitle=?, eventDescription=?, \n\t\tvenueID=?, catID=?, eventStartDate=?, \n\t\teventEndDate=?, eventPrice=? WHERE eventID=?;"; $stmt = mysqli_prepare($conn, $sql); mysqli_stmt_bind_param($stmt, "ssssssss", $event['title'], $event['desc'], $event['venue'], $event['category'], $event['startTime'], $event['endTime'], $event['price'], $event['e_id']); // execute update statement mysqli_stmt_execute($stmt); // check is it sucess update if (mysqli_stmt_affected_rows($stmt)) { $output = "<h1>{$event['title']} was successfully updated.</h1>"; return $output . $backURL; } else { $output = "<h1>Nothing update for {$event['title']}</h1>"; return $output . $backURL; } echo "<br/>"; return; }
function validateForm(&$errors) { global $firstname, $surname, $birthdate; ## firstname ## if (!validateRequired($firstname)) { $errors['firstname'][] = 'First name is required.'; } else { if (!validateLength($firstname, 2)) { $errors['firstname'][] = 'Minimum length is 2.'; } } ## surname ## if (!validateRequired($surname)) { $errors['surname'][] = 'Surname is required.'; } else { if (!validateLength($surname, 2)) { $errors['surname'][] = 'Minimum length is 2.'; } } ## date ## if (!validateRequired($birthdate)) { $errors['birthdate'][] = 'Date of Birth is required.'; } else { if (!validateDate($birthdate)) { $errors['birthdate'][] = 'Wrong date.'; } } ## return ## return empty($errors) ? true : false; }
function validateData() { $required = $_GET["required"]; $type = $_GET["type"]; $value = $_GET["value"]; validateRequired($required, $value, $type); switch ($type) { case 'number': validateNumber($value); break; case 'alphanum': validateAlphanum($value); break; case 'alpha': validateAlpha($value); break; case 'date': validateDate($value); break; case 'email': validateEmail($value); break; case 'url': validateUrl($value); case 'all': validateAll($value); break; } }
function setDatabase() { if (isset($_POST['submit'])) { if (isset($_POST['inputNaam']) && isset($_POST['inputBeschrijving']) && isset($_POST['inputDatum']) && isset($_POST['inputPrioriteit']) && isset($_POST['inputTijd'])) { // CONNECT TO DATABASE try { require 'app/config/db_connect.php'; // FILE OM MET DATABASE TE CONNECTEN // ZET DE INPUT IN DE VARIABELEN if (validateDate($_POST['inputDatum'], 'Y-m-d')) { if (preg_match("/(2[0-4]|[01][1-9]|10):([0-5][0-9])/", $_POST['inputTijd'])) { $naam = $_POST['inputNaam']; $beschrijving = $_POST['inputBeschrijving']; $datum = $_POST['inputDatum']; $tijd = $_POST['inputTijd']; $prioriteit = $_POST['inputPrioriteit']; // ZET DE INGEVOERDE INFORMATIE IN DE DATABASE $insert = 'INSERT INTO content (naam, beschrijving, datum, tijd, prioriteit, email) VALUES("' . $naam . '", "' . $beschrijving . '", "' . $datum . '","' . $tijd . '", "' . $prioriteit . '" , "' . $_SESSION['email'] . '")'; $conn->exec($insert); } else { echo 'de tijd is niet correct ingevuld'; } } else { echo 'de datum is niet correct inguvuld'; } // CHECK OF DE DATA IN DE DATABASE IS GEZET } catch (PDOException $e) { echo $insert . "<br>" . $e->getMessage(); } $conn = null; } else { echo 'Je hebt niet al de velden ingevuld'; } } }
function mysql_date_format($date, $time = false) { if (empty($date) || !validateDate($date, 'm-d-Y')) { return ''; } if ($time) { return date('Y-m-d H:i:s', strtotime(str_replace('-', '/', $date))); } else { return date('Y-m-d', strtotime(str_replace('-', '/', $date))); } }
public function postHydrate($post_params, $customMap = false) { $reflect = new \ReflectionObject($this); foreach ($post_params as $key => $value) { if (property_exists($this, $key)) { $prop = $reflect->getProperty($key); if (!$prop->isPrivate()) { if (validateDate($value, 'd-m-Y') || validateDate($value, 'd-m-Y H:i:s') || validateDate($value, 'Y-m-d H:i:s') || validateDate($value, 'd-m-Y H:i') || validateDate($value, 'd.m.Y H:i')) { $value = new \DateTime($value); } $this->{$key} = $value; } } if ($customMap) { foreach ($customMap as $key => $prop) { $this->{$prop} = $post_params[$key]; } } } }
function validateTourdates($form) { global $db; if (checkEmpty($form['venue_name'])) { $msg = str_replace('field', _VENUE, _ALRT_REQUIRED_FIELD); $show_tab_type = 'TOURDATES_INFO'; return $msg; } if (checkEmpty($form['tour_city'])) { $msg = str_replace('field', _CITY, _ALRT_REQUIRED_FIELD); $show_tab_type = 'TOURDATES_INFO'; return $msg; } if (checkEmpty($form['tour_state'])) { $msg = str_replace('field', _LBL_STATE, _ALRT_REQUIRED_FIELD); $show_tab_type = 'TOURDATES_INFO'; return $msg; } if (checkEmpty($form['tour_country'])) { $msg = str_replace('field', _LBL_COUNTRY, _ALRT_REQUIRED_FIELD); $show_tab_type = 'TOURDATES_INFO'; return $msg; } if (checkEmpty($form['tourdate'])) { $msg = str_replace('field', _LBL_START_DATE, _ALRT_REQUIRED_FIELD); $show_tab_type = 'TOURDATES_INFO'; return $msg; } if (checkEmpty($form['tourdate'])) { $msg = _ALRT_SEL_STARTDATE; $show_tab_type = 'TOURDATES_INFO'; return $msg; } else { $showdate = validateDate($form['tourdate']); if ($showdate !== true) { $msg = $showdate . ' ' . _LBL_FOR . ' ' . _LBL_START_DATE; $show_tab_type = 'TOURDATES_INFO'; return $msg; } if (compareDate($form['tourdate'], date('m/d/Y'), 1)) { $msg = _ALRT_VALID_TOURDATE; $show_tab_type = 'TOURDATES_INFO'; return $msg; } } $date = getYearMonthDateSearch($form['tourdate'], "/", "-"); if (isset($form['tourdate_id'])) { $sql = 'SELECT AF_TOURDATE_ID FROM xebura_TOURDATE WHERE AF_TOURDATE_ARTIST_ID = \'' . $_SESSION['User_Account_Id'] . '\' AND (AF_TOURDATE_VENUE_ID = \'' . $form['venue'] . '\' OR (AF_TOURDATE_VENUE_NAME = \'' . $form['venue_name'] . '\' AND AF_TOURDATE_VENUE_CITY = \'' . $form['tour_city'] . '\' AND AF_TOURDATE_VENUE_STATE = \'' . $form['tour_state'] . '\' AND AF_TOURDATE_VENUE_COUNTRY = \'' . $form['tour_country'] . '\')) AND AF_TOURDATE_STARTDATE = \'' . $date . '\' AND AF_ARTIST_DISCOG_ID != \'' . $form['tourdate_id'] . '\''; } else { $sql = 'SELECT AF_TOURDATE_ID FROM xebura_TOURDATE WHERE AF_TOURDATE_ARTIST_ID = \'' . $_SESSION['User_Account_Id'] . '\' AND (AF_TOURDATE_VENUE_ID = \'' . $form['venue'] . '\' OR (AF_TOURDATE_VENUE_NAME = \'' . $form['venue_name'] . '\' AND AF_TOURDATE_VENUE_CITY = \'' . $form['tour_city'] . '\' AND AF_TOURDATE_VENUE_STATE = \'' . $form['tour_state'] . '\' AND AF_TOURDATE_VENUE_COUNTRY = \'' . $form['tour_country'] . '\')) AND AF_TOURDATE_STARTDATE = \'' . $date . '\''; } if ($db->query_affected_rows($sql) > 0) { $msg = _CHECK_DUPLICATE_TOURDATE; $show_tab_type = 'TOURDATES_INFO'; return $msg; } return true; }
/** * Mutator method for $answerDate * * @param mixed $newAnswerDate * @throws InvalidArgumentException if $newAnswerDate is not a valid object or string * @throws RangeException if $newAnswerDate is a date that does not exist * @throws Exception for any other exception */ public function setAnswerDate($newAnswerDate) { //base case: if the date is null, use the current date and time if ($newAnswerDate === null) { $this->answerDate = new DateTime(); return; } //store the answer date try { $newAnswerDate = validateDate($newAnswerDate); } catch (InvalidArgumentException $invalidArgument) { throw new InvalidArgumentException($invalidArgument->getMessage(), 0, $invalidArgument); } catch (RangeException $range) { throw new RangeException($range->getMessage(), 0, $range); } catch (Exception $exception) { throw new Exception($exception->getMessage(), 0, $exception); } $this->answerDate = $newAnswerDate; }
function candie_promotion($promotion_id = NULL) { if (!check_correct_login_type($this->main_group_id) && !check_correct_login_type($this->group_id_supervisor)) { redirect('/', 'refresh'); } $message_info = ''; $merchant_id = $this->ion_auth->user()->row()->id; $is_supervisor = 0; //if is login by supervisor then need change some setting if (check_correct_login_type($this->group_id_supervisor)) { $merchant_id = $this->ion_auth->user()->row()->su_merchant_id; $is_supervisor = 1; $supervisor = $this->ion_auth->user()->row(); } $search_month = NULL; $search_year = NULL; $is_history = 0; if ($promotion_id != NULL) { $allowed_list = $this->m_custom->get_list_of_allow_id('advertise', 'merchant_id', $merchant_id, 'advertise_id', 'advertise_type', 'pro'); if (!check_allowed_list($allowed_list, $promotion_id)) { redirect('/', 'refresh'); } //To check if it is history promotion, then disable the Save Button $promotionAdvertise = $this->m_custom->getOneAdvertise($promotion_id); if (!$promotionAdvertise) { $is_history = 1; } else { if ($promotionAdvertise['year'] < get_part_of_date('year') || $promotionAdvertise['year'] == get_part_of_date('year') && $promotionAdvertise['month_id'] < get_part_of_date('month')) { $is_history = 1; $search_month = $promotionAdvertise['month_id']; $search_year = $promotionAdvertise['year']; } } } $do_by_type = $this->main_group_id; $do_by_id = $merchant_id; $merchant_data = $this->m_custom->get_one_table_record('users', 'id', $merchant_id); $candie_branch = $this->m_custom->get_keyarray_list('merchant_branch', 'merchant_id', $merchant_id, 'branch_id', 'name'); $candie_term = $this->m_custom->get_dynamic_option_array('candie_term', NULL, NULL, $merchant_data->company, NULL, 0, 3); $month_list = $this->ion_auth->get_static_option_list('month'); $year_list = generate_number_option(get_part_of_date('year', $merchant_data->created_on, 1), get_part_of_date('year')); if (isset($_POST) && !empty($_POST)) { if ($this->input->post('button_action') == "submit") { $upload_rule = array('upload_path' => $this->album_merchant, 'allowed_types' => $this->config->item('allowed_types_image'), 'max_size' => $this->config->item('max_size'), 'max_width' => $this->config->item('max_width'), 'max_height' => $this->config->item('max_height')); $this->load->library('upload', $upload_rule); $candie_id = $this->input->post('candie_id'); //$sub_category_id = $this->input->post('candie_category'); $sub_category_id = $merchant_data->me_sub_category_id; //merchant cannot change sub category anymore $title = $this->input->post('candie_title'); $description = $this->input->post('candie_desc'); $upload_file = "candie-file"; $start_date = validateDate($this->input->post('start_date')); $end_date = validateDate($this->input->post('end_date')); $search_month = $this->input->post('candie_month'); $search_year = $this->input->post('candie_year'); $candie_point = check_is_positive_numeric($this->input->post('candie_point')); if ($candie_point < 30) { $candie_point = 30; } $expire_date = validateDate($this->input->post('expire_date')); $original_price = check_is_positive_decimal($this->input->post('original_price')); $show_extra_info = $this->input->post('show_extra_info'); $price_before = check_is_positive_decimal($this->input->post('price_before')); $price_after = check_is_positive_decimal($this->input->post('price_after')); //$price_before_show = $this->input->post('price_before_show'); //$price_after_show = $this->input->post('price_after_show'); if ($show_extra_info == 121) { $price_before_show = 1; $price_after_show = 1; } else { $price_before_show = 0; $price_after_show = 0; } $get_off_percent = check_is_positive_decimal($this->input->post('get_off_percent')); $how_many_buy = check_is_positive_numeric($this->input->post('how_many_buy')); $how_many_get = check_is_positive_numeric($this->input->post('how_many_get')); $adv_worth = check_is_positive_decimal($this->input->post('adv_worth')); $candie_extra_term = $this->input->post('candie_extra_term'); $image_data = NULL; $candie_term_selected = array(); $post_candie_term = $this->input->post('candie_term'); if (!empty($post_candie_term)) { foreach ($post_candie_term as $key => $value) { $candie_term_selected[] = $value; } } $candie_branch_selected = array(); $post_candie_branch = $this->input->post('candie_branch'); if (!empty($post_candie_branch)) { foreach ($post_candie_branch as $key => $value) { $candie_branch_selected[] = $value; } } if ($candie_id == 0) { if (!empty($_FILES[$upload_file]['name'])) { if (!$this->upload->do_upload($upload_file)) { $message_info = add_message_info($message_info, $this->upload->display_errors(), $title); } else { $image_data = array('upload_data' => $this->upload->data()); resize_image($this->album_merchant . $image_data['upload_data']['file_name']); } } $data = array('advertise_type' => 'pro', 'merchant_id' => $merchant_id, 'sub_category_id' => $sub_category_id, 'title' => $title, 'description' => $description, 'image' => empty($image_data) ? '' : $image_data['upload_data']['file_name'], 'start_time' => $start_date, 'end_time' => $end_date, 'month_id' => $search_month, 'year' => $search_year, 'voucher_candie' => $candie_point, 'voucher_expire_date' => $expire_date, 'original_price' => $original_price, 'show_extra_info' => $show_extra_info, 'price_before' => $price_before, 'price_after' => $price_after, 'price_before_show' => $price_before_show, 'price_after_show' => $price_after_show, 'get_off_percent' => $get_off_percent, 'how_many_buy' => $how_many_buy, 'how_many_get' => $how_many_get, 'voucher_worth' => $adv_worth, 'extra_term' => $candie_extra_term); $new_id = $this->m_custom->get_id_after_insert('advertise', $data); if ($new_id) { $this->m_custom->insert_row_log('advertise', $new_id, $do_by_id, $do_by_type); $this->m_custom->many_insert_or_remove('candie_term', $new_id, $candie_term_selected); $this->m_custom->many_insert_or_remove('candie_branch', $new_id, $candie_branch_selected); $message_info = add_message_info($message_info, 'Candie Promotion for ' . $search_year . ' ' . $this->m_custom->display_static_option($search_month) . ' success create.'); $candie_id = $new_id; } else { $message_info = add_message_info($message_info, $this->ion_auth->errors()); } } else { $previous_image_name = $this->m_custom->get_one_table_record('advertise', 'advertise_id', $candie_id)->image; //To check old deal got change image or not, if got then upload the new one and delete previous image if (!empty($_FILES[$upload_file]['name'])) { if (!$this->upload->do_upload($upload_file)) { $message_info = add_message_info($message_info, $this->upload->display_errors()); } else { $image_data = array('upload_data' => $this->upload->data()); if (!IsNullOrEmptyString($previous_image_name)) { delete_file($this->album_merchant . $previous_image_name); } resize_image($this->album_merchant . $image_data['upload_data']['file_name']); } } //To update previous food & beverage $data = array('sub_category_id' => $sub_category_id, 'title' => $title, 'description' => $description, 'image' => empty($image_data) ? $previous_image_name : $image_data['upload_data']['file_name'], 'start_time' => $start_date, 'end_time' => $end_date, 'voucher_candie' => $candie_point, 'voucher_expire_date' => $expire_date, 'original_price' => $original_price, 'show_extra_info' => $show_extra_info, 'price_before' => $price_before, 'price_after' => $price_after, 'price_before_show' => $price_before_show, 'price_after_show' => $price_after_show, 'get_off_percent' => $get_off_percent, 'how_many_buy' => $how_many_buy, 'how_many_get' => $how_many_get, 'voucher_worth' => $adv_worth, 'extra_term' => $candie_extra_term); if ($this->m_custom->simple_update('advertise', $data, 'advertise_id', $candie_id)) { $this->m_custom->update_row_log('advertise', $candie_id, $do_by_id, $do_by_type); $this->m_custom->many_insert_or_remove('candie_term', $candie_id, $candie_term_selected); $this->m_custom->many_insert_or_remove('candie_branch', $candie_id, $candie_branch_selected); $message_info = add_message_info($message_info, 'Candie Promotion for ' . $search_year . ' ' . $this->m_custom->display_static_option($search_month) . ' success update.'); } else { $message_info = add_message_info($message_info, $this->ion_auth->errors()); } } $this->session->set_flashdata('message', $message_info); redirect('merchant/candie_promotion/' . $candie_id, 'refresh'); } else { if ($this->input->post('button_action') == "search_voucher") { $search_month = $this->input->post('candie_month'); $search_year = $this->input->post('candie_year'); if ($search_year < get_part_of_date('year') || $search_year == get_part_of_date('year') && $search_month < get_part_of_date('month') || $search_year == get_part_of_date('year') && $search_month > get_part_of_date('month') + 1) { $is_history = 1; } else { $is_history = 0; } $promotion_id = NULL; } } if ($this->input->post('button_action') == "frozen_hotdeal") { $promotion_id = $this->input->post('promotion_id'); $this->m_custom->update_frozen_flag(1, 'advertise', $promotion_id); $message_info = add_message_info($message_info, 'Candie Voucher success frozen.'); $this->session->set_flashdata('message', $message_info); redirect('merchant/candie_promotion/' . $promotion_id, 'refresh'); } if ($this->input->post('button_action') == "unfrozen_hotdeal") { $promotion_id = $this->input->post('promotion_id'); $this->m_custom->update_frozen_flag(0, 'advertise', $promotion_id); $message_info = add_message_info($message_info, 'Candie Voucher success unfrozen.'); $this->session->set_flashdata('message', $message_info); redirect('merchant/candie_promotion/' . $promotion_id, 'refresh'); } } //To get this month candie promotion if already create before $this_month_candie = $this->m_merchant->get_merchant_monthly_promotion($merchant_id, $search_month, $search_year, $promotion_id); $this->data['is_history'] = $is_history; $this->data['candie_term_current'] = empty($this_month_candie) ? array() : $this->m_custom->many_get_childlist('candie_term', $this_month_candie['advertise_id']); $this->data['candie_branch_current'] = empty($this_month_candie) ? array() : $this->m_custom->many_get_childlist('candie_branch', $this_month_candie['advertise_id']); $this->data['candie_id'] = array('candie_id' => empty($this_month_candie) ? '0' : $this_month_candie['advertise_id'], 'current_month' => get_part_of_date('month')); $this->data['sub_category_list'] = $this->m_custom->getSubCategoryList(NULL, NULL, $merchant_data->me_category_id); $this->data['candie_category'] = array('name' => 'candie_category', 'id' => 'candie_category'); $this->data['candie_category_selected'] = empty($this_month_candie) ? $merchant_data->me_sub_category_id : $this_month_candie['sub_category_id']; $this->data['candie_title'] = array('name' => 'candie_title', 'id' => 'candie_title', 'value' => empty($this_month_candie) ? '' : $this_month_candie['title'], 'maxlength' => '20'); //$default_desc = PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL . '<b>Original Price RM</b>'; $this->data['candie_desc'] = array('name' => 'candie_desc', 'id' => 'candie_desc', 'value' => empty($this_month_candie) ? '' : $this_month_candie['description']); $this->data['candie_image'] = empty($this_month_candie) ? $this->config->item('empty_image') : $this->album_merchant . $this_month_candie['image']; $this->data['start_date'] = array('name' => 'start_date', 'id' => 'start_date', 'readonly' => 'true', 'value' => empty($this_month_candie) ? '' : displayDate($this_month_candie['start_time'])); $this->data['end_date'] = array('name' => 'end_date', 'id' => 'end_date', 'readonly' => 'true', 'value' => empty($this_month_candie) ? '' : displayDate($this_month_candie['end_time'])); $this->data['year_list'] = $year_list; $this->data['candie_year'] = array('name' => 'candie_year', 'id' => 'candie_year'); $this->data['candie_year_selected'] = empty($search_year) ? get_part_of_date('year') : $search_year; $this->data['month_list'] = $month_list; $this->data['candie_month'] = array('name' => 'candie_month', 'id' => 'candie_month'); $this->data['candie_month_selected'] = empty($search_month) ? get_part_of_date('month') : $search_month; $this->data['candie_point'] = array('name' => 'candie_point', 'id' => 'candie_point', 'value' => empty($this_month_candie) ? '' : $this_month_candie['voucher_candie']); $this->data['expire_date'] = array('name' => 'expire_date', 'id' => 'expire_date', 'readonly' => 'true', 'value' => empty($this_month_candie) ? '' : displayDate($this_month_candie['voucher_expire_date'])); $this->data['original_price'] = array('name' => 'original_price', 'id' => 'original_price', 'value' => empty($this_month_candie) ? '' : $this_month_candie['original_price'], 'onkeypress' => 'return isNumber(event)'); $this->data['show_extra_info_list'] = $this->m_custom->get_static_option_array('adv_extra_info', '0', 'Select Extra Info To Show', 0, NULL, 1); $this->data['show_extra_info'] = array('name' => 'show_extra_info', 'id' => 'show_extra_info', 'onchange' => 'showextrainfodiv()'); $this->data['show_extra_info_selected'] = empty($this_month_candie) ? '' : $this_month_candie['show_extra_info']; $this->data['promotion_price_before'] = array('name' => 'price_before', 'id' => 'price_before', 'value' => empty($this_month_candie) ? '' : $this_month_candie['price_before'], 'onkeypress' => 'return isNumber(event)'); $this->data['promotion_price_after'] = array('name' => 'price_after', 'id' => 'price_after', 'value' => empty($this_month_candie) ? '' : $this_month_candie['price_after'], 'onkeypress' => 'return isNumber(event)'); $price_before_show = $this_month_candie['price_before_show']; $this->data['price_before_show'] = array('name' => 'price_before_show', 'id' => 'price_before_show', 'checked' => $price_before_show == "1" ? TRUE : FALSE, 'value' => empty($this_month_candie) ? '' : $this_month_candie['advertise_id']); $price_after_show = $this_month_candie['price_after_show']; $this->data['price_after_show'] = array('name' => 'price_after_show', 'id' => 'price_after_show', 'checked' => $price_after_show == "1" ? TRUE : FALSE, 'value' => empty($this_month_candie) ? '' : $this_month_candie['advertise_id']); $this->data['get_off_percent'] = array('name' => 'get_off_percent', 'id' => 'get_off_percent', 'value' => empty($this_month_candie) ? '' : $this_month_candie['get_off_percent'], 'onkeypress' => 'return isNumber(event)'); $this->data['how_many_buy'] = array('name' => 'how_many_buy', 'id' => 'how_many_buy', 'value' => empty($this_month_candie) ? '' : $this_month_candie['how_many_buy'], 'onkeypress' => 'return isNumber(event)', 'style' => 'width:70px'); $this->data['how_many_get'] = array('name' => 'how_many_get', 'id' => 'how_many_get', 'value' => empty($this_month_candie) ? '' : $this_month_candie['how_many_get'], 'onkeypress' => 'return isNumber(event)', 'style' => 'width:70px'); $this->data['adv_worth'] = array('name' => 'adv_worth', 'id' => 'adv_worth', 'value' => empty($this_month_candie) ? '' : $this_month_candie['voucher_worth'], 'onkeypress' => 'return isNumber(event)'); $this->data['extra_term'] = array('name' => 'candie_extra_term', 'id' => 'candie_extra_term', 'value' => empty($this_month_candie) ? '' : $this_month_candie['extra_term'], 'cols' => 90, 'placeholder' => 'Add extra T&C seperate by Enter, one line one T&C'); $this->data['promotion_id'] = empty($this_month_candie) ? '' : $this_month_candie['advertise_id']; $this->data['promotion_frozen'] = empty($this_month_candie) ? '' : $this_month_candie['frozen_flag']; $this->data['temp_folder'] = $this->temp_folder; $this->data['candie_term'] = $candie_term; $this->data['candie_branch'] = $candie_branch; $this->data['message'] = $this->session->flashdata('message'); $this->data['page_path_name'] = 'merchant/candie_promotion'; $this->load->view('template/index', $this->data); }
<?php date_default_timezone_set('Europe/Sofia'); $text = $_GET['text']; $rows = preg_split("/\n/", $text, -1, PREG_SPLIT_NO_EMPTY); for ($row = 0; $row < count($rows); $row++) { if (trim($rows[$row]) !== '') { $pattern = "/(.*?);\\s*(\\d{1,2}-\\d{1,2}-\\d{4})\\s*;(.*?);\\s*(\\d+)\\s*;(.*)?/"; preg_match($pattern, trim($rows[$row]), $posts); $date = $posts[2]; if (validateDate($date)) { $date = new DateTime($date); $comments = preg_split('/\\//', trim($posts[5]), -1, PREG_SPLIT_NO_EMPTY); $facebook[] = ['name' => trim($posts[1]), 'date' => $date, 'text' => trim($posts[3]), 'likes' => $posts[4], 'comments' => $comments]; } } } usort($facebook, function ($a, $b) { return $b['date'] > $a['date']; }); for ($i = 0; $i < count($facebook); $i++) { $name = htmlspecialchars($facebook[$i]['name']); $date = $facebook[$i]['date']; $postText = htmlspecialchars($facebook[$i]['text']); $likes = $facebook[$i]['likes']; echo "<article><header><span>{$name}</span><time>{$date->format('j F Y')}</time></header><main><p>{$postText}</p></main><footer><div class=\"likes\">{$likes} people like this</div>"; if (!empty($facebook[$i]['comments'])) { echo "<div class=\"comments\">"; for ($j = 0; $j < count($facebook[$i]['comments']); $j++) { echo "<p>" . htmlspecialchars(trim($facebook[$i]['comments'][$j])) . "</p>"; }
/** * mutator method for the comment time * * @param mixed $newTime new value of time as either string, DateTime object, or null for the current time * @throws InvalidArgumentException if $newTime is not a valid object or string * @throws RangeException if $newTime is a time and date that does not exist * @throws Exception if some other exception is thrown **/ public function setTime($newTime) { //base case: if the time is null, assign to the current time if ($newTime === null) { $this->time = new DateTime(); return; } //validate using the function defined in validate-date.php, and store if it works try { $newTime = validateDate($newTime); } catch (InvalidArgumentException $invalidArgument) { throw new InvalidArgumentException($invalidArgument->getMessage(), 0, $invalidArgument); } catch (RangeException $range) { throw new RangeException($range->getMessage(), 0, $range); } catch (Exception $exception) { throw new Exception($exception->getMessage(), 0, $exception); } $this->time = $newTime; }
<?php require "../config.php"; function validateDate($date) { $d = DateTime::createFromFormat('d.m.Y', $date); return $d && $d->format('d.m.Y') == $date; } if (!isset($_POST['name']) || strlen($_POST['name']) < 1) { die("Bitte geben Sie einen gültigen Namen ein."); } if (!isset($_POST['public']) || !validateDate($_POST['public']) || !isset($_POST['editable']) || !validateDate($_POST['editable'])) { die("Bitte geben Sie ein gültiges Datum ein."); } dbConn::execute("UPDATE :prefix:plan SET name = :0, public = :1, editable = :2 WHERE name = :3", htmlspecialchars($_POST['name']), DateTime::createFromFormat("d.m.Y", $_POST['public'])->format("Y-m-d H:i:s"), DateTime::createFromFormat("d.m.Y", $_POST['editable'])->format("Y-m-d H:i:s"), htmlspecialchars($_POST['originalName'])); dbConn::execute("DELETE FROM :prefix:email_subscriber WHERE plan = :0", htmlspecialchars($_POST['originalName'])); foreach ($_POST['subscribers'] as $r) { dbConn::execute("INSERT INTO :prefix:email_subscriber (email, plan) VALUES (:0, :1);", $r, htmlspecialchars($_POST['name'])); } echo "SUCCESS";
$entries = getDBEntryCount($statement); $statement .= setLimit($startAt, $rowsPerPage); echo "Zielland: " . $input1; } else { if ($_POST["filter"] == "filterDate") { if (isset($_GET["in1"])) { $input1 = $_GET["in1"]; } else { $input1 = filterfunktion($_POST["filterStartDate"]); } if (isset($_GET["in2"])) { $input2 = $_GET["in2"]; } else { $input2 = filterfunktion($_POST["filterEndDate"]); } if (validateDate($input1) || validateDate($input2)) { $statement = filterDatespan(reformDatetoDB($input1), reformDatetoDB($input2)); $statement .= " GROUP BY id "; $entries = getDBEntryCount($statement); $statement .= setLimit($startAt, $rowsPerPage); echo "Angebot gültig zwischen " . $input1 . " und " . $input2; } else { $statement = filterNone(); $statement .= " GROUP BY id "; $entries = getDBEntryCount($statement); $statement .= setLimit($startAt, $rowsPerPage); echo "Kein Filter gesetzt"; } } else { if ($_POST["filter"] == "filterName") { if (isset($_GET["in1"])) {
} //Build Query from input $table = $_GET["table"]; $maxbid = $_GET["maxbid"]; $minbid = $_GET["minbid"]; $saletype = $_GET["saletype"]; $salevalidity = $_GET["salevalidity"]; $startdate = $_GET["startdate"]; $enddate = $_GET["enddate"]; //escape user input to help prevent injection attacks $maxbid = mysql_real_escape_string($maxbid); $minbid = mysql_real_escape_string($minbid); $minbid = parseCurrency($minbid); $maxbid = parseCurrency($maxbid); $startdate = validateDate($startdate); $enddate = validateDate($enddate); //check that minbid/maxbid are in low->high order and not vice versa if ($minbid > $maxbid) { $temp = $maxbid; $maxbid = $minbid; $minbid = $temp; } $salestatus = mysql_real_escape_string($salestatus); $saledate = mysql_real_escape_string($saledate); // quote only values, not column name $query = "SELECT * FROM {$table} WHERE PRICE < "; if (is_numeric($maxbid)) { $query .= "'{$maxbid}' and PRICE >= "; } //>= to capture values that are 0. if (is_numeric($minbid)) {
$month -= 20; } else { if ($month >= 41 && $month <= 52) { $year .= "20" . $data['year']; $month -= 40; } else { $validPIN = false; } } } /*----- CHECK VALID DATE ------*/ if ($month < 10) { $month = "0" . intval($month); } $date = $year . $month . $data['day']; $validPIN = $validPIN && validateDate($date); function validateDate($date, $format = 'Ymd') { $d = DateTime::createFromFormat($format, $date); if ($d === false) { return false; } return strcmp($d->format($format), $date) == 0; } /*------ CHECK VALID GENDER -----*/ $validPIN = $validPIN && strcmp($gender, "male") == 0 ^ $data['gender'] % 2 != 0; /*------ CHECK VALID CHECKSUM ------*/ $checkSumArr = [2, 4, 8, 5, 10, 9, 7, 3, 6]; $sum = 0; for ($i = 0; $i < strlen($pin) - 1; $i++) { $sum += intval($pin[$i]) * $checkSumArr[$i];
if (!empty($q)) { $url .= "?" . $q; } } return $url; } } $params = is_array($modx->event->params) ? $modx->event->params : array(); $out = $beforePage = $afterPage = ''; $display = (int) APIHelpers::getkey($params, 'display', '10'); $dateSource = APIHelpers::getkey($params, 'dateSource', 'content'); $dateField = APIHelpers::getkey($params, 'dateField', 'if(pub_date=0,createdon,pub_date)'); $tmp = date("Y-m-d H:i:s"); $currentDay = APIHelpers::getkey($params, 'currentDay', $tmp); // Текущий день if (!validateDate($currentDay)) { $currentDay = $tmp; } $start = (int) APIHelpers::getkey($_GET, 'start', '0'); $elements = array('offset' => $start); //Если положительное значение, то нужы события предстоящие. Если отрицательное - прошедшее $rule = $start >= 0 ? 'after' : 'before'; $noRule = $start >= 0 ? 'before' : 'after'; if ($start < 0) { $start = abs($start) > $display ? $start + $display : 0; } $d = $modx->db->escape($currentDay); if ($dateSource == 'tv') { $params['tvSortType'] = 'TVDATETIME'; $query = array('after' => "STR_TO_DATE(`dltv_" . $dateField . "_1`.`value`,'%d-%m-%Y %H:%i:%s') >= '" . $d . "'", 'before' => "STR_TO_DATE(`dltv_" . $dateField . "_1`.`value`,'%d-%m-%Y %H:%i:%s') < '" . $d . "'"); } else {
function formular_velkoobchod_validate($form_data) { $fieldsets_c = count($form_data[material_all]); if (!empty($form_data)) { foreach ($form_data as $key => $value) { ${$key} = $value; } } //var_dump($datum); if (empty($datum) or !validateDate($datum)) { $error_msg[] = "Zle zadaný dátum"; $error_data[material] = $material; } //if(!is_numeric($vyrobca) OR $vyrobca<0 OR $vyrobca>1000) $error_msg[] = "Zle zadaný údaj Výrobcu"; for ($i = 0; $i < $fieldsets_c; $i++) { $error_line = 0; $error_line = $i + 1; if (empty($material_all[$i]) or !is_numeric($material_all[$i])) { $error_msg[] = "Materiál je povinný údaj - riadok {$error_line}"; $error_data[material_all] = $material_all[$i] . " na riadku: " . $error_line; } if (empty($vyrobca_all[$i]) or !is_numeric($vyrobca_all[$i])) { $error_msg[] = "Výrobca je povinný údaj - riadok {$error_line}"; $error_data[vyrobca_all] = $vyrobca_all[$i] . " na riadku: " . $error_line; } if (empty($dekor_all[$i]) or !is_numeric($dekor_all[$i])) { $error_msg[] = "Dekor je povinný údaj - riadok {$error_line}"; $error_data[dekor_all] = $dekor_all[$i] . " na riadku: " . $error_line; } if (empty($m2_all[$i]) and empty($m3_all[$i])) { $error_msg[] = "Aspoň jeden údaj ks / m3 musí byť vyplnený - riadok {$error_line}"; } if (!empty($m2_all[$i]) and !is_numeric($m2_all[$i])) { $error_msg[] = "ks nie je číselný údaj - riadok {$error_line}"; } if (!empty($m3_all[$i]) and !is_numeric($m3_all[$i])) { $error_msg[] = "m3 nie je číselný údaj - riadok {$error_line}"; } } return $error_msg; }
$postOK = false; } else { if (validateDate($_POST["startDate"])) { $startDate = (new DateTime($_POST["startDate"]))->format('d.m.Y'); } else { $startDateErr = "Bitte gültiges Datum eingeben (tt.mm.yyyy)"; $postOK = false; $startDate = filterfunktion($_POST["startDate"]); } } //ENDDATE--------------------------------- if (empty($_POST["endDate"])) { $endDateErr = "Bitte Datum eingeben"; $postOK = false; } else { if (validateDate($_POST["endDate"])) { $endDate = (new DateTime($_POST["endDate"]))->format('d.m.Y'); } else { $endDateErr = "Bitte gültiges Datum eingeben (tt.mm.yyyy)"; $postOK = false; $endDate = filterfunktion($_POST["endDate"]); } } //DATECHECK-------------------------------- /*if(strtotime(date('d.m.Y')) > strtotime(date($startDate))){ $startDateErr = "Datum muss heute oder in der Zukunft sein."; $postOK = false; } else */ if (strtotime(date($endDate)) < strtotime(date($startDate))) { $endDateErr = "Datum muss Startdatum oder danach sein";
public function editar_usuario() { //carregar Model $this->load->model('Usuarios_model', 'usuarios'); $check = array('nome' => TRUE, 'email' => TRUE, 'data' => TRUE); $data = array(); $user = $_POST; /*******************VALIDAÇOES DOS CAMPOS DO FORMULARIO*****************/ //Validar Campo Nome if ($user['nome'] == '') { $check['nome'] = FALSE; $data['msg'][1] = "O campo nome precisa ser preenchido."; } //Validar Campo email $this->load->helper('quick'); $check['email'] = isMail($user['email']); if ($check['email'] == FALSE || $_POST['email'] == '') { $check['email'] = FALSE; $data['msg'][2] = "Email Inválido. Digite um email válido."; } //Validar o campo data if ($user['data_de_nascimento'] == '') { $check['data'] = FALSE; $data['msg'][3] = "A data precisa ser preenchida."; } elseif (!validateDate($user['data_de_nascimento'])) { $check['data'] = FALSE; $data['msg'][3] = "A data está no formato incorreto."; } //Se tudo deu certo na validação encaminha para o banco if ($check['nome'] && $check['email'] && $check['data']) { //Formate a data para armazenar no banco $user['data_de_nascimento'] = to_mysql_data($user['data_de_nascimento']); //Resgata id e prepara vetor para editar no banco $id = $user['idd']; unset($user['idd']); $this->usuarios->editar_usuario($user, $id); $data['mensagem'] = "Edição realizada!"; $data['usuario'] = $this->usuarios->info_do_usuario_pelo_id($id); $this->template->load('template_view', 'usuario/editar_usuario', $data); } else { $data['mensagem'] = "Editar."; $data['usuario'] = $this->usuarios->info_do_usuario_pelo_id($user['idd']); $this->template->load('template_view', 'usuario/editar_usuario', $data); } }
$publish_status = 'publish'; $publish_type = 'fee'; $msg = ''; if (trim($_POST['fee_name']) === '') { $hasError = true; $msg .= '<p>Falta el nombre de la cuota!</p>'; } if (!is_numeric($_POST['fee_quantity'])) { $hasError = true; $msg .= '<p>Falta la cantidad de la cuota!</p>'; } if (!validateDate($_POST['fee_date_start'])) { $hasError = true; $msg .= '<p>Fecha de inicio incorrecta!</p>'; } if (!validateDate($_POST['fee_date_end'])) { $hasError = true; $msg .= '<p>Fecha de finalización incorrecta!</p>'; } if (!$hasError) { $post_information = array('post_title' => wp_strip_all_tags($_POST['fee_name']), 'post_content' => 'Ey', 'post_type' => $publish_type, 'post_status' => $publish_status); $post_id = wp_insert_post($post_information); update_post_meta($post_id, 'fee_date_start', esc_attr($_POST['fee_date_start'])); update_post_meta($post_id, 'fee_date_end', esc_attr($_POST['fee_date_end'])); update_post_meta($post_id, 'fee_quantity', esc_attr($_POST['fee_quantity'])); $alerts_success .= '<p>Cuota ' . $_POST['fee_name'] . ' creada</p>'; } else { $alerts_error .= $msg; } } if (esc_attr($_POST['updatesection']) == 'updatefee') {
function clean_up_get_params($_get) { if (isset($_get['lat'])) { $get_lat = $_get['lat']; } else { $get_lat = 51; } if (isset($_get['lon'])) { $get_lon = $_get['lon']; } else { $get_lon = 0; } if (isset($_get['clat'])) { $get_clat = $_get['clat']; } else { $get_clat = ""; } if (isset($_get['clon'])) { $get_clon = $_get['clon']; } else { $get_clon = ""; } if (isset($_get['date'])) { $get_date = $_get['date']; } else { $get_date = date("Y-m-d"); } if (isset($_get['skins'])) { $get_skins = $_get['skins']; } else { $get_skins = 1; } if (isset($_get['debug'])) { if ($_get['debug'] == "debug") { $get_debug = true; } else { $get_debug = false; } } else { $get_debug = false; } // ------------------------------------------------------------------------------------- // $get_skins default and range check // ------------------------------------------------------------------------------------- if ($get_skins == "") { $get_skins = 1; } if (!is_int($get_skins + 0)) { $get_skins = 1; } if ($get_skins > 6) { $get_skins = 6; } if ($get_skins < 0) { $get_skins = 0; } // ------------------------------------------------------------------------------------- // LATITUDE and LONGITUDE INTEGERS // ------------------------------------------------------------------------------------- // $get_lat default and range check // ------------------------------------------------------------------------------------- if ($get_lat == "") { $get_lat = 51; } if (!is_int($get_lat + 0)) { $get_lat = 51; } if ($get_lat < 0) { $get_lat = $get_lat - 1; } if ($get_lat === "-0") { $get_lat = -1; } // ## if ($get_lat + $get_skins > 89) { $get_lat = 89 - $get_skins; } // 89 88 87 86 85 84 83 82 81 80 79 78 77 if ($get_lat - $get_skins < -89) { $get_lat = -90 + $get_skins; } // 89 88 87 86 85 84 83 82 81 80 79 78 77 // ------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------- // $get_lon default and range check // ------------------------------------------------------------------------------------- if ($get_lon == "") { $get_lon = 0; } if (!is_int($get_lon + 0)) { $get_lon = 0; } if ($get_lon < 0) { $get_lon = $get_lon - 1; } if ($get_lon === "-0") { $get_lon = -1; } // ### if ($get_lon + $get_skins > 179) { $get_lon = 179 - $get_skins; } // 179 178 177 176 175 174 173 172 171 170 169 168 167 if ($get_lon - $get_skins < -179) { $get_lon = -180 + $get_skins; } // 179 178 177 176 175 174 173 172 171 170 169 168 167 // ------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------- // VIEW CENTERING LATITUDE and LONGITUDE REAL NUMBERS // ------------------------------------------------------------------------------------- // $get_clat default and range check // ------------------------------------------------------------------------------------- if (!is_numeric($get_clat + 0)) { $get_clat = ""; } if ($get_clat < 0) { $get_clat = $get_clat - 1; } if ($get_clat === "-0") { $get_clat = -1; } if ($get_clat > 89.9999) { $get_clat = 89.9999; } if ($get_clat < -89.9999) { $get_clat = -89.9999; } // ------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------- // $get_clon default and range check // ------------------------------------------------------------------------------------- if (!is_numeric($get_clon + 0)) { $get_clon = ""; } if ($get_clon < 0) { $get_clon = $get_clon - 1; } if ($get_clon === "-0") { $get_clon = -1; } if ($get_clon > 179.9999) { $get_clon = 179.9999; } if ($get_clon < -179.9999) { $get_clon = -179.9999; } // ------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------- // $get_date default and validate // ------------------------------------------------------------------------------------- if ($get_date == "") { $get_date = date("Y-m-d"); } // Today is the default if (!validateDate($get_date)) { if (is_int($get_date + 0) && $get_date >= -7 && $get_date <= 7) { $get_date = tweekDate(date("Y-m-d"), $get_date); } else { $get_date = date("Y-m-d"); } } $return_array = array("get_date" => $get_date, "get_lat" => $get_lat, "get_lon" => $get_lon, "get_clat" => $get_clat, "get_clon" => $get_clon, "get_skins" => $get_skins, "get_debug" => $get_debug); return $return_array; }
if ($client->exit) { $OP->ser("Something Happened", "<a href='" . $client->redirect_uri . "'>Try Again</a>"); } /* A function to validate date */ function validateDate($date) { $d = DateTime::createFromFormat('Y-m-d', $date); return $d && $d->format('Y-m-d') == $date; } if ($success) { $location = $_SESSION['continue']; $email = $user->email; $name = $user->name; $gender = $user->gender; /* Make it DD/MM/YYYY format */ if (isset($user->birthday) && validateDate($user->birthday)) { $birthday = date('d/m/Y', strtotime($user->birthday)); } $image = $user->picture; /* We now check if the E-Mail is already registered */ if ($LS->userExists($email)) { /* Since user exist, we log him in */ $LS->login($email, ""); $OP->redirect($location); } else { /* An array containing user details that will made in to JSON */ $userArray = array("joined" => date("Y-m-d H:i:s"), "gen" => $gender, "img" => $image); if (isset($birthday)) { $userArray["birth"] = $birthday; } $json = json_encode($userArray);
case 'loadFreeResponseResults': $surveyId = $_POST['surveyId']; $pageId = $_POST['pageId']; $beginDate = $_POST['beginDate']; $endDate = $_POST['endDate']; $questionsFilter = $_POST['questionsFilter']; $pageFilter = ""; $beginDateFilter = ""; $endDateFilter = ""; if ($pageId !== "all") { $pageFilter = " and question.pageId = {$pageId}"; } if (validateDate($beginDate)) { $beginDateFilter = " and freeResponse.datetime >= '{$beginDate}'"; } if (validateDate($endDate)) { $endDateFilter = " and freeResponse.datetime <= '{$endDate}'"; } $freeResponseAnswers = $db->query("select question.questionId, question.questionText, freeResponse.responseText\n\t from freeResponse\n\t inner join question on question.questionId = freeResponse.questionId\n\t inner join page on page.pageId = question.pageId\n\t where freeResponse.surveyId = '{$surveyId}' {$pageFilter} {$beginDateFilter} {$endDateFilter} {$questionsFilter}\n order by page.pageOrder, question.questionOrder"); $answersReturned = array(); while ($row = $freeResponseAnswers->fetch_array()) { $questionId = $row['questionId']; $questionText = $row['questionText']; $answerText = $row['responseText']; $answersReturned[] = array('questionId' => $questionId, 'questionText' => $questionText, 'answerText' => $answerText); } echo json_encode($answersReturned); break; case 'loadSurveys': $surveys = $db->query("select surveyid, surveyname from survey where archived = 0 order by surveyname"); $surveysReturned = array();
<?php // Get the actor data $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $gender = $_POST['gender']; $birth_date = $_POST['birth_date']; //function to validate Date format function validateDate($date) { $d = DateTime::createFromFormat('Y-m-d', $date); return $d && $d->format('Y-m-d') == $date; } // Validate inputs if (empty($first_name) || empty($last_name) || empty($gender) || empty($birth_date)) { $error = "Invalid actor data. Check all fields and try again."; include 'error.php'; } else { if (validateDate($birth_date) == false) { $error = "Invalid Date Format. Enter in yyyy-mm-dd format."; include 'error.php'; } else { // If valid, add the actor to the database require_once 'database.php'; $query = "INSERT INTO actors\r\n (firstName, lastName, actorGender, birthDate)\r\n VALUES\r\n ('{$first_name}', '{$last_name}', '{$gender}', '{$birth_date}')"; $db->exec($query); // Display the Actors page include 'actors.php'; } }
public function setUpdatedTime($newUpdatedTime) { //if date is null, use current time and date if ($newUpdatedTime === null) { $this->updatedTime = new DateTime(); return; } //Catch exceptions and display correct error (refers to validate-date.php) and if no exceptions, save the new time. try { $newUpdatedTime = validateDate($newUpdatedTime); } catch (InvalidArgumentException $invalidArgument) { throw new InvalidArgumentException($invalidArgument->getMessage(), 0, $invalidArgument); } catch (RangeException $range) { throw new RangeException($range->getMessage(), 0, $range); } catch (Exception $exception) { throw new Exception($exception->getMessage(), 0, $exception); } $this->updatedTime = $newUpdatedTime; }
function ProcessItem($formid, $fvalue, $params, $output_type) { global $TOOL_SHORT; $PASS_VALUE = "ok"; $FAIL_VALUE = "error"; global $VALIDATE_TEXT; $failed = false; $VALIDATE_TEXT = ""; // clear before doing the validation if (!validateRequired($fvalue) && !array_key_exists("required", $params)) { // blank and not required return ""; } // do the validation foreach ($params as $value) { if ($failed) { break; } $type = $value; if (strpos($value, ";") !== false) { // get the special rule type $type = substr($value, 0, strpos($value, ";")); } writeLog($TOOL_SHORT, "ajax", "validate:" . $type . ":" . $fvalue); if ($type == "required" || $type == "notblank") { if (!validateRequired($fvalue)) { $failed = true; } } else { if ($type == "email") { if (!validateEmail($fvalue)) { $failed = true; } } else { if ($type == "phone") { if (!validatePhone($fvalue)) { $failed = true; } } else { if ($type == "date") { if (!validateDate($fvalue)) { $failed = true; } } else { if ($type == "time") { if (!validateTime($fvalue)) { $failed = true; } } else { if ($type == "zip" || $type == "zipcode") { if (!validateZip($fvalue)) { $failed = true; } } else { if ($type == "nospaces" || $type == "password") { if (!validateNoSpaces($fvalue)) { $failed = true; } } else { if ($type == "alpha") { if (!validateAlpha($fvalue)) { $failed = true; } } else { if ($type == "alphanum") { if (!validateAlphaNumeric($fvalue)) { $failed = true; } } else { if ($type == "number") { if (!validateNumeric($fvalue)) { $failed = true; } } else { if ($type == "name") { if (!validateAlphaName($fvalue)) { $failed = true; } } else { if ($type == "namespaces") { if (!validateAlphaNameSpaces($fvalue)) { $failed = true; } } else { if ($type == "uniquesql") { // should be uniquesql;(columnname);(tablename);(tableid);(userid) $parts = split(';', $value); if (!validateUniqueSQL($parts[1], $parts[2], $fvalue, $parts[3], $parts[4])) { $VALIDATE_TEXT = $formid . " already used"; $failed = true; } } else { if ($type == "uniqueinstp") { // should be uniqueinstp;(value);($field);(idval) $parts = split(';', $value); if (!validateUniqueInst($fvalue, $parts[1], $parts[2])) { $VALIDATE_TEXT = $formid . " already used"; $failed = true; } } else { if ($type == "uniqueuserp") { // should be uniqueuserp;(value);($field);(idval) $parts = split(';', $value); if (!validateUniqueUser($fvalue, $parts[1], $parts[2])) { $VALIDATE_TEXT = $formid . " already used"; $failed = true; } } } } } } } } } } } } } } } } } if ($output_type == "ajax") { $status = $PASS_VALUE; if ($failed) { $status = $FAIL_VALUE; } $ajaxReturn = "{$status}|{$formid}|{$VALIDATE_TEXT}"; echo $ajaxReturn; writeLog($TOOL_SHORT, "ajax", "return={$ajaxReturn}"); } else { if ($output_type == "print") { if ($failed) { print $VALIDATE_TEXT . "<br>"; } } else { if ($output_type == "array") { if ($failed) { return $VALIDATE_TEXT; } } } } // defaults to "return" if ($failed) { return $VALIDATE_TEXT . "<br>"; } return ""; }
$result = curl_exec($ch); $result = json_decode($result, true); } else { // reCAPTCHA is disabled $result = array('success' => 'true'); } if (isset($result['success']) && $result['success'] == 'true') { // Validate $validate = new Validate(); $to_validation = array('password' => array('required' => true, 'min' => 6, 'max' => 30), 'password_again' => array('matches' => 'password'), 'email' => array('required' => true, 'min' => 4, 'max' => 64, 'unique' => 'users'), 't_and_c' => array('required' => true, 'agree' => true), 'location' => array('max' => 128)); if ($recaptcha === "true") { // check Recaptcha response $to_validation['g-recaptcha-response'] = array('required' => true); } // Validate date of birth if (Input::get('birthday') && (!validateDate(Input::get('birthday')) || strtotime(Input::get('birthday')) > strtotime('now'))) { // Invalid $error = '<div class="alert alert-danger">' . $user_language['invalid_date_of_birth'] . '</div>'; } else { // Valid date of birth if ($uuid_linking == '1') { if ($custom_usernames == "true") { // validate username and Minecraft name $to_validation['mcname'] = array('required' => true, 'min' => 3, 'max' => 20, 'unique' => 'users'); $to_validation['username'] = array('required' => true, 'min' => 3, 'max' => 20, 'unique' => 'users'); $mcname = htmlspecialchars(Input::get('mcname')); // Perform validation on Minecraft name $profile = ProfileUtils::getProfile(str_replace(' ', '%20', $mcname)); $mcname_result = $profile->getProfileAsArray(); if (isset($mcname_result['username']) && !empty($mcname_result['username'])) { // Valid
public function trans_extra_update($extra_id = NULL, $amount_change = NULL, $trans_bank = NULL, $trans_date = NULL, $trans_no = NULL, $trans_remark = NULL) { if ($extra_id != NULL) { $the_data = array('amount_change' => check_is_decimal($amount_change), 'trans_bank' => $trans_bank, 'trans_date' => validateDate($trans_date), 'trans_no' => $trans_no, 'trans_remark' => $trans_remark); $this->db->where('extra_id', $extra_id); $this->db->update('transaction_extra', $the_data); return TRUE; } else { return FALSE; } }
function processFlattererReminder($DaysBefore = 5, $PID = 0, $toArrID = array(), $isremind = false) { global $wpdb; global $post; $dyear = date('Y', strtotime('+ ' . $DaysBefore . ' Days ')); $month = date('n', strtotime('+ ' . $DaysBefore . ' Days ')); $list_day = date('j', strtotime('+ ' . $DaysBefore . ' Days ')); if (isset($_GET['dyear']) && isset($_GET['month']) && isset($_GET['list_day'])) { $dyear = $_GET['dyear']; $month = $_GET['month']; $list_day = $_GET['list_day']; } $subject = 'Reminder: You\'re invited to send a Flatterbox sentiment!'; $toArr = array(); if ($PID == 0) { $args = array('post_type' => 'flatterboxes', 'posts_per_page' => -1, 'meta_query' => array('relation' => 'AND', array('key' => 'date_sentiments_complete', 'value' => array($dyear . '-' . $month . '-' . $list_day . ' 00:00:00', $dyear . '-' . $month . '-' . $list_day . ' 23:59:59'), 'compare' => 'BETWEEN', 'type' => 'date'), array('relation' => 'OR', array('key' => 'order_count', 'value' => '', 'compare' => '='), array('key' => 'order_count', 'compare' => 'NOT EXISTS')))); } else { $args = array('post_type' => 'flatterboxes', 'posts_per_page' => 1, 'p' => $PID); } $the_query = new WP_Query($args); if (isset($_GET['showme'])) { print_r($the_query); } if ($the_query->have_posts()) { while ($the_query->have_posts()) { $the_query->the_post(); $PID = intval(get_the_ID()); try { //echo get_field('date_sentiments_complete', $PID); if (substr_count(get_field('date_sentiments_complete', $PID), '/') > 0) { $dateneeded = DateTime::createFromFormat('d/m/Y', get_field('date_sentiments_complete', $PID))->format('m/d/Y'); } else { $dateneeded = DateTime::createFromFormat('Ymd', get_field('date_sentiments_complete', $PID))->format('m/d/Y'); } } catch (Exception $e) { $dateneeded = ''; } //echo '!!!'; //echo get_field("date_sentiments_complete",$PID); //echo '$'.$dateneeded.'$'; //echo '!!!'; if (!validateDate($dateneeded, 'm/d/Y')) { $dateneeded = date_format(date_create(get_field("date_sentiments_complete", $PID)), 'm/d/Y'); } //$dateneeded = date('F j, Y',mktime(0, 0, 0, $month, $list_day, $dyear)); $occasion = get_field('occasion'); $creator = get_field('who_is_this_from'); $recipient = get_field('who_is_this_for'); if (strlen($creator) == 0) { $creator = get_the_author(); } $boxtheme = get_field('box_theme'); if (strpos($boxtheme, '(name)') > 0) { $boxtheme = str_replace('(name)', $recipient, $boxtheme); } else { $boxtheme = $boxtheme . ' ' . get_field("who_is_this_for", $PID); } $boxtheme = trim($boxtheme); $private = get_field("private", $PID); $instuctions = nl2br(get_field("special_instructions_to_flatterers", $PID)); $rem_instuctions = nl2br(get_field("reminder_instructions", $PID)); if (!$isremind) { $rem_instuctions = ''; } if (empty($toArrID)) { $flatterer_results = $wpdb->get_results("SELECT * FROM flatterers WHERE invalid = 0 AND responded = 0 AND PID = " . $PID, ARRAY_A); } else { $prefix = ''; $idList = ''; foreach ($toArrID as $toID) { $idList .= $prefix . '"' . $toID . '"'; $prefix = ', '; } $flatterer_results = $wpdb->get_results("SELECT * FROM flatterers WHERE invalid = 0 AND responded = 0 AND FID IN (" . $idList . ") AND PID = " . $PID, ARRAY_A); } unset($toArr); $toArr = array(); // Reset to avoid people seeing different items unset($messageArr); $messageArr = array(); if ($flatterer_results) { foreach ($flatterer_results as $row) { $linkURL = home_url() . '/sentiment/?PID=' . $PID . '&FID=' . $row['FID']; $bloginfo2 = home_url(); $message = '<html> <head> <title>Flatterbox_Eblast_final</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <center> <table id="Table_01" width="650" height="848" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="650" height="307" colspan="5" align="center" valign="top" style="font-family: Arial, Helvetica, sans-serif; font-size: 15px; color: #0e2240;"> <p style="font-size: 28px; color: #f38707; font-weight: bold; margin-bottom: 20px;"><em>Don\'t Forget!</em></p> <p style="font-weight: bold;">You have been invited by ' . $creator . ' to participate in a gift for </p> <p style="font-size: 48px; font-weight: bold;">' . $recipient . '</p> <p style="font-size: 18px;">The occasion: <strong>' . $occasion . '</strong></p> <p>The gift is called a Flatterbox and we need just <br> one minute of your time to make it happen.</p> <div style="padding: 10px; width: 310px; background-color: #f38707; color: #fff; font-size: 19px; font-weight: bold;"><em><a href="' . $linkURL . '" target="_blank" style="color: #fff;">Click here</a></em> to share<br>' . $boxtheme . '</div> <!--<p style="font-size: 14px; color: #797979; font-weight: bold;">SENTIMENT NEEDED BY: ' . $dateneeded . '</p>--> <p style="margin:20px 55px;"><strong>' . $instuctions . '</strong></p>'; if (false && $rem_instuctions) { // Hiding but keeping incase we need it. $message .= '<p style="margin:20px 55px;"><strong>' . $rem_instuctions . '</strong></p>'; } $message .= ' </tr>'; /* <tr> <td width="34" height="106"> </td> <td width="183" height="106" align="center" valign="top"><p><img src="'.$bloginfo2.'/emails/sentiment_reminder/images/fb_invite_number_1.png" width="29" height="29" alt="Step 1"></p> <p style="font-family:Arial, Helvetica, sans-serif; font-size: 14px; color:#0D2240;">By '.$dateneeded.'<br> <a href="'.$linkURL.'" target="_blank" style="color:#0D2240;">click this link</a></p></td> <td width="191" height="106" align="center" valign="top"><p><img src="'.$bloginfo2.'/emails/sentiment_reminder/images/fb_invite_number_2.png" width="29" height="29" alt="Step 2"></p> <p style="font-family:Arial, Helvetica, sans-serif; font-size: 14px; color:#0D2240;">Share <strong>'.$boxtheme.' '.$row["flatterer_name"].'</strong></p></td> <td width="209" height="106" align="center" valign="top"><p><img src="'.$bloginfo2.'/emails/sentiment_reminder/images/fb_invite_number_3.png" width="29" height="29" alt="Step 3"></p> <p style="font-family:Arial, Helvetica, sans-serif; font-size: 14px; color:#0D2240;">Your sentiment will be included<br>in a beautiful Flatterbox</p></td> <td width="33" height="106"> </td> </tr> */ $message .= '<tr>'; if ($private) { $message .= "<br/><br/>And don't forget your passcode. Your passcode is: " . $row["passcode"]; } $message .= '</tr> <tr> <td colspan="5"> <img src="' . $bloginfo2 . '/emails/sentiment_reminder/images/Flatterbox_Eblast_final_08.jpg" width="650" height="300" alt="Your sentiment will appear on a card like this. Click on the link and share ' . $boxtheme . ' ' . $recipient . '. - Flatterbox"></td> </tr> <tr> <td width="650" height="28" colspan="5" align="center" valign="middle" style="font-size: 11px; font-family: Arial, Helvetica, sans-serif; background-color: #0D2065; color: #fff;">Thank you for participating in their Flatterbox! <em>- From the Flatterbox Team</em> | <a href="http://www.flatterbox.com" target="_blank" style="color:#fff; text-decoration:none;">flatterbox.com</a> | <a href="mailto:info@flatterbox.com" target="_blank" style="color:#fff; text-decoration:none;">info@flatterbox.com</a></td> </tr> </table> </center> </body> </html>'; $toArr[] = $row["flatterer_email"]; $messageArr[] = $message; //echo $message; } if (!isset($_GET['showme'])) { if (count($toArr) > 0) { processEmail($toArr, $subject, $messageArr, $PID); } //echo 'REMINDER OK'; } else { echo '<br/><br/>'; print_r($the_query); echo '<br/><br/>'; print_r($toArr); echo '<br/><br/>'; echo $subject; echo '<br/><br/>'; print_r($messageArr); //echo 'REMINDER OK'; } } } } //echo 'COMPLETE'; }
function getValueFormat($value, $dataType) { //$retVal=0.0; if (strtolower($dataType) == 'numeric') { //echo $value.' '; //$str_arr = explode('.',$value); //$retVal = number_format($value,strlen($str_arr[1])); // After the Decimal point if (is_numeric($value)) { if (strpos($value, '.')) { $retVal = number_format($value, 1); } else { $retVal = number_format($value); } } else { $retVal = $value; } } elseif (strtolower($dataType) == 'date') { if (validateDate($value)) { $retVal = date('d-m-Y', strtotime($value)); } else { $retVal = ""; } } else { $retVal = $value; } return $retVal; }