Fóruns sobre PHP, JavaScript, HTML, MySQLi, jQuery, Banco de Dados, CSS


Moderador: web

 
Mais de 25 postagens
Mais de 25 postagens
Tópico Autor
Mensagens: 49
Nome: Renildo Marcio
Descrição do site: Web Radio Gratis
Localização: goias / goiania / brasil
Contato:

Top 10 - com Administração

25-06-2009 15:01

Olá pessoal.
Vamos Fazer um Top 10 com administração?

Então vamos começa!

sql.txt

CREATE TABLE IF NOT EXISTS `admin_top10` ( `id_admin` int(11) NOT NULL auto_increment, `id_admin_login` varchar(50) NOT NULL, `id_admin_senha` varchar(50) NOT NULL, `id_admin_nome` varchar(50) NOT NULL, PRIMARY KEY (`id_admin`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ; -- -- Extraindo dados da tabela `admin_top10` -- INSERT INTO `admin_top10` (`id_admin`, `id_admin_login`, `id_admin_senha`, `id_admin_nome`) VALUES (1, 'admin', 'admin', 'admin'); CREATE TABLE IF NOT EXISTS `top10` ( `id_top10` int(11) NOT NULL auto_increment, `nome` varchar(100) NOT NULL, PRIMARY KEY (`id_top10`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ; -- -- Extraindo dados da tabela `top10` -- INSERT INTO `top10` (`id_top10`, `nome`) VALUES (1, 'Rihana - Please Dont stop the music'), (2, 'Chris Brown and ordin Sparks - No Air'), (3, 'Charlie Brown - Beco sem saida'), (4, 'em breve'), (5, 'em breve'), (6, 'em breve'), (7, 'em breve'), (8, 'em breve'), (9, 'em breve'), (10, 'em breve');

index.hp

<?php require_once('Connections/conexao.php'); ?> <?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "login.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $maxRows_Listatop10 = 10; $pageNum_Listatop10 = 0; if (isset($_GET['pageNum_Listatop10'])) { $pageNum_Listatop10 = $_GET['pageNum_Listatop10']; } $startRow_Listatop10 = $pageNum_Listatop10 * $maxRows_Listatop10; mysql_select_db($database_conexao, $conexao); $query_Listatop10 = "SELECT * FROM top10"; $query_limit_Listatop10 = sprintf("%s LIMIT %d, %d", $query_Listatop10, $startRow_Listatop10, $maxRows_Listatop10); $Listatop10 = mysql_query($query_limit_Listatop10, $conexao) or die(mysql_error()); $row_Listatop10 = mysql_fetch_assoc($Listatop10); if (isset($_GET['totalRows_Listatop10'])) { $totalRows_Listatop10 = $_GET['totalRows_Listatop10']; } else { $all_Listatop10 = mysql_query($query_Listatop10); $totalRows_Listatop10 = mysql_num_rows($all_Listatop10); } $totalPages_Listatop10 = ceil($totalRows_Listatop10/$maxRows_Listatop10)-1; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Top 10</title> <style type="text/css"> <!-- .style1 { color: #000000; font-weight: bold; font-family: Tahoma; } --> </style> </head> <body> <table width="785" border="0" bgcolor="#FFFFCC"> <tr> <td><table width="780" border="0"> <tr> <td bgcolor="#99FFFF"><table width="780" border="0"> <tr> <td><span class="style1">Top10 - noossaradioweb.com |<a href="index.php">Inicio</a>|<a href="cadastra_usu.php">Cadastra usuários</a> |<a href="mostra_lista_codigo.php">Mostra Top10</a>|<a href="<?php echo $logoutAction ?>">Sair</a></span></td> </tr> <tr> <td><div align="center"> <table width="529" border="0"> <tr> <td width="64" bgcolor="#FFFFFF">Id :</td> <td width="374" bgcolor="#FFFFCC">Lista de Top 10</td> </tr> </table> <?php do { ?> <table width="529" border="0" align="center"> <tr> <td width="116" bgcolor="#FFFFCC"><?php echo $row_Listatop10['id_top10']; ?></td> <td width="403" bgcolor="#FFFFFF"><?php echo $row_Listatop10['nome']; ?></td> <td width="403"><a href="alterar.php?id_top10=<?php echo $row_Listatop10['id_top10']; ?>">Atualizar</a></td> </tr> </table> <?php } while ($row_Listatop10 = mysql_fetch_assoc($Listatop10)); ?>Desevolvido por : Renildo Marcio - Apoio: <a href="http://localhostr.com.br" target="_blank">Local Host Br - Hospedagens</a><br /> </div></td> </tr> </table></td> </tr> </table></td> </tr> </table> </body> </html> <?php mysql_free_result($Listatop10); ?>

cadastra-usu.php

<?php require_once('Connections/conexao.php'); ?><?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "login.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO admin_top10 (id_admin_nome, id_admin_login, id_admin_senha) VALUES (%s, %s, %s)", GetSQLValueString($_POST['id_admin_nome'], "text"), GetSQLValueString($_POST['id_admin_login'], "text"), GetSQLValueString($_POST['id_admin_senha'], "text")); mysql_select_db($database_conexao, $conexao); $Result1 = mysql_query($insertSQL, $conexao) or die(mysql_error()); $insertGoTo = "sucesso_admin.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Top 10</title> <style type="text/css"> <!-- .style1 { color: #000000; font-weight: bold; font-family: Tahoma; } --> </style> </head> <body> <table width="785" border="0" bgcolor="#FFFFCC"> <tr> <td><table width="780" border="0"> <tr> <td bgcolor="#99FFFF"><table width="780" border="0"> <tr> <td><span class="style1">Top10 - noossaradioweb.com |<a href="index.php">Inicio</a>|<a href="cadastra_usu.php">Cadastra usuários</a> |<a href="mostra_lista_codigo.php">Mostra Top10</a>|<a href="<?php echo $logoutAction ?>">Sair</a></span></td> </tr> <tr> <td><div align="center"> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Nome:</td> <td><input type="text" name="id_admin_nome" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Login:</td> <td><input type="text" name="id_admin_login" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Senha:</td> <td><input type="password" name="id_admin_senha" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">&nbsp;</td> <td><input type="submit" value="Cadastrar" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form> <p>&nbsp;</p> <br /> </div> <p align="center">Desenvolvido por: Renildo Marcio - Apoio <a href="http://localhostbr.com.br" target="_blank">Local Host Br - Hospedagens</a></p></td> </tr> </table></td> </tr> </table></td> </tr> </table> </body> </html>

mostra_lista_codigo.php

<?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "login.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Top 10</title> <style type="text/css"> <!-- .style1 { color: #000000; font-weight: bold; font-family: Tahoma; } .style2 { color: #FF0000; font-weight: bold; } --> </style> </head> <body> <table width="785" border="0" bgcolor="#FFFFCC"> <tr> <td><table width="780" border="0"> <tr> <td bgcolor="#99FFFF"><table width="780" border="0"> <tr> <td><span class="style1">Top10 - noossaradioweb.com |<a href="index.php">Inicio</a>|<a href="cadastra_usu.php">Cadastra usuários</a> |<a href="mostra_lista_codigo.php">Mostra Top10</a>|<a href="<?php echo $logoutAction ?>">Sair</a></span></td> </tr> <tr> <td><div align="center"> <p><span class="style2">"Iframe" </span><br /> <br /> <input name="textfield" type="text" id="textfield" value="<IFRAME name=top10 src=top10/mostra_lista.php width=400 height=700 frameborder=0 scrolling=auto></IFRAME>" size="100" /> </p> <p><span class="style2">"include"</span><br /> <br /> <?php include('top10/mostra_lista.php'); ?><br /> <br /> </p> </div> <p align="center">Desenvolvido por: Renildo Marcio - Apoio <a href="http://localhostbr.com.br" target="_blank">Local Host Br - Hospedagens</a></p></td> </tr> </table></td> </tr> </table></td> </tr> </table> </body> </html>


mostra_lista.php

<?php require_once('Connections/conexao.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $maxRows_Listatop10 = 10; $pageNum_Listatop10 = 0; if (isset($_GET['pageNum_Listatop10'])) { $pageNum_Listatop10 = $_GET['pageNum_Listatop10']; } $startRow_Listatop10 = $pageNum_Listatop10 * $maxRows_Listatop10; mysql_select_db($database_conexao, $conexao); $query_Listatop10 = "SELECT * FROM top10"; $query_limit_Listatop10 = sprintf("%s LIMIT %d, %d", $query_Listatop10, $startRow_Listatop10, $maxRows_Listatop10); $Listatop10 = mysql_query($query_limit_Listatop10, $conexao) or die(mysql_error()); $row_Listatop10 = mysql_fetch_assoc($Listatop10); if (isset($_GET['totalRows_Listatop10'])) { $totalRows_Listatop10 = $_GET['totalRows_Listatop10']; } else { $all_Listatop10 = mysql_query($query_Listatop10); $totalRows_Listatop10 = mysql_num_rows($all_Listatop10); } $totalPages_Listatop10 = ceil($totalRows_Listatop10/$maxRows_Listatop10)-1; ?><title>Top 10</title> <table width="287" border="0"> <tr> <td width="541"><table width="281" border="0"> <tr> <td width="275"><table width="275" border="0"> <tr> <td width="269"><div align="center"> <?php do { ?> <table width="266" border="0" align="center"> <tr> </tr> <tr> <td width="139" align="left" valign="top"><?php echo $row_Listatop10['id_top10']; ?></td> <td width="117" align="left" valign="top"><?php echo $row_Listatop10['nome']; ?></td> </tr> </table> <?php } while ($row_Listatop10 = mysql_fetch_assoc($Listatop10)); ?><br /> </div></td> </tr> </table></td> </tr> </table></td> </tr> </table> <?php ?>

alterar.php

<?php require_once('Connections/conexao.php'); ?> <?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "login.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) $MM_referrer .= "?" . $QUERY_STRING; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE top10 SET nome=%s WHERE id_top10=%s", GetSQLValueString($_POST['nome'], "text"), GetSQLValueString($_POST['id_top10'], "int")); mysql_select_db($database_conexao, $conexao); $Result1 = mysql_query($updateSQL, $conexao) or die(mysql_error()); $updateGoTo = "sucesso.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } $colname_Atualizartop10 = "-1"; if (isset($_GET['id_top10'])) { $colname_Atualizartop10 = $_GET['id_top10']; } mysql_select_db($database_conexao, $conexao); $query_Atualizartop10 = sprintf("SELECT * FROM top10 WHERE id_top10 = %s", GetSQLValueString($colname_Atualizartop10, "int")); $Atualizartop10 = mysql_query($query_Atualizartop10, $conexao) or die(mysql_error()); $row_Atualizartop10 = mysql_fetch_assoc($Atualizartop10); $totalRows_Atualizartop10 = mysql_num_rows($Atualizartop10); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Top 10</title> <style type="text/css"> <!-- .style1 { color: #000000; font-weight: bold; font-family: Tahoma; } --> </style> </head> <body> <table width="785" border="0" bgcolor="#FFFFCC"> <tr> <td><table width="780" border="0"> <tr> <td bgcolor="#99FFFF"><table width="780" border="0"> <tr> <td><span class="style1">Top10 - noossaradioweb.com |<a href="index.php">Inicio</a>|<a href="cadastra_usu.php">Cadastra usuários</a> |<a href="mostra_lista_codigo.php">Mostra Top10</a>|<a href="<?php echo $logoutAction ?>">Sair</a></span></td> </tr> <tr> <td><form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Top <?php echo $row_Atualizartop10['id_top10']; ?>: :</td> <td><input type="text" name="nome" value="<?php echo htmlentities($row_Atualizartop10['nome'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">&nbsp;</td> <td><input type="submit" value="Atualizar" /></td> </tr> </table> <input type="hidden" name="MM_update" value="form1" /> <input type="hidden" name="id_top10" value="<?php echo $row_Atualizartop10['id_top10']; ?>" /> </form> <div align="center">Desenvolvido por: Renildo Marcio - Apoio <a href="http://localhostbr.com.br" target="_blank">Local Host Br - Hospedagens</a></div></td> </tr> </table></td> </tr> </table></td> </tr> </table> </body> </html> <?php mysql_free_result($Atualizartop10); ?>

login.php

<?php require_once('Connections/conexao.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['id_admin_login'])) { $loginUsername=$_POST['id_admin_login']; $password=$_POST['id_admin_senha']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "index.php"; $MM_redirectLoginFailed = "login.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_conexao, $conexao); $LoginRS__query=sprintf("SELECT id_admin_login, id_admin_senha FROM admin_top10 WHERE id_admin_login=%s AND id_admin_senha=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $conexao) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Top 10</title> <style type="text/css"> <!-- .style1 { color: #000000; font-weight: bold; font-family: Tahoma; } --> </style> </head> <body> <table width="785" border="0" bgcolor="#FFFFCC"> <tr> <td><table width="780" border="0"> <tr> <td bgcolor="#99FFFF"><table width="780" border="0"> <tr> <td><span class="style1">Top10 - noossaradioweb.com</span></td> </tr> </table> <form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>"> <table width="360" border="0" align="center" class="style1"> <tr> <td>Login :</td> <td><input name="id_admin_login" type="text" id="id_admin_login" size="40" /></td> </tr> <tr> <td>Senha :</td> <td><input name="id_admin_senha" type="password" id="id_admin_senha" size="32" /></td> </tr> <tr> <td colspan="2"><input type="submit" name="button2" id="button2" value="entra" /></td> </tr> </table> </form> <p align="center">Desenvolvido por: Renildo Marcio - Apoio <a href="http://localhostbr.com.br" target="_blank">Local Host Br - Hospedagens</a></p></td> </tr> </table></td> </tr> </table> </body> </html>

sucesso.php

<?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "login.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Top 10</title> <style type="text/css"> <!-- .style1 { color: #000000; font-weight: bold; font-family: Tahoma; } --> </style> </head> <body> <table width="785" border="0" bgcolor="#FFFFCC"> <tr> <td><table width="780" border="0"> <tr> <td bgcolor="#99FFFF"><table width="780" border="0"> <tr> <td><span class="style1">Top10 - noossaradioweb.com |<a href="index.php">Inicio</a>|<a href="cadastra_usu.php">Cadastra usuários</a> |<a href="<?php echo $logoutAction ?>">Sair</a></span></td> </tr> <tr> <td><div align="center"><br /> Top 10 Alterado com sucesso! <a href="index.php">clique aqui</a> para volta</div> <p align="center">Desenvolvido por: Renildo Marcio - Apoio <a href="http://localhostbr.com.br" target="_blank">Local Host Br - Hospedagens</a></p></td> </tr> </table></td> </tr> </table></td> </tr> </table> </body> </html>

sucesso_admin.php

<?php //initialize the session if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['MM_Username'] = NULL; $_SESSION['MM_UserGroup'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['MM_Username']); unset($_SESSION['MM_UserGroup']); unset($_SESSION['PrevUrl']); $logoutGoTo = "login.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Top 10</title> <style type="text/css"> <!-- .style1 { color: #000000; font-weight: bold; font-family: Tahoma; } --> </style> </head> <body> <table width="785" border="0" bgcolor="#FFFFCC"> <tr> <td><table width="780" border="0"> <tr> <td bgcolor="#99FFFF"><table width="780" border="0"> <tr> <td><span class="style1">Top10 - noossaradioweb.com |<a href="index.php">Inicio</a>|<a href="cadastra_usu.php">Cadastra usuários</a> |<a href="mostra_lista_codigo.php">Mostra Top10</a>|<a href="<?php echo $logoutAction ?>">Sair</a></span></td> </tr> <tr> <td><div align="center"><br /> Cadastrado com sucesso! <a href="index.php">clique aqui</a> para volta</div> <p align="center">Desenvolvido por: Renildo Marcio - Apoio <a href="http://localhostbr.com.br" target="_blank">Local Host Br - Hospedagens</a></p></td> </tr> </table></td> </tr> </table></td> </tr> </table> </body> </html>

Continuar no proximo post!
0
Web site:
www.webradiogratis.com

Cadastro:
http://auth.webradiogratis.com/index.php

Comunidade Codigos na Web
http://www.orkut.com.br/Main#Community?cmm=94905489

Acessem a comunidade do codigos na web no orkut...
 
Mais de 25 postagens
Mais de 25 postagens
Tópico Autor
Mensagens: 49
Nome: Renildo Marcio
Descrição do site: Web Radio Gratis
Localização: goias / goiania / brasil
Contato:

Top 10 - com Administração

25-06-2009 15:03

Continuação do post!

Agora vamos criar as pastas Connections e _mmServerScripts ok?

Connections/conexao.php

<?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_conexao = "localhost"; $database_conexao = "radio_site"; $username_conexao = "radio_site"; $password_conexao = "123456"; $conexao = mysql_pconnect($hostname_conexao, $username_conexao, $password_conexao) or trigger_error(mysql_error(),E_USER_ERROR); ?>

_mmServerScripts/MMHTTPDB.php

<?php // <ERRORS><ERROR><DESCRIPTION>Your testing server do not has support for PHP pages</DESCRIPTION></ERROR>\n</ERRORS> $debug_to_file = false; function log_messages($error_message){ global $f, $debug_to_file; if ($debug_to_file === true){ if (!is_resource($f)){ @ini_set('display_errors', 1); @error_reporting(E_ALL); $f = @fopen('log.txt', 'a'); } if (is_resource($f)){ return @fwrite($f, $error_message."\n"); } } return false; } function create_error($error_msg = '', $line = -1){ if ($error_msg != ''){ return '<ERRORS><ERROR><DESCRIPTION>'.$error_msg.'</DESCRIPTION></ERROR></ERRORS>\n'; }else{ return '<ERRORS><ERROR><DESCRIPTION> Unidentified Connection Error at Line '.$line.'</DESCRIPTION></ERROR></ERRORS>\n'; } } log_messages("\n--------------------------------"); // what parameters were sent ?! foreach($_POST as $key=>$value) { if (strtoupper($key) != 'PASSWORD'){ log_messages('$_POST["'.$key.'"] = \''.$value."';"); } } // We need these information only once when the test button is hit if (isset($_POST['opCode']) && $_POST['opCode'] == 'IsOpen' ){ // What PHP version log_messages("\nPHP-Version: ".phpversion()); // What OS System is running on log_messages('PHP-OS: '.PHP_OS); // How PHP is installed (CGI, ISAPI, FastCGI) // !!!! Major difference exists on these servers for $_ENV, $_SERVER log_messages('PHP-SAPI-NAME: '.php_sapi_name()); // MySQL, mbstring modules are installed ?! log_messages('PHP-Extensions: '.var_export(get_loaded_extensions(),true)); } if(extension_loaded('mbstring')) { $acceptCharsetHeader = 'Accept-Charset: ' . mb_internal_encoding(); header( $acceptCharsetHeader ); $head = '<html><head><meta http-equiv=\'Content-Type\' content=\'text/html; charset=' . mb_http_output() . '\'></head>'; echo $head; }else{ echo '<html><head></head>'; } // Build connection object if (isset($_POST['Type']) && $_POST['Type'] == 'MYSQL') { require("./mysql.php"); $oConn = new MySqlConnection(@$_POST['ConnectionString'], @$_POST['Timeout'], @$_POST['Host'], @$_POST['Database'], @$_POST['UserName'], @$_POST['Password']); if (!isset($oConn) || $oConn == false){ log_messages("\n".'MySQL Connection Object initialisation failed'."\n\n".@$error); }else{ log_messages("\n".'MySQL Connection Object Created'."\n\n"); } }else{ $error=create_error('The files from the _mmServerScripts folder are for the server model PHP-MySQL. You try to connect to a database using a different server model '.@$_POST['Type'].".\n\nPlease remove this folder outside the Dreamweaver environment on both local and testing machines and try again.",__LINE__); log_messages("\nError Sent:\n\n\t".@$error."\n\n\n"); echo $error.'</HTML>'; return; } // Process opCode if (isset($oConn) && $oConn) { $oConn->Open(); if ($_POST['opCode'] == 'IsOpen'){ $answer = $oConn->TestOpen(); }elseif (is_resource($oConn->connectionId) && $oConn->isOpen){ switch ($_POST['opCode']){ case 'GetTables': $answer = $oConn->GetTables(@$_POST['Database']); break; case 'GetColsOfTable': $answer = $oConn->GetColumnsOfTable(@$_POST['TableName']); break; case 'ExecuteSQL': $answer = $oConn->ExecuteSQL(@$_POST['SQL'], @$_POST['MaxRows']); break; case 'GetODBCDSNs': $answer = $oConn->GetDatabaseList(); break; case 'SupportsProcedure': $answer = $oConn->SupportsProcedure(); break; case 'GetProviderTypes': $answer = $oConn->GetProviderTypes(); break; case 'GetViews': $answer = $oConn->GetViews(); break; case 'GetProcedures': $answer = $oConn->GetProcedures(); break; case 'GetParametersOfProcedure': $answer = $oConn->GetParametersOfProcedure(@$_POST['ProcName']); break; case 'ReturnsResultset': $answer = $oConn->ReturnsResultSet($_POST['RRProcName']); break; case 'ExecuteSP': $answer = $oConn->ExecuteSP(@$_POST['ExecProcName'], 0, @$_POST['ExecProcParameters']); break; case 'GetKeysOfTable': $answer = $oConn->GetPrimaryKeysOfTable(@$_POST['TableName']); break; default: $answer = create_error('The \''.$_POST['opCode'].'\' command is not supported.'); break; } } $oConn->Close(); }else{ $answer = create_error('The Connection Module was not initialized properly for an unknown reason.'); } log_messages("\nAnswer From Database:\n\n\t".@$answer."\n\n\n"); echo $answer; echo '</html>'; ?>

_mmServerScripts/mysql.php

<?php // If this file is not included from the MMHTTPDB possible hacking problem. if (!function_exists('create_error')){ die(); } define('MYSQL_NOT_EXISTS', create_error("Your PHP server doesn't have the MySQL module loaded or you can't use the mysql_(p)connect functions.")); define('CONN_NOT_OPEN_GET_TABLES', create_error('The Connection could not be opened when trying to retrieve the tables.')); define('CONN_NOT_OPEN_GET_DB_LIST', create_error('The Connection could not be opened when trying to retrieve the database list.')); if (!function_exists('mysql_connect') || !function_exists('mysql_pconnect') || !extension_loaded('mysql')){ echo MYSQL_NOT_EXISTS; die(); } // Now let's handle the crashes or any other PHP errors that we can catch function KT_ErrorHandler($errno, $errstr, $errfile, $errline) { global $f, $already_sent; $errortype = array ( 1 => "Error", 2 => "Warning", 4 => "Parsing Error", 8 => "Notice", 16 => "Core Error", 32 => "Core Warning", 64 => "Compile Error", 128 => "Compile Warning", 256 => "User Error", 512 => "User Warning", 1024=> "User Notice", 2048=> "E_ALL", 2049=> "PHP5 E_STRICT" ); $str = sprintf("[%s]\n%s:\t%s\nFile:\t\t'%s'\nLine:\t\t%s\n\n", date('d-m-Y H:i:s'),(isset($errortype[@$errno])?$errortype[@$errno]:('Unknown '.$errno)),@$errstr,@$errfile,@$errline); if (error_reporting() != 0) { @fwrite($f, $str); if (@$errno == 2 && isset($already_sent) && !$already_sent==true){ $error = '<ERRORS>'."\n"; $error .= '<ERROR><DESCRIPTION>An Warning Type error appeared. The error is logged into the log file.</DESCRIPTION></ERROR>'."\n"; $error .= '</ERRORS>'."\n"; $already_sent = true; echo $error; } } } if ($debug_to_file){ $old_error_handler = set_error_handler("KT_ErrorHandler"); } class MySqlConnection { /* // The 'var' keyword is deprecated in PHP5 ... we will define these variables at runtime. var $isOpen; var $hostname; var $database; var $username; var $password; var $timeout; var $connectionId; var $error; */ function MySqlConnection($ConnectionString, $Timeout, $Host, $DB, $UID, $Pwd) { $this->isOpen = false; $this->timeout = $Timeout; $this->error = ''; if( $Host ) { $this->hostname = $Host; } elseif( preg_match("/host=([^;]+);/", $ConnectionString, $ret) ) { $this->hostname = $ret[1]; } if( $DB ) { $this->database = $DB; } elseif( preg_match("/db=([^;]+);/", $ConnectionString, $ret) ) { $this->database = $ret[1]; } if( $UID ) { $this->username = $UID; } elseif( preg_match("/uid=([^;]+);/", $ConnectionString, $ret) ) { $this->username = $ret[1]; } if( $Pwd ) { $this->password = $Pwd; } elseif( preg_match("/pwd=([^;]+);/", $ConnectionString, $ret) ) { $this->password = $ret[1]; } } function Open() { $this->connectionId = mysql_connect($this->hostname, $this->username, $this->password); if (isset($this->connectionId) && $this->connectionId && is_resource($this->connectionId)) { $this->isOpen = ($this->database == "") ? true : mysql_select_db($this->database, $this->connectionId); } else { $this->isOpen = false; } } function TestOpen() { return ($this->isOpen) ? '<TEST status=true></TEST>' : $this->HandleException(); } function Close() { if (is_resource($this->connectionId) && $this->isOpen) { if (mysql_close($this->connectionId)) { $this->isOpen = false; unset($this->connectionId); } } } function GetTables($table_name = '') { $xmlOutput = ""; if ($this->isOpen && isset($this->connectionId) && is_resource($this->connectionId)){ // 1. mysql_list_tables and mysql_tablename are deprecated in PHP5 // 2. For backward compatibility GetTables don't have any parameters if ($table_name === ''){ $table_name = @$_POST['Database']; } //added backtick for handling reserved words and special characters //http://dev.mysql.com/doc/refman/5.0/en/legal-names.html $sql = ' SHOW TABLES FROM ' . $this->ensureTicks($table_name) ; $results = mysql_query($sql, $this->connectionId) or $this->HandleException(); $xmlOutput = "<RESULTSET><FIELDS>"; // Columns are referenced by index, so Schema and // Catalog must be specified even though they are not supported $xmlOutput .= '<FIELD><NAME>TABLE_CATALOG</NAME></FIELD>'; // column 0 (zero-based) $xmlOutput .= '<FIELD><NAME>TABLE_SCHEMA</NAME></FIELD>'; // column 1 $xmlOutput .= '<FIELD><NAME>TABLE_NAME</NAME></FIELD>'; // column 2 $xmlOutput .= "</FIELDS><ROWS>"; if (is_resource($results) && mysql_num_rows($results) > 0){ while ($row = mysql_fetch_array($results)){ $xmlOutput .= '<ROW><VALUE/><VALUE/><VALUE>' . $row[0]. '</VALUE></ROW>'; } } $xmlOutput .= "</ROWS></RESULTSET>"; } return $xmlOutput; } function GetViews() { // not supported return "<RESULTSET><FIELDS></FIELDS><ROWS></ROWS></RESULTSET>"; } function GetProcedures() { // not supported return "<RESULTSET><FIELDS></FIELDS><ROWS></ROWS></RESULTSET>"; } function GetColumnsOfTable($TableName) { $xmlOutput = ""; //added backtick for handling reserved words and special characters //http://dev.mysql.com/doc/refman/5.0/en/legal-names.html $query = "DESCRIBE ".$this->ensureTicks($TableName); $result = mysql_query($query) or $this->HandleException(); if ($result) { $xmlOutput = "<RESULTSET><FIELDS>"; // Columns are referenced by index, so Schema and // Catalog must be specified even though they are not supported $xmlOutput .= "<FIELD><NAME>TABLE_CATALOG</NAME></FIELD>"; // column 0 (zero-based) $xmlOutput .= "<FIELD><NAME>TABLE_SCHEMA</NAME></FIELD>"; // column 1 $xmlOutput .= "<FIELD><NAME>TABLE_NAME</NAME></FIELD>"; // column 2 $xmlOutput .= "<FIELD><NAME>COLUMN_NAME</NAME></FIELD>"; $xmlOutput .= "<FIELD><NAME>DATA_TYPE</NAME></FIELD>"; $xmlOutput .= "<FIELD><NAME>IS_NULLABLE</NAME></FIELD>"; $xmlOutput .= "<FIELD><NAME>COLUMN_SIZE</NAME></FIELD>"; $xmlOutput .= "</FIELDS><ROWS>"; // The fields returned from DESCRIBE are: Field, Type, Null, Key, Default, Extra while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $xmlOutput .= "<ROW><VALUE/><VALUE/><VALUE/>"; // Separate type from size. Format is: type(size) if (preg_match("/(.*)\((.*)\)/", $row["Type"], $ret)) { $type = $ret[1]; $size = $ret[2]; } else { $type = $row["Type"]; $size = ""; } // MySQL sets nullable to "YES" or "", so we need to set "NO" $null = $row["Null"]; if ($null == "") $null = "NO"; $xmlOutput .= "<VALUE>" . $row["Field"] . "</VALUE>"; $xmlOutput .= "<VALUE>" . $type . "</VALUE>"; $xmlOutput .= "<VALUE>" . $null . "</VALUE>"; $xmlOutput .= "<VALUE>" . $size . "</VALUE></ROW>"; } mysql_free_result($result); $xmlOutput .= "</ROWS></RESULTSET>"; } return $xmlOutput; } function GetParametersOfProcedure($ProcedureName, $SchemaName, $CatalogName) { // not supported on MySQL return '<RESULTSET><FIELDS></FIELDS><ROWS></ROWS></RESULTSET>'; } function ExecuteSQL($aStatement, $MaxRows) { if ( get_magic_quotes_gpc() ) { $aStatement = stripslashes( $aStatement ) ; } $xmlOutput = ""; $result = mysql_query($aStatement) or $this->HandleException(); if (isset($result) && is_resource($result)) { $xmlOutput = "<RESULTSET><FIELDS>"; $fieldCount = mysql_num_fields($result); for ($i=0; $i < $fieldCount; $i++) { $meta = mysql_fetch_field($result); if ($meta) { $xmlOutput .= '<FIELD'; $xmlOutput .= ' type="' . $meta->type; $xmlOutput .= '" max_length="' . $meta->max_length; $xmlOutput .= '" table="' . $meta->table; $xmlOutput .= '" not_null="' . $meta->not_null; $xmlOutput .= '" numeric="' . $meta->numeric; $xmlOutput .= '" unsigned="' . $meta->unsigned; $xmlOutput .= '" zerofill="' . $meta->zerofill; $xmlOutput .= '" primary_key="' . $meta->primary_key; $xmlOutput .= '" multiple_key="'. $meta->multiple_key; $xmlOutput .= '" unique_key="' . $meta->unique_key; $xmlOutput .= '"><NAME>' . $meta->name; $xmlOutput .= '</NAME></FIELD>'; } } $xmlOutput .= "</FIELDS><ROWS>"; $row = mysql_fetch_assoc($result); for ($i=0; $row && ($i < $MaxRows); $i++) { $xmlOutput .= "<ROW>"; foreach ($row as $key => $value) { $xmlOutput .= "<VALUE>"; $xmlOutput .= htmlspecialchars($value); $xmlOutput .= "</VALUE>"; } $xmlOutput .= "</ROW>"; $row = mysql_fetch_assoc($result); } mysql_free_result($result); $xmlOutput .= "</ROWS></RESULTSET>"; } return $xmlOutput; } function GetProviderTypes() { return '<RESULTSET><FIELDS></FIELDS><ROWS></ROWS></RESULTSET>'; } function ExecuteSP($aProcStatement, $TimeOut, $Parameters) { return '<RESULTSET><FIELDS></FIELDS><ROWS></ROWS></RESULTSET>'; } function ReturnsResultSet($ProcedureName) { return '<RETURNSRESULTSET status=false></RETURNSRESULTSET>'; } function SupportsProcedure() { return '<SUPPORTSPROCEDURE status=false></SUPPORTSPROCEDURE>'; } /* * HandleException added by InterAKT for ease in database translation answer */ function HandleException() { global $debug_to_file, $f; $this->error = create_error(' MySQL Error#: '. ((int)mysql_errno()) . "\n\n".mysql_error()); log_messages($this->error); die($this->error.'</HTML>'); } function ensureTicks($inputSQL) { $outSQL = $inputSQL; //added backtick for handling reserved words and special characters //http://dev.mysql.com/doc/refman/5.0/en/legal-names.html //only add ticks if not already there $oLength = strlen($outSQL); $bHasTick = false; if (($oLength > 0) && (($outSQL[0] == "`") && ($outSQL[$oLength-1] == "`"))) { $bHasTick = true; } if ($bHasTick == false) { $outSQL = "`".$outSQL."`"; } return $outSQL; } function GetDatabaseList() { $xmlOutput = '<RESULTSET><FIELDS><FIELD><NAME>NAME</NAME></FIELD></FIELDS><ROWS>'; if (isset($this->connectionId) && is_resource($this->connectionId)){ $dbList = mysql_list_dbs($this->connectionId); while ($row = mysql_fetch_object($dbList)) { $xmlOutput .= '<ROW><VALUE>' . $row->Database . '</VALUE></ROW>'; } }else{ $this->error = CONN_NOT_OPEN_GET_DB_LIST; return $this->error; } $xmlOutput .= '</ROWS></RESULTSET>'; return $xmlOutput; } function GetPrimaryKeysOfTable($TableName) { $xmlOutput = ''; //added backtick for handling reserved words and special characters //http://dev.mysql.com/doc/refman/5.0/en/legal-names.html $query = "DESCRIBE ".$this->ensureTicks($TableName); $result = mysql_query($query) or $this->HandleException(); if ($result) { $xmlOutput = '<RESULTSET><FIELDS>'; // Columns are referenced by index, so Schema and // Catalog must be specified even though they are not supported $xmlOutput .= '<FIELD><NAME>TABLE_CATALOG</NAME></FIELD>'; // column 0 (zero-based) $xmlOutput .= '<FIELD><NAME>TABLE_SCHEMA</NAME></FIELD>'; // column 1 $xmlOutput .= '<FIELD><NAME>TABLE_NAME</NAME></FIELD>'; // column 2 $xmlOutput .= '<FIELD><NAME>COLUMN_NAME</NAME></FIELD>'; $xmlOutput .= '<FIELD><NAME>DATA_TYPE</NAME></FIELD>'; $xmlOutput .= '<FIELD><NAME>IS_NULLABLE</NAME></FIELD>'; $xmlOutput .= '<FIELD><NAME>COLUMN_SIZE</NAME></FIELD>'; $xmlOutput .= '</FIELDS><ROWS>'; // The fields returned from DESCRIBE are: Field, Type, Null, Key, Default, Extra while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { if (strtoupper($row['Key']) == 'PRI'){ $xmlOutput .= '<ROW><VALUE/><VALUE/><VALUE/>'; // Separate type from size. Format is: type(size) if (preg_match("/(.*)\((.*)\)/", $row['Type'], $ret)) { $type = $ret[1]; $size = $ret[2]; } else { $type = $row['Type']; $size = ''; } // MySQL sets nullable to "YES" or "", so we need to set "NO" $null = $row['Null']; if ($null == '') $null = 'NO'; $xmlOutput .= '<VALUE>' . $row['Field'] . '</VALUE>'; $xmlOutput .= '<VALUE>' . $type . '</VALUE>'; $xmlOutput .= '<VALUE>' . $null . '</VALUE>'; $xmlOutput .= '<VALUE>' . $size . '</VALUE></ROW>'; } } mysql_free_result($result); $xmlOutput .= '</ROWS></RESULTSET>'; } return $xmlOutput; } } // class MySqlConnection ?>


Espero que você gostem e tambem melhore ele...

Abraço para a equipe CodigonaWeb.com
0
Web site:
www.webradiogratis.com

Cadastro:
http://auth.webradiogratis.com/index.php

Comunidade Codigos na Web
http://www.orkut.com.br/Main#Community?cmm=94905489

Acessem a comunidade do codigos na web no orkut...
 
Avatar do usuário
ADMIN
ADMIN
Mensagens: 17563
Nome: Kleber
Descrição do site: Onde você encontra scripts grátis para o seu site
Sexo: Masculino
Localização: RJ / RJ / Brasil
Contato:

Top 10 - com Administração

25-06-2009 15:06

Boa, uma vez postei só uma base, mas esse parece ser completo. Estarei testando em breve. :)
0
A melhor hospedagem para o seu site HostGator!

Quem está online

Usuários navegando neste fórum: Nenhum usuário registrado