|
|
|
|
|
|
IT Security and Insecurity Portal |
|
|
plz see thes code |
|
Posted: Thu Mar 26, 2009 12:19 pm |
|
|
e4s |
Beginner |
|
|
Joined: Mar 26, 2009 |
Posts: 1 |
|
|
|
|
|
|
|
|
Last edited by e4s on Mon Mar 30, 2009 9:29 pm; edited 1 time in total |
|
|
|
|
|
|
|
Posted: Fri Mar 27, 2009 8:51 am |
|
|
zerobytes |
Valuable expert |
|
|
Joined: Aug 30, 2008 |
Posts: 199 |
|
|
|
|
|
|
|
Code: |
<?
define("EZSQL_VERSION","1.01");
define("OBJECT","OBJECT",true);
define("ARRAY_A","ARRAY_A",true);
define("ARRAY_N","ARRAY_N",true);
class db {
function db($dbuser,$dbpassword,$dbname,$dbhost)
{
$this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword);
if ( !$this->dbh )
{
$this->print_error("<ol><b>Error establishing a database connection!</b><li>Are you sure you have the correct user/password?<li>Are you sure that you have typed the correct hostname?<li>Are you sure that the database server is running?</ol>");
}
$this->select($dbname);
}
function select($db)
{
if ( !@mysql_select_db($db,$this->dbh))
{
$this->print_error("<ol><b>Error selecting database <u>$db</u>!</b><li>Are you sure it exists?<li>Are you sure there is a valid database connection?</ol>");
}
}
function print_error($str = "")
{
if ( !$str ) $str = mysql_error();
print "<blockquote><font face=arial size=2 color=ff0000>";
print "<b>SQL/DB Error --</b> ";
print "[<font color=000077>$str</font>]";
print "</font></blockquote>";
}
public function query($sql)
{
$this->resultlink = mysql_query($sql);
return $this->resultlink;
}
function RecordCount ( $query )
{
return mysql_num_rows ( mysql_query ( $query ) );
}
function Mresult ( $query,$a,$b )
{
return mysql_result ( mysql_query ( $query ),$a,$b );
}
function qstr ( $string,$magic_quotes = false )
{
if (!$magic_quotes) {
if (strnatcmp(PHP_VERSION,'4.3.0') >= 0) {
return "'".mysql_real_escape_string($string) ."'";
}
$string = str_replace("'","\\'",str_replace('\\','\\\\',str_replace("\0","\\\0",$string)));
return "'".$string ."'";
}
return "'".str_replace('\\"','"',$string) ."'";
}
function get_var($query=null,$x=0,$y=0)
{
$this->func_call = "\$db->get_var(\"$query\",$x,$y)";
if ( $query )
{
$this->query($query);
}
if ( $this->last_result[$y] )
{
$values = array_values(get_object_vars($this->last_result[$y]));
}
return $values[$x]?$values[$x]:null;
}
public function fetch_rows($result) {
$rows = array();
if($result) {
while($row = mysql_fetch_array($result)) {
$rows[] = $row;
}
}
else {
$rows = null;
}
return $rows;
}
function get_col($query=null,$x=0)
{
if ( $query )
{
$this->query($query);
}
for ( $i=0;$i <count($this->last_result);$i++)
{
$new_array[$i] = $this->get_var(null,$x,$i);
}
return $new_array;
}
function get_results($query=null,$output = OBJECT)
{
$this->func_call = "\$db->get_results(\"$query\", $output)";
if ( $query )
{
$this->query($query);
}
if ( $output == OBJECT )
{
return $this->last_result;
}
elseif ( $output == ARRAY_A ||$output == ARRAY_N )
{
if ( $this->last_result )
{
$i=0;
foreach( $this->last_result as $row )
{
$new_array[$i] = get_object_vars($row);
if ( $output == ARRAY_N )
{
$new_array[$i] = array_values($new_array[$i]);
}
$i++;
}
return $new_array;
}
else
{
return null;
}
}
}
function get_col_info($info_type="name",$col_offset=-1)
{
if ( $this->col_info )
{
if ( $col_offset == -1 )
{
$i=0;
foreach($this->col_info as $col )
{
$new_array[$i] = $col->{$info_type};
$i++;
}
return $new_array;
}
else
{
return $this->col_info[$col_offset]->{$info_type};
}
}
}
function vardump($mixed)
{
echo "<blockquote><font color=000090>";
echo "<pre><font face=arial>";
if ( !$this->vardump_called )
{
echo "<font color=800080><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Variable Dump..</b></font>\n\n";
}
print_r($mixed);
echo "\n\n<b>Last Query:</b> ".($this->last_query?$this->last_query:"NULL")."\n";
echo "<b>Last Function Call:</b> ".($this->func_call?$this->func_call:"None")."\n";
echo "<b>Last Rows Returned:</b> ".count($this->last_result)."\n";
echo "</font></pre></font></blockquote>";
echo "\n<hr size=1 noshade color=dddddd>";
$this->vardump_called = true;
}
function dumpvars($mixed)
{
$this->vardump($mixed);
}
function debug()
{
echo "<blockquote>";
if ( !$this->debug_called )
{
echo "<font color=800080 face=arial size=2><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Debug..</b></font><p>\n";
}
echo "<font face=arial size=2 color=000099><b>Query --</b> ";
echo "[<font color=000000><b>$this->last_query</b></font>]</font><p>";
echo "<font face=arial size=2 color=000099><b>Query Result..</b></font>";
echo "<blockquote>";
if ( $this->col_info )
{
echo "<table cellpadding=5 cellspacing=1 bgcolor=555555>";
echo "<tr bgcolor=eeeeee><td nowrap valign=bottom><font color=555599 face=arial size=2><b>(row)</b></font></td>";
for ( $i=0;$i <count($this->col_info);$i++)
{
echo "<td nowrap align=left valign=top><font size=1 color=555599 face=arial>{$this->col_info[$i]->type} {$this->col_info[$i]->max_length}<br><font size=2><b>{$this->col_info[$i]->name}</b></font></td>";
}
echo "</tr>";
if ( $this->last_result )
{
$i=0;
foreach ( $this->get_results(null,ARRAY_N) as $one_row )
{
$i++;
echo "<tr bgcolor=ffffff><td bgcolor=eeeeee nowrap align=middle><font size=2 color=555599 face=arial>$i</font></td>";
foreach ( $one_row as $item )
{
echo "<td nowrap><font face=arial size=2>$item</font></td>";
}
echo "</tr>";
}
}
else
{
echo "<tr bgcolor=ffffff><td colspan=".(count($this->col_info)+1)."><font face=arial size=2>No Results</font></td></tr>";
}
echo "</table>";
}
else
{
echo "<font face=arial size=2>No Results</font>";
}
echo "</blockquote></blockquote><hr noshade color=dddddd size=1>";
$this->debug_called = true;
}
}
?>
|
Enjoy
ZeroBytes |
|
|
|
|
|
www.waraxe.us Forum Index -> PHP script decode requests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT
Page 1 of 1
|
|
|
Powered by phpBB © 2001-2008 phpBB Group
|
|
|
|
|