Beispiel #1
0
 public function create()
 {
     $status = true;
     global $settings;
     Coach::create($input = array('name' => $this->username, 'passwd' => $this->password, 'mail' => $this->email, 'def_leagues' => array($this->leagueId), 'ring' => ACCESS_LEVEL, 'realname' => '', 'phone' => '', 'settings' => array('lang' => $settings['lang'])));
     #Input: name, realname, passwd, mail, phone, ring, settings, def_leagues (array of LIDs)
     #        $query = sprintf( "INSERT INTO %s ( %s, %s, %s, %s, %s ) VALUES ( '%s', '%s', '%s', %d, %d )",
     #                 USERTABLE,
     #                 USERNAME, PASSWORD, EMAIL, ACTIVATION, ACCESS,
     #                 mysql_real_escape_string($this->username), $this->password, mysql_real_escape_string($this->email), NOT_ACTIVATED, ACCESS_LEVEL );
     $query = sprintf("UPDATE %s SET %s = %d WHERE %s = '%s' LIMIT 1", USERTABLE, ACTIVATION, NOT_ACTIVATED, USERNAME, mysql_real_escape_string($this->username));
     $results = mysql_query($query);
     if (!$results) {
         $status = false;
         $this->error = mysql_error();
     }
     return $status;
 }
Beispiel #2
0
         $_POST['realname'] = stripslashes($_POST['realname']);
         $_POST['mail'] = stripslashes($_POST['mail']);
         $_POST['phone'] = stripslashes($_POST['phone']);
         $_POST['passwd'] = stripslashes($_POST['passwd']);
     }
     global $_LEAGUES;
     $_LEAGUES = $leagues;
     # Trick for create_function() below.
     $errors = array('Please enter a non-empty name (login).' => empty($_POST['name']), 'The chosen name (login) is already in use. Pick another.' => is_numeric(get_alt_col('coaches', 'name', $_POST['name'], 'coach_id')), 'Invalid choice of global access level.' => $_POST['ring'] > $coach->ring, 'Can\'t add the new coach to a league in which you are not a commissioner' => isset($_POST['def_leagues']) && 0 < count(array_filter($_POST['def_leagues'], create_function('$lid', 'global $_LEAGUES; return (!isset($_LEAGUES[$lid]) || $_LEAGUES[$lid]["ring"] != ' . Coach::T_RING_LOCAL_ADMIN . ');'))), 'The chosen language does not exist!' => !in_array($_POST['lang'], Translations::$registeredLanguages));
     foreach ($errors as $msg => $halt) {
         if ($halt) {
             status(false, $msg);
             break 2;
         }
     }
     status($cid = Coach::create(array('name' => $_POST['name'], 'realname' => $_POST['realname'], 'passwd' => $_POST['passwd'], 'mail' => $_POST['mail'], 'phone' => $_POST['phone'], 'ring' => $_POST['ring'], 'def_leagues' => isset($_POST['def_leagues']) ? $_POST['def_leagues'] : array(), 'settings' => array('lang' => $_POST['lang']))));
     $c = new Coach($cid);
     break;
 case 'ch_ring_global':
     $errors = array('You only global admins may change global access levels.' => !$IS_GLOBAL_ADMIN);
     foreach ($errors as $msg => $halt) {
         if ($halt) {
             status(false, $msg);
             break 2;
         }
     }
     status($c->setRing(Coach::T_RING_GROUP_GLOBAL, (int) $_POST['ring']));
     break;
 case 'ch_ring_local':
     $errors = array('You do not have access to the chosen league.' => $CANT_VIEW = !array_key_exists($_POST['lid'], $leagues), 'You are not a commissioner in the selected league.' => $CANT_VIEW || $leagues[$_POST['lid']]['ring'] != Coach::T_RING_LOCAL_ADMIN);
     foreach ($errors as $msg => $halt) {
Beispiel #3
0
function setup_database()
{
    global $core_tables;
    $conn = mysql_up();
    require_once 'lib/class_sqlcore.php';
    // Create core tables.
    echo "<b>Creating core tables...</b><br>\n";
    foreach ($core_tables as $tblName => $def) {
        echo Table::createTable($tblName, $def) ? "<font color='green'>OK &mdash; {$tblName}</font><br>\n" : "<font color='red'>FAILED &mdash; {$tblName}</font><br>\n";
    }
    // Create tables used by modules.
    echo "<b>Creating module tables...</b><br>\n";
    foreach (Module::createAllRequiredTables() as $module => $tables) {
        foreach ($tables as $name => $tblStat) {
            echo $tblStat ? "<font color='green'>OK &mdash; {$name}</font><br>\n" : "<font color='red'>FAILED &mdash; {$name}</font><br>\n";
        }
    }
    echo "<b>Other tasks...</b><br>\n";
    echo SQLCore::syncGameData() ? "<font color='green'>OK &mdash; Synchronize game data with database</font><br>\n" : "<font color='red'>FAILED &mdash; Error whilst synchronizing game data with database</font><br>\n";
    echo SQLCore::installTableIndexes() ? "<font color='green'>OK &mdash; applied table indexes</font><br>\n" : "<font color='red'>FAILED &mdash; could not apply one more more table indexes</font><br>\n";
    echo SQLCore::installProcsAndFuncs(true) ? "<font color='green'>OK &mdash; created MySQL functions/procedures</font><br>\n" : "<font color='red'>FAILED &mdash; could not create MySQL functions/procedures</font><br>\n";
    // Create root user and leave welcome message on messageboard
    global $rootpass;
    $rootpass = isset($rootpass) ? $rootpass : '******';
    echo Coach::create(array('name' => 'root', 'realname' => 'root', 'passwd' => $rootpass, 'ring' => Coach::T_RING_GLOBAL_ADMIN, 'mail' => '', 'phone' => '', 'settings' => array(), 'def_leagues' => array())) ? "<font color=green>OK &mdash; root user created.</font><br>\n" : "<font color=red>FAILED &mdash; root user was not created.</font><br>\n";
    Message::create(array('f_coach_id' => 1, 'f_lid' => Message::T_BROADCAST, 'title' => 'OBBLM installed!', 'msg' => 'Congratulations! You have successfully installed Online Blood Bowl League Manager. See "about" and "introduction" for more information.'));
    // Done!
    mysql_close($conn);
    return true;
}