Esempio n. 1
0
<?php

namespace bmtmgr;

require_once \dirname(__DIR__) . '/src/common.php';
utils\csrf_protect();
$u = user\check_current();
$u->require_perm('admin');
if (!config\get('allow_import', false)) {
    throw new \Exception('Configuration directive allow_import not set!');
}
// TODO This should later be http://www.blv-nrw.de/blvdb/fb/blv_club_kontakte.php?id=%d
$url_pattern = 'http://localhost/bmtmgr/import/clubs/blv_club_kontakte.php%%3fid=%d';
$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;
    }
Esempio n. 2
0
<?php

namespace bmtmgr;

\set_error_handler(function ($errno, $errstr, $errfile, $errline) {
    throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
});
// All modules can assume access to the following modules and the timezone being set correctly.
require_once __DIR__ . '/utils.php';
require_once __DIR__ . '/model.php';
require_once __DIR__ . '/config.php';
config\Config::load();
require_once __DIR__ . '/db.php';
Model::connect();
require_once __DIR__ . '/user.php';
// These should be autoloaded later
require_once \dirname(__DIR__) . '/models/discipline.php';
require_once \dirname(__DIR__) . '/models/entry.php';
require_once \dirname(__DIR__) . '/models/player.php';
require_once \dirname(__DIR__) . '/models/season.php';
require_once \dirname(__DIR__) . '/models/tournament.php';
require_once \dirname(__DIR__) . '/models/user.php';
require_once \dirname(__DIR__) . '/models/publication.php';
\date_default_timezone_set(config\get('timezone'));
Esempio n. 3
0
<?php

namespace bmtmgr;

require_once dirname(__DIR__) . '/src/common.php';
require_once dirname(__DIR__) . '/src/utils.php';
require_once dirname(__DIR__) . '/src/email.php';
utils\csrf_protect();
utils\require_post_params(array('user'));
$u = User::find_by_input($_POST['user']);
if (!$u) {
    header('HTTP/1.1 404 Not Found');
    render('error', array('title' => 'Benutzer nicht gefunden', 'msg' => 'Benutzer "' . $_POST['user'] . '" konnte nicht gefunden werden.'));
    exit;
}
$s = $GLOBALS['db']->prepare('
	INSERT INTO login_email_token (token, user_id, request_time, expiry_time, metadata_json) VALUES(?, ?, ?, ?, ?)');
$ip = $_SERVER['REMOTE_ADDR'];
$metadata = array('ip' => $ip, 'ua' => $_SERVER['HTTP_USER_AGENT']);
$token = utils\gen_token();
$request_time = time();
$expire_time = $request_time + config\get('email_token_timeout', 24 * 60 * 60);
$s->execute(array($token, $u->id, $request_time, $expire_time, json_encode($metadata)));
$login_url = \bmtmgr\utils\absolute_url() . 'login?t=' . $token;
$m = \bmtmgr\email\send($u->email, 'mails/token_request', array('name' => $u->name, 'email' => $u->email, 'token' => $token, 'until' => $request_time, 'login_url' => $login_url, 'ip' => $ip));
render('token_requested', array('sent_emails' => array($m), 'name' => $u->name, 'email' => $u->email, 'until' => $request_time, 'token_length' => strlen($token), 'ip' => $ip));