/** * Зарегистрировать нового пользователя в системе * * @param string $mail Почта * @param string $password Пароль * @param string $name Имя * @param string $surname Фамилия * @param string $burthday Дата рождения * @param bool $gender Пол * @param integer $ip IP * @throws UserException Если пользователь уже существует * @throws UserException Если неверна дата рождения * @throws UserException Не заполнены имя и фамилия * @throws UserException Неверный формат почты */ public function register($mail, $password, $name, $surname, $burthday, $gender, $ip) { if (checkMail($mail)) { if ($this->checkIfExsist($mail)) { throw new UserException($mail, UserException::USR_ALREADY_EXIST); } if (!checkDateFormat($burthday)) { throw new UserException($mail, UserException::USR_CHECK_BURTHDAY); } else { if ($name == "" && $surname == "") { throw new UserException($mail, UserException::USR_NAME_EMPTY); } } $textPassword = $password; $password = md5($password); $date = date("Y-m-d"); $query = "\r\n INSERT INTO `SITE_USERS` SET\r\n `mail`='{$mail}',\r\n `password`='{$password}',\r\n `ip`={$ip},\r\n `register_date`='{$date}',\r\n `name`='{$name}',\r\n `second_name`='{$surname}',\r\n `gender`={$gender},\r\n `burthday`='{$burthday}'\r\n "; $this->_sql->query($query); $querySelectId = $this->_sql->selFieldsWhere("SITE_USERS", "`mail`='{$mail}'", "id"); $arr = $this->_sql->GetRows($querySelectId); $id = $arr[0]["id"]; $activationKey = $this->generateActivationKey(7); $insertActivationRowData = array($id, $activationKey); $this->_sql->insert("USERS_ACTIVATION_KEYS", $insertActivationRowData); $p = new UserMailer(); $p->mail = $mail; $embeddedImages = array("photos/no-photo.jpg", "photos/no-galary.jpg"); $s = new SmartyExst(); $s->assign("NAME", "{$name} {$surname}"); $s->assign("PASS", $textPassword); $s->assign("ID", $id); $s->assign("KEY", $activationKey); $sendString = $s->fetch($this->mailTemplate); $p->registerSend($sendString, $embeddedImages); return $id; } else { throw new UserException($mail, UserException::USR_NAME_INCORRECT); } }
} } else { return false; } } function checkTimeFormat($eventtime) { return preg_match('/(^([0-9]|[0-1][0-9]|[2][0-3]):([0-5][0-9])(\\s{0,1})([AM|PM|am|pm]{2,2})$)|(^([0-9]|[1][0-9]|[2][0-3])(\\s{0,1})([AM|PM|am|pm]{2,2})$)/xms', $eventtime, $match) ? sprintf('%02d:%d%s', $match[1], $match[2], strtoupper($match[3])) : false; } $meeting_id = ID_Incremenet(); $Date = $_POST['Date']; $Time = $_POST['Time']; $Venue = $_POST['Venue']; $Agenda = $_POST['Agenda']; $status = "OK"; if (checkDateFormat($Date) == False || $Date == NULL) { echo '<meta HTTP-EQUIV="REFRESH" content="3; url=Create-Meeting.php">'; echo "<center><font face='Verdana' size='3' color=red>\n Please enter the meeting date in the correct format!!!\n <br> <br> <br>\n Wait!!! You will be redirected in 3 seconds ...</font></center>"; exit; $status = "NOTOK"; } if (checkTimeFormat($Time) == False || $Time == NULL) { echo '<meta HTTP-EQUIV="REFRESH" content="3; url=Create-Meeting.php">'; echo "<center><font face='Verdana' size='3' color=red>\n Please enter the meeting time in the correct format!!!\n <br> <br> <br>\n Wait!!! You will be redirected in 3 seconds ...</font></center>"; exit; $status = "NOTOK"; } if ($Venue == NULL) { echo '<meta HTTP-EQUIV="REFRESH" content="3; url=Create-Meeting.php">'; echo "<center><font face='Verdana' size='3' color=red>\n Please enter the meeting venue!!!\n <br> <br> <br>\n Wait!!! You will be redirected in 3 seconds ...</font></center>"; exit;
/** * Check erroneous date strings, according to a DateTime format */ public function testCheckInvalidDateFormat() { $this->assertFalse(checkDateFormat('Ymd', '2015')); $this->assertFalse(checkDateFormat('Y-m-d', '2015-06')); $this->assertFalse(checkDateFormat('Ymd', 'DeLorean')); }
/** Check if provided correct arguments for a request. * * Only number of parameters is checked. * metadataPrefix has to be checked before it is used. * set has to be checked before it is used. * resumptionToken has to be checked before it is used. * from and until can easily checked here because no extra information * is needed. */ function checkArgs($args, $checkList) { // global $errors, $TOKEN_VALID, $METADATAFORMATS; global $errors, $METADATAFORMATS; // $verb = $args['verb']; unset($args["verb"]); debug_print_r('checkList', $checkList); debug_print_r('args', $args); // "verb" has been checked before, no further check is needed if (isset($checkList['required'])) { for ($i = 0; $i < count($checkList["required"]); $i++) { debug_message("Checking: par{$i}: " . $checkList['required'][$i] . " in "); debug_var_dump("isset(\$args[\$checkList['required'][\$i]])", isset($args[$checkList['required'][$i]])); // echo "key exists". array_key_exists($checkList["required"][$i],$args)."\n"; if (isset($args[$checkList['required'][$i]]) == false) { // echo "caught\n"; $errors[] = oai_error('missingArgument', $checkList["required"][$i]); } else { // if metadataPrefix is set, it is in required section if (isset($args['metadataPrefix'])) { $metadataPrefix = $args['metadataPrefix']; // Check if the format is supported, it has enough infor (an array), last if a handle has been defined. if (!array_key_exists($metadataPrefix, $METADATAFORMATS) || !(is_array($METADATAFORMATS[$metadataPrefix]) || !isset($METADATAFORMATS[$metadataPrefix]['myhandler']))) { $errors[] = oai_error('cannotDisseminateFormat', 'metadataPrefix', $metadataPrefix); } } unset($args[$checkList["required"][$i]]); } } } debug_message('Before return'); debug_print_r('errors', $errors); if (!empty($errors)) { return; } // check to see if there is unwanted foreach ($args as $key => $val) { debug_message("checkArgs: {$key}"); if (!in_array($key, $checkList["ops"])) { debug_message("Wrong\n" . print_r($checkList['ops'], true)); $errors[] = oai_error('badArgument', $key, $val); } switch ($key) { case 'from': case 'until': if (!checkDateFormat($val)) { $errors[] = oai_error('badGranularity', $key, $val); } break; case 'resumptionToken': // only check for expairation if ((int) $val + TOKEN_VALID < time()) { $errors[] = oai_error('badResumptionToken'); } break; } } }
/** * Returns the list of articles for a given day, chronologically sorted * * Day must be in the form 'YYYYMMDD' (e.g. '20120125'), e.g. * print_r($mydb->filterDay('20120125')); * * @param string $day day to filter. * * @return array all link matching given day. * * @throws Exception if date format is invalid. */ public function filterDay($day) { if (!checkDateFormat('Ymd', $day)) { throw new Exception('Invalid date format'); } $filtered = array(); foreach ($this->links as $l) { if (startsWith($l['linkdate'], $day)) { $filtered[$l['linkdate']] = $l; } } ksort($filtered); return $filtered; }
function formatDatestamp($datestamp) { global $granularity; $datestamp = date2UTCdatestamp($datestamp); if (!checkDateFormat($datestamp)) { if ($granularity == 'YYYY-MM-DD') { return '2002-01-01'; } else { return '2002-01-01T00:00:00Z'; } } else { return $datestamp; } }
if ($access_id != $ENTRADA_USER->getDefaultAccessId()) { $sidebar_html .= "<li class=\"checkmark\"><strong>" . html_encode($result["fullname"]) . "</strong><br /><span class=\"content-small\">Exp: " . ($result["expires"] ? date("D M d/y", $result["expires"]) : "Unknown") . "</span></li>\n"; } } $sidebar_html .= "</ul>\n"; new_sidebar_item("Delegated Permissions", $sidebar_html, "delegated-permissions", "open"); } add_mspr_admin_sidebar($year); $class_data = MSPRClassData::get($year); $class_close = $class_data->getClosedTimestamp(); if ($_POST["action"] == "Update Options") { $class_close_date = $_POST['close_datetime_date']; $class_close_hour = $_POST['close_datetime_hour']; $class_close_min = $_POST['close_datetime_min']; //error checking.... the fun part if (!$class_close_date || !checkDateFormat($class_close_date)) { add_error("Invalid date format. The submission deadline date must be in the format yyyy-mm-dd, and be a valid date."); } if (!$class_close_hour < 0 || $class_close_hour > 23 || $class_close_mins < 0 || $class_close_mins > 59) { add_error("Invalid time. Please check your values and try again."); } $parts = date_parse($class_close_date); $timestamp = mktime($class_close_hour, $class_close_min, 0, $parts['month'], $parts['day'], $parts['year']); if (!has_error()) { $has_custom = MSPRs::hasCustomDeadlines_Year($year); if ($_POST["confirm"] != "Continue" && $has_custom) { //there are set custom deadlines. need to present another set of options $page_mode = "confirm"; } else { $resolve_type = $_POST['resolve_type']; $class_data->setClosedTimestamp($timestamp);
$mspr = MSPR::get($user); $year = $user->getGradYear(); $class_data = MSPRClassData::get($year); $class_close = $class_data->getClosedTimestamp(); $mspr_close = $mspr->getClosedTimestamp(); add_mspr_management_sidebar(); if ($_POST["action"] == "Update Options") { if (!isset($_POST['close_datetime'])) { //removing the custom deadline.... or simply not setting it? $timestamp = null; } else { $mspr_close_date = $_POST['close_datetime_date']; $mspr_close_hour = $_POST['close_datetime_hour']; $mspr_close_min = $_POST['close_datetime_min']; //error checking.... the fun part if (!$mspr_close_date || !checkDateFormat($mspr_close_date)) { add_error("Invalid date format. The submission deadline date must be in the format yyyy-mm-dd, and be a valid date."); } if (!$mspr_close_hour < 0 || $mspr_close_hour > 23 || $mspr_close_mins < 0 || $mspr_close_mins > 59) { add_error("Invalid time. Please check your values and try again."); } $parts = date_parse($mspr_close_date); $timestamp = mktime($mspr_close_hour, $mspr_close_min, 0, $parts['month'], $parts['day'], $parts['year']); } if (!has_error()) { $is_early = $timestamp !== null && $timestamp < $class_close; if ($_POST["confirm"] != "Continue" && $is_early) { //the requested custom close is earlier than the class default. need to confirm $page_mode = "confirm"; } else { $resolve_type = $_POST['resolve_type'];
/** * Function will validate the calendar that is generated by generate_calendar(). * * @param string $fieldname * @param bool $use_times * @return int $timestamp */ function validate_calendar($label, $fieldname, $use_times = true, $required = true) { global $ERROR, $ERRORSTR; $timestamp_start = 0; $timestamp_finish = 0; if (!isset($_POST[$fieldname . "_date"]) || !trim($_POST[$fieldname . "_date"])) { if ($required) { add_error("<strong>" . $label . "</strong> date not entered."); } else { return; } } elseif (!checkDateFormat($_POST[$fieldname . "_date"])) { add_error("Invalid format for <strong>" . $label . "</strong> date."); } else { if ($use_times && !isset($_POST[$fieldname . "_hour"])) { add_error("<strong>" . $label . "</strong> hour not entered."); } else { if ($use_times && !isset($_POST[$fieldname . "_min"])) { add_error("<strong>" . $label . "</strong> minute not entered."); } else { $pieces = explode("-", $_POST[$fieldname . "_date"]); $hour = $use_times ? (int) trim($_POST[$fieldname . "_hour"]) : 0; $minute = $use_times ? (int) trim($_POST[$fieldname . "_min"]) : 0; $second = 0; $month = (int) trim($pieces[1]); $day = (int) trim($pieces[2]); $year = (int) trim($pieces[0]); $timestamp = mktime($hour, $minute, $second, $month, $day, $year); } } } return $timestamp; }
public function changeButhday($newDate) { if (checkDateFormat($newDate)) { $this->changeField($newDate, "burthday"); } }
$Category = $_POST['Category']; $Budget_Required = $_POST['Budget_Required']; $status = "OK"; if ($Name == NULL) { echo '<meta HTTP-EQUIV="REFRESH" content="3; url=Add-Event.php">'; echo "<center><font face='Verdana' size='3' color=red>\n Please enter the event name!!!\n <br> <br> <br>\n Wait!!! You will be redirected in 3 seconds ...</font></center>"; exit; $status = "NOTOK"; } if (checkDateFormat($Start_Date) == False || $Start_Date == NULL) { echo '<meta HTTP-EQUIV="REFRESH" content="3; url=Add-Event.php">'; echo "<center><font face='Verdana' size='3' color=red>\n Please enter the event start date in the correct format!!!\n <br> <br> <br>\n Wait!!! You will be redirected in 3 seconds ...</font></center>"; exit; $status = "NOTOK"; } if (checkDateFormat($End_Date) == False || $End_Date == NULL) { echo '<meta HTTP-EQUIV="REFRESH" content="3; url=Add-Event.php">'; echo "<center><font face='Verdana' size='3' color=red>\n Please enter the event end date in the correct format!!!\n <br> <br> <br>\n Wait!!! You will be redirected in 3 seconds ...</font></center>"; exit; $status = "NOTOK"; } if (checkTimeFormat($Start_Time) == False || $Start_Time == NULL) { echo '<meta HTTP-EQUIV="REFRESH" content="3; url=Add-Event.php">'; echo "<center><font face='Verdana' size='3' color=red>\n Please enter the event start time in the correct format!!!\n <br> <br> <br>\n Wait!!! You will be redirected in 3 seconds ...</font></center>"; exit; $status = "NOTOK"; } if (checkTimeFormat($End_Time) == False || $End_Time == NULL) { echo '<meta HTTP-EQUIV="REFRESH" content="3; url=Add-Event.php">'; echo "<center><font face='Verdana' size='3' color=red>\n Please enter the event end time in the correct format!!!\n <br> <br> <br>\n Wait!!! You will be redirected in 3 seconds ...</font></center>"; exit;
$englishDate = "/^([0-9]{4})-([0-9]{2})-([0-9]{2})/"; $frenchDate = "/^([0-9]{2})-([0-9]{2})-([0-9]{4})/"; if (preg_match($englishDate, $dateStart, $matches) != null) { return true; } else { if (preg_match($frenchDate, $dateStart, $matches) != null) { $dateStart = $matches[3] . "-" . $matches[2] . "-" . $matches[1]; preg_match($frenchDate, $dateEnd, $matches); $dateEnd = $matches[3] . "-" . $matches[2] . "-" . $matches[1]; return true; } else { return false; } } } $validDate = checkDateFormat(); if ($validDate == true) { $huby_db = new PDO('sqlite:HubyDb.db'); $huby_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); switch ($queryChoice) { case "in": $queryString = "SELECT * from Entry where Date between '" . $dateStart . "' and '" . $dateEnd . "' order by `Date` asc"; break; case "out": $queryString = "SELECT * from Exit where Date between '" . $dateStart . "' and '" . $dateEnd . "' order by `Date` asc"; break; case "chartin": $queryString = "SELECT COUNT(1) AS entries, strftime('%Y-%m',Date) as dt FROM Entry GROUP BY strftime('%Y-%m',Date);"; break; case "chartout": $queryString = "SELECT COUNT(1) AS entries, strftime('%Y-%m',Date) as dt FROM Exit GROUP BY strftime('%Y-%m',Date);";
function validar_fecha($fecha) { $errors = 0; $fecha_actual = date("d-m-Y"); if (trim($fecha) == '') { $_SESSION['error']['evento'][] = '<p><label style="color:#FF0000;" class="control-label" for="inputError">Debe introducir la fecha del evento</label></p>'; $errors++; } else { if (checkDateFormat($fecha) == false) { $_SESSION['error']['evento'][] = '<p><label style="color:#FF0000;" class="control-label" for="inputError">Debe introducir la fecha en el formato correcto dd-mm-yyyy</label></p>'; $errors++; } else { if (strtotime($fecha) >= strtotime($fecha_actual) != 1) { $_SESSION['error']['evento'][] = '<p><label style="color:#FF0000;" class="control-label" for="inputError">Debe introducir una fecha posterior a hoy</label></p>'; $errors++; } } } return $errors; }
} } } else { $deliveredrecords = 0; $extquery = ''; if (!isset($args['metadataPrefix'])) { $errors .= oai_error('missingArgument', 'metadataPrefix'); } if (isset($args['from'])) { if (!checkDateFormat($from)) { $errors .= oai_error('badGranularity', 'from', $from); } $extquery .= fromQuery($from); } if (isset($args['until'])) { if (!checkDateFormat($until)) { $errors .= oai_error('badGranularity', 'until', $until); } $extquery .= untilQuery($until); } if (isset($args['set'])) { // if (is_array($SETS)) { $extquery .= setQuery($set); // } else { // $errors .= oai_error('noSetHierarchy'); // oai_exit(); // } } } if (empty($errors)) { $query = idQuery() . $extquery;
/** * adds errors, if found. May modify inputs in the process * @param string $type * @param array $inputs May modify inputs in the process * @param mixed $translator */ function process_mspr_inputs($type, array &$inputs, $translator) { switch ($type) { case 'studentships': if (!($inputs['title'] && $inputs['year'])) { add_error($translator->translate("mspr_insufficient_info")); } break; case 'clineval': if (!($inputs['text'] && $inputs['source'])) { add_error($translator->translate("mspr_insufficient_info")); } break; case 'internal_awards': if (!($inputs['award_id'] && $inputs['year'])) { add_error($translator->translate("mspr_insufficient_info")); } break; case 'external_awards': if (!($inputs['title'] && $inputs['terms'] && $inputs['body'] && $inputs['year'])) { add_error($translator->translate("mspr_insufficient_info")); } break; case 'contributions': if (!($inputs['role'] && $inputs['org_event'] && $inputs['start_year'])) { add_error($translator->translate("mspr_insufficient_info")); } break; case 'student_run_electives': if (!($inputs['group_name'] && $inputs['university'] && $inputs['location'] && $inputs['start_year'])) { add_error($translator->translate("mspr_insufficient_info")); } break; case 'observerships': if (!checkDateFormat($inputs['start'])) { add_error($translator->translate("mspr_observership_invalid_dates")); } else { $parts = date_parse($inputs['start']); $start_ts = mktime(0, 0, 0, $parts['month'], $parts['day'], $parts['year']); if ($inputs['end'] && checkDateFormat($inputs['end'])) { $parts = date_parse($inputs['end']); $end_ts = mktime(0, 0, 0, $parts['month'], $parts['day'], $parts['year']); } else { $end_ts = null; } $inputs['start'] = $start_ts; $inputs['end'] = $end_ts; } if (!$inputs['preceptor_proxy_id']) { $inputs['preceptor_proxy_id'] = null; } if (!$inputs['preceptor_proxy_id'] && !($inputs['preceptor_firstname'] || $inputs['preceptor_lastname'])) { add_error($translator->translate("mspr_observership_preceptor_required")); } if ($inputs['preceptor_proxy_id'] == -1) { //special case for "Various" $inputs['preceptor_proxy_id'] = 0; //not faculty $inputs['preceptor_firstname'] = "Various"; $inputs['preceptor_lastname'] = ""; } if (!has_error() && !($inputs['title'] && $inputs['site'] && $inputs['location'] && $inputs['start'])) { add_error($translator->translate("mspr_insufficient_info")); } break; case 'int_acts': if (!checkDateFormat($inputs['start'])) { add_error($translator->translate("mspr_observership_invalid_dates")); } else { if (!$inputs['end'] || !checkDateFormat($inputs['end'])) { $inputs['end'] = $inputs['start']; } } if (!has_error() && !($inputs['title'] && $inputs['site'] && $inputs['location'] && $inputs['start'])) { add_error($translator->translate("mspr_insufficient_info")); } break; case 'critical_enquiry': case 'community_based_project': if (!($inputs['title'] && $inputs['organization'] && $inputs['location'] && $inputs['supervisor'])) { add_error($translator->translate("mspr_insufficient_info")); } break; case 'research_citations': if (!$inputs['details'] && !is_array($inputs['research_citations'])) { add_error($translator->translate("mspr_insufficient_info")); } break; } }
$errors[] = oai_error('badResumptionToken', '', $args['resumptionToken']); } else { debug_var_dump('readings', $readings); list($deliveredrecords, $extquery, $metadataPrefix) = $readings; } } else { // no, we start a new session $deliveredrecords = 0; $extquery = ''; $metadataPrefix = $args['metadataPrefix']; if (isset($args['from'])) { $from = checkDateFormat($args['from']); $extquery .= fromQuery($from); } if (isset($args['until'])) { $until = checkDateFormat($args['until']); $extquery .= untilQuery($until); } if (isset($args['set'])) { if (is_array($SETS)) { $extquery .= setQuery($args['set']); } else { $errors[] = oai_error('noSetHierarchy'); } } } if (!empty($errors)) { oai_exit(); } // Load the handler if (is_array($METADATAFORMATS[$metadataPrefix]) && isset($METADATAFORMATS[$metadataPrefix]['myhandler'])) {
/** * Change a date. * * __Authorization Required__ * * @param array $dateParams An array of parameters. * * It must include the following: * * |parameter |type |description |required | * |---------------|---------|------------|---------| * | `username` | string | The username of the event's owner | **YES** | * | `eventID` | integer | The ID of the event the date belongs to.| **YES** | * | `dateID` | integer | the ID of the date you wish to change. | **YES | * | `beginTime` | string | The time the event begins on this date.| NO | * | `endTime` | string | The time the event ends on this date.| NO | NO * | `salesEnd` | string | The time you wish to end sales.| NO | * | `maxSales` | integer | The maximum number of sales for this date.|NO| * | `physical` | boolean | Whether or not to sell physical tickets for this date.|NO| * | `pointOfSale` | boolean | Whether or not to make tickets available through the Brown Paper Tickets Open Ticket Network.|NO| * | `willCall` | boolean | Whether to offer tickets for Will-Call pickup.|NO| * | `printAtHome` | boolean | Whether to offer print at home tickets.|NO| * | `mobile` | boolean | Whether to offer mobile tickets.|NO| * * @return array True if successful, false if not. */ public function changeDate($dateParams) { if (!isset($dateParams['username']) || !isset($dateParams['eventID']) || !isset($dateParams['dateID'])) { throw new \InvalidArgumentException($this->missingParamsMessage); } if (!checkDateFormat($dateParams['beginTime']) || !checkDateFormat($dateParams['endTime'])) { $this->setError('addDate', 'Invalid date format.'); return false; } $apiOptions = array('endpoint' => 'changeDate', 'account' => $dateParams['username'], 'event_id' => $dateParams['eventID'], 'begin_time' => $dateParams['beginTime']); if (isset($dateParams['endTime'])) { if (!checkDateFormat($dateParams['endTime'])) { $this->setError('addDate', 'Invalid endTime format.'); return false; } $apiOptions['end_time'] = $dateParams['endTime']; } if (isset($dateParams['salesEnd'])) { if (!checkDateFormat($dateParams['salesEnd'])) { $this->setError('addDate', 'Invalid salesEnd format.'); return false; } $apiOptions['sales_end'] = $dateParams['salesEnd']; } if (isset($dateParams['maxSales'])) { $apiOptions['max_sales'] = $dateParams['maxSales']; } if (isset($dateParams['physical'])) { $apiOptions['physical'] = $this->convertBoolToString($dateParams['physical']); } if (isset($dateParams['pos'])) { $apiOptions['pos'] = $this->convertBoolToString($dateParams['pos']); } if (isset($dateParams['willCall'])) { $apiOptions['willcall'] = $this->convertBoolToString($dateParams['willcall']); } if (isset($dateParams['printAtHome'])) { $apiOptions['pah'] = $this->convertBoolToString($dateParams['printAtHome']); } if (isset($dateParams['mobile'])) { $apiOptions['mobile'] = $this->convertBoolToString($dateParams['mobile']); } $changeDateXML = $this->parseXML($this->callAPI($apiOptions)); if (isset($changeDateXML['error'])) { $this->setError('changeDate', $changeDateXML['error']); return false; } return true; }