/**
  * Create the DOT syntax for a given databases.
  *
  * @param $database Database
  *
  * @return string The DOT syntax created.
  */
 public static function create(Database $database)
 {
     $dotSyntax = '';
     // table nodes
     foreach ($database->getTables() as $table) {
         $columnsSyntax = '';
         foreach ($table->getColumns() as $column) {
             $attributes = '';
             if (count($column->getForeignKeys()) > 0) {
                 $attributes .= ' [FK]';
             }
             if ($column->isPrimaryKey()) {
                 $attributes .= ' [PK]';
             }
             $columnsSyntax .= sprintf('%s (%s)%s\\l', $column->getName(), $column->getType(), $attributes);
         }
         $nodeSyntax = sprintf('node%s [label="{<table>%s|<cols>%s}", shape=record];', $table->getName(), $table->getName(), $columnsSyntax);
         $dotSyntax .= "{$nodeSyntax}\n";
     }
     // relation nodes
     foreach ($database->getTables() as $table) {
         foreach ($table->getColumns() as $column) {
             foreach ($column->getForeignKeys() as $fk) {
                 $relationSyntax = sprintf('node%s:cols -> node%s:table [label="%s=%s"];', $table->getName(), $fk->getForeignTableName(), $column->getName(), implode(',', $fk->getForeignColumns()));
                 $dotSyntax .= "{$relationSyntax}\n";
             }
         }
     }
     return sprintf("digraph G {\n%s}\n", $dotSyntax);
 }
Example #2
0
 /**
  * Returns an array of all the table names in the XML schema
  * @return array
  */
 function getTableNames()
 {
     $table_names = array();
     foreach ($this->database->getTables() as $table) {
         $table_names[] = $table->getName();
     }
     return $table_names;
 }
Example #3
0
 /**
  * Get list of tables that will be tracked (the list items are the command line's arguments in --tables.
  * @param array $list
  * @return array
  */
 public function getTables(array $list)
 {
     $tables = array();
     // Get all tables from the database.
     $allTables = $this->dbms->getTables();
     // Check if the dbtrack tables are in there and remove them.
     $indexActions = array_search('dbtrack_actions', $allTables);
     $indexData = array_search('dbtrack_data', $allTables);
     if ($indexActions !== false) {
         unset($allTables[$indexActions]);
     }
     if ($indexData !== false) {
         unset($allTables[$indexData]);
     }
     // Re-index the array if required.
     if ($indexActions !== false || $indexData !== false) {
         $allTables = array_values($allTables);
     }
     // If there was no --tables argument passed, return all tables.
     if (count($list) == 0) {
         return $allTables;
     }
     // Parse passed tables (like wildcards).
     foreach ($list as $item) {
         // Check if we have any wildcards in the table name.
         if (stripos($item, '*') === false) {
             if (in_array($item, $allTables)) {
                 $tables[] = $item;
             }
         } else {
             // Clean parameter.
             $item = preg_replace('/[^\\*A-Za-z0-9_-]/i', '', $item);
             if (!empty($item)) {
                 // Create regex.
                 $regex = '/' . str_replace('*', '.*', $item) . '/i';
                 $found = preg_grep($regex, $allTables);
                 if (count($found) > 0) {
                     $tables = array_merge($tables, $found);
                 }
             }
         }
     }
     return $tables;
 }
Example #4
0
 protected function validateDatabaseTables(Database $database)
 {
     $phpNames = array();
     foreach ($database->getTables() as $table) {
         if (in_array($table->getPhpName(), $phpNames)) {
             $this->errors[] = sprintf('Table "%s" declares a phpName already used in another table', $table->getName());
         }
         $phpNames[] = $table->getPhpName();
         $this->validateTableAttributes($table);
         $this->validateTableColumns($table);
     }
 }
 private function createFormTypeFromDatabase(BundleInterface $bundle, \Database $database, $models, OutputInterface $output, $force = false)
 {
     $dir = $this->createDirectory($bundle, $output);
     foreach ($database->getTables() as $table) {
         if (0 < count($models) && !in_array($table->getPhpName(), $models)) {
             continue;
         }
         $file = new \SplFileInfo(sprintf('%s/%sType.php', $dir, $table->getPhpName()));
         if (!file_exists($file) || true === $force) {
             $this->writeFormType($bundle, $table, $file, $force, $output);
         } else {
             $output->writeln(sprintf('File <comment>%-60s</comment> exists, skipped. Try the <info>--force</info> option.', $this->getRelativeFileName($file)));
         }
     }
 }
 /**
  * Renders the initial page that comes up when you first install UserFrosting.
  *
  * This page performs the following steps:
  * 1. Check that the current version of PHP is adequate.
  * 2. Check that PDO is installed and enabled.
  * 3. Check that we can connect to the database, as configured in `config-userfrosting.php`.
  * 4. Check that the database tables have not already been created.
  * 5. If all of these checks are passed, set up the initial tables by calling `Database::install()`.
  * This page is "public access".
  * Request type: GET
  * @see MySqlDatabase::install()
  */
 public function pageSetupDB()
 {
     $messages = [];
     // 1. Check PHP version
     // PHP_VERSION_ID is available as of PHP 5.2.7, if our version is lower than that, then emulate it
     if (!defined('PHP_VERSION_ID')) {
         $version = explode('.', PHP_VERSION);
         define('PHP_VERSION_ID', $version[0] * 10000 + $version[1] * 100 + $version[2]);
     }
     if (PHP_VERSION_ID < 50400) {
         $messages[] = ["title" => "You need to upgrade your PHP installation.", "message" => "I'm sorry, UserFrosting relies on numerous features of PHP that are only available in PHP 5.4 or later.  Please upgrade your version of PHP, or contact your web hosting service and ask them to upgrade it for you."];
     }
     // 2. Check that PDO is installed and enabled
     if (!class_exists('PDO')) {
         $messages[] = ["title" => "PDO is not installed.", "message" => "I'm sorry, you must have PDO installed and enabled in order for UserFrosting to access the database.  If you don't know what PDO is, please see <a href='http://php.net/manual/en/book.pdo.php'>http://php.net/manual/en/book.pdo.php</a>.  You must also have MySQL version 4.1 or higher installed, since UserFrosting relies on native prepared statements."];
     }
     // 3. Check database connection
     if (!Database::testConnection()) {
         $messages[] = ["title" => "We couldn't connect to your database.", "message" => "Make sure that your database is properly configured in <code>config-userfrosting.php</code>, and that you have selected the correct configuration mode ('dev' or 'production').  Also, make sure that your database user has the proper privileges to connect to the database."];
     }
     $tables = Database::getTables();
     if (count($tables) > 0) {
         $messages[] = ["title" => "One or more tables already exist.", "message" => "The following tables already exist in the database: <strong>" . implode(", ", $tables) . "</strong>.  Do you already have another installation of UserFrosting in this database?  Please either create a new database (recommended), or change the table prefix in <code>config-userfrosting.php</code> if you cannot create a new database."];
     }
     if (count($messages) > 0) {
         $this->_app->render('common/install/install-errors.html', ['page' => ['author' => $this->_app->site->author, 'title' => "Installation Error", 'description' => "Installation page for UserFrosting", 'alerts' => $this->_app->alerts->getAndClearMessages()], "messages" => $messages]);
     } else {
         // Create tables
         Database::install();
         $messages[] = ["title" => "<i class='fa fa-lock'></i> PDO is installed.", "message" => "No need to worry about any pesky SQL injection attacks!", "class" => "success"];
         $messages[] = ["title" => "<i class='fa fa-database'></i> Database connection", "message" => "Hooray!  We were able to connect to your database and create the core tables for UserFrosting.", "class" => "success"];
         if (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50500) {
             $messages[] = ["title" => "<i class='fa fa-warning'></i> PHP version", "message" => "You currently have version " . PHP_VERSION . " of PHP installed.  We recommend version 5.5 or later.  UserFrosting can still be installed, but we highly recommend you upgrade soon.", "class" => "warning"];
         } else {
             $messages[] = ["title" => "<i class='fa fa-check'></i> PHP version", "message" => "You currently have version " . PHP_VERSION . " of PHP installed.  Good job!", "class" => "success"];
         }
         // Check for GD library (required for Captcha)
         if (!(extension_loaded('gd') && function_exists('gd_info'))) {
             $messages[] = ["title" => "<i class='fa fa-warning'></i> GD library not installed", "message" => "We could not confirm that the <code>GD</code> library is installed and enabled.  GD is an image processing library that UserFrosting uses to generate captcha codes for user account registration.  If you don't need captcha, you can disable it in Site Settings and ignore this message.", "class" => "warning"];
         }
         $this->_app->render('common/install/install-ready.html', ['page' => ['author' => $this->_app->site->author, 'title' => "Installation", 'description' => "Installation page for UserFrosting", 'alerts' => $this->_app->alerts->getAndClearMessages()], "messages" => $messages]);
     }
 }
 protected function validateDatabaseTables(Database $database)
 {
     $phpNames = array();
     $namespaces = array();
     foreach ($database->getTables() as $table) {
         $list =& $phpNames;
         if ($table->getNamespace()) {
             if (!isset($namespaces[$table->getNamespace()])) {
                 $namespaces[$table->getNamespace()] = array();
             }
             $list =& $namespaces[$table->getNamespace()];
         }
         if (in_array($table->getPhpName(), $list)) {
             $this->errors[] = sprintf('Table "%s" declares a phpName already used in another table', $table->getName());
         }
         $list[] = $table->getPhpName();
         $this->validateTableAttributes($table);
         $this->validateTableColumns($table);
     }
 }
 /**
  * Adds any requested validators to the data model.
  *
  * We will add the following type specific validators:
  *
  *      for notNull columns: required validator
  *      for unique indexes: unique validator
  *         for varchar types: maxLength validators (CHAR, VARCHAR, LONGVARCHAR)
  *         for numeric types: maxValue validators (BIGINT, SMALLINT, TINYINT, INTEGER, FLOAT, DOUBLE, NUMERIC, DECIMAL, REAL)
  *         for integer and timestamp types: notMatch validator with [^\d]+ (BIGINT, SMALLINT, TINYINT, INTEGER, TIMESTAMP)
  *         for float types: notMatch validator with [^\d\.]+ (FLOAT, DOUBLE, NUMERIC, DECIMAL, REAL)
  *
  * @param      Database $database The Database model.
  * @return     void
  * @todo       find out how to evaluate the appropriate size and adjust maxValue rule values appropriate
  * @todo       find out if float type column values must always notMatch('[^\d\.]+'), i.e. digits and point for any db vendor, language etc.
  */
 protected function addValidators(Database $database)
 {
     foreach ($database->getTables() as $table) {
         $set = new PropelSchemaReverse_ValidatorSet();
         foreach ($table->getColumns() as $col) {
             if ($col->isNotNull() && $this->isValidatorRequired(self::VALIDATORS_REQUIRED)) {
                 $validator = $set->getValidator($col);
                 $validator->addRule($this->getValidatorRule($col, 'required'));
             }
             if (in_array($col->getType(), array(PropelTypes::CHAR, PropelTypes::VARCHAR, PropelTypes::LONGVARCHAR)) && $col->getSize() && $this->isValidatorRequired(self::VALIDATORS_MAXLENGTH)) {
                 $validator = $set->getValidator($col);
                 $validator->addRule($this->getValidatorRule($col, 'maxLength', $col->getSize()));
             }
             if ($col->isNumericType() && $this->isValidatorRequired(self::VALIDATORS_MAXVALUE)) {
                 $this->log("WARNING: maxValue validator added for column " . $col->getName() . ". You will have to adjust the size value manually.", Project::MSG_WARN);
                 $validator = $set->getValidator($col);
                 $validator->addRule($this->getValidatorRule($col, 'maxValue', 'REPLACEME'));
             }
             if ($col->isPhpPrimitiveType() && $this->isValidatorRequired(self::VALIDATORS_TYPE)) {
                 $validator = $set->getValidator($col);
                 $validator->addRule($this->getValidatorRule($col, 'type', $col->getPhpType()));
             }
         }
         foreach ($table->getUnices() as $unique) {
             $colnames = $unique->getColumns();
             // currently 'unique' validator only works w/ single columns.
             if (count($colnames) == 1) {
                 $col = $table->getColumn($colnames[0]);
                 $validator = $set->getValidator($col);
                 $validator->addRule($this->getValidatorRule($col, 'unique'));
             }
         }
         foreach ($set->getValidators() as $validator) {
             $table->addValidator($validator);
         }
     }
     // foreach table
 }
 public function getAddSchemasDDL(Database $database)
 {
     $ret = '';
     $schemas = array();
     foreach ($database->getTables() as $table) {
         $vi = $table->getVendorInfoForType('pgsql');
         if ($vi->hasParameter('schema') && !isset($schemas[$vi->getParameter('schema')])) {
             $schemas[$vi->getParameter('schema')] = true;
             $ret .= $this->getAddSchemaDDL($table);
         }
     }
     return $ret;
 }
Example #10
0
<?php

require_once __DIR__ . '/app/bootstrap.php';
if (!isset($_GET['action'])) {
    die("No action set.");
}
if (!isset($_GET['db'])) {
    die("No db set.");
}
$action = $_GET['action'];
$active_db = $_GET['db'];
$active_table = false;
if ($action == 'show_menu') {
    $db = new Database($active_db);
    $tables = $db->getTables();
    if ($active_table == false) {
        if (isset($tables[0])) {
            $active_table = $tables[0];
        }
    }
    $curr_table = $db->getTable($active_table);
    // Build default menu for active_db.
    $lm = new ListMenu();
    $lm->setItems($tables);
    $lm->setColumnMax(3);
    TemplateVars::set('tables', $lm->toString($active_table));
    if (count($tables) == 0) {
        die("<em>This database is empty.</em>");
    }
    require_once './app/templates/partials/menu_display.phtml';
    exit;
Example #11
0
 /**
  * Creates a DOM document containing data for specified database.
  * @param Database $database
  * @return DOMDocument
  */
 private function createXMLDoc(Database $database)
 {
     $doc = new DOMDocument('1.0', 'utf-8');
     $doc->formatOutput = true;
     // pretty printing
     $doc->appendChild($doc->createComment("Created by data/dump/Control.tpl template."));
     $dsNode = $doc->createElement("dataset");
     $dsNode->setAttribute("name", "all");
     $doc->appendChild($dsNode);
     $this->log("Building DOM tree containing data from tables:");
     foreach ($database->getTables() as $tbl) {
         $this->log("\t+ " . $tbl->getName());
         $rs = $this->getTableDataRS($tbl->getName());
         while ($rs->next()) {
             $rowNode = $doc->createElement($tbl->getPhpName());
             foreach ($tbl->getColumns() as $col) {
                 $cval = $rs->get($col->getName());
                 if ($cval !== null) {
                     $rowNode->setAttribute($col->getPhpName(), iconv($this->dbEncoding, 'utf-8', $cval));
                 }
             }
             $dsNode->appendChild($rowNode);
             unset($rowNode);
         }
         $rs->close();
     }
     return $doc;
 }
Example #12
0
 /** exdoc
  * This function takes a database object and dumps
  * all of the records in all of the tables into a string.
  * The contents of the string are suitable for storage
  * in a file or other permanent mechanism, and is in
  * the EQL format naively handled by the current
  * implementation.
  *
  * @param Database $db The database object to dump to EQL.
  * @param null $tables
  * @param null $force_version
  * @return string
  * @node Model:expFile
  */
 public static function dumpDatabase($db, $tables = null, $force_version = null)
 {
     $dump = EQL_HEADER . "\r\n";
     if ($force_version == null) {
         $dump .= 'VERSION:' . EXPONENT . "\r\n\r\n";
     } else {
         $dump .= 'VERSION:' . $force_version . "\r\n\r\n";
     }
     if (!is_array($tables)) {
         $tables = $db->getTables();
         if (!function_exists('tmp_removePrefix')) {
             function tmp_removePrefix($tbl)
             {
                 return substr($tbl, strlen(DB_TABLE_PREFIX) + 1);
                 // we add 1, because DB_TABLE_PREFIX  no longer has the trailing
                 // '_' character - that is automatically added by the database class.
             }
         }
         $tables = array_map('tmp_removePrefix', $tables);
     }
     usort($tables, 'strnatcmp');
     foreach ($tables as $table) {
         $dump .= 'TABLE:' . $table . "\r\n";
         foreach ($db->selectObjects($table) as $obj) {
             $dump .= 'RECORD:' . str_replace(array("\r", "\n"), array('\\r', '\\n'), serialize($obj)) . "\r\n";
         }
         $dump .= "\r\n";
     }
     return $dump;
 }
Example #13
0
    public static function install()
    {
        SystemEvent::raise(SystemEvent::INFO, "Creating project related tables...", __METHOD__);
        $tableName = 'project';
        $sql = <<<EOT
DROP TABLE IF EXISTS {$tableName}NEW;
CREATE TABLE IF NOT EXISTS {$tableName}NEW (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  releaselabel TEXT NOT NULL DEFAULT '',
  datecreation DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  datecheckedforchanges DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  deploymentbuilder TEXT NOT NULL DEFAULT '',
  description TEXT DEFAULT '',
  integrationbuilder TEXT NOT NULL DEFAULT '',
  optionreleasepackage TINYINT UNSIGNED NOT NULL DEFAULT 0,
  scmcheckchangestimeout MEDIUMINT UNSIGNED NOT NULL DEFAULT 30,
  scmconnectortype VARCHAR(20) NOT NULL DEFAULT '',
  scmpassword VARCHAR(255) NOT NULL DEFAULT '',
  scmremoterepository VARCHAR(255) NOT NULL DEFAULT '',
  scmusername VARCHAR(255) NOT NULL DEFAULT '',
  scmenvvars VARCHAR(255) NOT NULL DEFAULT '',
  specialtasks TEXT NOT NULL DEFAULT '',
  statsnumbuilds INTEGER UNSIGNED NOT NULL DEFAULT 0,
  status TINYINT UNSIGNED NOT NULL DEFAULT 0,
  title VARCHAR(255) NOT NULL DEFAULT '',
  visits INTEGER UNSIGNED NOT NULL DEFAULT 0,
  workdir VARCHAR(255) NOT NULL DEFAULT '',
  avatar VARCHAR(255) NOT NULL DEFAULT ''
);
EOT;
        if (!Database::setupTable($tableName, $sql)) {
            SystemEvent::raise(SystemEvent::ERROR, "Problems setting up project table.", __METHOD__);
            return false;
        }
        if (!Project_User::install()) {
            return false;
        }
        //
        // Upgrade Project_Build tables
        //
        $tables = Database::getTables();
        $dummyProject = new Project();
        $dummyProject->setAutoSave(false);
        // Never save this dummy project
        foreach ($tables as $table) {
            if (preg_match('/^(projectbuild)(\\d+)$/', $table, $matches)) {
                $dummyProject->setId($matches[2]);
                if (!Project_Build::install($dummyProject)) {
                    return false;
                }
            } elseif (preg_match('/^(projectlog)(\\d+)$/', $table, $matches)) {
                $dummyProject->setId($matches[2]);
                if (!Project_Log::install($dummyProject)) {
                    return false;
                }
            }
        }
        $dummyProject = null;
        unset($dummyProject);
        SystemEvent::raise(SystemEvent::INFO, "All project related tables created.", __METHOD__);
        return true;
    }
 /**
  * Creates a DOM document containing data for specified database.
  *
  * @param Database $database
  *
  * @return DOMDocument
  */
 private function createXMLDoc(Database $database)
 {
     $doc = new DOMDocument('1.0', 'utf-8');
     $doc->formatOutput = true;
     // pretty printing
     $doc->appendChild($doc->createComment("Created by PropelDataDumpTask."));
     $dsNode = $doc->createElement("dataset");
     $dsNode->setAttribute("name", "all");
     $doc->appendChild($dsNode);
     $platform = $this->getGeneratorConfig()->getConfiguredPlatform($this->conn);
     $this->log("Building DOM tree containing data from tables:");
     foreach ($database->getTables() as $tbl) {
         $this->log("\t+ " . $tbl->getName());
         $stmt = $this->getTableDataStmt($tbl->getName(), $platform);
         while ($row = $stmt->fetch()) {
             $rowNode = $doc->createElement($tbl->getPhpName());
             foreach ($tbl->getColumns() as $col) {
                 $cval = $row[$col->getName()];
                 if ($cval !== null) {
                     $rowNode->setAttribute($col->getPhpName(), iconv($this->dbEncoding, 'utf-8', $cval));
                 }
             }
             $dsNode->appendChild($rowNode);
             unset($rowNode);
         }
         unset($stmt);
     }
     return $doc;
 }
Example #15
0
 protected function createForPropel(\Database $database, $models, CrudGenerator $generator, OutputInterface $output)
 {
     $generator->openFile();
     foreach ($database->getTables() as $table) {
         $name = $table->getPhpName();
         if (0 < count($models) && !in_array($name, $models)) {
             continue;
         }
         $output->writeln(sprintf('  > generating <comment>%s</comment>', $name));
         $properties = [];
         foreach ($table->getColumns() as $column) {
             if (!$column->isPrimaryKey()) {
                 $properties[] = $column->getPhpName();
             }
         }
         $generator->generate($name, $table->getNamespace(), $properties);
         $generator->register($name, $table->getNamespace());
     }
     $generator->closeFile();
 }
Example #16
0
 public static function getStats(Project $project, User $user, $access = Access::READ)
 {
     $ret = array();
     //
     // Build outcomes
     //
     $sql = 'SELECT status, COUNT(pb.status) AS c' . ' FROM projectbuild' . $project->getId() . ' pb, projectuser pu' . ' WHERE pu.projectid=?' . ' AND pu.userid=?' . ' AND pu.access & ?' . ' GROUP BY status';
     $val = array($project->getId(), $user->getId(), $access);
     if ($rs = Database::query($sql, $val)) {
         $r = array(0, 0);
         while ($rs->nextRow()) {
             $i = (int) $rs->getStatus();
             if ($i != self::STATUS_FAIL) {
                 $i = 1;
             }
             $r[$i] += (int) $rs->getC();
         }
         $ret['buildOutcomes'] = $r;
     }
     //
     // Build timeline and duration
     //
     $ret['buildTimeline'] = array();
     $ret['buildDuration'] = array();
     $sql = 'SELECT id, status, date, duration' . ' FROM projectbuild' . $project->getId() . ' pb, projectuser pu' . ' WHERE pu.projectid=?' . ' AND pu.userid=?' . ' AND pu.access & ?';
     $val = array($project->getId(), $user->getId(), $access);
     if ($rs = Database::query($sql, $val)) {
         $ok = array();
         $failed = array();
         while ($rs->nextRow()) {
             $date = strtotime($rs->getDate());
             $ret['buildDuration'][] = array($rs->getId(), $rs->getDuration());
             if ($rs->getStatus() != self::STATUS_FAIL) {
                 $ok[] = $date;
             } else {
                 $failed[] = $date;
             }
         }
         $ret['buildTimeline']['ok'] = $ok;
         $ret['buildTimeline']['failed'] = $failed;
     }
     //
     // Quality metrics (PHP_Depend)
     //
     $tables = Database::getTables();
     if (!empty($tables["phpdepend{$project->getId()}"])) {
         $ret['qualityTrend'] = Build_SpecialTask_PhpDepend::getTrend($project, $user, $access);
     }
     return $ret;
 }
Example #17
0
 /**
  * @return array
  *
  * Returns table structure for table returned by tableName()
  */
 private function getTableStructure()
 {
     // if the model is already stored, fetch the value from it.
     if (isset(self::$models[get_class($this)])) {
         return self::$models[get_class($this)]->tableStructure;
     }
     if (!isset($this->tableStructure)) {
         // get table names in the database
         $tables = Database::getTables();
         // check if the table is found in the database
         if (!in_array($this->tableName(), $tables)) {
             Logger::log("Table '%s' doesn't exist in database %s!", $this->tableName(), Config::DB_DATABASE);
             return array();
         }
         // get table structure from the database
         $this->tableStructure = Database::query("SHOW FULL COLUMNS FROM " . $this->tableName());
         if (!$this->tableStructure) {
             return array();
         }
     }
     return $this->tableStructure;
 }
Example #18
0
 protected function showDashboard()
 {
     $tables = Database::getTables();
     foreach ($tables as $table) {
         $tableDescription = Database::getTableStructure($table);
         $where = array();
         if ($tableDescription['season_nefub_id']) {
             $where = array('season_nefub_id' => Season::getInstance()->nefub_id);
         }
         $this->assign('count' . $table, Database::select_count($table, $where));
     }
     $lastLogs = RetrieveLog::getAll(null, 'id', 'desc', 1);
     $oLastLog = $lastLogs[0];
     $this->assign('oLastLog', $oLastLog);
     $availableAPI = false;
     if ($return = @get_headers(NEFUB_API . '/season.php?id=' . Season::getInstance()->nefub_id)) {
         if (substr($return[0], 9, 3) == '200') {
             $availableAPI = true;
         }
     }
     $this->assign('availableAPI', $availableAPI);
     $this->template = '/dashboard.tpl';
     $this->showOutput();
 }
Example #19
0
    }
} else {
    $error_msg = $db->getError();
    displayDbError("Unable to connect to the database " . $error_msg . "\n<br />\n");
    exit(0);
}
/* connected to DB */
// If there is another error we didn't catch
if ($action_required != 'tables') {
    displayInternalError("Invalid status returned after DB connect");
    exit(0);
}
// Make sure tables don't already exist in which case create
// or that they all exist in which case we continue to check / add the details
// we don't allow tables to be overridden (security risk)
$existing_tables = $db->getTables();
$table_count = 0;
// Count number of matching tables - make sure it matches number of required
if (!empty($existing_tables)) {
    foreach ($quiz_tables as $this_table) {
        // add the prefix
        $test_table = $dbsettings['tableprefix'] . $this_table;
        if (in_array($test_table, $existing_tables)) {
            $table_count++;
        }
    }
}
if ($table_count > 0 && $table_count < count($table_count)) {
    displayDbError("Some but not all tables already exists. Unable to continue with install<br />\nYou will need to delete the tables manually to re-run the install or install manually based on the install documentation.");
    exit(0);
} elseif ($table_count == 0) {