function mobileAddStoredTitles() { global $error; $arr_submit = array(array('cal_id', 'int', false, ''), array('color', 'string', false, ''), array('date_end', 'int', false, ''), array('date_start', 'int', false, ''), array('title', 'string', true, ''), array('username', 'string', true, ''), array('password', 'string', true, ''), array('store', 'string', true, ''), array('allDay', 'bool', false, '')); $frm_submitted = validate_var($arr_submit); // check user $int_user_id = 0; if (User::UserAuthenticated($frm_submitted['username'], $frm_submitted['password'], $int_user_id)) { // returned by reference user_id } else { echo 'username or password wrong'; exit; } if (empty($frm_submitted['store'])) { echo 'No items where send'; exit; } // setlocale(LC_ALL, 'nl_NL'); global $obj_db; $str_store = str_replace(array('(', ')'), '', $frm_submitted['store']); $arr_store = explode('|', $str_store); unset($arr_store[0]); $arr_maanden = array('jan' => 1, 'feb' => 2, 'mrt' => 3, 'apr' => 4, 'mei' => 5, 'jun' => 6, 'jul' => 7, 'aug' => 8, 'sep' => 9, 'okt' => 10, 'nov' => 11, 'dec' => 12); foreach ($arr_store as $title) { $arr_title = explode(';', $title); $str_title = str_replace('_', ' ', $arr_title[0]); $str_date = str_replace('_', '', $arr_title[3]); $str_day = str_replace('_', '', $arr_title[1]); $str_time = str_replace('_', '', $arr_title[4]); $bln_allday = str_replace('_', '', $arr_title[2]) == 'true' ? true : false; $arr_date_parts = date_parse_from_format("dMY", $str_date); //echo $arr_title[3]; $monthname = preg_replace('/[0-9]/', '', $str_date); $monthname = str_replace('.', '', $monthname); $monthnumber = $arr_maanden[$monthname]; $inputday = $arr_date_parts['year'] . '-' . $monthnumber . '-' . $arr_date_parts['day']; if ($str_day == 'today') { if ($bln_allday) { $frm_submitted['date_start'] = strtotime($inputday . ' ' . '00:00:00'); } else { $frm_submitted['date_start'] = strtotime($inputday . ' ' . $str_time); } } else { if ($str_day == 'yesterday') { if ($bln_allday) { $frm_submitted['date_start'] = strtotime($inputday . ' ' . '00:00:00') - 86400; } else { $frm_submitted['date_start'] = strtotime($inputday . ' ' . $str_time) - 86400; } } else { if ($str_day == 'daybeforeyesterday') { if ($bln_allday) { $frm_submitted['date_start'] = strtotime($inputday . ' ' . '00:00:00') - 2 * 86400; } else { $frm_submitted['date_start'] = strtotime($inputday . ' ' . $str_time) - 2 * 86400; } } } } if (!isset($frm_submitted['date_start'])) { $frm_submitted['date_start'] = time(); } $frm_submitted['date_end'] = $frm_submitted['date_start']; $str_query = 'INSERT INTO events (title, user_id, color, date_start, time_start, date_end, time_end, allday) ' . 'VALUES ("' . $str_title . '",' . $int_user_id . ',' . ' "#' . $frm_submitted['color'] . '",' . ' "' . date('Y-m-d', $frm_submitted['date_start']) . '",' . ' "' . date('H:i:s', $frm_submitted['date_start']) . '",' . ' "' . date('Y-m-d', $frm_submitted['date_end']) . '",' . ' "' . date('H:i:s', $frm_submitted['date_end']) . '"' . (date('H:i:s', $frm_submitted['date_start']) == '00:00:00' && date('H:i:s', $frm_submitted['date_end']) == '00:00:00' || $bln_allday ? ' ,1' : ' ,0') . ')'; $obj_result = mysqli_query($obj_db, $str_query); if ($obj_result !== false) { echo 'Saved succesfully'; // echo json_encode(array('success'=>true, 'msg'=>'gelukt' ));exit; } else { echo 'failure'; } } }