コード例 #1
1
ファイル: Email.php プロジェクト: vivait/customer-bundle
 /**
  * @param string $email
  */
 function __construct($email)
 {
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         throw new \InvalidArgumentException(sprintf('"%s" is not a valid email', $email));
     }
     $this->email = $email;
 }
コード例 #2
0
ファイル: App.php プロジェクト: CodeAmend/php-mvc-test
 protected function parseURL()
 {
     if (isset($_GET['url'])) {
         $url = preg_replace('/public\\//', '', $_GET['url']);
         return explode("/", filter_var(rtrim($url, "/"), FILTER_SANITIZE_URL));
     }
 }
コード例 #3
0
 public function __construct($name = 'Email', array $config = [])
 {
     parent::__construct($name, $config);
     $this->validators[] = function ($value) {
         return filter_var($value, FILTER_VALIDATE_EMAIL) ? true : "Invalid email address: {$value}";
     };
 }
コード例 #4
0
 public function Email($email, $reemail)
 {
     if (empty($email)) {
         $this->errors[] = "You must provide a valid E-Mail.";
     }
     //check if provided email is valid, but first check that the user typed something in.
     if (!empty($email)) {
         if ($email !== $reemail) {
             $this->errors[] = "The E-Mail's that you provided do not match.";
         }
         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $this->errors[] = "The E-Mail that you provided is not valid.";
         }
     }
     if (filter_var($email, FILTER_VALIDATE_EMAIL) && $email == $reemail) {
         $stmt = $this->mysqli->prepare("SELECT * FROM temp_users,users WHERE users.email = ? OR temp_users.email = ?") or die("There was an error of some sort.");
         $stmt->bind_param('ss', $email, $email);
         $stmt->execute();
         $stmt->store_result();
         if ($stmt->num_rows > 0) {
             // email is found, throw out error
             $this->errors[] = "That E-Mail is already in use.";
         }
         $stmt->free_result();
         $stmt->close();
     }
 }
コード例 #5
0
ファイル: FloatingPoint.php プロジェクト: broeser/wellid
 /**
  * Validates the given $value
  * Checks if it is a valid (possible) floating point value
  * 
  * @param float $value
  * @return ValidationResult
  */
 public function validate($value)
 {
     if (filter_var($value, FILTER_VALIDATE_FLOAT, array('options' => array('decimal' => $this->decimal))) === false) {
         return new ValidationResult(false, 'Not a floating point value');
     }
     return new ValidationResult(true);
 }
コード例 #6
0
 public function process_form($form_values, $data)
 {
     $flash_id = 'fw_ext_contact_form_process';
     if (empty($form_values)) {
         FW_Flash_Messages::add($flash_id, __('Unable to process the form', 'fw'), 'error');
         return;
     }
     $form_id = FW_Request::POST('fw_ext_forms_form_id');
     if (empty($form_id)) {
         FW_Flash_Messages::add($flash_id, __('Unable to process the form', 'fw'), 'error');
     }
     $form = $this->get_db_data($this->get_name() . '-' . $form_id);
     if (empty($form)) {
         FW_Flash_Messages::add($flash_id, __('Unable to process the form', 'fw'), 'error');
     }
     $to = $form['email_to'];
     if (!filter_var($to, FILTER_VALIDATE_EMAIL)) {
         FW_Flash_Messages::add($flash_id, __('Invalid destination email (please contact the site administrator)', 'fw'), 'error');
         return;
     }
     $entry_data = array('form_values' => $form_values, 'shortcode_to_item' => $data['shortcode_to_item']);
     $result = fw_ext_mailer_send_mail($to, $this->get_db_data($this->get_name() . '-' . $form_id . '/subject_message', ''), $this->render_view('email', $entry_data), $entry_data);
     if ($result['status']) {
         FW_Flash_Messages::add($flash_id, $this->get_db_data($this->get_name() . '-' . $form_id . '/success_message', __('Message sent!', 'fw')), 'success');
     } else {
         FW_Flash_Messages::add($flash_id, $this->get_db_data($this->get_name() . '-' . $form_id . '/failure_message', __('Oops something went wrong.', 'fw')) . ' <em style="color:transparent;">' . $result['message'] . '</em>', 'error');
     }
 }
コード例 #7
0
 function process()
 {
     $email = $this->input->post('email');
     $password = $this->input->post('password');
     $name = $this->input->post('name');
     if ($email == '') {
         $this->session->set_flashdata('error', 'Email is required');
         redirect('register');
     }
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $this->session->set_flashdata('error', 'Enter your Valid email id.');
         redirect('register');
     }
     if ($password == '') {
         $this->session->set_flashdata('error', 'Enter your Password');
         redirect('register');
     }
     $data = array('email' => $email, 'password' => $password, 'name' => $name, 'date' => date('d-m-y'), 'status' => '1');
     $sql = "SELECT * FROM user WHERE email='" . $data['email'] . "'";
     $query = $this->db->query($sql);
     if ($query->num_rows() == 0) {
         $this->db->insert('user', $data);
         $this->session->set_flashdata('error', 'Registered Successfully, Thank you !');
         redirect('cart');
     }
     if ($query->num_rows() == 1) {
         $this->session->set_flashdata('error', 'Email Address Aleready Exists');
         redirect('register');
     }
 }
コード例 #8
0
ファイル: App.php プロジェクト: navi15486/MusicMVC
 public function parseUrl()
 {
     if (isset($_GET['url'])) {
         //echo $_GET['url'];
         return $url = explode('/', filter_var(rtrim($_GET['url'], '/'), FILTER_SANITIZE_URL));
     }
 }
コード例 #9
0
ファイル: RedirectFilter.php プロジェクト: reliv/rcm-login
 /**
  * Filter the redirect url
  *
  * @param mixed $value
  * @return string|null
  */
 public function filter($value)
 {
     if (!$this->validator->isValid($value)) {
         return null;
     }
     return urldecode(filter_var($value, FILTER_SANITIZE_URL));
 }
コード例 #10
0
 /**
  * Sets GET and POST into local properties
  */
 public function __construct(&$conf = false)
 {
     // parse vars from URI
     if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING']) {
         $qrystr = str_replace('r=', '', filter_var($_SERVER['QUERY_STRING']));
         if (!strstr($qrystr, 'exe/')) {
             $this->parseUri($qrystr);
         } else {
             $key = explode('/', $qrystr);
             if (isset($key[1])) {
                 $this->_exe = $key[1];
             }
         }
         unset($qrystr);
     }
     // vars from GET
     if ($_GET) {
         while (list($key, $value) = each($_GET)) {
             if ($key != 'r') {
                 $this->{$key} = $value;
             }
         }
     }
     // vars from POST
     if ($_POST) {
         while (list($key, $value) = each($_POST)) {
             $this->{$key} = $value;
         }
     }
     // vars from FILES
     if ($_FILES) {
         $this->setFiles($conf);
     }
 }
コード例 #11
0
ファイル: mergecnf.inc.php プロジェクト: samyscoub/librenms
/**
 * Merge config function
 * @author f0o <*****@*****.**>
 * @copyright 2015 f0o, LibreNMS
 * @license GPL
 * @package LibreNMS
 * @subpackage Config
 */
function mergecnf($obj)
{
    $pointer = array();
    $val = $obj['config_value'];
    $obj = $obj['config_name'];
    $obj = explode('.', $obj, 2);
    if (!isset($obj[1])) {
        if (filter_var($val, FILTER_VALIDATE_INT)) {
            $val = (int) $val;
        } else {
            if (filter_var($val, FILTER_VALIDATE_FLOAT)) {
                $val = (double) $val;
            } else {
                if (filter_var($val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null) {
                    $val = filter_var($val, FILTER_VALIDATE_BOOLEAN);
                }
            }
        }
        if (!empty($obj[0])) {
            return array($obj[0] => $val);
        } else {
            return array($val);
        }
    } else {
        $pointer[$obj[0]] = mergecnf(array('config_name' => $obj[1], 'config_value' => $val));
    }
    return $pointer;
}
コード例 #12
0
ファイル: class.coupon.php プロジェクト: vilmark/vilmark_main
 function record_coupon_application($sub_id = false, $pricing = false)
 {
     global $blog_id;
     $global = defined('MEMBERSHIP_GLOBAL_TABLES') && filter_var(MEMBERSHIP_GLOBAL_TABLES, FILTER_VALIDATE_BOOLEAN);
     // Create transient for 1 hour.  This means the user has 1 hour to redeem the coupon after its been applied before it goes back into the pool.
     // If you want to use a different time limit use the filter below
     $time = apply_filters('membership_apply_coupon_redemption_time', HOUR_IN_SECONDS);
     // Grab the user account as we should be logged in by now
     $user = wp_get_current_user();
     $transient_name = 'm_coupon_' . $blog_id . '_' . $user->ID . '_' . $sub_id;
     $transient_value = array('coupon_id' => $this->_coupon->id, 'user_id' => $user->ID, 'sub_id' => $sub_id, 'prices_w_coupon' => $pricing);
     // Check if a transient already exists and delete it if it does
     if ($global && function_exists('get_site_transient')) {
         $trying = get_site_transient($transient_name);
         if ($trying != false) {
             // We have found an existing coupon try so remove it as we are using a new one
             delete_site_transient($transient_name);
         }
         set_site_transient($transient_name, $transient_value, $time);
     } else {
         $trying = get_transient($transient_name);
         if ($trying != false) {
             // We have found an existing coupon try so remove it as we are using a new one
             delete_transient($transient_name);
         }
         set_transient($transient_name, $transient_value, $time);
     }
 }
コード例 #13
0
 /**
  * Constructor
  * @since Version 3.9
  * @param int $routeId
  * @param object $gtfsProvider
  */
 public function __construct($routeId = null, $gtfsProvider = null)
 {
     if (function_exists("getRailpageConfig")) {
         $this->Config = getRailpageConfig();
     }
     $this->adapter = new Adapter(array("driver" => "Mysqli", "database" => $this->Config->GTFS->PTV->db_name, "username" => $this->Config->GTFS->PTV->db_user, "password" => $this->Config->GTFS->PTV->db_pass, "host" => $this->Config->GTFS->PTV->db_host));
     $this->db = new Sql($this->adapter);
     if (is_object($gtfsProvider)) {
         $this->Provider = $gtfsProvider;
     }
     /**
      * Fetch the route
      */
     if (!filter_var($routeId, FILTER_VALIDATE_INT)) {
         return;
     }
     $query = sprintf("SELECT route_id, route_short_name, route_long_name, route_desc, route_type, route_url, route_color, route_text_color FROM %s_routes WHERE id = %s", $this->Provider->getDbPrefix(), $routeId);
     $result = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
     if (!is_array($result)) {
         return;
     }
     foreach ($result as $row) {
         $row = $row->getArrayCopy();
         $this->id = $routeId;
         $this->route_id = $row['route_id'];
         $this->short_name = $row['route_short_name'];
         $this->long_name = $row['route_long_name'];
         $this->desc = $row['route_desc'];
         $this->type = $row['route_type'];
     }
 }
コード例 #14
0
ファイル: owlcarousel.php プロジェクト: em222iv/eerie
function submenu_parameters()
{
    $isWordpressGallery = filter_var(get_option('owl_carousel_wordpress_gallery', false), FILTER_VALIDATE_BOOLEAN) ? 'checked' : '';
    $orderBy = get_option('owl_carousel_orderby', 'post_date');
    $orderByOptions = array('post_date', 'title');
    echo '<div class="wrap owl_carousel_page">';
    echo '<?php update_option("owl_carousel_wordpress_gallery", $_POST["wordpress_gallery"]); ?>';
    echo '<h2>' . __('Owl Carousel parameters', 'owl-carousel-domain') . '</h2>';
    echo '<form action="' . plugin_dir_url(__FILE__) . 'save_parameter.php" method="POST" id="owlcarouselparameterform">';
    echo '<h3>' . __('Wordpress Gallery', 'owl-carousel-domain') . '</h3>';
    echo '<input type="checkbox" name="wordpress_gallery" ' . $isWordpressGallery . ' />';
    echo '<label>' . __('Use Owl Carousel with Wordpress Gallery', 'owl-carousel-domain') . '</label>';
    echo '<br />';
    echo '<label>' . __('Order Owl Carousel elements by ', 'owl-carousel-domain') . '</label>';
    echo '<select name="orderby" />';
    foreach ($orderByOptions as $option) {
        echo '<option value="' . $option . '" ' . ($option == $orderBy ? 'selected="selected"' : '') . '>' . $option . '</option>';
    }
    echo '</select>';
    echo '<br />';
    echo '<br />';
    echo '<input type="submit" class="button-primary owl-carousel-save-parameter-btn" value="' . __('Save changes', 'owl-carousel-domain') . '" />';
    echo '<span class="spinner"></span>';
    echo '</form>';
    echo '</div>';
}
コード例 #15
0
 /**
  * Import command
  *
  * @param string $icsCalendarUri
  * @param int    $pid
  */
 public function importCommand($icsCalendarUri = NULL, $pid = NULL)
 {
     if ($icsCalendarUri === NULL || !filter_var($icsCalendarUri, FILTER_VALIDATE_URL)) {
         $this->enqueueMessage('You have to enter a valid URL to the iCalendar ICS', 'Error', FlashMessage::ERROR);
     }
     if (!MathUtility::canBeInterpretedAsInteger($pid)) {
         $this->enqueueMessage('You have to enter a valid PID for the new created elements', 'Error', FlashMessage::ERROR);
     }
     // fetch external URI and write to file
     $this->enqueueMessage('Start to checkout the calendar: ' . $icsCalendarUri, 'Calendar', FlashMessage::INFO);
     $relativeIcalFile = 'typo3temp/ical.' . GeneralUtility::shortMD5($icsCalendarUri) . '.ical';
     $absoluteIcalFile = GeneralUtility::getFileAbsFileName($relativeIcalFile);
     $content = GeneralUtility::getUrl($icsCalendarUri);
     GeneralUtility::writeFile($absoluteIcalFile, $content);
     // get Events from file
     $icalEvents = $this->getIcalEvents($absoluteIcalFile);
     $this->enqueueMessage('Found ' . sizeof($icalEvents) . ' events in the given calendar', 'Items', FlashMessage::INFO);
     $events = $this->prepareEvents($icalEvents);
     $this->enqueueMessage('This is just a first draft. There are same missing fields. Will be part of the next release', 'Items', FlashMessage::ERROR);
     return;
     foreach ($events as $event) {
         $eventObject = $this->eventRepository->findOneByImportId($event['uid']);
         if ($eventObject instanceof Event) {
             // update
             $eventObject->setTitle($event['title']);
             $eventObject->setDescription($this->nl2br($event['description']));
             $this->eventRepository->update($eventObject);
             $this->enqueueMessage('Update Event Meta data: ' . $eventObject->getTitle(), 'Update');
         } else {
             // create
             $eventObject = new Event();
             $eventObject->setPid($pid);
             $eventObject->setImportId($event['uid']);
             $eventObject->setTitle($event['title']);
             $eventObject->setDescription($this->nl2br($event['description']));
             $configuration = new Configuration();
             $configuration->setType(Configuration::TYPE_TIME);
             $configuration->setFrequency(Configuration::FREQUENCY_NONE);
             /** @var \DateTime $startDate */
             $startDate = clone $event['start'];
             $startDate->setTime(0, 0, 0);
             $configuration->setStartDate($startDate);
             /** @var \DateTime $endDate */
             $endDate = clone $event['end'];
             $endDate->setTime(0, 0, 0);
             $configuration->setEndDate($endDate);
             $startTime = $this->dateTimeToDaySeconds($event['start']);
             if ($startTime > 0) {
                 $configuration->setStartTime($startTime);
                 $configuration->setEndTime($this->dateTimeToDaySeconds($event['end']));
                 $configuration->setAllDay(FALSE);
             } else {
                 $configuration->setAllDay(TRUE);
             }
             $eventObject->addCalendarize($configuration);
             $this->eventRepository->add($eventObject);
             $this->enqueueMessage('Add Event: ' . $eventObject->getTitle(), 'Add');
         }
     }
 }
コード例 #16
0
 public function getIndex()
 {
     if ($this->access['is_view'] == 0) {
         return Redirect::to('')->with('message', SiteHelpers::alert('error', ' Your are not allowed to access the page '));
     }
     // Filter sort and order for query
     $sort = !is_null(Input::get('sort')) ? Input::get('sort') : '';
     $order = !is_null(Input::get('order')) ? Input::get('order') : 'asc';
     // End Filter sort and order for query
     // Filter Search for query
     $filter = !is_null(Input::get('search')) ? $this->buildSearch() : '';
     // End Filter Search for query
     $page = Input::get('page', 1);
     $params = array('page' => $page, 'limit' => !is_null(Input::get('rows')) ? filter_var(Input::get('rows'), FILTER_VALIDATE_INT) : static::$per_page, 'sort' => $sort, 'order' => $order, 'params' => $filter, 'global' => isset($this->access['is_global']) ? $this->access['is_global'] : 0);
     // Get Query
     $results = $this->model->getRows($params);
     // Build pagination setting
     $page = $page >= 1 && filter_var($page, FILTER_VALIDATE_INT) !== false ? $page : 1;
     $pagination = Paginator::make($results['rows'], $results['total'], $params['limit']);
     $this->data['rowData'] = $results['rows'];
     // Build Pagination
     $this->data['pagination'] = $pagination;
     // Build pager number and append current param GET
     $this->data['pager'] = $this->injectPaginate();
     // Row grid Number
     $this->data['i'] = $page * $params['limit'] - $params['limit'];
     // Grid Configuration
     $this->data['tableGrid'] = $this->info['config']['grid'];
     $this->data['tableForm'] = $this->info['config']['forms'];
     $this->data['colspan'] = SiteHelpers::viewColSpan($this->info['config']['grid']);
     // Group users permission
     $this->data['access'] = $this->access;
     // Render into template
     $this->layout->nest('content', 'rinvoices.index', $this->data)->with('menus', SiteHelpers::menus());
 }
コード例 #17
0
 /**
  * @param Config $specs
  * @return boolean
  */
 private function isRemoved(Config $specs)
 {
     if ($remove = $specs->get('remove')) {
         return filter_var($remove, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
     }
     return false;
 }
コード例 #18
0
ファイル: SpecShell.php プロジェクト: nojimage/Bdd
 public function main()
 {
     $this->_initDb();
     $cli = new \Console_CommandLine_Result();
     $cli->options = $this->params;
     $cli->args = array('files' => $this->args);
     // Check if we can use colors
     if ($cli->options['color'] === 'auto') {
         $cli->options['color'] = DIRECTORY_SEPARATOR != '\\' && function_exists('posix_isatty') && @posix_isatty(STDOUT);
     } else {
         $cli->options['color'] = filter_var($cli->options['color'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
     }
     if (empty($cli->args['files'])) {
         $cli->args['files'] = array(ROOT . DS . 'spec');
     }
     if (!($cli->options['verbose'] || $cli->options['debug'])) {
         set_error_handler(array($this, 'skipWarning'), E_WARNING | E_NOTICE);
     }
     if ($cli->options['dump']) {
         $module = new DrSlump\Spec\Cli\Modules\Dump($cli);
         $module->run();
     } else {
         $module = new DrSlump\Spec\Cli\Modules\Test($cli);
         $module->run();
     }
 }
コード例 #19
0
ファイル: AuthController.php プロジェクト: thaida/CMS
 /**
  * Handle a login request to the application.
  *
  * @param  App\Http\Requests\LoginRequest  $request
  * @param  App\Services\MaxValueDelay  $maxValueDelay
  * @param  Guard  $auth
  * @return Response
  */
 public function postLogin(LoginRequest $request, Guard $auth)
 {
     $logValue = $request->input('log');
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return redirect('/auth/login')->with('error', trans('front/login.maxattempt'))->withInput($request->only('log'));
     }
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request->only('log'));
     }
     $user = $auth->getLastAttempted();
     if ($user->confirmed) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, $request->has('memory'));
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         return redirect('/');
     }
     $request->session()->put('user_id', $user->id);
     return redirect('/auth/login')->with('error', trans('front/verify.again'));
 }
コード例 #20
0
ファイル: SessionController.php プロジェクト: boweiliu/seat
 public function postSignIn()
 {
     $email = Input::get('email');
     $password = Input::get('password');
     $remember = Input::get('remember_me');
     $validation = new SeatUserValidator();
     if ($validation->passes()) {
         // Check if we got a username or email for auth
         $identifier = filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
         // Attempt authentication using a email address
         if (Auth::attempt(array($identifier => $email, 'password' => $password), $remember ? true : false)) {
             // If authentication passed, check out if the
             // account is activated. If it is not, we
             // just logout again.
             if (Auth::User()->activated) {
                 return Redirect::back()->withInput();
             } else {
                 // Inactive account means we will not keep this session
                 // logged in.
                 Auth::logout();
                 // Return the session back with the error. We are ok with
                 // revealing that the account is not active as the
                 // credentials were correct.
                 return Redirect::back()->withInput()->withErrors('This account is not active. Please ensure that you clicked the activation link in the registration email.
                     ');
             }
         } else {
             return Redirect::back()->withErrors('Authentication failure');
         }
     }
     return Redirect::back()->withErrors($validation->errors);
 }
コード例 #21
0
ファイル: Email.php プロジェクト: kingsj/core
 /**
  * Validate
  *
  * @param mixed $data Data
  *
  * @return void
  * @throws \XLite\Core\Validator\Exception
  */
 public function validate($data)
 {
     parent::validate($data);
     if (0 < strlen($data) && false === filter_var($data, FILTER_VALIDATE_EMAIL)) {
         throw $this->throwError('Not an email address');
     }
 }
コード例 #22
0
 public function service()
 {
     $userManager = new UserManager($this->config, $this->args);
     $email = strtolower($this->secure($_REQUEST["email"]));
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $jsonArr = array('status' => "err", "errText" => $this->getPhrase(471));
         echo json_encode($jsonArr);
         return false;
     }
     $customer = $userManager->getCustomerByEmail($email);
     if ($customer != null) {
         $emailSenderManager = new EmailSenderManager('gmail');
         $customerEmail = $customer->getEmail();
         $userName = $customer->getName();
         $password = $customer->getPassword();
         $subject = "Your PcStore Password!";
         $templateId = "customer_forgot_password";
         $params = array("name" => $userName, "password" => $password);
         $emailSenderManager->sendEmail('support', $customerEmail, $subject, $templateId, $params);
         $jsonArr = array('status' => "ok", "message" => "Your password sent to your " . $email . " email.\nPlease check your email.");
         echo json_encode($jsonArr);
         return true;
     } else {
         $jsonArr = array('status' => "err", "errText" => $this->getPhrase(381));
         echo json_encode($jsonArr);
         return false;
     }
 }
コード例 #23
0
ファイル: include.php プロジェクト: kelsh/classic
function replace_input($input)
{
    $output = stripslashes($input);
    $output = filter_var($output, FILTER_SANITIZE_SPECIAL_CHARS);
    $output = trim($output, "/");
    return $output;
}
コード例 #24
0
 /**
  * Initializes a TCP stream resource.
  *
  * @param ParametersInterface $parameters Initialization parameters for the connection.
  *
  * @return resource
  */
 protected function tcpStreamInitializer(ParametersInterface $parameters)
 {
     if (!filter_var($parameters->host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
         $uri = "tcp://{$parameters->host}:{$parameters->port}";
     } else {
         $uri = "tcp://[{$parameters->host}]:{$parameters->port}";
     }
     $flags = STREAM_CLIENT_CONNECT;
     if (isset($parameters->async_connect) && (bool) $parameters->async_connect) {
         $flags |= STREAM_CLIENT_ASYNC_CONNECT;
     }
     if (isset($parameters->persistent) && (bool) $parameters->persistent) {
         $flags |= STREAM_CLIENT_PERSISTENT;
         $uri .= strpos($path = $parameters->path, '/') === 0 ? $path : "/{$path}";
     }
     $resource = @stream_socket_client($uri, $errno, $errstr, (double) $parameters->timeout, $flags);
     if (!$resource) {
         $this->onConnectionError(trim($errstr), $errno);
     }
     if (isset($parameters->read_write_timeout)) {
         $rwtimeout = (double) $parameters->read_write_timeout;
         $rwtimeout = $rwtimeout > 0 ? $rwtimeout : -1;
         $timeoutSeconds = floor($rwtimeout);
         $timeoutUSeconds = ($rwtimeout - $timeoutSeconds) * 1000000;
         stream_set_timeout($resource, $timeoutSeconds, $timeoutUSeconds);
     }
     if (isset($parameters->tcp_nodelay) && function_exists('socket_import_stream')) {
         $socket = socket_import_stream($resource);
         socket_set_option($socket, SOL_TCP, TCP_NODELAY, (int) $parameters->tcp_nodelay);
     }
     return $resource;
 }
コード例 #25
0
 /**
  * Validate an email address
  * http://stackoverflow.com/questions/12026842/how-to-validate-an-email-address-in-php
  */
 private function validEmail($email)
 {
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         return false;
     }
     return true;
 }
コード例 #26
0
 public function save_user()
 {
     $errors = array();
     $this->load->model('Extravaganza_model', 'Extravaganza');
     $data = array('names' => $this->input->post('names'), 'email' => trim($this->input->post('email')), 'document' => trim($this->input->post('document')), 'phone' => trim($this->input->post('phone')), 'store' => $this->input->post('store'), 'passaport' => $this->input->post('passaport'), 'date_register' => date('Y-m-d H:i:s'));
     if (empty($data['names'])) {
         $errors[] = 'names';
     }
     if (empty($data['email']) || !filter_var($data['email'], FILTER_VALIDATE_EMAIL) || $this->Extravaganza->get_user_by_email($data['email'])) {
         $errors[] = 'email';
     }
     if (empty($data['document'])) {
         $errors[] = 'document';
     } else {
         if ($this->Extravaganza->get_user_by_document($data['document'])) {
             $errors[] = 'document';
         }
     }
     if (empty($data['phone'])) {
         $errors[] = 'phone';
     }
     if (empty($data['store'])) {
         $errors[] = 'store';
     }
     if (empty($data['passaport'])) {
         $errors[] = 'passaport';
     }
     if (empty($errors)) {
         $this->Extravaganza->save($data);
         echo json_encode(['success' => true]);
     } else {
         echo json_encode($errors);
     }
 }
 public function get_paged_jobs()
 {
     $paged = isset($_GET['paged']) ? filter_var($_GET['paged'], FILTER_SANITIZE_NUMBER_INT) : '';
     $paged = $paged ? $paged : 1;
     $per_page = $this->jobs_per_page;
     return array_slice($this->translation_jobs, ($paged - 1) * $per_page, $per_page);
 }
コード例 #28
0
ファイル: Utilities.php プロジェクト: BookOfOrigin/Ori
 public static function ValidateEmail($email = null)
 {
     if ($email !== null && filter_var($email, FILTER_VALIDATE_EMAIL)) {
         return true;
     }
     return false;
 }
コード例 #29
0
ファイル: form.php プロジェクト: svetel/wp-calendar-plugin
 public function validateEmail($email)
 {
     if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
         return TRUE;
     }
     return FALSE;
 }
コード例 #30
0
ファイル: functions_list.php プロジェクト: cfhb/nctfonline
function createAccount($pUsername, $pPassword, $pMail)
{
    global $dbc;
    // First check we have data passed in.
    if (!empty($pUsername) && !empty($pPassword) && !empty($pPassword) && !empty($pMail)) {
        $uLen = strlen($pUsername);
        $pLen = strlen($pPassword);
        // escape the $pUsername to avoid SQL Injections
        $eUsername = mysqli_real_escape_string($dbc, $pUsername);
        $sql = "SELECT username FROM nctf_accounts WHERE username = '******' LIMIT 1";
        // Note the use of trigger_error instead of or die.
        $query = mysqli_query($dbc, $sql) or trigger_error("Query Failed: " . mysql_error());
        $ip = get_ip();
        // Error checks (Should be explained with the error)
        if ($uLen <= 4 || $uLen >= 16) {
            $_SESSION['error'] = "Username must be between 5 and 11 characters.";
        } elseif ($pLen < 6) {
            $_SESSION['error'] = "Password must be longer then 6 characters.";
        } elseif (!filter_var($pMail, FILTER_VALIDATE_EMAIL)) {
            $_SESSION['error'] = "Invaild Email address.";
        } elseif (mysqli_num_rows($query) == 1) {
            $_SESSION['error'] = "Username already exists.";
        } else {
            $sql = "INSERT INTO nctf_accounts (`username`, `password`, `mail`,`register_time`,`register_ip`) VALUES ('" . $eUsername . "', '" . hashPassword($pPassword) . "','" . $pMail . "',now(),'" . $ip . "');";
            //echo $sql;
            $query = mysqli_query($dbc, $sql) or trigger_error("Query Failed: " . mysql_error());
            if ($query) {
                return true;
            }
        }
    }
    return false;
}