Feb 16
< ?php
final class Table extends Connector
{
private $TableSQL;
private $TableName;
private $TableClass;
private $TableData;
private $TableTitles;
private $TableModule;
private $ShowPagination;
private $PageNumber;
protected $RowsByPage;function __construct( $SQL, $Name, $Class, $Titles, $Module, $Pagination = true, $Page = 1 )
{
$this-&gt;TableSQL            = $SQL;
$this-&gt;TableName        = $Name;
$this-&gt;TableClass        = $Class;
$this-&gt;TableTitles        = $Titles;
$this-&gt;TableModule        = $Module;
$this-&gt;ShowPagination    = $Pagination;
$this-&gt;PageNumber        = $Page;
$this-&gt;RowsByPage        = 15;if($this-&gt;Pages($SQL)&gt;1)
{
$SQL = $SQL." LIMIT ".(($Page-1)*$this-&gt;RowsByPage)."," . $this-&gt;RowsByPage;
}$this-&gt;TableData        = $this-&gt;Query( $SQL, true, $Titles );
$this-&gt;getTable();
}
 
private function getTable()
{
$Output = "&lt;table name='".$this-&gt;TableName."' id='".$this-&gt;TableName."' class='".$this-&gt;TableClass."' cellpadding=0 cellspacing=0&gt;";
 
if( $this-&gt;TableTitles )
{
$Start = 1;
 
$Output .= "&lt;thead&gt;";
 
$Output .= "&lt;tr&gt;";
 
for( $i=0; $i&lt;count( $this-&gt;TableData[0] ); $i++ )
{
$Output .= "&lt;th&gt;" . $this-&gt;TableData[0][$i] . "&lt;/th&gt;";
}
 
$Output .= "&lt;/tr&gt;";
 
$Output .= "&lt;/thead&gt;";
}
else
{
$Start = 0;
}
 
$Output .= "&lt;tbody&gt;";
 
$Color = "#ffffff";
 
for( $i=$Start; $i&lt;count( $this-&gt;TableData ); $i++ )
{
if($Color == "#f1f1f1")
{
$Color = "#ffffff";
}
else
{
$Color = "#f1f1f1";
}
 
$Output .= "&lt;tr bgcolor='".$Color."' onclick=Go('driver.php?Module=".$this-&gt;TableModule."&amp;Method=Edit&amp;RegisterID=".$this-&gt;TableData[$i][0]."') title='Clique para editar este registro...'&gt;";
 
for( $j=0; $j&lt;count( $this-&gt;TableData[$i] ); $j++ )
{
$Output .= "&lt;td&gt;" . $this-&gt;TableData[$i][$j] . "&lt;/td&gt;";
}
 
$Output .= "&lt;/tr&gt;";
}
 
$Output .= "&lt;/tbody&gt;";
 
$Output .= "&lt;/table&gt;";
 
print( $Output );
 
if($this-&gt;ShowPagination)
{
$this-&gt;PageLinks();
}
}
 
private function PageLinks()
{
if($this-&gt;ShowPagination)
{
print("&lt;div id='Barra'&gt;");
 
print("&lt;img src='Resources/Images/InGrid/page-first.png' class='Paginacao' onclick=Go('driver.php?Module=".$this-&gt;TableModule."&amp;Method=View&amp;Page=1');&gt;");
 
if($this-&gt;PageNumber &gt;= 1)
{
print("&lt;img src='Resources/Images/InGrid/page-prev.png' class='Paginacao' onclick=Go('driver.php?Module=".$this-&gt;TableModule."&amp;Method=View&amp;Page=".($this-&gt;PageNumber-1)."');&gt;");
}
else
{
print("&lt;img src='Resources/Images/InGrid/page-prev.png' class='Paginacao'&gt;");
}
 
if($this-&gt;Pages($this-&gt;TableSQL) &gt; 0)
{
print("&lt;img src='Resources/Images/InGrid/page-next.png' class='Paginacao' onclick=Go('driver.php?Module=".$this-&gt;TableModule."&amp;Method=View&amp;Page=".($this-&gt;PageNumber+1)."');&gt;");
}
else
{
print("&lt;img src='Resources/Images/InGrid/page-next.png' class='Paginacao'&gt;");
}
 
print("&lt;img src='Resources/Images/InGrid/page-last.png' class='Paginacao' onclick=Go('driver.php?Module=".$this-&gt;TableModule."&amp;Method=View&amp;Page=".$this-&gt;Pages($this-&gt;TableSQL)."');&gt;");
 
print("&lt;/div&gt;");
}
}
}
?>
Feb 16
< ?php
/**
* XML
* Classe de cria??o de arquivos XML
*
* @version 0.01b
* @author Brajola &lt;brajola@brajola.com&gt;
* @copyright 2008 - Brajola.com
* @license http://www.gnu.org/licenses/gpl-3.0.txt
*/
final class XML
{
/**
* FileName
* Nome do arquivo XML
*/
private $FileName;/**
* Nodes
* Matriz com todos os n?s do arquivo
*/
private $Nodes;/**
* SubNodes
* Matriz com todos os sub-n?s do arquivo
*/
private $SubNodes;/**
* XMLData
* Dados brutos do XML
*/
private $XMLData;
 
/**
* __construct
* Constru??o da classe
*/
function __construct( $FileName )
{
$this-&gt;FileName = $FileName;
 
$this-&gt;Nodes = array();
$this-&gt;SubNodes = array();
}
 
/**
* MakeFile
* Constr?i o arquivo XML e grava
*/
public final function MakeFile()
{
$this-&gt;XMLData = $this-&gt;OpenDeclaration();
 
for( $i=0; $i&lt;count( $this-&gt;Nodes ); $i++ )
{
$this-&gt;XMLData .= "\t&lt;".$this-&gt;Nodes[$i]."&gt;\n";
 
for( $j=0; $j&lt;count( $this-&gt;SubNodes ); $j++ )
{
if( $this-&gt;SubNodes[$j][0] == $i )
{
$this-&gt;XMLData .= $this-&gt;ParseSubNode(
$this-&gt;SubNodes[$j][1],
$this-&gt;SubNodes[$j][2]
);
}
}
 
$this-&gt;XMLData .= "\t&lt;/".$this-&gt;Nodes[$i]."&gt;\n";
}
 
$this-&gt;XMLData .= $this-&gt;CloseDeclaration();
 
$fHandler = fopen( $this-&gt;FileName . ".xml", "w" );
fwrite( $fHandler, $this-&gt;XMLData );
fclose( $fHandler );
}
 
/**
* OpenDeclaration
* Inicia a declara??o do arquivo XML
*/
private final function OpenDeclaration()
{
return '&lt;?xml version="1.0" encoding="UTF-8"?&gt;'."\n"."&lt;".$this-&gt;FileName."&gt;\n";
}
 
/**
* CloseDeclaration
* Encerra a declara??o do arquivo XML
*/
private final function CloseDeclaration()
{
return "&lt;/".$this-&gt;FileName."&gt;\n";
}
 
/**
* AddNode
* Adiciona um n? a matriz de dados
*/
public final function AddNode( $NodeName )
{
$this-&gt;Nodes[] = $NodeName;
}
 
/**
* AddSubNode
* Adiciona um sub-n? a matriz de dados
*/
public final function AddSubNode( $NodeID, $Name, $Value )
{
$this-&gt;SubNodes[] = array( $NodeID, $Name, $Value );
}
 
/**
* ParseSubNode
* Trata os dados do sub-n?
*/
private function ParseSubNode( $NodeName, $NodeValue )
{
return "\t\t&lt;".$NodeName."&gt;".$NodeValue."&lt;/".$NodeName."&gt;\n";
}
}
?>
Feb 16
< ?php
/**
* Connector
* Classe de conex?o a bancos de dados
*
* Esta classe se conecta a servidores de bancos de dados
* provendo uma camada de abstra??o relevanta entre a
* aplica??o e o servidor.
*
* @version 0.01b
* @link http://brajola.com
* @author Brajola &lt;brajola@brajola.com&gt;
* @copyright 2008 - Brajola.com
* @license http://www.gnu.org/licenses/gpl-3.0.txt
*/
class Connector
{
/**
* HostName
* Nome do servidor
*
* @var HostName
* @access private
* @author Brajola &lt;brajola@brajola.com&gt;
*/
private $HostName;/**
* UserName
* Nome do usu?rio
*
* @var UserName
* @access private
* @author Brajola &lt;brajola@brajola.com&gt;
*/
private $UserName;/**
* UserPass
* Senha de acesso do usu?rio
*
* @var UserPass
* @access private
* @author Brajola &lt;brajola@brajola.com&gt;
*/
private $UserPass;/**
* Database
* Nome do banco de dados
*
* @var Database
* @access private
* @author Brajola &lt;brajola@brajola.com&gt;
*/
private $Database;
 
/**
* RowsByPage
* Número de registros por página
*
* @var Database
* @access protected
* @author Brajola &lt;brajola@brajola.com&gt;
*/
protected $RowsByPage;
 
/**
* __construct
* Constru??o da Classe
*
* @param string $Host
* @param string $User
* @param string $Pass
* @param string $Data
*
* @access public
* @author Brajola &lt;brajola@brajola.com&gt;
*/
public function __construct( $Host,$User,$Pass,$Data )
{
$this-&gt;HostName = $Host;
$this-&gt;UserName = $User;
$this-&gt;UserPass    = $Pass;
$this-&gt;Database = $Data;
 
if( !$this-&gt;Connect() )
{
die("Connection Error");
}
 
$this-&gt;RowsByPage = 15;
}
 
/**
* Connect
* Conecta ao servidor
*
* @access private
* @author Brajola &lt;brajola@brajola.com&gt;
*/
private final function Connect()
{
try
{
if( !mysql_connect($this-&gt;HostName,$this-&gt;UserName,$this-&gt;UserPass) )
{
throw new Exception( "Connection Error" );
}
 
if( !mysql_select_db( $this-&gt;Database ) )
{
throw new Exception( "Connection Error" );
}
 
return true;
}
catch (Exception $e)
{
return false;
}
}
 
/**
* Query
* Executa uma consulta
*
* @param string $SQL
* @param boolean $Return
* @param boolean $Titles
*
* @return mixed
*
* @access protected
* @author Brajola &lt;brajola@brajola.com&gt;
*/
public final function Query( $SQL, $Return, $Titles )
{
$Result = mysql_query( $SQL );
 
if( !$Return )
{
return true;
}
 
$ReturnData = array();
 
if( $Titles )
{
for( $i=0;$i&lt;mysql_num_fields( $Result ); $i++ )
{
$ReturnData[0][$i] = mysql_field_name( $Result, $i );
}
}
 
while( $Row = mysql_fetch_row( $Result ) )
{
array_push( $ReturnData, $Row );
}
 
return $ReturnData;
}
 
/**
* Count
* Conta os elementos de uma consulta
*
* @param string $SQL
*
* @return mixed
*
* @access protected
* @author Brajola &lt;brajola@brajola.com&gt;
*/
public final function Count( $SQL )
{
$Result = mysql_query( $SQL );
 
$ReturnData = array();
 
while( $Row = mysql_fetch_row( $Result ) )
{
array_push( $ReturnData, $Row );
}
 
return count($ReturnData);
}
 
/**
* Pages
* Conta as páginas de uma consulta
*
* @param string $SQL
*
* @return mixed
*
* @access protected
* @author Brajola &lt;brajola@brajola.com&gt;
*/
public final function Pages( $SQL )
{
$Result = mysql_query( $SQL );
 
$ReturnData = array();
 
while( $Row = mysql_fetch_row( $Result ) )
{
array_push( $ReturnData, $Row );
}
 
return ceil(count($ReturnData)/$this-&gt;RowsByPage);
}
}
?>
Feb 16

Segue o link do melhor tutorial sobre Dialog que encontrei na internet.

*Todas as operações descritas no tutorial também podem ser utilizadas para o xDialog.

http://aurelio.net/dialog

Feb 16

Seguem alguns links legais para quem está pensando em construir um cluster ou mais.

Clusters em Linux
http://www.linuxjournal.com/article/4344
http://clusterknoppix.sw.be/
http://tldp.org/HOWTO/Cluster-HOWTO.html
http://www.linuxvirtualserver.org/
http://www.lcic.org/
http://openmosix.sourceforge.net/

Clusters para MySQL
http://www.oreillynet.com/pub/a/databases/2006/02/16/ha_mysql_cluster.html

Clusters em SQL Server
http://www.databasejournal.com/features/mssql/article.php/3456991