Estou a meio de um desafio de programacao e precisava apenas de uma caminho a seguir o codigo que tenho de rever :
<?php
require_once( "settings.php" );
class Database{
function __construct(){
$this->setDefaults();
}
function setDefaults(){
if( !isset($this->host) ) $this->host = DB_HOST;
if( !isset($this->user) ) $this->user = DB_USER;
if( !isset($this->pass) ) $this->pass = DB_PASS;
if( !isset($this->name) ) $this->name = DB_NAME;
$this->description = $this->user."@".$this->host."/".$this->name;
}
function connect(){
$this->connection = new mysqli( $this->host, $this->user, $this->pass, $this->name );
if( !$this->connection ) die( "Connection to ".$this->host." failed!" );
}
function query( $sql ){
if( !isset( $this->connection ) ) $this->connect();
$this->result = $this->connection->query( $sql );
return $this->result;
}
function fetchRow(){
return $this->result->fetch_assoc();
}
}
class Flag{
function getFlag(){
return file_get_contents( FLAG_PATH );
}
}
class Page{
function __construct(){
$this->elements = array();
$this->html = "";
}
function __wakeup(){
$this->compile();
}
function addElement($el){
return $this->elements[] = $el;
}
function render(){
if( empty( $this->html ) ) $this->compile();
return $this->html;
}
function compile(){
foreach( $this->elements as $el ){
$this->html .= $el->render();
}
}
}
Interface Element{
function render();
}
class SelectElement implements Element{
function render(){
if( empty( $this->aItems ) ) return "";
$html = "<select>\n";
foreach( $this->aItems as $k => $item ){
$html .= "<option>".$item."</option>\n";
}
$html .= "</select>\n";
return $html;
}
}
class ObjectDescriber{
function __construct( $obj, $prop, $type ){
$this->obj = $obj;
$this->prop = $prop;
$this->t = $type;
}
function __toString(){
if( $this->t == "m" ){
return $this->obj->{$this->prop}();
}else{
return $this->obj->{$this->prop};
}
}
}
class DatabaseDescriber extends ObjectDescriber{
function __construct( $db ){
$this->obj = $db;
$this->prop = "description";
$this->t = "p";
}
}
?>
Desafio :
Receber o valor de Flag->getFlag()