public function testInvalid()
 {
     $data = array('username' => 'homer', 'email' => '*****@*****.**', 'zip' => 0, 'street' => '');
     $rules = array('name' => array('required'), 'username' => array('required'), 'zip' => array('required'), 'street' => array('required'));
     $messages = array('name' => 'The name is required', 'street' => 'The street is required');
     $invalid = invalid($data, $rules, $messages);
     $expected = array('name' => 'The name is required', 'street' => 'The street is required');
     $this->assertEquals($expected, $invalid);
 }
Beispiel #2
0
 public function validates()
 {
     $invalid = invalid($this->data, $this->rules, $this->messages);
     if ($invalid) {
         $this->addErrors($invalid);
         $this->saveData();
         return false;
     }
     return true;
 }
Beispiel #3
0
function iter1($x, $y, $tx, $ty)
{
    global $n, $m, $el, $paths, $chp, $newpaths, $newchp;
    if (invalid($tx, $ty)) {
        return;
    }
    $changed = FALSE;
    $oldnewp = 1000000000000;
    for ($i = 9; $i >= 0; --$i) {
        $e = abs($i - $el[$tx][$ty]);
        $newp = min($newpaths[$x][$y][$i][0] + $e, $oldnewp);
        if (!isset($newpaths[$tx][$ty][$i]) || $newp < $newpaths[$tx][$ty][$i][0]) {
            $a = $newpaths[$x][$y][$i][1];
            $a[] = array($tx, $ty);
            $newpaths[$tx][$ty][$i] = array($newp, $a);
            $changed = TRUE;
        }
        $oldnewp = $newp;
    }
    if ($changed) {
        $newchp[] = array($tx, $ty);
    }
}
Beispiel #4
0
function processNormal($id, $action)
{
    global $user, $table;
    $my = (int) $id == (int) $user->id;
    if (!$my && !$user->isAdmin()) {
        invalid();
    }
    if ($action == 'comment') {
        $comment = get($_POST, 'comment');
        if (strlen($comment) > 10000) {
            $comment = substr($comment, 0, 10000);
        }
        query("update {$table['user']} set comment = ? where id = ?", $comment, $id);
    } else {
        if ($action == 'password') {
            if (!$my) {
                invalid();
            }
            $oldp = md5(get($_POST, 'oldp'));
            $newp = md5(get($_POST, 'newp'));
            $q = query("update {$table['user']} set password = ? where id = ? and password = ?", $newp, $id, $oldp);
            if (!$q->num_rows) {
                error(2);
            }
        } else {
            if (!$user->isAdmin()) {
                invalid();
            }
            if ($action == 'admin_comment') {
                $comment = get($_POST, 'admin_comment');
                query("update {$table['user']} set admin_comment = ? where id = ?", $comment, $id);
            } else {
                if ($action == 'ban') {
                    $ban_date = strtotime(get($_POST, 'ban_date'));
                    if (!$ban_date || $ban_date <= time()) {
                        error(3);
                    }
                    $revert = get($_POST, 'ban_revert_all') == '1';
                    $ban_ips = get($_POST, 'ban_ips') == '1';
                    $ban_reason = get($_POST, 'ban_reason');
                    query("update {$table['user']} set ban_date = from_unixtime(?), banned_by = ?, ban_reason = ? where id = ?", $ban_date, $user->id, $ban_reason, $id);
                    if ($revert && !$ban_ips) {
                        revertUserChanges("main.user_id = '{$id}'", $ban_reason);
                    }
                    if ($ban_ips) {
                        $q = query("select distinct user_ip from translation where user_id = ?", $id);
                        $ips = $q->fetchAll();
                        foreach ($ips as $ip) {
                            banIp($ip[0], $ban_date, $ban_reason, $revert, false);
                        }
                    }
                } else {
                    if ($action == 'unban') {
                        $unban_reason = get($_POST, 'ban_reason');
                        query("update {$table['user']} set ban_date = from_unixtime(1), banned_by = ?, ban_reason = ? where id = ?", $user->id, $unban_reason, $id);
                    } else {
                        if ($action == 'promote') {
                            query("update {$table['user']} set role = 'admin' where id = ? and id != 1", $id);
                        } else {
                            if ($action == 'demote') {
                                query("update {$table['user']} set role = 'user' where id = ? and id != 1", $id);
                            } else {
                                invalid();
                            }
                        }
                    }
                }
            }
        }
    }
}
				$year 	= substr($last_seen,0,4);
				$month	= substr($last_seen,5,2);
				$day	= substr($last_seen,6,2);
				$last_seen=mktime(0,0,0,$month,$day,$year);
	*/
            echo "<host>";
            echo "<hostname>" . $hostname . "</hostname>";
            echo "<last_audited>" . $last_seen . "</last_audited>";
            echo "</host>";
        }
        echo "</node>";
    } else {
        $nodata = 0;
        success($nodata);
    }
}
// include config file, also contains the API KEY
require_once '../include/config.php';
require_once '../include/dboa.php';
$api_key = strip_tags($_REQUEST['key']);
$hostname = strip_tags($_REQUEST['hostname']);
$num_rows = '';
// validate api key
if ($api_key != $API_KEY || $api_key == '') {
    invalid();
} else {
    $sql = "SELECT hostname,UNIX_TIMESTAMP(last_seen) FROM system WHERE hostname='{$hostname}'";
    $result = mysql_query($sql);
    $num_rows = mysql_num_rows($result);
    showxml($result, $num_rows);
}
Beispiel #6
0
                 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']);
                 }
             }
             // info
         }
         // warning
     }
     // error
 }
 // critical
 //////////////////////////////////////////////////////////////////////////////
 // Record our current context for error logging and future checks.
 //////////////////////////////////////////////////////////////////////////////
 if ($tag_level == '0' && $tag != '') {
     $curr_xref = $xref;
     $curr_l0tag = $tag;
<?php

return function ($site, $pages, $page) {
    $alert = null;
    $data = array('name' => '', 'email' => '', 'phone' => '', 'text' => '');
    if (get('submit')) {
        $data = array('name' => get('name'), 'email' => get('email'), 'phone' => get('phone'), 'text' => get('text'));
        $rules = array('name' => array('required'), 'email' => array('required', 'email'), 'phone' => array('required', 'num'), 'text' => array('required', 'min' => 3, 'max' => 3000));
        $messages = array('name' => 'Enter a valid name.', 'email' => 'Enter a valid email address.', 'phone' => 'Enter a valid phone number.', 'text' => 'Please fill in the message textarea.');
        // some of the data is invalid
        if ($invalid = invalid($data, $rules, $messages)) {
            $alert = $invalid;
            // the data is fine, let's send the email
        } else {
            // create the body from a simple snippet
            $body = snippet('contactmail', $data, true);
            // build the email
            $email = email(array('to' => $site->email(), 'from' => $data['email'], 'subject' => 'New message from Paradise Construction', 'replyTo' => $data['email'], 'body' => $body));
            // try to send it and redirect to the
            // thank you page if it worked
            if ($email->send()) {
                go('contact/status:thank-you');
                // add the error to the alert list if it failed
            } else {
                $alert = array($email->error());
            }
        }
    }
    return compact('alert', 'data');
};
Beispiel #8
0
return function ($site, $pages, $page) {
    //set variables
    $troubleshootLink = null;
    $typeOfTroubleshoot = null;
    $invalid = null;
    //if $_POST data is present
    if (count($_POST) > 0) {
        //store specific sanitized $_POST variables into $data variable
        $data = r::postData(array('email', 'password'));
        //define validation rules for $data
        $rules = array('email' => array('required', 'email'), 'password' => array('required', 'match' => c::get('password.length.regex')));
        //define validation messages for $data
        $messages = array('email' => l('field.email.validation.message'), 'password' => l('field.password.validaton.message'));
        //if validation is passed
        if (!($invalid = invalid(array_filter($data), $rules, $messages))) {
            //compute user's username (based upon user's email)
            $computedUsername = Auth::computeUsername($data['email']);
            //get user
            $user = Auth::loadUser($computedUsername);
            //if user exists
            if ($user) {
                //get user's activation hash
                //(if user's activation hash is empty -> user is activated, otherwise not)
                //please note: in case the activation procedure is disabled
                //this test evaluates always to true, as if the user was activated
                $isActivated = $user->activation();
                //if user has been activated
                if (empty($isActivated)) {
                    //set login redirect page to tests page
                    $redirect = site()->find(c::get('tests.folder'))->url();
        if (isset($repodateDb['repo_date']) and $repodateDb['repo_date'] != '') {
            $result = invalid($repodateDb['repo_date'], $repodateDb['repo_gedcomnr'], 'repo_date');
        }
        if ($result === true) {
            $found = true;
        }
    }
    if ($found === false) {
        echo '<tr><td colspan=4 style="color:red">No invalid dates found</td></tr>';
    }
    echo '<tr><td colspan="4" style="text-align:' . $direction . ';font-weight:bold">' . __('Invalid source dates:') . '</td></tr>';
    $found = false;
    $sources = $dbh->query("SELECT * FROM humo_sources WHERE source_tree_id='" . $tree_id . "'");
    while ($sourcedateDb = $sources->fetch()) {
        if (isset($sourcedateDb['source_date']) and $sourcedateDb['source_date'] != '') {
            $result = invalid($sourcedateDb['source_date'], $sourcedateDb['source_gedcomnr'], 'source_date');
        }
        if ($result === true) {
            $found = true;
        }
    }
    if ($found === false) {
        echo '<tr><td colspan=4 style="color:red">No invalid dates found</td></tr>';
    }
    echo '</table>';
}
if (isset($_POST['tree']) and (isset($_POST['data_check']) or isset($_POST['unmark']) or isset($_POST['mark_all']))) {
    // displays menu for date consistency check
    // easily set other defaults:
    $b1_def = 50;
    //Birth date - more than X years after mother's birth