コード例 #1
0
 public function __invoke()
 {
     $obj = $this->obj;
     return all(func_get_args())->then(function ($args) use($obj) {
         return call_user_func_array($obj, $args);
     });
 }
コード例 #2
0
 public static function getlist($job_id = null, $output = null, $page = 0, $size = 20)
 {
     $page = int($page);
     $size = int($size);
     if ($size > 100) {
         $size = 100;
     }
     $sql = 'select * from wm_jobs_history ';
     $cond = '';
     $params = [];
     if ($job_id !== null) {
         if (!empty($cond)) {
             $cond += ' and ';
         }
         $cond += 'job_id = :job_id';
         $params[':job_id'] = $job_id;
     }
     if ($output !== null) {
         if (!empty($cond)) {
             $cond += ' and ';
         }
         $cond += 'output = :output';
         $params[':output'] = $output;
     }
     $sql += ' where ' + $cond + ' limit ' + $page * $size + ',' + $size;
     return JobHistoryModel::findBySql($sql, $params) . all();
 }
コード例 #3
0
ファイル: FunctionAllTest.php プロジェクト: reactphp/promise
 /** @test */
 public function shouldPreserveTheOrderOfArrayWhenResolvingAsyncPromises()
 {
     $mock = $this->createCallableMock();
     $mock->expects($this->once())->method('__invoke')->with($this->identicalTo([1, 2, 3]));
     $deferred = new Deferred();
     all([resolve(1), $deferred->promise(), resolve(3)])->then($mock);
     $deferred->resolve(2);
 }
コード例 #4
0
ファイル: do_if.php プロジェクト: akamon/phunctional
/**
 * Returns a callable that will call the given function if the result of applying
 * the callable arguments to the predicates is true for all of them.
 *
 * @since 0.1
 *
 * @param callable   $fn         Function to call if all predicates are valid.
 * @param callable[] $predicates Predicates to validate.
 *
 * @return callable|null
 */
function do_if(callable $fn, array $predicates)
{
    return function (...$args) use($fn, $predicates) {
        $isValid = function ($predicate) use($args) {
            return $predicate(...$args);
        };
        return all($isValid, $predicates) ? $fn(...$args) : null;
    };
}
コード例 #5
0
 public function test_all()
 {
     ensure(all(array(1, 2, 3), function ($v) {
         return $v > 0;
     }));
     ensure(!all(array(1, 2, 3), function ($v) {
         return $v > 2;
     }));
 }
コード例 #6
0
ファイル: validator.php プロジェクト: akilli/qnd
/**
 * Unique validator
 *
 * @param array $attr
 * @param array $item
 *
 * @return bool
 */
function validator_uniq(array $attr, array &$item) : bool
{
    if (empty($attr['uniq']) || !empty($attr['nullable']) && $item[$attr['id']] === null) {
        return true;
    }
    $old = all($item['_entity']['id'], [$attr['id'] => $item[$attr['id']]]);
    if (!$old || count($old) === 1 && !empty($old[$item['_id']])) {
        return true;
    }
    $item['_error'][$attr['id']] = _('%s must be unique', $attr['name']);
    return false;
}
コード例 #7
0
ファイル: section.php プロジェクト: akilli/qnd
/**
 * Node section
 *
 * @param array $§
 *
 * @return string
 */
function section_node(array &$§) : string
{
    if (empty($§['vars']['crit']) || !($menu = one('menu', $§['vars']['crit'])) || !($data = all('node', ['root_id' => $menu['id'], 'project_id' => $menu['project_id']]))) {
        return '';
    }
    $data = array_filter($data, function ($item) use($data) {
        if (strpos($item['target'], 'http') === 0) {
            return true;
        }
        if ($item['target']) {
            return allowed(privilege_url($item['target']));
        }
        foreach ($data as $i) {
            if ($i['lft'] > $item['lft'] && $i['rgt'] < $item['rgt'] && $i['target'] && allowed(privilege_url($i['target']))) {
                return true;
            }
        }
        return false;
    });
    $count = count($data);
    $level = 0;
    $i = 0;
    $html = '';
    foreach ($data as $item) {
        $attrs = [];
        $class = '';
        if ($item['target'] === request('path')) {
            $attrs['class'] = 'active';
            $class .= ' class="active"';
        }
        if ($item['level'] > $level) {
            $html .= '<ul><li' . $class . '>';
        } elseif ($item['level'] < $level) {
            $html .= '</li>' . str_repeat('</ul></li>', $level - $item['level']) . '<li' . $class . '>';
        } else {
            $html .= '</li><li' . $class . '>';
        }
        if ($item['target']) {
            $attrs['href'] = $item['target'];
            $html .= html_tag('a', $attrs, $item['name']);
        } else {
            $html .= html_tag('span', [], $item['name']);
        }
        $html .= ++$i === $count ? str_repeat('</li></ul>', $item['level']) : '';
        $level = $item['level'];
    }
    return $html;
}
コード例 #8
0
ファイル: Tag.php プロジェクト: perminder-klair/kato-core
 /**
  * Returns tag names and their corresponding weights.
  * Only the tags with the top weights will be returned.
  * @param integer the maximum number of tags that should be returned
  * @return array weights indexed by tag names.
  */
 public function findTagWeights($limit = 20)
 {
     $models = self::find()->orderBy('frequency DESC')->limit($limit) - all();
     $total = 0;
     foreach ($models as $model) {
         $total += $model->frequency;
     }
     $tags = [];
     if ($total > 0) {
         foreach ($models as $model) {
             $tags[$model->name] = 8 + (int) (16 * $model->frequency / ($total + 10));
         }
         ksort($tags);
     }
     return $tags;
 }
コード例 #9
0
ファイル: transport.php プロジェクト: WlasnaGra/Tribal
function transport($miasto)
{
    fx('surowce');
    $eventy_karawany = all("select * from tribal_karawany where z_miasta = " . $miasto . "  and koniec <= " . time());
    if (is_array($eventy_karawany)) {
        foreach ($eventy_karawany as $karawana) {
            if ($karawana['status'] == 0) {
                surowce($karawana['do_miasta'], $karawana['drewno'], $karawana['kamien'], $karawana['zelazo'], $karawana['jedzenie'], 0);
                call("update tribal_karawany set status = 1, drewno = 0, kamien = 0, zelazo =0, jedzenie = 0,  start = koniec, koniec = koniec + 3600 where karawana = " . $karawana['karawana']);
            } else {
                surowce($karawana['z_miasta'], $karawana['drewno'], $karawana['kamien'], $karawana['zelazo'], $karawana['jedzenie'], 0);
                call("delete from tribal_karawany  where karawana = " . $karawana['karawana']);
            }
        }
    }
}
コード例 #10
0
ファイル: submission.inc.php プロジェクト: Ashwincy/lattice
function vectorIsTheBestInThisDim($dim, $norm)
{
    require_once 'db.php';
    $res = all();
    $i = 1;
    foreach ($res as $key => $dimarray) {
        foreach ($dimarray as $key => $value) {
            if (strcmp($dim, $value->dim) == 0) {
                if ($norm >= $value->len) {
                    return false;
                }
            }
            $i++;
        }
    }
    return true;
}
コード例 #11
0
ファイル: core.php プロジェクト: WlasnaGra/HellPit
function getPlayer($id)
{
    $player = row("select *, (select count(*) from hellpit_messages where m_type = 1 and m_to = {$id} and m_status - 0) as msg, (select count(*) from hellpit_events where e_pit_id = actual_pit) as events ,(select count(*) from hellpit_events where e_pit_id = actual_pit and e_end <= unix_timestamp()) as end_events , unix_timestamp() as user_time,(select pit_name from hellpit_pits where pit_id = actual_pit)  as actual_pit_name from hellpit_users where user = "******"select * from hellpit_pits where pit_user = "******"Chochlik";
                break;
            case 2:
                $player->rang = "Chowaniec";
                break;
            case 3:
                $player->rang = "Gog";
                break;
            case 4:
                $player->rang = "Magog";
                break;
            case 5:
                $player->rang = "Demon";
                break;
            case 6:
                $player->rang = "Rogaty Demon";
                break;
            case 7:
                $player->rang = "Czart";
                break;
            case 8:
                $player->rang = "Czarci Lord";
                break;
            case 9:
                $player->rang = "Pan Piekieł";
                break;
            default:
                $player->rang = "Szatański Pomiot";
                break;
        }
    } else {
        $player->rang = "Pan Piekieł";
    }
    query("update hellpit_users set last_action = unix_timestamp() where user = " . $id);
    return $player;
}
コード例 #12
0
ファイル: rozwiaz_armie.php プロジェクト: WlasnaGra/Tribal
function rozwiaz_armie($id)
{
    //zabezpiecz zmienne
    $id = (int) $id;
    fx('wiadomosc_wyslij');
    $login = one($q = "select login from tribal_gracze inner join tribal_miasta on gracz_id = gracz inner join tribal_ataki on miasto = miasto_id where atak = " . $id);
    $atak_info = row("select * from tribal_ataki where atak = {$id}");
    $jednostki = all("select * from tribal_ataki_jednostki inner join tribal_ataki a on a.atak = atak_id where atak_id = {$id}");
    if (is_array($jednostki)) {
        foreach ($jednostki as $jednostka) {
            call("update tribal_jednostki_miasta set ilosc = ilosc + " . $jednostka['ilosc'] . " where jednostka_id = " . $jednostka['jednostka_id'] . " and miasto_id = " . $jednostka['miasto_id']);
        }
    }
    call("delete from tribal_ataki_jednostki where atak_id = {$id}");
    call("delete from tribal_ataki where atak = {$id}");
    fx('surowce');
    surowce($atak_info['miasto_id'], $atak_info['drewno'], $atak_info['kamien'], $atak_info['zelazo'], $atak_info['jedzenie'], 0);
    fx('raport');
    $a = raport($login, "Armia powróciła do miasta ,rozładowano " . $atak_info['drewno'] . " drewna,  " . $atak_info['kamien'] . " kamienia,  " . $atak_info['zelazo'] . " żelaza i " . $atak_info['jedzenie'] . " jedzenia");
}
コード例 #13
0
ファイル: rozwiaz_armie.php プロジェクト: WlasnaGra/Tribal2
function rozwiaz_armie($id)
{
    //zabezpiecz zmienne
    $id = (int) $id;
    require_once 'wiadomosc_wyslij.php';
    $login = mysql_fetch_array(mysql_query("select login from tribal_gracze inner join tribal_miasta on gracz_id = gracz inner join tribal_ataki on miasto = miasto_id where atak = " . $id));
    $login = $login[0];
    $atak_info = mysql_fetch_array(mysql_query("select * from tribal_ataki where atak = {$id}"));
    $jednostki = all("select * from tribal_ataki_jednostki inner join tribal_ataki a on a.atak = atak_id where atak_id = {$id}");
    if (is_array($jednostki)) {
        foreach ($jednostki as $jednostka) {
            mysql_query("update tribal_jednostki_miasta set ilosc = ilosc + " . $jednostka['ilosc'] . " where jednostka_id = " . $jednostka['jednostka_id'] . " and miasto_id = " . $jednostka['miasto_id']);
        }
    }
    mysql_query("delete from tribal_ataki_jednostki where atak_id = {$id}");
    mysql_query("delete from tribal_ataki where atak = {$id}");
    require_once 'surowce.php';
    surowce($atak_info['miasto_id'], $atak_info['drewno'], $atak_info['kamien'], $atak_info['zelazo'], $atak_info['jedzenie'], 0);
    require_once 'raport.php';
    $a = raport($login, "Armia powróciła do miasta ,rozładowano " . $atak_info['drewno'] . " drewna,  " . $atak_info['kamien'] . " kamienia,  " . $atak_info['zelazo'] . " żelaza i " . $atak_info['jedzenie'] . " jedzenia");
}
コード例 #14
0
ファイル: opt.php プロジェクト: akilli/qnd
/**
 * Menu options
 *
 * @return array
 */
function opt_position() : array
{
    $roots = all('menu');
    $data = [];
    foreach (all('node') as $item) {
        if (empty($data[$item['root_id'] . ':0'])) {
            $data[$item['root_id'] . ':0']['name'] = $roots[$item['root_id']]['name'];
            $data[$item['root_id'] . ':0']['class'] = 'group';
        }
        $data[$item['position']]['name'] = $item['name'];
        $data[$item['position']]['level'] = $item['level'];
    }
    // Add roots without items
    foreach ($roots as $id => $root) {
        if (empty($data[$id . ':0'])) {
            $data[$id . ':0']['name'] = $root['name'];
            $data[$id . ':0']['class'] = 'group';
        }
    }
    return $data;
}
コード例 #15
0
ファイル: getNorm.php プロジェクト: Ashwincy/lattice
            continue;
        }
        $entry = explode("|", $line);
        if (count($entry) != 10 && count($entry) != 4) {
            continue;
        }
        $e = new Entry();
        $e->dim = $entry[0];
        $e->len = $entry[1];
        $e->name = $entry[2];
        $e->sol = $entry[3];
        if (count($entry) == 10) {
            $e->email = $entry[4];
            $e->algorithm = $entry[5];
            $e->hardware = $entry[6];
            $e->runtime = $entry[7];
            $e->notes = $entry[8];
            $e->date = $entry[9];
        }
        $results[$i] = $e;
        $i = $i + 1;
    }
    return $results;
}
$res = all();
$i = 1;
foreach ($res as $key => $value) {
    $rec = $value;
    vectorTest($rec);
    $i++;
}
コード例 #16
0
ファイル: prawy_blok.php プロジェクト: WlasnaGra/Tribal
<p><strong>zdarzenia:</strong></p>
    <p>
	<?php 
$eventy = all("select *, t.nazwa as tech_nazwa, j.nazwa as jedn_nazwa, b.nazwa as bud_nazwa, koniec - " . mktime() . " as czas from tribal_eventy left join tribal_budynki b on podtyp = b.budynek left join tribal_jednostki j on podtyp = j.jednostka left join tribal_technologie t on podtyp = t.technologia where miasto_id = " . $gracz['id_miasta'] . " and typ < 4 order by czas asc");
if (is_array($eventy)) {
    refresh($eventy[0]['czas']);
    foreach ($eventy as $event) {
        $czas = $event['czas'];
        if ($event['typ'] == 1) {
            echo "\n\t\t\t\t\t<div style='margin-bottom:10px'>" . $event['bud_nazwa'] . " <span style='float:right'><span id='t" . $event['event'] . "'></span> [ <a href='?akcja=budynek&id=" . $event['podtyp'] . "&przerwij'>x</a> ]</span>\n\t\t\t\t\t<script type='text/javascript'>liczCzas('t" . $event['event'] . "',{$czas});</script>\n\t\t\t\t\t</div>\n\t\t\t\t\t";
        } elseif ($event['typ'] == 2) {
            echo "\n\t\t\t\t\t<div style='margin-bottom:10px'>" . $event['tech_nazwa'] . " <span style='float:right'><span id='t" . $event['event'] . "'>{$pozostalo}</span> [ <a href='?akcja=nauka&przerwij=" . $event['podtyp'] . "'>x</a> ]</span>\n\t\t\t\t\t<script type='text/javascript'>liczCzas('t" . $event['event'] . "',{$czas});</script>\n\t\t\t\t\t</div>\n\t\t\t\t\t";
        } else {
            echo "\n\t\t\t\t\t<div style='margin-bottom:10px'>" . $event['jedn_nazwa'] . " <span style='float:right'><span id='t" . $event['event'] . "'>{$pozostalo}</span> [ <a href='?akcja=armia&przerwij=" . $event['event'] . "'>x</a> ]</span>\n\t\t\t\t\t<script type='text/javascript'>liczCzas('t" . $event['event'] . "',{$czas});</script>\n\t\t\t\t\t</div>\n\t\t\t\t\t";
        }
    }
} else {
    echo "brak zdarzeń";
}
?>
	</p>
コード例 #17
0
ファイル: konto.php プロジェクト: WlasnaGra/Tribal
			
			<div style=' padding:10px; border:solid 1px #FF0000; height:100px'>
			<?php 
//jeżeli gracz nie ma wgranego avatara to wyświetl domyślny
if ($gracz['obrazek'] == 0) {
    echo "<img src='www/noavatar.png' alt='' style='float:left;margin-right:10px' width='80px'/>";
} else {
    echo "<img src='avatar/" . $gracz['gracz'] . ".jpg' alt='' style='float:left;margin-right:10px' width='80px'/>";
}
?>
			<form action='?akcja=konto' method='post' enctype='multipart/form-data'>
				<input type='hidden' name='MAX_FILE_SIZE' value='100000' />				
				Zmień avatar <input name='obrazek' type='file' /> <input type='submit' value='zmień'>
			</form>
			</div>
			Twoje miasta:
			<table>
			<?php 
$miasta = all("select * from tribal_miasta where gracz_id = " . $gracz['gracz']);
foreach ($miasta as $miasto) {
    if ($gracz['id_miasta'] != $miasto['miasto']) {
        echo "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>- " . $miasto['nazwa'] . "</td>\n\t\t\t\t\t\t\t<td><a href='?akcja=konto&ustaw_miasto=" . $miasto['miasto'] . "'>[ ustaw aktywne ]</td>\n\t\t\t\t\t\t</tr>";
    } else {
        echo "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>- " . $miasto['nazwa'] . "</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t</tr>";
    }
}
?>
			
			</table>
			<hr/>
			<a href='?akcja=konto&urlop=1'>idź na 7 dni urlopu</a> | <a href='?akcja=konto2'>załóż osadę</a>
コード例 #18
0
ファイル: sklep.php プロジェクト: WlasnaGra/Driver
<h2>Sklep z odzieżą</h2><hr/>
<p>
<?php 
if (!empty($_GET['kup'])) {
    fx('kup_ciuch');
    $msg = kup_ciuch($gracz['gracz'], $_GET['kup']);
    $gracz = getUser($gracz['gracz']);
    echo "<span style='color:#FF0000; margin-bottom:20px;display:block'>" . $msg . "</span>";
}
//pobierz listę
$ciuchy = all($q = "select driver_ciuchy.* from driver_ciuchy left join driver_ciuchy_gracze on id = c_id and gracz_id = " . $gracz['gracz'] . " where gracz_id is null order by typ ");
//jeżeli w ogóle są ciuchy
if (is_array($ciuchy)) {
    foreach ($ciuchy as $ciuch) {
        if ($gracz['kasa'] >= $ciuch['cena'] && $gracz['monety'] >= $ciuch['monety']) {
            $opcja = "<a href='?akcja=sklep&kup=" . $ciuch['id'] . "'>[ kup ]</a>";
        } else {
            $opcja = "nie stać Cię";
        }
        echo "\n\t\t\t<div style=' padding:10px; border:solid 1px #FF0000;'>\n\t\t\t\t<div style='width:134px; float: left'>\n\t\t\t\t\t<img src='sprzet/" . $ciuch['obrazek'] . "' alt=''  width='134px'/>\n\t\t\t\t</div>\n\t\t\t\t<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align=right>Nazwa </td>\n\t\t\t\t\t<td><i><b>" . $ciuch['nazwa'] . "</b></i></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align=right>Szybkość </td>\n\t\t\t\t\t<td><b>" . $ciuch['vmax'] . "</b></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align=right>Przyspieszenie </td>\n\t\t\t\t\t<td><b>" . $ciuch['do100'] . "</b></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align=right>Cena </td>\n\t\t\t\t\t<td><b>" . $ciuch['cena'] . "\$</b></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align=right>Monety </td>\n\t\t\t\t\t<td><b>" . $ciuch['monety'] . "</b></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td align=center colspan=2><b>{$opcja}</b></td>\n\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t</div>\n\t\t\t";
    }
} else {
    echo "nie ma więcej ciuchów do kupienia";
}
?>

</p>
コード例 #19
0
        print "<tr>";
        printf("<td bgcolor={$bgcolor2}>&nbsp;&nbsp;<a href=\"modules.php?name={$module_name}&file=search&bywhat=aid&forwhat=%s\">%s</a></td>", $row[joid], $row[joid]);
        printf("<td bgcolor={$bgcolor2} align=center><div class=title><a href=\"modules.php?name={$module_name}&file=search&bywhat=aid&forwhat=%s\"><img src=\"modules/{$module_name}/images/binocs.gif\" border=0 alt=\"" . _VIEWJOURNAL2 . "\" title=\"" . _VIEWJOURNAL2 . "\"></a></td>", $row[joid], $row[joid]);
        printf("<td bgcolor={$bgcolor2} align=center><a href=\"modules.php?name=Your_Account&op=userinfo&username=%s\"><img src=\"modules/{$module_name}/images/nuke.gif\" alt=\"" . _USERPROFILE2 . "\" title=\"" . _USERPROFILE2 . "\" border=0></a></td>", $row[joid], $row[joid], $row[joid]);
        if ($username == "") {
            print "<td align=center bgcolor={$bgcolor2}><a href=\"modules.php?name=Your_Account&op=new_user\"><img src=\"modules/{$module_name}/images/folder.gif\" border=0 alt=\"" . _CREATEACCOUNT . "\" title=\"" . _CREATEACCOUNT . "\"></a></td>";
        } elseif ($username != "" and is_active("Private_Messages")) {
            printf("<td align=center bgcolor={$bgcolor2}><a href=\"modules.php?name=Private_Messages&mode=post&u={$row['user_id']}\"><img src='modules/{$module_name}/images/chat.gif' border='0' alt='" . _PRIVMSGJ2 . "'></a></td>", $row[aid], $row[aid]);
        }
        echo "</tr>";
    }
    echo "</table>";
    CloseTable();
}
echo "<br>";
OpenTable();
echo "<div align=center> [ <a href=\"modules.php?name={$module_name}&op=last\">" . _20AUTHORS . "</a> | <a href=\"modules.php?name={$module_name}&op=all\">" . _LISTALLJOURNALS . "</a> | <a href=\"modules.php?name={$module_name}&file=search&disp=showsearch\">" . _SEARCHMEMBER . "</a> ]</div>";
CloseTable();
echo "<br>";
switch ($op) {
    case "last":
        last20($bgcolor1, $bgcolor2, $bgcolor3, $username);
        break;
    case "all":
        all($bgcolor1, $bgcolor2, $bgcolor3, $sitename, $username);
        break;
    default:
        last20($bgcolor1, $bgcolor2, $bgcolor3, $username);
        break;
}
journalfoot();
コード例 #20
0
ファイル: admin2.php プロジェクト: WlasnaGra/Tribal
<div class="post" id="post-18">
<h2>Dodawanie surowców</h2>
<hr/>
<?php 
if (!empty($_POST['nazwa'])) {
    $_POST['nazwa'] = vText($_POST['nazwa']);
    $miasto = row("select * from tribal_miasta where nazwa ='" . $_POST['nazwa'] . "'");
    if (empty($miasto)) {
        echo "nie ma takiego miasta";
    } else {
        $_GET['miasto'] = $miasto['miasto'];
    }
}
if (empty($_GET['miasto'])) {
    //pobierz listę miast
    $miasta = all("select * from tribal_miasta");
    //jeżeli w ogóle są miasta
    if (is_array($miasta)) {
        echo "\n\t\tWyszukaj po nazwie:\n\t\t<form action='?akcja=admin2' method='post'>\n\t\tnazwa miasta: <input type='text' name='nazwa'> <input type='submit' value='szukaj'/>\n\t\t</form>\n\n\t\t<hr/>\n\t\t<table>\n\t\t<tr style='background-color:#336600'>\n\t\t\t<th>Miasto</th>\n\t\t\t<th></th>\n\t\t</tr>\n\t\t";
        foreach ($miasta as $miasto) {
            echo "\n\t\t\t<tr>\n\t\t\t\t<td>&nbsp;" . $miasto['nazwa'] . " &nbsp; {$zbanowany}</td>\t\t\t\t\n\t\t\t\t<td>\n\t\t\t\t\t<a href='?akcja=admin2&miasto=" . $miasto['miasto'] . "'>[dodaj surowce]</a>\t\t\t\t\t\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t";
        }
        echo "</table>";
    } else {
        echo "w grze nie ma miast";
    }
} else {
    $_GET['miasto'] = (int) $_GET['miasto'];
    if (!empty($_POST)) {
        $drewno = 0;
        $kamien = 0;
コード例 #21
0
<?php

/*
 * This file is part of the async generator runtime project.
 *
 * (c) Julien Bianchi <*****@*****.**>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */
require_once __DIR__ . '/../../vendor/autoload.php';
use function jubianchi\async\runtime\{await, all, wrap};
use function jubianchi\async\time\{delay};
$start = microtime(true);
function second()
{
    var_dump(__FUNCTION__ . ' - ' . 3);
    yield from delay(1000);
    var_dump(__FUNCTION__ . ' - ' . 4);
}
function first()
{
    var_dump(__FUNCTION__ . ' - ' . 1);
    yield from delay(1000);
    var_dump(__FUNCTION__ . ' - ' . 2);
    yield from delay(1000);
    yield from second();
    return 5;
}
var_dump(await(all(first(), second())));
echo 'Time spent: ' . ($with = microtime(true) - $start) . PHP_EOL;
コード例 #22
0
ファイル: Server.php プロジェクト: efueger/aerys
 private function doStop() : \Generator
 {
     assert($this->logDebug("stopping"));
     $this->state = self::STOPPING;
     foreach ($this->acceptWatcherIds as $watcherId) {
         \Amp\cancel($watcherId);
     }
     $this->boundServers = [];
     $this->acceptWatcherIds = [];
     foreach ($this->pendingTlsStreams as list(, $socket)) {
         $this->failCryptoNegotiation($socket);
     }
     $this->stopPromisor = new Deferred();
     if (empty($this->clients)) {
         $this->stopPromisor->succeed();
     } else {
         foreach ($this->clients as $client) {
             if (empty($client->requestCycles)) {
                 $this->close($client);
             }
         }
     }
     (yield all([$this->stopPromisor->promise(), $this->notify()]));
     assert($this->logDebug("stopped"));
     $this->state = self::STOPPED;
     $this->stopPromisor = null;
     (yield $this->notify());
 }
コード例 #23
0
ファイル: mapa.php プロジェクト: WlasnaGra/Tribal
<div style='width:270px; height:270px;position:relative; display:block;'>
<div id='box' style='width:240px; background-color:#F6F0E0; border:solid 2px #990000; height:150px; padding: 10px; position:absolute; top:30px; left:0px; display:none'></div>
<script type='text/javascript'>
function show(mid, miasto, login,gracz){
	document.getElementById('box').innerHTML = '<h4>Gracz '+login+' <div onclick="hide()" style="float:right; cursor:pointer">[x]</div></h4>Miasto: '+miasto+'<hr/><a href="?akcja=profil&gracz='+gracz+'" style="display:block">zobacz profil</a><a href="?akcja=poczta&do='+login+'&nowa=ok" style="display:block">wyślij wiadomość</a><a href="?akcja=armia&atakuj='+mid+'" style="display:block">zaatakuj</a>';
	document.getElementById('box').style.display = 'block';
}
function hide(){
	document.getElementById('box').innerHTML = '';
	document.getElementById('box').style.display = 'none';
}
</script>

<?php 
$map = all($q = "select  x ,  y, nazwa, miasto, gracz, login from tribal_mapa left join tribal_miasta on miasto = miasto_id  left join tribal_gracze on gracz_id = gracz where x >= {$x} and x <= {$x2} and  y >= {$y} and y <= {$y2} order by x asc, y asc limit 25");
if (is_array($map)) {
    foreach ($map as $m) {
        if (empty($m['nazwa'])) {
            echo "<div style='float:left;width:50px; height:50px; border: solid 1px black;background-color:#336633;'><img src='www/bg.jpg' alt=''/></div>";
        } else {
            ?>
				<div style='float:left;width:50px; height:50px; border: solid 1px black;  cursor:pointer' >
					<span style='cursor:pointer' title="Miasto <i><b><?php 
            echo $m['nazwa'];
            ?>
</b></i>|gracz <i><b><?php 
            echo $m['login'];
            ?>
</b></i>|pozycja: <?php 
            echo $m['x'];
コード例 #24
0
 protected function create_conditions_from_keys(Model $model, $condition_keys = array(), $value_keys = array())
 {
     $condition_string = implode('_and_', $condition_keys);
     $condition_values = array_values($model->get_values_for($value_keys));
     // return null if all the foreign key values are null so that we don't try to do a query like "id is null"
     if (all(null, $condition_values)) {
         return null;
     }
     $conditions = SQLBuilder::create_conditions_from_underscored_string($condition_string, $condition_values);
     # DO NOT CHANGE THE NEXT TWO LINES. add_condition operates on a reference and will screw options array up
     if (isset($this->options['conditions'])) {
         $options_conditions = $this->options['conditions'];
     } else {
         $options_conditions = array();
     }
     return Utils::add_condition($options_conditions, $conditions);
 }
コード例 #25
0
ファイル: Socket_Client.php プロジェクト: qieangel2013/zys
 public function invoke($name, array &$args = array(), $callback = null, InvokeSettings $settings = null)
 {
     if ($callback instanceof InvokeSettings) {
         $settings = $callback;
         $callback = null;
     }
     if ($settings === null) {
         $settings = new InvokeSettings();
     }
     $context = $this->getContext($settings);
     $invokeHandler = $this->invokeHandler;
     if (is_callable($callback)) {
         if (is_array($callback)) {
             $f = new ReflectionMethod($callback[0], $callback[1]);
         } else {
             $f = new ReflectionFunction($callback);
         }
         $n = $f->getNumberOfParameters();
         $onError = $this->onError;
         return all($args)->then(function ($args) use($invokeHandler, $name, $context, $n, $callback, $onError) {
             $result = toFuture($invokeHandler($name, $args, $context));
             $result->then(function ($result) use($n, $callback, $args) {
                 switch ($n) {
                     case 0:
                         call_user_func($callback);
                         break;
                     case 1:
                         call_user_func($callback, $result);
                         break;
                     case 2:
                         call_user_func($callback, $result, $args);
                         break;
                     case 3:
                         call_user_func($callback, $result, $args, null);
                         break;
                 }
             }, function ($error) use($n, $callback, $args, $name, $onError) {
                 switch ($n) {
                     case 0:
                         call_user_func($callback);
                         if (is_callable($onError)) {
                             call_user_func($onError, $name, $error);
                         }
                         break;
                     case 1:
                         call_user_func($callback, $error);
                         break;
                     case 2:
                         call_user_func($callback, $error, $args);
                         break;
                     case 3:
                         call_user_func($callback, null, $args, $error);
                         break;
                 }
             });
             return $result;
         });
     } else {
         if ($this->async) {
             $args = all($args);
             return $args->then(function ($args) use($invokeHandler, $name, $context) {
                 return $invokeHandler($name, $args, $context);
             });
         }
         return $invokeHandler($name, $args, $context);
     }
 }
コード例 #26
0
ファイル: armia.php プロジェクト: WlasnaGra/Tribal
<script src="www/jquery.min.js" type="text/javascript"></script>
<script src="www/jquery.cluetip.js" type="text/javascript"></script>
<script src="www/demo.js" type="text/javascript"></script>
<link rel="stylesheet" href="www/jquery.cluetip.css" type="text/css" /> 

<?php 
if (!empty($_GET['przerwij'])) {
    fx('przerwij_trening');
    $error = przerwij_trening($gracz, $_GET['przerwij']);
    echo $error . "<br/>";
}
if (!empty($_GET['atakuj'])) {
    $_GET['atakuj'] = (int) $_GET['atakuj'];
    $cel = one("select nazwa from tribal_miasta where miasto = " . $_GET['atakuj'] . " limit 1");
}
$jednostki = all("select * from tribal_jednostki left join tribal_jednostki_miasta on jednostka = jednostka_id where miasto_id = " . $gracz['id_miasta']);
if (!is_array($jednostki)) {
    echo "nie masz jednostek w armii";
} else {
    echo "\n\t<form action='?akcja=ataki' method='post'>\n\t<table>\n\t<tr style='background:#CCC8B3'>\n\t\t<th>nazwa</th>\n\t\t<th>ilość</th>\n\t\t<th>poślij</th>\n\t</tr>\n\t\n\t";
    /*foreach($jednostki as $jednostka){
    		echo "
    		<tr style='text-align:center'>
    			<td><span title='Statystyki|atak: ".$jednostka['atak']."|obrona: ".$jednostka['obrona']."'>".$jednostka['nazwa']."</span></td>
    			<td>".$jednostka['ilosc']."</td>
    			<td>
    				<input type='text' name='jednostki[".$jednostka['jednostka']."]' value='0'>
    			</td>
    		</tr>";
    	}*/
    foreach ($jednostki as $jednostka) {
コード例 #27
0
ファイル: action.php プロジェクト: akilli/qnd
/**
 * Index Action
 *
 * @param array $entity
 *
 * @return void
 */
function action_index(array $entity) : void
{
    $action = request('action');
    $attrs = entity_attr($entity['id'], $action);
    $crit = empty($entity['attr']['active']) || $action === 'admin' ? [] : ['active' => true];
    $p = [];
    $q = http_post('q') ? filter_var(http_post('q'), FILTER_SANITIZE_STRING, FILTER_REQUIRE_SCALAR) : null;
    if ($q || ($q = http_get('q'))) {
        if (($s = array_filter(explode(' ', $q))) && ($all = all($entity['id'], ['name' => $s], ['search' => true]))) {
            $crit['id'] = array_keys($all);
            $p['q'] = urlencode(implode(' ', $s));
        } else {
            message(_('No results for provided query %s', $q));
        }
    }
    $opts = ['limit' => abs((int) data('limit', $action)) ?: 10];
    $size = size($entity['id'], $crit);
    $pages = (int) ceil($size / $opts['limit']);
    $p['page'] = min(max(http_get('page'), 1), $pages ?: 1);
    $opts['offset'] = ($p['page'] - 1) * $opts['limit'];
    if (($sort = http_get('sort')) && !empty($attrs[$sort])) {
        $p['sort'] = $sort;
        $p['dir'] = http_get('dir') === 'desc' ? 'desc' : 'asc';
        $opts['order'] = [$p['sort'] => $p['dir']];
    }
    layout_load();
    vars('content', ['data' => all($entity['id'], $crit, $opts), 'title' => $entity['name'], 'attr' => $attrs, 'params' => $p]);
    vars('pager', ['size' => $size, 'limit' => $opts['limit'], 'params' => $p]);
    vars('head', ['title' => $entity['name']]);
}
コード例 #28
0
ファイル: admin_auta.php プロジェクト: WlasnaGra/Driver
        $plik_nazwa = $_FILES['obrazek']['name'];
        if (is_uploaded_file($plik)) {
            //jeżeli udało się wgrać obrazek to dodaj auto
            move_uploaded_file($plik, "auta/" . $plik_nazwa);
            //zabezpiecz dane
            $_POST['nazwa'] = vText($_POST['nazwa']);
            $_POST['do100'] = (int) $_POST['do100'];
            $_POST['vmax'] = (int) $_POST['vmax'];
            $_POST['cena'] = (int) $_POST['cena'];
            //dodaj auto do bazy danych
            call("insert into driver_auta(nazwa, vmax, do100, cena, obrazek) value ('" . $_POST['nazwa'] . "'," . $_POST['vmax'] . "," . $_POST['do100'] . "," . $_POST['cena'] . ",'auta/" . $plik_nazwa . "')");
            echo "dodano auto<br/><br/>";
        }
    }
    //pobierz listę aut
    $auta = all("select * from driver_auta");
    //jeżeli w ogóle są auta
    if (is_array($auta)) {
        echo "\n\t\t<table>\n\t\t<tr style='background-color:#336600'>\n\t\t\t<th>Nazwa</th>\n\t\t\t<th>Szybkość</th>\n\t\t\t<th>Przyspieszenie</th>\n\t\t\t<th>Cena</th>\n\t\t\t<th></th>\n\t\t</tr>\n\t\t";
        //dla każdego auta wyświetl jego dane w osobnym wierszu w tabeli
        foreach ($auta as $auto) {
            echo "\n\t\t\t<tr>\n\t\t\t\t<td>" . $auto['nazwa'] . "</td>\n\t\t\t\t<td>" . $auto['vmax'] . "</td>\n\t\t\t\t<td>" . $auto['do100'] . "</td>\n\t\t\t\t<td>" . $auto['cena'] . "</td>\n\t\t\t\t<td width='150px'>\n\t\t\t\t\t<a href='?akcja=admin_auta&del=" . $auto['auto'] . "' onclick='confirm(\"Na pewno usunąć to auto?\")'>[ usuń ]</a> \n\t\t\t\t\t<a href='?akcja=admin_auta&edit=" . $auto['auto'] . "'>[ edytuj ]</a>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t";
        }
        echo "</table>";
    } else {
        echo "w grze nie ma aut";
    }
    //pokaż panel dodawania auta
    echo "\n\t\t<br/><br/><br/>\n\t\tDodaj auto, pamiętaj, by nie używać dziwnych znaków w nazwach a wartości liczbowe mają być dodatnie , im niższa wartość Przyspieszenia tym lepiej dla auta\n\t\t<form action='?akcja=admin_auta' method='post' enctype='multipart/form-data'>\n\t\t\t<input type='hidden' name='MAX_FILE_SIZE' value='500000000' />\n\t\t\t<table>\n\t\t\t<tr>\n\t\t\t\t<td align=right>Nazwa </td>\n\t\t\t\t<td align=left><input type='text' name='nazwa' ></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td align=right>Cena </td>\n\t\t\t\t<td align=left><input type='text' name='cena' ></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td align=right>Szybkość </td>\n\t\t\t\t<td align=left><input type='text' name='vmax' ></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td align=right>Przyspieszenie </td>\n\t\t\t\t<td align=left><input type='text' name='do100' ></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td align=right>Obrazek </td>\n\t\t\t\t<td align=left><input name='obrazek' type='file' /></td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t\n\t\t\n\t\t<input type='submit' value='dodaj auto'>\n\t\t</form>\n\t";
}
?>
コード例 #29
0
ファイル: main_town.php プロジェクト: WlasnaGra/Tribal
function main_town($miasto)
{
    fx('usun_event');
    $eventy_budynki = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 1 and koniec <= " . time());
    if (is_array($eventy_budynki)) {
        foreach ($eventy_budynki as $wybudowany) {
            usun_event($wybudowany['event']);
            call("update tribal_gracze g inner join tribal_miasta on g.gracz = gracz_id set g.punkty = g.punkty + 1 where miasto = " . $miasto);
            $info = one("select count(*) from tribal_budynki_miasta where miasto_id = {$miasto} and budynek_id = " . $wybudowany['podtyp']);
            $obiekt = row("select * from  tribal_budynki where budynek = " . $wybudowany['podtyp']);
            if (!empty($info)) {
                call($q = "update tribal_budynki_miasta set \n\t\t\t\tdrewno = drewno * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100), \n\t\t\t\tkamien = kamien * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tjedzenie = jedzenie * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tzelazo = zelazo * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tpopulacja = populacja * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tczas_budowy = czas_budowy * ((100 + " . $obiekt['wzrost_czasu_budowy'] . " )/100),\n\t\t\t\tpoziom = poziom + 1\n\t\t\t\twhere miasto_id = {$miasto} and budynek_id = \n\t\t\t\t" . $wybudowany['podtyp']);
                $poziom = 1;
            } else {
                call($q = "insert into tribal_budynki_miasta(miasto_id, budynek_id, drewno, kamien, zelazo, jedzenie, populacja, czas_budowy, poziom) value ({$miasto}, " . $wybudowany['podtyp'] . ", " . $obiekt['drewno'] . ", " . $obiekt['kamien'] . ", " . $obiekt['zelazo'] . ", " . $obiekt['jedzenie'] . ", " . $obiekt['populacja'] . ", " . $obiekt['czas_budowy'] . ", 1)");
                $poziom = 0;
            }
            switch ($wybudowany['podtyp']) {
                case 1:
                    if ($poziom == 0) {
                        call("update tribal_miasta set drewno_przyrost = drewno_przyrost + 50 where miasto = {$miasto}");
                    } else {
                        call("update tribal_miasta set drewno_przyrost = drewno_przyrost * 1.2 where miasto = {$miasto}");
                    }
                    break;
                case 2:
                    if ($poziom == 0) {
                        call("update tribal_miasta set kamien_przyrost = kamien_przyrost + 50 where miasto = {$miasto}");
                    } else {
                        call("update tribal_miasta set kamien_przyrost = kamien_przyrost * 1.2 where miasto = {$miasto}");
                    }
                    break;
                case 3:
                    if ($poziom == 0) {
                        call("update tribal_miasta set zelazo_przyrost = zelazo_przyrost + 50 where miasto = {$miasto}");
                    } else {
                        call("update tribal_miasta set zelazo_przyrost = zelazo_przyrost * 1.2 where miasto = {$miasto}");
                    }
                    break;
                case 4:
                    if ($poziom == 0) {
                        call("update tribal_miasta set jedzenie_przyrost = jedzenie_przyrost + 50 where miasto = {$miasto}");
                    } else {
                        call("update tribal_miasta set jedzenie_przyrost = jedzenie_przyrost * 1.2 where miasto = {$miasto}");
                    }
                    break;
                case 5:
                    call("update tribal_miasta set populacja_max = populacja_max * 1.3 where miasto = {$miasto}");
                    break;
                case 6:
                    call("update tribal_miasta set surowce_max = surowce_max * 1.3 where miasto = {$miasto}");
                    break;
            }
        }
    }
    $eventy_technologie = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 2 and koniec <= " . time());
    if (is_array($eventy_technologie)) {
        foreach ($eventy_technologie as $wybudowany) {
            usun_event($wybudowany['event']);
            $info = one("select count(*) from tribal_technologie_miasta where miasto_id = {$miasto} and technologia_id = " . $wybudowany['podtyp']);
            $obiekt = row("select * from  tribal_technologie where technologia = " . $wybudowany['podtyp']);
            if (!empty($info)) {
                call("update tribal_technologie_miasta set \n\t\t\t\tdrewno = drewno * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100), \n\t\t\t\tkamien = kamien * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tjedzenie = jedzenie * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tzelazo = zelazo * ((100 + " . $obiekt['wzrost_koszt_surowce'] . " )/100),\n\t\t\t\tczas_rozwoju = czas_rozwoju * ((100 + " . $obiekt['wzrost_czasu_budowania'] . " )/100),\n\t\t\t\tpoziom = poziom + 1\n\t\t\t\twhere miasto_id = {$miasto} and technologia_id = \n\t\t\t\t" . $wybudowany['podtyp']);
                $poziom = 1;
            } else {
                call("insert into tribal_technologie_miasta(miasto_id, technologia_id, drewno, kamien, zelazo, jedzenie,  czas_rozwoju, poziom) value ({$miasto}, " . $wybudowany['podtyp'] . ", " . $obiekt['drewno'] . ", " . $obiekt['kamien'] . ", " . $obiekt['zelazo'] . ", " . $obiekt['jedzenie'] . ", " . $obiekt['czas_rozwoju'] . ", 1)");
                $poziom = 0;
            }
        }
    }
    $eventy_jednostki = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 3 and koniec <= " . time());
    if (is_array($eventy_jednostki)) {
        foreach ($eventy_jednostki as $wybudowany) {
            usun_event($wybudowany['event']);
            $info = one("select count(*) from tribal_jednostki_miasta where miasto_id = {$miasto} and jednostka_id = " . $wybudowany['podtyp']);
            if (!empty($info)) {
                call("update tribal_jednostki_miasta set \n\t\t\t\tilosc = ilosc + " . $wybudowany['ilosc'] . "\n\t\t\t\twhere miasto_id = {$miasto} and jednostka_id = \n\t\t\t\t" . $wybudowany['podtyp']);
            } else {
                call("insert into tribal_jednostki_miasta(miasto_id, jednostka_id, ilosc) value ({$miasto}, " . $wybudowany['podtyp'] . "," . $wybudowany['ilosc'] . ")");
            }
        }
    }
    fx('rozwiaz_armie');
    $eventy_ataki_powrot = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 11 and koniec <= " . time());
    if (is_array($eventy_ataki_powrot)) {
        foreach ($eventy_ataki_powrot as $atak) {
            usun_event($atak['event']);
            rozwiaz_armie($atak['ilosc']);
        }
    }
    fx('bitwa');
    $eventy_bitwy = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 10 and koniec <= " . time());
    if (is_array($eventy_bitwy)) {
        foreach ($eventy_bitwy as $atak) {
            usun_event($atak['event']);
            bitwa($atak);
        }
    }
    fx('rozwiaz_szpiegow');
    $eventy_szpiedzy_powrot = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 21 and koniec <= " . time());
    if (is_array($eventy_szpiedzy_powrot)) {
        foreach ($eventy_szpiedzy_powrot as $atak) {
            usun_event($atak['event']);
            rozwiaz_szpiegow($atak);
        }
    }
    fx('szpiegowanie');
    $eventy_szpiegowanie = all("select * from tribal_eventy where miasto_id = {$miasto} and typ = 20 and koniec <= " . time());
    if (is_array($eventy_szpiegowanie)) {
        foreach ($eventy_szpiegowanie as $atak) {
            usun_event($atak['event']);
            szpiegowanie($atak);
        }
    }
}
コード例 #30
0
ファイル: pipes.php プロジェクト: jubianchi/async-generator
<?php

/*
 * This file is part of the async generator runtime project.
 *
 * (c) Julien Bianchi <*****@*****.**>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */
require_once __DIR__ . '/../../vendor/autoload.php';
use function jubianchi\async\pipe\{make};
use function jubianchi\async\runtime\{await, all, fork};
use function jubianchi\async\time\{delay, throttle};
$pipe = make();
$i = 0;
await(all(throttle(2500, function () use($pipe, &$i) {
    $pipe->enqueue($i++);
}), throttle(500, function () use($pipe) {
    echo __LINE__;
    var_dump("" . (yield from $pipe->dequeue()) . "");
}), throttle(1000, function () use($pipe) {
    echo __LINE__;
    var_dump("" . (yield from $pipe->dequeue()) . "");
})));