コード例 #1
0
ファイル: entry_add.php プロジェクト: nishad/bmtmgr
$tournament = $discipline->get_tournament();
$season = $tournament->get_season();
$player = null;
$player_club = null;
$partner = null;
$partner_club = null;
if (!empty($_POST['player'])) {
    $player = $season->get_player_by_input($_POST['player']);
    if (!empty($_POST['player_club'])) {
        $player_club = $season->get_club_by_input($_POST['player_club']);
    }
}
if (!empty($_POST['partner'])) {
    $partner = $season->get_player_by_input($_POST['partner']);
    if (!empty($_POST['partner_club'])) {
        $partner_club = $season->get_club_by_input($_POST['partner_club']);
    }
}
$email = isset($_POST['email']) ? $_POST['email'] : null;
$seeding = isset($_POST['seeding']) ? $_POST['seeding'] : null;
$memo = isset($_POST['memo']) ? $_POST['memo'] : null;
try {
    $discipline->check_entry($player, $partner);
} catch (utils\InvalidEntryException $iee) {
    render_ajax_error('Meldung kann nicht angenommen werden: ' . $iee->getMessage());
    exit;
}
$entry = Entry::create($discipline, $player, $player_club, $partner, $partner_club, $email, $seeding, $memo);
$entry->save();
render_ajax('d/' . $discipline->id . '/', ['entry' => $entry]);
コード例 #2
0
ファイル: tournament_create.php プロジェクト: nishad/bmtmgr
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
utils\require_post_params(['name', 'season_id']);
$season = Season::by_id($_POST['season_id']);
try {
    $tournament = Tournament::create($season, $_POST['name']);
    $tournament->save();
} catch (utils\DuplicateEntryException $e) {
    render_ajax_error('Ein Turnier mit dem Namen "' . $_POST['name'] . '" existiert bereits');
    exit;
}
render_ajax('t/' . $tournament->id . '/', ['season' => $season, 'tournament' => $tournament]);
コード例 #3
0
ファイル: publication_edit.php プロジェクト: nishad/bmtmgr
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
require_once dirname(__DIR__) . '/src/sftp.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
utils\require_get_params(['publication_id']);
utils\require_post_params(['type']);
$publication_type = $_POST['type'];
$tournament = Tournament::by_id($_GET['tournament_id']);
$season = $tournament->get_season();
switch ($publication_type) {
    case 'sftp':
        utils\require_post_params(['server', 'port', 'user', 'path']);
        $publication = sftp\SFTPPublication::sftp_create($tournament, $_POST['server'], \intval($_POST['port']), $_POST['user'], $_POST['path']);
        $publication->save();
        render_ajax('t/' . $tournament->id . '/publication/' . $publication->id . '/', ['publication' => $publication]);
        break;
    default:
        throw new \Exception('Invalid publication type');
}
コード例 #4
0
ファイル: club_import.php プロジェクト: nishad/bmtmgr
$imported_clubs = [];
$not_found_since = 0;
Model::beginTransaction();
for ($i = 1; $i < 100000; $i++) {
    $url = \sprintf($url_pattern, $i);
    $page = \file_get_contents($url);
    $r = \preg_match('/
		<label>ClubID:<\\/label><div>(?P<id>[0-9-]+)<\\/div>.*
		<label>Vereinsname:<\\/label><div>(?P<name>[^<]+)<\\/div>.*
		<label>Email:<\\/label><div><a.*?>(?P<email>[^<]+)<\\/a>
		/xs', $page, $m);
    if (!$r) {
        $not_found_since++;
        if ($not_found_since > 100) {
            break;
        }
        continue;
    }
    $id = \html_entity_decode($m['id'], ENT_QUOTES | ENT_HTML5, 'utf-8');
    $name = \html_entity_decode($m['name'], ENT_QUOTES | ENT_HTML5, 'utf-8');
    $email = \html_entity_decode($m['email'], ENT_QUOTES | ENT_HTML5, 'utf-8');
    $c = User::by_id_optional($id);
    if (!$c) {
        $c = new User($id, $name, $email, ['register']);
        $c->save();
        \array_push($imported_clubs, $c);
    }
}
Model::commit();
render_ajax('club/', ['imported_clubs' => $imported_clubs]);
コード例 #5
0
{
    global $config;
    if (!isset($config['hast']['enable'])) {
        return gettext("HAST disabled");
    }
    $cmd = "/sbin/hastctl status";
    if (isset($_GET['name'])) {
        $cmd .= " {$_GET['name']}";
    }
    $cmd .= " 2>&1";
    mwexec2($cmd, $rawdata);
    return implode("\n", $rawdata);
}
if (is_ajax()) {
    $status = hast_get_status();
    render_ajax($status);
}
include "fbegin.inc";
?>
<script type="text/javascript">//<![CDATA[
$(document).ready(function(){
	var gui = new GUI;
	gui.recall(0, 5000, 'services_hast_info.php', null, function(data) {
		$('#hast_status').text(data.data);
	});
});
//]]>
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="tabnavtbl">
コード例 #6
0
ファイル: disks_init.php プロジェクト: BillTheBest/OpenNAS
$cfdevice = "/dev/{$cfdevice}";
// Get list of all configured disks (physical and virtual).
$a_disk = get_conf_all_disks_list_filtered();
function get_fs_type($devicespecialfile)
{
    global $a_disk;
    $index = array_search_ex($devicespecialfile, $a_disk, "devicespecialfile");
    if (false === $index) {
        return "";
    }
    return $a_disk[$index]['fstype'];
}
if (is_ajax()) {
    $devfile = $_GET['devfile'];
    $fstype = get_fs_type($devfile);
    render_ajax($fstype);
}
function filter_disk($array)
{
    return array_filter($array, function ($diskv) {
        if (0 != strcmp($diskv['size'], "NA") && 1 != disks_exists($diskv['devicespecialfile'])) {
            return $diskv;
        }
    });
}
// Advanced Format
$pconfig['aft4k'] = $aft4k = false;
$do_format = array();
$disks = array();
$type = 'zfs';
$minspace = '';
コード例 #7
0
ファイル: season_actions.php プロジェクト: nishad/bmtmgr
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
utils\require_get_params(['id', 'action']);
$season = Season::by_id($_GET['id']);
switch ($_GET['action']) {
    case 'hide':
    case 'show':
        $season->visible = $_GET['action'] == 'show';
        $season->save();
        render_ajax('season/' . $season->id . '/', ['season' => $season]);
        break;
    default:
        header('HTTP/1.1 404 Not Found');
        render('error', ['title' => 'Unbekannte Aktion', 'msg' => 'Entschuldigung, wir haben eine Adresse falsch eingetragen. Die Aktion "' . $_GET['action'] . '" ist nicht implementiert.']);
}
コード例 #8
0
ファイル: player_edit.php プロジェクト: nishad/bmtmgr
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
utils\require_get_params(['player_id']);
$player = Player::by_id($_GET['player_id']);
utils\require_post_params(['email']);
$player->email = $_POST['email'];
$player->save();
render_ajax('player/' . $player->id . '/', ['player' => $player]);
コード例 #9
0
ファイル: discipline_update.php プロジェクト: nishad/bmtmgr
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
utils\require_get_params(['discipline_id']);
utils\require_post_params(['note', 'capacity']);
$discipline = Discipline::by_id($_GET['discipline_id']);
$discipline->capacity = $_POST['capacity'] !== '' ? \intval($_POST['capacity']) : null;
$discipline->note = $_POST['note'];
$discipline->save();
render_ajax('d/' . $discipline->id . '/', ['discipline' => $discipline]);
コード例 #10
0
ファイル: season_import.php プロジェクト: nishad/bmtmgr
    if (!$club) {
        $club = new User($m['id'], $m['name'], null, ['register']);
        $club->save();
    }
    $players_url = $base_url . 'clubplayers.aspx' . $m['club_path'] . '&cid=' . $m['club_num'];
    $players_page = \file_get_contents($players_url);
    $genders = ['Männer' => 'm', 'Frauen' => 'f'];
    if (!\preg_match_all('#<caption>\\s*(?<gender_str>Männer|Frauen)\\s*</caption><thead>(?P<table>.*?)</tbody>#s', $players_page, $player_table_m, \PREG_SET_ORDER)) {
        continue;
        // Some clubs don't have any players associated with them (because of merger etc.)
    }
    foreach ($player_table_m as $table_m) {
        $g = $genders[$table_m['gender_str']];
        $table = $table_m['table'];
        preg_match_all('#
			<td\\s+id="playercell"><a\\s+href="[^"]+">(?P<name>[^<]+)</a></td>
			<td\\s+class="flagcell">(?:<img.*?/><span[^>]*>\\[(?P<nationality>[A-Z]+)\\]\\s*</span>)?</td>
			<td>(?P<textid>[^>]+)</td>
			<td>(?P<birth_year>[0-9]{4})</td>#xs', $table, $matches, \PREG_SET_ORDER);
        foreach ($matches as $m) {
            if (Player::exists($season, $m['textid'])) {
                continue;
            }
            $p = new Player(['id' => null, 'season_id' => $season->id, 'club_id' => $club->id, 'textid' => $m['textid'], 'name' => $m['name'], 'gender' => $g, 'birth_year' => \intval($m['birth_year']), 'nationality' => $m['nationality'], 'email' => null, 'phone' => null], true);
            $p->save();
        }
    }
}
Model::commit();
render_ajax('season/' . urlencode($season->id) . '/', ['season' => $season]);
コード例 #11
0
ファイル: lp.init.php プロジェクト: pingmalu/LazyPHP4
        render_web($error, 'info');
    }
} catch (\Lazyphp\Core\RestException $e) {
    $class_array = explode('\\', get_class($e));
    $class = t(end($class_array));
    $prefix = strtoupper(rremove($class, 'Exception'));
    $error = get_error($prefix);
    $error['message'] = $error['message'] . '- ' . $e->getMessage();
    $error['created'] = date("Y-m-d H:i:s");
    if (is_json_request() || c('api_server_only')) {
        send_json($error);
    } elseif (is_ajax_request()) {
        render_ajax($error, 'info');
    } else {
        render_web($error, 'info');
    }
} catch (\Exception $e) {
    $class_array = explode('\\', get_class($e));
    $class = t(end($class_array));
    $prefix = strtoupper(rremove($class, 'Exception'));
    $error = get_error($prefix);
    $error['message'] = $error['message'] . '- ' . $e->getMessage();
    $error['created'] = date("Y-m-d H:i:s");
    if (is_json_request() || c('api_server_only')) {
        send_json($error);
    } elseif (is_ajax_request()) {
        render_ajax($error, 'info');
    } else {
        render_web($error, 'info');
    }
}
コード例 #12
0
ファイル: discipline_create.php プロジェクト: nishad/bmtmgr
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
utils\require_get_params(['tournament_id']);
utils\require_post_params(['name', 'dtype']);
$tournament = Tournament::by_id($_GET['tournament_id']);
if ($_POST['dtype'] == 'all') {
    $specs = [['name' => 'HE' . $_POST['name'], 'dtype' => 'MS'], ['name' => 'DE' . $_POST['name'], 'dtype' => 'WS'], ['name' => 'HD' . $_POST['name'], 'dtype' => 'MD'], ['name' => 'DD' . $_POST['name'], 'dtype' => 'WD'], ['name' => 'MX' . $_POST['name'], 'dtype' => 'MX']];
} else {
    $specs = [['name' => $_POST['name'], 'dtype' => $_POST['dtype']]];
}
Model::beginTransaction();
foreach ($specs as $spec) {
    try {
        $discipline = Discipline::create($tournament, $spec['name'], $spec['dtype']);
        $discipline->save();
    } catch (utils\DuplicateEntryException $e) {
        render_ajax_error(sprintf('Disziplin "%s" existiert bereits!', $spec['name']));
        exit;
    }
}
Model::commit();
render_ajax('d/' . $discipline->id . '/', ['tournament' => $tournament, 'disciplines' => $disciplines]);
コード例 #13
0
ファイル: functions.php プロジェクト: Rongya/LazyPHP4
function send_error($type, $info = null, $force_json = false)
{
    if ($error = get_error($type)) {
        if ($info != null) {
            $error['message'] = $error['message'] . ' -' . $info;
        }
    } else {
        $error['message'] = $info;
    }
    //print_r( $error );
    //send_json($error);
    if (is_json_request() || $force_json) {
        return send_json($error);
    } elseif (is_ajax_request()) {
        return render_ajax($error, 'info');
    } else {
        return render_web($error, 'info');
    }
}
コード例 #14
0
ファイル: publication_create.php プロジェクト: nishad/bmtmgr
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
require_once dirname(__DIR__) . '/src/sftp.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
utils\require_get_params(['tournament_id']);
utils\require_post_params(['type']);
$publication_type = $_POST['type'];
$tournament = Tournament::by_id($_GET['tournament_id']);
$season = $tournament->get_season();
switch ($publication_type) {
    case 'sftp':
        utils\require_post_params(['server', 'port', 'username', 'path']);
        $publication = sftp\SFTPPublication::sftp_create($tournament, $_POST['server'], \intval($_POST['port']), $_POST['path'], $_POST['username']);
        $publication->save();
        render_ajax('publication/' . $publication->id . '/', ['publication' => $publication]);
        break;
    default:
        throw new \Exception('Invalid publication type');
}
コード例 #15
0
ファイル: lookup_leagues.php プロジェクト: nishad/bmtmgr
                $age_group = '';
                break;
            case 'U19':
                if ($line['league'] == 'Mini') {
                    $age_group = 'U19-';
                } else {
                    $age_group = 'J';
                }
                break;
        }
        $l = $age_group . $line['league'];
        if (!\array_key_exists($l, $games_in_league)) {
            $games_in_league[$l] = 0;
            $wins_in_league[$l] = 0;
        }
        $games_in_league[$l]++;
        if (\array_key_exists('won', $line)) {
            $wins_in_league[$l]++;
        }
        $days[$line['date']] = $l;
    }
    if (\count($games_in_league) > 0) {
        // For now, pick the league with the most games
        $league = \bmtmgr\utils\array_max_key($games_in_league);
        $player->league = $league;
        $player->winrate = $wins_in_league[$league] / $games_in_league[$league];
        $player->save();
    }
}
render_ajax('t/' . $tournament->id . '/', ['tournament' => $tournament]);
コード例 #16
0
ファイル: status_process.php プロジェクト: rterbush/nas4free
	The views and conclusions contained in the software and documentation are those
	of the authors and should not be interpreted as representing official policies,
	either expressed or implied, of the NAS4Free Project.
*/
require "auth.inc";
require "guiconfig.inc";
$pgtitle = array(gettext("Status"), gettext("Processes"));
function get_process_info()
{
    exec("top -b", $result);
    return implode("\n", $result);
}
if (is_ajax()) {
    $procinfo = get_process_info();
    render_ajax($procinfo);
}
include "fbegin.inc";
?>
<script type="text/javascript">//<![CDATA[
$(document).ready(function(){
	var gui = new GUI;
	gui.recall(0, 5000, 'status_process.php', null, function(data) {
		$('#procinfo').val(data.data);
	});
});
//]]>
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="tabcont">
コード例 #17
0
require "auth.inc";
require "guiconfig.inc";
$pgtitle = array(gettext("Disks"), gettext("ZFS"), gettext("Pools"), gettext("I/O statistics"));
function zfs_zpool_get_iostat()
{
    // Get zpool I/O statistic informations
    $cmd = "zpool iostat -v 2>&1";
    if (isset($_GET['pool'])) {
        $cmd .= " {$_GET['pool']}";
    }
    mwexec2($cmd, $rawdata);
    return implode("\n", $rawdata);
}
if (is_ajax()) {
    $iostat = zfs_zpool_get_iostat();
    render_ajax($iostat);
}
include "fbegin.inc";
?>
<script type="text/javascript">//<![CDATA[
$(document).ready(function(){
	var gui = new GUI;
	gui.recall(0, 5000, 'disks_zfs_zpool_io.php', null, function(data) {
		$('#zfs_zpool_iostat').text(data.data);
	});
});
//]]>
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="tabnavtbl">
コード例 #18
0
	The views and conclusions contained in the software and documentation are those
	of the authors and should not be interpreted as representing official policies,
	either expressed or implied, of the NAS4Free Project.
*/
require "auth.inc";
require "guiconfig.inc";
$pgtitle = array(gettext("Disks"), gettext("Software RAID"), gettext("RAID5"), gettext("Information"));
function get_raidinfo()
{
    exec("/sbin/graid5 list", $rawdata);
    return implode("\n", $rawdata);
}
if (is_ajax()) {
    $raidinfo = get_raidinfo();
    render_ajax($raidinfo);
}
include "fbegin.inc";
?>
<script type="text/javascript">//<![CDATA[
$(document).ready(function(){
	var gui = new GUI;
	gui.recall(0, 5000, 'disks_raid_graid5_info.php', null, function(data) {
		$('#raidinfo').text(data.data);
	});
});
//]]>
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr><td class="tabnavtbl">
  <ul id="tabnav">
コード例 #19
0
ファイル: publication_delete.php プロジェクト: nishad/bmtmgr
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
$u = user\check_current();
$u->require_perm('admin');
utils\require_get_params(['publication_id']);
$publication = Publication::by_id($_GET['publication_id']);
$tournament = $publication->get_tournament();
$publication->delete();
render_ajax('t/' . $tournament->id . '/', []);
コード例 #20
0
ファイル: player_create.php プロジェクト: nishad/bmtmgr
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
utils\require_get_params(['club_id', 'season_id']);
utils\require_post_params(['firstname', 'lastname', 'gender']);
$season = Season::by_id($_GET['season_id']);
$club = User::by_id($_GET['club_id']);
$name = \sprintf('%s, %s', $_POST['lastname'], $_POST['firstname']);
$textid = \str_replace(' ', '_', $club->name . '-' . $_POST['firstname'] . ' ' . $_POST['lastname']);
try {
    $player = Player::create($season->id, $club->id, $textid, $name, $_POST['gender']);
    $player->save();
} catch (utils\DuplicateEntryException $e) {
    render_ajax_error(sprintf('Ein Spieler mit der Id "%s" existiert bereits', $textid));
    exit;
}
render_ajax('season/' . $season->id . '/club/' . $club->id . '/', ['player' => $player]);
コード例 #21
0
ファイル: index.php プロジェクト: sdoney/nas4free
            $a = array();
            $a['raw'] = $match[0];
            $a['key'] = $match[1];
            $a['value'] = isset($match[3]) ? $match[3] : $match[2];
            $vminfo[$a['key']] = $a;
        }
    }
    return $vminfo;
}
if (is_ajax()) {
    $sysinfo = system_get_sysinfo();
    $vipstatus = get_vip_status();
    $sysinfo['vipstatus'] = $vipstatus;
    $upsinfo = get_upsinfo();
    $sysinfo['upsinfo'] = $upsinfo;
    render_ajax($sysinfo);
}
function tblrow($name, $value, $symbol = null, $id = null)
{
    if (!$value) {
        return;
    }
    if ($symbol == '&deg;') {
        $value = sprintf("%.1f", $value);
    }
    if ($symbol == 'Hz') {
        $value = sprintf("%d", $value);
    }
    if ($symbol == 'pre') {
        $value = '<pre>' . $value;
        $symbol = '</pre>';
コード例 #22
0
ファイル: club_create.php プロジェクト: nishad/bmtmgr
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
utils\require_post_params(['name']);
$textid = \preg_replace('/[^a-z]+/', '', strtolower($_POST['name']));
assert(\preg_match('/^[a-z]+$/', $textid));
try {
    $club = User::create($textid, $_POST['name'], null);
    $club->save();
} catch (utils\DuplicateEntryException $e) {
    render_ajax_error('Der Verein "' . $_POST['name'] . '" existiert bereits');
    exit;
}
render_ajax('club/' . $club->id . '/', ['club' => $club]);
コード例 #23
0
ファイル: functions.php プロジェクト: pingmalu/LazyPHP4
function send_error($type, $info = null, $force_json = false)
{
    if ($type == null) {
        $error['message'] = $info;
    } elseif ($error = get_error($type)) {
        if ($info != null) {
            $error['message'] = $error['message'] . ' -' . $info;
        }
    }
    $error['created'] = date("Y-m-d H:i:s");
    //print_r( $error );
    //send_json($error);
    if (is_json_request() || $force_json || c('api_server_only')) {
        return send_json($error);
    } elseif (is_ajax_request()) {
        return render_ajax($error, 'info');
    } else {
        return render_web($error, 'info');
    }
}