Example #1
0
 if ($err == '') {
     foreach ($count_plus_one as $tag_plus_one => $count_plus1) {
         if (isset($CONTEXT[$tmp . ':' . $tag_plus_one])) {
             if ($count_plus1 > $CONTEXT_MAX[$tmp . ':' . $tag_plus_one]) {
                 $err = too_many($tmp . ':' . $tag_plus_one);
             } elseif ($count_plus1 < $CONTEXT_MIN[$tmp . ':' . $tag_plus_one]) {
                 $err = too_few($tmp . ':' . $tag_plus_one);
             }
         }
     }
 }
 // Check for missing subordinate tag (ignore custom tags)
 if ($err == '' && isset($CONTEXT[$tmp])) {
     foreach ($CONTEXT_SUB[$tmp] as $sub_tag => $full_sub_tag) {
         if ($CONTEXT_MIN[$full_sub_tag] > 0 && !isset($count_plus_one[$sub_tag])) {
             $err = missing($full_sub_tag);
         }
     }
 }
 if ($err_level >= $warning && $err == '') {
     // WARNING CHECKS - data
     if (strpos($tmp, '_') === false && !preg_match('/^' . $CONTEXT[$tmp] . '$/i', $tag_data)) {
         $err = invalid($pgv_lang['data']);
     } elseif ($tag_level == '0' && $xref != '' && !isset($used_xrefs[$xref . $tag])) {
         $err = $pgv_lang['noref'];
     }
     if ($err_level >= $info && $err == '') {
         // INFOMATIONAL CHECKS - spacing
         if ($whitespace1 != '' || $whitespace2 != ' ' || $whitespace3 == ' ' && $xref == '' || $whitespace4 == ' ' && $tag == '') {
             $err = invalid($pgv_lang['spacing']);
         }
Example #2
0
 // Missing table prefix
 if (missing(array($settings['database']['database'], $settings['database']['username'], $settings['database']['host'], $settings['database']['port'], $settings['database']['table-prefix']))) {
     $errors->append('database', 'Database, Username, Password, Host, Port and Table Prefix are all required fields.');
 }
 // Database doesnt exist
 // Username+Password combo invalid
 // Invalid database host or port
 // Prefix in use
 // User ------------------------------------------------------------------------------------------------------
 $settings['user'] = array_map('trim', $settings['user']);
 // Missing username
 // Missing password
 // Missing first name
 // Missing Last name
 // Missing Email Address
 if (missing(array($settings['user']['username'], $settings['user']['password'], $settings['user']['first-name'], $settings['user']['last-name'], $settings['user']['email-address']))) {
     $errors->append('user', 'Username, Password, First Name, Last Name and Email Address are all required fields.');
 } elseif (preg_match('/[\\s]/i', $settings['user']['username'])) {
     $errors->append('user', 'Username is invalid.');
 } elseif ($settings['user']['password'] != $settings['user']['confirm-password']) {
     $errors->append('user', 'Passwords do not match.');
 } elseif (!preg_match('/^\\w(?:\\.?[\\w%+-]+)*@\\w(?:[\\w-]*\\.)+?[a-z]{2,}$/i', $settings['user']['email-address'])) {
     $errors->append('user', 'Email Address is invalid.');
 }
 if ($errors->length() == 0) {
     /// Create a DB connection --------------------------------------------------------------------------
     $db = new DBCMySQLProfiler();
     $db->character_encoding = 'utf8';
     $db->character_set = 'utf8';
     $db->force_query_caching = false;
     $db->prefix = $settings['database']['table-prefix'];
Example #3
0
 /**
  * Checks if either the specified key is missing from the array or it's corresponding value in the array is
  * empty.
  *
  * @param string|int $key An array key / offset.
  *
  * @return bool True if the key is missing or the corresponding value in the array is empty (null or empty string).
  * @see is_empty()
  */
 function missing($key)
 {
     return missing($this->A, $key);
 }
 /**
  * Checks of a property is bound to a databinding expression.
  *
  * @param string $prop A property name.
  * @return bool
  */
 function isBound($prop)
 {
     return !missing($this->bindings, $prop);
 }
Example #5
0
# Validation
$validations = array('title' => array('type' => 'string', 'required' => TRUE), 'authors' => 'array', 'pub_date' => 'integer', 'pub_name' => 'string', 'vol' => 'string', 'issue' => 'string', 'start_page' => 'integer', 'end_page' => 'integer', 'bib_code' => 'string');
//>>	validate($posted_vars, $validations, 'put_source POST variables' );
// Start aggregating the values that will be inserted into the db
$insert_vars = array();
foreach ($posted_vars as $key => $val) {
    $insert_vars[$key] = $val;
}
# Pick out the first and last name of the first author.  It's used for
# making the bib_code and naming the .pdf
$first_author = $posted_vars['authors'][0];
$last_name = $first_author[0];
$first_name = $first_author[1];
echo var_dump($first_author);
# If the user hasn't set the bib_code, make one from author names and year
if (missing('bib_code')) {
    $bib_code = $posted_vars['pub_date'] . $last_name;
    $bib_code .= time() % 100;
    $insert_vars['bib_code'] = $bib_code;
}
# Validation -- Make sure that the bib_code is unique #
$sql = get_sql_select_query($conn, $TABLE_NAME, array('bib_code' => $bib_code));
$result = mysqli_query($conn, $sql);
if ($err = mysqli_error($conn)) {
    echo '{"success":false, "error":"' . $err . '", "sql":"' . $sql . '"}';
    exit(1);
}
if (mysqli_num_rows($result)) {
    echo '{"success":false, "error":"Ref codes must be unique; ' . $bib_code . ' exists already.", "sql":"' . $sql . '"}';
    exit(2);
}