is_valid() публичный статический Метод

Shorthand method for inline validation.
public static is_valid ( array $data, array $validators ) : mixed
$data array The data to be validated
$validators array The GUMP validators
Результат mixed True(boolean) or the array of error messages
Пример #1
0
 public function delete()
 {
     $options = WebApp::post('options') === NULL ? array() : strgetcsv(WebApp::post('options'));
     if (count($options) == 0) {
         return new ActionResult($this, '/admin/core/option_view', 0, 'No option(s) were selected!', B_T_FAIL);
     }
     foreach ($options as $option) {
         $validated = GUMP::is_valid(array('opt' => $option), array('opt' => 'integer'));
         if ($validated !== true) {
             return new ActionResult($this, '/admin/core/option_view', 0, 'No option(s) were selected!', B_T_FAIL);
         }
     }
     $delete = $this->mySQL_w->prepare("DELETE FROM `core_options` WHERE `id`=?");
     $affected_rows = 0;
     foreach ($options as $id) {
         $delete->bind_param('i', $id);
         $delete->execute();
         $delete->store_result();
         $affected_rows += $delete->affected_rows;
     }
     if ($affected_rows == count($options)) {
         $this->parent->parent->logEvent($this::name_space, 'Deleted options: ' . csvgetstr($options));
         return new ActionResult($this, '/admin/core/option_view', 1, 'Successfully deleted selected option(s)!', B_T_SUCCESS);
     } else {
         $this->parent->parent->logEvent($this::name_space, 'Deleted some options: ' . csvgetstr($options));
         return new ActionResult($this, '/admin/core/option_view', 1, 'Successfully deleted ' . $affected_rows . '/' . count($options) . ' selected option(s)!<br /><small>Possible cause: <code>Unknown</code></small>', B_T_WARNING);
     }
 }
Пример #2
0
 public static function validate($validation, $value, $type)
 {
     $rules = array('required');
     if (array_key_exists('email', $validation)) {
         array_push($rules, 'valid_email');
     }
     if (array_key_exists('starts', $validation)) {
         array_push($rules, 'starts,' . $validation['starts']);
     }
     if (array_key_exists('regex', $validation)) {
         $regex = is_array($validation['regex']) ? implode(',', $validation['regex']) : $validation['regex'];
         error_log($regex);
         error_log($value);
         if (!preg_match($regex, $value)) {
             return false;
         }
     }
     if ($type == 'string') {
         if (array_key_exists('maxLength', $validation)) {
             array_push($rules, 'max_len,' . $validation['maxLength']);
         }
         if (array_key_exists('minLength', $validation)) {
             if ($validation['minLength'] === 0 && strlen($value) == 0) {
                 return true;
             }
             array_push($rules, 'min_len,' . $validation['minLength']);
         }
     } else {
         if ($type == 'integer' || $type == 'timestamp') {
             if ($type == 'integer') {
                 array_push($rules, 'integer');
             }
             if (array_key_exists('min', $validation)) {
                 array_push($rules, 'min_numeric,' . $validation['min']);
             }
             if (array_key_exists('max', $validation)) {
                 array_push($rules, 'max_numeric,' . $validation['max']);
             }
         }
     }
     if (count($rules) == 1) {
         return true;
     }
     $valid = \GUMP::is_valid(array('temp' => $value), array('temp' => implode('|', $rules)));
     return $valid === true;
 }
 /**
  * @param array $params
  * @param array $files
  * @return array
  */
 public function run($params = array(), $files = array())
 {
     // Siga esse modelo para retornar erros
     $error = array("error" => false, "errorInfo" => "", "errorDesc" => "", "errorFields" => array());
     // Roda validação de campos simples
     foreach ($this->postRules as $field => $rule) {
         $data = array();
         $data[$field] = $rule;
         $validated = \GUMP::is_valid($params, $data);
         if ($validated !== true) {
             $error['errorFields'][] = $field;
         }
     }
     foreach ($this->fileRules as $field => $rule) {
         if (isset($files[$field]['name']) && !empty($files[$field]['name'])) {
             $storage = new FileSystem('public/uploads', BASEPATH);
             $file = new File($field, $storage);
             $file->setName(uniqid());
             $file->addValidations(array(new \Upload\Validation\Extension($rule['extension']), new \Upload\Validation\Size($rule['size'])));
             $name = $file->getNameWithExtension();
             try {
                 $file->upload();
                 $params[$field] = $name;
             } catch (\Exception $e) {
                 $error['errorFields'][] = $field;
             }
         } else {
             if (!isset($params[$field]) || empty($params[$field])) {
                 $error['errorFields'][] = $field;
             }
         }
     }
     if (!empty($error['errorFields'])) {
         $error['error'] = true;
         $error['errorInfo'] = "Erro ao salvar registro.";
         $error['errorDesc'] = "Preencha todos os campos corretamente";
         return array_merge_recursive($error, $params);
     } else {
         // Roda os tratamentos
         return $this->treatment($params, $files);
     }
 }
Пример #4
0
#!/usr/bin/php -q
<?php 
error_reporting(-1);
ini_set('display_errors', 1);
require "../gump.class.php";
$data = array('street' => '6 Avondans Road');
$validated = GUMP::is_valid($data, array('street' => 'required|street_address'));
if ($validated === true) {
    echo "Valid Street Address\n";
} else {
    print_r($validated);
}
Пример #5
0
#!/usr/bin/php -q
<?php 
error_reporting(-1);
ini_set('display_errors', 1);
require "../gump.class.php";
$data = array('one' => 'Freiheit, Mobilität und Unabhängigkeit lebt. ö, Ä, é, or ß', 'two' => 'ß');
$validated = GUMP::is_valid($data, array('one' => 'required|min_len,10', 'two' => 'required|min_len,1'));
if ($validated === true) {
    echo "Valid Text\n";
} else {
    print_r($validated);
}
Пример #6
0
#!/usr/bin/php -q
<?php 
error_reporting(-1);
ini_set('display_errors', 1);
require "../gump.class.php";
$data = array('str' => null);
$rules = array('str' => 'required');
GUMP::set_field_name("str", "Street");
$validated = GUMP::is_valid($data, $rules);
if ($validated === true) {
    echo "Valid Street Address\n";
} else {
    print_r($validated);
}
Пример #7
0
function sendMailchimp($formData, $config)
{
    $validated = GUMP::is_valid($formData, array('newsletter-name' => 'required', 'newsletter-email' => 'required|valid_email'));
    if ($validated === true) {
        $Mailchimp = new Mailchimp($config['mailchimp_api_key']);
        $Mailchimp_Lists = new Mailchimp_Lists($Mailchimp);
        $email = $formData['newsletter-email'];
        //replace with a test email
        $name = $formData['newsletter-name'];
        //replace with a test email
        try {
            $subscriber = $Mailchimp_Lists->subscribe($config['mailchimp_list_id'], array('email' => $email, 'name' => $name));
            //pass the list id and email to mailchimp
        } catch (Exception $e) {
            $result = array('result' => 'error', 'msg' => $e->getMessage());
            return json_encode($result);
        }
        // check that we've succeded
        if (!empty($subscriber['leid'])) {
            $result = array('result' => 'success', 'msg' => array('Success! Thank you for signing up to our newsletter.'));
            return json_encode($result);
        }
    } else {
        $result = array('result' => 'error', 'msg' => $validated);
        return json_encode($result);
    }
}
Пример #8
0
<?php

if (WebApp::get('cat4') !== NULL) {
    $option_query = $mySQL_r->prepare("SELECT `core_ip`.`ID`,`time`, CONCAT(`f_name`, ' ', `s_name`, ' (', `username`, ')'),  INET_NTOA(`ip`), `length`,`reason` FROM `core_ip`\nLEFT JOIN `core_users`\nON `user_id`=`core_users`.`id`\nWHERE `core_ip`.`ID`=?\n");
    if (GUMP::is_valid(array('id' => WebApp::get('cat4')), array('id' => 'required|integer'))) {
        $id = WebApp::get('cat4');
        $option_query->bind_param('i', $id);
        $option_query->execute();
        $option_query->bind_result($block_id, $time, $user, $ip, $length, $reason);
        $option_query->store_result();
        if ($option_query->num_rows == 1) {
            $option_query->fetch();
        } else {
            $page->setStatus(404);
            return;
        }
    } else {
        $page->setStatus(404);
        return;
    }
} else {
    $page->setStatus(404);
    return;
}
$closeBtn = array('a' => array('t' => 'url', 'a' => '../ipblock_view'), 'ic' => 'remove-sign');
$saveBtn = array('s' => B_T_SUCCESS, 'a' => array('t' => 'url', 'a' => '#', 'oc' => 'processForm(\'ipblock_edit\', this, \'save\')'), 'ic' => 'floppy-disk');
$applyBtn = array('s' => B_T_PRIMARY, 'a' => array('t' => 'url', 'a' => '#', 'oc' => 'processForm(\'ipblock_edit\', this, \'apply\')'), 'ic' => 'ok-sign');
$form = $page->getPlugin('form', array('ipblock_edit', WebApp::action('core', 'ipblock_edit', true), 'post'));
$form->setColumns(2, 6)->setIndent('    ')->addTextField('Block ID', 'id', $block_id, array(), array('ro' => true))->addTextField('Block Created', 'time', date(DATET_LONG, strtotime($time)), array('t' => 'Time the block was created'), array('ro' => true))->addTextField('User', 'user', $user, array('t' => 'User that created the block.'), array('ro' => true))->addTextField('IP Address', 'ip', $ip, array('t' => 'IP Address to block.', 'p' => 'xyz.xyz.xyz.xyz'), array('ro' => true))->addTextField('Length', 'length', $length, array('t' => 'Length of block in days.', 'p' => 'Days to block'), array('v' => true, 'vm' => array('textfieldRequiredMsg' => array('m' => 'Length of block is required.', 's' => 'danger')), 'vo' => 'validateOn:["blur"]', 'd' => false, 'r' => true, 'vt' => 'integer', 't' => 'number'))->addTextField('Reason', 'reason', $reason, array('t' => 'Reason for block.', 'p' => 'Reason'), array('v' => true, 'vm' => array('textfieldRequiredMsg' => array('m' => 'A Reason is required.', 's' => B_T_FAIL), 'textfieldMinCharsMsg' => array('m' => 'A Reason is required.', 's' => B_T_FAIL), 'textfieldMaxCharsMsg' => array('m' => 'Reason is limited to 255 chars.', 's' => B_T_FAIL)), 'vo' => 'minChars: 0, maxChars: 255, validateOn:["blur"]', 'r' => true))->addBtnLine(array('close' => $closeBtn, 'save' => $saveBtn, 'apply' => $applyBtn));
$form->build();
?>
Пример #9
0
 	{
 	    $validated_data[$key] = htmlentities($val);
 	}
 }
 echo '<pre>';var_dump($validated_data);echo '</pre>';
 */
 if ($validated_data === false) {
     $errors = $gump->validate($app->request->post(), $validation_rules_2);
     if (!is_array($errors)) {
         $errors = [];
     }
     $validate_username = GUMP::is_valid(['username' => $app->request->post('username')], ['username' => 'istaken']);
     if ($validate_username !== true) {
         $errors[] = array('field' => 'username', 'value' => '', 'rule' => 'validate_istaken', 'param' => '');
     }
     $validate_email = GUMP::is_valid(['email' => $app->request->post('email')], ['email' => 'istaken']);
     if ($validate_email !== true) {
         $errors[] = array('field' => 'email', 'value' => '', 'rule' => 'validate_istaken', 'param' => '');
     }
     if ($app->request->post('password') !== $app->request->post('password_confirm')) {
         $errors[] = array('field' => 'password_confirm', 'value' => '', 'rule' => 'validate_password_confirm', 'param' => '');
     }
     if (is_array($errors)) {
         foreach ($errors as $k => $v) {
             $transfield = $app->translator->trans('user.signup.form.' . $v['field']);
             $transerrors[$v['field']][] = $app->translator->trans('user.error.' . $v['rule'] . ' %field% %param%', ['%field%' => $transfield, '%param%' => $v['param']]);
         }
     }
     $app->render('login/signup.php', ['errors' => $errors, 'transerrors' => $transerrors, 'post' => $post]);
 } else {
     # TODO try catch loop
Пример #10
0
session_start();
$gump = new GUMP();
$_POST = $gump->sanitize($_POST);
// You don't have to sanitize, but it's safest to do so.
$gump->validation_rules(array('depart' => 'required|max_len,90|min_len,5', 'destination' => 'required|max_len,90|min_len,5', 'passager' => 'required|max_len,40|min_len,5', 'retour' => 'required|alpha_dash|max_len,20|min_len,4', 'clientName' => 'required|alpha_space|max_len,40|min_len,2', 'clientEmail' => 'required|valid_email', 'clientTel' => 'required|numeric|max_len,15|min_len,5', 'clientType' => 'required|max_len,90|min_len,4', 'clientPickUP' => 'required|date', 'clientPickTimeHUP' => 'required|numeric|max_len,2', 'clientPickTimeMUP' => 'required|numeric|max_len,2'));
$validated_data = $gump->run($_POST);
if ($validated_data === false) {
    $chaine = "Les données entrées sont erronés : <br>";
    foreach ($gump->get_errors_array() as $strings) {
        $chaine = $chaine . $strings . '<br>';
    }
    $_SESSION['aERROR'] = $chaine;
    Redirect('reservation.php', false);
} else {
    if ($_POST['retour'] == "Aller-Retour" && (!isset($_POST['clientPickBackUP']) || !isset($_POST['clientPickBackTimeHUP']) || !isset($_POST['clientPickBackTimeMUP']))) {
        $is_valid = GUMP::is_valid($_POST, array('clientPickBackUP' => 'required|date', 'clientPickBackTimeHUP' => 'required|numeric|max_len,2', 'clientPickBackTimeMUP' => 'required|numeric|max_len,2'));
        if (!($is_valid === true)) {
            $_SESSION['aERROR'] = "Vous avez choisi un Aller-Retour mais vous n'avez pas spécifié le champ <strong>Temps Retour</strong> ";
            Redirect('reservation.php', false);
        }
    }
    $consumer = new Consumer();
    $consumer->setName($_POST['clientName']);
    $consumer->setEmail($_POST['clientEmail']);
    $consumer->setTelephone($_POST['clientTel']);
    $consumer->setType(getConsumerTypeByName($_POST['clientType']));
    EManager::getEntityManager()->persist($consumer);
    EManager::getEntityManager()->flush();
    $station_depart = getStationObjByName($_POST['depart']);
    $station_destination = getStationObjByName($_POST['destination']);
    $reservation = new Reservation();
Пример #11
0
#!/usr/bin/php -q
<?php 
require "../gump.class.php";
$_FILES = array('attachments' => array('name' => array("test1.png"), 'type' => array("image/png"), 'tmp_name' => array("/tmp/phpmFkEUe"), 'error' => array(0), 'size' => array(9855)));
$errors = array();
$length = count($_FILES['attachments']['name']);
for ($i = 0; $i < $length; $i++) {
    $struct = array('name' => $_FILES['attachments']['name'][$i], 'type' => $_FILES['attachments']['type'][$i], 'tmp_name' => $_FILES['attachments']['tmp_name'][$i], 'error' => $_FILES['attachments']['error'][$i], 'size' => $_FILES['attachments']['size'][$i]);
    $validated = GUMP::is_valid($struct, array('name' => 'required', 'type' => 'required', 'tmp_name' => 'required', 'size' => 'required|numeric'));
    if ($validated !== true) {
        $errors[] = $validated;
    }
}
print_r($errors);
Пример #12
0
<?php

include_once 'inc/class.simple_mail.php';
include_once 'inc/gump.class.php';
include_once 'mail-config.php';
// Check Data
$isValid = GUMP::is_valid($_POST, array('first-name' => 'required', 'last-name' => 'required', 'telephone' => 'required', 'email' => 'required', 'message' => 'required'));
if ($isValid === true) {
    // Submit Mail
    $mail = new SimpleMail();
    $mail->setTo(YOUR_EMAIL_ADDRESS, YOUR_COMPANY_NAME)->setSubject('New contact request')->setFrom(htmlspecialchars($_POST['email']), htmlspecialchars($_POST['first-name'] . ' ' . $_POST['last-name']))->addGenericHeader('X-Mailer', 'PHP/' . phpversion())->addGenericHeader('Content-Type', 'text/html; charset="utf-8"')->setMessage(createMessage($_POST))->setWrap(100);
    $mail->send();
    $result = array('result' => 'success', 'msg' => array('Success! Your contact request has been send.'));
    echo json_encode($result);
} else {
    $result = array('result' => 'error', 'msg' => $isValid);
    echo json_encode($result);
}
function createMessage($formData)
{
    $body = "You have got a new contact request from your website : <br><br>";
    $body .= "First Name:  " . htmlspecialchars($formData['first-name']) . " <br><br>";
    $body .= "Last Name:  " . htmlspecialchars($formData['last-name']) . " <br><br>";
    $body .= "Telephone:  " . htmlspecialchars($formData['telephone']) . " <br><br>";
    $body .= "Email:  " . htmlspecialchars($formData['email']) . " <br><br>";
    $body .= "Message: <br><br>";
    $body .= htmlspecialchars($formData['message']);
    return $body;
}
// $mail = new SimpleMail();
// $mail->setTo('*****@*****.**', 'Your Email')
Пример #13
0
 /**
  * This function will validate the modal, and return a bool,
  * also, variable $errors will be fetched.
  * @return bool
  */
 public function validate()
 {
     $this->before_validate();
     $validator = new GUMP();
     $validated = $validator->is_valid($this->export(), $this->rules);
     if ($validated === true) {
         //check for addition validate
         $all_good = $this->after_validate();
         if ($all_good == true) {
             return true;
         } else {
             //$this->errors = $all_good;
             return false;
         }
     } else {
         $this->errors = $validated;
         return false;
     }
 }
Пример #14
0
#!/usr/bin/php -q
<?php 
require "../gump.class.php";
$data = array('guid' => "A98C5A1E-A742-4808-96FA-6F409E799937");
$is_valid = GUMP::is_valid($data, array('guid' => 'required|guidv4'));
if ($is_valid === true) {
    // continue
} else {
    print_r($is_valid);
}
Пример #15
0
 /**
  * checks to see if a model is valid to save to playbook
  *
  * @return bool
  */
 public function isValid()
 {
     $validations = array_merge($this->validation, $this->__defaultValidation);
     $valid = \GUMP::is_valid($this->props, $validations);
     if ($valid !== true) {
         $this->validationErrors = $valid;
         return false;
     }
     return true;
 }
Пример #16
0
#!/usr/bin/php -q
<?php 
require "../gump.class.php";
$data = array('username' => "myusername", 'password' => "mypassword", 'password_confirm' => "mypa33word");
$is_valid = GUMP::is_valid($data, array('username' => 'required|alpha_numeric', 'password' => 'required|max_len,100|min_len,6', 'password_confirm' => 'equalsfield,password'));
if ($is_valid === true) {
    // continue
} else {
    print_r($is_valid);
}
#!/usr/bin/php -q
<?php 
require "../gump.class.php";
// Add the custom validator
GUMP::add_validator("is_object", function ($field, $input, $param = NULL) {
    return is_object($input[$field]);
});
// Generic test data
$input_data = array('not_object' => 5, 'valid_object' => new stdClass());
$rules = array('not_object' => "required|is_object", 'valid_object' => "required|is_object");
// METHOD 1 (Long):
$validator = new GUMP();
$validated = $validator->validate($input_data, $rules);
if ($validated === true) {
    echo "Validation passed!";
} else {
    echo $validator->get_readable_errors(true);
}
// METHOD 2 (Short):
$is_valid = GUMP::is_valid($input_data, $rules);
if ($is_valid === true) {
    echo "Validation passed!";
} else {
    print_r($is_valid);
}
Пример #18
0
<?php

include_once 'inc/class.simple_mail.php';
include_once 'inc/gump.class.php';
require_once 'inc/MCAPI.class.php';
include_once 'mail-config.php';
// Check Data
$isValid = GUMP::is_valid($_POST, array('newsletter-email' => 'required|valid_email'));
if ($mailchimpSupport === true) {
    $mailchimpResult = sendMailchimp($_POST);
} else {
    $mailchimpResult = true;
}
if ($isValid === true && $mailchimpResult === true) {
    // Submit Mail
    $mail = new SimpleMail();
    $mail->setTo(YOUR_EMAIL_ADDRESS, YOUR_COMPANY_NAME)->setSubject('New newsletter subscription')->setFrom(htmlspecialchars($_POST['newsletter-email']), htmlspecialchars($_POST['newsletter-email']))->addGenericHeader('X-Mailer', 'PHP/' . phpversion())->addGenericHeader('Content-Type', 'text/html; charset="utf-8"')->setMessage(createMessage($_POST))->setWrap(100);
    $mail->send();
    $result = array('result' => 'success', 'msg' => array('Success! Thank you for signing up to our newsletter.'));
    echo json_encode($result);
} else {
    if ($isValid === true) {
        $error = array($mailchimpResult);
    } else {
        $error = $isValid;
    }
    $result = array('result' => 'error', 'msg' => $error);
    echo json_encode($result);
}
function createMessage($formData)
{
Пример #19
0
<?php

include_once 'inc/class.simple_mail.php';
include_once 'inc/gump.class.php';
include_once 'mail-config.php';
// Check Data
$isValid = GUMP::is_valid($_POST, array('first-name' => 'required', 'last-name' => 'required', 'phone-number' => 'required', 'email-address' => 'required|valid_email', 'address' => 'required', 'city' => 'required', 'zip-code' => 'required'));
if ($isValid === true) {
    // Submit Mail
    $mail = new SimpleMail();
    $mail->setTo(YOUR_EMAIL_ADDRESS, YOUR_COMPANY_NAME)->setSubject('New car rental request')->setFrom(htmlspecialchars($_POST['email-address']), htmlspecialchars($_POST['first-name'] . ' ' . $_POST['last-name']))->addGenericHeader('X-Mailer', 'PHP/' . phpversion())->addGenericHeader('Content-Type', 'text/html; charset="utf-8"')->setMessage(createMessage($_POST))->setWrap(100);
    $mail->send();
    // Submit Client Mail
    $mailClient = new SimpleMail();
    $mailClient->setTo(htmlspecialchars($_POST['email-address']), htmlspecialchars($_POST['first-name'] . ' ' . $_POST['last-name']))->setSubject('Youre car rental request at ' . YOUR_COMPANY_NAME)->setFrom(YOUR_EMAIL_ADDRESS, YOUR_COMPANY_NAME)->addGenericHeader('X-Mailer', 'PHP/' . phpversion())->addGenericHeader('Content-Type', 'text/html; charset="utf-8"')->setMessage(createClientMessage($_POST))->setWrap(100);
    $mailClient->send();
    $result = array('result' => 'success', 'msg' => array('Success! Your contact request has been send.'));
    echo json_encode($result);
} else {
    $result = array('result' => 'error', 'msg' => $isValid);
    echo json_encode($result);
}
function createMessage($formData)
{
    $body = "You have got a new car rental request from your website : <br><br>";
    $body .= "--------------------------------------------------------------------------------- <br><br>";
    $body .= "<strong>Selected Car:</strong>  " . htmlspecialchars($formData['selected-car']) . " <br><br>";
    $body .= "--------------------------------------------------------------------------------- <br><br>";
    $body .= "<strong>Pick-Up Date/Time:</strong><br>";
    $body .= htmlspecialchars($formData['pick-up']) . " <br>";
    $body .= htmlspecialchars($formData['pickup-location']) . " <br><br>";
Пример #20
0
<?php

$data = array('ip' => WebApp::get('ip'));
$validated = GUMP::is_valid($data, array('ip' => 'valid_ipv4'));
$ip = '';
if ($validated) {
    $ip = WebApp::get('ip');
}
$closeBtn = array('a' => array('t' => 'url', 'a' => 'ipblock_view'), 'ic' => 'remove-sign');
$saveBtn = array('s' => B_T_SUCCESS, 'a' => array('t' => 'url', 'a' => '#', 'oc' => 'processForm(\'ipblock_add\', this, \'save\')'), 'ic' => 'floppy-disk');
$form = $page->getPlugin('form', array('ipblock_add', WebApp::action('core', 'ipblock_add', true), 'post'));
$form->setColumns(2, 6)->setIndent('    ')->addTextField('IP Address', 'ip', $ip, array('t' => 'IP Address to block.', 'p' => 'xyz.xyz.xyz.xyz'), array('v' => true, 'vm' => array('textfieldRequiredMsg' => array('m' => 'An IP Address is required.', 's' => 'danger'), 'textfieldInvalidFormatMsg' => array('m' => 'Please enter a valid IPV4 Adress.', 's' => 'danger')), 'vo' => 'validateOn:["blur"]', 'd' => false, 'r' => true, 'vt' => 'ip', 't' => 'text'))->addTextField('Length', 'length', '', array('t' => 'Length of block in days.', 'p' => 'Days to block'), array('v' => true, 'vm' => array('textfieldRequiredMsg' => array('m' => 'Length of block is required.', 's' => 'danger')), 'vo' => 'validateOn:["blur"]', 'd' => false, 'r' => true, 'vt' => 'integer', 't' => 'number'))->addTextField('Reason', 'reason', '', array('t' => 'Reason for block.', 'p' => 'Reason'), array('v' => true, 'vm' => array('textfieldRequiredMsg' => array('m' => 'A Reason is required.', 's' => B_T_FAIL), 'textfieldMinCharsMsg' => array('m' => 'A Reason is required.', 's' => B_T_FAIL), 'textfieldMaxCharsMsg' => array('m' => 'Reason is limited to 255 chars.', 's' => B_T_FAIL)), 'vo' => 'minChars: 0, maxChars: 255, validateOn:["blur"]', 'r' => true))->addBtnLine(array('close' => $closeBtn, 'save' => $saveBtn));
$form->build();
?>

<div class="row pane">
  <div class="col-xs-12">
    <h1 class="page-header">New Block</h1>
    <?php 
print $form->getForm();
?>
  </div>
</div>
Пример #21
0
<?php

include_once 'inc/class.simple_mail.php';
include_once 'inc/gump.class.php';
include_once 'mail-config.php';
// Check Data
$isValid = GUMP::is_valid($_POST, array('first-name' => 'required', 'phone-number' => 'required', 'guest-email' => 'required', 'message' => 'required', 'point-where' => 'required'));
if ($isValid === true) {
    // Submit Mail
    $mail = new SimpleMail();
    $mail->setTo(YOUR_EMAIL_ADDRESS, YOUR_COMPANY_NAME)->setSubject('Новий клієнт')->setFrom(htmlspecialchars("*****@*****.**"), htmlspecialchars("company-mail"))->addGenericHeader('X-Mailer', 'PHP/' . phpversion())->addGenericHeader('Content-Type', 'text/html; charset="utf-8"')->setMessage(createMessage($_POST))->setWrap(300);
    $mail->send();
    $result = array('result' => 'success', 'msg' => array('Success! Your contact request has been send.'));
    echo json_encode($result);
    return json_encode($result);
} else {
    $result = array('result' => 'error', 'msg' => $isValid);
    echo json_encode($result);
    return json_encode($result);
}
function createMessage($formData)
{
    $body = "У вас новий клієнт : <br><br>";
    $body .= "Ім'я:  " . htmlspecialchars($formData['first-name']) . " <br><br>";
    $body .= "Телефон:  " . htmlspecialchars($formData['phone-number']) . " <br><br>";
    $body .= "Пошта:  " . htmlspecialchars($formData['guest-email']) . " <br><br>";
    $body .= "Повідомлення:  " . htmlspecialchars($formData['message']) . " <br><br>";
    $body .= "Звідки прийшов:  " . htmlspecialchars($formData['point-where']) . " <br><br>";
    return $body;
}
Пример #22
0
 public function backup()
 {
     if (!$this->accessAdminPage(3)) {
         return new ActionResult($this, '/admin/modules/', 1, 'You are not allowed to do that', B_T_FAIL);
     }
     $backups = WebApp::post('backups') === NULL ? array() : strgetcsv(WebApp::post('backups'));
     if (count($backups) == 0) {
         $backups = WebApp::get('m') === NULL ? array() : array(WebApp::get('m'));
     }
     if (count($backups) == 0) {
         return new ActionResult($this, '/admin/modules/backup', 0, 'No module(s) were selected!', B_T_FAIL);
     }
     foreach ($backups as $backup) {
         $validated = GUMP::is_valid(array('bk' => $backup), array('bk' => 'integer'));
         if ($validated !== true) {
             return new ActionResult($this, '/admin/modules/backup', 0, 'No module(s) were selected!', B_T_FAIL);
         }
     }
     $location = __BACKUP__ . DIRECTORY_SEPARATOR . date(DATET_BKUP) . DIRECTORY_SEPARATOR;
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'backup.php';
     $result = array();
     foreach ($backups as $module) {
         $backup = new Backup($this->parent);
         if (!$backup->setLocation($location)) {
             return new CronResult($this, false, 'Failed to create backup dir: ' . DIRECTORY_SEPARATOR . 'backup' . str_replace(__BACKUP__, '', $location . $module));
         }
         if (!$backup->setID($module)) {
             return new CronResult($this, false, 'Failed to setID for ' . $module);
         }
         $results[$module] = $backup->backup();
         unset($backup);
     }
     $msg = '';
     $status = true;
     foreach ($results as $ns => $data) {
         $msg .= '"' . $ns . '": ' . $data['msg'] . PHP_EOL;
         if (!$data['s']) {
             $status = false;
         }
     }
     if ($status) {
         $msg = 'Backup was completed for selected module(s)!';
         $type = B_T_SUCCESS;
     } else {
         $msg = 'Backup was completed but failed for some/all module(s). Details as follows:' . PHP_EOL . $msg;
         $type = B_T_WARNING;
     }
     $this->parent->parent->logEvent($this::name_space, 'Back up modules: ' . csvgetstr($backups));
     return new ActionResult($this, '/admin/modules/backup', 1, $msg, $type);
 }