Esempio n. 1
0
 function call($params)
 {
     $houses = findall(root($this), "House");
     $this->numhouses = count($houses);
     //return json_encode( $houses );
     //return $this->numhouses;
     if (count($houses) > 0) {
         $this->dice1 = rand(1, 6);
         $this->dice2 = rand(1, 6);
         //save to db
         root($this)->db->save($this);
         //root( $this )->db->save( $house );
         return json_encode(clean($this));
     } else {
         //dialog
         return false;
     }
 }
Esempio n. 2
0
function findall($object, $class = "", $param = "", $match = "")
{
    $out = array();
    foreach ($object as $property => $value) {
        if (gettype($value) == "object" and $property != "parent") {
            //if( $out == null ):
            $out += findall($value, $class, $param, $match);
            //endif;
        }
        if (gettype($value) == "array") {
            foreach ($value as $prop => $val) {
                if (gettype($val) == "object") {
                    //if( $out == null ):
                    $out += findall($val, $class, $param, $match);
                    //endif;
                }
            }
        }
    }
    if ($class == "") {
        if (isset($object->{$param}) and $object->{$param} == $match) {
            $out[] = $object;
        }
    } else {
        if (get_class($object) == $class) {
            if ($param == "") {
                $out[] = $object;
            } else {
                if (isset($object->{$param}) and $object->{$param} == $match) {
                    $out[] = $object;
                }
            }
        }
    }
    return $out;
}
Esempio n. 3
0
function date_sep_match($password)
{
    global $date_rx_year_suffix, $date_rx_year_prefix;
    $matches = array();
    foreach (findall($password, $date_rx_year_suffix) as $match) {
        $match['day'] = (int) $match[1];
        $match['month'] = (int) $match[3];
        $match['year'] = (int) $match[4];
        $match['sep'] = $match[2];
        $matches[] = $match;
    }
    foreach (findall($password, $date_rx_year_prefix) as $match) {
        $match['day'] = (int) $match[4];
        $match['month'] = (int) $match[3];
        $match['year'] = (int) $match[1];
        $match['sep'] = $match[2];
        $matches[] = $match;
    }
    $results = array();
    foreach ($matches as $match) {
        list($valid, $date) = check_date($match['day'], $match['month'], $match['year']);
        if (!$valid) {
            continue;
        }
        list($day, $month, $year) = $date;
        $i = $match['i'];
        $j = $match['j'];
        $results[] = array('pattern' => 'date', 'i' => $i, 'j' => $j, 'token' => _slice($password, $i, $j + 1), 'separator' => $match['sep'], 'day' => $day, 'month' => $month, 'year' => $year);
    }
    return $results;
}